var horizontal_offset="0px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox
//End comment
//Dem ky tu
var ns6=document.getElementById&&!document.all

function restrictinput(maxlength,e,placeholder){
if (window.event&&event.srcElement.value.length>=maxlength)
return false
else if (e.target&&e.target==eval(placeholder)&&e.target.value.length>=maxlength){
var pressedkey=/[a-zA-Z0-9\.\,\/]/ //detect alphanumeric keys
if (pressedkey.test(String.fromCharCode(e.which)))
e.stopPropagation()
}
}

function countlimit(maxlength,e,placeholder){
var theform=eval(placeholder)
var lengthleft=maxlength-theform.value.length
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder)
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,maxlength)
placeholderobj.innerHTML=lengthleft
}
}


function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename
var limit_text='<font color=#346b98>[<span id="'+theform.toString()+'">'+thelimit+'</span>]</font>'
if (document.all||ns6)
document.write(limit_text)
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,theform) }, true);
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true);
}
}

// tips map

function change_lang(i){
	 location.href="language.php?language="+i;
}

function over(id){
	  document.getElementById(id).className='td_top_tap';
}
function out(id){
	  document.getElementById(id).className='td_top';
}

function over1(id){
	  document.getElementById(id).className='td_top1_tap';
}
function out1(id){
	  document.getElementById(id).className='td_top1';
}
function change_page(i){
		 location.href=i;
}

function check_form_apply()
{
	if (document.applystep2.name.value == '')
	{
		alert('Please input your Name!');
		document.applystep2.name.focus();
		return false;
	}
	if (document.applystep2.country.value == '')
	{
		alert('Please select your Country!');
		document.applystep2.country.focus();
		return false;
	}	
	if (document.applystep2.passport_number.value == '')
	{
		alert('Please input Passport Number!');
		document.applystep2.passport_number.focus();
		return false;
	}
	if (document.applystep2.birth.value == '')
	{
		alert('Please input Date of birth!');
		document.applystep2.birth.focus();
		return false;
	}		
	if (document.applystep2.email.value == '')
	{
		alert('Please input your email!');
		document.applystep2.email.focus();
		return false;
	}	
	if (document.applystep2.arrival.value == '')
	{
		alert('Please input Date of arrival!');
		document.applystep2.arrival.focus();
		return false;
	}
    if (document.applystep2.flight.value == '')
	{
		alert('Please input Flight Ref!');
		document.applystep2.flight.focus();
		return false;
	}

	return true;
}


