/**
* init function after page load
*/
function InitPage()
{
	InitTooltips();
	return true;
}


function InitTooltips()
{
	var input = $('content').select('.siteform input');
	for(var i=0;i<input.length;i++){
		input[i].onfocus = function(){
			if(this.type=='text'){
				Element.addClassName(this.parentNode,'active');				
				this.nextSibling.nextSibling.style.display = 'block';
			}
		}
		
		input[i].onblur = function(){
			if(this.type=='text'){
				Element.removeClassName(this.parentNode,'active');
				if(!Element.hasClassName(this.parentNode,'error')){
					this.nextSibling.nextSibling.style.display = 'none';
				}
			}
		}
	}	
}

function MakeSifr() {
	sIFR_Prepare("#tabs-box h2");
	
	sIFR.replaceElement(named({sSelector:"#content h2", sFlashSrc:"/pics/frutiger.swf", sColor:"#666666", sBgColor:"#FFFFFF" }));
	return false;
}

function sIFR_Prepare(Item) { 
    $$(Item+".sIFR-replaced").each(function(obj){
		obj.removeClassName("sIFR-replaced");
	});
}



/**
* open accessible popup
*
* @param	string		url
* @return	boolean		always false
*/
function Popup (url) {
	var newwindow	= window.open(url, "popup","width=400,height=550,menubar=no,location=no,status=no,scrollbars=yes,toolbar=yes,resizable=yes");
	newwindow.focus();
	return false;
}

/**
* simulates target blank in an accessible way
*
* use links: <a href="http://www.triple-i.de" onclick="return TargetBlank(this.href)">Link</a>
*
* @param	string		url
* @return	boolean		always false
*/
function TargetBlank (url) {
	var newwindow	= window.open(url, "newwindow"+String(Math.round(Math.random()*10)),"menubar=yes,location=yes,status=yes,scrollbars=yes,toolbar=yes,resizable=yes");
	newwindow.focus();
	return false;
}

/*
* Close a window and optionally focus on opener.
*
* @param	boolean 	wether or not to focus on window opener
*/
function CloseWindow(focusopener) {
	if(typeof(focusopener)=="undefined") { var focusopener=false; }
	if(focusopener&&window.opener) { window.opener.focus(); }
	window.close();
}

/**
* center a popup window on screen
*
* @param    object  window object (optional)
*/
function CenterPopup(win) {
	if(typeof(win)=='undefined'||win=='') { var win=window; }
	
	win_width	= GetDocumentWidth(win);
	win_height	= GetDocumentHeight(win);
	
	win.moveTo(screen.width/2-win_width/2,screen.height/2-win_height/2,win);
}

/**
* Creates a cookie
*
* @param	string		name of the cookie
* @param	string		value
* @param	integer		number of days till expires
*/
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=/";
}

/**
* read a cookie by name
*
* @param	string		name of cookie
* @return	string		get value of cookie
*/
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;
}

/**
* erase a cookie by name
*
* @param	string		name of cookie
*/
function EraseCookie(name) {
	CreateCookie(name,"",-1);
}

