
function setCookie ( cookieName, cookieVar, expiration, path )
{
	if ( !expiration ) expiration = 100 * 24 * 60 * 60;
	if ( !path ) path = '';
	
	var expireDate = new Date()
	
	expireDate.setDate ( expireDate.getDate ( ) + expiration );
	
	var Cookie = cookieName + "=" + escape( cookieVar );
	if ( expiration ) Cookie += ";expires=" + expireDate.toGMTString ( );
	if ( path ) Cookie += ";path=" + path;
	document.cookie = Cookie;
}

function getCookie ( cookieName )
{
	if ( document.cookie.length > 0 )
  {
		var cookieStart = document.cookie.indexOf ( cookieName + "=" )
		if ( cookieStart != -1 )
		{ 
			cookieStart = cookieStart + cookieName.length + 1; 
			cookieEnd = document.cookie.indexOf ( ";", cookieStart );
			
			if ( cookieEnd == -1 ) 
			{
				cookieEnd = document.cookie.length;
			}
			return unescape ( document.cookie.substring( cookieStart, cookieEnd ) );
		} 
	}
	return false;
}

function InitGUIElements ( )
{
	var i = document.body.getElementsByTagName ( 'input' );
	for ( var a = 0; a < i.length; a++ )
	{
		if ( i[ a ].type == 'text' && i[ a ].parentNode && i[ a ].parentNode.className == 'Text' )
		{
			i[ a ].onfocus = function ( )
			{
				this.parentNode.style.backgroundImage = 'url(gfx/gui_input_text_spanbackground_on.png)';
				this.style.backgroundImage = 'url(gfx/gui_input_text_background_on.png)';
			}
			i[ a ].onblur = function ( )
			{
				this.parentNode.style.backgroundImage = 'url(gfx/gui_input_text_spanbackground.png)';
				this.style.backgroundImage = 'url(gfx/gui_input_text_background.png)';
			}
		}
	}
}

function InitTopMenu ( )
{
	var i = document.getElementById ( 'top' ).getElementsByTagName ( 'IMG' );
	for ( var a = 0; a < i.length; a++ )
	{
		i[ a ].onmouseover = function ( )
		{
			this.b = this.src;
			this.src = this.src.replace ( '_off', '_over' );
			this.src = this.src.replace ( '_on', '_hover' );
		}
		i[ a ].onmouseout = function ( )
		{
			this.src = this.b;
		}
	}
	if ( document.getElementById ( 'PasswordForgotForm' ) )
	{
		document.getElementById ( 'PasswordForgotForm' ).style.display = 'none';
	}
}


function showForgotPassword ( )
{
	document.getElementById ( 'PasswordForgot' ).style.display = 'none';
	document.getElementById ( 'PasswordForgotForm' ).style.display = '';
}

/**
 * Some workarounds for crappy browsers
**/
var onloadfuncs = new Array ( );
window.onload = function ( )
{
	if ( navigator.userAgent.indexOf ( 'MSIE 6' ) > 0 )
	{
		if ( document.getElementById ( 'body' ).offsetHeight < document.getElementById ( 'rightCol' ).offsetHeight )
		{
			document.getElementById ( 'body' ).style.height = document.getElementById ( 'rightCol' ).offsetHeight + 'px';
		}
	}
	for ( var a = 0; a < onloadfuncs.length; a++ )
	{
		onloadfuncs[ a ] ( );
	}
}


function initBBConfig ( )
{
	if ( typeof ( BlestBox ) == 'undefined' ) 
	{
		setTimeout ( 'initBBConfig ( )', 5 );
	}
	else 
	{
		BlestBoxSet ( 'background-opacity', 0.8 );
		BlestBoxSet ( 'background-color', '#ffffff' );
		BlestBoxSet ( 'framebackground-color', '#ffffff' );
		BlestBoxSet ( 'barbackground-color', '#ffffff' );
		BlestBoxSet ( 'shadowbackground-color', '#000000' );
		BlestBoxSet ( 'graphics-path', 'gfx/' );
		BlestBoxSet ( 'background-zoom', false );
		BlestBoxSet ( 'use-styles', false );
		BlestBoxSet ( 'closeimage-text', "Lukk" );
		BlestBoxSet ( 'closepage-text', "Lukk" );
		BlestBoxSet ( 'graphics-path', "gfx/" );
		BlestBoxSet ( 'animation-path', "gfx/animation/" );
	}
}
initBBConfig ( );
