var add_count = 0;
var key_press = null;

function populate_series(funct) {
	
	var obj0 = document.getElementById('series_tr');
	obj0.style.display = "";
	
	var obj1 = document.getElementById('series');
	obj1.options.length = 0;
	
	obj1.options[0] = new Option("---Choose window series---", "", true, true);
	
	if(funct == "Horizontal sliding") {
		obj1.options[1] = new Option("Series 10", "Series 10", false, false);
		obj1.options[2] = new Option("Series 80", "Series 80", false, false);
	}
	if(funct == "Vertical sliding") {
		obj1.options[1] = new Option("Series 20", "Series 20", false, false);
		obj1.options[2] = new Option("Series 90", "Series 90", false, false);
		obj1.options[3] = new Option("Series 60", "Series 60", false, false);
	}
	if(funct == "Hinged casement") {
		obj1.options[1] = new Option("Series 45", "Series 45", false, false);
		obj1.options[2] = new Option("Series 40", "Series 40", false, false);
		obj1.options[3] = new Option("Series 50", "Series 50", false, false);
	}
	if(funct == "Lift-out") {
		obj1.options[1] = new Option("Series 30", "Series 30", false, false);
		obj1.options[2] = new Option("Series 45", "Series 45", false, false);
		obj1.options[3] = new Option("Series 40", "Series 40", false, false);
	}
	if(funct == "Fixed") {
		obj1.options[1] = new Option("Series 45", "Series 45", false, false);
		obj1.options[2] = new Option("Series 40", "Series 40", false, false);
	}
	
		//document.getElementById('quantity').value = "";
		//document.getElementById('height').value = "";
		//document.getElementById('width').value = "";
		//document.getElementById('sill').value = "";
		//document.getElementById('colour').value = "White";
		//document.getElementById('glass_other').value = "Enter glass type here";
			
		//document.getElementById('series_tr').style.display = "none";
		document.getElementById('type_tr').style.display = "none";
		
		document.getElementById('quantity_tr').style.display = "none";
		document.getElementById('height_tr').style.display = "none";
		document.getElementById('width_tr').style.display = "none";
		document.getElementById('sill_tr').style.display = "none";
		document.getElementById('glass_tr').style.display = "none";
		document.getElementById('colour_tr').style.display = "none";
		document.getElementById('button_tr').style.display = "none";

}
function populate_type(series) {
	
	var funct = document.getElementById('funct').value;
	var obj0 = document.getElementById('type_tr');
	var obj1 = document.getElementById('type');
	obj1.options.length = 0;
		
		
	if(funct == "Vertical sliding" && series == "Series 60") {
		obj0.style.display = "";
		obj1.options[0] = new Option("Tilt-in", "Tilt-in", true, true);
	}
	else if(funct == "Horizontal sliding") {
		obj0.style.display = "";
		obj1.options[0] = new Option("---Choose window type---", "", true, true);
		obj1.options[1] = new Option("2 pane", "2 pane", false, false);
		obj1.options[2] = new Option("3 pane", "3 pane", false, false);
		obj1.options[3] = new Option("4 pane", "4 pane", false, false);
	}
	else if(funct == "Hinged casement") {
		obj0.style.display = "";
		obj1.options[0] = new Option("---Choose window type---", "", true, true);
		obj1.options[1] = new Option("Single", "Single", false, false);
		obj1.options[2] = new Option("Double", "Double", false, false);
	}
	else {
		document.getElementById('type_tr').style.display = "none";
	}
	
	document.getElementById('quantity_tr').style.display = "";
	document.getElementById('height_tr').style.display = "";
	document.getElementById('width_tr').style.display = "";
	document.getElementById('sill_tr').style.display = "";
	document.getElementById('glass_tr').style.display = "";
	document.getElementById('glass_other').style.display = "none";
	document.getElementById('colour_tr').style.display = "";
	document.getElementById('button_tr').style.display = "";
}

