
function hypeEvent(event, lang) {
	// Obtain an XMLHttpRequest instance
	var req = newXMLHttpRequest();

	// Set the handler function to receive callback notifications
	// from the request object
	var handlerFunction = getReadyStateHandler(req, updateHyped);
	req.onreadystatechange = handlerFunction;

	// Open an HTTP POST connection to the hype servlet.
	// Third parameter specifies request is asynchronous.
	req.open("POST", "modules/calendar/ajax/hypeevent.php", true);

	// Specify that the body of the request contains form data
	req.setRequestHeader("Content-Type", 
					   "application/x-www-form-urlencoded");

	// Send form encoded data stating that I want to add the 
	// specified item to the cart.
	req.send('action=hype&id='+event +'&lang=' + lang);
	
	// Set Cookie
	if (getCookie('hyped') == null) {
		setCookie('hyped', lang + '_' + event, 1);
	} else {
		setCookie('hyped', getCookie('hyped') + ',' + lang + '_' + event, 1);			
	}
}

function updateHyped(pageXML) {
	// Get the root "cart" element from the document
	var page = pageXML.getElementsByTagName("event")[0];
	// Update the cart's total using the value from the cart document
	document.getElementById("hypetotal").style.fontSize = 
	( Math.log(page.getAttribute("total"))*Math.LOG10E  >= 3 ? Math.round(70 / (Math.floor(Math.log(page.getAttribute("total")) * Math.LOG10E )) * 10)/10 + 'px' : '35px' );
	document.getElementById("hypetotal").innerHTML = page.getAttribute("total");
	document.getElementById("hypelink").innerHTML = "<img src=\"modules/calendar/images/hyped.png\" width=\"94\" height=\"30\" border=\"0\" alt=\"\" />";
	if (page.getAttribute("total") == 1)
		document.getElementById("hypetext").innerHTML = 'Hype';
	if (page.getAttribute("total") == 2)
		document.getElementById("hypetext").innerHTML = 'Hypes';	
}

function showLayer(layerName)
{
	if (document.getElementById) // Netscape 6 and IE 5+
	{
		var targetElement = document.getElementById(layerName);
		targetElement.style.visibility = 'visible';
	}
}					

function hideLayer(layerName)
{
	if (document.getElementById) 
	{
		var targetElement = document.getElementById(layerName);
		targetElement.style.visibility = 'hidden';
	}
}
