var xmlHttp;
var img_id;
function isAjaxSet() //Checks if the ajax functions is set in browser
{
	xx = 0;
	xmlHttp = false;
	try
	{
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e2)
		{
			xmlHttp = false;
		}
	}
	if (!xmlHttp && typeof XMLHttpRequest != 'undefined')
		xmlHttp = new XMLHttpRequest();
	return xmlHttp;
}


function startWaiting ()
{
	document.getElementById('waiting').style.visibility ="visible";
}

function stopWaiting ()
{
	document.getElementById('waiting').style.visibility ="hidden";
}


function CallServer(urlx) //Public method which is used in onClick events
{
	isAjaxSet();
	var url = urlx;
	startWaiting();
	xmlHttp.open("GET", url, true);
	
	xmlHttp.onreadystatechange = updatePage;
	xmlHttp.send(null);
}

function updatePage() //Handles the response of server
{
	
	if(xmlHttp.readyState == 4) //Loading completed
	{
		stopWaiting();
		var response = xmlHttp.responseText;
		var params = response.split("#,");
		for (i=0; i<params.length; i++) {
			//alert(params[i]);
		}
		
		document.getElementById('picture').style.backgroundImage ="url(" + params[1] + ")";
		document.getElementById('content').innerHTML ="<strong>" + params[0] + "</strong></br ><br />";
		document.getElementById('content').innerHTML = document.getElementById('content').innerHTML+ params[2];
		
		
	}
	
}
