var xmlHttp;

function GetXmlHttpObject() {
	var xmlHttp=null;
	// Firefox, Opera 8.0+, Safari
	try {xmlHttp=new XMLHttpRequest();}
	// Internet Explorer
	catch (e) {
	  try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
	  catch (e) {xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
	}
	return xmlHttp;
}

function ajax_prep(x) {
	var str = x;
	str = str.replace(/#/gi, "%23");
	str = str.replace(/\+/gi, "%2B");
	str = str.replace(/\n/gi, "-BREAK-");
	str = escape(str);
	return str;
}

function loadCompany(id) {
	if(!id) {return;}
	
	xmlHttp = GetXmlHttpObject();
	if(xmlHttp==null) {return;}
	
	var url = "/top500/single-company/load_company.asp";
	var params = '';
	params = params + "task=load_company";
	params = params + "&id=" + id;
	params = params + "&sid=" + Math.random();
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState==4) {
			document.getElementById("shadow_div").innerHTML = xmlHttp.responseText;
			document.getElementById("shadow_div").style.display = 'block'
		}
	}
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
}

function closeCompany() {
	document.getElementById("shadow_div").innerHTML = '';
	document.getElementById("shadow_div").style.display = 'none';
}