// Underfloor Heating Quotation
// Field Checking
function verify_ufh1() {
var themessage = "You are required to complete the following fields: ";
if (document.quote.size.value=="") {
themessage = themessage + " - Overall Size";
}
if (document.quote.rooms.value=="") {
themessage = themessage + " - Number of Rooms";
}
if (themessage == "You are required to complete the following fields: ") {
document.quote.submit();
}
else {
alert(themessage);
return false;
   }
}

function verify_ufh2() {
var themessage = "You are required to complete the following fields: ";
if (document.upload.cname.value=="") {
themessage = themessage + " - Contact name";
}
if (document.upload.email.value=="") {
themessage = themessage + " - Contact e-mail";
}
if (document.upload.file.value=="") {
themessage = themessage + " - File";
}
if (themessage == "You are required to complete the following fields: ") {
document.upload.submit();
}
else {
alert(themessage);
return false;
   }
}

// Numbers only
function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789.").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}

function changeSupportFile() {
	if (document.getElementById("showhideSupportFile").style.display == "none") {
		document.getElementById("showhideSupportFile").style.display = "block";
		document.getElementById("thetextSupportFile").innerHTML = "Hide supported files";
	} 
	else {
		document.getElementById("showhideSupportFile").style.display = "none";
		document.getElementById("thetextSupportFile").innerHTML = "Show supported files";
	}

}

function changeUploadPlan() {
	if (document.getElementById("showhideUploadPlan").style.display == "none") {
		document.getElementById("showhideUploadPlan").style.display = "block";
		document.getElementById("thetextUploadPlan").innerHTML = "click here to hide form";
	} 
	else {
		document.getElementById("showhideUploadPlan").style.display = "none";
		document.getElementById("thetextUploadPlan").innerHTML = "click here to show form";
	}

}
function changeAdvancedQuote() {
	if (document.getElementById("showhideAdvancedQuote").style.display == "none") {
		document.getElementById("showhideAdvancedQuote").style.display = "block";
		document.getElementById("thetextAdvancedQuote").innerHTML = "click here to hide form";
	} 
	else {
		document.getElementById("showhideAdvancedQuote").style.display = "none";
		document.getElementById("thetextAdvancedQuote").innerHTML = "click here to show form";
	}

}

	var lastDiv1 = "";
	function showDiv1(divName) {
		// hide last div
		if (lastDiv1) {
			document.getElementById(lastDiv1).className = "hiddenDiv1";
		}
		//if value of the box is not nothing and an object with that name exists, then change the class
		if (divName && document.getElementById(divName)) {
			document.getElementById(divName).className = "visibleDiv1";
			lastDiv1 = divName;
		}
	}
	var lastDiv2 = "";
	function showDiv2(divName) {
		// hide last div
		if (lastDiv2) {
			document.getElementById(lastDiv2).className = "hiddenDiv2";
		}
		//if value of the box is not nothing and an object with that name exists, then change the class
		if (divName && document.getElementById(divName)) {
			document.getElementById(divName).className = "visibleDiv2";
			lastDiv2 = divName;
		}
	}
	var lastDiv3 = "";
	function showDiv3(divName) {
		// hide last div
		if (lastDiv3) {
			document.getElementById(lastDiv3).className = "hiddenDiv3";
		}
		//if value of the box is not nothing and an object with that name exists, then change the class
		if (divName && document.getElementById(divName)) {
			document.getElementById(divName).className = "visibleDiv3";
			lastDiv3 = divName;
		}
	}
	var lastDiv4 = "";
	function showDiv4(divName) {
		// hide last div
		if (lastDiv4) {
			document.getElementById(lastDiv4).className = "hiddenDiv4";
		}
		//if value of the box is not nothing and an object with that name exists, then change the class
		if (divName && document.getElementById(divName)) {
			document.getElementById(divName).className = "visibleDiv4";
			lastDiv4 = divName;
		}
	}
	var lastDiv5 = "";
	function showDiv5(divName) {
		// hide last div
		if (lastDiv5) {
			document.getElementById(lastDiv5).className = "hiddenDiv5";
		}
		//if value of the box is not nothing and an object with that name exists, then change the class
		if (divName && document.getElementById(divName)) {
			document.getElementById(divName).className = "visibleDiv5";
			lastDiv5 = divName;
		}
	}
	var lastDiv6 = "";
	function showDiv6(divName) {
		// hide last div
		if (lastDiv6) {
			document.getElementById(lastDiv6).className = "hiddenDiv6";
		}
		//if value of the box is not nothing and an object with that name exists, then change the class
		if (divName && document.getElementById(divName)) {
			document.getElementById(divName).className = "visibleDiv6";
			lastDiv6 = divName;
		}
	}
	var lastDiv7 = "";
	function showDiv7(divName) {
		// hide last div
		if (lastDiv7) {
			document.getElementById(lastDiv7).className = "hiddenDiv7";
		}
		//if value of the box is not nothing and an object with that name exists, then change the class
		if (divName && document.getElementById(divName)) {
			document.getElementById(divName).className = "visibleDiv7";
			lastDiv7 = divName;
		}
	}
	var lastDiv8 = "";
	function showDiv8(divName) {
		// hide last div
		if (lastDiv8) {
			document.getElementById(lastDiv8).className = "hiddenDiv8";
		}
		//if value of the box is not nothing and an object with that name exists, then change the class
		if (divName && document.getElementById(divName)) {
			document.getElementById(divName).className = "visibleDiv8";
			lastDiv8 = divName;
		}
	}
// Field Checking
function verify_advancedufh() {
var themessage = "You are required to complete the following fields: ";
if (document.advancedquote.area_size_1.value=="") {
themessage = themessage + " - Square Metre";
}
if (document.advancedquote.area_floor_1.value=="") {
themessage = themessage + " - Floor Type";
}
if (document.advancedquote.area_thermo_1.value=="") {
themessage = themessage + " - Thermostat";
}
if (themessage == "You are required to complete the following fields: ") {
document.advancedquote.submit();
}
else {
alert(themessage);
return false;
   }
}

