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 assigncontactmethod(str) {
	var ContactUsForm = document.forms.ContactUsForm;
	ContactUsForm.q1c.checked=true;
	
	ClearContactUsForm();

	if (str == "email") {
		assigninnerhtmlvalue("TxtEmail","* Email:&nbsp;");
	} else {
		for (var i = 0; i < ContactUsForm.contactmethod.length; i++) {
			if (ContactUsForm.contactmethod[i].value == "phone") {
				ContactUsForm.contactmethod[i].checked = true;
				break;
			} 
		}	
		if (ContactUsForm.phoneoption.options[ContactUsForm.phoneoption.selectedIndex].value == "home") {
			assigninnerhtmlvalue("TxtPhone","* Home Phone:&nbsp;");
		} else {
			assigninnerhtmlvalue("TxtCellphone","* Mobile Phone:&nbsp;");
		}
	}

}

function ClearContactUsForm() {

	if (document.all) {
		/*document.all["TxtAddress"].innerHTML = "Address:&nbsp;";
		document.all["TxtCity"].innerHTML = "City:&nbsp;";
		document.all["TxtState"].innerHTML = "State:&nbsp;";
		document.all["TxtZIP"].innerHTML = "Zip:&nbsp;";*/
		document.all["TxtEmail"].innerHTML = "Email:&nbsp;";
		document.all["TxtPhone"].innerHTML = "Home Phone:&nbsp;";
		document.all["TxtCellphone"].innerHTML = "Mobile Phone:&nbsp;";
	} else {
		/*document.getElementById("TxtAddress").innerHTML = "Address:&nbsp;";
		document.getElementById("TxtCity").innerHTML = "City:&nbsp;";
		document.getElementById("TxtState").innerHTML = "State:&nbsp;";
		document.getElementById("TxtZIP").innerHTML = "Zip:&nbsp;";*/
		document.getElementById("TxtEmail").innerHTML = "Email:&nbsp;";
		document.getElementById("TxtPhone").innerHTML = "Home Phone:&nbsp;";
		document.getElementById("TxtCellphone").innerHTML = "Mobile Phone:&nbsp;";
	}


}

function assigncontactoption() {
	var ContactUsForm = document.forms.ContactUsForm;
	
	if (ContactUsForm.q1c.checked==true) {
		for (var i = 0; i < ContactUsForm.contactmethod.length; i++) {
			if (ContactUsForm.contactmethod[i].checked == true) {
				assigncontactmethod(ContactUsForm.contactmethod[i].value);
				break;
			} 
		}

	} else {
		ClearContactUsForm()
	
	}


}

function assignbrochure() {
	var ContactUsForm = document.forms.ContactUsForm;
	
	if (ContactUsForm.q2c.checked==true) {
	
		assigninnerhtmlvalue("TxtAddress","* Address:&nbsp;");
		assigninnerhtmlvalue("TxtCity","* City:&nbsp;");
		assigninnerhtmlvalue("TxtState","* State:&nbsp;");
		assigninnerhtmlvalue("TxtZIP","* Zip:&nbsp;");
	} else {
	
		assigninnerhtmlvalue("TxtAddress","Address:&nbsp;");
		assigninnerhtmlvalue("TxtCity","City:&nbsp;");
		assigninnerhtmlvalue("TxtState","State:&nbsp;");
		assigninnerhtmlvalue("TxtZIP","Zip:&nbsp;");	
	}
}

function assigninnerhtmlvalue(field,value) {
	if (document.all) {
		document.all[field].innerHTML = value;

	} else {
		document.getElementById(field).innerHTML = value;
	}
}


