<!--
//blah dee blah

function ReminderEmail(MailAddy,FirstName) {
	window.open('reminder.pl?em=' + MailAddy + '&nm=' + FirstName + '&fn=form','SubWindo', config='height=200,width=350,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=no');
	return;
}
function TerminateAuction(KeyId,RegionId,UserId) {
	var name = confirm("Terminate Participation in this Auction category : Are you sure?")
	if (name == true) {
		location.href="../cgi-bin/login.pl?uid=" + UserId + "&fn=bidding&kid=" + KeyId + "&rid=" + RegionId + "&st=terminate";
	}
	else { return; }
}
function EnableAuction(KeyId,RegionId,UserId) {
	var name = confirm("Enable Participation in this Auction category : Are you sure?")
	if (name == true) {
		location.href="../cgi-bin/login.pl?uid=" + UserId + "&fn=bidding&kid=" + KeyId + "&rid=" + RegionId + "&st=enable";
	}
	else { return; }
}
var errfound = false;
function ValidLength(item, len) {
   return (item.length >= len);
}
function ValidEmail(item) {
   if (!ValidLength(item, 5)) return false;
   if (item.indexOf ('@', 0) == -1) return false;
   if (item.indexOf ('.', 0) == -1) return false;
   return true;
}
function error(elem, text, tflag) {
   if (errfound) return;
   window.alert(text);
   if (tflag == 1) {
		elem.select();
   	elem.focus();
   }
   errfound = true;
}
function CheckReminderEmail() {
   errfound = false;
   if (!ValidEmail(document.email_reminder.EmailAddress.value))
      error(document.email_reminder.EmailAddress,"Please enter a valid email address!",1);
   return !errfound;
}
function CheckContactForm() {
   errfound = false;
   if (!ValidLength(document.EnquireForm.FirstName.value,2))
      error(document.EnquireForm.FirstName,"Your First Name appears to be invalid!",1);
   if (!ValidLength(document.EnquireForm.Company.value,2))
      error(document.EnquireForm.Company,"Your Company name appears to be invalid!",1);
   if (!ValidEmail(document.EnquireForm.MailAddy.value))
      error(document.EnquireForm.MailAddy,"Please enter a valid email address!",1);
   if (!ValidLength(document.EnquireForm.Comments.value,2))
      error(document.EnquireForm.Comments,"Please enter your query in the Comments box!",1);

   return !errfound;
}
function TestKeywordPass(KeyWordCount) {
   errfound = false;
   if (!ValidLength(document.set_keypass.PassWord_1.value,6))
      error(document.set_keypass.PassWord_1,"Please enter a password longer than 6 characters for password number 1!",1);
   if (KeyWordCount > 1) {
	   if (!ValidLength(document.set_keypass.PassWord_2.value,6))
    	  error(document.set_keypass.PassWord_2,"Please enter a password longer than 6 characters for password number 2!",1);
   }
   if (KeyWordCount > 2) {
	   if (!ValidLength(document.set_keypass.PassWord_3.value,6))
    	  error(document.set_keypass.PassWord_3,"Please enter a password longer than 6 characters for password number 3!",1);
   }
   if (KeyWordCount > 3) {
	   if (!ValidLength(document.set_keypass.PassWord_4.value,6))
    	  error(document.set_keypass.PassWord_4,"Please enter a password longer than 6 characters for password number 4!",1);
   }
   if (KeyWordCount > 4) {
	   if (!ValidLength(document.set_keypass.PassWord_5.value,6))
    	  error(document.set_keypass.PassWord_5,"Please enter a password longer than 6 characters for password number 5!",1);
   }
   if (KeyWordCount > 5) {
	   if (!ValidLength(document.set_keypass.PassWord_6.value,6))
    	  error(document.set_keypass.PassWord_6,"Please enter a password longer than 6 characters for password number 6!",1);
   }
   if (KeyWordCount > 6) {
	   if (!ValidLength(document.set_keypass.PassWord_7.value,6))
    	  error(document.set_keypass.PassWord_7,"Please enter a password longer than 6 characters for password number 7!",1);
   }
   if (KeyWordCount > 7) {
	   if (!ValidLength(document.set_keypass.PassWord_8.value,6))
    	  error(document.set_keypass.PassWord_8,"Please enter a password longer than 6 characters for password number 8!",1);
   }
   if (KeyWordCount > 8) {
	   if (!ValidLength(document.set_keypass.PassWord_9.value,6))
    	  error(document.set_keypass.PassWord_9,"Please enter a password longer than 6 characters for password number 9!",1);
   }
   if (KeyWordCount > 9) {
	   if (!ValidLength(document.set_keypass.PassWord_10.value,6))
    	  error(document.set_keypass.PassWord_10,"Please enter a password longer than 6 characters for password number 10!",1);
   }
   return !errfound;
}

