//visit visa form

// set the default values
function setDefaults()
{
	myForm.fName.value = 'First';
	myForm.mName.value = 'Middle';
	myForm.lName.value = 'Last';
	myForm.fName.style.color = '#666';
	myForm.mName.style.color = '#666';
	myForm.lName.style.color = '#666';
	myForm.passType[0].checked = true;
	myForm.expressService.focus();
}

function lasAlert() 
{
	alert("Please use this form if you are a Dubai Studio City business partner approved by Location Approval Services.");
}

function multipleEntryAlert() 
{
	if (myForm.visaType[2].checked == true) { alert("Multiple entry visit visa is valid for 6 months and the applicant must exit the country within 14 days after arrival. Also, applicant must enter the country on a single entry visit visa and apply for multiple entry visit visa within 5 days from arrival."); }
}

function expressSelected()
{
	if(myForm.expressService.checked == true)  { myForm.urgent.disabled = true; myForm.urgent.checked = false;}
	if(myForm.expressService.checked == false) { myForm.urgent.disabled = false; }
}

//calculate fee
function calFee()
{
	var fee = 0;
	
	// duration
	if(myForm.visaType[0].checked == true) { fee = 900; }
	if(myForm.visaType[1].checked == true) { fee = 2000; }
	if(myForm.visaType[2].checked == true) { fee = 3500; }
	
	//express service fees
	if(myForm.urgent.checked == true || myForm.urgent.disabled == true) { fee = fee + 250; }
	if(myForm.expressService.checked == true) { fee = fee + 300; }

	// display the fee and update the fee hidden field
	fee = addCommas(fee);
	paymentAmount.innerHTML = fee;
	myForm.feeAmount.value = fee;
}

function showDeposit()
{
	var countries = new Array();
	countries[0] = "Iraq";
	countries[1] = "Morocco";
	countries[2] = "Algeria";
	countries[3] = "Libyan Arab Jamahiriya";
	countries[4] = "Tunisia";
	
	var showDeposit = false;
	
	for(i=0;i<countries.length;i++)
	{
		if(myForm.cNationality.value == countries[i]){showDeposit = true;}
	}
	
	if (showDeposit) { depositSec.style.display = "block"; alert ("Deposit of 2,050 AED is required.")}
	if (!showDeposit) { depositSec.style.display = "none"; }
}

// calculate the age (years)
function calAge()
{
	if(checkDate(myForm.DOB)== true)
	{
		var DOB = fixDateFormat (myForm.DOB.value);
		var birthday= new Date(DOB);
		var today = new Date();
		$ageArray = DateDiff(today,birthday);
		age = $ageArray[1];
		
		if (age<25 && (myForm.title[1].checked == true || myForm.title[2].checked == true)) { alert("Since the applicant is less than 25 years old, the visa request is subjected to Immigration's approval."); }
		if (age<18) { alert("The applicant cannot be less than 18 years old."); }
		if (age>=70) { alert("Since the applicant is more than 70 years old, the visa request is subjected to Immigration's approval."); }
	}
}

function showUndertaking()
{
	var nationalities = new Array();
	nationalities[0] = "Iran, Islamic Republic of";
	nationalities[1] = "Iraq";
	nationalities[2] = "Yemen";
	// nationalities[3] = "Nigeria";
	nationalities[3] = "Somalia";
	
	var showUndertaking = false;
	
	for(i=0;i<nationalities.length;i++) { if(myForm.cNationality.value == nationalities[i]){showUndertaking = true;} }
	if (showUndertaking){extraAttachment.style.display = "block";alert ("Undertaking letter is required.")}
	if (!showUndertaking){extraAttachment.style.display = "none";}
}

function setRequirements () {
	if(myForm.visaType[2].checked == true) { multipleEntryRequirements.style.display = 'block';
	} else { multipleEntryRequirements.style.display = 'none';}
}

function setJobTitle () {
	if (myForm.cNationality.value == 'Yemen')
	{
		myForm.jobTitle.disabled = false;
		jobSearch.style.display = 'inline';
	} else {
		myForm.jobTitle.selectedIndex  = 381;
		myForm.jobTitle.disabled = true;
		jobSearch.style.display = 'none';
	}
}

function callAllFunctions() {
	expressSelected();
	setRequirements();
	setJobTitle();
	calFee();
}