function clearForm(form)
{
    $(":input", form).each(function()
    {
    var type = this.type;
    var tag = this.tagName.toLowerCase();
        if (type == 'text')
        {
        this.value = "";
        }
    });
};


jQuery.inputHighlight = function(color){  
    $("input[type='text'],input[type='file'],input[type='password'],textarea").each(function(){  
        $(this).focus(function(){  
            $(this).css({"background" : color});  
        });  
        $(this).blur(function(){  
            $(this).css({"background" : "white"});  
        });  
    });  
}

$(document).ready(function(){
	$('.vh_hdrNav li#gifts').mouseover(function(){
		$(this).find('ul.sMn').slideDown(200).css('zIndex',1);
	}).mouseleave(function(){
		$(this).find('ul.sMn').slideUp(100);
	});
	$('div.vh_navbar li.items').each(function(){
		if( $(this).attr('offsetHeight') < 28 )
			$(this).css( {'lineHeight':'38px','padding':'0 13px'} );
	});
	
	$('div.vh_navbar li.items:first').css('border',0).find('ul.nNav').css('left','1px');
	
	$('div.vh_navbar li.items').mouseover(function(){
		$(this).addClass('navHover');
		$(this).find('ul.nNav').slideDown(200);
	}).mouseleave(function(){
		$(this).removeClass('navHover');
		$(this).find('ul.nNav').slideUp(150);
	});
	
	$('div.vh_navbar li.items:last').find('ul.nNav').css( {'left':'auto','right':'-1px'} );
	/*$.inputHighlight("#f1fbff"); // form style;*/
	
	
	$('#yahoo_support').mouseover(function(){
		$(this).find('.support_list').slideDown(200);
		$('#vh_searchstatus').css('backgroundPosition','left -70px');
	})
	
	
	$('#phone_support').mouseover(function(){
		$(this).find('.support_list').slideDown(200);
		$('#vh_searchstatus').css('backgroundPosition','left -35px');
	});
	$('#phone_support, #yahoo_support').mouseleave(function(){
		$('.support_list').slideUp(100);
		$('#vh_searchstatus').css('backgroundPosition','left top');
	});
	
	$('#primarymessagewrap').mouseover(function(){		
		$(this).css('zIndex',1);
	}).mouseleave(function(){
		$(this).css('zIndex',0);
	});
	
	$('.pm_center_panel').each(function(){
		$(this).mouseover(function(){
		   	$('.pm_center_panel').css('zIndex',0);
			$(this).css('zIndex',9999);
		});
	});
	
	
	var ads_scroll_right = "#support_scroll";
	var menuYloc_right = null;
	menuYloc_right = parseInt($(ads_scroll_right).css("bottom").substring(0,$(ads_scroll_right).css("bottom").indexOf("px")));
	
	var offset_r = menuYloc_right-$(document).scrollTop()+"px";
	$(ads_scroll_right).animate({bottom:offset_r},{duration:500,queue:false});
	
	$(window).scroll(function () {
		var offset_r = menuYloc_right-$(document).scrollTop()+"px";
		$(ads_scroll_right).animate({bottom:offset_r},{duration:300,queue:false});
	});

	
})





function in_array(string, array){
   for (i = 0; i < array.length; i++){
	  if(array[i] == string){
		 return true;
	  }
   }
	return false;
}

function getCookie(w){
	cName = "";
	pCOOKIES = new Array();
	pCOOKIES = document.cookie.split('; ');
	for(bb = 0; bb < pCOOKIES.length; bb++){
		NmeVal  = new Array();
		NmeVal  = pCOOKIES[bb].split('=');
		if(NmeVal[0] == w){
			cName = unescape(NmeVal[1]);
		}
	}
	return cName;
}
function IsNumeric(input){ 
    var RE = /^-{0,1}\d*\.{0,1}\d+$/; 
    return (RE.test(input)); 
} 

function hashPages(){
	var hs = window.location.hash;
	if( hs != ''){
		hs = hs.replace("#","");
		if( IsNumeric(hs) == true )
			return hs;
		else{
			window.location.hash = 1;
			return 1;
		}
	}
}

function addToCart(id){
	$("#loadding").show();	
	$.post(server+"jquery/?option=com_product", {
		id: id,
		task: 'addToCart'
	},
	function(data) {
		$('.msg_cart_'+id).html(data);
		$('.msg_cart_'+id).slideDown(200);
		setTimeout( '$(\'.msg_cart_'+id+'\').slideUp(200)',2000 );
		$("#loadding").hide('slow');
	});
}
