//GXMLHTTPRequest is the variable to sync AJAX requests
var GXMLHTTPRequest;
function callPage(newlink,targetDivId) {
	showLoadingImg('loading_div');
	var jqxhr = $.ajax({
  		url: newlink,
  		cache: false,
  		beforeSend: function(jqXHR,settings) {
  			GXMLHTTPRequest = jqXHR;
  		},
  		success: function(html,status,jqXHR){
    		if (GXMLHTTPRequest == jqXHR){
    			document.getElementById(targetDivId).innerHTML = html;
				hideLoadingImg('loading_div');
				if (randomnumber == 0){
					$("#target").fadeIn(4000);
				} 
				if (randomnumber == 1){
					$(".left_pane,.right_pane").show("slide", { direction: "up" }, 1000);
				}
				if (randomnumber == 2){
					$(".left_pane,.right_pane").show("slide", { direction: "right" }, 1000);
				}				
    		}
  		}
	});
}
function showLoadingImg(divId) {
	var screenX=document.width/2-50;
	document.getElementById(divId).style.display="block";
    document.getElementById(divId).style.left=screenX+"px";
    document.getElementById(divId).style.top="400px";
	document.getElementById(divId).style.display="block";
}
function hideLoadingImg(divId) {
	document.getElementById(divId).style.display="none";
}
