﻿
function isArabicText(checkStr){
     var checkOK = "ذضصثقف()غعهخحجدطكمنتالبيسشئءؤرلاىةوزظ ~ْآلآًٌٍَُِلإإأّ";
     var allValid = true;
     var validGroups = true;
     for (i = 0;  i < checkStr.length;  i++){
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkOK.length;  j++)
          if (ch == checkOK.charAt(j))
            break;

        if (j == checkOK.length)
        {
          allValid = false;
          break;
        }
      }
      return allValid;
}
function isArabicTextWithN(checkStr){
     var checkOK = "ذضصثقفغعهخحجدطكم()نتالبيسشئءؤرلاىةوزظ ~ْآلآًٌٍَُِلإإأّ 1234567890";
     var allValid = true;
     var validGroups = true;
     for (i = 0;  i < checkStr.length;  i++){
        ch = checkStr.charAt(i);
        for (j = 0;  j < checkOK.length;  j++)
          if (ch == checkOK.charAt(j))
            break;

        if (j == checkOK.length)
        {
          allValid = false;
          break;
        }
      }
      return allValid;
}

function isEmpty(checkStr){
    if ( checkStr.length > 0 ){
        var counter = 0;
        for(i = 0; i < checkStr.length; i++ )
            if ( checkStr.charAt(i) != ' ' ){ counter++; if ( counter >= 3 ) return (false);}
        return (true);
        //if ( isWordsLengthShort(checkStr) ) return (true);
        return (false);
    }
    return (true);
}

function isEmptyA(checkStr){
    if ( checkStr.length > 0 ){
        var spaceCounter = 0;
        for(i = 0; i < checkStr.length; i++ )
            if ( checkStr.charAt(i) != ' ' )
                return (false);
        return (true);
    }
    return (true);
}

function wordCounter(checkStr){
    var counter = 0;
    for(i = 0; i<checkStr.length; i++)
        if ( checkStr.charAt(i) != ' ' ){
            while( (checkStr.charAt(i) != ' ') && (i<checkStr.length) ) i++;
            counter++;
        }
    return counter;
}
function isWordsLengthShort(checkStr){
    var wordLength = 0;
    for(i = 0; i<checkStr.length; i++)
        if ( checkStr.charAt(i) != ' ' ){
            wordLength = 0;
            while( (checkStr.charAt(i) != ' ') && (i<checkStr.length) ){ i++; wordLength++;}
            if ( wordLength < 3) return true;
        }
    return false;
}
function errorMSG_1(str){
    return   "Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø¥Ø¯Ø®Ø§Ù„ "+str+" Ø¨ØµÙˆØ±Ø© ØµØ­ÙŠØ­Ø©";
}
function errorMSG_2(str){
    return   "Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø¥Ø¯Ø®Ø§Ù„ "+str+" Ø¨Ø§Ù„Ù„ØºØ© Ø§Ù„Ø¹Ø±Ø¨ÙŠØ©";
    
}
function resetErrors(theForm){
    theForm.T1_e.value = "";
    theForm.T9_e.value = "";
    theForm.T10_e.value = "";
    theForm.T11_e.value = "";
    theForm.T4_e.value = "";
    theForm.T5_e.value = "";
    theForm.TD_e.value = "";
    theForm.T17_e.value = "";
    theForm.T18_e.value = "";
    theForm.T19_e.value = "";
    theForm.T20_e.value = "";
    theForm.T21_e.value = "";
    theForm.T14_e.value = "";
    theForm.T15_e.value = "";
    theForm.T16_e.value = "";
    //theForm.S1_e.value = "";
}

function checkEmail(the_email){
    var the_at = the_email.indexOf("@");
    var the_dot = the_email.lastIndexOf(".");
    var a_space = the_email.indexOf(" ");
    if ((the_at != -1) && // if there's an '@'
        (the_at != 0) && // and it's not at position 0
        (the_dot != -1) && // and there's a '.'
        (the_dot > the_at + 1) && // and something between the '@' and '.'
        (the_dot < the_email.length - 1) && // and something after the '.'
        (a_space == -1)) // and there are no spaces
    {
        return true;
    }else {
        return false;
    }
}
var eClientY = 0;
var eClientY = 0;
function mouseXY(e){
	eClientY = e.clientY;
	eClientX = e.clientX;
}

