function check(txtuser,txtpwd)

{ 

var boolResult=CheckInput(txtuser,"الرجاء كتابة اسم المستخدم")&& CheckInput(txtpwd,"الرجاء كتابة كلمة السر");

return boolResult;

}

/**********************************************************/

function send(txtTitle,txtSubject)

{ 

var boolResult=CheckInput(txtTitle,"الرجاء كتابة العنوان")&& CheckInput(txtSubject,"الرجاء كتابة نص الرسالة");

return boolResult;

}

/**********************************************************/

function sendArt(ddlCat,txtTitle,txtSubject)

{ 

var boolResult=CheckDdl(ddlCat,'الرجاء اختيار تصنيف المقالة')&& CheckInput(txtTitle,"الرجاء كتابة العنوان")&& CheckInput(txtSubject,"الرجاء كتابة نص المقالة");

return boolResult;

}

/**********************************************************/

function CheckDdl(strCtrlId,strMsgTxt)

{

     if(txttrim(document.getElementById(strCtrlId).value)== 0 )

     {   

    	alert(strMsgTxt);

        try{

	        document.getElementById(strCtrlId).focus();

	    }catch(er){};	    

	    return false;

	}	 

	return true;

}

/**********************************************************/

function echeck(str) {		

		var at="@"

		var dot="."

		var lat=str.indexOf(at)

		var lstr=str.length

		var ldot=str.indexOf(dot)

		if (str.indexOf(at)==-1){

		   alert("الرجاء كتابة الايميل بشكل صحيح");		

		   return false;

		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){

		  alert("الرجاء كتابة الايميل بشكل صحيح");		   

		   return false;

		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){

		    alert("الرجاء كتابة الايميل بشكل صحيح");		   

		    return false;

		}

		 if (str.indexOf(at,(lat+1))!=-1){

		  alert("الرجاء كتابة الايميل بشكل صحيح");		   

		    return false;

		 }



		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){

		   alert("الرجاء كتابة الايميل بشكل صحيح");		   

		    return false;

		 }



		 if (str.indexOf(dot,(lat+2))==-1){

		    alert("الرجاء كتابة الايميل بشكل صحيح");		   

		    return false;

		 }

		

		 if (str.indexOf(" ")!=-1){

		   alert("الرجاء كتابة الايميل بشكل صحيح");		   

		    return false;

		 }

 		 return true					

	}

/**************************************************************************/

