function stopgoogleautofill() {

  if(window.attachEvent)
    window.attachEvent("onload",setListeners);
}

function setListeners(){
  inputList = document.getElementsByTagName("INPUT");
  for(i=0;i<inputList.length;i++){
    inputList[i].attachEvent("onpropertychange",restoreStyles);
    inputList[i].style.backgroundColor = "";
  }
  selectList = document.getElementsByTagName("SELECT");
  for(i=0;i<selectList.length;i++){
    selectList[i].attachEvent("onpropertychange",restoreStyles);
    selectList[i].style.backgroundColor = "";
  }
}

function restoreStyles(){
  if(event.srcElement.style.backgroundColor != "")
    event.srcElement.style.backgroundColor = "";
}//-->


function showhidedrivinglicensecountryrow(straction) {
	if (straction == "hide") {
		document.frmlocumregistration.locumdrivinglicensecountry.value = "N/A"
    document.frmlocumregistration.locumdrivinglicensecountry.disabled = true;
	}
	else {
    document.frmlocumregistration.locumdrivinglicensecountry.disabled = false;
	  document.frmlocumregistration.locumdrivinglicensecountry.value = ""
	  document.frmlocumregistration.locumdrivinglicensecountry.focus();
	}
}


function validateregistration() {
/***************************************************************************/
/* Special Req's :- None                                                   */
/* Related Files :- None                                                   */
/* Purpose       :- To validate users entry                                */
/* Version       :- 1.00                                                   */
/* Author        :- Dennis McDermott                                       */
/* Date          :- 02/06/2008                                             */
/***************************************************************************/
/* Desc of Mod   :-                                                        */
/* Modified By   :-                                                        */
/* Date          :-                                                        */
/***************************************************************************/

/* check a first name has been entered */
if (document.frmlocumregistration.locumfirstname.value == "") {
  alert("Please enter your First Name");
  document.frmlocumregistration.locumfirstname.focus();
  return; 
}

/* check a surname has been entered */
if (document.frmlocumregistration.locumsurname.value == "") {
  alert("Please enter your Surname");
  document.frmlocumregistration.locumsurname.focus();
  return; 
}

/* if profession has not been picked */
if (document.frmlocumregistration.locumprofession.value == "Please Select") {
  alert("Please select a Profession");
  document.frmlocumregistration.locumprofession.focus();
  return;
}

/* if address has been entered then ensure postcode is entered */
if (document.frmlocumregistration.locumaddress1.value != "") {
	/* check a postcode has been entered */
	if (document.frmlocumregistration.locumpostcode.value == "") {
	  alert("Please enter your Postcode");
	  document.frmlocumregistration.locumpostcode.focus();
	  return; 
	}
	else {
	  document.frmlocumregistration.locumpostcode.value = document.frmlocumregistration.locumpostcode.value.toUpperCase()
	}
}

/* check a telephone number has been entered */
if (document.frmlocumregistration.locumphonenumber.value == "") {
  alert("Please enter your Telephone number");
  document.frmlocumregistration.locumphonenumber.focus();
  return; 
}

/*check email */
if (document.frmlocumregistration.locumemail.value != "") {
	if (! isemail(document.frmlocumregistration.locumemail.value)) {
	  alert("It does not look like you have entered a valid e-mail address")
	  document.frmlocumregistration.locumemail.focus();
	  return;
	}
}

/* check nationality has been entered */
if (document.frmlocumregistration.locumnationality.value == "") {
  alert("Please enter your nationality");
  document.frmlocumregistration.locumnationality.focus();
  return; 
} 

/* check a dob has been entered */
if (document.frmlocumregistration.locumdob.value == "") {
  alert("Please select your Date of Birth");
  document.frmlocumregistration.locumdob.focus();
  return; 
}

/* check a date available from has been entered */
if (document.frmlocumregistration.locumdateavailablefrom.value == "") {
  alert("Please select a Date you are available from");
  document.frmlocumregistration.locumdateavailablefrom.focus();
  return; 
}

/* check a date available to has been entered */
if (document.frmlocumregistration.locumdateavailableto.value == "") {
  alert("Please select a Date you are available to");
  document.frmlocumregistration.locumdateavailableto.focus();
  return; 
}

/* if a gender has not been selected */
if ((document.frmlocumregistration.locumgender[0].checked == false) && (document.frmlocumregistration.locumgender[1].checked == false)) {
  alert("Please select your Gender");
  return; 
}

/* if driving license has not been selected */
if ((document.frmlocumregistration.locumdrivinglicense[0].checked == false) && (document.frmlocumregistration.locumdrivinglicense[1].checked == false)) {
  alert("Please select whether or not you hold a Driving license");
  return; 
}

/* if driving license is yes */
if (document.frmlocumregistration.locumdrivinglicense[0].checked == true) {
	/* check driving license country has been entered */
	if (document.frmlocumregistration.locumdrivinglicensecountry.value == "") {
	  alert("Please enter the Country in which your driving license was issued");
	  document.frmlocumregistration.locumdrivinglicensecountry.focus();
	  return; 
	}  
}


/* if indemnity insurance not been selected */
if ((document.frmlocumregistration.locumindemnityinsurance[0].checked == false) && (document.frmlocumregistration.locumindemnityinsurance[1].checked == false)) {
  alert("Please select whether or not you have indemnity insurance");
  return; 
}

/* if terms and conditions have not been agreed */
if (document.frmlocumregistration.chktermsandcondidtions.checked == false) {
  alert("Please agree our Terms & Condidtions");
  return; 
}

if (document.frmlocumregistration.filetoupload01.value != "") {
	if(document.frmlocumregistration.filetoupload01.value.lastIndexOf(".jpg")==-1 &&
	  document.frmlocumregistration.filetoupload01.value.lastIndexOf(".png")==-1 &&
	  document.frmlocumregistration.filetoupload01.value.lastIndexOf(".gif")==-1 &&
	  document.frmlocumregistration.filetoupload01.value.lastIndexOf(".bmp")==-1 &&
	  document.frmlocumregistration.filetoupload01.value.lastIndexOf(".txt")==-1 &&		
	  document.frmlocumregistration.filetoupload01.value.lastIndexOf(".doc")==-1 &&
	  document.frmlocumregistration.filetoupload01.value.lastIndexOf(".xls")==-1 &&
	  document.frmlocumregistration.filetoupload01.value.lastIndexOf(".pdf")==-1 ) {
	  alert("Your First file does not appear to be valid\n\nPlease upload only files of the following types\n\nImage files .jpg .png .gif .bmp\n\nText Files\n\nWord Documents\n\nExcel Spreadsheets\n\nPDF files");
	  return false;
	}
}

if (document.frmlocumregistration.filetoupload02.value != "") {	
	if(document.frmlocumregistration.filetoupload02.value.lastIndexOf(".jpg")==-1 &&
	  document.frmlocumregistration.filetoupload02.value.lastIndexOf(".png")==-1 &&
	  document.frmlocumregistration.filetoupload02.value.lastIndexOf(".gif")==-1 &&
	  document.frmlocumregistration.filetoupload02.value.lastIndexOf(".bmp")==-1 &&
	  document.frmlocumregistration.filetoupload02.value.lastIndexOf(".txt")==-1 &&
	  document.frmlocumregistration.filetoupload02.value.lastIndexOf(".doc")==-1 &&
	  document.frmlocumregistration.filetoupload02.value.lastIndexOf(".xls")==-1 &&
	  document.frmlocumregistration.filetoupload02.value.lastIndexOf(".pdf")==-1 ) {
	  alert("Your Second file does not appear to be valid\n\nPlease upload only files of the following types\n\nImage files .jpg .png .gif .bmp\n\nText Files\n\nWord Documents\n\nExcel Spreadsheets\n\nPDF files");
	  return false;
	}
}

if (document.frmlocumregistration.filetoupload03.value != "") {	
	if(document.frmlocumregistration.filetoupload03.value.lastIndexOf(".jpg")==-1 &&
	  document.frmlocumregistration.filetoupload03.value.lastIndexOf(".png")==-1 &&
	  document.frmlocumregistration.filetoupload03.value.lastIndexOf(".gif")==-1 &&
	  document.frmlocumregistration.filetoupload03.value.lastIndexOf(".bmp")==-1 &&
	  document.frmlocumregistration.filetoupload03.value.lastIndexOf(".txt")==-1 &&		
	  document.frmlocumregistration.filetoupload03.value.lastIndexOf(".doc")==-1 &&
	  document.frmlocumregistration.filetoupload03.value.lastIndexOf(".xls")==-1 &&
	  document.frmlocumregistration.filetoupload03.value.lastIndexOf(".pdf")==-1 ) {
	  alert("Your Third file does not appear to be valid\n\nPlease upload only files of the following types\n\nImage files .jpg .png .gif .bmp\n\nText Files\n\nWord Documents\n\nExcel Spreadsheets\n\nPDF files");
	  return false;
	}
}

if (document.frmlocumregistration.filetoupload04.value != "") {	
	if(document.frmlocumregistration.filetoupload04.value.lastIndexOf(".jpg")==-1 &&
	  document.frmlocumregistration.filetoupload04.value.lastIndexOf(".png")==-1 &&
	  document.frmlocumregistration.filetoupload04.value.lastIndexOf(".gif")==-1 &&
	  document.frmlocumregistration.filetoupload04.value.lastIndexOf(".bmp")==-1 &&
	  document.frmlocumregistration.filetoupload04.value.lastIndexOf(".txt")==-1 &&		
	  document.frmlocumregistration.filetoupload04.value.lastIndexOf(".doc")==-1 &&
	  document.frmlocumregistration.filetoupload04.value.lastIndexOf(".xls")==-1 &&
	  document.frmlocumregistration.filetoupload04.value.lastIndexOf(".pdf")==-1 ) {
	  alert("Your Forth file does not appear to be valid\n\nPlease upload only files of the following types\n\nImage files .jpg .png .gif .bmp\n\nText Files\n\nWord Documents\n\nExcel Spreadsheets\n\nPDF files");
	  return false;
	}
}


/* for each element on the form */
for(thiselement = 0; thiselement <= document.frmlocumregistration.elements.length -1; thiselement++) {
  /* if the field is a txt field */
  if(document.frmlocumregistration.elements[thiselement].type.indexOf('text') == 0) {
    /* replace banned characters in this field fields */		
	 document.frmlocumregistration.elements[thiselement].value =
     replacebannedchars(document.frmlocumregistration.elements[thiselement].value)
  /* endif the field is a txt field */		
  }
}

/* if user has selected files and all extension are valid */ 
if (document.frmlocumregistration.filetoupload01.value != "" || document.frmlocumregistration.filetoupload02.value != "" || document.frmlocumregistration.filetoupload03.value != "" || document.frmlocumregistration.filetoupload04.value != "") {
	 document.getElementById('uploadingfilesfeedback').style.display = 'inline'
}

document.frmlocumregistration.submit();

}
/***************************************************************************/
/*                 End of function validateregistration()                  */
/***************************************************************************/

