jQuery('document').ready(function(){
	jQuery('form#QuickSearch input[type="text"]').focus(function(){ this.value = ''; });
	jQuery('div#categoryTree ul.level2 li').hover(function(){ jQuery(this).addClass('hover'); }, function(){ jQuery(this).removeClass('hover'); } );
	var changeMe = 0;
	jQuery('ul#TopNav li').hover(
		function(){
			if (jQuery(this).find('img').length > 0)
			{
				changeMe = jQuery(this).find('img').attr('src').indexOf('_off'); 
				jQuery(this).find('img').imgHoverOn();
			}
		}, 
		function(){ 
			if (jQuery(this).find('img').length > 0)
			{
				if (changeMe > 0) jQuery(this).find('img').imgHoverOff();
			}
		}
	);

	jQuery('div.TabbedContainer div.holder img.viewall').hover(function(){jQuery(this).imgHoverOn()}, function(){jQuery(this).imgHoverOff()});
	jQuery('div.TabbedContainer img.learnmore').hover(function(){jQuery(this).imgHoverOn()}, function(){jQuery(this).imgHoverOff()});
	jQuery('div.TabbedContainer div.holder div').hover(function(){ jQuery(this).addClass('hover'); }, function(){ jQuery(this).removeClass('hover'); } );
	jQuery('div.displayItemMerchHome div.displayItemImageMerchHome').hover(function(){ jQuery(this).addClass('hover'); }, function(){ jQuery(this).removeClass('hover'); } );
	jQuery('div.TabbedContainer div.container div.ItemGalleryDisplay div div').hover(function(){ jQuery(this).addClass('hover'); }, function(){ jQuery(this).removeClass('hover'); } );

	/*Cookie Check*/
// remember, these are the possible parameters for Set_Cookie:
// name, value, expires, path, domain, secure
document.cookie = 'cookietest=none';
// if Get_Cookie succeeds, cookies are enabled, since
//the cookie was successfully created.
if ( get_cookie("cookietest") == null )
{
	jQuery('div#nocookie').show();
}
document.cookie = 'cookietest=; expires=Thu, 01-Jan-70 00:00:01 GMT;';

	/* End Cookie Check*/

	/*Accessories page*/
	if( 'radioName' in urlObj ) 
	{
		jQuery('div#Accessories ul#RadioList li#acc' + radioNameToClass(urlObj['radioName']) + ' a').addClass('selected');
		jQuery('div#Accessories div#ImageHolder img.accimage').hide();
		jQuery('div#Accessories div#ImageHolder img.acc' + radioNameToClass(urlObj['radioName'])).show();
	}
	jQuery('div.TabbedContainer img.showmore').hover(function(){jQuery(this).imgHoverOn()}, function(){jQuery(this).imgHoverOff()});
	jQuery('div.TabbedContainer img.showmore').click(
		function()
		{
			var showMore = jQuery(this).attr('src').indexOf('MORE');
			if (showMore > 0)
			{
				jQuery(this).attr('src', jQuery(this).attr('src').replace('MORE', 'LESS'));
				jQuery(this).parent().addClass('expanded');
			}
			else
			{
				jQuery(this).attr('src', jQuery(this).attr('src').replace('LESS', 'MORE'));
				jQuery(this).parent().removeClass('expanded');
			}
		}
	);
	jQuery('div#Accessories div#AccessoriesMerchandisingAreas div#ViewAllAccessoryButton span span').click(
		function()
		{
			jQuery('div.TabbedContainer div.holder.count3').parent().addClass('expanded');
			jQuery('div.TabbedContainer img.showmore').attr('src', jQuery('div.TabbedContainer img.showmore').attr('src').replace('MORE', 'LESS'));
		}
	);
	jQuery('div#Accessories ul#RadioList li').hover(
		function()
		{
			var myParent = "";
			if (jQuery(this).attr('id').length > 0) myParent = jQuery(this).attr('id');
			jQuery('div#Accessories div#ImageHolder img.accimage').hide();
			jQuery('div#Accessories div#ImageHolder img.' + myParent ).show();
		},
		function(){}
	);
});
jQuery.fn.imgHoverOn = function() { 
	jQuery(this).attr('src', jQuery(this).attr('src').replace('_off', '_on')); 
}
jQuery.fn.imgHoverOff = function() { 
	jQuery(this).attr('src', jQuery(this).attr('src').replace('_on', '_off')); 
}
function radioNameToClass(name) 
{ 
	//First unescape since firefox and others encode the value fromt eh query string
	temp = unescape(name);
	//now remove anythign that is not alphanumeric
	return temp.replace(/[^a-zA-Z0-9]+/g,'').toLowerCase();
}


var allcookies = document.cookie;
var flCustLogon = false;
	
var cookieList = allcookies.split("; ");

for(var i=0; i<cookieList.length; i++)
{
	var mycookie = cookieList[i].split("=");
	var mycookieKey = mycookie[0];
	var mycookieVal = mycookie[1];

	if(mycookieKey == "EISESSION_ID")
	{		
		if(!mycookieVal || mycookieVal == "")
		{
			flCustLogon = false;
		}
		else
		{
			flCustLogon = true;
		}
	}
}

var urlObj = new Object();
window.location.search.replace(
	new RegExp( "([^?=&]+)(=([^&]*))?", "g" ),
	function( $0, $1, $2, $3 ){
		urlObj[ $1 ] = $3;
	}
);

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}