var http_request = false;
function makeRequest(url, parameters) {
	//alert(parameters);
  http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
	 http_request = new XMLHttpRequest();
	 if (http_request.overrideMimeType) {
		// set type accordingly to anticipated content type
		//http_request.overrideMimeType('text/xml');
		http_request.overrideMimeType('text/html');
	 }
  } else if (window.ActiveXObject) { // IE
	 try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
		try {
		   http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	 }
  }
  if (!http_request) {
	 alert('Cannot create XMLHTTP instance');
	 return false;
  }
  http_request.onreadystatechange = changeContents;
  http_request.open('GET', url + parameters, true);
  http_request.send(null);
}

function changeContents() {
  if (http_request.readyState == 4) {
	result = http_request.responseText;
	if(document.getElementById('promo-light-box')) {
		document.getElementById('promo-light-box').parentNode.removeChild(document.getElementById('promo-light-box'));
	}
	if(document.getElementById('leftcol')) {
		document.getElementById('leftcol').innerHTML = result;
	}
  }
  else {
  	if(!document.getElementById('promo-light-box')) {
		var lbox = document.createElement('div');
		lbox.id = 'promo-light-box';
		lbox.style.width = document.body.clientWidth+'px';
		lbox.style.height = document.body.clientHeight+'px';
		document.getElementsByTagName('body')[0].insertBefore(lbox,document.getElementsByTagName('body')[0].firstChild);
		var loadimg = document.createElement('img');
		loadimg.id = 'loading-image';
		loadimg.src = iconurl+'transparent-loading-bar.gif';
		loadimg.style.left = ((document.documentElement.clientWidth/2)-110)+'px';
		loadimg.style.top = ((document.documentElement.clientHeight/2)-10)+'px';
		document.getElementById('promo-light-box').appendChild(loadimg);
	}
  }
}

function loadPromo(pid,plink) {
	var getstr = '?frontpage=true';
	if(pid != undefined) {
		getstr += '&promoid='+pid;
	}
	makeRequest('/wsce-promos.php', getstr);
/*	window.location.hash = plink;*/
}
