
function ValidateForm()
{	
	//var i = document.contactform.selectCountry.selectedIndex;
	//var x = document.contactform.selTitle.selectedIndex;
	
	/*
	if (contactform.date_day.selectedIndex == 0) {
		alert("Please enter today's date (day).") ;
		contactform.date_day.focus() ;
		return (false) ;
	}
	
	if (contactform.date_month.selectedIndex == 0) {
		alert("Please enter today's date (month).") ;
		contactform.date_month.focus() ;
		return (false) ;
	}
	
	if (contactform.date_year.value == "") {
		alert("Please enter today's date (year).") ;
		contactform.date_year.focus() ;
		return (false) ;
	}
	
	if (contactform.date_year.value.length > 0 && contactform.date_year.value.length < 4 ) {
		alert("Please enter the year in full (e.g. 2005).") ;
		contactform.date_year.focus() ;
		return (false) ;
	}
	
	if (contactform.location_of_incident.value == "") {
		alert("Please enter the location of the incident?") ;
		contactform.location_of_incident.focus() ;
		return (false) ;
	}
	
	if (contactform.type_of_loss.value == "") {
		alert("Please enter the type of loss?") ;
		contactform.type_of_loss.focus() ;
		return (false) ;
	}
	
	if (contactform.quantum_or_estimated_damage_cost.value == "") {
		alert("Please enter the quantum or estimated cost of damage.") ;
		contactform.quantum_or_estimated_damage_cost.focus() ;
		return (false) ;
	}
	
	if (contactform.currency.value == "") {
		alert("Please enter the currency.") ;
		contactform.currency.focus() ;
		return (false) ;
	}
	*/
	if (contactform.firstname.value == "") {
		alert("Please enter your first name.") ;
		contactform.firstname.focus() ;
		return (false) ;
	}
	
	if (contactform.surname.value == "") {
		alert("Please enter your surname.") ;
		contactform.surname.focus() ;
		return (false) ;
	}
	
	if (contactform.email.value == "") {
          alert("Please enter a valid e-mail address.") ;
          contactform.email.focus() ;
		  contactform.email.value = "Please enter a valid e-mail address." ;
		  contactform.email.select() ;
          return false;
        }
	
	if (contactform.email.value != "") {
        var atSign = contactform.email.value.indexOf("@");
		var dot = contactform.email.value.lastIndexOf(".");
		var str=document.contactform.email.value
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
        if (atSign<2 || dot>(contactform.email.value.length-3) || dot<(contactform.email.value.length-4) || dot==-1 || dot<atSign+3) {
          alert("Please enter a valid e-mail address.") ;
          contactform.email.focus() ;
		  contactform.email.select() ;
          return false;
        }
        atSign= contactform.email.value.indexOf("@", atSign+1);
        if (atSign>-1) {
          alert("Please enter a valid e-mail address.") ;
          contactform.email.focus() ;
		  contactform.email.select() ;
          return false;
        }
		if (!filter.test(str)){
		alert("Please enter a valid e-mail address.")
		contactform.email.focus() ;
		contactform.email.select() ;
		return false;
		}
	}
	
	if (contactform.countrycode.selectedIndex == 0) {
		alert("Please select your country of residence.") ;
		contactform.countrycode.focus() ;
		return (false) ;
	}
	
	if (contactform.telephone.value == "") {
		alert("Please enter your telephone number.") ;
		contactform.telephone.focus() ;
		return (false) ;
	}
	/*
	if (contactform.incident_date_day.selectedIndex == 0) {
		alert("Please enter date of incident (day).") ;
		contactform.incident_date_day.focus() ;
		return (false) ;
	}
	
	if (contactform.incident_date_month.selectedIndex == 0) {
		alert("Please enter date of incident (month).") ;
		contactform.incident_date_month.focus() ;
		return (false) ;
	}
	
	if (contactform.incident_date_year.value == "") {
		alert("Please enter date of incident (year).") ;
		contactform.incident_date_year.focus() ;
		return (false) ;
	}
	
	if (contactform.incident_date_year.value.length > 0 && contactform.incident_date_year.value.length < 4 ) {
		alert("Please enter the year in full (e.g. 2003).") ;
		contactform.incident_date_year.focus() ;
		return (false) ;
	}
	
	if (contactform.location_of_incident.value == "") {
		alert("Please enter location of incident.") ;
		contactform.location_of_incident.focus() ;
		return (false) ;
	}
	
	if (contactform.description_of_full_loss.value == "") {
		alert("Please enter description of full loss circumstances and details.") ;
		contactform.description_of_full_loss.focus() ;
		return (false) ;
	}
	
	if (contactform.estimated_damage_cost.value == "") {
		alert("Please enter estimated damage cost.") ;
		contactform.estimated_damage_cost.focus() ;
		return (false) ;
	}
	
	/*if (contactform.selTitle.options[contactform.selTitle.selectedIndex].value == "na") {
		alert("Please enter a title.") ;
		contactform.selTitle.focus() ;
		return (false) ;
	}
	*/	
	
	/*function checkDropdown(choice) {
    var error = "";
    if (choice == 0) {
       error = "You didn't choose an option
         from the drop-down list.\n";
    }    
return error;
}  


    why += checkDropdown(theForm.choose.selectedIndex);
    */  
	
	
	
		//return (true);
		//alert("success!");
		document.contactform.submit();
}

function request(language) {
  document.cookie="cv_language="+language+"; path="+location.pathname;
  if (document.cookie.length==0) {
    alert(enableCookies);
    return;
  }
  location.reload();
}

function enter(input) {
    input.className="activeinput";
}

// NOTE THAT function exit(input) CALLS checkLength(input) AND HAVE SET MAX AT 200

function exit(input) {
  input.className="invalidinput";
}

function enter2(input) {
    input.className="activeinput2";
}

function exit2(input) {
  input.className="invalidinput2";
}

function checkLength(input){

//var numWords=document.contactform.location.value
var numWords=input.value
numWords=numWords.split(" ")

ev = window.event
var charCode = (ev.which) ? ev.which : ev.keyCode
  if (charCode != 8 && input.type=="textarea" && numWords.length>200) {
    alert("200 words maximum in this field.");
    input.focus();
  }
}

function checkIt(evt) {
    evt = (evt) ? evt : window.event
         var charCode = (evt.which) ? evt.which : evt.keyCode
              if (charCode > 31 && (charCode < 48 || charCode > 57)) {
                   alert('This field accepts numbers only.')
//                 status = "This field accepts numbers only."
                        return false
                   }
              status = ""
         return true
}