var firstClick = 0;

function load(container, target) {

	document.getElementById('ajax-box').style.display = 'block';

	switch(target) {
	case 'publishers-demo.php':
		//Change Tab
		document.getElementById('howTab1').style.backgroundPosition = 'top center';
		document.getElementById('howTab2').style.backgroundPosition = 'bottom center';
		document.getElementById('howTabA1').style.paddingTop = '0px';
		document.getElementById('howTabA2').style.paddingTop = '2px';
	break;
	case 'publishers_youtube-dom.php':
		//Change Tab
		document.getElementById('howTab1').style.backgroundPosition = 'bottom center';
		document.getElementById('howTab2').style.backgroundPosition = 'top center';
		document.getElementById('howTabA1').style.paddingTop = '2px';
		document.getElementById('howTabA2').style.paddingTop = '0px';
	break;
	default:
		alert("You shouldn't be seeing this, something went wrong.");
	}
	

	//Display loading indicator
	document.getElementById(container).innerHTML = "<html><body><center><img src='/imgs/newcss/yt-load.gif' height='32' width='32' alt='loading' style='margin-top: 50px;' /><br /><span style='color: #FF6F00; font-size: 14px;'>loading</span></center></body></html>";
	try {
		//Attempt to load ActiveX Socket in IE first, if fails, then attempt XMLHttp in Firefox/Webkit
		httpSocket = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP");
	} catch (e) {
		//Old browser, kill it
		alert("It appears that your browser does not support AJAX, please update your browser to its latest version");
	}

	httpSocket.onreadystatechange = function(){
		pageCheck(httpSocket, container)		
	}
	
	httpSocket.open('GET', target, true)

	//IE Requires Return :P Damn you microsoft!!
	httpSocket.send(null)

}

function pageCheck(pageRequest,container) {
	if (pageRequest.readyState == 4 && (pageRequest.status == 200 || window.location.href.indexOf("http")==-1)) {
	  document.getElementById(container).innerHTML = pageRequest.responseText
	}
}