var responseObj = '';
var serverDir = "https://www.desktopshark.com/control/controller/webServices.php";

function playSound(soundfile) {
	//document.getElementById("dummy").innerHTML='<embed src="' + soundfile + '" hidden="true" autostart="true" loop="false" />';
}

// Generates a random number so that the page requested isn't cached.
function randomNumber(){
	var now = new Date();
	var seed = now.getSeconds();
	return Math.round(Math.random(seed)*10000000000000000);
}

// Creats a new xmlHttp Object
function GetXmlHttpObject(){
	var xmlHttp=null;
	try{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e){
	    // Internet Explorer
		try{
    		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    	}
    	catch (e){
    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
  	}
	return xmlHttp;
}

function resizePage(size){
	document.getElementById('main').style.height = (size+348) + "px";
	document.getElementById('content').style.height = size + "px";
}

function sendServerRequest(classObj,methodObj,parametersObj,obj){
	var url = serverDir + "?class=" + classObj + "&method=" + methodObj + "&parameters=" + parametersObj + "&sid=" + randomNumber();
	var xmlHttp2=GetXmlHttpObject();
	if (xmlHttp2==null) alert ("Your browser does not support AJAX!");
	xmlHttp2.onreadystatechange= function(){
		if (xmlHttp2.readyState==4){
			if(xmlHttp2.responseText != ""){
				 document.getElementById(obj).innerHTML = xmlHttp2.responseText;
			}
		}
	};
	xmlHttp2.open("GET",url,true);
	xmlHttp2.send(null);
}

function StopLoading(){
	document.getElementById('loadbox').style.display = 'none';
}

// Sends Request to page
function sendPageRequest(url, obj){
	document.getElementById('loadbox').style.display = '';
	var xmlHttp1=GetXmlHttpObject();
	//alert(url);
	if (xmlHttp1==null) alert ("Your browser does not support AJAX!");
	xmlHttp1.onreadystatechange= function(){
		if (xmlHttp1.readyState==4){
			if(xmlHttp1.responseText != ""){
				 document.getElementById(obj).innerHTML = xmlHttp1.responseText;
				 setTimeout("StopLoading()", 1000);
			}
		}
	};
	//alert(url);
	xmlHttp1.open("GET",url + (url.search("\\?") > -1 ? "&sid=" : "?sid=") + randomNumber(),true);
	xmlHttp1.send(null);
} 