<!--
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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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 isNumeric(pccharinput) {  // 1) this allows the numbers 0-9
	return(pccharinput>="0" && pccharinput<="9")
}

function isQty(pccharinput) {
	return (pccharinput=="-" || pccharinput=="-1" || pccharinput=="-2" || pccharinput=="-3" || pccharinput=="-4" || pccharinput=="-5" || pccharinput=="-6" || pccharinput=="-7" || pccharinput=="-8" || pccharinput=="-9" )
}

function isAlphabetic(pccharinput) { // 2) this allows the letters A-Z & a-z
	return((pccharinput>="A" && pccharinput<="Z") || 
		(pccharinput>="a" && pccharinput<="z"))
}

function isAlphaNumeric(pccharinput) { //  3) this allows 1) & 2) from above to be put together
	return (isAlphabetic(pccharinput) || isNumeric(pccharinput))
}

function isEmpty(pccharinput) { // checks for any empty fields in the HTML form
	if (pccharinput=="" || pccharinput==" ")
		return true;
	else 
		return false;
	}
	
function isAddressChar(pccharInput) {  // allows numbers, alphabets and the special name characters from line 34.
	if (isAlphaNumeric(pccharInput) || isNameSpecialChar(pccharInput))
	return true
	else
	return false
}

function isNameChar(pccharinput) {  // this is all the alphabet and the special characters for the name
	return (isAlphabetic(pccharinput) || isNameSpecialChar(pccharinput))
}

//alert(isNameChar("michelle'hgf"))
function isNameSpecialChar(pccharinput) {  // these are the special characters allowed for the name
	return (pccharinput=="'" || pccharinput=="-" || pccharinput==" ")
}


///////////////////////////////////////////////////////////////////////


function isTelephoneSpecialChar(pccharinput) {  // 4) these are the special characters allowed for the telephone
	return (pccharinput=="(" || pccharinput==")" || pccharinput=="-" 
	|| pccharinput=="+" || pccharinput=="x" || pccharinput=="e" || pccharinput==" " || pccharinput=="t")
}

function isTelephoneChar(pccharinput) {  // this allows numbers and the special characters to be in the telephone field.
	if (isNumeric(pccharinput) || isTelephoneSpecialChar(pccharinput))
		return true
	else 
		return false
}


function isTelephoneString(pcstrInput) {  // this disallows all the letters below in that sequence.

	var w, lvintdashpos, lvintTXE, lvintTEX, lvintETX, lvintXET, lvintXTE, lvintEXT, lvintBracket

	lvintdashpos=pcstrInput.indexOf("-")
	lvintTXE=pcstrInput.indexOf("txe")
	lvintTEX=pcstrInput.indexOf("tex")
	lvintETX=pcstrInput.indexOf("etx")
	lvintXET=pcstrInput.indexOf("xet")
	lvintXTE=pcstrInput.indexOf("xte")
	lvintBracket=pcstrInput.indexOf("()")
	lvintEXT=pcstrInput.indexOf("ext")

	for (w=0; w<pcstrInput.length; w++) 
	{
		if (!isTelephoneChar (pcstrInput.charAt(w)))
		{ 
			return false
		}
	}
	
	if(lvintdashpos==0)  // if the - is at position 0 it's false
		return false
	
	if(lvintEXT==0) // if the ext is at position 0 it's false
		return false
	
	if(lvintTXE!=-1 || lvintTEX!=-1 || lvintETX!=-1 || lvintXET!=-1 || lvintXTE!=-1 || lvintBracket!=-1)
		return false  // this means none of the above can be in the text field.
	return true

} 

//////////////////////////////////////////////////////////////////////////



function isNameString(pcstrInput) {  

	var w, lvintapostrophepos, lvintdashpos, lvintspacepos
	
	lvintapostrophepos=pcstrInput.indexOf("'")
	lvintdashpos=pcstrInput.indexOf("-")
	lvintspacepos=pcstrInput.indexOf(" ")
	
	for (w=0; w<pcstrInput.length; w++) {
	
		if (!isNameChar (pcstrInput.charAt(w)))
		{ 
			return false
		}
	}
	
	if (lvintapostrophepos==0)  // if ' is at postion 0 it's false
		return false
	if (lvintdashpos==0) // if - is at postion 0 it's false
		return false
	if (lvintspacepos==0) // if there is a space at 0 it's wrong
		return false
	if (isEmpty(pcstrInput))  // if the text field is empty it will return false
		return false
	return true
} 

//alert(isNameString("'kjgf"))
//alert(isNameString(" "))
//alert(isNameString("-hgd"))
//alert(isNameString("hgfd's"))