function sill_check() {
	var obj1 = document.getElementById('glass');
	var obj2 = document.getElementById('glass_other');
	var obj3 = document.getElementById('sill');
	obj2.style.display = "none";

	if(obj3.value < 800) {
		obj1.options.length = 0;
		
		obj1.options[0] = new Option("---Choose glass type---", "", true, true);
		obj1.options[1] = new Option("4mm Safety glass", "4mm Safety glass", false, false);
		obj1.options[2] = new Option("6mm Safety glass", "6mm Safety glass", false, false);
		obj1.options[3] = new Option("Other", "Other", false, false);
	}
	else {
		obj1.options.length = 0;
		obj1.options[0] = new Option("---Choose glass type---", "", true, true);
		obj1.options[1] = new Option("4mm", "4mm", false, false);
		obj1.options[2] = new Option("6mm", "6mm", false, false);
		obj1.options[3] = new Option("Other", "Other", false, false);
	}
}



function add_it() {
	if(document.getElementById('funct').value == "" || document.getElementById('funct').value == null) alert("Please choose a window function before adding this window to your project.");
	else if(document.getElementById('series').value == "" || document.getElementById('series').value == null) alert("Please choose a  window series before adding this window to your project.");
	else if(document.getElementById('quantity').value == "" || document.getElementById('quantity').value == null || isNaN(document.getElementById('quantity').value)) alert("Please add a quantity before adding this window to your project.");
	else if(document.getElementById('height').value == "" || document.getElementById('height').value == null || isNaN(document.getElementById('height').value)) alert("Please add a height in mm before adding this window to your project.");
	else if(document.getElementById('width').value == "" || document.getElementById('width').value == null || isNaN(document.getElementById('width').value)) alert("Please add a width in mm before adding this window to your project.");
	else if(document.getElementById('sill').value == "" || document.getElementById('sill').value == null || isNaN(document.getElementById('sill').value)) alert("Please add a sill height in mm before adding this window to your project.");
	else if(document.getElementById('glass').value == "" || document.getElementById('glass').value == null) alert("Please choose a glass preference before adding this window to your project.");
	else if(document.getElementById('colour').value == "" || document.getElementById('colour').value == null) alert("Please add a colour before adding this window to your project.");
	
	else {
		add_count++;
		
		var obj0 = document.getElementById('project_table');
		obj0.style.display = "";
		var obj1 = document.getElementById('send_tr');
		obj1.style.display = "";
	
	
	
		var quantity = document.getElementById('quantity').value;
		var funct = document.getElementById('funct').value;
		var series = document.getElementById('series').value;
		var type = document.getElementById('type').value;
		var height = document.getElementById('height').value;
		var width = document.getElementById('width').value;
		var sill = document.getElementById('sill').value;
		var glass = document.getElementById('glass').value;
		var glass_other = document.getElementById('glass_other').value;
		var colour = document.getElementById('colour').value;
		
		var container_table = document.getElementById('project_table');
		mycurrent_tbody = document.createElement("tbody");
		
			mycurrent_row = document.createElement("tr");
			mycurrent_row.setAttribute("id", "added_row_" + add_count);
			   
					mycurrent_cell = document.createElement("td");
					mycurrent_cell.setAttribute("class", "tablebodywhite");
						current_field = document.createElement("input");
						current_field.setAttribute("type", "text");
						current_field.setAttribute("name", "quantity" + add_count);
						current_field.setAttribute("id", "quantity" + add_count);
						current_field.setAttribute("class", "gris");
						current_field.setAttribute("className", "gris");
						current_field.setAttribute("size", "2");
						current_field.setAttribute("value", quantity);
						current_field.setAttribute("readOnly", true);
						mycurrent_cell.appendChild(current_field);
				mycurrent_row.appendChild(mycurrent_cell);
				
					mycurrent_cell = document.createElement("td");
					mycurrent_cell.setAttribute("class", "tablebodywhite");
						current_field = document.createElement("input");
						current_field.setAttribute("type", "text");
						current_field.setAttribute("name", "funct" + add_count);
						current_field.setAttribute("id", "funct" + add_count);
						current_field.setAttribute("class", "gris");
						current_field.setAttribute("className", "gris");
						current_field.setAttribute("size", "9");
						current_field.setAttribute("value", funct);
						current_field.setAttribute("readOnly", true);
						mycurrent_cell.appendChild(current_field);
				mycurrent_row.appendChild(mycurrent_cell);
				
					mycurrent_cell = document.createElement("td");
					mycurrent_cell.setAttribute("class", "tablebodywhite");
						current_field = document.createElement("input");
						current_field.setAttribute("type", "text");
						current_field.setAttribute("name", "series" + add_count);
						current_field.setAttribute("id", "series" + add_count);
						current_field.setAttribute("class", "gris");
						current_field.setAttribute("className", "gris");
						current_field.setAttribute("size", "9");
						current_field.setAttribute("value", series);
						current_field.setAttribute("readOnly", true);
						mycurrent_cell.appendChild(current_field);
				mycurrent_row.appendChild(mycurrent_cell);
				
					mycurrent_cell = document.createElement("td");
					mycurrent_cell.setAttribute("class", "tablebodywhite");
						current_field = document.createElement("input");
						current_field.setAttribute("type", "text");
						current_field.setAttribute("name", "type" + add_count);
						current_field.setAttribute("id", "type" + add_count);
						current_field.setAttribute("class", "gris");
						current_field.setAttribute("className", "gris");
						current_field.setAttribute("size", "6");
						current_field.setAttribute("value", type);
						current_field.setAttribute("readOnly", true);
						mycurrent_cell.appendChild(current_field);
				mycurrent_row.appendChild(mycurrent_cell);
				
					mycurrent_cell = document.createElement("td");
					mycurrent_cell.setAttribute("class", "tablebodywhite");
						current_field = document.createElement("input");
						current_field.setAttribute("type", "text");
						current_field.setAttribute("name", "height" + add_count);
						current_field.setAttribute("id", "height" + add_count);
						current_field.setAttribute("class", "gris");
						current_field.setAttribute("className", "gris");
						current_field.setAttribute("size", "6");
						current_field.setAttribute("value", height + "mm");
						current_field.setAttribute("readOnly", true);
						mycurrent_cell.appendChild(current_field);
				mycurrent_row.appendChild(mycurrent_cell);
				
					mycurrent_cell = document.createElement("td");
					mycurrent_cell.setAttribute("class", "tablebodywhite");
						current_field = document.createElement("input");
						current_field.setAttribute("type", "text");
						current_field.setAttribute("name", "width" + add_count);
						current_field.setAttribute("id", "width" + add_count);
						current_field.setAttribute("class", "gris");
						current_field.setAttribute("className", "gris");
						current_field.setAttribute("size", "6");
						current_field.setAttribute("value", width + "mm");
						current_field.setAttribute("readOnly", true);
						mycurrent_cell.appendChild(current_field);
				mycurrent_row.appendChild(mycurrent_cell);
				
					mycurrent_cell = document.createElement("td");
					mycurrent_cell.setAttribute("class", "tablebodywhite");
						current_field = document.createElement("input");
						current_field.setAttribute("type", "text");
						current_field.setAttribute("name", "sill" + add_count);
						current_field.setAttribute("id", "sill" + add_count);
						current_field.setAttribute("class", "gris");
						current_field.setAttribute("className", "gris");
						current_field.setAttribute("size", "6");
						current_field.setAttribute("value", sill + "mm");
						current_field.setAttribute("readOnly", true);
						mycurrent_cell.appendChild(current_field);
				mycurrent_row.appendChild(mycurrent_cell);
				
					mycurrent_cell = document.createElement("td");
					mycurrent_cell.setAttribute("class", "tablebodywhite");
						current_field = document.createElement("input");
						current_field.setAttribute("type", "text");
						current_field.setAttribute("name", "glass" + add_count);
						current_field.setAttribute("id", "glass" + add_count);
						current_field.setAttribute("class", "gris");
						current_field.setAttribute("className", "gris");
						current_field.setAttribute("size", "7");
						if(glass_other && glass_other != "Enter glass type here") current_field.setAttribute("value", glass_other);
						else current_field.setAttribute("value", glass);
						current_field.setAttribute("readOnly", true);
						mycurrent_cell.appendChild(current_field);
				mycurrent_row.appendChild(mycurrent_cell);
				
					mycurrent_cell = document.createElement("td");
					mycurrent_cell.setAttribute("class", "tablebodywhite");
						current_field = document.createElement("input");
						current_field.setAttribute("type", "text");
						current_field.setAttribute("name", "colour" + add_count);
						current_field.setAttribute("id", "colour" + add_count);
						current_field.setAttribute("class", "gris");
						current_field.setAttribute("className", "gris");
						current_field.setAttribute("size", "6");
						current_field.setAttribute("value", colour);
						current_field.setAttribute("readOnly", true);
					mycurrent_cell.appendChild(current_field);
				mycurrent_row.appendChild(mycurrent_cell);
	
					mycurrent_cell = document.createElement("td");
					mycurrent_cell.setAttribute("class", "tablebodywhite");
						edit_button = document.createElement("input");
						edit_button.setAttribute("type", "button");
						edit_button.setAttribute("name", "editor" + add_count);
						edit_button.setAttribute("id", "editor" + add_count);
						edit_button.setAttribute("value", "Edit");
						//edit_button.setAttribute("onClick", "edit_it('" + add_count + "')");
					mycurrent_cell.appendChild(edit_button);
				mycurrent_row.appendChild(mycurrent_cell);
	
					mycurrent_cell = document.createElement("td");
					mycurrent_cell.setAttribute("class", "tablebodywhite");
						remove_button = document.createElement("input");
						remove_button.setAttribute("type", "button");
						remove_button.setAttribute("name", "remover");
						remove_button.setAttribute("id", "remover");
						remove_button.setAttribute("value", "Remove");
						//remove_button.setAttribute("onClick", "remove_it('added_row_" + add_count + "')");
					mycurrent_cell.appendChild(remove_button);
				mycurrent_row.appendChild(mycurrent_cell);
	
			mycurrent_tbody.appendChild(mycurrent_row);
			container_table.appendChild(mycurrent_tbody);

			eval("edit_button.onclick = function() {edit_it(" + add_count + ")}");
			eval("remove_button.onclick = function() {remove_it('added_row_" + add_count + "')}");					

		document.getElementById('quantity').value = "";
		document.getElementById('height').value = "";
		document.getElementById('width').value = "";
		document.getElementById('sill').value = "";
		document.getElementById('colour').value = "White";
		document.getElementById('glass_other').value = "Enter glass type here";
			
		document.getElementById('series_tr').style.display = "none";
		document.getElementById('type_tr').style.display = "none";
		
		document.getElementById('quantity_tr').style.display = "none";
		document.getElementById('height_tr').style.display = "none";
		document.getElementById('width_tr').style.display = "none";
		document.getElementById('sill_tr').style.display = "none";
		document.getElementById('glass_tr').style.display = "none";
		document.getElementById('colour_tr').style.display = "none";
		document.getElementById('button_tr').style.display = "none";
		
		var obj9 = document.getElementById('funct');
		obj9.options.length = 0;
		obj9.options[0] = new Option("---Choose window function---", "", true, true);
		obj9.options[1] = new Option("Horizontal sliding", "Horizontal sliding", false, false);
		obj9.options[2] = new Option("Vertical sliding", "Vertical sliding", false, false);
		obj9.options[3] = new Option("Hinged casement", "Hinged casement", false, false);
		obj9.options[4] = new Option("Lift-out", "Lift-out", false, false);
		obj9.options[5] = new Option("Fixed", "Fixed", false, false);
		
		var obj10 = document.getElementById('glass');
		obj10.options.length = 0;
		obj10.options[0] = new Option("---Choose glass type---", "", true, true);
		obj10.options[1] = new Option("4mm", "4mm", false, false);
		obj10.options[2] = new Option("6mm", "6mm", false, false);
		obj10.options[3] = new Option("Other", "Other", false, false);
	}
}

