// JavaScript Document
function restrictChars(myfield, e)

{
     var key;
     var keychar;
     if (window.event){
        key = window.event.keyCode;
	 }
     else if (e){
        key = e.which;
	 }
     else{
        return true;
	 }

      keychar = String.fromCharCode(key);
    // control keys
     if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27))
     {
		
       return true;
		
     } else if ((("0123456789").indexOf(keychar) > -1)) {
        return true;
     } else {
        return false;
     }

}


function validateIataAndSubmit() {
	
		
		var errorText = peformValidationStep1Fields();
		if (errorText.length > 0) {
			if (document.frmFreeTrial.iata_nbr.value.length>0 && document.frmFreeTrial.iata_nbr.value.length < 8){
				alert("Oops! The ARC/ IATA/ TSI/ TIDS Number should be an eight digit number. " + 
				"\n\nPlease complete the required fields and try again.");
			}
			else{
				alert("Oops! One or more of the following fields required to continue were not completed:\n\n* " + 
				errorText.join("\n* ") + "\n\nPlease complete the required fields and try again.");
			}
			
		}
		/*else if ( ! (Res = XX.match(/^(\d+)$/)) ) { 
			alert("Oops! your IATA number contains non-digit characters.\n\n*" +
				  "") ;
		}
		*/
		else {
			//alert('testing');
			new Ajax.Updater('idtrial', '../freetrialphp/triallib.php', {
						  parameters: $('frmFreeTrial').serialize(true),
						  evalScripts: true});
			//document.frmFreeTrial.submit();
		}
}
	
