var isOpen=false;
extract = new Object();
for (i=1; i<=30; i++){
	extract[i] = new Array();
	extract[i].isOpen = false;
}
function checkFocus(fieldname){
	var el = document.getElementById(fieldname);
	el.style.backgroundColor = "#999999";
	el.style.color = "white";
}
function loseFocus(fieldname){
	var el = document.getElementById(fieldname);
	el.style.backgroundColor = "white";	
	el.style.color = "#333333"
}
function showExtract(id, extractID){
	if (extract[id].isOpen==false){
		var el = document.getElementById(extractID);
		el.style.display = "block";
		extract[id].isOpen = true;
	} else{
		var el = document.getElementById(extractID);
		el.style.display = "none";
		extract[id].isOpen = false;
	}
}
	function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
	window.onload = func;
  } else {
	window.onload = function() {
	  oldonload();
	  func();
	}
  }
}

function prepareInputsForHints() {
  var inputs = document.getElementsByTagName("input");
  
  for (var i=0; i<inputs.length; i++){
	if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
		inputs[i].onfocus = function () {
			if (this.name=="searchField"){
				this.style.backgroundColor = "#999999";
				this.style.color = "white";
			}else{
				this.style.backgroundColor = "#c0264b";
				this.style.color = "white";
			}
			
		  this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
		}
		inputs[i].onblur = function () {
		  this.style.backgroundColor = "white";	
		  this.style.color = "#555555"
		  this.parentNode.getElementsByTagName("span")[0].style.display = "none";
		}
	}
  }
  var inputs = document.getElementsByTagName("textarea");
  
  for (var i=0; i<inputs.length; i++){
	if (inputs[i].parentNode.getElementsByTagName("span")[0]) {
		inputs[i].onfocus = function () {
			if (this.name=="searchField"){
				this.style.backgroundColor = "#999999";
				this.style.color = "white";
			}else{
				this.style.backgroundColor = "#c0264b";
				this.style.color = "white";
			}
			
		  this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
		}
		inputs[i].onblur = function () {
		  this.style.backgroundColor = "white";	
		  this.style.color = "#555555"
		  this.parentNode.getElementsByTagName("span")[0].style.display = "none";
		}
	}
  }
}
addLoadEvent(prepareInputsForHints);

function CheckFields() {

  // The fields are checked for blanks
  if ( document.pform.name.value   == "" ||
       document.pform.review.value  == "" ||
       document.pform.Email.value  == "" ) {
     alert( "You haven't completed the form.\nPlease ensure that all boxes are filled in." );
     
  }

// check for valid email address
else if ( document.pform.Email.value.length <= 6 ||
      document.pform.Email.value.indexOf ('@', 0) == -1 ||
      document.pform.Email.value.indexOf ('.', 0) == -1){

      alert("Sorry, " + document.pform.Email.value + " is not a valid Email Address.");
      
 }

  else { 
  

 document.pform.submit()
}

}
function CheckFields2() {

  // The fields are checked for blanks
  if ( document.pform.firstname.value   == "" ||
       document.pform.lastname.value   == "" ||
       document.pform.postcode.value  == "" ||
       document.pform.Email.value  == "" ) {
     alert( "You haven't completed the form.\nPlease ensure that all boxes are filled in." );
     
  }

// check for valid email address
else if ( document.pform.Email.value.length <= 6 ||
      document.pform.Email.value.indexOf ('@', 0) == -1 ||
      document.pform.Email.value.indexOf ('.', 0) == -1){

      alert("Sorry, " + document.pform.Email.value + " is not a valid Email Address.");
      
 }

  else { 
  

 document.pform.submit()
}

}
function CheckFields3() {

  // The fields are checked for blanks
  if ( document.pform.firstname.value   == "" ||
       document.pform.lastname.value   == "" ||
       document.pform.question.value  == "" ||
       document.pform.Email.value  == "" ) {
     alert( "You haven't completed the form.\nPlease ensure that all boxes are filled in." );
     
  }

// check for valid email address
else if ( document.pform.Email.value.length <= 6 ||
      document.pform.Email.value.indexOf ('@', 0) == -1 ||
      document.pform.Email.value.indexOf ('.', 0) == -1){

      alert("Sorry, " + document.pform.Email.value + " is not a valid Email Address.");
      
 }

  else { 
  

 document.pform.submit()
}

}