function CheckRegisterForm() {
   errfound = false;
   PassFirst = document.subscriber_base.PassWord.value;
   PassSecond = document.subscriber_base.RepPassWord.value;
   if (!ValidLength(document.subscriber_base.PassWord.value,5))
      error(document.subscriber_base.PassWord,"Please enter Password that is 5 characters or longer!",1);
   if (PassFirst != PassSecond)
      error(document.subscriber_base.RepPassWord,"Your Password and Repeat Password do not match!",1);
  if (!ValidLength(document.subscriber_base.ShortName.value,5))
    error(document.subscriber_base.ShortName,"Please enter a valid value for 10 character Short Name!",1);
  if (!ValidLength(document.subscriber_base.LongName.value,5))
    error(document.subscriber_base.LongName,"Please enter a valid value for 14 character Short Name!",1);

	if (!ValidLength(document.subscriber_base.CellPrefix.value,3))
			error(document.subscriber_base.CellPrefix,"Please enter a valid value for Display Number!",0);
	if (!ValidLength(document.subscriber_base.CellPhone.value,7))
			error(document.subscriber_base.CellPhone,"Please enter a valid value for Display Number!",1);
	if (!ValidLength(document.subscriber_base.CellPrefixSec.value,3))
			error(document.subscriber_base.CellPrefixSec,"Please enter a valid value for Secure Cell Number!",0);
	if (!ValidLength(document.subscriber_base.CellPhoneSec.value,7))
			error(document.subscriber_base.CellPhoneSec,"Please enter a valid value for Secure Cell Number!",1);
	if (!ValidLength(document.subscriber_base.CellPrefixNote.value,3))
			error(document.subscriber_base.CellPrefixNote,"Please enter a valid value for Notification Cell Number!",0);
	if (!ValidLength(document.subscriber_base.CellPhoneNote.value,7))
			error(document.subscriber_base.CellPhoneNote,"Please enter a valid value for Notification Cell Number!",1);

	if (!ValidLength(document.subscriber_base.CompanyName.value,5))
    error(document.subscriber_base.CompanyName,"Please enter a valid value for Company Name!",1);
  if (!ValidLength(document.subscriber_base.PostalAddress1.value,2))
    error(document.subscriber_base.PostalAddress1,"Please enter a valid value for Postal Address 1!",1);
  if (!ValidLength(document.subscriber_base.PostalAddress2.value,2))
    error(document.subscriber_base.PostalAddress2,"Please enter a valid value for Postal Address 2!",1);
	//  if (!ValidLength(document.subscriber_base.PostalAddress3.value,2))
	//    error(document.subscriber_base.PostalAddress3,"Please enter a valid value for PostalAddress3!",1);
  if (!ValidLength(document.subscriber_base.PostalCode.value,4))
    error(document.subscriber_base.PostalCode,"Please enter a valid value for Postal Code!",1);
  if (!ValidLength(document.subscriber_base.StreetAddress1.value,2))
    error(document.subscriber_base.StreetAddress1,"Please enter a valid value for Street Address 1!",1);
  if (!ValidLength(document.subscriber_base.StreetAddress2.value,2))
    error(document.subscriber_base.StreetAddress2,"Please enter a valid value for Street Address 2!",1);
	//  if (!ValidLength(document.subscriber_base.StreetAddress3.value,2))
	//    error(document.subscriber_base.StreetAddress3,"Please enter a valid value for Street Address 3!",1);
	//  if (!ValidLength(document.subscriber_base.Telephone.value,2))
	//    error(document.subscriber_base.Telephone,"Please enter a valid value for Telephone!",1);
	//  if (!ValidLength(document.subscriber_base.Fax.value,2))
	//    error(document.subscriber_base.Fax,"Please enter a valid value for Fax!",1);
  if (!ValidLength(document.subscriber_base.FirstName.value,2))
    error(document.subscriber_base.FirstName,"Please enter a valid value for FirstName!",1);
  if (!ValidLength(document.subscriber_base.SurName.value,2))
    error(document.subscriber_base.SurName,"Please enter a valid value for SurName!",1);
	//  if (!ValidLength(document.subscriber_base.Designation.value,2))
	//    error(document.subscriber_base.Designation,"Please enter a valid value for Designation!",1);
	//  if (!ValidLength(document.subscriber_base.EmailAddress.value,2))
	//    error(document.subscriber_base.EmailAddress,"Please enter a valid value for EmailAddress!",1);
	//  if (!ValidLength(document.subscriber_base.CellPhoneSec.value,2))
	//    error(document.subscriber_base.CellPhoneSec,"Please enter a valid value for CellPhoneSec!",1);
   return !errfound;
}
function CheckNewRegisterForm() {
  errfound = false;
  var doc = document.subscriber_base;
  PassFirst = doc.PassWord.value;
  PassSecond = doc.RepPassWord.value;
  if (!ValidLength(doc.PassWord.value,6))
    error(doc.PassWord,"Please enter Password that is 6 characters or longer.",1);
  else if (PassFirst != PassSecond){alert(PassFirst+" "+PassSecond);
    error(doc.RepPassWord,"Your Password and Repeat Password do not match.",1);}
  
  else if (!ValidLength(doc.ShortName.value,2))
    error(doc.ShortName,"Your Shortname should be at least 2 characters long.",1);
  
  else if (!ValidLength(doc.CompanyName.value,3))
    error(doc.CompanyName,"Your Company Name should contain at least 3 letters.",1);
    
  else if (!ValidLength(doc.PostalAddress1.value,2))
    error(doc.PostalAddress1,"Please enter a valid value for your Postal Address.",1);
  else if (!ValidLength(doc.PostalAddress2.value,2))
    error(doc.PostalAddress2,"Please enter a valid value for the suburb/city of your Postal Address.",1);
  else if (!ValidLength(doc.PostalAddress3.value,2))
    error(doc.PostalAddress3,"Please enter a valid value for the Province of your Postal Address.",1);
  else if (!ValidLength(doc.PostalCode.value,4))
    error(doc.PostalCode,"Please enter a valid value for Postal Code.",1);
  
  else if (!ValidLength(doc.StreetAddress1.value,2))
    error(doc.StreetAddress1,"Please enter a valid value for your Street Address.",1);
  else if (!ValidLength(doc.StreetAddress2.value,2))
    error(doc.StreetAddress2,"Please enter a valid value for the City/Suburb of your Street Address.",1);
	else if (!ValidLength(doc.StreetAddress3.value,2))
    error(doc.StreetAddress3,"Please enter a valid value for the Province of your Street Address.",1);
  
  
  else if (!ValidLength(doc.FirstName.value,2))
    error(doc.FirstName,"Please enter a valid value for the FirstName of your First Contact Person.",1);
  else if (!ValidLength(doc.SurName.value,2))
    error(doc.SurName,"Please enter a valid value for the SurName of your First Contact Person.",1);
  
  return !errfound;
}
function CheckUpdateForm() {
   errfound = false;
  if (!ValidLength(document.subscriber_base.ShortName.value,5))
    error(document.subscriber_base.ShortName,"Please enter a valid value for 10 character Short Name!",1);
  if (!ValidLength(document.subscriber_base.LongName.value,5))
    error(document.subscriber_base.LongName,"Please enter a valid value for 14 character Short Name!",1);

	if (!ValidLength(document.subscriber_base.CellPrefix.value,3))
			error(document.subscriber_base.CellPhone,"Please enter a valid value for Display Number!",0);
	if (!ValidLength(document.subscriber_base.CellPhone.value,7))
			error(document.subscriber_base.CellPhone,"Please enter a valid value for Display Number!",1);
	if (!ValidLength(document.subscriber_base.CellPrefixSec.value,3))
			error(document.subscriber_base.CellPhone,"Please enter a valid value for Secure Cell Number!",0);
	if (!ValidLength(document.subscriber_base.CellPhoneSec.value,7))
			error(document.subscriber_base.CellPhoneSec,"Please enter a valid value for Secure Cell Number!",1);
	if (!ValidLength(document.subscriber_base.CellPrefixNote.value,3))
			error(document.subscriber_base.CellPhone,"Please enter a valid value for Notification Cell Number!",0);
	if (!ValidLength(document.subscriber_base.CellPhoneNote.value,7))
			error(document.subscriber_base.CellPhoneNote,"Please enter a valid value for Notification Cell Number!",1);
	
	if (!ValidLength(document.subscriber_base.CompanyName.value,5))
    error(document.subscriber_base.CompanyName,"Please enter a valid value for Company Name!",1);
  if (!ValidLength(document.subscriber_base.PostalAddress1.value,2))
    error(document.subscriber_base.PostalAddress1,"Please enter a valid value for Postal Address 1!",1);
  if (!ValidLength(document.subscriber_base.PostalAddress2.value,2))
    error(document.subscriber_base.PostalAddress2,"Please enter a valid value for Postal Address 2!",1);
	//  if (!ValidLength(document.subscriber_base.PostalAddress3.value,2))
	//    error(document.subscriber_base.PostalAddress3,"Please enter a valid value for PostalAddress3!",1);
  if (!ValidLength(document.subscriber_base.PostalCode.value,4))
    error(document.subscriber_base.PostalCode,"Please enter a valid value for Postal Code!",1);
  if (!ValidLength(document.subscriber_base.StreetAddress1.value,2))
    error(document.subscriber_base.StreetAddress1,"Please enter a valid value for Street Address 1!",1);
  if (!ValidLength(document.subscriber_base.StreetAddress2.value,2))
    error(document.subscriber_base.StreetAddress2,"Please enter a valid value for Street Address 2!",1);
	//  if (!ValidLength(document.subscriber_base.StreetAddress3.value,2))
	//    error(document.subscriber_base.StreetAddress3,"Please enter a valid value for Street Address 3!",1);
	//  if (!ValidLength(document.subscriber_base.Telephone.value,2))
	//    error(document.subscriber_base.Telephone,"Please enter a valid value for Telephone!",1);
	//  if (!ValidLength(document.subscriber_base.Fax.value,2))
	//    error(document.subscriber_base.Fax,"Please enter a valid value for Fax!",1);
  if (!ValidLength(document.subscriber_base.FirstName.value,2))
    error(document.subscriber_base.FirstName,"Please enter a valid value for FirstName!",1);
  if (!ValidLength(document.subscriber_base.SurName.value,2))
    error(document.subscriber_base.SurName,"Please enter a valid value for SurName!",1);
	//  if (!ValidLength(document.subscriber_base.Designation.value,2))
	//    error(document.subscriber_base.Designation,"Please enter a valid value for Designation!",1);
	//  if (!ValidLength(document.subscriber_base.EmailAddress.value,2))
	//    error(document.subscriber_base.EmailAddress,"Please enter a valid value for EmailAddress!",1);
	//  if (!ValidLength(document.subscriber_base.CellPhoneSec.value,2))
	//    error(document.subscriber_base.CellPhoneSec,"Please enter a valid value for CellPhoneSec!",1);
   return !errfound;
}
function CheckAcceptForm() {
   errfound = false;
   if (document.subscriber_base.AcceptTerms.checked) { return true; } 
   else { error(document.subscriber_base.AcceptTerms,"Please accept our Terms and Conditions of Service before you continue!",1); }

   return false;
}
function CheckAcceptCats() {
  errfound = false;
	for (var x=0; x<document.category_list("categories").length; x++) {
		if (document.category_list("categories")[x].checked) { return !errorfound; }
	}
	error(document.category_list.categories,"Please place a tick in at least one of the boxes to continue.",0);
	return false;
}
function CheckAcceptRegions() {
	for (var x=0; x<document.region_list.length; x++) {
    if (document.region_list[x].name.indexOf("region") >= 0) {
      if(document.region_list[x].checked)
        return true;
    }
	}
	error(document.region_list.regions,"Please place a tick in at least one of the boxes to continue.",0);
	return false;
}
function CheckAllAreas(CheckAll) {
  var doc = document.region_list;
  for (var x=0; x<doc.length; x++) {
    if (doc[x].name.indexOf("region") >= 0) { 
      if (CheckAll == true) { doc[x].checked=true; }
      else { doc[x].checked=false; }
    }
	}
}
function CheckEnteredReferences() {
  var doc = document.references;
  if (doc.refname1.value.length < 3 || doc.refname2.value.length < 3 || doc.refname3.value.length < 3) {
    alert("Each Reference Name must consist of at least 3 letters");
    return false;
  }
  if (doc.refnum1.value.length<10 || doc.refnum2.value.length<10 || doc.refnum3.value.length<10) {
    alert("Each Reference Number must be a 10 digit telephone number.");
    return false;
  }
  if (isNaN(doc.refnum1.value) || isNaN(doc.refnum2.value) || isNaN(doc.refnum3.value)) {
    alert("Each Reference Number must consist of only digits.");
    return false;
  }
  return true;
}
function CheckDisplayValues() {
  var doc = document.register_sysvals;
  var namelen=4;
  var numlen=10;
  for(var x=0; x<doc.length; x++) {
    if (doc[x].name.substr(doc[x].name.length-5,5) == "dname") {
      if (doc[x].value.length < namelen) {
        alert("All Display Names must contain "+namelen+" letters or more.");
        return false;
      }
    }
    else if (doc[x].name.substr(doc[x].name.length-4,4) == "dnum") {
      if (doc[x].value.length < 10) {
        alert("All Display Numbers must be a 10 digit phone number.");
        return false;
      }
      if (isNaN(doc[x].value)) {
        alert("All Display Numbers must be a phone number consisting of 10 digits.");
        return false;
      }
    }
  }
}
function CheckNotificationNumbers() {
  var doc = document.register_sysvals;
  for(var x=0; x<doc.length; x++) {
    if (doc[x].name.substr(doc[x].name.length-5,5) == "nnum1") {
      if (doc[x].value.length < 3 || doc[x].value.length > 4) {
        alert("Make sure to select the first 3 digits for every Notification Number from the lists of available pre-fixes.");
        return false;
      }
    }
    else if (doc[x].name.substr(doc[x].name.length-5,5) == "nnum2") {
      if (doc[x].value.length < 1) {
        alert("The second part of one of your Notification Numbers is missing");
        return false;
      }
      if (doc[x].value.length < 7) {
        if (isNaN(doc[x].value)) {
          alert("One or more of your Notification Numbers contains a character that is not a digit.");
          return false;
        }
        alert("The second part of one of your Notification Numbers is shorter than 7 digits");
        return false;
      }
      if (isNaN(doc[x].value)) {
        alert("One or more of your Notification Numbers contains a character that is not a digit.");
        return false;
      }
    }
  }
}
function CheckSecureNumbers() {
  var doc = document.register_sysvals;
  var Tested="";
  var CurName;
  for(var x=0; x<doc.length; x++) {
    if (doc[x].name.substr(doc[x].name.length-7,4) == "snum") {
      CurName = doc[x].name.substr(0,doc[x].name.length-7);
      if (Tested.indexOf(CurName) < 0) {
        Tested = CurName+"|";
        var n = CurName+"snum1-1";
        var CurPrefix1 = doc[n].value;
        n = CurName+"snum2-1";
        var CurPrefix2 = doc[n].value;
        n = CurName+"snum1-2";
        var Cur7_1 = doc[n].value;
        n = CurName+"snum2-2";
        var Cur7_2 = doc[n].value;
        if (CurPrefix1 == "" && CurPrefix2 == "") {
          alert("One of your required Secure Numbers does not yet have a 3 digit cell phone prefix.");
          return false;
        }
        if (CurPrefix1 == "") {
          if (Cur7_1 == "") {
            if (test7digits(Cur7_2) == false) { return false; }
            else return true;
          }
          else {
            alert("One of your Secure Numbers does not have a 3 digit cell phone prefix selected.");
            return false;
          }
        }
        if (CurPrefix2 == "") {
          if (Cur7_2 == "") {
            if (test7digits(Cur7_1) == false) { return false; }
            else return true;
          }
          else {
            alert("One of your Secure Numbers does not have a 3 digit cell phone prefix selected.");
            return false;
          }
        }
        //Here we have established that both cell phone prefixes have been selected and so both "last 7 digits" must be correct so just test each one
        if (test7digits(Cur7_1) == false) { return false; }
        if (test7digits(Cur7_2) == false) { return false; }
        
      }
    }
  }
  if (x>0) return true;
}
function test7digits(Cur7) {
  if (Cur7 == "") {
    alert("You have selected a prefix for a Secure Number but have left out the last 7 digits.");
    return false;
  }
  if (isNaN(Cur7)) {
    alert("One of your Secure Numbers contains characters other than the required 7 digits [0-9].");
    return false;
  }
  if (Cur7.length < 7) {
    alert("One of your Secure Numbers is short of the required last 7 digits [0-9].");
    return false;
  }
  return true;
}

