function ImageOver(img1,img2,index) {
	document.images["Customer_Big_" + index].src = document.images[img1 + "_" + index].src;
	document.all("table1_" + img2 + "_" + index).className = "clsNoHighlighted";
	document.all("table2_" + img2 + "_" + index).className = "clsNoHighlighted";
	document.all("table1_" + img1 + "_" + index).className = "clsHighlighted";
	document.all("table2_" + img1 + "_" + index).className = "clsHighlighted";	
}

function ImageOut(img1,img2,index) {

}

function GalleryExperience(soundtracksetting,soundtrack,mylogo) {

	var URL = "/galleryexperience.aspx?soundtrack=" + soundtrack + "&soundtracksetting=" + soundtracksetting + "&mylogo=" + mylogo;
	
	window.open(URL,"GalleryExperience","width=687.5,height=500,scrollbars=no,location=no,menubar=no,resizable=no,toolbar=no,status=no");


}

function XMLEncode(sIn) {

	sIn = sIn.replace(/&/g, "&amp;");
	sIn = sIn.replace(/</g, "&lt;");
	sIn = sIn.replace(/>/g, "&gt;");
	sIn = sIn.replace(/"/g, "&quot;");
	sIn = sIn.replace(/'/g, "&apos;");
	
	return sIn;

}

function HDEncoding(sIn) {

	sIn = XMLEncode(sIn);
	sIn = escape(sIn);

	return sIn;
}

function SendContectUsForm() {

	var ContactUsForm = document.forms.ContactUsForm;
	var PostLeadForm = document.forms.PostLeadForm;
	
	if (ContactUsForm.firstname.value == "") {
	
		alert("Please enter your First Name 1");
		return false;
	
	
	} else if (ContactUsForm.lastname.value == "") {
	
		alert("Please enter your Last Name");
		return false;	
		
	} else if (ContactUsForm.email.value == "") {
	
		alert("Please enter your Email Address");
		return false;
		
	} else if (!isEmail(ContactUsForm.email.value)) {
	
		alert("Please enter an valid Email address.");

		return false;

	} else if (ContactUsForm.phone.value == "") {
	
		alert("Please enter your Phone Number");
		return false;				
	
	
	} else {
	
	var a1;
	var a2;
	var a3;
	var a4;
	var q3;
	
	
	var sCatch = '<lead>';
	sCatch += '<form_name>contact_us</form_name>';
	sCatch += '<nick_name>' + HDEncoding(ContactUsForm.NickName.value) + '</nick_name>';
	sCatch += '<dealerno>' + HDEncoding(ContactUsForm.dealerno.value) + '</dealerno>';
	sCatch += '<first_name>' + HDEncoding(ContactUsForm.firstname.value) + '</first_name>';
	sCatch += '<last_name>' + HDEncoding(ContactUsForm.lastname.value) + '</last_name>';
	sCatch += '<phone>' + HDEncoding(ContactUsForm.phone.value) + '</phone>';
	sCatch += '<email>' + HDEncoding(ContactUsForm.email.value) + '</email>';
	sCatch += '<address>' + HDEncoding(ContactUsForm.address.value) + '</address>';
	sCatch += '<city>' + HDEncoding(ContactUsForm.city.value) + '</city>';
	sCatch += '<state>' + HDEncoding(ContactUsForm.state.value) + '</state>';
	sCatch += '<zip>' + HDEncoding(ContactUsForm.postal.value) + '</zip>';
	sCatch += '<questionset>ver12</questionset>';
	
	
	if (ContactUsForm.q1c.checked == true) {
	
		a1 = "Yes";
	
	} else {
		
		a1 = "No";
		
	}
	

	if (ContactUsForm.q2c.checked == true) {
	
		a2 = "Yes";
	
	} else {
		
		a2 = "No";
		
	}

	
	q3 = ContactUsForm.q3.value;
	
	var a3 = "";
	
	if (ContactUsForm.q3c1.checked == true) {
		a3 =  a3 + "Yellowpage,";
	} 

	if (ContactUsForm.q3c2.checked == true) {
		a3 =  a3 + "Internet,";
	} 
	
	if (ContactUsForm.q3c3.checked == true) {
		a3 =  a3 + "Friends,";
	} 
	
	if (ContactUsForm.q3c4.checked == true) {
		a3 =  a3 + "Newspaper,";
	} 
	
	if (ContactUsForm.q3c5.checked == true) {
		a3 =  a3 + "Magazine,";
	} 
	
	if (ContactUsForm.q3c6.checked == true) {
		a3 =  a3 + "Other,";
	} 	
		
		

	if (ContactUsForm.q4c.checked == true) {
	
		a4 = "Checked";
	
	} else {
		
		a4 = "UnChecked";
		
	}
	

	sCatch += '<question_1>' + HDEncoding(ContactUsForm.q1.value) + '</question_1>';

	sCatch += '<answer_1>' + HDEncoding(a1) + '</answer_1>';

	sCatch += '<question_2>' + HDEncoding(ContactUsForm.q2.value) + '</question_2>';
	sCatch += '<answer_2>' + HDEncoding(a2) + '</answer_2>';

	sCatch += '<question_3>' + HDEncoding(q3) + '</question_3>';
	sCatch += '<answer_3>' + HDEncoding(a3) + '</answer_3>';

	sCatch += '<question_4>' + HDEncoding(ContactUsForm.q4.value) + '</question_4>';
	sCatch += '<answer_4>' + HDEncoding(a4) + '</answer_4>';

	sCatch += '<comments>' + HDEncoding(ContactUsForm.comments.value) + '</comments>';
	
 	sCatch += '<admajorcode>' + HDEncoding(PostLeadForm.admajorcode.value) + '</admajorcode>';
   	sCatch += '<adminorcode>' + HDEncoding(PostLeadForm.adminorcode.value) + '</adminorcode>';
   	sCatch += '<addealercode>' + HDEncoding(PostLeadForm.addealercode.value) + '</addealercode>';
	
		
	
	sCatch += '</lead>';
	
	var sPICCatch
	
	sPICCatch = '<lead>';
	sPICCatch += '<form_name>contact_us</form_name>';
	sPICCatch += '<nick_name>' + HDEncoding(ContactUsForm.NickName.value) + '</nick_name>';
	sPICCatch += '<dealerno>' + HDEncoding(ContactUsForm.dealerno.value) + '</dealerno>';
	sPICCatch += '<first_name>' + HDEncoding(ContactUsForm.firstname.value) + '</first_name>';
	sPICCatch += '<last_name>' + HDEncoding(ContactUsForm.lastname.value) + '</last_name>';
	sPICCatch += '<phone>' + HDEncoding(ContactUsForm.phone.value) + '</phone>';
	sPICCatch += '<email>' + HDEncoding(ContactUsForm.email.value) + '</email>';
	sPICCatch += '<address>' + HDEncoding(ContactUsForm.address.value) + '</address>';
	sPICCatch += '<city>' + HDEncoding(ContactUsForm.city.value) + '</city>';
	sPICCatch += '<state>' + HDEncoding(ContactUsForm.state.value) + '</state>';
	sPICCatch += '<zip>' + HDEncoding(ContactUsForm.postal.value) + '</zip>';
	sPICCatch += '<questionset>ver12</questionset>';
	
	
	if (ContactUsForm.q1c.checked == true) {
	
		a1 = "Yes";
	
	} else {
		
		a1 = "No";
		
	}
	

	if (ContactUsForm.q2c.checked == true) {
	
		a2 = "Yes";
	
	} else {
		
		a2 = "No";
		
	}

	
	q3 = ContactUsForm.q3.value;
	
	var a3 = "";
	
	if (ContactUsForm.q3c1.checked == true) {
		a3 =  a3 + "Yellowpage,";
	} 

	if (ContactUsForm.q3c2.checked == true) {
		a3 =  a3 + "Internet,";
	} 
	
	if (ContactUsForm.q3c3.checked == true) {
		a3 =  a3 + "Friends,";
	} 
	
	if (ContactUsForm.q3c4.checked == true) {
		a3 =  a3 + "Newspaper,";
	} 
	
	if (ContactUsForm.q3c5.checked == true) {
		a3 =  a3 + "Magazine,";
	} 
	
	if (ContactUsForm.q3c6.checked == true) {
		a3 =  a3 + "Other,";
	} 	
		
		

	if (ContactUsForm.q4c.checked == true) {
	
		a4 = "Checked";
	
	} else {
		
		a4 = "UnChecked";
		
	}
	
	var a1_1 ="";
	
	for (var i = 0; i < ContactUsForm.contactmethod.length; i++) {
		if (ContactUsForm.contactmethod[i].checked) {
			a1_1 = ContactUsForm.contactmethod[i].value;
		}            
	}
	
	sPICCatch += '<question_1>' + HDEncoding(ContactUsForm.q1.value) + '</question_1>';

	sPICCatch += '<answer_1>' + HDEncoding(a1) + '</answer_1>';
	sPICCatch += '<answer_1_1>' + HDEncoding(a1_1) + '</answer_1_1>';

	sPICCatch += '<question_2>' + HDEncoding(ContactUsForm.q2.value) + '</question_2>';
	sPICCatch += '<answer_2>' + HDEncoding(a2) + '</answer_2>';

	sPICCatch += '<question_3>' + HDEncoding(q3) + '</question_3>';
	sPICCatch += '<answer_3>' + HDEncoding(a3) + '</answer_3>';

	sPICCatch += '<question_4>' + HDEncoding(ContactUsForm.q4.value) + '</question_4>';
	sPICCatch += '<answer_4>' + HDEncoding(a4) + '</answer_4>';

	sPICCatch += '<comments>' + HDEncoding(ContactUsForm.comments.value) + '</comments>';
	
 	sPICCatch += '<admajorcode>' + HDEncoding(PostLeadForm.admajorcode.value) + '</admajorcode>';
   	sPICCatch += '<adminorcode>' + HDEncoding(PostLeadForm.adminorcode.value) + '</adminorcode>';
   	sPICCatch += '<addealercode>' + HDEncoding(PostLeadForm.addealercode.value) + '</addealercode>';
	sPICCatch += '<dealerlogo>' + HDEncoding(PostLeadForm.webserver.value + PostLeadForm.dealer_logo.value) + '</dealerlogo>';
	
	var oSThours = document.getElementById("storehours").XMLDocument.selectSingleNode("//Hours");
	
	if (oSThours.length == 0) {
		oSThours = document.getElementById("storehours").XMLDocument.selectSingleNode("//store_hours");
	} 
	sPICCatch += '<dealerstorehours>' + oSThours.xml + '</dealerstorehours>';	
	sPICCatch += '<dealerwebsite>' + PostLeadForm.dealerurl.value + '.hdwfg.com</dealerwebsite>';
	sPICCatch += '<LeadDate>' + PostLeadForm.nurealdate.value + '</LeadDate>';
	sPICCatch += '</lead>';	
	

	PostLeadForm.first_name.value = ContactUsForm.firstname.value;
	PostLeadForm.last_name.value = ContactUsForm.lastname.value;

	PostLeadForm.address.value = ContactUsForm.address.value;
	PostLeadForm.city.value = ContactUsForm.city.value;
	PostLeadForm.state.value = ContactUsForm.state.value;	
	PostLeadForm.phone.value = ContactUsForm.phone.value;
	PostLeadForm.zip.value = ContactUsForm.postal.value;
	PostLeadForm.email.value = ContactUsForm.email.value;	


	PostLeadForm.strXML.value = sCatch;
	PostLeadForm.strPICXML.value = sPICCatch;

	PostLeadForm.submit();
	return false;
	}

}


function GetSoftAdCookie() {

	var sCurrentCookie = GetCookie("ASP.NET_SessionId");
	
	return sCurrentCookie;

}

function GetCookie(name) { // use: getCookie("name");
	var bikky = document.cookie;
	var index = bikky.indexOf(name + "=");
	if (index == -1) return null;
	index = bikky.indexOf("=", index) + 1; // first character

	var endstr = bikky.indexOf(";", index);
	if (endstr == -1) endstr = bikky.length; // last character
	return unescape(bikky.substring(index, endstr));
}

function SetCookie(name, value) {
         var argv = SetCookie.arguments;
         var argc = SetCookie.arguments.length;
         var expires = (argc > 2) ? argv[2] : null;
         var path = (argc > 3) ? argv[3] : null;
         var domain = (argc > 4) ? argv[4] : null;
         var secure = (argc > 5) ? argv[5] : false;
         document.cookie = name + "=" + escape (value) +
         ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
         ((path == null) ? "" : ("; path=" + path)) +
         ((domain == null) ? "" : ("; domain=" + domain)) +
         ((secure == true) ? "; secure" : "");
}

function PopHowTofindUs(SiteGuid,Vanity,pagekey,font,theme) {

	var expDays = 1;
	var exp = new Date(); 
	exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

	var HDPopUpWindowCookie = GetCookie("HDPopUpWindow");

	var sCurrentSoftADCookie = GetSoftAdCookie();

	if (HDPopUpWindowCookie != sCurrentSoftADCookie) {	

		var URL = "/Themes/Default/en-us/SiteBuilder/howdidyoufindus.aspx?siteguid=" + SiteGuid + "&pagekey=" + pagekey + "&vanity=" + Vanity + "&font=" + font + "&theme=" + theme;

		var sSoftAdCookie = GetSoftAdCookie();
		
		SetCookie("HDPopUpWindow", sSoftAdCookie, exp);	
		
		window.open(URL,"HowDidYouFindUs","width=510,height=400,scrollbars=no,location=no,menubar=no,resizable=no,toolbar=no,status=no");
		
	}

}

function SubmitFindUsForm() {

	var FormObj = document.forms.FindUs;
	
	var vChecked = "";
	
	for (var i = 0; i < FormObj.HowToFindUs.length; i++) {
		
		if (FormObj.HowToFindUs[i].checked) {
			
			vChecked = FormObj.HowToFindUs[i].value;
		
		}          
	
	}
	
	if (vChecked == "") {
	
		alert("Please choose one option, thanks!");
		return false;
		
	} else {
		
		FormObj.submit.disabled = "disabled";
		var pagekey = FormObj.pagekey.value;
		var sCatch = "siteguid=" + FormObj.siteguid.value;
	
		window.opener.location.href = "/channelnet.aspx?cn=SiteBuilder&act=viewsite&crt=" + sCatch + "%26pagekey=" + pagekey;
		
		document.forms.ChannelNet.crt.value = sCatch;
		
		document.forms.ChannelNet.submit();    	

	}
}
