function getAdDate(){
   today = new Date();
   date = today.getDate();
   weekday = today.getDay();
   sCurDate = "";

   if (weekday == 6) sCurDate += ('السبت');
   if (weekday == 0) sCurDate += ('الأحد');
   if (weekday == 1) sCurDate += ('الإثنين');
   if (weekday == 2) sCurDate += ('الثلاثاء');
   if (weekday == 3) sCurDate += ('الأربعاء');
   if (weekday == 4) sCurDate += ('الخميس');
   if (weekday == 5) sCurDate += ('الجمعة');
   //document.write(', ', date,' ');
   sCurDate += " " + date + " ، ";

   month = today.getMonth();
   if (month == 0) sCurDate += ('يناير');
   if (month == 1) sCurDate += ('فبراير');
   if (month == 2) sCurDate += ('مارس');
   if (month == 3) sCurDate += ('أبريل');
   if (month == 4) sCurDate += ('مايو');
   if (month == 5) sCurDate += ('يونيو');
   if (month == 6) sCurDate += ('يوليو');
   if (month == 7) sCurDate += ('أغسطس');
   if (month == 8) sCurDate += ('سبتمبر');
   if (month == 9) sCurDate += ('أكتوبر');
   if (month == 10) sCurDate += ('نوفمبر');
   if (month == 11) sCurDate += ('ديسمبر');

   year=today.getYear();
   if (year<=99) sCurDate +=  " " + (' 19', year);
   if (year>=2000) sCurDate +=  " " + (year);
   //document.write (year);

   return sCurDate;
}

function xlaunch(sURL, sName, sFeatures, sParentName) {
  //var oWin = showModalDialog(sURL, sName, sFeatures);
  var oWin = open(sURL, sName, sFeatures);
  if (oWin.opener == null){
 	oWin.opener = window;
	oWin.opener.name = sParentName;
	oWin.window.focus();
  }
  return oWin;
}

function printArtical(iID){
	myRemote = xlaunch('print.php?rpt=' +iID,
	 'myRemote',
	 'height=600,width=800,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0',
	 'myWindo');
}

function sendArtical(iID,sTitle){
	myRemote = xlaunch('./send/?id=' +iID+ '&title=' + sTitle,
	 'myRemote',
	 'height=280,width=453,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0',
	 'myWindo');
}

function addComments(iID,sTitle){
	myRemote = xlaunch('comments.php?rpt=' +iID+ '&title=' + sTitle,
	 'myRemote',
	 'height=233,width=453,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0',
	 'myWindo');

}

// **************************
// Functions to check forms
// **************************
function isEmail(varX, fname){
   if (document.forms[fname].elements[varX].value.indexOf ('@',0) == -1 ||
       document.forms[fname].elements[varX].value.indexOf ('.',0) == -1)
      {
      //alert("\nThis is not a valid E-Mail address. \n\nPlease re-enter valid e-mail address.")
      document.forms[fname].elements[varX].select();
      document.forms[fname].elements[varX].focus();
      return false;
      }
   else
      {
      return true;
      }
}

function isEmpty( varX, fname ){	// Returns false if empty
  if (document.forms[fname].elements[varX].value == "")
      {
      document.forms[fname].elements[varX].focus();
      return true;
      }
 else return false;
}



var ErrInvalidEmail = "خطأ في العنوان البريدي \n";
var ErrEmptyField = 'يمكنك التسجيل لاستقبال رسائلنا الالكترونية و اخبار تحديث الموقع';
ErrEmptyField += "\n\nفضلاً سجل اسمك  و بريدك الالكتروني";
var ErrInvalidNo = " هذا الحقل لقيمة رقمية، فضلا تأكد من المدخلات";
var ErrEmptyField = 'الرجاء تعبئة الحقول المطلوبة';

function mailinFormCheck(form_name){
    var x;
    fname = form_name;
    // check filling up the form
    for (x=0; x<2; x++) {
     switch(x)
          {
            case 0:
            case 1:
						if ( isEmpty(x, form_name) ) {
							alert( ErrEmptyField );
							return false;
							break;
						}
          }
    }

    // check email format validity
    if ( isEmail(1,form_name) ){
    	if(! isEmail(1,form_name) ) {
     		alert(ErrInvalidEmail + ' ' + document.forms[fname].elements[1].name);
				document.forms[fname].elements[1].focus();
				return false;
			}
		}
		else{
   		alert( ErrInvalidEmail );
			document.forms[fname].elements[1].focus();
			return false;
		}
}

var ErrInvalidEmail = "خطأ في العنوان البريدي \n";
var ErrEmptyField 	= 'هذا الحقل فارغ\n\nفضلاً اكتب المعلومات المطلوبة';

function checkForm(){
    var x
    for (x=0; x<4; x++) {
     switch(x){
            case 0:
            case 1:
            case 3:
				if ( isEmpty(x) ) {
				  alert( ErrEmptyField );return false; break;}
     }
    }

    // check email format validity
    if ( ! isEmail(1) ){
		alert( ErrInvalidEmail );
		document.forms[0].elements[1].focus();
		return false;
	}


	document.forms[0].elements[6].disabled =true;
}

