$.fn.clearForm = function() {
	return this.each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form') 
			return $(':input',this).clearForm();
		if (type == 'text' || type == 'password' || tag == 'textarea')
			this.value = '';
		else if (type == 'checkbox' || type == 'radio')
			this.checked = false;
		else if (tag == 'select')
			this.selectedIndex = -1;
	});
};

$.extend({  
	getUrlVars: function(){    
		var vars = [], hash;    
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');    
		for(var i = 0; i < hashes.length; i++) {      
			hash = hashes[i].split('=');      
			vars.push(hash[0]);      
			vars[hash[0]] = hash[1];    
		}    
		return vars;  
	},  getUrlVar: function(name){    
		return $.getUrlVars()[name];  
	}
});


$(document).ready(function() {
	function megaHoverOver(){
		$(this).find(".sub").stop(true,true).fadeTo('fast', 1).show().siblings("a").css({'background-position': "bottom left", 'z-index':'3999'});
		$(this).find(".first-sub").stop(true,true).fadeTo('fast', 1).siblings("a").css({'background-position': "bottom left", 'z-index':'3999'});
		$(this).find("#locator-sub").stop(true,true).fadeTo('fast', 1).siblings("a").css({'background-position': "bottom left", 'z-index':'3999'});
//		$(this).find("a").css({'background-position': "bottom left", 'z-index':'3999'});
	}

	function megaHoverOut(){ 
		$(this).find(".sub").stop().slideUp('fast', function() {
			$(this).hide().siblings("a").css({'background-position': "top left", 'z-index':'2999'}); 
		}).end();
		$(this).find(".first-sub").stop().slideUp('fast', function() {
			$(this).hide().siblings("a").css({'background-position': "top left", 'z-index':'2999'}); 
		}).end();
		$(this).find("#locator-sub").stop().slideUp('fast', function() {
			$(this).hide().siblings("a").css({'background-position': "top left", 'z-index':'2999'});  
		}).end();
//		$(this).find("a").css({'background-position': "top left", 'z-index':'2999'});
	}

	function megaHoverOver1(){
		requestXmlGET3('shopping_cart_op.php', 'pdisplay=disp_mini_cart', '#mini_cart_section', '', 98);
		$(this).find(".sub").stop(true,true).fadeTo('fast', 1).show().siblings("a").css({'background-position': "bottom left", 'z-index':'3999'});
	}

	function megaHoverOut1(){ 
		$(this).find(".sub").stop().slideUp('fast', function() {
			$(this).hide().siblings("a").css({'background-position': "top left", 'z-index':'2999'}); 
		}).end();
	}

	var config = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 50, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
		 timeout: 50, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
	};

/*	$("ul#topnav li .sub").css({'opacity':'0'}); */
	$("ul#topnav li").hoverIntent(config);
	$("ul#login-menu li.regular").hoverIntent(config);
	
	
	var config1 = {    
		 sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
		 interval: 50, // number = milliseconds for onMouseOver polling interval    
		 over: megaHoverOver1, // function = onMouseOver callback (REQUIRED)    
		 timeout: 50, // number = milliseconds delay before onMouseOut    
		 out: megaHoverOut1 // function = onMouseOut callback (REQUIRED)    
	};
	$("ul#login-menu li.shopcart").hoverIntent(config1);
/*
	$("ul#login-menu li").hover(function() {
		$(this).find(".sub").stop().slideDown('fast').show().siblings("a").css({'background-position': "bottom left", 'z-index':'3999'});
	}, function() {
		$(this).hide().siblings("a").css({'background-position': "top left", 'z-index':'2999'}); 
	});
*/	

    //ACCORDION BUTTON ACTION (ON CLICK DO THE FOLLOWING)
	$('.product-cat').click(function() {

		//REMOVE THE ON CLASS FROM ALL BUTTONS
		$('.product-cat').removeClass('on');
		  
		//NO MATTER WHAT WE CLOSE ALL OPEN SLIDES
	 	$('.product-sub').slideUp('normal');
   
		//IF THE NEXT SLIDE WASN'T OPEN THEN OPEN IT
		if($(this).next().is(':hidden') == true) {
			
			//ADD THE ON CLASS TO THE BUTTON
			$(this).addClass('on');
			  
			//OPEN THE SLIDE
			$(this).next().slideDown('normal');
		 } 
		  
	 });
	
	/********************************************************************************************************************
	CLOSES ALL S ON PAGE LOAD
	********************************************************************************************************************/	
	$('.product-sub:not(.on)').hide();
	
    $(".expand").show();
    $(".expand-h3").click(function() {
		$(this).toggleClass("active").next().slideToggle("fast");
    });
	
	$(".box expand-2").hide(); 

	$(".expand-h4").click(function(){
		$(this).toggleClass("active").next().slideToggle("fast");
		return false; //Prevent the browser jump to the link anchor
    });
	
	$(".expand-3").hide(); 
    $(".expand-3:first").show(); 
	
	$(".expand-span").click(function(){
		$(this).toggleClass("active").next().slideToggle("fast");
		return false; 
		//Prevent the browser jump to the link anchor
    });
	
	$("ul.sf-menu").superfish({ 
		autoArrows:  false,                           // disable generation of arrow mark-up 
		delay:         600,
		animation	: {scrollDown:'show'},
//		pathClass:  'current', 
		dropShadows: false
	}); 
	
	$(".product-list li").hover(function() {$(this).css({'background-color':'#EEEEEE'});},
	function() {$(this).css({'background-color':'#FFFFFF'});})


	/********************************************************************************************************************
	Initial for footer
	********************************************************************************************************************/	
	$('#slidepress').cycle({ fx: 'scrollDown', timeout: 3000, cleartype: 1, speed: 400 });

});