function SendContectUsForm() {

	var ContactUsForm = document.forms.ContactUsForm;	
	
	if (ContactUsForm.q1c.checked == false && ContactUsForm.q2c.checked == false) {
	
		alert("Please select how we can help you.");
		return false;
		
	} else if (ContactUsForm.q1c.checked == true && ContactUsForm.contactmethod["0"].checked == false && ContactUsForm.contactmethod["1"].checked == false) {	
	
		alert("Please select how you want us to contact you");
		return false;		
		
	} else if (ContactUsForm.firstname.value == "") {
	
		alert("Please enter your First Name");
		ContactUsForm.firstname.focus();
		return false;
	
	
	} else if (ContactUsForm.lastname.value == "") {
	
		alert("Please enter your Last Name");
		ContactUsForm.lastname.focus();
		return false;	
		
	} else if (((ContactUsForm.q1c.checked == true && ContactUsForm.contactmethod["0"].checked == true) || Trim(ContactUsForm.email.value) != "") && !isEmail(ContactUsForm.email.value)) {
			
		alert("Please enter an valid Email Address");
		ContactUsForm.email.focus();
		return false;

	} else if (ContactUsForm.q1c.checked == true && ContactUsForm.contactmethod["1"].checked == true && ContactUsForm.phoneoption.options[ContactUsForm.phoneoption.selectedIndex].value == "home" && Trim(ContactUsForm.phone.value) == "") {
	
		alert("Please enter your Home Phone Number");
		ContactUsForm.phone.focus();
		return false;		
		
	} else if (ContactUsForm.q1c.checked == true && ContactUsForm.contactmethod["1"].checked == true && ContactUsForm.phoneoption.options[ContactUsForm.phoneoption.selectedIndex].value == "cell" && Trim(ContactUsForm.cellphone.value) == "") {
	
		alert("Please enter your Mobile Phone Number");
		ContactUsForm.cellphone.focus();
		return false;	
		
	} else if (ContactUsForm.q2c.checked == true && (Trim(ContactUsForm.address.value) == "" || Trim(ContactUsForm.city.value) == "" || Trim(ContactUsForm.postal.value) == "" || Trim(ContactUsForm.state.value) == "")) {
	
		alert("Please enter your Address, City, State and ZIP");
		return false;			
	
	} else {
		submitContactUsForm()

	}

}

function PreloadContactInfo() { 
	
	var ContactUsForm = document.forms.ContactUsForm;
	
	if (ContactUsForm) {
	
		var HunterDouglasContactUsCookie = GetCookie("HunterDouglasContactUs");

		var sCurrentSoftADCookie = GetSoftAdCookie();	

		if (HunterDouglasContactUsCookie == sCurrentSoftADCookie) {

			ContactUsForm.firstname.value = (GetCookie("FirstName") == "" || GetCookie("FirstName") == null) ? "" : GetCookie("FirstName");
			ContactUsForm.lastname.value = (GetCookie("LastName") == "" || GetCookie("LastName") == null) ? "" : GetCookie("LastName");

			ContactUsForm.address.value = (GetCookie("Address") == "" || GetCookie("Address") == null ) ? "" : GetCookie("Address");
			ContactUsForm.city.value = (GetCookie("City") == "" || GetCookie("City") == null) ? "" : GetCookie("City");

			if (GetCookie("State") != "" && GetCookie("State") != null) {
				for (var i = 0; i < ContactUsForm.state.length; i++) {
					if (ContactUsForm.state.options[i].value == GetCookie("State")) {
						ContactUsForm.state.options[i].selected = true;
						break;
					} 
				}		
			}
			ContactUsForm.postal.value = (GetCookie("Zip") == "" || GetCookie("Zip") == null) ? "" : GetCookie("Zip");
			ContactUsForm.email.value = (GetCookie("Email") == "" || GetCookie("Email") == null) ? "" : GetCookie("Email");
			ContactUsForm.phone.value = (GetCookie("Phone") == "" || GetCookie("Phone") == null) ? "" : GetCookie("Phone");
			ContactUsForm.cellphone.value = (GetCookie("Mobile") == "" || GetCookie("Mobile") == null) ? "" : GetCookie("Mobile");
		}
	}

}

