

function urlencode( str ) {
	// http://kevin.vanzonneveld.net
    var histogram = {}, histogram_r = {}, code = 0, tmp_arr = [];
    var ret = str.toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urldecode.
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);
    
    for (search in histogram) {
        replace = histogram[search];
        ret = replacer(search, replace, ret) // Custom replace. No regexing
    }
    
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
    
    return ret;
}

Array.prototype.indexOf = function (element)
{
    var l = this.length;
    this[-1] = element;
    while(this[--l] !== element);
    delete this[-1];
    return l;   
}
Array.prototype.inArray = function (element)
{
    return (this.indexOf(element) !== -1);
}


	loadedobjects='';
	function loadCSS()
	{
		try{
			if (!document.getElementById)			
				return
			for (i=0; i<loadCSS.arguments.length; i++)
			{
				var file=loadCSS.arguments[i]
				var fileref=""
				if (loadedobjects.indexOf(file)==-1)
				{ //Check to see if this object has not already been added to page before proceeding
					if (file.indexOf(".js")!=-1)
					{ //If object is a js file
						fileref=document.createElement('script')
						fileref.setAttribute("type","text/javascript");
						fileref.setAttribute("src", file);
					}
					else if (file.indexOf(".css")!=-1)
					{ //If object is a css file
						fileref=document.createElement("link")
						fileref.setAttribute("rel", "stylesheet");
						fileref.setAttribute("type", "text/css");
						fileref.setAttribute("href", file);
					}
				}
				if (fileref!="")
				{
					document.getElementsByTagName("head").item(0).appendChild(fileref)
					loadedobjects+=file+" " //Remember this object as being already added to page
				}
			}
		}
		catch(e){alert(e.message);};
	}
	
	/**
	 * IE Hover event used by css menu
	 */
	/*
	sfHover = function() {		
		var sfEls = document.getElementById("listnav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}	
	*/
	/**
	*   Funktionen zum Feststellen der tatsaechlichen (dynamisch gesetzten)
	*	Hoehe und Breite von HTML-Elementen
	*/
	function getElementHeight(id)
	{
	    var nHeight=0;
	    try{
	    var d = document.getElementById(id);
	    if(d.offsetHeight)
	        nHeight=d.offsetHeight;
	    else if(d.style.pixelHeight)
	        nHeight=d.style.pixelHeight;
	    }
	    catch(e){}
	    return nHeight;
	}
	
	function getElementWidth(id)
	{
	    var nWidth=0;
	    var d = document.getElementById(id);
	    if(d.offsetWidth)
	        nWidth=d.offsetWidth;
	    else if(d.style.pixelWidth)
	        nWidth=d.style.pixelWidth;
	    return nWidth;
	}
	
	guestImage=null;

	function showImagePopup (sImgSrc)
	{
		guestImage = new Image();
		guestImage.src = sImgSrc;
		setRedoTimeout("displayImagePopup('"+sImgSrc+"')", 200 );
	}

	function displayImagePopup(sImgSrc)
	{
		if (guestImage.complete)
		{
			var popupWidth = (guestImage.width > 0) ? guestImage.width+20 : 0; 
			var popupHeight = (guestImage.height > 0) ? guestImage.height+20 : 0;		
		
			var win = window.open(sImgSrc, "imagePopup", "width="+ popupWidth +",height="+ popupHeight +",left=100,top=100,toolbar=no,status=no,menubar=no,resizable=yes");
		win.focus();
	}
		else throw new Error("Image not loaded yet!");
	}

	aRedoId = new Array();
	function redoTimeout(sFunction, nTime, nId, nMaxRetry)
	{
		try{
			eval( sFunction );
		}
		catch(e)
		{
			if (aRedoId[nId] < nMaxRetry)
            {
             	var sFuncCall='redoTimeout("'+sFunction+'",'+nTime+','+nId+','+nMaxRetry+')';
				setTimeout (sFuncCall,nTime);
                aRedoId[nId]+=1;
                //console.log(aRedoId[nId]);
            }
		}
	}

    function setRedoTimeout(sFunction, nTime, nId, nMaxRetry)
    {
        if (setRedoTimeout.arguments.length < 3)
        	nId=1;
        if (setRedoTimeout.arguments.length < 4)
        	nMaxRetry=20;
		aRedoId[nId]=0;
        var sFuncCall='redoTimeout("'+sFunction+'",'+nTime+','+nId+','+nMaxRetry+')';
    	setTimeout (sFuncCall,nTime);
	}

	function getBody()
	{
	 return (window.document.compatMode && window.document.compatMode == "CSS1Compat") ?
	    window.document.documentElement : window.document.body || null;
	}

	function getWindowWidth()
	{
	    if (window.innerWidth)
	        return window.innerWidth;
	    else if (document.body && document.body.offsetWidth)
	        return document.body.offsetWidth;
	    return 0;
	}

	function getWindowHeight()
	{
	  return window.innerHeight || parseInt(getBody().clientHeight );
	}

	var hasSVGSupport = false;
	function checkSVGSupport()
	{
	    // Firefox sets appname = Netscape and appVersion = 5.0; use userAgent instead (contains "Firefox <version number>")
		if (navigator.userAgent.indexOf('Firefox') >= 0)
		{
			var sVersion = navigator.userAgent.substr((navigator.userAgent.indexOf('Firefox') + 8));
			// make sure that version number is 1.5 or hiqher
		    if ((parseInt(sVersion.substr(0, sVersion.indexOf('.'))) == 1
				&& parseInt(sVersion.substr(sVersion.indexOf('.')+1)) >= 5)
				|| parseInt(sVersion.substr(0, sVersion.indexOf('.'))) > 1)
		    hasSVGSupport = true;
		}
	    /* Internet Explorer returns 0 as the number of MIME types,	   so this code will not be executed by it. This is our indication  to use VBScript to detect SVG support.  */
		else if (navigator.mimeTypes != null && navigator.mimeTypes.length > 0)
		{
			alert(navigator.mimeTypes["image/svg-xml"].enabledPlugin);
			hasSVGSupport = (navigator.mimeTypes["image/svg-xml"] && navigator.mimeTypes["image/svg-xml"].enabledPlugin != null);
	        // alert(nse);
		}
		else
		{
			var ClassID = "Adobe.SVGCtl";
			document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n hasSVGSupport = IsObject(CreateObject("' + ClassID + '"))\n</SCRIPT>\n');
		}
		return hasSVGSupport;
	}

