////////////////////////////////////////////////////////////////////////////////////////////

var passportNormal=true;

////////////////////////////////////////////////////////////////////////////////////////////

function loading(){
	loadingmsg="<html><head>";
	loadingmsg+="<body bgcolor='#FFFFFF' background='/content/includes/webdocs/images/bgrfl.gif'>";
	loadingmsg+="<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;<font face='Arial, Helvetica, sans-serif' size='2'>Searching Timatic information</font>";
	document.write(loadingmsg);
	return;
}

////////////////////////////////////////////////////////////////////////////////////////////

function seeList(){
	var result="Use ctrl-key to select or deselect destination(s) above";
	var aantalSelected=0;
	for (var i=0; i<document.forms[1].DE.length; i++){
		if (document.forms[1].DE.options[i].selected){
			aantalSelected++;
			if (aantalSelected==1){ 
				result=document.forms[1].DE.options[i].text; 
			}
			else{	
				result +='\n'+document.forms[1].DE.options[i].text;
			}
		}
	}
	eval("document.forms[1].selDest.value=result");
	
	var result1="Use ctrl-key to select or deselect transit point(s) above"
	var aantalSelected1=0
	for (var i=0 ;i<document.forms[1].TR.length; i++){
		if (document.forms[1].TR.options[i].selected){
			aantalSelected1++;
			if (aantalSelected1==1){ 
				result1=document.forms[1].TR.options[i].text; 
			}
			else{	
				result1 +='\n'+document.forms[1].TR.options[i].text;
			}
		}
	}
	eval("document.forms[1].selTrans.value=result1");
	
	if(document.forms[1].page.value=="health"||document.forms[1].page.value=="both"){
		var result2="Use ctrl-key to select or deselect visited countries above";
		var aantalSelected2=0;
		for (var i=0; i<document.forms[1].VT.length; i++){
			if (document.forms[1].VT.options[i].selected){
				aantalSelected2++;
				if (aantalSelected2==1){
					result2=document.forms[1].VT.options[i].text;
				}else{	
					result2 +='\n'+document.forms[1].VT.options[i].text;
				}
			}
		}
		eval("document.forms[1].selVisi.value=result2")
	}
}

////////////////////////////////////////////////////////////////////////////////////////////

function resetForm(){	// Reset het formulier
	if (document.forms[1].page.value=="visa" || document.forms[1].page.value=="both"){
		document.forms[1].PASSTYPES[0].checked=true;
	}
	document.forms[1].reset();
	setTypeVar();
}

////////////////////////////////////////////////////////////////////////////////////////////

