
// js rules
// var = nur innerhalb funktion gueltig
// ohne var global

// from scriptsDetection.js
// BrowserDetect.browser;
// BrowserDetect.version;
// BrowserDetect.OS;

/**
* Function : dump()
* Arguments: The data - array,hash(associative array),object
* The level - OPTIONAL
* Returns  : The textual representation of the array.
* This function was inspired by the print_r function of PHP.
* This will accept some data as the argument and return a
* text that will be a more readable version of the
* array/hash/object that is given.
*/

function dump(arr, level)
 {
    var dumped_text = "";
    if (!level) level = 0;

    //The padding given at the beginning of the line.
    var level_padding = "";
    for (var j = 0; j < level + 1; j++) level_padding += "    ";

    if (typeof(arr) == 'object') {
        //Array/Hashes/Objects
        for (var item in arr) {
            var value = arr[item];

            if (typeof(value) == 'object') {
                //If it is an array,
                dumped_text += level_padding + "'" + item + "' ...\n";
                dumped_text += dump(value, level + 1);

            } else {
                dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";

            }

        }

    } else {
        //Stings/Chars/Numbers etc.
        dumped_text = "===>" + arr + "<===(" + typeof(arr) + ")";

    }
    return dumped_text;
}

function blockError(){
	return true;
}

function getHost(mode)
{
	theHost = window.location.hostname;

	if(theHost.indexOf("localhost") != -1 || theHost.indexOf("testkunde.de") != -1)
	{

		if (mode == undefined || mode == '' || mode == 0) {
			window.status = '';
		} else {
			window.status = theHost.toLowerCase() + ' - ' + BrowserDetect.browser + ' ' +BrowserDetect.version + ' on ' +BrowserDetect.OS;
		}

	} else {

		window.onerror = blockError;

		if (mode == undefined || mode == '' || mode == 0) {
			window.status = '';
		} else {
			window.status = theHost.toLowerCase();
		}
	}

	//alert(theHost.toLowerCase() + ' - ' + BrowserDetect.browser + ' ' +BrowserDetect.version + ' on ' +BrowserDetect.OS);
	return theHost.toLowerCase();
}

function switchImage(imgName, imgSrc)
{
	if (document.images)
	{
		if (imgSrc != "none")
		{
			document.images[imgName].src = imgSrc;
		}
	}
}

function BlurLinks()
{
	linkArray = new Array();
	lnks = document.getElementsByTagName('a');
	for(i=0;i<lnks.length;i++){
		lnks[i].onfocus=new Function("if(this.blur)this.blur()");
	}
}

function setCookie(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 getCookie(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 deleteCookie(name)
{
	createCookie(name,"",-1);
}

function UnCryptMailto(s, shift)
{
	var n=0;
	var r="";
	for(var i=0;i<s.length;i++) {
		n=s.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(shift));
	}
	return r;
}

function linkTo_UnCryptMailto(s, shift)
{
	location.href=UnCryptMailto(s, shift);
}

function openWindow(url,name,w,h)
{
  var win = null;
  LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
  TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
  settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes';
  win = window.open(url,name,settings);
}

function upLoader()
{
	BlurLinks();
	getHost(1);
}

onload=upLoader;
