function noCacheString() {

var str="noCache=";
return str.concat((new Date).getTime(),".",Math.random()*1234567)
};

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function NewVerifyImage() {

document['capt'].src = "captcha.asp?" + noCacheString();

}

function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (inputString == null) {
		return;}

   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
//   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
//      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
//   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

//check currency fields
function iscur(pobj,txt)
{
  var str=pobj.value;
  //Return false if str is blank
  if (str=="") {
    alert("\nThe " + txt + " field is blank.\n\nPlease enter a new " + txt + ".");
    pobj.select();
    pobj.focus();
    return false;
  }
  else {
    var flag=false;
    for (var i = 0; i < str.length; i++) 
    {
        var ch = str.substring(i, i + 1);
        if (ch != ' ') {flag=true;}
    }
    if (flag==false)
        {
          alert("\nThe " + txt + " field is blank.\n\nPlease enter a new " + txt + ".")
          pobj.select();
          pobj.focus();
          return false;
        }
    // Return false if characters are not '0-9'
   var dot=0;
   for (var i = 0; i < str.length; i++) 
      {
      var ch = str.substring(i, i + 1);
      if ((ch < "0" || "9" < ch) && (ch != "."))
         {
         alert("\nThe " + txt + " field accepts only numbers. \n\nPlease re-enter a number.");
         pobj.select();
         pobj.focus();
         return false;
         }
     else
        {
         if (ch == ".") 
	{
		dot=dot+1;
	         	if (dot>1) 
		{
		alert("\nThe " + txt + " field is error.\n\nPlease re-enter a number."); 
         		pobj.select();
	         	pobj.focus();
		return false;
		}
	}
          }
      }
    }
    return true;
}

function signup() {

	var fm = document.f1;
	var st="";
	
	if (fm.Email.value=="") {
		alert("Please enter an email address.");
		fm.Email.focus();
		return ;
	}
	if (fm.Email.value!=fm.EmailConfirm.value) {
		alert("Please enter a correct confirm email address.");
		fm.EmailConfirm.focus();
		return ;
	}
	if (fm.Password.value=="") {
		alert("Please enter a password.");
		fm.Password.focus();
		return ;
	}
	if (fm.Password.value!=fm.PasswordConfirm.value) {
		alert("Please enter a correct confirm password.");
		fm.PasswordConfirm.focus();
		return ;
	}
	if (fm.captchacode.value=="") {
		alert("Please enter the validate code.");
		fm.captchacode.focus();
		return ;
	}
	fm.action = "signup_submit.asp";
	fm.target="_self";
	fm.method = "post";
	fm.submit();
	
}

function signup_aso() {

	var fm = document.f1;
	var st="";
	
	if (fm.Email.value=="") {
		alert("Please enter an email address.");
		fm.Email.focus();
		return ;
	}
	if (fm.Email.value!=fm.EmailConfirm.value) {
		alert("Please enter a correct confirm email address.");
		fm.EmailConfirm.focus();
		return ;
	}
	if (fm.Password.value=="") {
		alert("Please enter a password.");
		fm.Password.focus();
		return ;
	}
	if (fm.Password.value!=fm.PasswordConfirm.value) {
		alert("Please enter a correct confirm password.");
		fm.PasswordConfirm.focus();
		return ;
	}
	if (fm.captchacode.value=="") {
		alert("Please enter the validate code.");
		fm.captchacode.focus();
		return ;
	}
	fm.action = "signup_aso_submit.asp";
	fm.target="_self";
	fm.method = "post";
	fm.submit();
	
}

function chglogin() {

	var fm = document.f1;
	
	if (fm.Email.value=="") {
		alert("Please enter an email address.");
		fm.Email.focus();
		return ;
	}
	if (fm.Password.value=="") {
		alert("Please enter a password.");
		fm.Password.focus();
		return ;
	}
	if (fm.Password.value!=fm.PasswordConfirm.value) {
		alert("Please enter a correct confirm password.");
		fm.PasswordConfirm.focus();
		return ;
	}
	if (fm.captchacode.value=="") {
		alert("Please enter the validate code.");
		fm.captchacode.focus();
		return ;
	}
	fm.action = "chglogin_submit.asp";
	fm.target="_self";
	fm.method = "post";
	fm.submit();
	
}

