function addBookmark() {
	title = document.title; 
	url = window.location;  
	if (window.sidebar) { // Mozilla Firefox Bookmark		
		window.sidebar.addPanel(title, url,"");	
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); 
	} else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	}
}

// Passchecker
function setDivHeight(h) {
	var layer = document.getElementById("passwdChecker");
	layer.style.height = h+"px";
}

// Mail

function contactMail( f ) {
	var bodyContent = "Name: "+document.forms.contactForm.name.value+"%0D%0AMail: ";
	document.forms.contactForm.action = "mailto:karg@helliwood.de?Subject=Kontakt&body="+bodyContent;
	document.forms.contactForm.submit();
	
	return false;
}

// search


function initializeSearch(){
	var resultElement = '';
	var strUrl = '';
	var searchstr = '';
	var myResults = new Array();
	
	strUrl = document.location.href;
	searchstr = decodeURI(strUrl.slice(strUrl.indexOf("#")+1,strUrl.length));
	searchInput = document.getElementById( 'searchValue' );
	if( searchInput != null ){
		searchInput.value = searchstr;
	}
	glossarySearch( searchstr);
}

function glossarySearch( searchStr){
	resultElement = document.getElementById( 'searchResults' );
	myResults = startSearch(searchStr);
	resultElement.innerHTML = '';
	if(myResults.length > 0){
		for(i = 0 ; myResults.length > i; i++){
			if(typeof(myResults[i][0]) == 'undefined'){
				continue;
			}
			
			resultElement.innerHTML += '<div class="p" style="margin-bottom:4px;"><span class="sect">'+myResults[i][1]+'</span><br /><span class="p">'+content[myResults[i][3]][1]+'<br /></span><span class="textCopyright">'+myResults[i][2]+'</span></div>';
		}
	} else {
		resultElement.innerHTML = '<span class="sect">Es wurden keine Ergebnisse gefunden!</span>';
	}
}

function submitGlossarySearch(){
	element = document.getElementById( 'searchValue' );
	

	
	strUrl = document.location.href;
	strUrl = strUrl.slice(0 , strUrl.indexOf("#") );
	strUrl = strUrl.slice(strUrl.lastIndexOf( '/')+1 , strUrl.length);
	if( strUrl == '402_Fachbegriffsuche.htm')
		glossarySearch( element.value );
	else
		document.location.href = '402_Fachbegriffsuche.htm#' + encodeURI(element.value);
	
}



// Glossary
var x = 0;
var y = 0;
document.onmousemove = cacheXY;

activeFlag = false;
flagTimeout = false;
function delayedExpand( flagId, sourceId , flagWidth, xStart, xWidth ){
	if( activeFlag == true ){
		flagTimeout = false;
		displayGlossaryFlag( flagId, sourceId, flagWidth, xStart, xWidth  );
	} else {
		if( typeof (arguments[5]) == 'undefined' || arguments[5] == true) { //recursivity
			if( flagTimeout != false ) {  // clear other timeouts to avoid jitter
				window.clearTimeout(flagTimeout);
				flagTimeout = false;
			}
			activeFlag = true;
			flagTimeout = window.setTimeout("delayedExpand( '"+flagId+"' , '"+sourceId+"', "+flagWidth+", "+xStart+", "+xWidth+" , false )", 250);
		}
	}
}

function keepExpand(){
	if( flagTimeout != false ) {
		window.clearTimeout(flagTimeout);
	}
}

function delayedClose( flagId ){
	if( activeFlag == false ){
		flagTimeout = false;
		hideGlossaryFlag( flagId );
	} else {
		if( typeof (arguments[1]) == 'undefined' || arguments[1] == true) { //recursivity
			if( flagTimeout != false ) {  // clear other timeouts to avoid jitter
				window.clearTimeout(flagTimeout);
				flagTimeout = false;
			}
			activeFlag = false;
			flagTimeout = window.setTimeout("delayedClose( '"+flagId+"' , false )", 1000);
		}
	}
}

function activate( element ){
	element.getAttributeNode("class").value += 'Active';
}

function deactivate( element ){
	element.getAttributeNode("class").value = element.getAttributeNode("class").value.substr(0, element.getAttributeNode("class").value.length - 6 );
}


function cacheXY( myEvent ) {
	if (!myEvent)
		myEvent = window.event;
	
	x = myEvent.clientX;
	y = myEvent.clientY;
}

