$(document).ready(function() {
/* ---------------------------------------------------------- */
// "Begin Button Rollover Effect
/* ---------------------------------------------------------- */
		
	/**************************************************************************************/		   
	/**** BEGIN _ MAIN NAVIGATION MENU ROLLOVER IMAGE/LINK Function - SITE WIDE ***********/
	/**************************************************************************************/
		
		// Preload all rollovers #mainContentLH img,
		$("#mainContentLH img, #mainContentRH img, #hdrRightSectB2 img").each(function() {
			// Set the original src
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.png$/ig,"_over.png");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers #mainContentLH a, #hdrRightSectA a, #hdrRightSectB1 a, #hdrRightSectB2 a, #moreInfoLink a
		$("#mainContentLH a, #mainContentRH a, #hdrRightSectB2 a").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if(!matches) {
				imgsrcON = imgsrc.replace(/.png$/ig,"_over.png"); // strip off extension
				$(this).children("img").attr("src", imgsrcON);
			}		
		});	
		
		$("#mainContentLH a, #mainContentRH a, #hdrRightSectB2 a").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
		$("#mainContentLH a, #mainContentRH a, #hdrRightSectB2 a").click(function(){
			$(this).children("img").attr("src", imgsrc);
		});	
		
	/* ------------------------------------------ */
	// START - GLOBAL "CONTACT_US" BUTTON FUNCTIONs 
	/* --------------------- ----------------------*/
	
		// Preload all rollovers #mainContentLH img,
		$(".contact-btn").each(function() {
			// Set the original src
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.png$/ig,"_over.png");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers #mainContentLH a, #hdrRightSectA a, #hdrRightSectB1 a, #hdrRightSectB2 a, #moreInfoLink a
		$(".contact-btn").mouseover(function(){
			imgsrc = $(this).attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if(!matches) {
				imgsrcON = imgsrc.replace(/.png$/ig,"_over.png"); // strip off extension
				$(this).attr("src", imgsrcON);
			}		
		});	
		
		$(".contact-btn").mouseout(function(){
			$(this).attr("src", imgsrc);
		});
		$(".contact-btn").click(function(){
			$(this).attr("src", imgsrc);
		});
	
	/* ------------------------------------------ */
	// END - GLOBAL "CONTACT_US" BUTTON FUNCTIONs 
	/* --------------------- ----------------------*/
		
	
	
	/* ---------------------------------------------------------- */
	// "Where To Buy" Global <Input type='image'> Form Button Rollover Effect
	/* ---------------------------------------------------------- */
	
		$("#headerRight input[type='image'], #formsContent input[type='image']").mouseover(function(){
			input_imgsrc = $(this).attr("src");
			matches = input_imgsrc.match(/_over/);
	
			// don't do the rollover if state is already ON
			if(!matches) {
				input_imgsrcON = input_imgsrc.replace(/.png$/ig,"_over.png"); // strip off extension
				$(this).attr("src", input_imgsrcON);
			}	
		});
		$("#headerRight input[type='image'], #productMenuBar input[type='image'], #formsContent input[type='image']").mouseout(function(){
			$(this).attr("src", input_imgsrc);
		});
		$("#headerRight input[type='image'], #productMenuBar input[type='image'], #formsContent input[type='image']").mousedown(function(){
			input_imgsrcON = input_imgsrc.replace(/_over.png$/ig,".png"); // strip off extension
			$(this).attr("src", input_imgsrcON);
		});
		
	/* ---------------------------------------------------------- */
	// "The PRODUCT MODEL JUMP MENU "SELECT" BUTTON Form Button Rollover Effect. The following scrpt effects product category landing page and product model pages
	/* ---------------------------------------------------------- */
		// Preload all rollovers #productMenuBar img
		$("#productMenuBar img").each(function() {
			// Set the original src
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.png$/ig,"_over.png");
			$("<img>").attr("src", rollON);
		});
		
		$("#productMenuBar a, .poplight").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if(!matches) {
				imgsrcON = imgsrc.replace(/.png$/ig,"_over.png"); // strip off extension
				$(this).children("img").attr("src", imgsrcON);
			}		
		});	
		$("#productMenuBar a, .poplight").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
		$("#productMenuBar a, .poplight").mousedown(function(){
			imgsrcON = imgsrc.replace(/_over.png$/ig,".png"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
		});
	
	
	/* ------------------------------------------------------------------------------- */
	// "DEALER LOCATOR "SEARCH", "SEARCH AGAIN" and "PRINT" BUTTON Form Button Rollover Effect. 
	// The following scrpt effects ALL  HOLCAM DEALER LOCATOR - RESULTS, SEARCH, ERROR and MAP pages
	/* ---------------------------------------------------------------------------------- */
		var xyz = (".searchAgainLH input[type='image'],.searchAgainRH input[type='image']");
		$(xyz).mouseover(function(){
			input_imgsrc = $(this).attr("src");
			matches = input_imgsrc.match(/_over/);
	
			// don't do the rollover if state is already ON
			if(!matches) {
				input_imgsrcON = input_imgsrc.replace(/.png$/ig,"_over.png"); // strip off extension
				$(this).attr("src", input_imgsrcON);
			}	
		});
		$(xyz).mouseout(function(){
			$(this).attr("src", input_imgsrc);
		});
		$(xyz).mousedown(function(){
			input_imgsrcON = input_imgsrc.replace(/_over.png$/ig,".png"); // strip off extension
			$(this).attr("src", input_imgsrcON);
		});

		
	/* ---------------------------------------------------------- */
	// "The PRODUCT MODEL LANDING PAGE <DIV> ELEMENT Rollover Effects. The following scrpt effects product category landing page  #5A5E4D #B1A281 #938460  background-color: #c7bea9;
	/* ---------------------------------------------------------- */
	
		$(".prodModel-img").hover(function(){
			$(this).css({'background-color':'#c7bea9','border':'#c7bea9 1px solid','-moz-border-radius':'0px 0px 4px 4px','border-radius':'0px 0px 4px 4px','-webkit-border-radius':'5px 0px 0px 5px','color':'#624E2D'});
		}, function () {
			var cssObj = {'background-color':'','border':'#938460 1px solid','-moz-border-radius':'0px 0px 4px 4px','border-radius':'0px 0px 4px 4px','-webkit-border-radius':'5px 0px 0px 5px','color':'#fff'}
			$(this).css(cssObj);
		});

/* ---------------------------------------------------------- */
// "END Button Rollover Effect
/* ---------------------------------------------------------- */
});