function login() {

	var fm = document.f1;
	
	if (fm.Email.value=="") {
		alert("Please enter an email address.");
		fm.Email.focus();
		return ;
	}
	if (fm.Password.value=="") {
		alert("Please enter a password.");
		fm.Password.focus();
		return ;
	}
	if (fm.captchacode.value=="") {
		alert("Please enter the validate code.");
		fm.captchacode.focus();
		return ;
	}
	fm.action = "signin_submit.asp";
	fm.target="_self";
	fm.method = "post";
	fm.submit();
	
}

function login_aso() {

	var fm = document.f1;
	
	if (fm.Email.value=="") {
		alert("Please enter an email address.");
		fm.Email.focus();
		return ;
	}
	if (fm.Password.value=="") {
		alert("Please enter a password.");
		fm.Password.focus();
		return ;
	}
	if (fm.captchacode.value=="") {
		alert("Please enter the validate code.");
		fm.captchacode.focus();
		return ;
	}
	fm.action = "signin_aso_submit.asp";
	fm.target="_self";
	fm.method = "post";
	fm.submit();
	
}

function forgotpw() {

	var fm = document.f1;
	
	if (fm.Email.value=="") {
		alert("Please enter an email address.");
		fm.Email.focus();
		return ;
	}
	if (fm.captchacode.value=="") {
		alert("Please enter the validate code.");
		fm.captchacode.focus();
		return ;
	}
	fm.action = "forgotpw.asp";
	fm.target="_self";
	fm.method = "post";
	fm.submit();
	
}

function pinfo_submit() {

	var fm = document.f1;
	var st="";
	
	if (fm.GivenName.value=="") {
		alert("Please enter a given name.");
		fm.GivenName.focus();
		return ;
	}
	if (fm.FamilyName.value=="") {
		alert("Please enter a family name.");
		fm.FamilyName.focus();
		return ;
	}
	st = fm.Nationality.options[fm.Nationality.selectedIndex].value;
	if (st=="") {
		alert("Please select a nationality.");
		fm.Nationality.focus();
		return ;
	}
	st = fm.Nationality.options[fm.Nationality.selectedIndex].text;
	fm.Nationality_full.value=st;
	st = fm.Gender.options[fm.Gender.selectedIndex].value;
	if (st=="0") {
		alert("Please select a gender.");
		fm.Gender.focus();
		return ;
	}
	st = fm.BirthDtemp.options[fm.BirthDtemp.selectedIndex].value;	
	if (st=="00") {
		alert("Please select a day of your birth date.");
		fm.BirthDtemp.focus();
		return ;
	}
	st = fm.BirthMtemp.options[fm.BirthMtemp.selectedIndex].value;
	if (st=="00") {
		alert("Please select a month of your birth date.");
		fm.BirthMtemp.focus();
		return ;
	}
	st = fm.BirthYtemp.options[fm.BirthYtemp.selectedIndex].value;
	if (st=="0000") {
		alert("Please select a year of your birth date.");
		fm.BirthYtemp.focus();
		return ;
	}
	if (fm.Occupation.value=="") {
		alert("Please enter an occupation.");
		fm.Occupation.focus();
		return ;
	}
	if (fm.Address.value=="") {
		alert("Please enter a street address.");
		fm.Address.focus();
		return ;
	}
	if (fm.PostalCode.value=="") {
		alert("Please enter a postal/zip code.");
		fm.PostalCode.focus();
		return ;
	}
	st = fm.Country.options[fm.Country.selectedIndex].value;
	if (st=="") {
		alert("Please select a country.");
		fm.Country.focus();
		return ;
	}
	st = fm.Country.options[fm.Country.selectedIndex].text;
	fm.Country_full.value=st;	
	if (fm.BusinessPhone.value=="") {
		alert("Please enter a business phone.");
		fm.BusinessPhone.focus();
		return ;
	}
	if (fm.HomePhone.value=="") {
		alert("Please enter a home phone.");
		fm.HomePhone.focus();
		return ;
	}
	if (fm.Mobile.value=="") {
		alert("Please enter a mobile phone.");
		fm.Mobile.focus();
		return ;
	}
	if (fm.EmergencyPerson.value=="") {
		alert("Please enter an emergency contact person.");
		fm.EmergencyPerson.focus();
		return ;
	}
	if (fm.EmergencyTel.value=="") {
		alert("Please enter an emergency contact phone.");
		fm.EmergencyTel.focus();
		return ;
	}
	if (fm.MedicalCheck[0].checked==false && fm.MedicalCheck[1].checked==false) {
		alert("Please choose if you have current medical problems or conditions for which a doctor is treating you.");
		fm.MedicalCheck[0].focus();
		return ;
	}
	if (fm.AllergicCheck[0].checked==false && fm.AllergicCheck[1].checked==false) {
		alert("Please choose if you are allergic to any medications.");
		fm.AllergicCheck[0].focus();
		return ;
	}
	if (fm.ProblemCheck[0].checked==false && fm.ProblemCheck[1].checked==false) {
		alert("Please choose if you wish the event medical staff to be aware of any specific medical problem.");
		fm.ProblemCheck[0].focus();
		return ;
	}
/*	
	if (fm.captchacode.value=="") {
		alert("Please enter the validate code.");
		fm.captchacode.focus();
		return ;
	}
*/	
	fm.action = "pinfo_submit.asp";
	fm.target="_self";
	fm.method = "post";
	fm.submit();
	
}