function peformValidationStep1Fields(){
	var errorText = new Array();
		
	if (document.frmFreeTrial.iata_nbr.value.length < 8) {
		errorText.push("IATA Number");
	}
	
	return errorText;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function validateStep2Fields(isIata){
		
		var errorText = peformValidationStep2Fields(isIata);
		
		if (errorText.length > 0) {
			alert("Oops! One or more of the following fields required to continue were not completed:\n\n* " + 
			errorText.join("\n* ") + "\n\nPlease complete the required fields and try again.");
		}/*
		else if(document.frmFreeTrial.agency_email.value != document.frmFreeTrial.confirm_agency_email.value){
			alert("Oops! The email address entered in the 'E-Mail Address' field does not match the email address entered in the " + 					
				"Confirm E-Mail Address field." + errorText.join("\n") + "\n\nPlease enter the matching email addresses.");
		}
		*/
		else {
			new Ajax.Updater('idtrial', '../freetrialphp/triallib.php', {
						  parameters: $('frmFreeTrial').serialize(true)});
			//document.frmFreeTrial.submit();
		}
}	

function peformValidationStep2Fields(isIata){
	document.frmFreeTrial.telno.value = document.frmFreeTrial.telno1.value + "-" + document.frmFreeTrial.telno2.value + "-" +
											document.frmFreeTrial.telno3.value;
		document.frmFreeTrial.faxno.value = document.frmFreeTrial.faxno1.value + "-" + document.frmFreeTrial.faxno2.value + "-" +
											document.frmFreeTrial.faxno3.value;
		//document.frmFreeTrial.tollfreeno.value = document.frmFreeTrial.tollfreeno1.value + 
											//document.frmFreeTrial.tollfreeno2.value + 
		var errorText = new Array();
		
		if(isIata==1){
			if (document.frmFreeTrial.agency_name.value == "") {
				errorText.push("Agency Name");
			}
		}
		
		if(isIata==0){
			if (document.frmFreeTrial.agency_dba.value == "") {
				errorText.push("Agency Name");
			}
		}
		/**
		if (document.frmFreeTrial.address1.value == "") {
			errorText.push("Street Address");
		}
		if (document.frmFreeTrial.city.value == "") {
			errorText.push("City");
		}
		**/
		//country
		if (document.frmFreeTrial.country.value == "") {
			errorText.push("Country");
		}
		
		
		var selectCountryIndex = document.frmFreeTrial.country.selectedIndex;
		var countryValue = document.frmFreeTrial.country.options[selectCountryIndex].value;
		
		/**
		if(countryValue == "USA"||
		   countryValue == "CAN"||
		   countryValue == "MEX"){
			
			var selecIndex = document.frmFreeTrial.state.selectedIndex;
			var stateValue =  document.frmFreeTrial.state.options[selecIndex].value;
			
			if (stateValue == null||stateValue == "") {
				errorText.push("Province/State");
			}
		}
		if (document.frmFreeTrial.zip.value == "") {
			errorText.push("Postal/ZIP Code");
		}
				
		if (document.frmFreeTrial.telno.value.length < 8) {
			errorText.push("Business Telephone Number");
		}
		
		if (document.frmFreeTrial.faxno.value.length ==1) {
			document.frmFreeTrial.faxno.value = '';
		}
		**/
		/**
		if (document.frmFreeTrial.faxno.value.length < 8) {
			errorText.push("Business Fax Number");
		}
		
		if (document.frmFreeTrial.image_code.value.length < 6) {
			errorText.push("Generated Image Code (6 Characters)");
		}
		***/
	
	return errorText;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function validateStep3Fields(){
		
		var errorText = peformValidationStep3Fields();
		
		if (errorText.length > 0) {
			alert("Oops! One or more of the following fields required to continue were not completed:\n\n* " + 
			errorText.join("\n* ") + "\n\nPlease complete the required fields and try again.");
		}
		else if(!document.frmFreeTrial.agency_email.value.match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)){ 
			alert("Oops! The email address entered in the 'E-Mail Address' field is not valid." + 					
				 errorText.join("\n") + "\n\nPlease enter a valid email addresses.");
		}
		else if(document.frmFreeTrial.agency_email.value != document.frmFreeTrial.confirm_agency_email.value){
			alert("Oops! The email address entered in the 'E-Mail Address' field does not match the email address entered in the " + 					
				"Confirm E-Mail Address field." + errorText.join("\n") + "\n\nPlease enter the matching email addresses.");
		}
		else {
			new Ajax.Updater('idtrial', '../freetrialphp/triallib.php', {
						  parameters: $('frmFreeTrial').serialize(true)});
			//document.frmFreeTrial.submit();
		}
}

	
function peformValidationStep3Fields(){
	var errorText = new Array();
		
	if (document.frmFreeTrial.agent_first.value == "") {
		errorText.push("Contact/Administrator First Name");
	}
	if (document.frmFreeTrial.agent_last.value == "") {
		errorText.push("Contact/Administrator Last Name");
	}
	if (document.frmFreeTrial.agency_email.value == "") {
		errorText.push("E-Mail Address");
	}
	if (document.frmFreeTrial.confirm_agency_email.value == "") {
		errorText.push("Confirm E-Mail Address");
	}
	/************
	//gds
	if (document.frmFreeTrial.gds.value == "") {
		errorText.push("GDS Used If Any");
	}
	//backoffice
	if (document.frmFreeTrial.backoffice.value == "") {
		errorText.push("Back Office System Used If Any");
	}
	//crm
	if (document.frmFreeTrial.crm.value == "") {
		errorText.push("CRM/Profile Management System Used If Any");
	}
	************/
	if (document.frmFreeTrial.agent_lang.value == "") {
		errorText.push("Default Language");
	}
	
	return errorText;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function validateStep4Fields(){
	var errorText = peformValidationStep4Fields();
		
	if (errorText.length > 0) {
		alert("Oops! One or more of the following fields required to continue were not completed:\n\n* " + 
		errorText.join("\n* ") + "\n\nPlease complete the required fields and try again.");
	}
	else {
		new Ajax.Updater('idtrial', '../freetrialphp/triallib.php', {
					  parameters: $('frmFreeTrial').serialize(true)});
		//document.frmFreeTrial.submit();
	}
	
}

function peformValidationStep4Fields(){
	var errorText = new Array();
	
	/***
	if (document.frmFreeTrial.image_code.value.length < 6) {
		errorText.push("Generated Image Code (6 Characters)");
	}
	***/
	return errorText;
}
///////////////////////////////////////Back Button////////////////////////////////////////////////////////////////////////
function goBack(step){
	var stepnum = document.frmFreeTrial.stepnum.value;
	document.frmFreeTrial.stepnum.value = step;
	//alert("step: " + stepnum);
	/***
	switch(stepnum){
		case '1':
			var errorText = peformValidationStep1Fields();
			if (errorText.length > 0) {
				alert("Oops! One or more of the following fields required to continue were not completed:\n\n* " + 
				errorText.join("\n* ") + "\n\nPlease complete the required fields and try again.");
			}
			else {
				document.frmFreeTrial.stepnum.value = step;
				new Ajax.Updater('idtrial', '../freetrialphp/triallib.php', {
							  parameters: $('frmFreeTrial').serialize(true)});
			}
			break;
		case '2':
			var errorText = peformValidationStep2Fields();
						
			if (errorText.length > 0) {
				alert("Oops! One or more of the following fields required to continue were not completed:\n\n* " + 
				errorText.join("\n* ") + "\n\nPlease complete the required fields and try again.");
			}
			else {
				document.frmFreeTrial.stepnum.value = step;
				new Ajax.Updater('idtrial', '../freetrialphp/triallib.php', {
							  parameters: $('frmFreeTrial').serialize(true)});
				//document.frmFreeTrial.submit();
			}
			break;
		case '3':
			var errorText = peformValidationStep3Fields();
		
			if (errorText.length > 0) {
				alert("Oops! One or more of the following fields required to continue were not completed:\n\n* " + 
				errorText.join("\n* ") + "\n\nPlease complete the required fields and try again.");
			}
			else if(!document.frmFreeTrial.agency_email.value.match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)){ 
				alert("Oops! The email address entered in the 'E-Mail Address' field is not valid." + 					
					 errorText.join("\n") + "\n\nPlease enter a valid email addresses.");
			}
			else if(document.frmFreeTrial.agency_email.value != document.frmFreeTrial.confirm_agency_email.value){
				alert("Oops! The email address entered in the 'E-Mail Address' field does not match the email address entered in the " + 					
					"Confirm E-Mail Address field." + errorText.join("\n") + "\n\nPlease enter the matching email addresses.");
			}
			else {
				document.frmFreeTrial.stepnum.value = step;
				new Ajax.Updater('idtrial', '../freetrialphp/triallib.php', {
							  parameters: $('frmFreeTrial').serialize(true)});
				//document.frmFreeTrial.submit();
			}
			break;
		case '4':
			var errorText = peformValidationStep4Fields();
		
			if (errorText.length > 0) {
				alert("Oops! One or more of the following fields required to continue were not completed:\n\n* " + 
				errorText.join("\n* ") + "\n\nPlease complete the required fields and try again.");
			}
			else {
				document.frmFreeTrial.stepnum.value = step;
				new Ajax.Updater('idtrial', '../freetrialphp/triallib.php', {
							  parameters: $('frmFreeTrial').serialize(true)});
				//document.frmFreeTrial.submit();
			}
			break;
		default:
			//alert("derault step: " + stepnum);
			break;
			
	}
	**/
	new Ajax.Updater('idtrial', '../freetrialphp/triallib.php', {
					  parameters: $('frmFreeTrial').serialize(true)});
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function displayStateList(country){
	var stateElm = document.getElementById("divState");
	
	if(country=="USA"){
		stateElm.innerHTML ="" +
		"<select name=\"state\" id=\"state\" onchange=\"selectCountryBySelectedState()\">\n" + 
            "<option value=\"\">Please select ----------&gt;</option>\n" +
			"<option value=\"AL\" id=\"USA-AL\">Alabama (AL)</option>\n" +
			"<option value=\"AK\" id=\"USA-AK\">Alaska (AK)</option>\n" + 
			"<option value=\"AZ\" id=\"USA-AZ\">Arizona (AZ)</option>\n" + 
			"<option value=\"AR\" id=\"USA-AR\">Arkansas (AR)</option>\n" + 
			"<option value=\"CA\" id=\"USA-CA\">California (CA)</option>\n" + 
			"<option value=\"CO\" id=\"USA-CO\">Colorado (CO)</option>\n" + 
			"<option value=\"CT\" id=\"USA-CT\">Connecticut (CT)</option>\n" + 
			"<option value=\"DE\" id=\"USA-DE\">Delaware (DE)</option>\n" + 
			"<option value=\"DC\" id=\"USA-DC\">District of Columbia (DC)</option>\n" +  
			"<option value=\"FL\" id=\"USA-FL\">Florida (FL)</option>\n" +  
			"<option value=\"GA\" id=\"USA-GA\">Georgia (GA)</option>\n" +  
			"<option value=\"GU\" id=\"USA-GU\">Guam (GU)</option> \n" + 
			"<option value=\"HI\" id=\"USA-HI\">Hawaii (HI)</option> \n" + 
			"<option value=\"ID\" id=\"USA-ID\">Idaho (ID)</option> \n" + 
			"<option value=\"IL\" id=\"USA-IL\">Illinois (IL)</option> \n" + 
			"<option value=\"IN\" id=\"USA-IN\">Indiana (IN)</option> \n" + 
			"<option value=\"IA\" id=\"USA-IA\">Iowa (IA)</option> \n" + 
			"<option value=\"KS\" id=\"USA-KS\">Kansas (KS)</option> \n" + 
			"<option value=\"KY\" id=\"USA-KY\">Kentucky (KY)</option> \n" + 
			"<option value=\"LA\" id=\"USA-LA\">Louisiana (LA)</option> \n" + 
			"<option value=\"ME\" id=\"USA-ME\">Maine (ME)</option> \n" + 
			"<option value=\"MD\" id=\"USA-MD\">Maryland (MD)</option> \n" + 
			"<option value=\"MA\" id=\"USA-MA\">Massachusetts (MA)</option> \n" + 
			"<option value=\"MI\" id=\"USA-MI\">Michigan (MI)</option> \n" + 
			"<option value=\"MN\" id=\"USA-MN\">Minnesota (MN)</option> \n" + 
			"<option value=\"MS\" id=\"USA-MS\">Mississippi (MS)</option> \n" + 
			"<option value=\"MO\" id=\"USA-MO\">Missouri (MO)</option> \n" + 
			"<option value=\"MT\" id=\"USA-MT\">Montana (MT)</option> \n" + 
			"<option value=\"NE\" id=\"USA-NE\">Nebraska (NE)</option> \n" + 
			"<option value=\"NV\" id=\"USA-NV\">Nevada (NV)</option> \n" + 
			"<option value=\"NH\" id=\"USA-NH\">New Hampshire (NH)</option> \n" + 
			"<option value=\"NJ\" id=\"USA-NJ\">New Jersey (NJ)</option> \n" + 
			"<option value=\"NM\" id=\"USA-NM\">New Mexico (NM)</option> \n" + 
			"<option value=\"NY\" id=\"USA-NY\">New York (NY)</option> \n" + 
			"<option value=\"NC\" id=\"USA-NC\">North Carolina (NC)</option> \n" + 
			"<option value=\"ND\" id=\"USA-ND\">North Dakota (ND)</option> \n" + 
			"<option value=\"OH\" id=\"USA-OH\">Ohio (OH)</option> \n" + 
			"<option value=\"OK\" id=\"USA-OK\">Oklahoma (OK)</option> \n" + 
			"<option value=\"OR\" id=\"USA-OR\">Oregon (OR)</option> \n" + 
			"<option value=\"PA\" id=\"USA-PA\">Pennyslvania (PA)</option> \n" + 
			"<option value=\"PR\" id=\"USA-PR\">Puerto Rico (PR)</option>\n" + 
			"<option value=\"RI\" id=\"USA-RI\">Rhode Island (RI)</option>\n" + 
			"<option value=\"SC\" id=\"USA-SC\">South Carolina (SC)</option> \n" + 
			"<option value=\"SD\" id=\"USA-SD\">South Dakota (SD)</option>\n" + 
			"<option value=\"TN\" id=\"USA-TN\">Tennessee (TN)</option> \n" + 
			"<option value=\"TX\" id=\"USA-TX\">Texas (TX)</option> \n" + 
			"<option value=\"UT\" id=\"USA-UT\">Utah (UT)</option> \n" + 
			"<option value=\"VT\" id=\"USA-VT\">Vermont (VT)</option> \n" + 
			"<option value=\"VA\" id=\"USA-VA\">Virginia (VA)</option> \n" + 
			"<option value=\"VI\" id=\"USA-VI\">Virgin Islands (VI)</option> \n" + 
			"<option value=\"WA\" id=\"USA-WA\">Washington (WA)</option> \n" + 
			"<option value=\"WV\" id=\"USA-WV\">West Virginia (WV)</option> \n" + 
			"<option value=\"WI\" id=\"USA-WI\">Wisconsin (WI)</option> \n" + 
			"<option value=\"WY\" id=\"USA-WY\">Wyoming (WY)</option> \n" + 
		"</select>";
	}
	else if(country=="CAN"){
		stateElm.innerHTML ="" +
		"<select name=\"state\" id=\"state\" onchange=\"selectCountryBySelectedState()\">\n" + 
            "<option value=\"\">Please select ----------&gt;</option>\n"+
			"<option value=\"AB\" id=\"CAN-AB\">Alberta (AB)</option> \n" +  
			"<option value=\"BC\" id=\"CAN-BC\">British Columbia (BC)</option> \n" +  
			"<option value=\"MB\" id=\"CAN-MB\">Manitoba (MB)</option> \n" +  
			"<option value=\"NB\" id=\"CAN-NB\">New Brunswick (NB)</option> \n" +  
			"<option value=\"NL\" id=\"CAN-NL\">Newfoundland and Labrador (NL)</option> \n" +  
			"<option value=\"NT\" id=\"CAN-NT\">Northwest Territories (NT)</option> \n" +  
			"<option value=\"NS\" id=\"CAN-NS\">Nova Scotia (NS)</option> \n" +  
			"<option value=\"NU\" id=\"CAN-NU\">Nunavut (NU)</option> \n" +  
			"<option value=\"PE\" id=\"CAN-PE\">Prince Edward Island (PE)</option> \n" +  
			"<option value=\"SK\" id=\"CAN-SK\">Saskatchewan (SK)</option> \n" +  
			"<option value=\"ON\" id=\"CAN-ON\">Ontario (ON)</option>\n" +  
			"<option value=\"QC\" id=\"CAN-QC\">Quebec (QC)</option>\n" +  
			"<option value=\"YT\" id=\"CAN-YT\">Yukon (YT)</option>\n" +
		"</select>";
	}
	else if(country=="MEX"){
		stateElm.innerHTML ="" +
		"<select name=\"state\" id=\"state\" onchange=\"selectCountryBySelectedState()\">\n" + 
            "<option value=\"\">Please select ----------&gt;</option>\n"+
			"<option value=\"AGS\" id=\"MEX-AGS\">Aguascalientes (AGS)</option>\n" +
			"<option value=\"BCN\" id=\"MEX-BCN\">Baja California Norte (BCN)</option>\n" +
			"<option value=\"BCS\" id=\"MEX-BCS\">Baja California Sur (BCS)</option>\n" +
			"<option value=\"CAM\" id=\"MEX-CAM\">Campeche (CAM)</option>\n" +
			"<option value=\"CHIS\" id=\"MEX-CHIS\">Chiapas (CHIS)</option>\n" +
			"<option value=\"CHIH\" id=\"MEX-CHIH\">Chihuahua (CHIH)</option>\n" +
			"<option value=\"COAH\" id=\"MEX-COAH\">Coahuila (COAH)</option>\n" +
			"<option value=\"COL\" id=\"MEX-COL\">Colima (COL)</option>\n" +
			"<option value=\"DF\" id=\"MEX-DF\">Distrito Federal (DF)</option>\n" +
			"<option value=\"DGO\" id=\"MEX-DGO\">Durango (DGO)</option>\n" +
			"<option value=\"GTO\" id=\"MEX-GTO\">Guanajuato (GTO)</option>\n" +
			"<option value=\"GRO\" id=\"MEX-GRO\">Guerrero (GRO)</option>\n" +
			"<option value=\"HGO\" id=\"MEX-HGO\">Hidalgo (HGO)</option>\n" + 
			"<option value=\"JAL\" id=\"MEX-JAL\">Jalisco (JAL)</option>\n" + 
			"<option value=\"EDM\" id=\"MEX-EDM\">M&eacute;xico - Estado de (EDM)</option>\n" +
			"<option value=\"MICH\" id=\"MEX-MICH\">Michoac&aacute;n (MICH)</option>\n" + 
			"<option value=\"MOR\" id=\"MEX-MOR\">Morelos (MOR)</option>\n" + 
			"<option value=\"NAY\" id=\"MEX-NAY\">Nayarit (NAY)</option>\n" + 
			"<option value=\"NL\" id=\"MEX-NL\">Nuevo Le&oacute;n (NL)</option>\n" + 
			"<option value=\"OAX\" id=\"MEX-OAX\">Oaxaca (OAX)</option>\n" + 
			"<option value=\"PUE\" id=\"MEX-PUE\">Puebla (PUE)</option>\n" + 
			"<option value=\"QRO\" id=\"MEX-QRO\">Quer&eacute;taro (QRO)</option>\n" + 
			"<option value=\"QROO\" id=\"MEX-QROO\">Quintana Roo (QROO)</option>\n" + 
			"<option value=\"SLP\" id=\"MEX-SLP\">San Luis Potos&iacute; (SLP)</option>\n" + 
			"<option value=\"SIN\" id=\"MEX-SIN\">Sinaloa (SIN)</option>\n" + 
			"<option value=\"SON\" id=\"MEX-SON\">Sonora (SON)</option>\n" + 
			"<option value=\"TAB\" id=\"MEX-TAB\">Tabasco (TAB)</option>\n" + 
			"<option value=\"TAMPS\" id=\"MEX-TAMPS\">Tamaulipas (TAMPS)</option>\n" + 
			"<option value=\"TLAX\" id=\"MEX-TLAX\">Tlaxcala (TLAX)</option>\n" + 
			"<option value=\"VER\" id=\"MEX-VER\">Veracruz (VER)</option>\n" + 
			"<option value=\"YUC\" id=\"MEX-YUC\">Yucat&aacute;n (YUC)</option>\n" + 
			"<option value=\"ZAC\" id=\"MEX-ZAC\">Zacatecas (ZAC)</option>\n" + 
		"</select>";
	}
	else{//other coutnries
		stateElm.innerHTML ="<input name='state' value='' maxlength='3' style=\"width:40px\" ";
	}
	
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function getCountryPhoneCode(countryCode){
	var arrCountryCode = new Array('USA', 'CAN',
							   'MEX', 'AFG',
							   'ALB', 'DZA',
							   'ASM', 'AND',
							   'AGO', 'ATG',
							   'ARG',  'ARM', 
							   'ABW', 'AUS',
							   'AUT', 'AZE',
							   'BHS', 'BHR',
							   'BGD', 'BRB',
							   'BLR', 'BEL',
							   'BLZ', 'BEN',
							   'BMU', 'BTN',
							   'BOL', 'BIH',
							   'BWA', 'BRN',
							   'BGR', 'BFA',
							   'BDI', 'KHM',
							   'CMR', 'CPV',
							   'CYM', 'CAF',
							   'TCD', 'CHL',
							   'CHN', 'COL',
							   'COM', 'COG',
							   'COD', 'COK',
							   'CRI', 'CIV',
							   'HRV', 'CUB',
							   'CYP', 'CZE',
							   'DNK', 'DJI',
							   'DMA', 'DOM',
							   'ECU', 'EGY',
							   'SLV', 'GNQ',
							   'ERI', 'EST',
							   'ETH', 'FIJ',
							   'FIN', 'FRA',
							   'GAB', 'GMB',
							   'DEU', 'GHA',
							   'GBR', 'GRC',
							   'GRD', 'GUM',
							   'GTM', 'GIN',
							   'GNB', 'GUY',
							   'HTI', 'HND',
							   'HKG', 'HUN',
							   'ISL', 'IND',
							   'IDN',
							   'IRN', 'IRQ',
							   'IRL', 'ITA',
							   'ISR', 'JAM',
							   'JPN', 'JOR',
							   'KAZ', 'KEN',
							   'KIR', 'PRK',
							   'KOR', 'KWT',
							   'KGZ', 'LAO',
							   'LVA', 'LBN',
							   'LSO', 'LBR',
							   'LBY', 'LIE',
							   'LTU', 'LUX',
							   'MKD', 'MDG',
							   'MAD', 'MWI',
							   'MYS', 'MDV',
							   'MLI', 'MLT',
							   'MHL', 'MRT',
							   'MUS', 'MEX',
							   'FSM', 'MDA',
							   'MCO', 'MNG',
							   'MNE', 'MAR',
							   'MOZ', 'MMR',
							   'NAM', 'NRU',
							   'NPL', 'NLD',
							   'ANT', 'NIC',
							   'NIC', 'NER',
							   'NGA', 'NOR',
							   'OMA', 'PAK',
							   'PLW', 'PSE',
							   'PAN', 'PNG',
							   'PRY', 'PER',
							   'PHL', 'POL',
							   'PRT', 'PRI',
							   'QAT', 'ROU',
							   'RUS', 'RWA',
							   'KNA', 'LCA',
							   'VCT', 'WSM',
							   'SMR', 'STP',
							   'SAU', 'SEN',
							   'SRB', 'SYC',
							   'SLE', 'SGP',
							   'SVK', 'SVN',
							   'SLB', 'SOM',
							   'ZAF', 'ESP',
							   'LKA', 'SDN',
							   'SUR', 'SWZ',
							   'SWE', 'CHE',
							   'SYR', 'TWN',
							   'TJK', 'TZA',
							   'THA', 'TLS',
							   'TGO', 'TKL',
							   'TON', 'TTO',
							   'TUN', 'TUR',
							   'TKM', 'TCA',
							   'TUV', 'UGA',
							   'UKR', 'ARE',
							   'GBR', 'URY',
							   'UZB', 'VUT',
							   'VAT', 'VEN',
							   'VNM', 'VGB',
							   'VIR', 'WLF',
							   'YEM', 'ZMB',
							   'ZWE');
	var arrCountryPhoneCodes = new Array(1, 1,
							   52, 93,
							   355, 213,
							   684, 376,
							   244, 264,
							   54, 7, 
							   297,67,
							   43, 994,
							   242, 973,
							   880, 246,
							   373, 32,
							   501, 229,
							   441, 975,
							   591, 387,
							   267, 673,
							   359, 226,
							   257, 855,
							   
							   237, 238,
							   345, 236,
							   235, 56,
							   86, 57,
							   269, 242,
							   243, 682,
							   506, 225,
							   385, 53,
							   357, 420,
							   45, 253,
							   767, 809,
							   593, 20,
							   
							   503, 240,
							   291, 372,
							   251, 679,
							   358, 33,
							   241, 220,
							   49, 233,
							   44, 30,
							   473, 671,
							   502, 224,
							   245, 592,
							   509, 504,
							   852, 36,
							   354, 91,
							   62,
							   98, 964,
							   353, 39,
							   972, 876,
							   81, 962,
							   7, 254,
							   686, 850,
							   82, 965,
							   996, 856,
							   371, 961,
							   266, 231,
							   218, 423,
							   370, 352,
							   389, 261,
							   261, 261,
							   60, 960,
							   223, 356,
							   692, 222,
							   230, 252,
							   691, 373,
							   377, 976,
							   382, 212,
							   258, 95,
							   264, 674,
							   977, 31,
							   599, 64,
							   505, 227,
							   234, 47,
							   968, 92,
							   680, 970,
							   507, 675,
							   595, 51,
							   63, 48,
							   351, 1,
							   974, 40,
							   7, 250,
							   869, 758,
							   784, 685,
							   378, 239,
							   966, 221,
							   381, 248,
							   232, 65,
							   421, 386,
							   677, 252,
							   27, 34,
							   94, 249,
							   597, 268,
							   46, 41,
							   963, 886,
							   992, 255,
							   66, 670,
							   228, 690,
							   676, 868,
							   216, 90,
							   993, 649,
							   688, 256,
							   380, 971,
							   44, 598,
							   998, 678,
							   379, 58,
							   84, 284,
							   340, 681,
							   967, 260,
							   263);

	//find the index from the first arry
	var foundIndex = -1;
	for(var i=0; i<arrCountryCode.length; i++){
			if(countryCode == arrCountryCode[i]){
				foundIndex = i;
				break;
			}
	}
	
	if(foundIndex == -1){
		return "";
	}
	else{
		return arrCountryPhoneCodes[foundIndex];
	}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function selectCountryBySelectedState(){
		
		var selectedIndex = document.frmFreeTrial.state.selectedIndex;
		var idValue = document.frmFreeTrial.state.options[selectedIndex].id;
		var splitArr = idValue.split("-");
		selectCountryByCode(splitArr[0]);//select a country
		
		if(splitArr[0]==""){
			document.frmFreeTrial.country.selectedIndex = 0;//reset country list
		}
		else if(splitArr[0]=="CAN"){
			//showHideDiv("row-gst", true);
			
			showHide("row-gst", true);
			if(splitArr[1]=="QC"){//Show qst row for Quebec, Canada
				 //showHideDiv("row-qst", true);
				 showHide("row-qst", true);	
			}
			else{
			
				///////////////////////////////////////////////////////////////
				if(splitArr[1] == "NS"||
					   splitArr[1] == "NB"||
					   splitArr[1] == "NL"){
						
						document.getElementById("idGST").innerHTML = "GST/HST Number:";
				}
				else{
					document.getElementById("idGST").innerHTML = "GST Number:";
				}
				//////////////////////////////////////////////////////////////
				//showHideDiv("row-qst", false);	
				showHide("row-qst", false);	
			}
		}
		else{
			//showHideDiv("row-qst", false);	
			showHide("row-qst", false);	
			showHide("row-gst", false);
		}
	
}
//select by country code
function selectCountryByCode(countryCode){
	
	var numOfOptions = document.frmFreeTrial.country.length;
	for(var i=0; i<numOfOptions; i++){
		
		if(document.frmFreeTrial.country.options[i].value == countryCode){
			document.frmFreeTrial.country.options[i].selected = true;
			break;
		}
	}
}
//select by state code
function selectStateByCode(stateCode){
	
	var numOfOptions = document.frmFreeTrial.state.length;
	for(var i=0; i<numOfOptions; i++){
		
		if(document.frmFreeTrial.state.options!=null && document.frmFreeTrial.state.options[i].value == stateCode){
			document.frmFreeTrial.state.options[i].selected = true;
			break;
		}
	}
}
function hideShowStateRow(){
	var selectedIndex = document.frmFreeTrial.country.selectedIndex;
	var countryCode = document.frmFreeTrial.country.options[selectedIndex].value;
	
	//select state list
	//alert(countryCode);
	displayStateList(countryCode);
	//set phone code
	var phoneCode = getCountryPhoneCode(countryCode);
	document.getElementById("telno1").value = phoneCode;
	//document.getElementById("faxno1").value = phoneCode;
	//document.getElementById("tollfree1").value = phoneCode;
	
	
	if(countryCode=="USA" || countryCode=="CAN" || countryCode=="MEX"){

		showHide("row-state", true);
         //showHideDiv("row-state", true);
		if(countryCode=="CAN"){
			 //showHideDiv("row-gst", true);
			 showHide("row-gst", true);
			 
			
				if(document.frmFreeTrial.state.value == "NS"||
					   document.frmFreeTrial.state.value == "NB"||
					   document.frmFreeTrial.state.value == "NL"){
						
						document.getElementById("idGST").innerHTML = "GST/HST Number:";
				}
				else{
					document.getElementById("idGST").innerHTML = "GST Number:";
				}
			
		}
		else{
			//showHideDiv("row-gst", false);
			showHide("row-qst", false);	
		  	showHide("row-gst", false);
		}
	}
	else{
            showHide("row-state", false);
			showHide("row-qst", false);	
			showHide("row-gst", false);
			//showHideDiv("row-state", false);
                
	}
	
	//alert(document.frmFreeTrial.state + "");
	if(document.frmFreeTrial.state!=null && document.frmFreeTrial.state.options !=null)
		document.frmFreeTrial.state.options[0].selected = true;
	
	
}
	//display hide element tag contents by id
	function showHide(elmId, displayBoolean){
		
		if(displayBoolean == true){
		
				document.getElementById(elmId).style.display = "";
		}
		else{
			
				document.getElementById(elmId).style.display = "none";						
		}
	}
	
////////////Submit login agent form
function handleKeyPressAgtLogin1(e){
	var key=e.keyCode || e.which;
	//alert('agent login:' + key);
	if (key==13){
		
		validateIataAndSubmit();
	}
}
/******************************************************************************************************************
function menuMouseOverSmall($leftId, $centerId, $rightId){
	//document.getElementById($leftId).innerHTML = "<img src=\"../assets/button_left.png\"/>";
	document.getElementById($leftId).className = "innerSmallHiMenuLeft"
	document.getElementById($centerId).className = "innerSmallHiMenu";
	document.getElementById($rightId).className = "innerSmallHiMenuRight"
	
	//document.getElementById($rightId).innerHTML = "<img src=\"../assets/button_right.png\"/>";
}
function menuMouseOutSmall($leftId, $centerId, $rightId){
	//document.getElementById($leftId).innerHTML = "<img src=\"../assets/button_left_dark.png\"/>";
	document.getElementById($leftId).className = "innerSmallMenuLeft";
	document.getElementById($centerId).className = "innerSmallMenu";
	document.getElementById($rightId).className = "innerSmallMenuRight";
	//document.getElementById($rightId).innerHTML = "<img src=\"../assets/button_right_dark.png\"/>";
}	
**********/
	/**
	//display hide element tag contents by id
	function showHideDiv(elmId, displayBoolean){
		
		if(displayBoolean == true){
		
				document.getElementById(elmId).style.visibility = 'visible'; 
		}
		else{
			
				document.getElementById(elmId).style.visibility = 'hidden'; 
						
		}
	}
	**/