/* ---------------------------------------------------------- */
// "Where To Buy" Global Form Validation Script - Site Wide
/* ---------------------------------------------------------- */

function validateZip(thisForm){	
		var reZipexp = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
		
		if (thisForm.postalcode.value == "" ){ // Check to see if zip code is empty
	    		window.alert("Please enter a Valid Postal/Zip Code!\n US zip code schemes: 12345-1234 or 12345");
				thisForm.postalcode.focus();
	    		return false;
	  	} else if(!reZipexp.test(thisForm.postalcode.value)) { // Check for correct zip code
     			alert("Zip Code Is Not Valid\n US zip code schemes: 12345-1234 or 12345");
			  	return false;
		}
		
return true;	
}

/* Removes "Enter Zip Code" from the "where to buy" input form box on the global header*/
function clearInputForm(theText) {
     if (theText.value == theText.defaultValue) {
         theText.value = ""
     }
 }

/* ------------------------------- */
/*  Begin -- Holcam Contact Email script - warranty-&-care.php */
/* ------------------------------- */  

function emailForm(){

	var email = "sales";
	var emailHost = "holcam.com"
	var errorMsg = "here here here is the error error error error";
	var subject = "Holcam.com - Warranty Claim Inquiry";
	var body_message = "";
	
	var mailto_link = 'mailto:'+email+'@'+emailHost+'?subject='+subject+'&body='+body_message;
	
	var win = (parent.location= mailto_link);
}	

function emailFormDealer(){

	var email = "sales";
	var emailHost = "holcam.com"
	var errorMsg = "here here here is the error error error error";
	var subject = "Holcam.com - Dealer Locator Inquiry";
	var body_message = "";
	
	var mailto_link = 'mailto:'+email+'@'+emailHost+'?subject='+subject+'&body='+body_message;
	
	var win = (parent.location= mailto_link);
}	

function emailForm1(){

	var email = "sales";
	var emailHost = "holcam.com"
	var errorMsg = "here here here is the error error error error";
	var subject = "Holcam.com - Installation/Technical Inquiries";
	var body_message = "";
	
	var mailto_link = 'mailto:'+email+'@'+emailHost+'?subject='+subject+'&body='+body_message;
	
	var win = (parent.location= mailto_link);
}	


