function mc(d){
        if( document.all[d].style.display == 'none' ){
                document.all[d].style.display = 'inline';
        }else{
                document.all[d].style.display = 'none';
        }
}
function validateEmail( strEmail ) {
        var strEmailString = new String(strEmail);
        return (strEmailString.indexOf("@")!= -1 && strEmailString.indexOf(".") != -1);
}
function digitvalidation(entered, min, max, alertbox, datatype)
{
with (entered)
{
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i")
{
checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
}
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{
if (alertbox!="")
 {
alert(alertbox);}
return false;
}
else {return true;}
}
}
function validate(){
                if(document.form1.description){
                if (document.form1.description.value == ''){
                                alert('يجب اختيار توصيف مهني');
                                document.form1.description.focus();
                                return false;
                        }
                  }
if(document.form1.description1){
if (document.form1.description.value == 'أخرى' && document.form1.description1.value == ''){
                                alert('يجب اختيار توصيف مهني');
                                document.form1.description1.focus();
                                return false;
                        }
                  }

if(document.form1.select_name){
if (document.form1.select_name.value == ''){
                                alert('يجب اختيار اختصاص');
                                document.form1.select_name.focus();
                                return false;
                        }
                  }
if(document.form1.select_name1){
if (document.form1.select_name.value == 'أخرى' && document.form1.select_name1.value == ''){
                                alert('يجب اختيار اختصاص');
                                document.form1.select_name1.focus();
                                return false;
                        }
                   }

                if (document.form1.first_name.value == ''){
                                alert('حقل الاسم فارغ');
                                document.form1.first_name.focus();
                                return false;
                        }
                        if (document.form1.father_name.value == ''){
                                alert('حقل اسم الأب فارغ');
                                document.form1.father_name.focus();
                                return false;
                        }
                if (document.form1.last_name.value == '')
                        {
                                alert("حقل الكنية فارغ");
                                document.form1.last_name.focus();
                                return false;
                        }
                        if (document.form1.nationality.value == ''){
                                alert("حقل الجنسية فارغ");
                                document.form1.nationality.focus();
                                return false;
                        }

 if(document.form1.spouse_option.checked){
 if (document.form1.spouse_name.value == ''){
                                alert('حقل اسم الزوجة فارغ');
                                document.form1.spouse_name.focus();
                                return false;
                        }
 if (document.form1.sfather_name.value == ''){
                                alert('حقل اسم الأب للزوجة فارغ');
                                document.form1.sfather_name.focus();
                                return false;
                        }
 if (document.form1.slast_name.value == ''){
                                alert('حقل الكنية للزوجة فارغ');
                                document.form1.slast_name.focus();
                                return false;
                        }
 if (document.form1.spouse_profession.value == ''){
                                alert('حقل التوصيف المهني للزوجة فارغ');
                                document.form1.spouse_profession.focus();
                                return false;
                        }
                  }
if (document.form1.mobile.value == '')
                        {
                                alert('حقل الموبايل فارغ');
                                document.form1.mobile.focus();
                                return false;
                        }

if (document.form1.tel.value == '')
                        {
                                alert('حقل الهاتف فارغ');
                                document.form1.tel.focus();
                                return false;
                        }
if (document.form1.address.value == '')
                        {
                                alert('حقل العنوان فارغ');
                                document.form1.address.focus();
                                return false;
                        }

 if( !digitvalidation(document.form1.mobile,1,20, 'تأكد من صحة حقل الجوال',"float")){
         document.form1.mobile.focus();
    return false;
 }
 if( !digitvalidation(document.form1.tel,1,20, 'تأكد من صحة حقل الهاتف',"float")){
         document.form1.tel.focus();
    return false;
 }

if(document.form1.email.value !='') {
 if(!validateEmail(document.form1.email.value)){   alert("تأكد من صحة البريد الالكتروني");
         document.form1.email.focus();
    return false;
}
}

}

