var xmlHttp

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function showBodyText(str, anchor)
{
	if ((str == "home") || (!anchor) || (anchor == ""))
		{ bg = 3; }
	else
	{
		bg = readCookie("background");
		if (bg != null)
		{
			bg = parseInt(bg) + 1;
			if (bg > 3) { bg = 1; }
		}
		else
		{
			bg = 3;
		}
	}
	createCookie("background", bg, 7);
	document.getElementById("mainTable").background="img/innoteam"+bg+".png";

	if (anchor)
	{
		createCookie("anchor", anchor, 1);
	}
	if (anchor && (anchor != null) && (anchor != ""))
	{
		hash = "#" + anchor;
	}
	else
	{
		hash = "";
	}
	window.location = window.location.protocol + "//" + window.location.hostname + window.location.pathname+ "?q=" + str + hash;
}

function stateChanged()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		window.offscreenBuffering=true;

		blocks = xmlHttp.responseText.split("|");

		selectedElement = blocks[0].replace(/^\s+|\s+$/g, '') ;

		if (selectedElement=="news")
		{
			i = 0;
			while (i < 3)
			{
				i = i + 1;
			}
		}
		else
		{
			alert("start");
			leftmenu = document.getElementsByTagName('LeftMenu');
			i = 0;
			alert(leftmenu.length);
			while (i < leftmenu.length)
			{
				if (leftmenu[i].id == selectedElement)
					leftmenu[i] = "LeftMenuItemSelected";
				else
				{
					if (leftmenu[i].className == "LeftMenuItemSelected")
						leftmenu[i] = "LeftMenuItem";
				}
				i = i + 1;
			}
		}
		anchor = readCookie("anchor");
		if (anchor)
		{
			document.location.hash = anchor;
			eraseCookie("anchor");
		}
 	}
}
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

