//Copyright 2008
//Eadetech Limited
//This script is not to be copied or used outside this website unless permission is given by Eadetech Limited

//toggle script
function togimg(toggle) {

var info = document.getElementById(toggle);

	if(info.style.display == "none") {
	info.src = "img/minus.gif";
	info.style.display = "block"; 
} else if(info.style.display == "block") {
	info.src = "img/plus.gif";
	info.style.display = "none";
   }
}

function validatefrm() {
	
	if(document.contact.fullname.value.length == 0 || document.contact.fullname.value.length =="") {
		alert("Please Enter your Full name");
		document.contact.fullname.focus();
		document.contact.fullname.backgroundColor = "#890000;"
	} else if(document.contact.email.value.length == 0 || document.contact.email.value.length =="") {
		alert("Please Enter your Email Address");
		document.contact.email.focus();
	} else if(document.contact.phone.value.length == 0 || document.contact.phone.value.length =="") {
		alert("Please Enter your Phone number");
		document.contact.phone.focus();
	} else if(document.contact.requirements.value.length == 0 || document.contact.requirements.value.length == "") {
		alert("Please Enter your project requirements");
		document.contact.requirements.focus();
	} else if(document.contact.need.value == 0 || document.contact.need.value == "") {
		alert("Please select your need");
		document.contact.need.focus();
	} else if(document.contact.prefcontact.value == 0 || document.contact.prefcontact.value == "") {
		alert("Please select your preferred contact method");
		document.contact.prefcontact.focus();
	} else if(document.contact.findus.value == 0 || document.contact.findus.value == "") {
		alert("Please tell us how you found us");
		document.contact.findus.focus();
	} else {
		document.contact.action = "";
		document.contact.method = "POST";
		document.contact.submit(); //submits form
		document.getElementById("cform").style.display = "none";
		var st = document.getElementById("status");
		
		st.style.display = "block";
		st.innerHTML = "Form Filled out correctly and sent";
	}
} //end of function

//Start of quotation section -----------------------------------------------------

//set values to 0 initially
total1 = 0;
total2 = 0;
total3 = 0;
total = 0;
totals = 0;
totextra = 0;
formdisplay = 0;

function sum() {

  var x = document.getElementById("hosting"); //hosting amount dropdown list
  var y = document.getElementById("domain"); //domain amount dropdown list
  var p = document.getElementById("pages"); //page amount dropdown list
  var xt = document.getElementById("seo"); //seo amount dropdown list
  var type = document.getElementById("type"); //webtype drop down list

    total1 = x.value;
    total2 = y.value;
	total3 = p.value;
	
//Extras
if(type.value == 0) { //if website type is selected as SELECT then hide static pages
	document.getElementById("pagetype").style.display = "none";
	document.getElementById("seocontainer").style.display = "none";
	total3 = 0; //reset the counter which holds value of the selected option on the id=pages
	} else
if(type.value == "static") {
	document.getElementById("extras").style.display = "block";
	document.getElementById("pagetype").style.display = "block";
	document.getElementById("seocontainer").style.display = "block";
	document.getElementById("dynamic").style.display = "none";
	if(xt.checked) { //if seo box is ticked
		if(p.selectedIndex == 0) {
				alert("No pages have been selected, please choose how many pages you need");
				xt.checked = false;
				total = 0;
			} else { //if a value exists on the pages list
				seosum = 0; //set counter
				//seopages = p.value; //takes the value selected from the pages drop down menu
				seosum = p.value * 40/100 ; //takes the value selected from pages drop down menu and times it by the percentage number divided by 100 to get percentage amount.
				seototal = Number(seosum); //Stores the total of the seo sum
				total = Number(seototal); //stores the seototal amount
			  }
	} else {
	total = 0; //reset back to 0 if seo is unticked again
	}
	
} else
 	if(type.value == "dynamic") {
		document.getElementById("pagetype").style.display = "none";
		document.getElementById("dynamic").style.display = "block";
		total3 = 0; //reset counter to 0
		document.getElementById("adlogincontainer").style.display = "none";
		document.getElementById("searchcontainer").style.display = "none";
		document.getElementById("seocontainer").style.display = "none";
}
	totals = Number(total1) + Number(total2) + Number(total3) + Number(total) + Number(totextra);
	document.getElementById('total').innerHTML = totals; //this adds all above values inside the html for the total id
}

function extras(objtype) {

var extype = document.getElementById(objtype); //takes each extra id and assigns to extype

	if(extype.checked) {
		var ex = extype.value;
		//alert(ex);
		totextra += Number(ex); //
		document.getElementById('total').innerHTML = totals + totextra;
	}
}

function conquote() {
	
	if(document.calc.pages.value == 0 && document.calc.domain.value == 0 && document.calc.hosting.value == 0 &&
	   document.calc.webtype.value == 0 && document.calc.requirements.value == 0) {
		document.getElementById("validfrmstatus").style.display = "block";
		document.getElementById("validfrmstatus").innerHTML = "To proceed with a quotation, please select or enter one section above";
		document.getElementById("validfrmstatus").style.color = "#990000";
	} else {
		
document.calc.cost.value = document.getElementById('total').innerHTML; //stores the current total in the hidden form variable value
document.calc.sem.value = total; //assign the value of total variable for seo to a hidden field named sem so it posts as part of the form
document.calc.submit(); //submit the form
	}
}
//end of quotation section

function qmail() {
	if(document.getElementById("quotemail").value != "") {
		document.getElementById("sub").disabled = false;
  }
}

//interest form validation so they cannot submit unless all fields are entered
function intvalid() {
	if(document.interest.name.value.length == 0 || 
	   document.interest.email.value.length == 0 || 
	    document.interest.phone.value.length == 0 || 
		 document.interest.details.value.length == 0) {
		alert("Please enter all fields to provide full information on your selected interest");
	} else {
		 document.interest.submit();
	}	
}