function remove_it(row) {
		var obj0 = document.getElementById(row);
		obj0.style.display = "none";

}

function hider () {
	document.getElementById('series_tr').style.display = "none";
	document.getElementById('type_tr').style.display = "none";
	
	document.getElementById('quantity_tr').style.display = "none";
	document.getElementById('height_tr').style.display = "none";
	document.getElementById('width_tr').style.display = "none";
	document.getElementById('sill_tr').style.display = "none";
	document.getElementById('glass_tr').style.display = "none";
	document.getElementById('colour_tr').style.display = "none";
	document.getElementById('button_tr').style.display = "none";
	
	document.getElementById('project_table').style.display = "none";
	//var document.getElementById('send_tr').style.display = "none";
	
	document.getElementById('about_your_tr').style.display = "none";
	document.getElementById('tell_us_tr').style.display = "none";
	document.getElementById('diff_address_tr').style.display = "none";
	document.getElementById('diff_postcode_tr').style.display = "none";
	document.getElementById('purpose_tr').style.display = "none";
	document.getElementById('include_tr').style.display = "none";
	document.getElementById('windows_tr').style.display = "none";
	document.getElementById('answer_tr').style.display = "none";
	document.getElementById('function_tr').style.display = "none";
	document.getElementById('table_tr').style.display = "none";
	document.getElementById('additional_proj_tr').style.display = "none";
	document.getElementById('blanker_1_tr').style.display = "none";
	document.getElementById('blanker_2_tr').style.display = "none";
}