function setTypeVar(){	
	if (document.forms[1].page.value=="visa" || document.forms[1].page.value=="both"){
		if(document.forms[1].PASSTYPES[0].checked){ passportNormal=true; } else { passportNormal=false; }
		checkIt();
	}
	seeList();
	setEmbarkation();
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function checkIt(){
	if (document.forms[1].page.value=="visa" || document.forms[1].page.value=="both"){
		if(passportNormal){
			document.forms[1].AR.options[0].text='Select, if applicable';
			document.forms[1].AR.options[0].value='00';
			document.forms[1].AR.disabled=false;
		} 		
		else{
			document.forms[1].AR.options[0].selected=true;		
			document.forms[1].AR.options[0].text='NA';
			document.forms[1].AR.disabled=true;
			document.forms[1].AR.options[0].value='00';
		}
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function setEmbarkation(){
	if(document.forms[1].page.value=="both" && document.forms[1].EM.value=="00"){
		document.forms[1].EM.value = document.forms[1].NA.value;
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function makeList(name,multiple){
	var dbCountries = [
		{value: 'AF', text: 'Afghanistan'},
		{value: 'AL', text: 'Albania'},
		{value: 'DZ', text: 'Algeria'},
		{value: 'AD', text: 'Andorra'},
		{value: 'AO', text: 'Angola'},
		{value: 'AI', text: 'Anguilla'},
		{value: 'AG', text: 'Antigua and Barbuda'},
		{value: 'AR', text: 'Argentina'},
		{value: 'AM', text: 'Armenia'},
		{value: 'AW', text: 'Aruba'},
		{value: 'AU', text: 'Australia'},
		{value: 'AT', text: 'Austria'},
		{value: 'AZ', text: 'Azerbaijan'},
		{value: 'BS', text: 'Bahamas'},
		{value: 'BH', text: 'Bahrain'},
		{value: 'BD', text: 'Bangladesh'},
		{value: 'BB', text: 'Barbados'},
		{value: 'BY', text: 'Belarus'},
		{value: 'BE', text: 'Belgium'},
		{value: 'BZ', text: 'Belize'},
		{value: 'BJ', text: 'Benin(Rep.)'},
		{value: 'BM', text: 'Bermuda'},
		{value: 'BT', text: 'Bhutan'},
		{value: 'BO', text: 'Bolivia'},
		{value: 'BA', text: 'Bosnia Her.'},
		{value: 'BW', text: 'Botswana'},
		{value: 'BR', text: 'Brazil'},
		{value: 'BN', text: 'Brunei'},
		{value: 'BG', text: 'Bulgaria'},
		{value: 'BF', text: 'Burkina Faso'},
		{value: 'BI', text: 'Burundi'},
		{value: 'KH', text: 'Cambodia'},
		{value: 'CM', text: 'Cameroon'},
		{value: 'CA', text: 'Canada'},
		{value: 'CV', text: 'Cape Verde Islands'},
		{value: 'KY', text: 'Cayman Islands'},
		{value: 'CF', text: 'Central African Rep.'},
		{value: 'TD', text: 'Chad'},
		{value: 'CL', text: 'Chile'},
		{value: 'CN', text: 'China(Peoples Rep.)'},
		{value: 'TW', text: 'Chinese Taipei'},
		{value: 'CO', text: 'Colombia'},
		{value: 'KM', text: 'Comores Islands'},
		{value: 'CG', text: 'Congo(Brazzaville)'},
		{value: 'CD', text: 'Congo(Kinshasa)'},
		{value: 'CK', text: 'Cook Islands'},
		{value: 'CR', text: 'Costa Rica'},
		{value: 'CI', text: 'Cote d Ivoire'},
		{value: 'HR', text: 'Croatia'},
		{value: 'CU', text: 'Cuba'},
		{value: 'CY', text: 'Cyprus'},
		{value: 'CZ', text: 'Czech Rep.'},
		{value: 'DK', text: 'Denmark'},
		{value: 'DJ', text: 'Djibouti (Rep.)'},
		{value: 'DM', text: 'Dominica'},
		{value: 'DO', text: 'Dominican Rep.'},
		{value: 'EC', text: 'Ecuador'},
		{value: 'EG', text: 'Egypt (Arab Rep. of)'},
		{value: 'SV', text: 'El Salvador'},
		{value: 'GQ', text: 'Equatorial Guinea'},
		{value: 'ER', text: 'Eritrea'},
		{value: 'EE', text: 'Estonia'},
		{value: 'ET', text: 'Ethiopia'},
		{value: 'FK', text: 'Falkland Islands'},
		{value: 'FO', text: 'Faroe Islands'},
		{value: 'FJ', text: 'Fiji'},
		{value: 'FI', text: 'Finland'},
		{value: 'FR', text: 'France'},
		{value: 'GF', text: 'French Guiana'},
		{value: 'PF', text: 'French Polynesia'},
		{value: 'GP', text: 'French West Indies'},
		{value: 'GA', text: 'Gabon'},
		{value: 'GM', text: 'Gambia'},
		{value: 'GE', text: 'Georgia'},
		{value: 'DE', text: 'Germany'},
		{value: 'GH', text: 'Ghana'},
		{value: 'GI', text: 'Gibraltar'},
		{value: 'GR', text: 'Greece'},
		{value: 'GL', text: 'Greenland'},
		{value: 'GD', text: 'Grenada'},
		{value: 'GU', text: 'Guam(Mariana Island)'},
		{value: 'GT', text: 'Guatemala'},
		{value: 'GN', text: 'Guinea (Rep. of)'},
		{value: 'GW', text: 'Guinea-Bissau'},
		{value: 'GY', text: 'Guyana'},
		{value: 'HT', text: 'Haiti'},
		{value: 'HN', text: 'Honduras'},
		{value: 'HK', text: 'Hong Kong (SAR China)'},
		{value: 'HU', text: 'Hungary'},
		{value: 'IS', text: 'Iceland'},
		{value: 'IN', text: 'India'},
		{value: 'ID', text: 'Indonesia'},
		{value: 'IR', text: 'Iran(Isl. Rep. of)'},
		{value: 'IQ', text: 'Iraq'},
		{value: 'IE', text: 'Ireland (Rep. of)'},
		{value: 'IL', text: 'Israel'},
		{value: 'IT', text: 'Italy'},
		{value: 'JM', text: 'Jamaica'},
		{value: 'JP', text: 'Japan'},
		{value: 'JO', text: 'Jordan'},
		{value: 'KZ', text: 'Kazakhstan'},
		{value: 'KE', text: 'Kenya'},
		{value: 'KI', text: 'Kiribati'},
		{value: 'KP', text: 'Korea(Peoples Rep.)'},
		{value: 'KR', text: 'Korea(Rep.)'},
		{value: 'RK', text: 'Kosovo (Rep. of)'},
		{value: 'KW', text: 'Kuwait'},
		{value: 'KG', text: 'Kyrgyzstan'},
		{value: 'LA', text: 'Laos'},
		{value: 'LV', text: 'Latvia'},
		{value: 'LB', text: 'Lebanon'},
		{value: 'LS', text: 'Lesotho'},
		{value: 'LR', text: 'Liberia'},
		{value: 'LY', text: 'Libya'},
		{value: 'LI', text: 'Liechtenstein'},
		{value: 'LT', text: 'Lithuania'},
		{value: 'LU', text: 'Luxembourg'},
		{value: 'MO', text: 'Macao (SAR China)'},
		{value: 'MK', text: 'Macedonia (FYROM)'},
		{value: 'MG', text: 'Madagascar(Dem. Rep.)'},
		{value: 'MW', text: 'Malawi'},
		{value: 'MY', text: 'Malaysia'},
		{value: 'MV', text: 'Maldives'},
		{value: 'ML', text: 'Mali'},
		{value: 'MT', text: 'Malta'},
		{value: 'MH', text: 'Marshall Islands'},
		{value: 'MR', text: 'Mauritania'},
		{value: 'MU', text: 'Mauritius'},
		{value: 'YT', text: 'Mayotte'},
		{value: 'MX', text: 'Mexico'},
		{value: 'FM', text: 'Micronesia (Fed. St. of)'},
		{value: 'MD', text: 'Moldova(Rep. of)'},
		{value: 'MC', text: 'Monaco'},
		{value: 'MN', text: 'Mongolia'},
		{value: 'ME', text: 'Montenegro (Rep. of)'},
		{value: 'MS', text: 'Montserrat'},
		{value: 'MA', text: 'Morocco'},
		{value: 'MZ', text: 'Mozambique'},
		{value: 'MM', text: 'Myanmar'},
		{value: 'NA', text: 'Namibia'},
		{value: 'NR', text: 'Nauru'},
		{value: 'NP', text: 'Nepal'},
		{value: 'AN', text: 'Netherlands Antilles'},
		{value: 'NL', text: 'Netherlands'},
		{value: 'NC', text: 'New Caledonia'},
		{value: 'NZ', text: 'New Zealand'},
		{value: 'NI', text: 'Nicaragua'},
		{value: 'NE', text: 'Niger'},
		{value: 'NG', text: 'Nigeria'},
		{value: 'NU', text: 'Niue'},
		{value: 'NF', text: 'Norfolk Island'},
		{value: 'MP', text: 'Northern Mariana Isl.'},
		{value: 'NO', text: 'Norway'},
		{value: 'OM', text: 'Oman'},
		{value: 'PK', text: 'Pakistan'},
		{value: 'PW', text: 'Palau Islands'},
		{value: 'PS', text: 'Palestinian Territory'},
		{value: 'PA', text: 'Panama'},
		{value: 'PG', text: 'Papua New Guinea'},
		{value: 'PY', text: 'Paraguay'},
		{value: 'PE', text: 'Peru'},
		{value: 'PH', text: 'Philippines'},
		{value: 'PL', text: 'Poland'},
		{value: 'PT', text: 'Portugal'},
		{value: 'PR', text: 'Puerto Rico'},
		{value: 'QA', text: 'Qatar'},
		{value: 'RE', text: 'Reunion'},
		{value: 'RO', text: 'Romania'},
		{value: 'RU', text: 'Russian Federation'},
		{value: 'RW', text: 'Rwanda'},
		{value: 'AS', text: 'Samoa(American)'},
		{value: 'WS', text: 'Samoa'},
		{value: 'SM', text: 'San Marino'},
		{value: 'ST', text: 'Sao Tome &amp; Principe'},
		{value: 'SA', text: 'Saudi Arabia'},
		{value: 'SN', text: 'Senegal'},
		{value: 'RS', text: 'Serbia (Rep. of)'},
		{value: 'SC', text: 'Seychelles'},
		{value: 'SL', text: 'Sierra Leone'},
		{value: 'SG', text: 'Singapore'},
		{value: 'SK', text: 'Slovak Rep.'},
		{value: 'SI', text: 'Slovenia'},
		{value: 'SB', text: 'Solomon Islands'},
		{value: 'SO', text: 'Somalia'},
		{value: 'ZA', text: 'South Africa'},
		{value: 'ES', text: 'Spain'},
		{value: 'LK', text: 'Sri Lanka (Rep.)'},
		{value: 'KN', text: 'St.Kitts-Nevis'},
		{value: 'LC', text: 'St.Lucia'},
		{value: 'VC', text: 'St.Vincent &amp; Grenadines'},
		{value: 'SD', text: 'Sudan'},
		{value: 'SR', text: 'Suriname'},
		{value: 'SZ', text: 'Swaziland'},
		{value: 'SE', text: 'Sweden'},
		{value: 'CH', text: 'Switzerland'},
		{value: 'SY', text: 'Syria'},
		{value: 'TJ', text: 'Tajikistan'},
		{value: 'TZ', text: 'Tanzania(United Rep. of)'},
		{value: 'TH', text: 'Thailand'},
		{value: 'TL', text: 'Timor Leste'},
		{value: 'TG', text: 'Togo'},
		{value: 'TO', text: 'Tonga'},
		{value: 'TT', text: 'Trinidad &amp; Tobago'},
		{value: 'TN', text: 'Tunisia'},
		{value: 'TR', text: 'Turkey'},
		{value: 'TM', text: 'Turkmenistan'},
		{value: 'TC', text: 'Turks &amp; Caicos Isl.'},
		{value: 'TV', text: 'Tuvalu'},
		{value: 'US', text: 'U.S.A.'},
		{value: 'UG', text: 'Uganda'},
		{value: 'UA', text: 'Ukraine'},
		{value: 'AE', text: 'United Arab Emirates'},
		{value: 'GB', text: 'United Kingdom (GB)'},
		{value: 'UY', text: 'Uruguay'},
		{value: 'UZ', text: 'Uzbekistan'},
		{value: 'VU', text: 'Vanuatu'},
		{value: 'VA', text: 'Vatican City'},
		{value: 'VE', text: 'Venezuela'},
		{value: 'VN', text: 'Vietnam'},
		{value: 'VI', text: 'Virgin Islands (U.S.A.)'},
		{value: 'VG', text: 'Virgin Islands (British)'},
		{value: 'YE', text: 'Yemen Rep.'},
		{value: 'ZM', text: 'Zambia'},
		{value: 'ZW', text: 'Zimbabwe'}
	];
	
	var txt = '';
	if (!multiple) {
		txt = 'Select country';
		if(name=='AR'){
			txt = 'Select, if applicable';
		} 
	}

	var countryList='<select class="text" '+multiple+' name="'+name+'" onChange="setTypeVar()" style="padding:0;margin:0">';
	if (txt != '') {
		countryList+='<option value="00">'+txt+'</option>';
	}
	var i = dbCountries.length;
	while (i>0) {
		var c = dbCountries.length-i;
		var txt = dbCountries[c].text;
		var val = dbCountries[c].value;
		countryList+='<option value="'+val+'">'+txt+'</option>';
		i--;
	}
	countryList+='</select>';
	
	document.writeln(countryList);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function MM_goToURL(){ //v2.0
	for (var i=0; i < (MM_goToURL.arguments.length - 1); i+=2) { //with arg pairs
		eval(MM_goToURL.arguments[i]+".location='"+MM_goToURL.arguments[i+1]+"'");
	}
	document.MM_returnValue = false;
}

function validate(){
	document.forms[1].action = "http://www.timaticweb.com/cgi-bin/tim_website_client.cgi";
	document.forms[1].method = "get";
	getTimCookie();
	document.forms[1].user.value = user;
	document.forms[1].subuser.value = subuser;
	document.forms[1].submit();
}