function createLayer(mID,parentId,top,left,width,height,bgcolor,zindex){
	var theLayer = document.createElement("div");
	if (theLayer){
		theLayer.id = "layer"+mID;
		theLayer.name = ""+parentId;
		theLayer.style.position = "absolute";
		theLayer.style.top = top;
		theLayer.style.left = left;
		theLayer.style.width = width;
		theLayer.style.height = height;
		theLayer.style.backgroundColor = bgcolor;
		if (zindex) theLayer.style.zIndex = zindex;
		//"openSubmenu("+layerName+",event);";
		//"";
		//theLayer.onmouseout="";
		//	theLayer.innerHTML = "<div onmouseover=\"openSubmenu("+mID+",null,event);\" onmouseout=\"closeSubmenu("+mID+",event);\"><table dir=\"rtl\"border=\"1\"width=\""+width+"\"cellspacing=\"0\" cellpadding=\"0\" height=\""+height+"\"  onmouseover=\"this.style.cursor='pointer';\" onmouseout=\"this.style.cursor='default';\"><tr><td  align=\"center\" width=\"100%\" height=\"100%\"><font color=\"#383838\" size=\"3\"><b><span lang=\"ar-jo\">Ø¬Ø§Ø±ÙŠ ØªØ­Ù…ÙŠÙ„&nbsp;Ø§Ù„Ù‚Ø§Ø¦Ù…Ø© Ø§Ù„ÙØ±Ø¹ÙŠØ©...</span></b></font><img border=\"0\" src=\"../images/loading.gif\" width=\"16\" height=\"16\"></td></tr></table></div>";
		document.body.appendChild(theLayer);
		return theLayer;
	}
	return null;
}
function openErrorMassege(eText,w){
	var theLayer = document.getElementById("layerError");
	var top = eClientY + document.body.scrollTop - 40 ;
	var left =((window.screen.width + document.body.scrollLeft)/2) - (w/2);
	if (theLayer != null) {		
		theLayer.style.top = top+"px";
		theLayer.style.left = left+"px";
		theLayer.style.width = w+"px";	
		theLayer.style.visibility = 'visible';
		theLayer.style.zIndex = "1";								
		theLayer.innerHTML = eText ;
		
		var errorButton = document.getElementById("errorButton");
		if (errorButton) errorButton.focus();
		
		return;
	}			
	createLayer("Error",null,top+"px",left+"px",w+"px","80px","#FFFFFF","1");
	var theLayer = document.getElementById("layerError");
	theLayer.innerHTML = eText;	
	
	var errorButton = document.getElementById("errorButton");
	if (errorButton) errorButton.focus();
}
function closeError(){
	var theLayer = document.getElementById("layerError");
	if (theLayer){
		theLayer.style.visibility = 'hidden';
	}
	if ( toFocus ) toFocus.focus();
	//var theElement = document.getElementsByName(eName);
	//if ( theElement ) if (theElement[0])theElement[0].focus();
}
var toFocus;
function createMassege(mText,w,toFocusN){
toFocus = toFocusN;
	return "<table bordercolor=\"#383838\" border=\"5\" dir=\"rtl\" width=\""+w+"\" cellspacing=\"5\" cellpadding=\"5\" bgcolor=\"#EADFDE\">"+
				"<tr>"+
					"<td>"+
						"<form>"+					
							"<table border=\"0\" width=\""+w+"\" cellspacing=\"0\" cellpadding=\"0\">"+
								"<tr >"+
									"<td align=\"center\" colspan=\"2\"><b><font size=\"5\" color=\"#383838\">"+mText+"</font></b></td>"+
								"</tr>"+
								"<tr>"+
									"<td align=\"center\">"+
											"<input id=\"errorButton\" type=\"button\" onkeydown=\"closeError();\" onclick=\"closeError();\" value=\"موافق\" name=\"quit\" style=\"font-size: 14pt; font-weight: bold\"></td>"+
								"</tr>"+
							"</table>"+
						"</form>"+
					"</td>"+
				"</tr>"+
			"</table>";
}
function checkAllForms(theForm){
	if (theForm.name)     if  (isEmpty(theForm.name.value)) {openErrorMassege(createMassege("الرجاء التأكد من الإسم",200,theForm.name),200); return false;}	
	if (theForm.name && (theForm.id == 'jobForm' || theForm.id == 'userForm') )     if  (! isArabicText(theForm.name.value)) {openErrorMassege(createMassege("الرجاء كتابة الإسم باللغة العربية",200,theForm.name),200); return false;}	
	if (theForm.name && (theForm.id == 'jobForm' || theForm.id == 'userForm') )     if  (wordCounter(theForm.name.value) < 3) {openErrorMassege(createMassege("الرجاء كتابة الإسم ثلاثي",200,theForm.name),200); return false;}	
		if (theForm.logName)  if  (isEmpty(theForm.logName.value)) {openErrorMassege(createMassege("الرجاء التأكد من إسم الدخول",200,theForm.logName),200); return false;}
	if (theForm.password && theForm.id == 'loginForm') if  (theForm.password.value.length < 4) {openErrorMassege(createMassege("الرجاء التأكد من كلمة المرور",200,theForm.password),200); return false;}	
	if (theForm.password && theForm.id != 'loginForm') if  (theForm.password.value.length < 4) {openErrorMassege(createMassege("أقل طول لكلمة المرور أربعة احرف",200,theForm.password),200); return false;}	
	if (theForm.passwordTwo) if  (theForm.password.value != theForm.passwordTwo.value) {openErrorMassege(createMassege("كلمتا المرور غير متطابقتين",200,theForm.passwordTwo),200); return false;}	
	if (theForm.phone) if ( !(isEmpty(theForm.phone.value) && theForm.id == 'userForm') )	if ( isNaN(theForm.phone.value) || !( (theForm.phone.value.length == 10) || (theForm.phone.value.length == 14) )  ){openErrorMassege(createMassege("الرجاء التأكد من الهاتف",200,theForm.phone),200); return false;}	
	if (theForm.email) if ( !isEmpty(theForm.email.value)) if ( ! checkEmail(theForm.email.value) )  {openErrorMassege(createMassege("الرجاء التأكد من البريد الإلكتروني",200,theForm.email),200); return false;}else;else	 theForm.email.value = "";
	if (theForm.month){ var theDate = ""+theForm.month.value+"/"+theForm.day.value+"/"+theForm.year.value;
    				  if ( ! checkDate(theDate) ){openErrorMassege(createMassege("الرجاء التأكد من التاريخ",200,theForm.day),200); return false;}	
    				}
if (theForm.specialization) if  (theForm.specialization.value == "-1") if ( isEmpty(theForm.jsName.value)) {openErrorMassege(createMassege("الرجاء التأكد من التخصص",200,theForm.jsName),200); return false;}
    if (theForm.answerer) if  (isEmpty(theForm.answerer.value)) {openErrorMassege(createMassege("الرجاء التأكد من المجيب",200,theForm.answerer),200); return false;}	
    //if (theForm.body) if  (isEmpty(theForm.body.value)) {openErrorMassege(createMassege("الرجاء التأكد من النص",200,theForm.body),200); return false;}	
    if (theForm.owner) if  (isEmpty(theForm.owner.value)) {openErrorMassege(createMassege("الرجاء التأكد من المالك",200,theForm.owner),200); return false;}	
    if (theForm.asker) if  (isEmpty(theForm.asker.value)) {openErrorMassege(createMassege("الرجاء التأكد من السائل",200,theForm.asker),200); return false;}	 
    if (theForm.writeTime) if  (isEmpty(theForm.writeTime.value)) {openErrorMassege(createMassege("الرجاء التأكد من التاريخ",200,theForm.writeTime),200); return false;}	
    
    
	return true;	
}

