function moveFocus()
{
	var obj = event.srcElement ;//document.getElementById(objName) ;
	
	if( event.keyCode == 9 || event.keyCode == 16) return true;
	
	if(obj)
	{
		var objName = obj.name ;
		if( obj.value.length == obj.maxLength )
		{
			 toUpperValue(obj)
			 if( objName=="part1" && document.getElementById("part2") && (document.getElementById("part2").value == "" || document.getElementById("part2").value.length != document.getElementById("part2").maxLength) )
			 {
			 	document.getElementById("part2").focus();
			 }	
			 else if( objName=="part1" && document.getElementById("part3") && document.getElementById("part3").value == "" )
			 {
			 	document.getElementById("part3").focus();
			 }			 
			 else if( objName=="part2" && document.getElementById("part1") && document.getElementById("part1").value == "" )
			 {
			 	document.getElementById("part1").focus();
			 }
			 else if( objName=="part2" && document.getElementById("part3") && document.getElementById("part3").value == "" )
			 {
			 	document.getElementById("part3").focus();
			 }	
			 else if( objName=="part3" && document.getElementById("part2") && document.getElementById("part2").value == "" )
			 {
			 	document.getElementById("part2").focus();
			 }	
			 else if( objName=="part3" && document.getElementById("part1") && document.getElementById("part1").value == "" )
			 {
			 	document.getElementById("part1").focus();
			 }			 			 		 
		}
	}	
}
function showHideDate(selectedIdVal)
{
	if( selectedIdVal == "qidNo" )
	{
		hideDate() ;
		showQidNo();		
	}
	else 
	{
		showDate() ;
		hideQidNo() ;
	}
}
function showDate()
{
		if(document.getElementById("_imgCalender"))   	
		{
			document.getElementById("_imgCalender").readOnly = false ;
			document.getElementById("_imgCalender").disabled = false ;
			
		}
 		if(document.getElementById("year"))   	
		{
			document.getElementById("year").readOnly = false ;
			document.getElementById("year").disabled = false ;
			document.getElementById("year").className = "TxtClass" ;
			
		}
 		if(document.getElementById("month"))   	
		{
			document.getElementById("month").readOnly = false ;
			document.getElementById("month").disabled = false ;
			document.getElementById("month").className = "TxtClass" ;
			
		}
 		if(document.getElementById("day"))   	
		{
			document.getElementById("day").readOnly = false ;
			document.getElementById("day").disabled = false ;
			document.getElementById("day").className = "TxtClass" ;
			document.getElementById("day").focus();
		}		
}
function hideDate()
{
 		if(document.getElementById("_imgCalender"))   	
		{
			document.getElementById("_imgCalender").readOnly = true ;
			document.getElementById("_imgCalender").disabled = true ;
			
		}
 		if(document.getElementById("applicationDate"))   	
		{
			//document.getElementById("applicationDate").readOnly = true ;
			//document.getElementById("applicationDate").disabled = true ;
			//document.getElementById("applicationDate").className = "TxtDisabledClass" ;
		}	
 		if(document.getElementById("year"))   	
		{
			document.getElementById("year").readOnly = true ;
			document.getElementById("year").disabled = true ;
			document.getElementById("year").className = "TxtDisabledClass" ;
			//document.getElementById("year").value ="" ;
			
		}
 		if(document.getElementById("month"))   	
		{
			document.getElementById("month").readOnly = true ;
			document.getElementById("month").disabled = true ;
			document.getElementById("month").className = "TxtDisabledClass" ;
			//document.getElementById("month").value = "" ;
		}
 		if(document.getElementById("day"))   	
		{
			document.getElementById("day").readOnly = true ;
			document.getElementById("day").disabled = true ;
			document.getElementById("day").className = "TxtDisabledClass" ;
			//document.getElementById("day").value = "" ;
			
		}
}
function showQidNo()
{
	if( document.getElementById("qidNo") )
	{
		document.getElementById("qidNo").readOnly = false ;
		document.getElementById("qidNo").disabled = false ;
		document.getElementById("qidNo").className = "TxtClass" ;
		document.getElementById("qidNo").focus();
		
	}		
}
function hideQidNo()
{
	if( document.getElementById("qidNo") )
	{
		document.getElementById("qidNo").readOnly = true ;
		document.getElementById("qidNo").disabled = true ;
		document.getElementById("qidNo").className = "TxtDisabledClass" ;
		
	}		
}
function showHideItems()
{
   
  //_HpbHideObj('dateRow');
    var selected = event.srcElement.value;//document.VisaApproval.kind.value;
    if( selected == "visit" )
    {
		hideDate() ;	
		hideQidNo() ;
		if( document.getElementById("radioByDate") )
		{
			document.getElementById("radioByDate").disabled = true ;
			document.getElementById("radioByDate").checked = false ;
		}	
		if( document.getElementById("radioByQid") )
		{
			document.getElementById("radioByQid").disabled = true ;
			document.getElementById("radioByQid").checked = false ;
		}			
    }
    else if(selected=="residency")
    {
 		showDate() ;	
		if( document.getElementById("radioByDate") )
		{
			document.getElementById("radioByDate").disabled = false ;
			document.getElementById("radioByDate").checked = true ;
		}	
		if( document.getElementById("radioByQid") )
		{
			document.getElementById("radioByQid").disabled = false ;
		} 		
    }
}
function checkvalues()
{
	
		var dateValue = document.VisaApproval.applicationDate;
		var strMessage = "" ;
		if (document.VisaApproval.part1.value=="" || document.VisaApproval.part1.value.length != 2) 
		{
			strMessage = LanguageType.toUpperCase() == "ENG" ? "Please,Enter the first part correctly" : "الرجاء ادخال الجزء الأول بشكل صحيح" ;
			alert(strMessage) ;
			document.VisaApproval.part1.focus();
			return false;
		}
		else if (document.VisaApproval.part2.value=="" || document.VisaApproval.part2.value.length != 4) 
		{
			strMessage = LanguageType.toUpperCase() == "ENG" ? "Please,Enter the second part correctly" : "الرجاء ادخال الجزء الثاني بشكل صحيح" ;
			alert(strMessage) ;
			document.VisaApproval.part2.focus();
			return false;
		}
		else if (document.VisaApproval.part3.value=="" || document.VisaApproval.part3.value.length != 6) 
		{
			strMessage = LanguageType.toUpperCase() == "ENG" ? "Please,Enter the second part correctly" : "الرجاء ادخال الجزء الثالث بشكل صحيح" ;
			alert(strMessage) ;
			document.VisaApproval.part3.focus();
			return false;
		}
		else if (document.VisaApproval.kindPerm.checked )
		{
			if( document.VisaApproval.radioByQid && document.VisaApproval.radioByDate.checked )
			{
				if( document.VisaApproval.year && document.VisaApproval.month && document.VisaApproval.day)
				{
					var dayStr 		= document.VisaApproval.day.value ;
					var monthStr 	= document.VisaApproval.month.value ;
					
					if( dayStr.length == 1 )
						dayStr = "0" + dayStr ;
					if( monthStr.length == 1 )
						monthStr = "0" + monthStr ;
					
					document.VisaApproval.month.value = monthStr ;
					document.VisaApproval.day.value = dayStr ;
					
					dateValue.value = document.VisaApproval.year.value + "/" + document.VisaApproval.month.value + "/" + document.VisaApproval.day.value ;
				}
	
				if( dateValue.value.length != 10 )
				{
					strMessage = LanguageType.toUpperCase() == "ENG" ? "Please,Enter Valid Date" : "الرجاء ادخال التاريخ بشكل صحيح" ;
					alert(strMessage) ;
					if( !document.VisaApproval.year )
						dateValue.focus();
					else
						document.VisaApproval.year.focus();
					
					dateValue.value = "" ;		
					return false;
				}
				else if( !isDate(dateValue.value) )
				{
					if( !document.VisaApproval.year )
						dateValue.focus();
					else
						document.VisaApproval.year.focus();
					
					dateValue.value = "" ;	
					return false ;
				}
			}
			else 
			{
				dateValue.value = "" ;
				var qidNoVal = Trim(document.VisaApproval.qidNo.value) ;
				if( qidNoVal == "" )
				{
					strMessage = LanguageType.toUpperCase() == "ENG" ? "Please,Enter Qatari Id Number" : "الرجاء ادخال الرقم الشخصي بشكل صحيح" ;
					alert(strMessage) ;
					document.VisaApproval.qidNo.focus();
					return false;		
				}
				else if( qidNoVal.length != 11 )
				{
					strMessage = LanguageType.toUpperCase() == "ENG" ? "The Number of qidNo character is 11 digit" : "الرجاء ادخال الرقم الشخصي بشكل صحيح" ;
					alert(strMessage) ;
					document.VisaApproval.qidNo.focus();
					return false;			
				}				
			}	
		}
		
		
		toUpperValue(document.VisaApproval.part1);
		toUpperValue(document.VisaApproval.part2);
		toUpperValue(document.VisaApproval.part3);
		
		if( document.VisaApproval.kindVisit.checked )
			dateValue.value = "" ;
		if( typeof showToolTipL == "function" )
			showToolTipL(document.VisaApproval.Button1);		
		return true;
}
function onChangeDate()
{
	//dateSelected,monthSelected,yearSelected
	monthSelected++;
	if( monthSelected <= 9 )
		monthSelected = "0" + monthSelected ;

	if( dateSelected <= 9 )
		dateSelected = "0" + dateSelected ;
		
	if( document.getElementById("year") )
		document.getElementById("year").value = yearSelected ;
	if( document.getElementById("month") )
		document.getElementById("month").value = monthSelected ;
	if( document.getElementById("day") )
		document.getElementById("day").value = dateSelected ;
	
}
function viewVisaResults(applicationNumber,selectedValue)
{
	var urlForward = "/VisaApplications/Actions?action=getPaginationResult&applicationNumber=" + applicationNumber + "&language=" +( LanguageType.toUpperCase() == "ENG" ? "English" : "" ) ;
	var strMessage = "" ;
	if( selectedValue == "underProcess" )
	{
		urlForward +="&showPrinted=false" ;
		strMessage = LanguageType.toUpperCase() == "ENG" ? "Visa Under Process" : "التأشيرات التي تحت الإجراء" ;
		if( document.getElementById("showPrinted") )
			document.getElementById("showPrinted").value = "false" ;
	}	
	else
	{
		urlForward +="&showPrinted=true" ;
		strMessage = LanguageType.toUpperCase() == "ENG" ? "Visa Ready For Print" : "طباعة التأشيرات" ;
		if( document.getElementById("showPrinted") )
			document.getElementById("showPrinted").value = "true" ;
	}
	
	if( document.getElementById("tdLabel") )	
	{
		document.getElementById("tdLabel").innerText = strMessage ;
	}
					
	
	if( document.getElementById("iFrameResults") )
	{
		document.getElementById("iFrameResults").src = urlForward;
	}
	
}
function checkVisaEnquiry()
{
	if( document.all.VisaEnquiryForm )
	{
		if( document.all.VisaEnquiryForm.visaNo && Trim(document.all.VisaEnquiryForm.visaNo.value) == "" || (document.all.VisaEnquiryForm.visaNo.value).length < 12 )
		{
			strMessage = LanguageType.toUpperCase() == "ENG" ? "The Number of Visa character is 12 digit" : "الرجاء إدخال رقم تأشيرة مكون من 12 رقم" ;
			alert(strMessage) ;			
			document.all.VisaEnquiryForm.visaNo.focus();
			return false;
		}
		else if(isNaN(Trim(document.all.VisaEnquiryForm.visaNo.value)))
		{
		 	strMessage = LanguageType.toUpperCase() == "ENG" ? "Only Numbers are allowed" : "الرجاء ادخال ارقام فقط" ;
		 	alert(strMessage) ;
		    document.all.VisaEnquiryForm.visaNo.focus();
			return false;
		}
		else if( document.all.VisaEnquiryForm.nationCode && document.all.VisaEnquiryForm.nationCode.value == '000' )
		{
		 	strMessage = LanguageType.toUpperCase() == "ENG" ? "Only Numbers are allowed" : "الرجاء اختيار الجنسية " ;
		 	alert(strMessage) ;
			document.all.VisaEnquiryForm.nationCode.focus();
			return false;
		}
		if(document.all.VisaEnquiryForm.nationCode)
			document.all.VisaEnquiryForm.nationCode.style.display = "none" ;
		if(document.VisaEnquiryForm.Button1)
			document.VisaEnquiryForm.Button1.disabled = true ;
		if(typeof showToolTipL == "function" && document.VisaEnquiryForm.Button1)
 			showToolTipL(document.VisaEnquiryForm.Button1);
	}
	
	return true;		
}