function createRequestObject() {
	
	
	
	var ro;
	if (window.XMLHttpRequest) {
	  ro = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
	  ro = new ActiveXObject("Msxml2.XMLHTTP");
	}
	
	/**var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else{
		ro = new XMLHttpRequest();
	}
	**/
	return ro;
}

var http = createRequestObject();
var loadingGif = new Image();




function fs(fscal,fsdt){
	//alert(fsdt);
	loadingGif.src = 'http://www.alislam.org/archives/friday-sermons-images/loading.gif';
	fscal.hide;
	http.open('get', 'rpc.php?date='+fscal.currentDate.print("%Y-%m-%d"));
	http.onreadystatechange = handleResponse;
	http.send(null);
}

function handleResponse(){
	
	if(http.readyState == 0 || http.readyState == 1 || http.readyState == 2 || http.readyState == 3){
			document.getElementById("archived-sermon-links").innerHTML = "<img src=\"http://www.alislam.org/archives/friday-sermons-images/loading.gif\"><h4>loading...</h4>";
			window.setTimeout(displayLinks,1000);
	}
}

function displayLinks(){
	
	if(http.readyState == 4){
	var response = http.responseText;
	var update = new Array();

	
   
      
	

	  if(response.indexOf('%%')!= -1){
        	update = response.split('%%');
        	var str = "<div><h4>Text:</h4><ul>"+update[2]+"</ul></div>" +
					  "<div><h4>Audio:</h4><ul>"+update[3]+"</ul></div>" +
        			  "<div><h4>Video:</h4><ul>"+update[4]+"</ul></div>" ;
        	document.getElementById("archived-sermon-title").innerHTML = update[0];
        	document.getElementById("sermon-author").innerHTML = update[1];
        	document.getElementById("archived-sermon-links").innerHTML = str;
        	//document.getElementById("urdu-synopsis").innerHTML = "<div class=\"urd\">"+update[5]+"</div>";
        	
        	    

        	
        }
       


        
	}
}

function doNothing(){
	
}




