// JavaScript Document
// Auto-Fill Plugin
// Written by Joe Sak http://www.joesak.com/2008/11/19/a-jquery-function-to-auto-fill-input-fields-and-clear-them-on-click/
(function($){$.fn.autofill=function(options){var defaults={value:'',defaultTextColor:"#CCC",activeTextColor:"#000"};var options=$.extend(defaults,options);return this.each(function(){var obj=$(this);obj.css({color:options.defaultTextColor}).val(options.value).focus(function(){if(obj.val()==options.value){obj.val("").css({color:options.activeTextColor});}}).blur(function(){if(obj.val()==""){obj.css({color:options.defaultTextColor}).val(options.value);}});});};})(jQuery);

$(document).ready(function() {
	function addMega(){
		$(this).find("a.foldout").addClass("foldoutHover");
		$(this).find(".mega").stop().show(); 
	}
	
	function removeMega(){
		$(this).find("a.foldout").removeClass("foldoutHover");
		$(this).find(".mega").stop().hide(); 
	}
	
	var megaConfig = {
		interval: 50,
		sensitivity: 4,
		over: addMega,
		timeout: 50,
		out: removeMega
	};

	$(".sf-menu li").hoverIntent(megaConfig)
});

setCurrency = function(curr) {
	document.location.href="/setCurrency.asp?curr="+curr+"&url="+ escape(document.location)
};
setUnit = function(unt) {
	document.location.href="/setUnit.asp?unit="+unt+"&url="+ escape(document.location)
};
setLanguage = function(lang) {
	document.location.href="/setLanguage.asp?lang="+lang+"&url="+ escape(document.location)
};

delCartItem = function(id,message) {
	if (confirm(message) == true) 
	{
		$('#delet'+id).val('true');
		$('#checkoutform').submit();
	}
};

$.fn.clearForm = function() { return this.each(function() {
		$(this).is('form') && this.reset();
        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 = 0;
		}
    });
};

selectHide = function(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}
selectShow = function(){
	selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}
toggle = function(obj) {
	selectShow();
	var el = document.getElementById(obj);
	el.style.display = (el.style.display != 'none' ? 'none' : '' );
    document.mainform.clientEmail.focus();
}

jQuery.fn.fadeIn = function(speed, callback) { 
    return this.animate({opacity: 'show'}, speed, function() { 
        if (jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 
 
jQuery.fn.fadeOut = function(speed, callback) { 
    return this.animate({opacity: 'hide'}, speed, function() { 
        if (jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 
 
jQuery.fn.fadeTo = function(speed,to,callback) { 
    return this.animate({opacity: to}, speed, function() { 
        if (to == 1 && jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 

setPrices = function() {
	if($('#price').val()==1) {
		$('#pFrom').val('0');
		$('#pTo').val('25');
	} 
	else if($('#price').val()==2) {
		$('#pFrom').val('25');
		$('#pTo').val('37.5');
	}
	else if($('#price').val()==3) {
		$('#pFrom').val('37.5');
		$('#pTo').val('50');
	} 
	else if($('#price').val()==4) {
		$('#pFrom').val('50');
		$('#pTo').val('75');
	}
	else if($('#price').val()==5) {
		$('#pFrom').val('75');
		$('#pTo').val('250');
	} 
};

s4 = function () {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}

guid = function() {
return s4()+s4()+"-"+s4()+"-"+s4()+"-"+s4()+"-"+s4()+s4()+s4();
}