function key_pressed(e) {
	if(window.event) last_key = window.event.keyCode;     //IE
	else last_key = e.which;     //firefox
}

function submit_it() {	
	if(last_key == 13) {
		return false;
	}
	else {
		var purpose_checked = "clear";
		if(document.email_form.purposegroup[0].checked == true) purpose_checked = "checked";
		if(document.email_form.purposegroup[1].checked == true) purpose_checked = "checked";
		if(document.email_form.purposegroup[2].checked == true) purpose_checked = "checked";
	
		if(document.getElementById('firstname').value == "" || document.getElementById('firstname').value == null) {
			alert("Please enter your First name in the appropriate box before submitting the price enquiry.")
			return false;
		}
		else if(document.getElementById('lastname').value == "" || document.getElementById('lastname').value == null) {
			alert("Please enter your Last name in the appropriate box before submitting the price enquiry.")
			return false;
		}
		else if(document.getElementById('iam').value == "" || document.getElementById('iam').value == null) {
			alert("Please choose from the options from the 'I am:' fields before submitting the price enquiry.")
			return false;
		}
		else if(document.getElementById('address').value == "" || document.getElementById('address').value == null) {
			alert("Please enter your Address in the appropriate box before submitting the price enquiry.")
			return false;
		}
		else if(document.getElementById('postcode').value == "" || document.getElementById('postcode').value == null) {
			alert("Please enter your Postcode in the appropriate box before submitting the price enquiry.")
			return false;
		}
		else if(document.getElementById('phone').value == "" || document.getElementById('phone').value == null) {
			alert("Please enter your Phone number in the appropriate box before submitting the price enquiry.")
			return false;
		}
		else if(document.getElementById('email').value == "" || document.getElementById('email').value == null) {
			alert("Please enter your Email address in the appropriate box before submitting the price enquiry.")
			return false;
		}
		else if(document.getElementById('email').value !=  document.getElementById('email_confirm').value) {
			alert("Please make sure your email confirmation is the same as your email address before submitting the price enquiry.")
			return false;
		}
	
		else if(purpose_checked == "clear" && like == "to make a price enquiry") {
			alert("Please choose at least one option from the 'What is the purpose of the secondary glazing?' fields before submitting the price enquiry.")
			return false;
		}
	
		else if(document.getElementById('supply').value== "" ||  document.getElementById('supply').value == null) {
			alert("Please choose from the options from the 'What would you like your estimate to include?' fields before submitting the price enquiry.")
			return false;
		}
	
	
		
		else {
			return true;
		}
	}//end keypress check
}
	