/* parseUri JS v0.1, by Steven Levithan (http://badassery.blogspot.com)
Splits any well-formed URI into the following parts (all are optional):
----------------------
• source (since the exec() method returns backreference 0 [i.e., the entire match] as key 0, we might as well use it)
• protocol (scheme)
• authority (includes both the domain and port)
    • domain (part of the authority; can be an IP address)
    • port (part of the authority)
• path (includes both the directory path and filename)
    • directoryPath (part of the path; supports directories with periods, and without a trailing backslash)
    • fileName (part of the path)
• query (does not include the leading question mark)
• anchor (fragment)
*/
function parseUri(sourceUri)
{
    var uriPartNames = ["source","protocol","authority","domain","port","path","directoryPath","fileName","query","anchor"];
    var uriParts = new RegExp("^(?:([^:/?#.]+):)?(?://)?(([^:/?#]*)(?::(\\d*))?)?((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[\\?#]|$)))*/?)?([^?#/]*))?(?:\\?([^#]*))?(?:#(.*))?").exec(sourceUri);
    var uri = {};
    
    for(var i = 0; i < 10; i++){
        uri[uriPartNames[i]] = (uriParts[i] ? uriParts[i] : "");
    }
    
    // Always end directoryPath with a trailing backslash if a path was present in the source URI
    // Note that a trailing backslash is NOT automatically inserted within or appended to the "path" key
    if(uri.directoryPath.length > 0){
        uri.directoryPath = uri.directoryPath.replace(/\/?$/, "/");
    }
    return uri;
}	
    
    /* Beispielanwendung:
       ------------------
       doBGFade(document.getElementById('globalsearchInfo'),[255,252,204],[242,242,242],'rgb(242,242,242)',20,20,1);
    */

    function doBGFade(elem,startRGB,endRGB,finalColor,steps,intervals,powr)
    {
        // BG Fader by www.hesido.com
        // Quelle: http://www.hesido.com/web.php?page=javascriptanimation
        if (elem.bgFadeInt) window.clearInterval(elem.bgFadeInt);

        var actStep = 0;

        elem.bgFadeInt = window.setInterval(
    		function() {
                elem.style.backgroundColor = "rgb("+
    				easeInOut(startRGB[0],endRGB[0],steps,actStep,powr)+","+
    				easeInOut(startRGB[1],endRGB[1],steps,actStep,powr)+","+
    				easeInOut(startRGB[2],endRGB[2],steps,actStep,powr)+")";
    			actStep++;
    			if (actStep > steps) {
                    elem.style.backgroundColor = finalColor;
                    window.clearInterval(elem.bgFadeInt);
    			}
    		}
		,intervals)
    }

    function easeInOut(minValue,maxValue,totalSteps,actualStep,powr)
    {
        // Generic Animation Step Value Generator By www.hesido.com
        // Quelle: http://www.hesido.com/web.php?page=javascriptanimation
    	var delta = maxValue - minValue;
    	var stepp = minValue+(Math.pow(((1 / totalSteps)*actualStep),powr)*delta);
    	return Math.ceil(stepp)
    }
	
	function toggle(target){
		if(document.getElementById('head' + target).className == 'scoop_bright clearfix'){			
			var i = 0;
			var eHead;
			var eContent;
			while (true) {
				eHead = document.getElementById('head' + i);
				eContent = document.getElementById('content' + i);
				if (eHead != null && eContent != null) {				
					eHead.className = 'scoop_bright clearfix';
					eContent.className = 'scoop_hidden';
				}
				else
					break;
				i++;	
			}
			document.getElementById('head' + target).className = 'scoop_dark clearfix';
			document.getElementById('content' + target).className = 'scoop_visible';
		}
		else{
			document.getElementById('head' + target).className = 'scoop_bright clearfix';
			document.getElementById('content' + target).className = 'scoop_hidden';
		}
	}
		