
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>";
    }
    if(http.readyState == 4){
        var response = http.responseText;
        document.getElementById(hLstID).innerHTML = response;
		//document.getElementById('Loading').style.display='none';
    }
}
// ==== Style Sheet ====
function highlightButton(s) 
{
	if(document.all) 
		event.srcElement.className=s
}
// ==== 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.email.focus();
    return (false);
  }

  return (true);
}
//===========================================
function ShowAuthor(AlphaID){
    getInfo('GetArticle_Ajax.php?AlphaID='+AlphaID, 'lstDiv');
	document.getElementById('Pager').style.display='none';
}

function ShowLecturer(AlphaID){
    getInfo('GetSound_Ajax.php?AlphaID='+AlphaID, 'lstDiv');
	document.getElementById('Pager').style.display='none';
}

//================ ------- ==================
function PrintIt(prID){
	window.ExecWB (6, 0);
	alert("OK");
}
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;
}
//================ ------- ==================
function printSubject(id){				
window.open('printSubject.php?ID='+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 printArticle(id){				
window.open('printArticle.php?ID='+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 TellYourFriend(id){				
window.open('TellYourFriends.php?'+id,"",'toolbar=no,location=yeas,directories=no,status=no,menubar=no,scrollbars=yes,close=0,resizable=yes,copyhistory=yeas,width=468,height=410,left=10,top=10,border=0' ).focus();			
}
//================ 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;
}
