var onload_function = new Array();
var onresize_function = new Array();
var windowWidth = 0, windowHeight = 0;

function $get(element)
{	
	return document.getElementById(element);
}

function recalcSize()
{
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		windowWidth = window.innerWidth;
		windowHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
}

function loadScript(url, callback) 
{
	var f = arguments.callee;
	if (!("queue" in f))
		f.queue = {};
	var queue =  f.queue;
	if (url in queue) { // script is already in the document
		if (callback) {
			if (queue[url]) // still loading
				queue[url].push(callback);
			else // loaded
				callback();
		}
		return;
	}
	queue[url] = callback ? [callback] : [];
	var script = document.createElement("script");
	script.type = "text/javascript";
	script.onload = script.onreadystatechange = function() {
		if (script.readyState && script.readyState != "loaded" && script.readyState != "complete")
			return;
		script.onreadystatechange = script.onload = null;
		while (queue[url].length)
			queue[url].shift()();
		queue[url] = null;
	};
	script.src = url;
	document.getElementsByTagName("head")[0].appendChild(script);
}

function nl2br(str, is_xhtml) 
{
    breakTag = '<br />';
    if (typeof is_xhtml != 'undefined' && !is_xhtml) {
        breakTag = '<br>';
    }
    return (str + '').replace(/([^>]?)\n/g, '$1'+ breakTag);
}

function br2nl(str) 
{
    return (str + '').replace(/<br\s*\/?>/mg,"\n");
}

function objectSize(obj)
{
    var size = 0, key;
    for (key in obj) {
        if (obj.hasOwnProperty(key)) size++;
    }
    return size;
}

window.onload = function () 
{
  	if (!!(window.attachEvent && !window.opera)) {
  		document.body.className += ' ie';
  	} else if (!!window.opera) {
  		document.body.className += ' opera';
  	} else if (navigator.userAgent.indexOf('AppleWebKit/') > -1) {
  		document.body.className += ' webkit';
  	} else if (navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1) {
  		document.body.className += ' gecko';
  	} else if (!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)) {
  		document.body.className += ' iphone';
  	}
  	
  	recalcSize();
  	
	for (var ol_i = 0; ol_i < onload_function.length; ++ol_i) {
		onload_function[ol_i]();
	}
}
	
window.onresize = function () 
{
	recalcSize();
	for (var or_i = 0; or_i < onresize_function.length; ++or_i) {
		onresize_function[or_i]();
	}
}

function str_replace(suchen,ersetzen,string) 
{
	ausgabe = "" + string;
	while (ausgabe.indexOf(suchen)>-1) 
	{
		pos= ausgabe.indexOf(suchen);
		ausgabe = "" + (ausgabe.substring(0, pos) + ersetzen +
		ausgabe.substring((pos + suchen.length), ausgabe.length));
	}
	return ausgabe;
}
