
var hLstID='';

var http = createRequestObject();
function createRequestObject(){
    var request_;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        request_ = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
        request_ = new XMLHttpRequest();
    }
    return request_;
}

//================ GetInfo ==================
function getInfo(PageName, LstID){
	hLstID=LstID;
	//alert("PageName="+PageName+"\nLstID="+LstID);
    http.open('get', PageName);
	http.onreadystatechange = handleInfo;
    http.send(null);

}

function handleInfo(){
    if(http.readyState == 1){
		//document.getElementById('Loading').style.display='';
		document.getElementById('MainTable').scrollIntoView(true);
        document.getElementById(hLstID).innerHTML = '<div id=Loading>برجاء الانتظار جاري تحميل البيانات...<br></div>' + document.getElementById(hLstID).innerHTML;
    }
    if(http.readyState == 4){
        var response = http.responseText;
        document.getElementById(hLstID).innerHTML = response;
		//document.getElementById('Loading').style.display='none';
    }
}
//================ ------- ==================
function PrintIt(prID){
	window.ExecWB (6, 0);
	alert("OK");
}
//================ ------- ==================
function printArticle(id){
window.open('printArticle.php?ArticleID='+id,"",'toolbar=no,location=yeas,directories=no,status=no,menubar=no,scrollbars=yes,close=0,resizable=yes,copyhistory=yeas,width=468,height=500,left=10,top=10,border=0' ).focus();
}

function NoData(){ SetData=0;}
function AddBookMark(www,name){ if (document.all) {window.external.AddFavorite(www,name) }; }

// ==== Open window in screen center ====
 function rnp_open_window(name,width,height) {
	 var x= (screen.availWidth-width)/2;
	 var y= (screen.availHeight-height)/2;
     window.open('',name,'width='+width+',height='+height+',screenX='+x+',screenY='+y+',scrollbar=yes').focus();
	 return true;
}

// ==== Search On Google ====
function SearchOnGoogle() {
 if (document.frmsearch.q.value == "")
  {
    document.getElementById('em_msg').innerHTML ="أدخل الكلمة المراد البحث عنها";
    frmsearch.q.focus();
    return (false);
  }
  window.open('http://www.google.com/search?hl=ar&q='+frmsearch.q.value+'&btnG=Google+Search','SearchOnGoogle').focus();
  return (true);
}

//================ Alpha ==================
function wlow(which1){
theobject=which1
lowlighting=setInterval("lowlightit(theobject)",75)
}
function whigh(which1){
clearInterval(lowlighting)
which1.filters.alpha.opacity=100
}
function lowlightit(cur1){
if (cur1.filters.alpha.opacity>40)
cur1.filters.alpha.opacity-=10
else if (window.lowlighting)
clearInterval(lowlighting)
}

//================ writeCookie ==================
function writeCookie(name, value, hours)

{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }

  document.cookie = name + "=" + escape(value) + expire;
}

//================ Style Sheet ==================
function highlightButton(s)
{
	if(document.all)
		event.srcElement.className=s
}

//================ CHECK Search ==================
function search_Validator(theForm)
{
 if (theForm.q.value == "")
  {
    document.getElementById('em_msg').innerHTML ="أدخل الكلمة المراد البحث عنها";
    theForm.q.focus();
    return (false);
  }

  return (true);
}
//================ CHECK EMAIL LIST ==================
function emaillist_Validator(theForm)
{
 if (theForm.email.value == "")
  {
    document.getElementById('em_msg').innerHTML ="أدخل البريد الإلكترونى";
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.indexOf("@")== "-1")
  {
    document.getElementById('em_msg').innerHTML ="البريد الإلكترونى غير صحيح";
    theForm.email.focus();
    return (false);
  }

 if (theForm.email.value.indexOf(".")== "-1")
  {
    document.getElementById('em_msg').innerHTML ="البريد الإلكترونى غير صحيح";
    theForm.email.focus();
    return (false);
  }

  return (true);
}