function validate_company(){
            if (document.form1.company_name.value == ''){
                                alert('حقل اسم الشركة فارغ');
                                document.form1.company_name.focus();
                                return false;
                        }
                        if (document.form1.company_activity.value == ''){
                                alert('حقل نشاط الشركة فارغ');
                                document.form1.company_activity.focus();
                                return false;
                        }

                        if (document.form1.address_company.value == ''){
                                alert('حقل عنوان الشركة فارغ');
                                document.form1.address_company.focus();
                                return false;
                        }
                                                if (document.form1.center.value == ''){
                                alert('حقل المقر الرئيسي فارغ');
                                document.form1.center.focus();
                                return false;
                        }

                        if (document.form1.tel_company1.value == ''){
                                alert('حقل هواتف الشركة فارغ');
                                document.form1.tel_company1.focus();
                                return false;
                        }if (document.form1.fax_company1.value == ''){
                                alert('حقل فاكسات الشركة فارغ');
                                document.form1.fax_company1.focus();
                                return false;
                        }
                        if( !digitvalidation(document.form1.tel_company1,1,20, 'تأكد من صحة حقل الهاتف',"float")){
         document.form1.tel_company1.focus();
    return false;
            }
                        if( !digitvalidation(document.form1.fax_company1,1,20, 'تأكد من صحة حقل الفاكس',"float")){
         document.form1.fax_company1.focus();
    return false;
            }
}

function populate9(objForm,selectIndex) {
timeA = new Date(objForm.year9.options[objForm.year9.selectedIndex].text, objForm.month9.options[objForm.month9.selectedIndex].value,1);
timeDifference = timeA - 86400000;
timeB = new Date(timeDifference);
var daysInMonth = timeB.getDate();
for (var i = 0; i < objForm.day9.length; i++) {
objForm.day9.options[0] = null;
}
for (var i = 0; i < daysInMonth; i++) {
objForm.day9.options[i] = new Option(i+1);
}
}
function getYears() {
var years = new Array(1997,1998,1999,2000,2001,2005)
for (var i = 0; i < document.f1.year.length; i++) {
document.f1.year.options[0] = null;
}
timeC = new Date();
currYear = timeC.getFullYear();
for (var i = 0; i < years.length; i++) {
document.f1.year.options[i] = new Option(years[i]);
}
document.f1.year.options[2].selected=true;
}
function enableDate(n){
        var m1 = document.getElementById("m1");
        var m2 = document.getElementById("m2");
        var m3 = document.getElementById("m3");
        if(n=="date"){
                m1.disabled=false;
                m2.disabled=false;
                m3.disabled=false;
        }
        else{
                m1.disabled=true;
                m2.disabled=true;
                m3.disabled=true;
        }
}
function military(selectedIndex){
        var line = document.getElementById("mil");
        var radio = document.getElementById("milDate");
        radio = radio.value;
        var m1 = document.getElementById("m1");
        var m2 = document.getElementById("m2");
        var m3 = document.getElementById("m3");
        if(selectedIndex=="???") {
                line.disabled=false;
                if(radio=="date"){
                m1.disabled=false;
                m2.disabled=false;
                m3.disabled=false;
                }
        }
        else {
         line.disabled=true;
         m1.disabled=true;
         m2.disabled=true;
         m3.disabled=true;
        }
}
function enable_spouse_info(){
        if(document.form1.spouse_option.checked){
                document.form1.spouse_name.disabled = false;
                document.form1.spouse_name.focus();
                document.form1.sfather_name.disabled = false;
                document.form1.slast_name.disabled = false;
                document.form1.spouse_profession.disabled = false;
        }
        else{
                document.form1.spouse_name.disabled = true;
                document.form1.sfather_name.disabled = true;
                document.form1.slast_name.disabled = true;
                document.form1.spouse_profession.disabled = true;
        }
}
function phd(value){
        var td = document.getElementById("phd");
        if(value==1){
                td.disabled=false;
                document.form1.phd_name.disabled = false;
                document.form1.phd_country.disabled = false;
                document.form1.year5.disabled = false;
                document.form1.month5.disabled = false;
                document.form1.day5.disabled = false;
        }
        else{
                td.disabled=true;
                document.form1.phd_name.disabled = true;
                document.form1.phd_country.disabled = true;
                document.form1.year5.disabled = true;
                document.form1.month5.disabled = true;
                document.form1.day5.disabled = true;
        }
}