jQuery(document).ready(function($) {
	// Dropdown menu on click.
	$('#NavBar_MenuExpand_Button').click(function() {
		if ($('#NavBar_MenuExpand nav').length > 0) {
			$('#NavBar_MenuExpand nav').toggle();

			if ($('#NavBar_MenuExpand nav').css('display') == 'block') {
				$('#NavBar_MenuExpand_Button').html('&#8722;');
			} else {
				$('#NavBar_MenuExpand_Button').html('+');
			}
		} else {
			$('#container footer').toggle();

			if ($('#container footer').css('display') == 'block') {
				$('#NavBar_MenuExpand_Button').html('&#8722;');
			} else {
				$('#NavBar_MenuExpand_Button').html('+');
			}
		}
		
		return false;
	});
	
	// Navbar Marquee
	$('#NavBar_Marquee').SetScroller({
		velocity:			70,
		direction:		'horizontal',
		startfrom:		'right',
		loop:					'infinite',
		movetype:			'linear',
		onmouseover:	'play',
		onmouseout:		'play',
		onstartup:		'play',
		cursor:				'pointer'
	});
	
	// Make the blank area of the marquee still clickable.
	$('#NavBar_Marquee').click(function(e) {
		if ($(this).find('a').length > 0) {		
			window.location = $(this).find('a').first().attr('href');
		}
	});
	
	
	// Emulate placeholder support.
	if (!Modernizr.input.placeholder) {
		$("input").each(function() {
			if ($(this).val() == "" && $(this).attr("placeholder") != "") {
				$(this).val($(this).attr("placeholder"));

				$(this).focus(function() {
					if ($(this).val() == $(this).attr("placeholder")) $(this).val("");
				});

				$(this).blur(function() {
					if ($(this).val() == "") $(this).val($(this).attr("placeholder"));
				});
			}
		});
	}
	
	// Copy category nav into place if appropriate.
	if ($('#Sidebar_Categories').length && $('#CategoryNavHidden').length) {
		$('#Sidebar_Categories nav ul').html($('#CategoryNavHidden ul').html());
	}

	// Copy cart status into place if appropriate.
	if ($('#Sidebar_Shop').length && $('#CartStatusHidden').length) {
		$('#Sidebar_Shop nav ul').html($('#CartStatusHidden ul').html());
	}
	
	// Copy top sellers into place if appropriate.
	if ($('#Sidebar_Popular').length && $('#TopSellersHidden').length) {
		if ($('#TopSellersHidden ul').html().replace(/\s/g,'') != "") {
			$('#Sidebar_Popular nav ul').html($('#TopSellersHidden ul').html());
		}
	}
	
	// Copy cart summary into place if appropriate.
	if ($('#Sidebar_Cart_Summary').length && $('#CartSummaryHidden').length) {
		$('#Sidebar_Cart_Summary').html($('#CartSummaryHidden').html());
	}
});

// Will Hover
if(typeof Prototype!=='undefined'){document.observe("dom:loaded",function(){$$('.will_hover').each(function(el,index){Event.observe(el,'mouseover',function(){var ext=this.src.split('.').reverse().first();this.src=this.src.replace('.'+ext,'-hover.'+ext);});Event.observe(el,'mouseout',function(){var ext=this.src.split('.').reverse().first();this.src=this.src.replace('-hover.'+ext,'.'+ext);});});$$('.will_hover_bg').each(function(el,index){Event.observe(el,'mouseover',function(){var ext=this.getStyle('background-image').replace(/^url\(/,'').replace(/\)$/,'').split('.').reverse().first();this.setStyle({backgroundImage:this.getStyle('background-image').replace('.'+ext,'-hover.'+ext)});});Event.observe(el,'mouseout',function(){var ext=this.getStyle('background-image').replace(/^url\(/,'').replace(/\)$/,'').split('.').reverse().first();this.setStyle({backgroundImage:this.getStyle('background-image').replace('-hover.'+ext,'.'+ext)});});});});}else if(typeof jQuery!=='undefined'){jQuery(document).ready(function($){$('.will_hover').bind({mouseover:function(){var ext=this.src.split('.').reverse();ext=ext[0];this.src=this.src.replace('.'+ext,'-hover.'+ext);},mouseout:function(){var ext=this.src.split('.').reverse();ext=ext[0];this.src=this.src.replace('-hover.'+ext,'.'+ext);}});$('.will_hover_bg').bind({mouseover:function(){var ext=$(this).css('background-image').replace(/^url\(/,'').replace(/\)$/,'').split('.').reverse();ext=ext[0];$(this).css({'background-image':$(this).css('background-image').replace('.'+ext,'-hover.'+ext)});},mouseout:function(){var ext=$(this).css('background-image').replace(/^url\(/,'').replace(/\)$/,'').split('.').reverse();ext=ext[0];$(this).css({'background-image':$(this).css('background-image').replace('-hover.'+ext,'.'+ext)});}});});}else{alert('will_hover.js requires Prototype or jQuery.');}
