function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
}




$(document).ready(function(){


	
// HOVER
	$("#topNav a, .sub a").hover( 
		// over
		function(){
			var theImg = $(this).find('img:first');
			// store the original image src
			theImg.data( "originalsrc" , theImg.attr("src") );
			
			// add -over to the image unless it is already -over
			if (!theImg.attr("src").match(/-over/) ) {
				theImg.attr( "src", theImg.attr("src").replace(/\./, "-over.") );
			}
			
		},
		
		// out
		function(){
			var theImg = $(this).find('img:first');
			// replace the original src
			theImg.attr("src", theImg.data("originalsrc")).data("originalsrc", null);
		}
	);
	
	//On Hover Over
	function megaHoverOver(){
 	   $(this).find(".sub").stop().fadeTo('fast', 1).show(); //Find sub and fade it in
    
	}
	//On Hover Out
	function megaHoverOut(){
	  $(this).find(".sub").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy
      $(this).hide();  //after fading, hide it
  	});
	}


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

//	$("ul#mainNav li .sub").css({'opacity':'0'}); //Fade sub nav to 0 opacity on default
	$("ul#mainNav li").hoverIntent(config); //Trigger Hover intent with custom configurations
	
	



// Cookie set for Age Verify

	$("#yes").click(function(e){
		e.preventDefault;
		document.cookie = 'legal=1; path=/';
		$("#overlay").fadeOut();
		return false;
	});


// Contact Form Serialize

	$("#contactForm.contactForm").submit(function(e){
                var $this = $(this);

              

                var $emailField = $this.find("input[name=reale]");
                if ((!$emailField.attr('value')) || ($emailField.attr('value') == 'Email Address'))
                        {
                                alert('Please enter your Email.');
                                $emailField.focus();
                                return false;
                        }

                var params = $this.serialize();
                
				$.post("/cgi-bin/contact.cgi", params,
                        function(data){
                        $this.find(".button").fadeOut('slow', function(){
                                $this.find(".formText").attr('value', '');
                                $this.find(".button").after(data);
                                $("#response").fadeIn('slow');
                        });

                        setTimeout(function(){
                                        $("#response").fadeOut('slow',function(){
                                                $("#response").remove();
                                                $this.find(".button").fadeIn('slow');
                                        });
                                }, 5000);

                });
				
				pageTracker._trackPageview('/action/customer_comment');
                return false;

        });



// Form Value Togglign

	$(".formText").toggleVal();

// track blog comments
$("#commentform").submit(function(){
	pageTracker._trackPageview('/action/blog_comment');
	return true;
});
	
	

}); // end document ready

// <![CDATA[

			function CheckMultiple1(frm, name) {
				for (var i=0; i < frm.length; i++)
				{
					fldObj = frm.elements[i];
					fldId = fldObj.id;
					if (fldId) {
						var fieldnamecheck=fldObj.id.indexOf(name);
						if (fieldnamecheck != -1) {
							if (fldObj.checked) {
								return true;
							}
						}
					}
				}
				return false;
			}
		function CheckForm1(f) {
			var email_re = /[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i;
			if (!email_re.test(f.email.value)) {
				alert("Please enter your email address.");
				f.email.focus();
				return false;
			}
		
					lists_chosen = CheckMultiple1(f, "lists");
					if (!lists_chosen) {
						alert("Please choose some contact lists to subscribe to");
						return false;
					}
				
					lists_chosen = CheckMultiple1(f, "lists");
					if (!lists_chosen) {
						alert("Please choose some contact lists to subscribe to");
						return false;
					}
				
				return true;
			}
		
// ]]>



window.onload = function() {
		// preload
		$("#topNav img, .sub img").each(
			function() {
				if (!$(this).attr("src").match(/-over/) ) {
					$("<img>").attr( "src", $(this).attr("src").replace(/\./, "-over.") );
				}
			}
		);
}





