var xmlHttp;
var finished = true;
var is_response_ready = false;
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 CallServer() //Public method which is used in onClick events
{
	isAjaxSet();
	timestamp = new Date();
	var url = "3rd_parties/parser.php?timestamp=" + timestamp.getTime();
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = updatePage;
	xmlHttp.send(null);
}

function updatePage() //Handles the response of server
{
	finished = false;
	if(xmlHttp.readyState != 4)
	{
		show_alert_message("Gathering the responses...");
		is_response_ready = false;
	}
	if(xmlHttp.readyState == 4) //Loading completed
	{
		show_alert_message("Responses are completed...");		
		hide_alert_message();
		is_response_ready = true;		
		var response = xmlHttp.responseText;
		console(response);
	}	
}