function isemail(string) {
/***************************************************************************/
/* Special Req's :- None                                                   */
/* Related Files :- None                                                   */
/* Purpose       :- Check to see if string represents a valid email address*/
/* Version       :- 1.00                                                   */
/* Author        :- Dennis McDermott                                       */
/* Date          :- 28/05/2008                                             */
/***************************************************************************/
/* Desc of Mod   :-                                                        */
/* Modified By   :-                                                        */
/* Date          :-                                                        */
/***************************************************************************/
if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
  return true;
else
  return false;
}
/***************************************************************************/
/*                        End of function isEmail()                        */
/***************************************************************************/

function validateenquiry() {
/***************************************************************************/
/* Special Req's :- None                                                   */
/* Related Files :- None                                                   */
/* Purpose       :- Check data has been entered before submitting form     */
/* Version       :- 1.00                                                   */
/* Author        :- Dennis McDermott                                       */
/* Date          :- 28/05/2008                                             */
/***************************************************************************/
/* Desc of Mod   :-                                                        */
/* Modified By   :-                                                        */
/* Date          :-                                                        */
/***************************************************************************/

/* if no name has been supplied */
if (document.frmenquiry.txtname.value == "") {
  alert("Please enter your Name");
  document.frmenquiry.txtname.focus();  
  return;
}  

/* if email has been supplied but is invalid  */
if (document.frmenquiry.txtemail.value != "" && !isemail(document.frmenquiry.txtemail.value)) {
    alert("Your e-mail Address appears to be invalid\n\nPlease enter a valid E-mail Address");
    document.frmenquiry.txtemail.focus();
    return; 
}  


/* if email nor telephone number have been supplied */
if (document.frmenquiry.txtemail.value == "" && document.frmenquiry.txttelephone.value == "") {
    alert("Please supply either a valid E-mail address or a Telephone Number");
    document.frmenquiry.txtemail.focus();
    return; 
}  

/* if no message has been supplied */
if (document.frmenquiry.txtmessage.value == "") {
  alert("Please enter your Message");
  document.frmenquiry.txtmessage.focus();  
  return;
}  

document.frmenquiry.submit()
}
/***************************************************************************/
/*                    End of function validateenquiry()                    */
/***************************************************************************/

function replacebannedchars(strinputtext) 
/***************************************************************************/
/* Special Req's :- None                                                   */
/* Related Files :- None                                                   */
/* Purpose       :- Replaces all " or '  characters with the ` character   */
/*               :- in the input string and passes the result back         */
/* Version       :- 1.00                                                   */
/* Author        :- Dennis McDermott                                       */
/* Date          :- 18/01/2007                                             */
/***************************************************************************/
/* Desc of Mod   :-                                                        */
/* Modified By   :-                                                        */
/* Date          :-                                                        */
/***************************************************************************/
{
  strwithbannedcharsreplaced = strinputtext.replace(/"|'/g,"`");
  return strwithbannedcharsreplaced;
}
/***************************************************************************/
/*                   End of function replacebannedchars()                  */
/***************************************************************************/