function checkDate(the_date){
    var date_array = the_date.split("/");
    if ((date_array.length == 3) &&
        (date_array[0] > 0) && (date_array[0] < 13) &&
        (date_array[1] > 0) && (date_array[1] < 32) &&
        (date_array[2] >= 1880 ) && (date_array[2] < 2200 ))
    {
        return true;
    } else {
        //alert("Please type the date in a mm/dd/yy format.");
        return false;
    }
}

function Validator(theForm){
    return true;

    resetErrors(theForm);

    var itemsCheck = new Array();
    for(i=0; i<14; i++)
	    itemsCheck[i] = true;


	var first_focus = false;
    if (!isArabicText(theForm.T1.value)){
        theForm.T1_e.value = errorMSG_2("Ø§Ù„Ø¥Ø³Ù…");
        if ( ! first_focus ){
            theForm.T1.focus();
            first_focus = true;
        }
        itemsCheck[0] = false;
    }else
	    if ( wordCounter(theForm.T1.value) != 4 ){
	        theForm.T1_e.value = "Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø¥Ø¯Ø®Ø§Ù„ Ø§Ù„Ø¥Ø³Ù… Ø±Ø¨Ø§Ø¹ÙŠØ§ÙŽ";
	        if ( ! first_focus ){
            	theForm.T1.focus();
         	   first_focus = true;
     	   }
	        itemsCheck[0] = false;
	    }else
		    if (isEmpty(theForm.T1.value)) {
		        theForm.T1_e.value = errorMSG_1("Ø§Ù„Ø¥Ø³Ù…");
		        if ( ! first_focus ){
          		  theForm.T1.focus();
        	     first_focus = true;
     		   }
		        itemsCheck[0] = false;
		    }


    if (!isArabicText(theForm.T9.value)){
        theForm.T9_e.value = errorMSG_2("Ø¥Ø³Ù… Ø§Ù„Ø¯Ø®ÙˆÙ„");
        if ( ! first_focus ){
            theForm.T9.focus();
            first_focus = true;
        }
        itemsCheck[1] = false;
    }else
	    if (isEmpty(theForm.T9.value)) {
	        theForm.T9_e.value = errorMSG_1("Ø¥Ø³Ù… Ø§Ù„Ø¯Ø®ÙˆÙ„");
	        if ( ! first_focus ){
	            theForm.T9.focus();
	            first_focus = true;
	        }
	        itemsCheck[1] = false;
	    }

    if (  theForm.T10.value.length <= 5 ){
        theForm.T10_e.value = "Ø£Ù‚Ù„ Ø·ÙˆÙ„ Ù„ÙƒÙ„Ù…Ø© Ø§Ù„Ù…Ø±ÙˆØ± Ø³ØªØ© Ø§Ø­Ø±Ù";
        if ( ! first_focus ){
            theForm.T10.focus();
            first_focus = true;
        }
        itemsCheck[2] = false;
    }else if ( theForm.T10.value != theForm.T11.value ){
            theForm.T11_e.value = "ØºÙŠØ± Ù…ØªØ·Ø§Ø¨Ù‚Ø© Ù…Ø¹ ÙƒÙ„Ù…Ø© Ø§Ù„Ù…Ø±ÙˆØ±";
            if ( ! first_focus ){
                theForm.T11.focus();
                first_focus = true;
            }
            itemsCheck[2] = false;
        }

    if ( isNaN(theForm.T4.value) || isEmpty(theForm.T4.value) || !( (theForm.T4.value.length == 11) || (theForm.T4.value.length == 14) )  ){
        theForm.T4_e.value = errorMSG_1("Ø±Ù‚Ù… Ø§Ù„Ù‡Ø§ØªÙ");
        if ( ! first_focus ){
            theForm.T4.focus();
            first_focus = true;
        }
        itemsCheck[3] = false;
    }

    if ( ! checkEmail(theForm.T5.value) ){
        theForm.T5_e.value = errorMSG_1("Ø§Ù„Ø¨Ø±ÙŠØ¯ Ø§Ù„Ø¥Ù„ÙƒØªØ±ÙˆÙ†ÙŠ");
        if ( ! first_focus ){
            theForm.T5.focus();
            first_focus = true;
        }
        itemsCheck[4] = false;
    }

    var the_Date = ""+theForm.T7.value+"/"+theForm.T6.value+"/"+theForm.T8.value;
    if ( ! checkDate(the_Date) ){
        theForm.TD_e.value = errorMSG_1("ØªØ§Ø±ÙŠØ® Ø§Ù„Ù…ÙŠÙ„Ø§Ø¯");
        if ( ! first_focus ){
            theForm.T6.focus();
            first_focus = true;
        }
        itemsCheck[5] = false;
    }

    if ( isNaN(theForm.T17.value) || isEmpty(theForm.T17.value)  ){
        theForm.T17_e.value = errorMSG_1("Ø±Ù‚Ù… Ø§Ù„Ø¬Ù†Ø³ÙŠØ©");
        if ( ! first_focus ){
            theForm.T17.focus();
            first_focus = true;
        }
        itemsCheck[6] = false;
    }

    if ( isNaN(theForm.T18.value) || isEmpty(theForm.T18.value) ){
        theForm.T18_e.value = errorMSG_1("Ø±Ù‚Ù… Ø¨Ø·Ø§Ù‚Ø© Ø§Ù„Ø®ÙØ¯Ù…Ø©");
        if ( ! first_focus ){
            theForm.T18.focus();
            first_focus = true;
        }
        itemsCheck[7] = false;
    }

    if ( ! isEmptyA(theForm.T19.value) ){
        if ( isEmpty(theForm.T19.value) ){
            theForm.T19_e.value = errorMSG_1("Ø§Ù„Ù…Ø±Ø­Ù„Ø© Ø§Ù„Ø¥Ø¨ØªØ¯Ø§Ø¦ÙŠØ©");
            if ( ! first_focus ){
                theForm.T19.focus();
                first_focus = true;
            }
            itemsCheck[8] = false;
        }else if ( ! isArabicText(theForm.T19.value) ){
                theForm.T19_e.value = errorMSG_2("Ø§Ù„Ù…Ø±Ø­Ù„Ø© Ø§Ù„Ø¥Ø¨ØªØ¯Ø§Ø¦ÙŠØ©");
                if ( ! first_focus ){
                    theForm.T19.focus();
                    first_focus = true;
                }
                itemsCheck[8] = false;
        }
    }

    if ( ! isEmptyA(theForm.T20.value) ){
        if ( isEmpty(theForm.T20.value) ){
            theForm.T20_e.value = errorMSG_1("Ø§Ù„Ù…Ø±Ø­Ù„Ø© Ø§Ù„ÙˆØ³Ø·Ù‰");
            if ( ! first_focus ){
                theForm.T20.focus();
                first_focus = true;
            }
            itemsCheck[9] = false;
        }else if ( ! isArabicText(theForm.T20.value) ){
                theForm.T20_e.value = errorMSG_2("Ø§Ù„Ù…Ø±Ø­Ù„Ø© Ø§Ù„ÙˆØ³Ø·Ù‰");
                if ( ! first_focus ){
                    theForm.T20.focus();
                    first_focus = true;
                }
                itemsCheck[9] = false;
        }else if ( isEmpty(theForm.T19.value) ){
                theForm.T19_e.value = errorMSG_1("Ø§Ù„Ù…Ø±Ø­Ù„Ø© Ø§Ù„Ø¥Ø¨ØªØ¯Ø§Ø¦ÙŠØ©");
                if ( ! first_focus ){
                    theForm.T19.focus();
                    first_focus = true;
                }
        }
    }

    if ( ! isEmptyA(theForm.T21.value) ){
        if ( isEmpty(theForm.T21.value) ){
            theForm.T21_e.value = errorMSG_1("Ø§Ù„Ù…Ø±Ø­Ù„Ø© Ø§Ù„Ø«Ø§Ù†ÙˆÙŠØ©");
            if ( ! first_focus ){
                theForm.T21.focus();
                first_focus = true;
            }
            itemsCheck[10] = false;
        }else if ( ! isArabicText(theForm.T21.value) ){
                theForm.T21_e.value = errorMSG_2("Ø§Ù„Ù…Ø±Ø­Ù„Ø© Ø§Ù„Ø«Ø§Ù†ÙˆÙŠØ©");
                if ( ! first_focus ){
                    theForm.T21.focus();
                    first_focus = true;
                }
                itemsCheck[10] = false;
        }else if ( isEmpty(theForm.T19.value) ){
                theForm.T19_e.value = errorMSG_1("Ø§Ù„Ù…Ø±Ø­Ù„Ø© Ø§Ù„Ø¥Ø¨ØªØ¯Ø§Ø¦ÙŠØ©");
                if ( ! first_focus ){
                    theForm.T19.focus();
                    first_focus = true;
                }
                itemsCheck[8] = false;
        }
    }

    if ( ! isEmptyA(theForm.T14.value) ){
        if ( isEmpty(theForm.T14.value) ){
            theForm.T14_e.value = "Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø¥Ø¯Ø®Ø§Ù„ Ø¥Ø³Ù… Ø§Ù„Ø¬Ø§Ù…Ø¹Ø© ØµØ­ÙŠØ­Ø§Ù‹";
            if ( ! first_focus ){
                theForm.T14.focus();
                first_focus = true;
            }
            itemsCheck[11] = false;
        }else if ( ! isArabicText(theForm.T14.value) ){
                theForm.T14_e.value = "Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø¥Ø¯Ø®Ø§Ù„ Ø¥Ø³Ù… Ø§Ù„Ø¬Ø§Ù…Ø¹Ø© Ø¨Ø§Ù„Ø¹Ø±Ø¨ÙŠØ©";
                if ( ! first_focus ){
                    theForm.T14.focus();
                    first_focus = true;
                }
                itemsCheck[11] = false;
        }else {
            if ( isEmpty(theForm.T19.value) ){
                    theForm.T19_e.value = errorMSG_1("Ø§Ù„Ù…Ø±Ø­Ù„Ø© Ø§Ù„Ø¥Ø¨ØªØ¯Ø§Ø¦ÙŠØ©");
                    if ( ! first_focus ){
                        theForm.T19.focus();
                        first_focus = true;
                    }
                    itemsCheck[8] = false;
            }
            if ( isEmpty(theForm.T21.value) ){
                    theForm.T21_e.value = errorMSG_1("Ø§Ù„Ù…Ø±Ø­Ù„Ø© Ø§Ù„Ø«Ø§Ù†ÙˆÙŠØ©");
                    if ( ! first_focus ){
                        theForm.T21.focus();
                        first_focus = true;
                    }
                    itemsCheck[10] = false;
            }
            if ( isEmpty(theForm.T15.value) ){
                    theForm.T15_e.value = "Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø¥Ø¯Ø®Ø§Ù„ Ø¥Ø³Ù… Ø§Ù„ÙƒÙ„ÙŠØ© ØµØ­ÙŠØ­Ø§Ù‹";
                    if ( ! first_focus ){
                        theForm.T15.focus();
                        first_focus = true;
                    }
                    itemsCheck[12] = false;
            }
            if ( isEmpty(theForm.T16.value) ){
                    theForm.T16_e.value = "Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø¥Ø¯Ø®Ø§Ù„ Ø¥Ø³Ù… Ø§Ù„Ù‚Ø³Ù… ØµØ­ÙŠØ­Ø§ÙŽ";
                    if ( ! first_focus ){
                        theForm.T16.focus();
                        first_focus = true;
                    }
                    itemsCheck[13] = false;
            }
        }
    }

    if ( ! isEmptyA(theForm.T15.value) ){
        if ( isEmpty(theForm.T15.value) ){
            theForm.T15_e.value = "Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø¥Ø¯Ø®Ø§Ù„ Ø¥Ø³Ù… Ø§Ù„ÙƒÙ„ÙŠØ© ØµØ­ÙŠØ­Ø§Ù‹";
            if ( ! first_focus ){
                theForm.T15.focus();
                first_focus = true;
            }
            itemsCheck[12] = false;
        }else if ( ! isArabicText(theForm.T15.value) ){
                theForm.T15_e.value = "Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø¥Ø¯Ø®Ø§Ù„ Ø¥Ø³Ù… Ø§Ù„ÙƒÙ„ÙŠØ© Ø¨Ø§Ù„Ø¹Ø±Ø¨ÙŠØ©";
                if ( ! first_focus ){
                    theForm.T15.focus();
                    first_focus = true;
                }
                itemsCheck[12] = false;
        }else {
            if ( isEmpty(theForm.T19.value) ){
                    theForm.T19_e.value = errorMSG_1("Ø§Ù„Ù…Ø±Ø­Ù„Ø© Ø§Ù„Ø¥Ø¨ØªØ¯Ø§Ø¦ÙŠØ©");
                    if ( ! first_focus ){
                        theForm.T19.focus();
                        first_focus = true;
                    }
                    itemsCheck[8] = false;
            }
            if ( isEmpty(theForm.T21.value) ){
                    theForm.T21_e.value = errorMSG_1("Ø§Ù„Ù…Ø±Ø­Ù„Ø© Ø§Ù„Ø«Ø§Ù†ÙˆÙŠØ©");
                    if ( ! first_focus ){
                        theForm.T21.focus();
                        first_focus = true;
                    }
                    itemsCheck[10] = false;
            }
            if ( isEmpty(theForm.T14.value) ){
                    theForm.T14_e.value = "Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø¥Ø¯Ø®Ø§Ù„ Ø¥Ø³Ù… Ø§Ù„Ø¬Ø§Ù…Ø¹Ø© ØµØ­ÙŠØ­Ø§Ù‹";
                    if ( ! first_focus ){
                        theForm.T14.focus();
                        first_focus = true;
                    }
                    itemsCheck[11] = false;
            }
            if ( isEmpty(theForm.T16.value) ){
                    theForm.T16_e.value = "Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø¥Ø¯Ø®Ø§Ù„ Ø¥Ø³Ù… Ø§Ù„Ù‚Ø³Ù… ØµØ­ÙŠØ­Ø§ÙŽ";
                    if ( ! first_focus ){
                        theForm.T16.focus();
                        first_focus = true;
                    }
                    itemsCheck[13] = false;
            }
        }
    }

    if ( ! isEmptyA(theForm.T16.value) ){
        if ( isEmpty(theForm.T16.value) ){
            theForm.T16_e.value = "Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø¥Ø¯Ø®Ø§Ù„ Ø¥Ø³Ù… Ø§Ù„Ù‚Ø³Ù… ØµØ­ÙŠØ­Ø§ÙŽ";
            if ( ! first_focus ){
                theForm.T16.focus();
                first_focus = true;
            }
            itemsCheck[13] = false;
        }else if ( ! isArabicText(theForm.T16.value) ){
                theForm.T16_e.value = "Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø¥Ø¯Ø®Ø§Ù„ Ø¥Ø³Ù… Ø§Ù„Ù‚Ø³Ù… Ø¨Ø§Ù„Ø¹Ø±Ø¨ÙŠØ©";
                if ( ! first_focus ){
                    theForm.T16.focus();
                    first_focus = true;
                }
                itemsCheck[13] = false;
        }else {
            if ( isEmpty(theForm.T19.value) ){
                    theForm.T19_e.value = errorMSG_1("Ø§Ù„Ù…Ø±Ø­Ù„Ø© Ø§Ù„Ø¥Ø¨ØªØ¯Ø§Ø¦ÙŠØ©");
                    if ( ! first_focus ){
                        theForm.T19.focus();
                        first_focus = true;
                    }
                    itemsCheck[8] = false;
            }
            if ( isEmpty(theForm.T21.value) ){
                    theForm.T21_e.value = errorMSG_1("Ø§Ù„Ù…Ø±Ø­Ù„Ø© Ø§Ù„Ø«Ø§Ù†ÙˆÙŠØ©");
                    if ( ! first_focus ){
                        theForm.T21.focus();
                        first_focus = true;
                    }
                    itemsCheck[10] = false;
            }
            if ( isEmpty(theForm.T14.value) ){
                    theForm.T14_e.value = "Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø¥Ø¯Ø®Ø§Ù„ Ø¥Ø³Ù… Ø§Ù„Ø¬Ø§Ù…Ø¹Ø© ØµØ­ÙŠØ­Ø§Ù‹";
                    if ( ! first_focus ){
                        theForm.T14.focus();
                        first_focus = true;
                    }
                    itemsCheck[11] = false;
            }
            if ( isEmpty(theForm.T15.value) ){
                    theForm.T15_e.value = "Ø§Ù„Ø±Ø¬Ø§Ø¡ Ø¥Ø¯Ø®Ø§Ù„ Ø¥Ø³Ù… Ø§Ù„ÙƒÙ„ÙŠØ© ØµØ­ÙŠØ­Ø§Ù‹";
                    if ( ! first_focus ){
                        theForm.T15.focus();
                        first_focus = true;
                    }
                    itemsCheck[12] = false;
            }
        }
    }

    /*if (  isEmptyA(theForm.T21.value) ) theForm.R1[6].checked = true;
    else if (  isEmptyA(theForm.T14.value) ) theForm.R1[0].checked = true;
    else if ( ( theForm.R1[0].checked ) || ( theForm.R1[6].checked ) ) theForm.R1[2].checked = true;

    if ( ! isEmptyA(theForm.S1.value)  ){
        if ( isEmpty(theForm.S1.value) ){
            theForm.S1_e.value = errorMSG_1("Ø§Ù„Ø®Ø¨Ø±Ø§Øª");
            if ( ! first_focus ){
                theForm.S1.focus();
                first_focus = true;
            }
            itemsCheck[14] = false;
        }
    } */

    for(i=0; i<itemsCheck.length; i++)
        if ( ! itemsCheck[i] ) return (false);
	return (true);
}


