/*function get_cookie(name)
{
    var dc = document.cookie;	
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}*/

function fix_ie_hover_nav()
{
	if (document.all&&document.getElementById) 
	{
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) 
		{
			with(navRoot.childNodes[i])
			{
				if (nodeName=="LI") 
				{
					onmouseover=function() { this.className = "hover"; }
  					onmouseout=function() { this.className=""; }
   				}
			}
 		}
	}
}
 /* adds roll-over effect for games sections */
function fix_ie_hover_games()
{
	if(document.all&&document.getElementById)
	{
		roots = new Array(2);
		roots[0] = 'game_type_group';
		roots[1] = 'game_pictures';
		for(n=0;n<roots.length;n++)
		{
			gamesRoot = document.getElementById(roots[n]);
			if(gamesRoot)
			{
				for(i=0;i<gamesRoot.childNodes.length;i++)
				{
					with(gamesRoot.childNodes[i])
					{
						if(nodeName=="A")
						{ 
							onmouseover = function() { i = 5; find_div = this; while(find_div.nodeName != 'DIV' && i--) find_div = find_div.nextSibling; if(i) find_div.className += " hover"; }
							onmouseout = function()  { i = 5; find_div = this; while(find_div.nodeName != 'DIV' && i--) find_div = find_div.nextSibling; if(i) find_div.className = find_div.className.substring(0,find_div.className.length-5); }
						}
					}
				}
			}
		}
	}
}

function set_currency(x,y)
{
	old_currency = get_cookie('currency');
	document.cookie = "currency=" + x;
	bodytag = document.getElementsByTagName("body")[0];
	if(y) {
		with(bodytag)
			className = className.substring(0,className.length - old_currency.length);
		location.reload();
	}
	bodytag.className += (" " + x);
}

function setup_currency_nav()
{
	ctag = document.getElementById("usd").childNodes[0];
	if(ctag)
		ctag.onclick = function() { set_currency('usd',true); }
	ctag = document.getElementById("euro").childNodes[0];
	if(ctag)
		ctag.onclick = function() { set_currency('euro',true); }
	ctag = document.getElementById("pound").childNodes[0];
	if(ctag)
		ctag.onclick= function() { set_currency('pound',true); }
	ctag = document.getElementById("yen").childNodes[0];
	if(ctag)
		ctag.onclick = function() { set_currency('yen',true); }
}
do_onloads = function() 
{
	fix_ie_hover_nav();
	//fix_ie_hover_games();
	//currency = get_cookie('currency');
	//if(!currency) currency = 'usd';
	//set_currency(currency,false);
	//setup_currency_nav();
}
doreload = function()
{
	location.reload();
}
window.onload=do_onloads;
window.onresize = doreload;