function displayGlossaryFlag( elementId, elementSourceId ){
	var flagWidth = 258;
	var xStart = 206;
	var xWidth = 438;
	if( typeof (arguments[2]) == 'number')
		flagWidth = arguments[2];
	if( typeof (arguments[3]) == 'number')
		xStart = arguments[3];
	if( typeof (arguments[4]) == 'number')
		xWidth = arguments[4];
	var xPos = x;
	var yPos = y;
	if(  xPos < xStart)
		xPos = xStart;
	if( (xPos - xStart + flagWidth) > xWidth  || (xPos - xStart) > xWidth ) 
		xPos = xStart + xWidth - flagWidth;

	
	// get scroll amount excepting safari, it includes scroll values already
	xScroll = 0;
	yScroll = 0;
	if ( !/Safari/.test(navigator.userAgent) && !/AppleWebKit/.test(navigator.userAgent)) {
		if (self.pageYOffset) { // all except Explorer
			xScroll = self.pageXOffset;
			yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) { 	// Explorer 6 Strict
			xScroll = document.documentElement.scrollLeft;
			yScroll = document.documentElement.scrollTop;
		} else if (document.body) { // all other Explorers
			xScroll = document.body.scrollLeft;
			yScroll = document.body.scrollTop;
		}
	}
	
	xPos += xScroll ;
	yPos += yScroll + 20;
	if (document.getElementById) {
		element = document.getElementById( elementId );
		contentElement = document.getElementById( elementId+'Content' );
		sourceElement = document.getElementById( elementSourceId );
		element.style.left  = xPos + "px";
		element.style.top = yPos + "px";
	} else if (document.all) {
		element = document.all[elementId]
		contentElement = document.all[ elementId+'Content' ];
		sourceElement = document.all( elementSourceId );
		element.style.left = xPos;
		element.style.top = yPos;
	}
	
	contentElement.innerHTML = sourceElement.innerHTML;
	element.style.display = "block";
}

function hideGlossaryFlag( elementId ){
	if (document.getElementById) {
		element = document.getElementById( elementId );
		contentElement = document.getElementById( elementId+'Content' );
	} else if (document.all) {
		element = document.all[elementId];
		contentElement = document.all[elementId+'Content'];
	}
	
	element.style.display = "none";
	contentElement.innerHTML = "";
	 
}


// noclick flash activation
function enableActiveX (containerID)
// Use it, improve it
// by Dirk Alban Adler // KLITSCHE.DE
{
	// No IE = no need to enable
    if (getInternetExplorerVersion () != -1)
    {
        // Get container
        var container = document.getElementById (containerID);
        // Get html in noscript 
        var html = container.innerHTML; 
		container.innerHTML = '';
        // Write html back to container
        
		container.innerHTML = html;

    }
}
function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// Found at: 
// http://msdn.microsoft.com/workshop/author/dhtml/overview/browserdetection.asp
{
    var rv = -1; // Return value assumes failure
    if (navigator.appName == 'Microsoft Internet Explorer')
    {
        var ua = navigator.userAgent;
        var re  = new RegExp ("MSIE ([0-9]{1,}[\.0-9]{0,})");
        if (re.exec (ua) != null)
        {
        	rv = parseFloat (RegExp.$1);
        }
    }
    return rv;
}


/* Auswahl der LearningGateways */
function GatewayMenu(winName,selObj,restore){
//  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	winName=winName+String(Math.floor(Math.random()*1000));
	window.open(selObj.options[selObj.selectedIndex].value, winName, "scrollbars=yes,menubar=no,toolbar=no,status=no,resizable=yes,location=no,width=885,height=700");
  if (restore) selObj.selectedIndex=0;
}

function openMediaWindow( theUrl, theWidth, theHeight ) {
	
	theUrl = theUrl.replace(/image\.htm/g, "image_osz.htm");
	
	theWidth  = 540+18;
	theHeight = theHeight+190;
	
	var wide = screen.availWidth;
	var high  = screen.availHeight;
	
	xpos = (wide/2)-(theWidth/2);
	ypos = (high/2)-(theHeight/2);
	
	winName	   = "ICT"+String(Math.floor(Math.random()*1000));
	
	winOptions = "width=" + theWidth + ",height=" + theHeight + ",screenX=" + xpos + ",screenY=" + ypos + ",left=" + xpos + ",top=" + ypos + ","+
				 "menubar=0,location=0,locationbar=0,personalbar=0,resizable=1,scrollbars=no,directories=0,status=0,statusbar=0,toolbar=0";
	
	popUp = window.open( theUrl, winName, winOptions );
	
}

function openMediaFile(url) {
	var winName = "Media" + String(Math.floor(Math.random()*1000));
	if( url.toLowerCase().substr( url.length-4, url.length ) == ".swf" ) {
	    options = 'toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=900,height=500';
	} else {
		options = 'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=no,resizable=yes,copyhistory=no,width=900,height=500';
	}
	pop = open(url, winName, options );
	if(navigator.appName == "Netscape"){
		pop.focus();
    }
}

function ImageOpen (url,breite,hoehe,options){
	if( !breite && !hoehe ) {
		Fenster = window.open(url,"Zweitfenster","Width=10,Height=10,status=no,"+options);
	} else {
		Fenster = window.open(url,"Zweitfenster","Width="+breite+",Height="+hoehe+",status=no,"+options);
	}
	Fenster.innerWidth = breite;
	Fenster.innerHeight = hoehe;
	Fenster.focus();
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}