function test(theForm){
	theForm.T9.value = "";
}




function logoutDone(done){
	if(done == 1){
		loginS = false;
		var newFrame = document.getElementById("flogin");
		if ( newFrame == null ){
			newFrame = document.createElement("iframe");
			newFrame.width=0;
		    newFrame.height=0;
		    newFrame.frameBorder=0;
		    newFrame.name = "flogin";
		    newFrame.id = "flogin";
		    document.body.appendChild(newFrame);
		}
		newFrame = frames["flogin"];
		newFrame.location = "2t_is_login.php";	
			
	}
}
function closeSubpage(){
	var theLayer = document.getElementById("layerSubpage");
	if (theLayer){
		theLayer.style.visibility = 'hidden';
	}	
}
var theSubpageLayer;
var theSubpageText;
function subpageResult(pText,pName){
	var theLayer = document.getElementById("layerSubpage");
	if (theLayer){
	 	if (pName.search('طالب وظيفة') != -1 ){theSubpageLayer = theLayer; theSubpageText = pText; getJobFormData(); return;}
		theLayer.innerHTML = pText;
		theLayer.scrollIntoView();
	}	
}

function openSubpage(e,url,pId,pName,w,h,pText,pw,ph,mID){
	if ( (w == null) || (w == 0) ) var w = 500;
	if ( (h == null) || (h == 0) ) var h = 500;
	var hurl = url;
	
	var inUnicode = new String();
	inUnicode = pName.charCodeAt(0);
	for(i=1;i<pName.length;i++) inUnicode = inUnicode+","+pName.charCodeAt(i);
	
	if (url == null) hurl = new String("2t_subpage_details.php?pId="+pId);	
	
	var urlUnicode = new String();
	urlUnicode = hurl.charCodeAt(0);
	for(i=1;i<hurl.length;i++) urlUnicode = urlUnicode+","+hurl.charCodeAt(i);
	hurl = urlUnicode;
	
	var theLayer = document.getElementById("layerSubpage");
	var top = e.clientY + document.body.scrollTop - 40;	
	var left =((window.screen.width + document.body.scrollLeft)/2) - (w/2);
	
	if (pw) left = left + pw;
	if (ph) top = top + ph;
	
	if (theLayer != null) {		
		theLayer.style.top = top;
		theLayer.style.left = left;
		theLayer.style.width = w+"px";
		theLayer.style.height = h+"px";
		theLayer.style.visibility = 'visible';
		if (pText != null){				
				theLayer.innerHTML = pText;
		}else{							
			var theFrame = document.getElementById("fSubpage");
			if (theFrame){					
					theLayer.innerHTML = "<div><table dir=\"rtl\"border=\"1\"width=\"100%\"cellspacing=\"0\" cellpadding=\"0\" height=\"100%\"  onmouseover=\"this.style.cursor='pointer';\" onmouseout=\"this.style.cursor='default';\"><tr><td  align=\"center\" width=\"100%\" height=\"100%\"><font color=\"#383838\" size=\"3\"><b><span lang=\"ar-jo\">جاري تحميل&nbsp;الصفحة الفرعية...</span></b></font><img border=\"0\" src=\"../images/loading.gif\" width=\"16\" height=\"16\"></td></tr></table></div>";					
					newFrame = frames["fSubpage"];
					//alert("2t_subpage_index.php?pName="+inUnicode+"&w="+w+"&h="+h+"&url="+hurl);
					newFrame.location = "2t_subpage_index.php?pName="+inUnicode+"&w="+w+"&h="+h+"&mID="+mID+"&url="+hurl;
			}
		}
		return;
	}
	createLayer("Subpage",null,top+"px",left+"px",w+"px",h+"px","#FFFFFF");
	var theLayer = document.getElementById("layerSubpage");
	if (pText != null){
				theLayer.innerHTML = pText;
	}else{		
		theLayer.innerHTML = "<div><table dir=\"rtl\"border=\"1\"width=\"100%\"cellspacing=\"0\" cellpadding=\"0\" height=\"100%\"  onmouseover=\"this.style.cursor='pointer';\" onmouseout=\"this.style.cursor='default';\"><tr><td  align=\"center\" width=\"100%\" height=\"100%\"><font color=\"#383838\" size=\"3\"><b><span lang=\"ar-jo\">جاري تحميل&nbsp;الصفحة الفرعية...</span></b></font><img border=\"0\" src=\"../images/loading.gif\" width=\"16\" height=\"16\"></td></tr></table></div>";		
		var newFrame = document.createElement("iframe");
		newFrame.width=0;
		newFrame.height=0;
		newFrame.frameBorder=0;
		newFrame.name = "fSubpage";
		newFrame.id = "fSubpage";
		document.body.appendChild(newFrame);
		newFrame = frames["fSubpage"];
		newFrame.location = "2t_subpage_index.php?pName="+inUnicode+"&w="+w+"&h="+h+"&mID="+mID+"&url="+hurl;
	}
	
}

function logout(){
		document.getElementById('isLogin').innerHTML = "<div><table dir=\"rtl\"border=\"0\"width=\"100%\"cellspacing=\"0\" cellpadding=\"0\" height=\"100%\"  onmouseover=\"this.style.cursor='pointer';\" onmouseout=\"this.style.cursor='default';\"><tr><td  align=\"center\" width=\"100%\" height=\"100%\"><font color=\"#383838\" size=\"3\"><b><span lang=\"ar-jo\">جاري تسجيل الخروج&nbsp;...</span></b></font><img border=\"0\" src=\"../images/loading.gif\" width=\"16\" height=\"16\"></td></tr></table></div>";
	var newFrame = document.getElementById("flogout");
	if ( newFrame == null ){
		newFrame = document.createElement("iframe");
		newFrame.width=0;
	    newFrame.height=0;
	    newFrame.frameBorder=0;
	    newFrame.name = "flogout";
	    newFrame.id = "flogout";
	    document.body.appendChild(newFrame);
	}
    newFrame = frames["flogout"];
	newFrame.location = "2t_logout.php";
}
function headerLoginName(hText){
	document.getElementById('isLogin').innerHTML = hText;
	if (isIndex) loadLoginNew();
}