function submitContactUsForm() {

	var ContactUsForm = document.forms.ContactUsForm;
	var PostLeadForm = document.forms.PostLeadForm;
	
	

	var a1;
	var a2;
	var a3;
	var a4;
	var q3;
	
	var phone = Trim(ContactUsForm.phone.value) + "," + Trim(ContactUsForm.cellphone.value)
	
	
	if (phone.substring(0,1) == ",") {
		phone = phone.substring(1,phone.length)
	} else if (phone.substring(phone.length-1,phone.length) == ",") {
		phone = phone.substring(0,phone.length-1)
	}
	
	
	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(phone) + '</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>';
	
	
	var expDays = 30; 
	var exp = new Date(); 
		
	exp.setTime(exp.getTime() + (expDays*24*60*60*1000));		
	sSoftAdCookie = GetSoftAdCookie();	
	SetCookie('HunterDouglasContactUs', sSoftAdCookie, exp);
	SetCookie('FirstName', ContactUsForm.firstname.value, exp); 
	SetCookie('LastName', ContactUsForm.lastname.value, exp); 
	SetCookie('Email', ContactUsForm.email.value, exp);
	SetCookie('Phone', ContactUsForm.phone.value, exp);
 	SetCookie('Mobile', ContactUsForm.cellphone.value, exp);
 	SetCookie('Address', ContactUsForm.address.value, exp);
 	SetCookie('City', ContactUsForm.city.value, exp);
 	SetCookie('State', ContactUsForm.state.value, exp);
 	SetCookie('Zip', ContactUsForm.postal.value, exp);
 	 	
	
	if (ContactUsForm.q1c.checked == true) {
	
		a1 = "Yes";

	} else {
		
		a1 = "No";

	}
	var a1_1 ="";
	
	for (var i = 0; i < ContactUsForm.contactmethod.length; i++) {
		if (ContactUsForm.contactmethod[i].checked) {
			if (ContactUsForm.contactmethod[i].value == "email") {
				a1_1 = "Contact me by email";
			} else {
			
				if (ContactUsForm.phoneoption.options[ContactUsForm.phoneoption.selectedIndex].value == "home") {
					
					a1_1 = "Call my home phone";
				
				} else {
				
					a1_1 = "Call my mobile phone";
				}
			}
		}            
	}	
	
	PostLeadForm.q1.value = ContactUsForm.q1.value;
	PostLeadForm.a1.value = a1;
	PostLeadForm.a1_1.value = a1_1;
	
	if (ContactUsForm.q2c.checked == true) {
	
		a2 = "Yes";

	} else {
		
		a2 = "No";

	}
	PostLeadForm.q2.value = ContactUsForm.q2.value;
	PostLeadForm.a2.value = a2;	
	
	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,";
	} 	
	
	PostLeadForm.q3.value = ContactUsForm.q3.value;
	PostLeadForm.a3.value = a3;	
		

	if (ContactUsForm.q4c.checked == true) {
	
		a4 = "Checked";
	
	} else {
		
		a4 = "UnChecked";
		
	}
	
    if (GetCookie("iMagine")!=null)
        PostLeadForm.a6.value = "Yes";
    else    
        PostLeadForm.a6.value = "No";

	
	PostLeadForm.q4.value = ContactUsForm.q4.value;
	PostLeadForm.comments.value = HDEncoding(ContactUsForm.comments.value);

	PostLeadForm.a4.value = a4;
	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 += '<question_6>iMagine visits</question_6>';
    
    if (GetCookie("iMagine")!=null)
        sCatch += '<answer_6>Yes</answer_6>';
    else    
        sCatch += '<answer_6>No</answer_6>';

	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>';

	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.hdnetsession.value = GetSoftAdCookie();
	
	//alert(PostLeadForm.storehours.value)
	PostLeadForm.strXML.value = sCatch;
	PostLeadForm.submit();
	return false;
}



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 = GetCookie("SoftadTrackingCookie");

	if (HDPopUpWindowCookie != sCurrentSoftADCookie) {	

		var URL = "/Themes/Default/en-us/SiteBuilder/howdidyoufindus.aspx?siteguid=" + SiteGuid + "&pagekey=" + pagekey + "&vanity=" + Vanity + "&font=" + font + "&theme=" + theme;

		var sSoftAdCookie = GetCookie("SoftadTrackingCookie");
		
		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 + "&Logging=majorcode=" + vChecked + "|minorcode1=SurveyPopup";
		
		var sCatch1 = "siteguid=" + FormObj.siteguid.value + "%26generic1=admajorcode=" + vChecked + "|adminorcode=SurveyPopup";
	
		window.opener.location.href = "/channelnet.aspx?cn=SiteBuilder&act=viewsite&crt=" + sCatch1 + "%26pagekey=" + pagekey;
		
		document.forms.ChannelNet.crt.value = sCatch;
		
		document.forms.ChannelNet.submit();    	

	}
}

function openiMagine(dealerid, pagekey) {    
	var expDays = 30; 
	var exp = new Date(); 

	exp.setTime(exp.getTime() + (expDays*24*60*60*1000));		
	sSoftAdCookie = GetSoftAdCookie();	
	SetCookie('HunterDouglasiMagine', sSoftAdCookie, exp);
	SetCookie('iMagine', 'yes', exp); 

//	var sURL = "/channelnet.aspx?cn=sitebuilder&act=view&crt=sitekey="+dealerid+"%26pagekey="+pagekey+"%26generic=iMagine%26logging=admajorcode=iMagine visits|minorcode1=HDDealerSite&style=/themes/Default/en-us/SiteBuilder/redirectiMagine.xsl&debug=0";
	var sURL = "/channelnet.aspx?cn=sitebuilder&act=view&crt=sitekey="+dealerid+"%26pagekey="+pagekey+"%26generic=iMagine%26logging=majorcode=iMagineVisits|minorcode1=HDDealerSite&style=/themes/Default/en-us/SiteBuilder/redirectiMagine.xsl&debug=0";

	window.open(sURL, "popup2","height=670,width=880,resizable=yes,status=no,toolbar=no,directories=no,menubar=no,scrollbars=yes,location=no");
}