function check_form_apply1()
{
	if (document.apply1.Name1.value == '')
	{
		alert('Please enter your name!');
		document.apply1.Name1.focus();
		return false;
	}
	
	if ((document.apply1.DOB1_Day.value == '') || (document.apply1.DOB1_Month.value == '') || (document.apply1.DOB1_Year.value == ''))
	{
		alert('The date of birth is not valid!');
		document.apply1.DOB1_Day.focus();
		return false;
	}
	
	
	if (document.apply1.Nationality1.value == '')
	{
		alert('Please enter your nationality!');
		document.apply1.Nationality1.focus();
		return false;
	}
	
	if (document.apply1.PassportNumber.value == '')
	{
		alert('Please enter your passport number!');
		document.apply1.PassportNumber.focus();
		return false;
	}
	
	//Information
	
	//Check sender email
	if (document.apply1.SenderEmail.value == '')
	{
		alert('Please enter your email address!');
		document.apply1.SenderEmail.focus();
		return false;
	} else {
		
			if (!_CF_checkregex(document.apply1.SenderEmail.value, 
/^[A-Za-z0-9]+([._-]?[A-Za-z0-9]+)*@[A-Za-z0-9]+([.-]?[A-Za-z0-9]+)*.(([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/, true))
            {
                alert('E-mail address is improperly formatted!');
				document.apply1.SenderEmail.focus();
				return false;				
            }
	}
	
	//Check date of arrival
	if ((document.apply1.DateOfArrival_Day.value == '') || (document.apply1.DateOfArrival_Month.value == '') || (document.apply1.DateOfArrival_Year.value == ''))
	{
		alert('The date of arrival is not valid!');
		document.apply1.DateOfArrival_Day.focus();
		return false;
	}
	//---------------
	
	return true;
}

function check_form_apply2()
{
	//Person 01
	if (document.apply2.Name1.value == '')
	{
		alert('Please enter your name!');
		document.apply2.Name1.focus();
		return false;
	}
	
	if ((document.apply2.DOB1_Day.value == '') || (document.apply2.DOB1_Month.value == '') || (document.apply2.DOB1_Year.value == ''))
	{
		alert('The date of birth is not valid!');
		document.apply2.DOB1_Day.focus();
		return false;
	}	
	
	if (document.apply2.Nationality1.value == '')
	{
		alert('Please enter your nationality!');
		document.apply2.Nationality1.focus();
		return false;
	}
	
	if (document.apply2.PassportNumber.value == '')
	{
		alert('Please enter your passport number!');
		document.apply2.PassportNumber.focus();
		return false;
	}
	
	//Person 02
	if (document.apply2.Name2.value == '')
	{
		alert('Please enter your name!');
		document.apply2.Name2.focus();
		return false;
	}
	
		if ((document.apply2.DOB2_Day.value == '') || (document.apply2.DOB2_Month.value == '') || (document.apply2.DOB2_Year.value == ''))
	{
		alert('The date of birth is not valid!');
		document.apply2.DOB2_Day.focus();
		return false;
	}
	
	if (document.apply2.Nationality2.value == '')
	{
		alert('Please enter your nationality!');
		document.apply2.Nationality2.focus();
		return false;
	}
	
	if (document.apply2.PassportNumber2.value == '')
	{
		alert('Please enter your passport number!');
		document.apply2.PassportNumber2.focus();
		return false;
	}
	
		
	//Information
	
	//Check sender email
	if (document.apply2.SenderEmail.value == '')
	{
		alert('Please enter your email address!');
		document.apply2.SenderEmail.focus();
		return false;
	} else {
		
			if (!_CF_checkregex(document.apply2.SenderEmail.value, 
/^[A-Za-z0-9]+([._-]?[A-Za-z0-9]+)*@[A-Za-z0-9]+([.-]?[A-Za-z0-9]+)*.(([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/, true))
            {
                alert('E-mail address is improperly formatted!');
				document.apply2.SenderEmail.focus();
				return false;				
            }
	}
	
	//Check date of arrival
	if ((document.apply2.DateOfArrival_Day.value == '') || (document.apply2.DateOfArrival_Month.value == '') || (document.apply2.DateOfArrival_Year.value == ''))
	{
		alert('The date of arrival is not valid!');
		document.apply2.DateOfArrival_Day.focus();
		return false;
	}
	//---------------
	
	return true;
}


function check_form_apply3()
{
	//Person 01
	if (document.apply3.Name1.value == '')
	{
		alert('Please enter your name!');
		document.apply3.Name1.focus();
		return false;
	}
	
	if ((document.apply3.DOB1_Day.value == '') || (document.apply3.DOB1_Month.value == '') || (document.apply3.DOB1_Year.value == ''))
	{
		alert('The date of birth is not valid!');
		document.apply3.DOB1_Day.focus();
		return false;
	}
		

	if (document.apply3.Nationality1.value == '')
	{
		alert('Please enter your nationality!');
		document.apply3.Nationality1.focus();
		return false;
	}
	
	if (document.apply3.PassportNumber.value == '')
	{
		alert('Please enter your passport number!');
		document.apply3.PassportNumber.focus();
		return false;
	}
	
	//Person 02
	if (document.apply3.Name2.value == '')
	{
		alert('Please enter your name!');
		document.apply3.Name2.focus();
		return false;
	}
	
	if ((document.apply3.DOB2_Day.value == '') || (document.apply3.DOB2_Month.value == '') || (document.apply3.DOB2_Year.value == ''))
	{
		alert('The date of birth is not valid!');
		document.apply3.DOB2_Day.focus();
		return false;
	}
	

	if (document.apply3.Nationality2.value == '')
	{
		alert('Please enter your nationality!');
		document.apply3.Nationality2.focus();
		return false;
	}
	
	if (document.apply3.PassportNumber2.value == '')
	{
		alert('Please enter your passport number!');
		document.apply3.PassportNumber2.focus();
		return false;
	}

//Person 03
	if (document.apply3.Name3.value == '')
	{
		alert('Please enter your name!');
		document.apply3.Name3.focus();
		return false;
	}
	
	if ((document.apply3.DOB3_Day.value == '') || (document.apply3.DOB3_Month.value == '') || (document.apply3.DOB3_Year.value == ''))
	{
		alert('The date of birth is not valid!');
		document.apply3.DOB3_Day.focus();
		return false;
	}
	

	if (document.apply3.Nationality3.value == '')
	{
		alert('Please enter your nationality!');
		document.apply3.Nationality3.focus();
		return false;
	}
	
	if (document.apply3.PassportNumber3.value == '')
	{
		alert('Please enter your passport number!');
		document.apply3.PassportNumber3.focus();
		return false;
	}
		
	//Information
	
	//Check sender email
	if (document.apply3.SenderEmail.value == '')
	{
		alert('Please enter your email address!');
		document.apply3.SenderEmail.focus();
		return false;
	} else {
		
			if (!_CF_checkregex(document.apply3.SenderEmail.value, 
/^[A-Za-z0-9]+([._-]?[A-Za-z0-9]+)*@[A-Za-z0-9]+([.-]?[A-Za-z0-9]+)*.(([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/, true))
            {
                alert('E-mail address is improperly formatted!');
				document.apply3.SenderEmail.focus();
				return false;				
            }
	}
	
	//Check date of arrival
	if ((document.apply3.DateOfArrival_Day.value == '') || (document.apply3.DateOfArrival_Month.value == '') || (document.apply3.DateOfArrival_Year.value == ''))
	{
		alert('The date of arrival is not valid!');
		document.apply3.DateOfArrival_Day.focus();
		return false;
	}
	//---------------
	
	return true;
}


function check_form_apply4()
{
	//Person 01
	if (document.apply4.Name1.value == '')
	{
		alert('Please enter your name!');
		document.apply4.Name1.focus();
		return false;
	}

	if ((document.apply4.DOB1_Day.value == '') || (document.apply4.DOB1_Month.value == '') || (document.apply4.DOB1_Year.value == ''))
	{
		alert('The date of birth is not valid!');
		document.apply4.DOB1_Day.focus();
		return false;
	}
	

	if (document.apply4.Nationality1.value == '')
	{
		alert('Please enter your nationality!');
		document.apply4.Nationality1.focus();
		return false;
	}
	
	if (document.apply4.PassportNumber.value == '')
	{
		alert('Please enter your passport number!');
		document.apply4.PassportNumber.focus();
		return false;
	}
	
	//Person 02
	if (document.apply4.Name2.value == '')
	{
		alert('Please enter your name!');
		document.apply4.Name2.focus();
		return false;
	}
	
	if ((document.apply4.DOB2_Day.value == '') || (document.apply4.DOB2_Month.value == '') || (document.apply4.DOB2_Year.value == ''))
	{
		alert('The date of birth is not valid!');
		document.apply4.DOB2_Day.focus();
		return false;
	}
	

	if (document.apply4.Nationality2.value == '')
	{
		alert('Please enter your nationality!');
		document.apply4.Nationality2.focus();
		return false;
	}
	
	if (document.apply4.PassportNumber2.value == '')
	{
		alert('Please enter your passport number!');
		document.apply4.PassportNumber2.focus();
		return false;
	}

//Person 03
	if (document.apply4.Name3.value == '')
	{
		alert('Please enter your name!');
		document.apply4.Name3.focus();
		return false;
	}
	
	if ((document.apply4.DOB3_Day.value == '') || (document.apply4.DOB3_Month.value == '') || (document.apply4.DOB3_Year.value == ''))
	{
		alert('The date of birth is not valid!');
		document.apply4.DOB3_Day.focus();
		return false;
	}
	

	if (document.apply4.Nationality3.value == '')
	{
		alert('Please enter your nationality!');
		document.apply4.Nationality3.focus();
		return false;
	}
	
	if (document.apply4.PassportNumber3.value == '')
	{
		alert('Please enter your passport number!');
		document.apply4.PassportNumber3.focus();
		return false;
	}
		
		
//Person 04
	if (document.apply4.Name4.value == '')
	{
		alert('Please enter your name!');
		document.apply4.Name4.focus();
		return false;
	}
	
	if ((document.apply4.DOB4_Day.value == '') || (document.apply4.DOB4_Month.value == '') || (document.apply4.DOB4_Year.value == ''))
	{
		alert('The date of birth is not valid!');
		document.apply4.DOB4_Day.focus();
		return false;
	}
		

	if (document.apply4.Nationality4.value == '')
	{
		alert('Please enter your nationality!');
		document.apply4.Nationality4.focus();
		return false;
	}
	
	if (document.apply4.PassportNumber4.value == '')
	{
		alert('Please enter your passport number!');
		document.apply4.PassportNumber4.focus();
		return false;
	}
		
		
	//Information
	
	//Check sender email
	if (document.apply4.SenderEmail.value == '')
	{
		alert('Please enter your email address!');
		document.apply4.SenderEmail.focus();
		return false;
	} else {
		
			if (!_CF_checkregex(document.apply4.SenderEmail.value, 
/^[A-Za-z0-9]+([._-]?[A-Za-z0-9]+)*@[A-Za-z0-9]+([.-]?[A-Za-z0-9]+)*.(([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/, true))
            {
                alert('E-mail address is improperly formatted!');
				document.apply4.SenderEmail.focus();
				return false;				
            }
	}
	
	//Check date of arrival
	if ((document.apply4.DateOfArrival_Day.value == '') || (document.apply4.DateOfArrival_Month.value == '') || (document.apply4.DateOfArrival_Year.value == ''))
	{
		alert('The date of arrival is not valid!');
		document.apply4.DateOfArrival_Day.focus();
		return false;
	}
	//---------------
	

	return true;
}


function check_form_apply5()
{
	//Person 01
	if (document.apply5.Name1.value == '')
	{
		alert('Please enter your name!');
		document.apply5.Name1.focus();
		return false;
	}

	if ((document.apply5.DOB1_Day.value == '') || (document.apply5.DOB1_Month.value == '') || (document.apply5.DOB1_Year.value == ''))
	{
		alert('The date of birth is not valid!');
		document.apply5.DOB1_Day.focus();
		return false;
	}
	

	if (document.apply5.Nationality1.value == '')
	{
		alert('Please enter your nationality!');
		document.apply5.Nationality1.focus();
		return false;
	}
	
	if (document.apply5.PassportNumber.value == '')
	{
		alert('Please enter your passport number!');
		document.apply5.PassportNumber.focus();
		return false;
	}
	
	//Person 02
	if (document.apply5.Name2.value == '')
	{
		alert('Please enter your name!');
		document.apply5.Name2.focus();
		return false;
	}
	
	if ((document.apply5.DOB2_Day.value == '') || (document.apply5.DOB2_Month.value == '') || (document.apply5.DOB2_Year.value == ''))
	{
		alert('The date of birth is not valid!');
		document.apply5.DOB2_Day.focus();
		return false;
	}
		
	if (document.apply5.Nationality2.value == '')
	{
		alert('Please enter your nationality!');
		document.apply5.Nationality2.focus();
		return false;
	}
	
	if (document.apply5.PassportNumber2.value == '')
	{
		alert('Please enter your passport number!');
		document.apply5.PassportNumber2.focus();
		return false;
	}

//Person 03
	if (document.apply5.Name3.value == '')
	{
		alert('Please enter your name!');
		document.apply5.Name3.focus();
		return false;
	}
	
	if ((document.apply5.DOB3_Day.value == '') || (document.apply5.DOB3_Month.value == '') || (document.apply5.DOB3_Year.value == ''))
	{
		alert('The date of birth is not valid!');
		document.apply5.DOB3_Day.focus();
		return false;
	}
		
	if (document.apply5.Nationality3.value == '')
	{
		alert('Please enter your nationality!');
		document.apply5.Nationality3.focus();
		return false;
	}
	
	if (document.apply5.PassportNumber3.value == '')
	{
		alert('Please enter your passport number!');
		document.apply5.PassportNumber3.focus();
		return false;
	}
		
		
//Person 04
	if (document.apply5.Name4.value == '')
	{
		alert('Please enter your name!');
		document.apply5.Name4.focus();
		return false;
	}
	
	if ((document.apply5.DOB4_Day.value == '') || (document.apply5.DOB4_Month.value == '') || (document.apply5.DOB4_Year.value == ''))
	{
		alert('The date of birth is not valid!');
		document.apply5.DOB4_Day.focus();
		return false;
	}
		
	if (document.apply5.Nationality4.value == '')
	{
		alert('Please enter your nationality!');
		document.apply5.Nationality4.focus();
		return false;
	}
	
	if (document.apply5.PassportNumber4.value == '')
	{
		alert('Please enter your passport number!');
		document.apply5.PassportNumber4.focus();
		return false;
	}

//Person 05
	if (document.apply5.Name5.value == '')
	{
		alert('Please enter your name!');
		document.apply5.Name5.focus();
		return false;
	}
	
	if ((document.apply5.DOB5_Day.value == '') || (document.apply5.DOB5_Month.value == '') || (document.apply5.DOB5_Year.value == ''))
	{
		alert('The date of birth is not valid!');
		document.apply5.DOB5_Day.focus();
		return false;
	}
	
	if (document.apply5.Nationality5.value == '')
	{
		alert('Please enter your nationality!');
		document.apply5.Nationality5.focus();
		return false;
	}
	
	if (document.apply5.PassportNumber5.value == '')
	{
		alert('Please enter your passport number!');
		document.apply5.PassportNumber5.focus();
		return false;
	}
		
		
	//Information
	
	//Check sender email
	if (document.apply5.SenderEmail.value == '')
	{
		alert('Please enter your email address!');
		document.apply5.SenderEmail.focus();
		return false;
	} else {
		
			if (!_CF_checkregex(document.apply5.SenderEmail.value, 
/^[A-Za-z0-9]+([._-]?[A-Za-z0-9]+)*@[A-Za-z0-9]+([.-]?[A-Za-z0-9]+)*.(([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/, true))
            {
                alert('E-mail address is improperly formatted!');
				document.apply5.SenderEmail.focus();
				return false;				
            }
	}
	
	//Check date of arrival
	if ((document.apply5.DateOfArrival_Day.value == '') || (document.apply5.DateOfArrival_Month.value == '') || (document.apply5.DateOfArrival_Year.value == ''))
	{
		alert('The date of arrival is not valid!');
		document.apply5.DateOfArrival_Day.focus();
		return false;
	}
	//---------------
	

	return true;
}