function edit_it(rownum) {
	if(document.getElementById('editor' + rownum).value == "Edit") {
		document.getElementById('quantity' + rownum).readOnly = false;
		document.getElementById('quantity' + rownum).style.backgroundColor = "#FFFFFF";
		document.getElementById('funct' + rownum).readOnly = false;
		document.getElementById('funct' + rownum).style.backgroundColor = "#FFFFFF";
		document.getElementById('series' + rownum).readOnly = false;
		document.getElementById('series' + rownum).style.backgroundColor = "#FFFFFF";
		document.getElementById('type' + rownum).readOnly = false;
		document.getElementById('type' + rownum).style.backgroundColor = "#FFFFFF";
		document.getElementById('height' + rownum).readOnly = false;
		document.getElementById('height' + rownum).style.backgroundColor = "#FFFFFF";
		document.getElementById('width' + rownum).readOnly = false;
		document.getElementById('width' + rownum).style.backgroundColor = "#FFFFFF";
		document.getElementById('sill' + rownum).readOnly = false;
		document.getElementById('sill' + rownum).style.backgroundColor = "#FFFFFF";
		document.getElementById('glass' + rownum).readOnly = false;
		document.getElementById('glass' + rownum).style.backgroundColor = "#FFFFFF";
		document.getElementById('colour' + rownum).readOnly = false;
		document.getElementById('colour' + rownum).style.backgroundColor = "#FFFFFF";
		document.getElementById('editor' + rownum).value = "Save";
		
	
	}
	else {
		//CBD0BF
		document.getElementById('quantity' + rownum).readOnly = true;
		document.getElementById('quantity' + rownum).style.backgroundColor = "#CCCCCC";
		document.getElementById('funct' + rownum).readOnly = true;
		document.getElementById('funct' + rownum).style.backgroundColor = "#CCCCCC";
		document.getElementById('series' + rownum).readOnly = true;
		document.getElementById('series' + rownum).style.backgroundColor = "#CCCCCC";
		document.getElementById('type' + rownum).readOnly = true;
		document.getElementById('type' + rownum).style.backgroundColor = "#CCCCCC";
		document.getElementById('height' + rownum).readOnly = true;
		document.getElementById('height' + rownum).style.backgroundColor = "#CCCCCC";
		document.getElementById('width' + rownum).readOnly = true;
		document.getElementById('width' + rownum).style.backgroundColor = "#CCCCCC";
		document.getElementById('sill' + rownum).readOnly = true;
		document.getElementById('sill' + rownum).style.backgroundColor = "#CCCCCC";
		document.getElementById('glass' + rownum).readOnly = true;
		document.getElementById('glass' + rownum).style.backgroundColor = "#CCCCCC";
		document.getElementById('colour' + rownum).readOnly = true;
		document.getElementById('colour' + rownum).style.backgroundColor = "#CCCCCC";
		document.getElementById('editor' + rownum).value = "Edit";
	}
}
function clear_other() {
	obj = document.getElementById('glass_other');
	if (obj.value == "Enter glass type here") {
		obj.value = "";
	}
}
function fill_other() {
	obj = document.getElementById('glass_other');
	if (obj.value == "") {
		obj.value = "Enter glass type here";
	}
}
function other_hider() {
	obj = document.getElementById('glass');
	obj1 = document.getElementById('glass_other');
	if (obj.value == "Other") {
		obj1.style.display = "";
	}
	else {
		obj1.style.display = "none";	
	}
}