function validate(){

	var emailID = document.frm.txtEmail;

	var name    = document.frm.txtName;		

	var pwd     = document.frm.txtPwd;		

	var natio   = document.frm.txtNationalty;

	var job     = document.frm.txtJob;

	var company = document.frm.txtCompany;

	var country = document.frm.txtCountry;

	var studay  = document.frm.txtStuday;

	var track   = document.frm.txtTrack;

	var sub     = document.frm.txtSub;

	var ExpY    = document.frm.txtExpYear;	

	var phone   = document.frm.txtPhone;

	var mobile  = document.frm.txtMobile;

	var fax     = document.frm.txtFax;

	var url     = document.frm.txtUrl;

	if ((emailID.value==null)||(emailID.value=="")){

		alert("الرجاء كتابة الايميل")

		emailID.focus();

		return false;

	}

	if (echeck(emailID.value)==false){

		emailID.value=""

		emailID.focus();

		return false;

	}

	if ((pwd.value==null)||(pwd.value=="")){

		alert("الرجاء كتابة كلمة السر")		

		pwd.focus();

		return false;

	}

	if ((name.value==null)||(name.value=="")){

		alert("الرجاء كتابة الاسم")

		name.focus();

		return false;

	}

	if (IsCharss(name.value,"الرجاء ادخال  الاسم بشكل صحيح ,الحروف فقط المسموح بها ")==false){

		name.focus();

		return false;

	}	

	if ((mobile.value==null)||(mobile.value=="")){

		alert("الرجاء كتابة رقم الجوال")

		mobile.focus();

		return false;

	}

	if (IsNumericc(mobile.value,"الرجاء ادخال  رقم الجوال بشكل صحيح ,الحروف فقط المسموح بها ")==false){

		mobile.focus();

		return false;

	}

	if ((natio.value!=null)||(natio.value!="")){

		if (IsCharss(natio.value,"الرجاء ادخال  الجنسية بشكل صحيح ,الحروف فقط المسموح بها ")==false){

			natio.focus();

			return false;

		}

	}

	if ((job.value!=null)||(job.value!="")){

		if (IsCharss(job.value,"الرجاء ادخال  العمل بشكل صحيح ,الحروف فقط المسموح بها ")==false){

			job.focus();

			return false;

		}

	}

	if ((company.value!=null)||(natio.value!="")){

		if (IsCharss(company.value,"الرجاء ادخال  جهة العمل بشكل صحيح ,الحروف فقط المسموح بها ")==false){

			company.focus();

			return false;

		}

	}

	if ((country.value!=null)||(natio.value!="")){

		if (IsCharss(country.value,"الرجاء ادخال  الدولة بشكل صحيح ,الحروف فقط المسموح بها ")==false){

			country.focus();

			return false;

		}

	}

	if ((phone.value!=null)||(phone.value!="")){

		if (IsNumericc(phone.value,"الرجاء ادخال  رقم الهاتف بشكل صحيح ,الحروف فقط المسموح بها ")==false){

			phone.focus();

			return false;

		}

	}

	if ((fax.value!=null)||(fax.value!="")){

		if (IsNumericc(fax.value,"الرجاء ادخال  رقم الفاكس بشكل صحيح ,الحروف فقط المسموح بها ")==false){

			fax.focus();

			return false;

		}

	}

/*	if ((url.value!=null)||(url.value!="")){

		if (IsCharss(url.value,"الرجاء ادخال  الجنسية بشكل صحيح ,الحروف فقط المسموح بها ")==false){

			url.focus();

			return false;

		}

	}*/

	if ((studay.value!=null)||(studay.value!="")){

		if (IsCharss(studay.value,"الرجاء ادخال  الدرجة العلمية بشكل صحيح ,الحروف فقط المسموح بها ")==false){

			studay.focus();

			return false;

		}

	}

	if ((track.value!=null)||(studay.value!="")){

		if (IsCharss(track.value,"الرجاء ادخال  التخصص العلمي بشكل صحيح ,الحروف فقط المسموح بها ")==false){

			track.focus();

			return false;

		}

	}

	if ((sub.value!=null)||(studay.value!="")){

		if (IsCharss(sub.value,"الرجاء ادخال  التخصص الدقيق بشكل صحيح ,الحروف فقط المسموح بها ")==false){

			sub.focus();

			return false;

		}

	}

	if ((ExpY.value!=null)||(ExpY.value!="")){

		if (IsNumericc(ExpY.value,"الرجاء ادخال  عدد سنوات الخبرة بشكل صحيح ,الحروف فقط المسموح بها ")==false){

			ExpY.focus();

			return false;

		}

	}

	return true

 } 

 /***************************************************************************/

 function IsNumericc(strCtrlId, strMsgTxt){

   var txt = strCtrlId;

   var ValidChars = "0123456789.";

   var Char;

   for (i = 0; i < txt.length ; i++) 

   { 

      Char = txt.charAt(i); 

      if (ValidChars.indexOf(Char) == -1)

      {

            if(strMsgTxt != null && strMsgTxt != "")

            {

                alert(strMsgTxt);

            }            

         return false;

       } 

    }

   return true;  

   }

/**************************************************************************************************/

function IsCharss(strCtrlId, strMsgTxt)

{

    var textchar = strCtrlId;

    var Validch = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ابتثجحخدذرزسشصضطظعغفقكلمنهوىيءؤئإأة";

    for (i=0;i<textchar.length;i++) 

    { 

          var chr = textchar.charAt(i);

          if (Validch.indexOf(chr) == -1)

          { 

                 if(strMsgTxt != null && strMsgTxt != "")

                 {

                    alert(strMsgTxt);

                 } 

             return false;

          }

    }

    return true;

} 