function CopyToAllDVals(sName, sVal, sAlertName) {
  if (sVal == "") {
    alert("To replace all occurences of "+sAlertName+"': select a 3 digit prefix and enter a complete value then click again.");
    return;
  }
  var go = confirm("Click OK to replace all occurences of "+sAlertName+"' with this value: '"+sVal1+"'.");
  if (go){
    var doc = document.register_sysvals;
    for(var x=0; x<doc.length; x++) {
      if (doc[x].name.indexOf(sName)>=0) doc[x].value=sVal;
    }
  }
}
function CopyToAllNNums(sName, sVal1, sVal2, sAlertName) {
  if (sVal1 == "" || sVal2 == "") {
    alert("To replace all occurences of "+sAlertName+"': select a 3 digit prefix and enter a complete value then click again.");
    return;
  }
  var go = confirm("Click OK to replace all occurences of "+sAlertName+"' with this value: '"+sVal1+" "+sVal2+"'.");
  if (go){
    var doc = document.register_sysvals;
    for(var x=0; x<doc.length; x++) {
      if (doc[x].name.indexOf(sName+"1")>=0) doc[x].value=sVal1;
      else if (doc[x].name.indexOf(sName+"2")>=0) doc[x].value=sVal2;
    }
  }
}
function CopyToAllSNums(sName, sVal1, sVal2, sAlertName) {
  if (sVal1 == "" || sVal2 == "") {
    alert("To replace all occurences of "+sAlertName+"': select a 3 digit prefix and enter a complete value then click again.");
    return;
  }
  var go = confirm("Click OK to replace all occurences of "+sAlertName+"' with this value: '"+sVal1+" "+sVal2+"'.");
  if (go){
    var doc = document.register_sysvals;
    for(var x=0; x<doc.length; x++) {
      if (doc[x].name.indexOf(sName+"-1")>=0) doc[x].value=sVal1;
      else if (doc[x].name.indexOf(sName+"-2")>=0) doc[x].value=sVal2;
    }
  }
}

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.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];}
}

//-->

