function Trim(str,tchar)
{
	
    while (str.substring(0,1) == tchar) // check for white spaces from beginning
    {
        str = str.substring(1, str.length);
    }
    
    while (str.substring(str.length-1, str.length) == tchar) // check white space from end
    {
        str = str.substring(0,str.length-1);
    }
	
   
    return str;
}

 function PrintThisPage() {  
            var sOption = "toolbar=yes,location=no,directories=yes,menubar=yes,";  
            sOption += "scrollbars=yes,width=750,height=600,left=100,top=25";  
  
            var sTitle = document.getElementById('sah_main_title').innerHTML;
            var sBody = document.getElementById('sah_main_body').innerHTML;
            var sDate = document.getElementById('sah_item_date').innerHTML;    

  
            var winprint = window.open("", "", sOption);  
            winprint.document.open();  
            winprint.document.write('<html><head></head><body align=right dir=rtl>');  
            winprint.document.write('<h2>صحفي جو</h2>');
            winprint.document.write('<span align="right" dir="ltr">'+sDate+'</span>');
            winprint.document.write('<h1>'+sTitle+'</h1>');
            winprint.document.write(sBody);    
            winprint.document.write('</body></html>');  

          winprint.print();  
/*            window.focus(winprint);  
            window.print(winprint);  
             
          */
 }


function ajaxRequest(){
 var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
 if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
  for (var i=0; i<activexmodes.length; i++){
   try{
    return new ActiveXObject(activexmodes[i])
   }
   catch(e){
    //suppress error
   }
  }
 }
 else if (window.XMLHttpRequest) // if Mozilla, Safari etc
  return new XMLHttpRequest()
 else
  return false
}

function fill_latest_news(sitemid){


 var mypostrequest1=new ajaxRequest()
  mypostrequest1.onreadystatechange=function(){
  if (mypostrequest1.readyState==4){
    if (mypostrequest1.status==200 || window.location.href.indexOf("http")==-1){
    document.getElementById("headert").innerHTML=mypostrequest1.responseText
    }
    else{
    /*alert("An error has occured making the request")*/
    }
  }
  }

     
  mypostrequest1.open("post", "../commons/header.html", true)
  mypostrequest1.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
  mypostrequest1.send()


 var mypostrequest=new ajaxRequest()
  mypostrequest.onreadystatechange=function(){
  if (mypostrequest.readyState==4){
    if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
    document.getElementById("latest_news").innerHTML=mypostrequest.responseText
    }
    else{
    /*alert("An error has occured making the request")*/
    }
  }
  }

     
  mypostrequest.open("post", "../commons/latest_news.html", true)
  mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
  mypostrequest.send()


 

  var mypostrequest2=new ajaxRequest()
  mypostrequest2.onreadystatechange=function(){
  if (mypostrequest2.readyState==4){
    if (mypostrequest2.status==200 || window.location.href.indexOf("http")==-1){
    document.getElementById("footert").innerHTML=mypostrequest2.responseText
    }
    else{
    /*alert("An error has occured making the request")*/
    }
  }
  }

     
  mypostrequest2.open("post", "../commons/footer.php", true)
  mypostrequest2.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
  mypostrequest2.send()


  var mypostrequest3=new ajaxRequest()
  mypostrequest3.onreadystatechange=function(){
  if (mypostrequest3.readyState==4){
    if (mypostrequest3.status==200 || window.location.href.indexOf("http")==-1){
    document.getElementById("most_read_news").innerHTML=mypostrequest3.responseText
    }
    else{
    /*alert("An error has occured making the request")*/
    }
  }
  }

     
  mypostrequest3.open("post", "../commons/most_read.html", true)
  mypostrequest3.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
  mypostrequest3.send()


if (sitemid>0)
{     


var mypostrequest4=new ajaxRequest()
  mypostrequest4.onreadystatechange=function(){
  if (mypostrequest4.readyState==4){
    if (mypostrequest4.status==200 || window.location.href.indexOf("http")==-1){
    1==1
    }
    else{
    /*alert("An error has occured making the request")*/
    }
  }
  }

  mypostrequest4.open("post", "../commons/update_news_hits.php", true)
  mypostrequest4.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
  mypostrequest4.send("id="+sitemid)

}

var mypostrequest5=new ajaxRequest()
  mypostrequest5.onreadystatechange=function(){
  if (mypostrequest5.readyState==4){
    if (mypostrequest5.status==200 || window.location.href.indexOf("http")==-1){
     document.getElementById("flash_news").innerHTML=mypostrequest5.responseText
    }
    else{
    /*alert("An error has occured making the request")*/
    }
  }
  }

     
  mypostrequest5.open("post", "../commons/breaknews.php", true)
  mypostrequest5.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
  mypostrequest5.send()




var mypostrequest6=new ajaxRequest()
  mypostrequest6.onreadystatechange=function(){
  if (mypostrequest6.readyState==4){
    if (mypostrequest6.status==200 || window.location.href.indexOf("http")==-1){
     document.getElementById("social_media_box").innerHTML=mypostrequest6.responseText
    }
    else{
    /*alert("An error has occured making the request")*/
    }
  }
  }

     
  mypostrequest6.open("post", "../commons/sahafi_sm_box.php", true)
  mypostrequest6.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
  mypostrequest6.send()







//  alert(parameters);
}