///////////////////////////////////////////////////////////

function isEmailSpecialChar(pccharinput) {
	return (pccharinput=="@" || pccharinput=="-" || pccharinput=="_" || pccharinput==".")
}

function isEmailChar(pccharinput) {  // allows numbers, alphabets and the special email characters from above.
	return (isAlphaNumeric(pccharinput) || isEmailSpecialChar(pccharinput))
}

//alert(isEmailChar("michelle@.com"))
//alert(isEmailChar("mich_-elle@.com"))
//alert(isEmailChar("mich_-elle@.com653"))
//alert(isEmailChar("mi#$%$%ch_-elle@.com"))




function isEmailString (pcstrInput) { 

	var w, lvintlength, lvintlastpos, lvintatpos, lvintatlastpos, lvintfirstpos

	lvintlength=pcstrInput.length
	lvintlastpos=pcstrInput.lastIndexOf(".")
	lvintatpos=pcstrInput.indexOf("@")
	lvintfirstpos=pcstrInput.indexOf(".")
	lvintatlastpos=pcstrInput.lastIndexOf("@")
	
	
	for (w=0; w<pcstrInput.length; w++) 
	{ 
		if (!isEmailChar (pcstrInput.charAt(w)))
		{ 
			return false
		} 
	} 	

	if(lvintatpos==0) // if @ is = 0 it's false.
		return false

	if (lvintlastpos==0) // if last . is = 0 it's wrong
		return false

	if (lvintfirstpos==0) // if . is = to 0 it's wrong
		return false

	if (lvintatlastpos==-1) // there is no @ in the email address
		return false

	if (lvintfirstpos==-1) // there is no . in the email address
		return false

	if (pcstrInput.indexOf("@.")!=-1) // this means the @. are not = to -1 (basically if there is @ and. together it returns false.)
		return false
		
	if (pcstrInput.indexOf(".@")!=-1) //there are .@ together
		return false
		
	if (pcstrInput.indexOf("@@")!=-1) // two @@ together
		return false
		
	if (pcstrInput.indexOf("..")!=-1) // this means the two .. are not = to -1 (basically if there are 2 .. it returns false.)
		return false

	if(lvintlength-lvintlastpos<3) // there are not two letters after the last .
		return false
	 
	return true
} 

 



function isCorporate() {  // this validates the add user form.
	
	if (document.enquiry.team.value=="") {
		alert("Please enter your team name.")
		document.enquiry.team.focus();
		return false;
		}
		
	if (document.enquiry.name.value=="") {
		alert("Please enter a contact name for the team.")
		document.enquiry.name.focus();
		return false;
		}
		
	if (document.enquiry.phone.value=="") {
		alert("Please enter a phone number.")
		document.enquiry.phone.focus();
		return false;
		}
		
	if (!isTelephoneString(document.enquiry.phone.value)) {
		alert("Please enter a correct phone number.")
		document.enquiry.phone.focus();
		document.enquiry.phone.select();
		return false;
		}
		
	if (document.enquiry.email.value=="") {
		alert("Please enter an email address.")
		document.enquiry.email.focus();
		return false;
		}
	
		
	if (!isEmailString(document.enquiry.email.value)) {
		alert("Please enter a correct email address.")
		document.enquiry.email.focus();
		document.enquiry.email.select();
		return false;
		}

	 	
}

function isRegister() {  // this validates the add user form.

	
	if (document.enquiry.team.value=="") {
		alert("Please enter your team name.")
		document.enquiry.team.focus();
		return false;
		}
		
	if (document.enquiry.name.value=="") {
		alert("Please enter a contact name for the team.")
		document.enquiry.name.focus();
		return false;
		}
		
	if (document.enquiry.phone.value=="") {
		alert("Please enter a phone number.")
		document.enquiry.phone.focus();
		return false;
		}
		
	if (!isTelephoneString(document.enquiry.phone.value)) {
		alert("Please enter a correct phone number.")
		document.enquiry.phone.focus();
		document.enquiry.phone.select();
		return false;
		}
		
	if (document.enquiry.email.value=="") {
		alert("Please enter an email address.")
		document.enquiry.email.focus();
		return false;
		}
	
		
	if (!isEmailString(document.enquiry.email.value)) {
		alert("Please enter a correct email address.")
		document.enquiry.email.focus();
		document.enquiry.email.select();
		return false;
		}

		
	/*if (document.enquiry.waterPromotion.checked == true && document.enquiry.Quantity.selectedIndex == 0) {
		alert("Please select your water quantity.");
		document.enquiry.Quantity.focus();
		return false;
	}*/
	
	if (document.enquiry.grade.selectedIndex==0) {
		alert("Please select a grade.")
		document.enquiry.grade.focus();
		return false;
		}
		
	if (document.enquiry.skill.selectedIndex==0) {
		alert("Please select a skill level.")
		document.enquiry.skill.focus();
		return false;
		}


}