function pinfo_update() {

	var fm = document.f1;

	fm.action = "pinfo_update.asp";
	fm.target = "_self";
	fm.method = "post";
	fm.submit();
}

function GoChglogin() {

	var fm = document.f1;

	fm.action = "chglogin.asp";
	fm.target = "_self";
	fm.method = "post";
	fm.submit();
}

function GoMenu() {

	var fm = document.f1;

	fm.action = "menu.asp";
	fm.target = "_self";
	fm.method = "post";
	fm.submit();
	
}

function GoReg1() {

	var fm = document.f1;

	fm.action = "regis.asp";
	fm.target = "_self";
	fm.method = "post";
	fm.submit();
	
}

function GoReg2() {

	var fm = document.f1;

	fm.action = "regisII.asp";
	fm.target = "_self";
	fm.method = "post";
	fm.submit();
	
}

function GoReg1Edit() {

	var fm = document.f1;

	fm.action = "regisedit.asp";
	fm.target = "_self";
	fm.method = "post";
	fm.submit();
	
}

function GoReg2Edit() {

	var fm = document.f1;

	fm.action = "regisIIedit.asp";
	fm.target = "_self";
	fm.method = "post";
	fm.submit();
	
}

function click_b1() {

	var fm = document.f1;

	if (fm.selectReg.selectedIndex==0) {
		alert("Please select an event to register.");
		fm.selectReg.focus();
		return ;
	}
	
	var st=fm.selectReg.options[fm.selectReg.selectedIndex].value;

//	fm.action = "regis.asp";
	fm.action = st;	
	fm.target = "_self";
	fm.method = "post";
	fm.submit();
	
}

function click_b2() {

	var fm = document.f1;

	if (fm.selectRegStatus.selectedIndex==0) {
		alert("Please select an event to check for your registration status.");
		fm.selectRegStatus.focus();
		return ;
	}
	
	fm.action = "regstatus.asp";
	fm.target = "_self";
	fm.method = "post";
	fm.submit();
	
}

function click_b3() {

	var fm = document.f1;

	if (fm.selectAccom.selectedIndex==0) {
		alert("Please select an event to view accommodation information.");
		fm.selectAccom.focus();
		return ;
	}
	
	fm.action = "http://www.goadventureasia.com/accom/pimaccom.php";
	fm.target = "_blank";
	fm.method = "post";
	fm.submit();
	
}

function click_b4() {

	var fm = document.f1;

	if (fm.selectPack.selectedIndex==0) {
		alert("Please select an event to view package information.");
		fm.selectPack.focus();
		return ;
	}
	
	fm.action = "http://www.goadventureasia.com/accom/pimpack.php";
	fm.target = "_blank";
	fm.method = "post";
	fm.submit();
	
}