/**************************************************************************/

function contact(txtName,txtEmail,txtTitle,txtSubject)

{ var boolResult=CheckInput(txtName,"الرجاء ادخال  الإسم")&& CheckInput(txtEmail,"الرجاء ادخال  الإيميل")&& CheckInput(txtTitle,"الرجاء ادخال  العنوان")&& CheckInput(txtSubject,"الرجاء ادخال  المطلوب");

return boolResult;

} 

/**************************************************************************/

function contact()

{

	var Name = document.contfrm.txtName;

	var emailID = document.contfrm.txtEmail;	

	var title   = document.contfrm.txtTitle;		

	var subject = document.contfrm.txtSubject;	

	

	if ((Name.value==null)||(Name.value=="")){

		alert("الرجاء كتابة الاسم")		

		Name.focus();

		return false;

	}

	if ((emailID.value==null)||(emailID.value=="")){

		alert("الرجاء كتابة الايميل")

		emailID.focus();

		return false;

	}

	if (echeck(emailID.value)==false){

		emailID.value=""

		emailID.focus();

		return false;

	}

	if ((title.value==null)||(title.value=="")){

		alert("الرجاء كتابة الموضوع")		

		title.focus();

		return false;

	}

	if ((subject.value==null)||(subject.value=="")){

		alert("الرجاء كتابة النص")		

		subject.focus();

		return false;

	}

   return true;

}

/**************************************************************************/

function login()

{

	var emailID = document.log.txtEmail;	

	var pwd     = document.log.txtPwd;	

	if ((emailID.value==null)||(emailID.value=="")){

		alert("الرجاء كتابة الايميل")

		emailID.focus();

		return false;

	}

	if (echeck(emailID.value)==false){

		emailID.value=""

		emailID.focus();

		return false;

	}

	if ((pwd.value==null)||(pwd.value=="")){

		alert("الرجاء كتابة كلمة السر")		

		pwd.focus();

		return false;

	}

   return true;

}

/**************************************************************************************************/	

function IsNumeric(strCtrlId, strMsgTxt){

  var txt = document.getElementById(strCtrlId).value;

   var ValidChars = "0123456789.";

   var Char;

   for (i = 0; i < txt.length ; i++) 

   { 

      Char = txt.charAt(i); 

      if (ValidChars.indexOf(Char) == -1)

      {

            if(strMsgTxt != null && strMsgTxt != "")

            {

                alert(strMsgTxt);

            }

            

         return false;

       } 

    }

   return true;  

   }

/**************************************************************************************************/

function IsChar(strCtrlId, strMsgTxt)

{

    var textchar = document.getElementById(strCtrlId).value;

     var Validch = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ابتثجحخدذرزسشصضطظعغفقكلمنهوىيءؤئإأة";

    for (i=0;i<textchar.length;i++) 

    { 

          var chr = textchar.charAt(i);

          if (Validch.indexOf(chr) == -1)

          {       

          

                 if(strMsgTxt != null && strMsgTxt != "")

                 {

                    alert(strMsgTxt);

                 }                 

                  try{

	                document.getElementById(strCtrlId).focus();

	              }catch(er){};

	              	    

             return false;

          }

    }

    return true;

}

/**************************************************************************/

function CheckInput(strCtrlId, strMsgTxt)

{

     if(txttrim(document.getElementById(strCtrlId).value)== "" )

     {   

    	alert(strMsgTxt);

        try{

	        document.getElementById(strCtrlId).focus();

	    }catch(er){};	    

	    return false;

	}	

	return true;

}

	

function txttrim(str){



        

        while(str.charAt(0) == (" ") )

        { 

            str = str.substring(1);

        }



        while(str.charAt(str.length-1) == " " )

        { 

             str = str.substring(0,str.length-1);

        }

        return str;

}

/**************************************/
function changePic(imgId,strPath)
 {
         var o = document.images[imgId];
	 var s = new String(strPath);
	 s = s.replace("\\","/");
	 o.src = "file:///" + s;    
 }