function hideLevel( _levelId) {
	var thisLevel = document.getElementById( _levelId );
	thisLevel.style.display = "none";
}

function showLevel( _levelId) {
	var thisLevel = document.getElementById( _levelId );
	if ( thisLevel.style.display == "none" ) {
		thisLevel.style.display = "block";
	}
	else {
		hideLevel( _levelId);
		_levelId = '';
	}
	setCookie("sub_menu",_levelId);
}

function menuDiv(){
	az = document.getElementsByTagName('a')
	for( i=0;i<az.length;i++) {
		if( String(location.href).indexOf(az[i]) != -1){
			//az[i].style.backgroundColor= '#d0d0d0';
			az[i].style.color=  '#339933';
			//az[i].style.cursor=  'arrow'
			az[i].removeAttribute('href');
			//az[i].className = 'hi_menu_link';
			//az[i].innerHTML = '&#9668;' + ' '+az[i].innerHTML 
			j=i-1;

		}
	}
	// get cookie, and showLevel of last clicked menu item
	g =  getCookie("sub_menu") ;

	if( g!=""){
		showLevel(g);
		//p = document.getElementById(g+'_parent');
		//p.className = 'hi';
		//p.style.color=  'white';
	}
}


function setCookie(sName, sValue)
{
    date = new Date();
    date.setTime(date.getTime() + (1000 * 60 * 60 * 24 * 30)); 
    document.cookie = sName + "=" + sValue + "; expires=" + date.toGMTString();  
 // alert( "cookie is set: " + document.cookie );
}

function getCookie(crumbName)
{
    colCookie = document.cookie.split(";");
    
    for (a=0; a < colCookie.length; a++)
    {
        colCrumb = colCookie[a].split("=");                    
        if(colCrumb[0] == crumbName)
            return unescape(colCrumb[1]);
    }

    return "";

}




function cf(oForm){
	try{
			var x
			for (x=0; x<3; x++) {
				switch(x) {
							case 0:
							case 1:
							case 2:
								if (oForm.elements[x].value == "")
								{
										oForm.elements[x].focus();
										alert( ErrEmptyField );
										return false;
										break;
								}
				}
			}

		 if (oForm.elements[1].value.indexOf ('@',0) == -1 ||
       	 oForm.elements[1].value.indexOf ('.',0) == -1)
      {
      		//alert("\nThis is not a valid E-Mail address. \n\nPlease re-enter valid e-mail address.")
      		oForm.elements[1].select();
      		oForm.elements[1].focus();
      		alert( ErrInvalidEmail );
      		return false;
      }
	//alert('true')
	return true;

	}
	catch(e) { alert(e) }
}


function isNumber(theElement, theElementName)
{
  s = theElement.value;
  if ( (s == "") || (isNaN(Math.abs(s)) && (s.charAt(0) != '#')))
  {
      if ( isNumber.arguments.length  == 1 )
         alert( " Value must be a number." );
      else
         alert( theElementName +  " Value must be a number." );
    theElement.focus();
    return false;
  }
  return true;
}




function saleFormChk(oForm){
	try{
			var x
			for (x=0; x<7; x++) {
					if (oForm.elements[x].value == "")
					{
							oForm.elements[x].focus();
							alert( ErrEmptyField );
							return false;
							break;
					}

			}

		// check email

		 if (oForm.elements[1].value.indexOf ('@',0) == -1 ||
       	 oForm.elements[1].value.indexOf ('.',0) == -1)
      {
      		//alert("\nThis is not a valid E-Mail address. \n\nPlease re-enter valid e-mail address.")
      		oForm.elements[1].select();
      		oForm.elements[1].focus();
      		alert( ErrInvalidEmail );
      		return false;
      }

     // check p.o.box
     s = oForm.elements[3].value
		 if ( (s == "")  ||  (isNaN(Math.abs(s)) &&  (s.charAt(0) != '#') )) {
			    oForm.elements[3].select();
      		oForm.elements[3].focus();
      		alert( ErrInvalidNo );
			 		return false;
		 }
     s = oForm.elements[4].value
		 if ( (s == "")  ||  (isNaN(Math.abs(s)) &&  (s.charAt(0) != '#') )) {
			    oForm.elements[4].select();
      		oForm.elements[4].focus();
      		alert( ErrInvalidNo );
			 		return false;
		 }
     s = oForm.elements[5].value
		 if ( (s == "")  ||  (isNaN(Math.abs(s)) &&  (s.charAt(0) != '#') )) {
			    oForm.elements[5].select();
			 		oForm.elements[5].focus();
			 		alert( ErrInvalidNo );
			 		return false;
		 }


	//alert('true')
	return true;

	}
	catch(e) { alert(e) }
}
