﻿function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
	function getState(countryId) {		
		
		var strURL="countries_data_provider.php?country="+countryId;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('statediv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
		function getState2(countryId) {		
		
		var strURL="countries_data_provider.php?id=2&country="+countryId;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('statediv2').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
	function getprayertime(stateId) {		
		var strURL="monasabat.php?content=7&city="+stateId;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('prayerdiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}

	function getweather(stateId) {		
		var strURL="monasabat.php?content=6&weather="+stateId;
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('weatherdiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
function prayerget(lat,longt,zone,area)
{

	var date = new Date(); // today
	var times = prayTime.getPrayerTimes(date,+lat,+longt,+zone);

	var str = '<table id="timetable">';
	str += '<tr><th colspan="2">اليوم في '+ area +'</th></tr>';
	for(var i = 0; i < times.length; i++)
	{
		str += '<tr><td>'+ prayTime.timeNames[i]+ '</td>';
		str += '<td>'+ times[i]+ '</td></tr>';
	}
	str += '</table>';
	document.getElementById('prayerdiv').innerHTML = str;
}
// open in new window 
function gettvlinks(){ 
newwindow=window.open("") 
newwindow.location=document.tv_form.tv_links.options [document.tv_form.tv_links.selectedIndex].value; 
} 
// open in new window 
function getforumlinks(){ 
newwindow=window.open("") 
newwindow.location=document.forum_form.forum_links.options [document.forum_form.forum_links.selectedIndex].value; 
}
// open in new window 
function getshialinks(){ 
newwindow=window.open("") 
newwindow.location=document.shia_form.shia_links.options [document.shia_form.shia_links.selectedIndex].value; 
}
// open in new window 
function getwaveslinks(){ 
newwindow=window.open("") 
newwindow.location=document.waves_form.waves_links.options [document.waves_form.waves_links.selectedIndex].value; 
}
