function GetRegions(sValue, oTarget, sAddlParams)
	{
	    while (oTarget.options.length > 0) {
            oTarget.options[0] = null;
        }

        oTarget.options[0] = new Option("Retrieving...", "");  
        oTarget.style.color = "red";        	
		var oXmlHttp;
		oXmlHttp=GetXmlHttp();
		var sUrl;
		sUrl="region_states.aspx?st=" + sValue+ "&" +sAddlParams; 
		oXmlHttp.open("GET", sUrl, true);
		
		oXmlHttp.onreadystatechange=function() 
		{
			if (oXmlHttp.readyState==4) 
			{
			    while (oTarget.options.length > 0) {
                    oTarget.options[0] = null;
                }
                
                oTarget.style.color = "black";
                oTarget.size = 7
                oTarget.style.width = 200;
                //oTarget.style.height = 200;
			
				if (oXmlHttp.responseText!="")
				{
					var sResponse = oXmlHttp.responseText;
					var sItems = sResponse.split(";");
					for (x=0; x<sItems.length; x++){
					    if (!sItems[x]=="") {
                            var sValueText = sItems[x].split(",");
                            oTarget.options[x] = new Option(eval(sValueText[1]), eval(sValueText[0]));
                        }
                    }
				}				
			}
		}
		
		oXmlHttp.send(null)
	}
	function selectState(stateID, oState, stateName){
	    //document.getElementById('DestinationStates').innerText = stateName;
	    GetRegions(stateID, oState, null);
        
	
	}
	
	function GetXmlHttp()
	{
		var oXmlHttp=false;
	
		// -----> This method was provided from Jim Ley's website 
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		// JScript gives us Conditional compilation, we can cope with old IE versions.
		// and security blocked creation of the objects.
		try {
			oXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
			oXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			oXmlHttp = false;
		}
		}
		/*@end @*/
	

		if (!oXmlHttp && typeof XMLHttpRequest!='undefined') 
		{
			oXmlHttp = new XMLHttpRequest();
		}
		
		return oXmlHttp;	  
	}
function checkDate() {
var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;
var dateStr = document.arrivalForm.Arrival.value;

var matchArray = dateStr.match(datePat); // is the format ok?
if (matchArray == null) 
{
	alert("Date field is empty or format of date field is not valid.");
	document.arrivalForm.Arrival.focus();
	return false;
	}
	month = matchArray[3]; // parse date into variables
	day = matchArray[1];
	year = matchArray[4];
	if (month < 1 || month > 12) 
	{
		alert("The date format is not valid");
		document.arrivalForm.Arrival.focus();
		return false;
	} // check month range
	if (day < 1 || day > 31){
		alert("The date format is not valid.");
		document.arrivalForm.Arrival.focus();
		return false;
		} 
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		alert("The date format is not valid");	
		document.arrivalForm.Arrival.focus();
		return false;
	}
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)){
		alert("The date format is not valid");
		document.arrivalForm.Arrival.focus();
		return false;
	}
	}
	if (document.arrivalForm.Region.value == ""){
	    alert("Please select a valid destination.");
	    return false;
    }	
	return true;
	
	//document.arrivalForm.submit(); // date is valid 
	}
	
function checkEmail() {
var rexEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;  
	   					if (!rexEmail.test(document.Subscribe.Email.value)){
						alert("Please enter valid email address to subscribe.")
						if(document.Subscribe.Email.value>""){
  							document.Subscribe.Email.select();
  							document.Subscribe.Email.focus();
						}
	    				return false;
	  					}
	  					else {
						    return true;
						  }							
	}

function destinationSelected(oRegion){
    switch (oRegion.name){
        case "optRegion":  
            document.getElementById('cbRegionOthers').disabled = true;
            document.getElementById('lstRegion').disabled  = true;
            document.getElementById('optRegionOthers').checked = false;
            break;
        case "optRegionOthers":
             for (var i = 0; i < document.arrivalForm.optRegion.length; i++) {
		          document.arrivalForm.optRegion[i].checked = false;
		     }
            document.getElementById('cbRegionOthers').disabled  = false;
            document.getElementById('lstRegion').disabled  = true;
            break;
        case "austmap":
             for (var i = 0; i < document.arrivalForm.optRegion.length; i++) {
		          document.arrivalForm.optRegion[i].checked = false;
		     }
            document.getElementById('cbRegionOthers').disabled  = true;
            document.getElementById('lstRegion').disabled  = false;
            document.getElementById('optRegionOthers').checked = false;
            break;
         case "lnkOthers":
             for (var i = 0; i < document.arrivalForm.optRegion.length; i++) {
		          document.arrivalForm.optRegion[i].checked = false;
		     }
            document.getElementById('cbRegionOthers').disabled  = true;
            document.getElementById('lstRegion').disabled  = false;
            document.getElementById('optRegionOthers').checked = false;
            break;           
   }


}
function regionSelected(sValue){
    document.getElementById('Region').value = sValue;
}