//CHECK EMAIL Form//
function email_Validator(theForm)
{
 if (theForm.name.value == "")
  {
    alert("من فضلك أدخل الاسم");
    theForm.name.focus();
    return (false);
  }

  if (theForm.email.value == "")
  {
    alert("من فضلك أدخل البريد الإلكترونى");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.indexOf("@")== "-1")
  {
    alert("من فضلك أدخل البريد الإلكترونى بصورة صحيحة");
    theForm.email.focus();
    return (false);
  }
if (theForm.email.value.indexOf(".")== "-1")
  {
    alert("من فضلك أدخل البريد الإلكترونى بصورة صحيحة");
    theForm.email.focus();
    return (false);
  }

 if (theForm.Subject.value == "")
  {
    alert("من فضلك أدخل موضوع الرسالة");
    theForm.Subject.focus();
    return (false);
  }

 if (theForm.comment.value == "")
  {
    alert("من فضلك أدخل نص الرسالة");
    theForm.comment.focus();
    return (false);
  }

  return (true);
}

//CHECK TellYourFriends EMAIL Form//
function email_TellYourFriends_Validator(theForm)
{
 if (theForm.name.value == "")
  {
    alert("من فضلك أدخل الاسم");
    theForm.name.focus();
    return (false);
  }

  if (theForm.email.value == "")
  {
    alert("من فضلك أدخل البريد الإلكترونى");
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.indexOf("@")== "-1")
  {
    alert("من فضلك أدخل البريد الإلكترونى بصورة صحيحة");
    theForm.email.focus();
    return (false);
  }
if (theForm.email.value.indexOf(".")== "-1")
  {
    alert("من فضلك أدخل البريد الإلكترونى بصورة صحيحة");
    theForm.email.focus();
    return (false);
  }

 if (theForm.fname.value == "")
  {
    alert("من فضلك أدخل اسم صديقك");
    theForm.fname.focus();
    return (false);
  }

  if (theForm.femail.value == "")
  {
    alert("من فضلك أدخل البريد الإلكترونى");
    theForm.femail.focus();
    return (false);
  }

  if (theForm.femail.value.indexOf("@")== "-1")
  {
    alert("من فضلك أدخل البريد الإلكترونى بصورة صحيحة");
    theForm.femail.focus();
    return (false);
  }
if (theForm.femail.value.indexOf(".")== "-1")
  {
    alert("من فضلك أدخل البريد الإلكترونى بصورة صحيحة");
    theForm.femail.focus();
    return (false);
  }

  return (true);
}

//================ CHECK Comment ==================
function comment_Validator(theForm)
{
 if (theForm.name.value == "")
  {
    document.getElementById('em_msg').innerHTML ="من فضلك أدخل الاسم";
    theForm.name.focus();
    return (false);
  }

 if (theForm.email.value == "")
  {
    document.getElementById('em_msg').innerHTML ="أدخل البريد الإلكترونى";
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.indexOf("@")== "-1")
  {
    document.getElementById('em_msg').innerHTML ="البريد الإلكترونى غير صحيح";
    theForm.email.focus();
    return (false);
  }

 if (theForm.email.value.indexOf(".")== "-1")
  {
    document.getElementById('em_msg').innerHTML ="البريد الإلكترونى غير صحيح";
    theForm.email.focus();
    return (false);
  }

 if (theForm.title.value == "")
  {
    document.getElementById('em_msg').innerHTML ="من فضلك أدخل عنوان التعليق";
    theForm.title.focus();
    return (false);
  }

 if (theForm.comment.value == "")
  {
    document.getElementById('em_msg').innerHTML ="من فضلك أدخل التعليق";
    theForm.comment.focus();
    return (false);
  }

  return (true);
}