function max_width() {
	var funct = document.getElementById('funct').value;
	var series = document.getElementById('series').value;
	var type = document.getElementById('type').value;
	var width = document.getElementById('width');
	var widthval = width.value;
	
	if(funct == "Horizontal sliding") {
		if(series == "Series 10") {
			if (type == "2 pane" && widthval > 2200) {
				alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
				width.value = 2200;
			}
			if (type == "3 pane" && widthval > 3300) {
				alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
				width.value = 3300;
			}
			if (type == "4 pane" && widthval > 4400) {
				alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
				width.value = 4400;
			}
		}
		if(series == "Series 80") {
			if (type == "2 pane" && widthval > 3000) {
				alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
				width.value = 3000;
			}
			if (type == "3 pane" && widthval > 4200) {
				alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
				width.value = 4200;
			}
			if (type == "4 pane" && widthval > 5600) {
				alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
				width.value = 5600;
			}
		}
		if(series == "Series 85") {
			if (type == "2 pane" && widthval > 2600) {
				alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
				width.value = 2600;
			}
		}
	}
	
	if(funct == "Vertical sliding") {
		if(series == "Series 20" && widthval > 1500) {
			alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
			width.value = 1500;
		}
		if(series == "Series 60" && widthval > 1500) {
			alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
			width.value = 1500;
		}
		if(series == "Series 90" && widthval > 1600) {
			alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
			width.value = 1600;
		}
		if(series == "Series 95" && widthval > 1600) {
			alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
			width.value = 1600;
		}
	}
	
	if(funct == "Hinged casement") {
		if(series == "Series 40") {
			if (type == "Single" && widthval > 1500) {
				alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
				width.value = 1500;
			}
			if (type == "Double" && widthval > 3000) {
				alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
				width.value = 3000;
			}
		}
		if(series == "Series 45") {
			if (type == "Single" && widthval > 1300) {
				alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
				width.value = 1300;
			}
			if (type == "Double" && widthval > 2400) {
				alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
				width.value = 2400;
			}
		}
		if(series == "Series 50") {
			if (type == "Single" && widthval > 1500) {
				alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
				width.value = 1500;
			}
			if (type == "Double" && widthval > 3000) {
				alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
				width.value = 3000;
			}
		}
	}
	
	if(funct == "Lift-out") {
		if(series == "Series 30" && widthval > 1000) {
			alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
			width.value = 1000;
		}
		if(series == "Series 45" && widthval > 1000) {
			alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
			width.value = 1000;
		}
		if(series == "Series 40" && widthval > 1200) {
			alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
			width.value = 1200;
		}
	}
	
	if(funct == "Fixed") {
		if(series == "Series 40" && widthval > 1200) {
			alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
			width.value = 1200;
		}
		if(series == "Series 45" && widthval > 1000) {
			alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
			width.value = 1000;
		}
		if(series == "Series 50" && widthval > 1500) {
			alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
			width.value = 1500;
		}
		if(series == "Series 55" && widthval > 1500) {
			alert("Your chosen width is greater than that allowed for this window type; it has been reduced to the maximum value.");
			width.value = 1500;
		}
	}
}

