//هاوشانی‌ خوێندنت كار ده‌كه‌یت ؟
function isStdJob(elem,elemO,elemT, helperMsg){
	if((elem.value == 2) && ((elemO.value.length == 0) || (elemT.value.length == 0))){
		
		elem.focus();
		elemO.focus();
		elemT.focus();
		alert(helperMsg);
		return false;
	}
	else{
		return true;
	}
}
function isKurdishTextWS(elem, helperMsg){
	var alphaExp = /^[ط,ئ,‌و,ۆ,ر,لا,ی‌,ه,و,ز,ڤ,ش,س,ێ,ی,ب,ل,ا,ت,ن,م,ك,گ,چ,ص,پ,ق,ف,غ,ع,ه,خ,ح,ج,د,ژ,ڵا,ڵ,ي,ک,ڕ,ص,ث,ض,ذ,ة,ظ,ؤ,ء]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

//arabic functions
function isArabicTextWS(elem, helperMsg){
	var alphaExp = /^[ئ, ء, ؤ, ر, لا, ى, ة, و, ز, ظ ,ط, ك, م, ن, ت, ا, ل, ب, ي, س, ش, ض, ص, ث, ق, ف,  غ, ع, ه, خ, ح, ج, د, ذ ]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}
//Note:WS=with out space
function isArabicText(elem, helperMsg){
	var alphaExp = /^[   ئ, ء, ؤ, ر, لا, ى, ة, و, ز, ظ ,ط, ك, م, ن, ت, ا, ل, ب, ي, س, ش, ض, ص, ث, ق, ف,  غ, ع, ه, خ, ح, ج, د, ذ,  ]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}



//for bary komalayati nawoe e syane e hawsar
function baryKomalayati(elem,elemO,elemT,elemTH, helperMsg){
	if((elem.value == 2) && ((elemO.value.length == 0) || (elemT.value.length == 0) || (elemTH.value.length == 0))){
		alert(helperMsg);
		elem.focus();
		elemO.focus();
		elemT.focus();
		elemTH.focus();
		return false;
	}
	else{
		return true;
	}
}

//for ئه‌گه‌ر وه‌لاَمه‌كه‌ت به‌ڵێیه‌ له‌خواره‌وه‌ ناوی‌ سیانی‌‌و جۆری‌ خزمایه‌تیه‌كه‌ت دیاریبكه
function xzmayatiFullname(elem,elemO,elemT,elemTH,elemF,helperMsg){
	if((elem.value == 2) && ((elemO.value.length == 0) || (elemT.value.length == 0) || (elemTH.value.length == 0) || (elemF.value.length == 0) ) ){
		alert(helperMsg);
		elem.focus();
		elemO.focus();
		elemT.focus();
		elemTH.focus();
		elemF.focus();
		return false;
	}
	else{
		return true;
	}
}

//for full name
function checkFullName(elemO,elemT,elemTH, helperMsg){
	if((elemO.value.length == 0) || (elemT.value.length == 0) || (elemTH.value.length == 0)){
		alert(helperMsg);
		elemO.focus();
		elemT.focus();
		elemTH.focus();
		return false;
	}
	else{
		return true;
	}
}

//for combo and input box
function SelectionWithInput(elem,elemt, helperMsg){
	if((elem.value == 2) && (elemt.value.length == 0)){
		alert(helperMsg);
		elem.focus();
		elemt.focus();
		return false;
	}
	else{
		return true;
	}
}

function notEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}

function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphabet(elem, helperMsg){
	var alphaExp = /^[a-z A-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphanumeric(elem, helperMsg){
	var alphaExp = /^[0-9 a-z A-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function lengthRestriction(elem, min, max,helperMsg){
	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function madeSelection(elem, helperMsg){
	if(elem.value == 0){
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
}

function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	if(elem.value.match(emailExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function machPassword(elem1,elem2, helperMsg){
	if(elem1.value == elem2.value ){
		return true;
	}else{
		alert(helperMsg);
		elem1.focus();
		return false;
	}
}

function checkdate(input,helperMsg){
	var validformat=/^\d{4}\/\d{1,2}\/\d{1,2}$/ //Basic check for format validity
	var returnval=false
	if (!validformat.test(input.value))
		alert(helperMsg);
		else{ //Detailed check for valid date ranges
		var monthfield=input.value.split("/")[1]
		var dayfield=input.value.split("/")[2]
		var yearfield=input.value.split("/")[0]
		var dayobj = new Date(yearfield, monthfield-1,dayfield)
		if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
		alert(helperMsg);
	else
		returnval=true
	}
	if (returnval==false) 
	input.select()
	return returnval
}
function isHiwaIDformat(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}
//this function for email creating with out space
function checkUserName(elem1, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem1.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem1.focus();
		return false;
	}
}
function isKurdishText(elem, helperMsg){
	var alphaExp = /^[ ئ, ‌و, ۆ, ر, لا, ی‌, ه,‌ و, ز, ڤ, ش, س, ێ, ی, ب, ل, ا, ت, ن, م, ك, گ, چ, ص, پ, ق, ف, غ, ع, ه, خ, ح, ج, د, ژ, ڵا,ڵ,ي,ک,ڕ,ص,ث,ض,ذ,ة,ظ,ؤ,ء,ط,  ]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}
//for submitting the application form confirm message
function submit_supp_app_form() {
	a = window.confirm(" ئایا‌ تۆ دڵنیات له‌ ڕاستی و دروستی ئه‌و زانیاریانه‌ی كه‌ پڕتكردونه‌ته‌وه؟");
	if (a) { 
		return true;
	}
	else {
		return false;
	}	
}