
     var http_request_pray = false; 
      var http_request_pray_city = false; 
   
   function pray_ajax(f,x) { 
   		document.getElementById('pray-ajax').innerHTML = '<table width="100%" height="100%"><tr><td align="center"><img src="http://www.factway.net/images/loader.gif"  align="middle"/></td></tr></table>';
       if (window.XMLHttpRequest) { // Mozilla, Safari,... 
           http_request_pray = new XMLHttpRequest(); 
       } else if (window.ActiveXObject) { // IE 
           http_request_pray = new ActiveXObject("Microsoft.XMLHTTP"); 
       } 
       
       var city='39.49,21.26';
       if(x==1)
	       	city=document.getElementById('city').value;

       	var Long=city.substr(0,4);
      	var lat=city.substr(6,10);

       var gmt=document.getElementById('pray-country').value;
       
       	for(i=1;i<6;i++)
       		if(gmt.substr(i,1)=='%')
       			gmt=gmt.substr(0,i);      		      		
  		
       	var type;
       	if(document.getElementsByName('prayer_type')[0].checked)
       		type=1;
       	if(document.getElementsByName('prayer_type')[1].checked)
       		type=2;

       http_request_pray.onreadystatechange = alertContents_pray; 
       http_request_pray.open('get', f+'?long='+Long+'&lat='+lat+'&gmt='+gmt+'&type='+type,true); 
       http_request_pray.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=windows-1256"); 
	   http_request_pray.setRequestHeader ("Connection", "close");
       http_request_pray.send(null); 

   } 


   function alertContents_pray() { 

       if (http_request_pray.readyState == 4) { 
           if (http_request_pray.status == 200) { 
               document.getElementById('pray-ajax').innerHTML = http_request_pray.responseText;
           } else { 
                //document.getElementById('pray-ajax').innerHTML ='There was a problem with the request.'; 
           } 
       }
       
      }
      
      
      function pray_city_ajax(f) { 
   		document.getElementById('pray-ajax').innerHTML = '<table width="100%" height="100%"><tr><td align="center"><img src="http://www.factway.net/images/loader.gif"  align="middle"/></td></tr></table>';      
       if (window.XMLHttpRequest) { // Mozilla, Safari,... 
           http_request_pray_city = new XMLHttpRequest(); 
       } else if (window.ActiveXObject) { // IE 
           http_request_pray_city = new ActiveXObject("Microsoft.XMLHTTP"); 
       } 
       var country=document.getElementById('pray-country').value;
		
		for(i=1;i<6;i++)
			if(country.substr(i,1)=='%')
	       		country=country.substr(i+1,country.length-i+1);

       
       http_request_pray_city.onreadystatechange = alertContents_pray_city; 
       http_request_pray_city.open('get', f+'?country='+country,true); 
       http_request_pray_city.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=windows-1256"); 
	   http_request_pray_city.setRequestHeader ("Connection", "close");
       http_request_pray_city.send(null); 

   } 



   function alertContents_pray_city() { 

       if (http_request_pray_city.readyState == 4) { 
           if (http_request_pray_city.status == 200) { 
               document.getElementById('pray-city').innerHTML = http_request_pray_city.responseText;
                pray_ajax('prayertime.php',1);
           } else { 
                //document.getElementById('pray-ajax').innerHTML ='There was a problem with the request.'; 
           } 
       }
       
      }