function GetCate(cmb) {

	var id="cate";
	if (cmb.selectedIndex==0) {
//		alert("Please select a race type.");
//		cmb.focus();
		document.getElementById(id).innerHTML="";
		return ;
	} else {
		document.getElementById(id).innerHTML="<font style=\"font-size: 8pt; font-family: Arial\">loading...</font>";
		var frm = document.f1;
		var param="";	
		param=noCacheString()+"&mid="+encodeURIComponent(frm.mid.value);
		param+="&race="+encodeURIComponent(cmb.options[cmb.selectedIndex].value);

var xmlHttp;
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return ;
  } 
var url="getcategory.asp";
var str=param;
			xmlHttp.onreadystatechange=function getdataajax_stateChanged()
			{ 
			if (xmlHttp.readyState==4)
			{ 
				document.getElementById(id).innerHTML=xmlHttp.responseText;
			}
			}
	
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 
xmlHttp.send(str);
	}	
}

function regiscfm() {

	var fm = document.f1;
	var st="";
	
	if (fm.cust_par.selectedIndex==0) {
		alert("Please select a race type.");
		fm.cust_par.focus();
		return ;
	}
	if("undefined" == typeof(fm.racecode)) {
		alert("Please select a race type.");
		fm.cust_par.focus();
		return ;
	} else {
		if (fm.racecode.value=="") {
			alert("Please select a race type.");
			fm.cust_par.focus();
			return ;
		}
	}
	if (fm.TShirt.selectedIndex==0) {
		alert("Please select a T-Shirt size.");
		fm.TShirt.focus();
		return ;
	}
	if (fm.HotelPhuket.selectedIndex==0) {
		alert("Please select a hotel staying in Phuket.");
		fm.HotelPhuket.focus();
		return ;
	}
	if (fm.Donation.value!="") {
		if (!iscur(fm.Donation, "Donation")) {
			return ;
		}
	}
	fm.action = "regiscfm.asp";
	fm.target="_self";
	fm.method = "post";
	fm.submit();
		
}

function regisIIcfm() {

	var fm = document.f1;
	var st="";
	
	if (fm.cust_par.selectedIndex==0) {
		alert("Please select a race type.");
		fm.cust_par.focus();
		return ;
	}
	if("undefined" == typeof(fm.racecode)) {
		alert("Please select a race type.");
		fm.cust_par.focus();
		return ;
	} else {
		if (fm.racecode.value=="") {
			alert("Please select a race type.");
			fm.cust_par.focus();
			return ;
		}
	}
	if (fm.TShirt.selectedIndex==0) {
		alert("Please select a T-Shirt size.");
		fm.TShirt.focus();
		return ;
	}
	if (fm.HotelPhuket.selectedIndex==0) {
		alert("Please select a hotel staying in Phuket.");
		fm.HotelPhuket.focus();
		return ;
	}
	if (fm.Donation.value!="") {
		if (!iscur(fm.Donation, "Donation")) {
			return ;
		}
	}
	
	fm.action = "regisIIcfm.asp";
	fm.target="_self";
	fm.method = "post";
	fm.submit();
		
}

function regiscfm_submit() {

	var fm = document.f1;
	fm.action = "regiscfm_submit.asp";
	fm.target="_self";
	fm.method = "post";
	fm.submit();
	
}

function regisIIcfm_submit() {

	var fm = document.f1;
	fm.action = "regisIIcfm_submit.asp";
	fm.target="_self";
	fm.method = "post";
	fm.submit();
	
}

function regiscfm_payment() {

	var fm = document.f1;
//	fm.action = "https://test.siamapy.com/b2cDemo/eng/payment/payForm.jsp";
	fm.action = "https://www.siampay.com/b2c2/eng/payment/payForm.jsp";
	fm.target="_self";
	fm.method = "post";
	fm.submit();
	
}

function regisIIcfm_payment() {

	var fm = document.f1;
//	fm.action = "https://test.siamapy.com/b2cDemo/eng/payment/payForm.jsp";
	fm.action = "https://www.siampay.com/b2c2/eng/payment/payForm.jsp";
	fm.target="_self";
	fm.method = "post";
	fm.submit();
	
}