function isWaitingList() {  // this validates the add user form.


		
	if (document.enquiry.name.value=="") {
		alert("Please enter a contact name for the team.")
		document.enquiry.name.focus();
		return false;
		}
		
	if (document.enquiry.email.value=="") {
		alert("Please enter an email address.")
		document.enquiry.email.focus();
		return false;
		}
	
		
	if (!isEmailString(document.enquiry.email.value)) {
		alert("Please enter a correct email address.")
		document.enquiry.email.focus();
		document.enquiry.email.select();
		return false;
		}
	
	if (document.enquiry.phone.value=="") {
		alert("Please enter a phone number.")
		document.enquiry.phone.focus();
		return false;
		}
		
	if (!isTelephoneString(document.enquiry.phone.value)) {
		alert("Please enter a correct phone number.")
		document.enquiry.phone.focus();
		document.enquiry.phone.select();
		return false;
		}
		
	

		
	if (document.enquiry.skill.selectedIndex==0) {
		alert("Please select a skill level.")
		document.enquiry.skill.focus();
		return false;
		}


}




function isPrimaryRegister() {  // this validates the add user form.

	
	if (document.enquiry.team.value=="") {
		alert("Please enter your team name.")
		document.enquiry.team.focus();
		return false;
		}
		
	if (document.enquiry.name.value=="") {
		alert("Please enter a contact name for the team.")
		document.enquiry.name.focus();
		return false;
		}
		
	if (document.enquiry.phone.value=="") {
		alert("Please enter a phone number.")
		document.enquiry.phone.focus();
		return false;
		}
		
	if (!isTelephoneString(document.enquiry.phone.value)) {
		alert("Please enter a correct phone number.")
		document.enquiry.phone.focus();
		document.enquiry.phone.select();
		return false;
		}
		
	if (document.enquiry.email.value=="") {
		alert("Please enter an email address.")
		document.enquiry.email.focus();
		return false;
		}
	
		
	if (!isEmailString(document.enquiry.email.value)) {
		alert("Please enter a correct email address.")
		document.enquiry.email.focus();
		document.enquiry.email.select();
		return false;
		}
		
	if (document.enquiry.year.selectedIndex==0) {
		alert("Please select a year")
		document.enquiry.year.focus();
		return false;
		}
		
	if (document.enquiry.season.selectedIndex==0) {
		alert("Please select a season")
		document.enquiry.season.focus();
		return false;
		}
		

}

function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function isradio() {
	var radio_choice = false;
	
	for (counter = 0; counter < enquiry.grade.length; counter++) {

		if (enquiry.grade[counter].checked)
		radio_choice = true; 
		}
	
		if (!radio_choice) {
		
		alert("Please select a grade.")
			return (false);
		}
		return (true);	
}

function isskill() {
	var radio_choice2 = false;
	
	for (counter = 0; counter < enquiry.skill.length; counter++) {

		if (enquiry.skill[counter].checked)
		radio_choice2 = true; 
		}
	
		if (!radio_choice2) {
		
		alert("Please select a skill level.")
			return (false);
		}
		return (true);	
}




function isContactForm() {
	if (document.enquiry.name.value=="") {
		alert("Please enter your name.")
		document.enquiry.name.focus();
		return false;
		}

	if (document.enquiry.organisation.value=="") {
		alert("Please enter your name.")
		document.enquiry.organisation.focus();
		return false;
		}
		
	if (document.enquiry.email.value=="") {
		alert("Please enter an email address.")
		document.enquiry.email.focus();
		return false;
		}
	
		
	if (!isEmailString(document.enquiry.email.value)) {
		alert("Please enter a correct email address.")
		document.enquiry.email.focus();
		document.enquiry.email.select();
		return false;
		}
		
	if (document.enquiry.enquiry.value=="") {
		alert("Please enter your question or comments in the enquiry field.")
		document.enquiry.enquiry.focus();
		return false;
		}

}



function promotion() {
	window.open("waiwera-promotion.html", null, "height=400,width=420,status=yes,toolbar=no,menubar=yes,location=no,scrollbars=yes,resizable=yes");
}

function showQty(i){
    hideShow = document.getElementById("waterPromotion").checked ? "block" : "none"
	document.getElementById("textShow").style.display = hideShow
  }