function max_height() {
	var funct = document.getElementById('funct').value;
	var series = document.getElementById('series').value;
	var type = document.getElementById('type').value;
	var height = document.getElementById('height');
	var heightval = height.value;
	
	if(funct == "Horizontal sliding") {
		if(series == "Series 10" && heightval > 2200) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 2200;
		}
		if(series == "Series 80" && heightval > 2600) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 2600;
		}
		if(series == "Series 85" && heightval > 2600) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 2600;
		}
	}
	
	if(funct == "Vertical sliding") {
		if(series == "Series 20" && heightval > 3000) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 3000;
		}
		if(series == "Series 60" && heightval > 3000) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 3000;
		}
		if(series == "Series 90" && heightval > 3600) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 3600;
		}
		if(series == "Series 95" && heightval > 3600) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 3600;
		}
	}
	
	if(funct == "Hinged casement") {
		if(series == "Series 40" && heightval > 2700) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 2700;
		}
		if(series == "Series 45" && heightval > 2200) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 2200;
		}
		if(series == "Series 50" && heightval > 3200) {
				alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
				height.value = 3200;
		}
	}
	
	if(funct == "Lift-out") {
		if(series == "Series 30" && heightval > 1700) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 1700;
		}
		if(series == "Series 45" && heightval > 2000) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 2000;
		}
		if(series == "Series 40" && heightval > 2400) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 2400;
		}
	}
	
	if(funct == "Fixed") {
		if(series == "Series 40" && heightval > 2400) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 2400;
		}
		if(series == "Series 45" && heightval > 2000) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 2000;
		}
		if(series == "Series 50" && heightval > 3000) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 3000;
		}
		if(series == "Series 55" && heightval > 3000) {
			alert("Your chosen height is greater than that allowed for this window type; it has been reduced to the maximum value.");
			height.value = 3000;
		}
	}
}

