//Google toolbar fix
 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 MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function cjvCheck_Email(strEmail)  {
if (strEmail.length < 9 || strEmail.lastIndexOf("@") < 1) {
		return false;
} else {
		if (strEmail.lastIndexOf(" ") > -1) {
			return false;
		} else {
			if (strEmail.lastIndexOf(".") < 1) {
				return false;
			} else {
				return true;			
			}
		}
}
}

function cjvMissed_Fields(objForm,strFields) {
	var strMissedfields = '';
	eval("arrFields = new Array(" + strFields + ");");
	for (numIndex = 0;numIndex < arrFields.length/2;numIndex++) {
		eval("if (document." + objForm.name + "." + arrFields[numIndex * 2] + ".value == '') {strMissedfields = strMissedfields + ' - ' + arrFields[numIndex * 2 + 1] + '\\n'};");
	}
	
	if (strMissedfields != '') {
		alert ("Please ensure the following fields are completed:\n" + strMissedfields);
		return false;
	} else {
		return true;
	}
}

//Standard Propel javavalidation. Checks fieldname in array then alerts if blank using following descriptive name
function cjvCheck_Form(objForm) {
	if (MissedFields(objForm,"'First_Name','First Name','Last_Name','Surname','Address1','Address','Town_City','Town\/City','Email_Address','Email Address'")==false) {
		return false;
  	}
	
	if (CheckEmail(objForm.Email_Address.value)==false) {
  		alert("Please ensure your Email Address is correct.");
		return false;
  	}
  	if (objForm.Terms_Conditions.checked==false) {
  		alert("You must tick the Terms and Conditions box to continue.");
		return false;
  	}
	 	if (objForm.Privacy.checked==false) {
  		alert("You must tick the Privacy Policy box to continue.");
		return false;
  	}
	
}


function  cjvSelect_Page(objSelect_List,strNull_Href,strSelected_Href) {
	numSerial_Selected = objSelect_List.selectedIndex;
	strSerial_Selected = objSelect_List.options[numSerial_Selected].value;
	if (strSerial_Selected == "") {
		document.location.href = strNull_Href;
	} else {
		document.location.href = strSelected_Href + strSerial_Selected;
	}
}

function cjvValidate_Integer_Field(objFormField) {
	if (isNaN("0" + objFormField.value) == true) {
		alert('Please enter a non\-negative number.');
		objFormField.value = "";
		return false;
	} else {
		return true;
	}
}	

function cjvCheck_Max_Chars(objFormField,numMax_Chars,strMessage) {
	if (objFormField.value.length > numMax_Chars) {
		if (strMessage == "") {
			alert("Max " + numMax_Chars + " characters allowed.");
		} else {
			alert(strMessage);
		}
		objFormField.value = objFormField.value.substring(0,numMax_Chars);
	}
}	

function cjvValidate_Number_Field(objForm_Field,numType,blnAllow_Negative) {
	numForm_Field = objForm_Field.value
	
	if ((numForm_Field=="-")&&(blnAllow_Negative==false)) {
		alert('Please enter a non\-negative number.');
		objForm_Field.value = numForm_Field.substring(0,numForm_Field.length-1);
		return;
	}
	
	if ((numForm_Field=="")||(numForm_Field=="-")) {
		return;
	}
	
	numForm_Field = numForm_Field.replace(" ","");
	objForm_Field.value = numForm_Field;
	//Integer
	numForm_Field_Temp = numForm_Field.replace(".","x");
	numForm_Field_Temp = numForm_Field_Temp.replace("\-","");
	
	if ((numType==1)&&(isNaN(numForm_Field_Temp) == true)) {
		alert('Please enter a valid whole number.');
		objForm_Field.value = numForm_Field.substring(0,numForm_Field.length-1);
		objForm_Field.focus();
		return false;
	}
	
	if ((numType==2)&&(isNaN(numForm_Field) == true)) {
		alert('Please enter a valid number.');
		objForm_Field.value = numForm_Field.substring(0,numForm_Field.length-1);
		objForm_Field.focus();
		return false;
	}
	
	if ((blnAllow_Negative==false)&&(numForm_Field<0)){
		alert('Please enter a non\-negative number.');
		objForm_Field.value = "";
		objForm_Field.focus();
		return false;
	}
	
	return true;
}	

function cjvToggle_HTML_Block(strBlockName,blnShow) {
	if (blnShow==true) {
		eval("document.getElementById('" + strBlockName + "').style.display='block';");
	} else {
		eval("document.getElementById('" + strBlockName + "').style.display='none';");
	}
}

function cjvSet_HTML_Block(strBlockName,strContent) {
		eval("document.getElementById('" + strBlockName + "').innerHTML=" + strContent + ";");
}

function cjvConfirm_Href(strMessage,strLink) {
	blnCont = confirm(strMessage);
	if (blnCont == true) {
		document.location.href = strLink
	}
}

var cjvNewWindow = null;
function cjvPop_Window(strURL,strName,numWidth,numHeight) {
	var numScreenWidth = 640, numScreenHeight = 480;
	if (parseInt(navigator.appVersion)>3) {
	 numScreenWidth = screen.width;
	 numScreenHeight = screen.height;
	}
	else if (navigator.appName == "Netscape" 
	    && parseInt(navigator.appVersion)==3
	    && navigator.javaEnabled()
	   ) 
	{
	 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
	 var jScreenSize = jToolkit.getScreenSize();
	 numScreenWidth = jScreenSize.width;
	 numScreenHeight = jScreenSize.height;
	}

	if (numWidth == 0 || numHeight == 0) {
		//strWindow_Size = 'fullscreen';
		strWindow_Size = 'width=' + numScreenWidth + ',height=' + numScreenHeight;
		
	} else {
		strWindow_Size = 'width=' + numWidth + ',height=' + numHeight;
	}

	if (cjvNewWindow == null || cjvNewWindow.closed) {
		cjvNewWindow = window.open(strURL, strName,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,'+strWindow_Size);
	} else {
		if (cjvNewWindow.closed == false) {
			cjvNewWindow.location = strURL;
			cjvNewWindow.focus();
		}
	}
}