//================ CHECK contact US==================
function contact_Validator(theForm)
{
 if (theForm.name.value == "")
  {
    document.getElementById('em_msg').innerHTML ="من فضلك أدخل الاسم";
    theForm.name.focus();
    return (false);
  }

 if (theForm.email.value == "")
  {
    document.getElementById('em_msg').innerHTML ="أدخل البريد الإلكترونى";
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.indexOf("@")== "-1")
  {
    document.getElementById('em_msg').innerHTML ="البريد الإلكترونى غير صحيح";
    theForm.email.focus();
    return (false);
  }

 if (theForm.email.value.indexOf(".")== "-1")
  {
    document.getElementById('em_msg').innerHTML ="البريد الإلكترونى غير صحيح";
    theForm.email.focus();
    return (false);
  }

 if (theForm.title.value == "")
  {
    document.getElementById('em_msg').innerHTML ="من فضلك أدخل عنوان الموضوع";
    theForm.title.focus();
    return (false);
  }

 if (theForm.message.value == "")
  {
    document.getElementById('em_msg').innerHTML ="من فضلك أدخل نص الموضوع";
    theForm.message.focus();
    return (false);
  }
  if(document.getElementById('captcha').value == "") {
		//alert("عفوا!! الرجاء إدخال رمز التحقق");
		document.getElementById('em_msg').innerHTML =" عفوا!! الرجاء إدخال رمز التحقق ";
		document.getElementById('captcha').focus();
		return false;
	}

	if(document.getElementById('cap_code').value != document.getElementById('captcha').value) {
		//alert("OOPs !! Verification Code Mismatch");
		document.getElementById('em_msg').innerHTML =" عفوا!! عدم تطابق رمز التحقق ";
		document.getElementById('captcha').focus();
		return false;
	}

	if(document.getElementById('cap_code').value == document.getElementById('captcha').value) {
		//alert("Success: I have passed captcha validation......")
	}

  return (true);
}

 //================ CHECK TellYourFriends ==================
function TellYourFriends_Validator(theForm)
{
 if (theForm.name.value == "")
  {
    document.getElementById('em_msg').innerHTML ="من فضلك أدخل الاسم";
    theForm.name.focus();
    return (false);
  }

 if (theForm.email.value == "")
  {
    document.getElementById('em_msg').innerHTML ="أدخل البريد الإلكترونى";
    theForm.email.focus();
    return (false);
  }

  if (theForm.email.value.indexOf("@")== "-1")
  {
    document.getElementById('em_msg').innerHTML ="البريد الإلكترونى غير صحيح";
    theForm.email.focus();
    return (false);
  }

 if (theForm.email.value.indexOf(".")== "-1")
  {
    document.getElementById('em_msg').innerHTML ="البريد الإلكترونى غير صحيح";
    theForm.email.focus();
    return (false);
  }

  // Fmail

  if (theForm.femail.value == "")
  {
    document.getElementById('em_msg').innerHTML ="أدخل البريد الإلكترونى";
    theForm.femail.focus();
    return (false);
  }

  if (theForm.femail.value.indexOf("@")== "-1")
  {
    document.getElementById('em_msg').innerHTML ="البريد الإلكترونى غير صحيح";
    theForm.femail.focus();
    return (false);
  }

 if (theForm.femail.value.indexOf(".")== "-1")
  {
    document.getElementById('em_msg').innerHTML ="البريد الإلكترونى غير صحيح";
    theForm.femail.focus();
    return (false);
  }

  //title

 if (theForm.title.value == "")
  {
    document.getElementById('em_msg').innerHTML ="من فضلك أدخل عنوان الموضوع";
    theForm.title.focus();
    return (false);
  }
//message


 if (theForm.message.value == "")
  {
    document.getElementById('em_msg').innerHTML ="من فضلك أدخل نص الموضوع";
    theForm.message.focus();
    return (false);
  }

  return (true);
}

$(document).ready(function(){
    $("#table").hide();
    $("#open").click(function () {
	$("#table").toggle();
    });
  });
