function createRequestObject() {
   var req;
   if(window.XMLHttpRequest){
      req = new XMLHttpRequest();
   } else if(window.ActiveXObject) {
      req = new ActiveXObject("Microsoft.XMLHTTP");
   } else {
      alert('حدث خطأ عند محاوله تنفيذ هذا الاستعلام ، متصفحك لا يدعم تقنيه الاجاكس');
   }
   return req;
}
var http = createRequestObject();
function doLogin(){
var user  = document.getElementById('panel_username').value;
var pass  = document.getElementById('panel_password').value;
var url="ajax.php"
url=url+"?action=login"
url=url+"&user="+user
url=url+"&pass="+pass
 	
   http.open('get',url, true);
   http.onreadystatechange = handleLgoin;
   http.setRequestHeader('Content-Type', 'text/html; charset:windows-1256'); 
   http.send(null);
}
function handleLgoin() {
   var ajaxLogin = document.getElementById("ajaxLogin");
   ajaxLogin.innerHTML = '<img border="0" src="http://localhost/al-3geb_v2/template/web2/imgs/loading.gif">';
   if(http.readyState == 4 && http.status == 200){
      var response = http.responseText;
      if(response) {
         ajaxLogin.innerHTML = response;
      }
   } 
}
function creatAccount() {
var user  = document.getElementById('panel_username').value;
var email = document.getElementById('panel_email').value;
var url="ajax.php"
url=url+"?action=newAccount"
url=url+"&user="+user
url=url+"&email="+email
   http.open('get',url, true);
   http.onreadystatechange = handleNew;
   http.setRequestHeader('Content-Type', 'text/html; charset:windows-1256'); 
   http.send(null);
}
function handleNew() {
   var ajaxNew = document.getElementById("ajaxNew");
   ajaxNew.innerHTML = '<img border="0" src="http://localhost/al-3geb_v2/template/web2/imgs/loading.gif">';
   if(http.readyState == 4 && http.status == 200){
      var response = http.responseText;
      if(response) {
         ajaxNew.innerHTML = response;
      }
   }  
}
function RessetPassword() {
var email = document.getElementById('panel_email').value;
var url="ajax.php"
url=url+"?action=ressetPassword"
url=url+"&email="+email   
   http.open('get',url, true);
   http.onreadystatechange = handleResset;
   http.setRequestHeader('Content-Type', 'text/html; charset:windows-1256'); 
   http.send(null);
}
function handleResset() {
   var ajaxResset = document.getElementById("ajaxResset");
   ajaxResset.innerHTML = '<img border="0" src="http://localhost/al-3geb_v2/template/web2/imgs/loading.gif">';
   if(http.readyState == 4 && http.status == 200){
      var response = http.responseText;
      if(response) {
         ajaxResset.innerHTML = response;
      }
   }  
}

function getVote(int) {
var email = document.getElementById('panel_email').value;
var url="ajax_vote.php"
url=url+"?action=do"
url=url+"&email="+email
url=url+"&a1="+int       
   http.open('get',url, true);
   http.onreadystatechange = stateChanged;
   http.setRequestHeader('Content-Type', 'text/html; charset:windows-1256'); 
   http.send(null);
}
function stateChanged() 
{ 
 if (http.readyState==0 || http.readyState==1  || http.readyState==2 || http.readyState==3)
 { 
 var msg='<img border="0" src="http://localhost/al-3geb_v2/template/web2/imgs/loading.gif">';
 document.getElementById("poll").innerHTML=msg;
 } 
 if (http.readyState==4 || http.readyState=="complete")
 { 
 document.getElementById("poll").innerHTML=http.responseText;
 

 } 
}


function startclock(){
var thetime=new Date();
var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var nday=thetime.getDay();
var nmonth=thetime.getMonth();
var ntoday=thetime.getDate();
var nyear=thetime.getYear();
var AorP=" ";

if (nhours>=12)
    AorP="مساءً";
else
    AorP="صباحاً";

if (nhours>=13)
    nhours-=12;

if (nhours==0)
   nhours=12;

if (nsecn<10)
 nsecn="0"+nsecn;

if (nmins<10)
 nmins="0"+nmins;

if (nday==0)
  nday="الأحد";
if (nday==1)
  nday="الاثنين";
if (nday==2)
  nday="الثلاثاء";
if (nday==3)
  nday="الأربعاء";
if (nday==4)
  nday="الخميس";
if (nday==5)
  nday="الجمعة";
if (nday==6)
  nday="السبت";
nmonth+=1;

if (nmonth==1)
nmonth="يناير";  
if (nmonth==2)
nmonth="فبراير";
if (nmonth==3)
nmonth="مارس";
if (nmonth==4)
nmonth="أبريل";
if (nmonth==5)
nmonth="مايو";
if (nmonth==6)
nmonth="يونيو";
if (nmonth==7)
nmonth="يوليو";
if (nmonth==8)
nmonth="أغسطس";
if (nmonth==9)
nmonth="سبتمبر";
if (nmonth==10)
nmonth="أكتوبر";
if (nmonth==11)
nmonth="نوفبمر";
if (nmonth==12)
nmonth="ديسمبر";

if (nyear<=99)
  nyear= "19"+nyear;

if ((nyear>99) && (nyear<2000))
 nyear+=1900;

document.getElementById("time").innerHTML = nday+" "+ntoday+" "+nmonth+" "+nyear+" - "+nsecn+": "+nmins+": "+nhours+" "+AorP;

setTimeout('startclock()',1000);

} 




function sendRequestGet(){
var newemail  = document.getElementById('newmail').value;
var type  = document.getElementById('type').checked;
var url="maillist.php"
url=url+"?action=add"
url=url+"&idx="+newemail 
url=url+"&type="+type
 	
   http.open('get',url, true);
   http.onreadystatechange = handleMaillist;
   http.setRequestHeader('Content-Type', 'text/html; charset:windows-1256'); 
   http.send(null);
}
function handleMaillist() {
   var ajaxmaillist = document.getElementById("ajaxmaillist");
   ajaxmaillist.innerHTML = '<img border="0" src="http://localhost/al-3geb_v2/template/web2/imgs/loading.gif">';
   if(http.readyState == 4 && http.status == 200){
      var response = http.responseText;
      if(response) {
         ajaxmaillist.innerHTML = response;
      }
   } 
}



function sendMobGet(){
var newmob  = document.getElementById('newmob').value;
var type  = document.getElementById('type2').checked;
var url="moblist.php"
url=url+"?action=add"
url=url+"&idx="+newmob 
url=url+"&type="+type
 	
   http.open('get',url, true);
   http.onreadystatechange = handleMoblist;
   http.setRequestHeader('Content-Type', 'text/html; charset:windows-1256'); 
   http.send(null);
}
function handleMoblist() {
   var ajaxMoblist = document.getElementById("ajaxMoblist");
   ajaxMoblist.innerHTML = '<img border="0" src="http://localhost/al-3geb_v2/template/web2/imgs/loading.gif">';
   if(http.readyState == 4 && http.status == 200){
      var response = http.responseText;
      if(response) {
         ajaxMoblist.innerHTML = response;
      }
   } 
}
