function getHTTPObject() {
	if (window.ActiveXObject)
		return new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest)
		return new XMLHttpRequest();
	else {      
		alert("Your browser does not support AJAX.");
		return null;   
	}
}

function hangman(diff, hangman_gameID, letter, frm) {
	httpObject = getHTTPObject();
   	    	
   	if (httpObject != null) {
		var now = new Date();
   	
		var fullURL = 'game.php?d=' + escape(diff) + '&hangman_gameID=' + escape(hangman_gameID) + '&letter=' + escape(letter) + '&ts=' + now.getTime();
   			
		httpObject.open("GET", fullURL, true);
		httpObject.send(null);
		httpObject.onreadystatechange = hangman_handler;
	}
}

function hangman_handler() {
	if (httpObject.readyState == 4) {
		document.getElementById("game_div").innerHTML = httpObject.responseText;
	}
}

function get_help(diff, hangman_gameID, letter, frm) {
	httpObject = getHTTPObject();
   	    	
   	if (httpObject != null) {
		var now = new Date();
   	
		var fullURL = 'game.php?d=' + escape(diff) + '&hangman_gameID=' + escape(hangman_gameID) + '&letter=' + escape(letter) + '&ts=' + now.getTime();
   			
		httpObject.open("GET", fullURL, true);
		httpObject.send(null);
		httpObject.onreadystatechange = hangman_handler;
	}
}

function hangman_handler() {
	if (httpObject.readyState == 4) {
		document.getElementById("game_div").innerHTML = httpObject.responseText;
	}
}

function toggleLayer(whichLayer) {
  	var elem, vis;
  
	if(document.getElementById) // this is the way the standards work
    		elem = document.getElementById(whichLayer);
  	else if(document.all) // this is the way old msie versions work
      		elem = document.all[whichLayer];
  	else if(document.layers) // this is the way nn4 works
    		elem = document.layers[whichLayer];
  
	vis = elem.style;
  	
  	// if the style.display value is blank we try to figure it out here
  	if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    		vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  
	vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function preload_hangman_images() {
	var img0 = new Image();
	img0.src = "/horror_hangman/images/hangman/0.jpg";

	var img1 = new Image();
	img1.src = "/horror_hangman/images/hangman/1.jpg";

	var img2 = new Image();
	img2.src = "/horror_hangman/images/hangman/2.jpg";

	var img3 = new Image();
	img3.src = "/horror_hangman/images/hangman/3.jpg";

	var img4 = new Image();
	img4.src = "/horror_hangman/images/hangman/4.jpg";

	var img5 = new Image();
	img5.src = "/horror_hangman/images/hangman/5.jpg";

	var img6 = new Image();
	img6.src = "/horror_hangman/images/hangman/6.jpg";
}