function hide_price() {
	//var like = document.forms['email_form'].like[0];
	
	//if(like == "to make a price enquiry") {
	if(document.forms['email_form'].like[0].checked == true) {
		document.getElementById('about_your_tr').style.display = "";
		document.getElementById('tell_us_tr').style.display = "";
		document.getElementById('diff_address_tr').style.display = "";
		document.getElementById('diff_postcode_tr').style.display = "";
		document.getElementById('purpose_tr').style.display = "";
		document.getElementById('include_tr').style.display = "";
		document.getElementById('windows_tr').style.display = "";
		document.getElementById('answer_tr').style.display = "";
		document.getElementById('function_tr').style.display = "";
		document.getElementById('table_tr').style.display = "";
		document.getElementById('additional_proj_tr').style.display = "";
		document.getElementById('blanker_1_tr').style.display = "";
		document.getElementById('blanker_2_tr').style.display = "";
		
		document.getElementById('addinfo_tr').style.display = "none";
		
		document.getElementById('send').value = "Send price enquiry";
		if(add_count > 0) document.getElementById('send_tr').style.display = "";
		else document.getElementById('send_tr').style.display = "none";
	}
	else {
		document.getElementById('about_your_tr').style.display = "none";
		document.getElementById('tell_us_tr').style.display = "none";
		document.getElementById('diff_address_tr').style.display = "none";
		document.getElementById('diff_postcode_tr').style.display = "none";
		document.getElementById('purpose_tr').style.display = "none";
		document.getElementById('include_tr').style.display = "none";
		document.getElementById('windows_tr').style.display = "none";
		document.getElementById('answer_tr').style.display = "none";
		document.getElementById('function_tr').style.display = "none";
		
		document.getElementById('series_tr').style.display = "none";
		document.getElementById('type_tr').style.display = "none";
		document.getElementById('quantity_tr').style.display = "none";
		document.getElementById('sill_tr').style.display = "none";
		document.getElementById('height_tr').style.display = "none";
		document.getElementById('width_tr').style.display = "none";
		document.getElementById('glass_tr').style.display = "none";
		document.getElementById('colour_tr').style.display = "none";
		document.getElementById('button_tr').style.display = "none";
		
		
		
		
		document.getElementById('table_tr').style.display = "none";
		document.getElementById('additional_proj_tr').style.display = "none";
		document.getElementById('blanker_1_tr').style.display = "none";
		document.getElementById('blanker_2_tr').style.display = "none";
		
		document.getElementById('addinfo_tr').style.display = "";
		
		document.getElementById('send').value = "Send enquiry";
		document.getElementById('send_tr').style.display = "";
	}
	
}