/**
 ******************************************************************
 *              Philipp Knï¿½ller Software Entwicklung              *
 *                        Framework Funktor                       *
 *                           Version 0.9b                         *
 *                                                                * 
 *                  http://pksoftware.de/funktor                  *
 *                                                                *
 ******************************************************************
 * 
 * $Id: FAjax.js,v 1.1.2.3 2008/06/18 11:56:50 pknoeller Exp $
 * 
 * Functions for AJAX Requests
 * 
 * @author Philipp Knoeller
 * @copyright Copyright &copy; 2006, Philipp Knoeller
 * @link http://pksoftware.de/funktor
 * @version 1.0.0.3
 * @package funktor_ffmain
 * @subpackage js
 */

/**
 * Class FAjax represents an AJAX request
 */ 
function FAjax(nUrl, sendRid){

	 this.requestUrl=nUrl;
     this.getString=null;
     this.postString=null;
     this.searchTimer=null;
     this.http_request = false;
     this.requestId=0;
     this.sendRid=sendRid;

    /**
     * initializes a browser specific http request object
     * @author Philipp Knoeller
     */
    this.prepareRequest=function() {

        this.http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            this.http_request = new XMLHttpRequest();
            if (this.http_request.overrideMimeType) {
                this.http_request.overrideMimeType('text/xml');
                
            }
        } 
        else if (window.ActiveXObject) { // IE
            try {
                this.http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } 
            catch (e) {
                try {
                    this.http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } 
                catch (e) {}
            }
        }

        if (!this.http_request) {
            alert('Cannot create XMLHTTP instance.');
            return false;
        }
   };
 
 /**
  * sets the get string
  */
 this.setGetString=function(ngs){
 	this.getString=ngs;
 };
 
 /**
  * sets the post string
  */
 this.setPostString=function(nps){
 	this.postString=nps;
 }
 
 /**
  * sets the url of the next request
  */
  this.setUrl=function(ngs){
 	this.requestUrl=ngs;
 };
 
 /**
 * Sends a new request, "overrides" any other requests 
 * @author Philipp Knoeller
 * @param method request method 'GET' or 'POST'
 */
 this.request=function(xmlExspected, method, responseFunction, errorFunction, customUrl, customGet, customPost){
         method=method.toUpperCase();
         if(!((method=='GET') || (method=='POST'))) alert('Invalid request method: '+method);
         
         this.prepareRequest();
         
         this.requestId++;
         
         var httpRequest=this.http_request;
         var finalRequestId=this.requestId;
         this.http_request.onreadystatechange=function(){
         	  if ( (httpRequest.readyState == 4) &&
                   (httpRequest.status == 200) ) {
                        return responseFunction(xmlExspected ? 
                                                httpRequest.responseXML : 
                                                httpRequest.responseText, finalRequestId);
              }
 	          
 	          if(!errorFunction) return false;        
              
              return errorFunction(httpRequest.readyState, httpRequest.status);
 	                   
         };
         
         
         var ridAdd="";
         if(this.sendRid) ridAdd+="ff_rid="+this.requestId+"&";
         
         var finalUrl=(customUrl ? customUrl :this.requestUrl);
         var finalGet=(customGet ? customGet : this.getString);
         var finalPost=(customPost ? customPost : this.postString);
         
         if(finalGet) finalUrl+=(-1 == finalUrl.indexOf("?") ? "?" : "&") + finalGet;
         
         this.http_request.open(method, finalUrl, true);
         
         if(method=='POST'){ 
	          this.http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	          this.http_request.setRequestHeader("Content-length", finalPost.length);
	          this.http_request.setRequestHeader("Connection", "close"); 
         }
         
         this.http_request.send(finalPost ? finalPost : null);
         
         return true;
 }        
 
 /**
  * Sends a request OLD
  * @deprecated use this.request instead
  */
 this.sendRequest=function(method, responseFunction, customUrl, customGet, customPost){
         this.prepareRequest();
         this.requestId++;
         var fixId=this.requestId;
         var ht=this.http_request;
         this.http_request.onreadystatechange=function(){
         	  if (ht.readyState == 4) {
                   if (ht.status == 200) {
                        var xmldoc = ht.responseXML;
                        //xml_decode(xmldoc);

                        return responseFunction(xmldoc, fixId);
                   }
                   return false;
 	          }
 	          else{         
                   return false; //setFirstNodeValue(searchHintElement, 'xx'+f);f++;
 	          }         
         };
         
         
         var ridAdd="";
         if(this.sendRid) ridAdd+="ff_rid="+this.requestId+"&";
         
         var finalUrl=(customUrl ? customUrl :this.requestUrl);
         var finalGet=(customGet ? customGet : this.getString);
         var finalPost=(customPost ? customPost : this.postString);
         
         this.http_request.open(method, finalUrl+(finalGet ? (-1==finalUrl.indexOf("?") ? "?" : "&")+finalGet : ""), true);
         
         if(method.toUpperCase()=='POST'){ 
          this.http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
          this.http_request.setRequestHeader("Content-length", finalPost.length);
          this.http_request.setRequestHeader("Connection", "close"); 
         }
         
         this.http_request.send(finalPost ? finalPost : null);
         
         return true;
 };  

 /**
 * Returns the id of the last request
 */
 this.getRequestId=function(){
 	  return this.requestId;
 }

 this.setRequestId=function(nr){
 	  this.requestId=nr;
 }

 
 /**
 * Starts a request with a delay
 */
 this.search_once=function(searchFunction, delay){
 	   window.setTimeout(searchFunction, delay);
 }
 
 /**
 * Starts a timer request
 */
 this.start_search=function(searchFunction, searchInterval){
       this.searchTimer=window.setInterval(searchFunction, searchInterval);
 };
 
 /**
 * Stops a timer request
 */
 this.stop_search=function(){
 	  window.clearInterval(this.searchTimer);
 	  this.searchTimer=null;
 };
 



}

function ffHasInputChanged(textFieldId, minLength, notValue,doNotCacheField){
    var field=gE(textFieldId);
    
    if(field.type=='checkbox'){
         var newSearchString=field.checked?'1':'0';
         var oldSearchString=getFieldCache(textFieldId);
         if(oldSearchString!=newSearchString){
            if(!doNotCacheField) setFieldCache(textFieldId, newSearchString);
            return newSearchString;
         }
         return null;
    }
    
    var newSearchString=field.value;
    var oldSearchString=getFieldCache(textFieldId);
    if ( (oldSearchString!=newSearchString) &&
             ((null==minLength) || (newSearchString.length>=minLength)) &&
             ((null==notValue) || newSearchString!=notValue) ) {
              
              if(!doNotCacheField) setFieldCache(textFieldId, newSearchString);
              return newSearchString;
              }
               return null;
}

 /**
 * fuellt eine <select> Box mit <entry>s aus einer xml
 * der nodeValue wir zum Label der <option>s, der Inhalt der "value" attribute der <entry>s wird zum "value" der <option>s
 * @author Philipp Knï¿½ller
 * @param ressource xmldoc XML document root node
 * @param string searchSelectBox id of the <select> box which should contain the result
 * @deprecated use ffArrayToSelectBox instead
 */
  function xmlToSelectBox(xmldoc, selectBoxId, containerDivId){
   	     var entrys=xmldoc.getElementsByTagName("entry");
         return ffArrayToSelectBox(entrys, selectBoxId, containerDivId, 'Keine passenden Eintraege'); 
                //alert(root_node.firstChild.data);
               // alert(http_request.responseText);
   }
   
   /**
 * fills a <select> box with data from an array
 * if sourceArray is a dom object, the value attribute will become the value of the option. The firstChild.nodeValue will become the label of the option.
 * If sourceArray is a normal object the property names will be the values of the options, and the property values will be the label of the options
 * @author Philipp Knï¿½ller
 * @param ressource xmldoc XML document root node
 * @param string searchSelectBox id of the <select> box which should contain the result
 * @deprecated use ffArrayToSelectBox instead
 */
   function ffArrayToSelectBox(sourceArray, selectBoxId, containerDivId, noResultLabel){
         gE(containerDivId).style.display='block';
         
         if(sourceArray.length==0){
                   deleteAllOptions(selectBoxId);
                   if(noResultLabel)
                       addOption(selectBoxId, noResultLabel, NaN, false, false);
                   else    
                       gE(containerDivId).style.display='none';
                   return false;
         }
         else{
                   var newOptions=new Array();
                   for(var i=0; i<sourceArray.length; i++){
                         
                         var newOptionValue=null;
                         var newOptionLabel=null;
                         //alert(sourceArray[i]);
                         if(!sourceArray[i].value){
                             newOptionValue=sourceArray[i].getAttribute('value');
                             newOptionLabel=sourceArray[i].firstChild.nodeValue;
                         }
                         else{
                             newOptionValue=sourceArray[i].value;
                             newOptionLabel=sourceArray[i].label;
                         }        
                         newOptions[i]=new NewOptionsArray(newOptionLabel, newOptionValue);
                   }
                   fillSelect(selectBoxId, newOptions);
                   return true;
         }
   }      
         
   function ffSelectBoxToTextField(selectBox, textField){
   	    document.getElementById(textField).value=getSelectedOptionLabel(selectBox);
   }
   
   function ffFormSubmit(formId, selectBox, textField){
   	    ffSelectBoxToTextField(selectBox, textField);
   	    document.getElementById(formId).submit();
   }
   
   function ffEntityDecode(string){
   	   	    string=string.replace("&auml;", "Ã¤");
   	   	    string=string.replace("&ouml;", "Ã¶");
   	   	    string=string.replace("&uuml;", "Ã¼");   	   	    
   	   	    string=string.replace("&szlig;", "ÃŸ"); 	   	    
   	   	    string=string.replace("&Auml;", "Ã„");
   	   	    string=string.replace("&Ouml;", "Ã–");
   	   	    string=string.replace("&Uuml;", "Ãœ");  	   	    
   	   	    return string;
   }	   	    /**
 ******************************************************************
 *              Philipp Knoeller Software Entwicklung             *
 *                        Framework Funktor                       *
 *                           Version 1.0                          *
 *                                                                * 
 *                  http://pksoftware.de/funktor                  *
 *                                                                * 
 *                       ALL RIGHTS RESERVED                      *
 *                                                                *
 ******************************************************************
 * 
 * $Id: FBrowser.js,v 1.1.2.3 2008/07/08 13:46:13 pknoeller Exp $
 * 
 * @author Philipp Knoeller
 * @copyright Copyright &copy; 2006, Philipp Knoeller
 * @link http://pksoftware.de/funktor
 * @version 1.0.0.2
 * @package funktor_ffmain
 * @subpackage js
 */

/**
 * Is Internet Explorer?
 */
function isIE(){ return !window.opera && navigator.userAgent.indexOf("MSIE") !=-1;}

isNS4 = (document.layers) ? 1 : 0;
isIE4 = (document.all) ? 1 : 0;
isW3C = (document.getElementById && !document.all) ? 1 : 0;

/**
 * function for retrieving the browser's calculated CSS property values
 */
function getCalculatedProperty(objName, property) {

    // ***** W3C Compatible DOM (NN6, Mozilla 16, etc.) *****

    if (isW3C) {
        docObj = document.getElementById(objName);
		
        if (property == "visibility") {
	        cssp = docObj.style.visibility;
	        return (cssp == "") ? "inherit" : cssp;
	    }

	    if (property == "clip") {
	        cssp = docObj.style.clip;

	        if (cssp == "") {
		       cssStr = "rect(0px "; 
		       cssStr += getCalculatedProperty(objName, "width") + " ";
		       cssStr += getCalculatedProperty(objName, "height") + " ";
		       cssStr += "0px)";
		       return cssStr;
	        }
	        return cssp;
	    }

	    if (property == "zIndex") {
	       cssp = docObj.style.zIndex;
	       return (cssp == "") ? "inherit" : cssp;
	    }

	    cssp = document.defaultView.getComputedStyle(docObj, "").getPropertyValue(property);

	    return (cssp == "") ? "unknown" : cssp;
    }

    // ***** Netscape Navigator 4+ DOM *****

    if (isNS4) {
	    docObj = document.layers[objName];

	    if (property == "visibility") {
	          cssp = docObj.visibility;
	          return (cssp == "hide") ? "hidden" : (cssp == "show") ? "visible" : "inherit";
	    }

	    if (property == "clip") {
	          cssStr = "rect(" + docObj.clip.top + "px ";
	          cssStr += docObj.clip.right + "px ";
	          cssStr += docObj.clip.bottom + "px ";
	          cssStr += docObj.clip.left + "px)";
	          return cssStr;
	    }

	    if ((property == "width") || (property == "height")) {
	         return eval("docObj.clip." + property) + "px";
	    }

	    if (property == "top") property = "pageY";
	    if (property == "left") property = "pageX";

	    cssp = eval("docObj." + property);

	    if (property != "zIndex") cssp += "px";

	    return cssp;
    }

    // ***** Internet Explorer 4+ DOM *****

    if (isIE4) {
	     if (property == "width") return eval(objName + ".offsetWidth") + "px";

	     if (property == "height") return eval(objName + ".offsetHeight") + "px";

	     if (property == "clip") {
	          cssp = eval(objName + ".style.clip");

	          if (cssp == "") {
		           cssStr = "rect(0px ";
		           cssStr += getCalculatedProperty(objName, "width") + " ";
		           cssStr += getCalculatedProperty(objName, "height") + " ";
		           cssStr += "0px)";
		           return cssStr;
	          }
	          return cssp;
	     }

	     if (property == "top") return eval(objName + ".offsetTop") + 'px';

	     if (property == "left") return eval(objName + ".offsetLeft") + 'px';

        // Else, use 'currentStyle' to find the rest

	     return eval(objName + ".currentStyle." + property);
    }
}

/**
 * ermittelt die aktuelle Breite eines Elements (Laufzeit)
 * @author Philipp Knöller
 */
function getComputedWidth(elementId){
	  var el=document.getElementById(elementId);
      
      return isIE() ? el.offsetWidth : getPxValue(document.defaultView.getComputedStyle(el, null).getPropertyValue("width"));
}

/**
 * ermittelt die aktuelle Hoehe eines Elements (Laufzeit)
 * @author Philipp Knöller
 */
function getComputedHeight(elementId){
	  var el=document.getElementById(elementId);
      
      return isIE() ? el.offsetHeight : getPxValue(document.defaultView.getComputedStyle(el, null).getPropertyValue("height"));
}

/**
 * ermittelt die aktuelle X-Position eines Elements (Laufzeit)
 * @author Philipp Knöller
 */
function getComputedLeft(elementId){
	    var el=document.getElementById(elementId);
      
        return isIE() ? el.offsetLeft : getPxValue(document.defaultView.getComputedStyle(el, null).getPropertyValue("left"));
}

/**
 * ermittelt die aktuelle X-Position eines Elements (Laufzeit)
 * @author Philipp Knöller
 */
function getComputedTop(elementId){
	    var el=document.getElementById(elementId);
      
        return isIE() ? el.offsetTop : getPxValue(document.defaultView.getComputedStyle(el, null).getPropertyValue("top"));
}

function getCurrentStyle(elementId, attr){
	    var el=document.getElementById(elementId);
      
        return getPxValue(isIE() ? el.currentStyle[attr] : document.defaultView.getComputedStyle(el, null).getPropertyValue(attr));
}        

///////////////////////////////////////////
/////Window and Page Dimensions////////////
///////////////////////////////////////////

/**
 * returns the dimensions of the browser window
 */
function getWindowDimensions(){
   var x,y;

   if (self.innerHeight){ // all except Explorer
	   x = self.innerWidth;
	   y = self.innerHeight;
   }
   else if (document.documentElement && document.documentElement.clientHeight){ // Explorer 6 Strict Mode
	   x = document.documentElement.clientWidth;
	   y = document.documentElement.clientHeight;
   }
   else if (document.body){  // other Explorers
	   x = document.body.clientWidth;
	   y = document.body.clientHeight;
   }
   var dimensions=new Array(x,y);
   return dimensions;
}

/**
 * returns the dimensions of the visible page in the browser
 */
function getPageDimensions(){
   var x,y;
   var test1 = document.body.scrollHeight;
   var test2 = document.body.offsetHeight
   if (test1>test2) { // all but Explorer Mac
	     x = document.body.scrollWidth;
	     y = document.body.scrollHeight;
   }
   else{ // Explorer Mac; would also work in Explorer 6 Strict, Mozilla and Safari
	     x = document.body.offsetWidth;
	     y = document.body.offsetHeight;
   }
   var dimensions=new Array(x,y);
   return dimensions;
}

/**
* Returns the size of the viewport(visible area) of the browser
**/
function getVisiblePageSize(){
       var dim=new Object();
       //dim.width=document.body.scrollWidth ? document.body.scrollWidth :document.body.offsetWidth;
       //dim.height=document.body.scrollHeight ? document.body.scrollHeight : document.body.offsetHeight;
       
		if (self.innerHeight) // all except Explorer
		{
			dim.width = self.innerWidth;
			dim.height = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
			// Explorer 6 Strict Mode
		{
			dim.width = document.documentElement.clientWidth;
			dim.height = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			dim.width = document.body.clientWidth;
			dim.height = document.body.clientHeight;
		}
       return dim;
}
       
///////////////////////////////////////////
/////////////Text Selection////////////////
///////////////////////////////////////////
 
var selStart=true;
var dissel=true;

//document.onselectstart=selectStart;
//if (window.sidebar){
  //  document.onmousedown=disableselect;
   // document.onclick=reEnable;
//}

function selectStart(e){
    return selStart;
}

function disableselect(e){
    return dissel;
}

function reEnable(){
    return true;
}

/**
 * enables/disables text selection
 */
function setTextSelectEnabled(tEnabled){
    selStart=tEnabled;
    dissel=tEnabled;
} 

/**
 * enables/disables text selection for special element
 */ 
function disableSelection(element) {
    element.onselectstart = function() {
        return false;
    };
    element.unselectable = "on";
    element.style.MozUserSelect = "none";
    element.style.cursor = "default";
} 

///////////////////////////////////////////
/////////////Event Handling////////////////
///////////////////////////////////////////

/**
 * adds an event handler
 */
function addEventHandler(obj, evType, fn, useCapture) {
    if (obj.addEventListener) {
       obj.addEventListener(evType, fn, useCapture);
       return true;
    } 
    else if (obj.attachEvent) {
       var r = obj.attachEvent('on'+evType,fn);
       return r;
    } 
    else {
       obj['on'+evType] = fn;
    }
}



var FFUniBrowser={
    /**
    * Mouse positions
    */
    mouseX:0,
    mouseY:0,
    
    /**
    * Gets the mouseX coordinate from the event
    */
	_mouseX:function(evt) {
	    if (!evt){
	          evt = window.event; 
	    }      
	    if (evt.pageX){
	          return evt.pageX; 
	    }
	    else if (evt.clientX){
	          return evt.clientX + 
	                 (document.documentElement.scrollLeft ?  
	                  document.documentElement.scrollLeft : 
	                  document.body.scrollLeft); 
	    }
	    else{ return 0;}
	}, 

	/**
	* Gets the mouseY coordinate from the event
	*/
	_mouseY:function(evt) {
	    if (!evt){
	          evt = window.event; 
	    }      
	    
	    if (evt.pageY){
	          return evt.pageY; 
	    }
	    else if (evt.clientY){ 
	          return evt.clientY + FFUniBrowser.getScrollY(); 
	    }
	    else{ return 0; }
	}, 
	
	refreshMouseCoordinates:function(evt){
	    FFUniBrowser.mouseX=FFUniBrowser._mouseX(evt);
         FFUniBrowser.mouseY=FFUniBrowser._mouseY(evt); 
	},
	
	//Scroll Wert erfassen
	getScrollY:function(){
	    return (document.documentElement.scrollTop ? 
	                  document.documentElement.scrollTop : 
	                  document.body.scrollTop);
	},
	
	setScrollY:function(newTop){
	   if(document.documentElement.scrollTop) 
	                  document.documentElement.scrollTop=newTop; 
	   else document.body.scrollTop=newTop;
	   return true;
	},
	
	//Scroll Wert erfassen
	getScrollX:function(){
	    return (document.documentElement.scrollLeft ? 
	                  document.documentElement.scrollLeft : 
	                  document.body.scrollLeft);
	},
	
    /**
    * determines the absolute position of a non absolute object
    * @author Philipp Knoeller
    * @return Object with left and top attributes
    */
    getCurrentLocation:function(obj){
         var pos = {left:0, top:0};
	     if(typeof obj.offsetLeft != 'undefined'){
		     while (obj){
		          pos.left += obj.offsetLeft;
		          pos.top += obj.offsetTop;
		          obj = obj.offsetParent;
		     }
	    }
		else{
			   pos.left = obj.left ;
			   pos.top = obj.top ;
		}
		return pos;
    },
    
    getCurrentDimension:function(obj){
	     var dim={width:0, height:0};
         dim.height=isIE() ? obj.offsetHeight : getPxValue(document.defaultView.getComputedStyle(obj, null).getPropertyValue("height"));
         dim.width=isIE() ? obj.offsetWidth : getPxValue(document.defaultView.getComputedStyle(obj, null).getPropertyValue("width"));
         return dim; 
    },
    
    getShiftAltCtrl:function(e) {
		 var returnObj=new Object();
		 returnObj.ctrl=0;
		 returnObj.alt=0;
		 returnObj.shift=0;
		
		 if (parseInt(navigator.appVersion)>3) {
		      var evt = navigator.appName=="Netscape" ? e:event;
		
			  if (navigator.appName=="Netscape" && parseInt(navigator.appVersion)==4) {
				   // NETSCAPE 4 CODE
				   var mString =(e.modifiers+32).toString(2).substring(3,6);
				   returnObj.shift=(mString.charAt(0)=="1");
				   returnObj.ctrl =(mString.charAt(1)=="1");
				   returnObj.alt  =(mString.charAt(2)=="1");
				   self.status="modifiers="+e.modifiers+" ("+mString+")";
			  }
			  else {
				   // NEWER BROWSERS [CROSS-PLATFORM]
				   returnObj.shift=evt.shiftKey;
				   returnObj.alt  =evt.altKey;
				   returnObj.ctrl =evt.ctrlKey;
				   self.status=""
				    +  "shiftKey="+returnObj.shift 
				    +", altKey="  +returnObj.alt 
				    +", ctrlKey=" +returnObj.ctrl 
			  }
		
		 }
		 return returnObj;
     }
};	/////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////Tabellen///////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////

function createTd(tr, content, className, id){
    var td1 = document.createElement("td");
    var td1Text = document.createTextNode(content);
    td1.appendChild(td1Text); 
    tr.appendChild(td1);
    if(className){
         var classAtt=document.createAttribute('class');
         classAtt.nodeValue=className;
         td1.setAttributeNode(classAtt);
    }
    return td1;
}

function createTdF(fd, tr, content, className, id){
    var td1 = fd.createElement("td");
    var td1Text = fd.createTextNode(content);
    td1.appendChild(td1Text); 
    tr.appendChild(td1);
    if(className){
         var classAtt=fd.createAttribute('class');
         classAtt.nodeValue=className;
         td1.setAttributeNode(classAtt);
    }
    return td1;
}

function createTr(tableId, index, trClass){
   var tr = frameDocument.getElementById(tableId).insertRow(index);
   var trClass=frameDocument.createAttribute('class');
   trClass.nodeValue=trClass;
   tr.setAttributeNode(trClass);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////Text Felder////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////








    	 
 

function setFirstNodeValue(id, value){
    document.getElementById(id).firstChild.nodeValue=value;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////Auswahllisten bearbeiten/////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Fuegt eine Option hinzu
function addOption(listId, newLabel, newValue, a, b){
    var newPos=document.getElementById(listId).length;
	document.getElementById(listId).options[newPos]=new Option(newLabel, newValue, a, b);
}

//loesch alle Eintraege
function deleteAllOptions(listId){
    var dl=document.getElementById(listId).length;
    for(i=0; i<dl; i++){
	      document.getElementById(listId).options[document.getElementById(listId).length-1]=null;
	}

}

//Selektiert alle Eintraege einer Liste
function selectAllOptions(listId){
	for(i=0; i<document.getElementById(listId).length; i++){
	      document.getElementById(listId).options[i].selected='selected';
	}
}

//loescht eine option
function deleteOption(listId, index){
	document.getElementById(listId).options[index]=null;
}

//loescht eine option
function deleteLastOption(listId){
	document.getElementById(listId).options[document.getElementById(listId).options.length-1]=null;
}

function setOption(listId, index, label, value, selected){
    document.getElementById(listId).options[index].firstChild.nodeValue=label; 
    document.getElementById(listId).options[index].value=value; 
    if(selected){
    document.getElementById(listId).options[index].selected='selected';
    }
}

function getSelectSelectedIndex(selectId){
	 return document.getElementById(selectId).selectedIndex;
}

function setSelectOptionSelected(selectId, optionsIndex, selected){
	 document.getElementById(selectId).options[optionsIndex].selected=selected ? 'selected' : '';   
}

function setToggleSelected(inputName, index){
     document.getElementsByName(inputName)[index].checked='1';
}

function getSelectOptionValue(selectId, optionIndex){
	    return document.getElementById(selectId).options[optionIndex].value;
}

function getSelectOptionLabel(selectId, optionIndex){
	    return document.getElementById(selectId).options[optionIndex].firstChild.nodeValue;
}

function getOptionValue(listId, index){
    return document.getElementById(listId).options[index].value;
}

function getSelectedOptionLabel(listId){
    return document.getElementById(listId).options[document.getElementById(listId).selectedIndex].firstChild.nodeValue;
}

function getOptionValues(listId){
    var options=document.getElementById(listId).options;
    var returnArray=new Array();
    for(var i=0; i<options.length; i++){
         if(options[i].value!='NaN'){
         returnArray.push(options[i].value);
         }
    }
    return returnArray;
}

function getSelectOptionsLength(listId){
    return document.getElementById(listId).options.length;
}

function NewOptionsArray(label, value){
    this.label=label;
    this.value=value;
}

function fillSelect(listId, newOptions){
    var oldLength=getSelectOptionsLength(listId);
    for(var i=0; i<newOptions.length; i++){
         var label=newOptions[i].label;
         var value=newOptions[i].value;
         if(i<oldLength){
              setOption(listId, i, label, value, i==0);
         }
         else{
              addOption(listId, label, value, i==0, i==0);
         }
    }
    if(newOptions.length<oldLength){
         for(var i=newOptions.length; i<oldLength; i++){
              deleteLastOption(listId);
         }
    }
}


var FFForms={

   clearTextField:function(id){
         gE(id).value='';
   }   

};






/**
 ******************************************************************
 *              Philipp Knoeller Software Entwicklung              *
 *                        Framework Funktor                       *
 *                           Version 0.9b                         *
 *                                                                * 
 *                  http://pksoftware.de/funktor                  *
 *                                                                *
 ******************************************************************
 * 
 * $Id: FElements.js,v 1.1.2.1 2008/04/06 20:41:32 pknoeller Exp $
 * 
 * Functions for Funktor GUI Elements
 * 
 * @author Philipp Knoeller
 * @copyright Copyright &copy; 2006, Philipp Knoeller
 * @link http://pksoftware.de/funktor
 * @version 1.0.0.1
 */
 
 /**
  * verschiebt ein Element einer Select Box nach oben / unten
  * @author Philipp Knöller
  */
 function fSwapOption(selectBoxId, upDown){
    var selIndex=getSelectSelectedIndex(selectBoxId);
	var selLength=getSelectOptionsLength(selectBoxId);
	//alert(selEl);
	if(selIndex!=-1 && selLength>0){
    	   var selLabel=getSelectOptionLabel(selectBoxId, selIndex);
           var selValue=getSelectOptionValue(selectBoxId, selIndex);
    	   if(selValue!='NaN'){
    	   	   var swapIndex=selIndex;

    	       if(upDown==1){
    	   	      if(selIndex<selLength-1){
    	   	      	    swapIndex=selIndex+1;
    	   	      } 	    
    	       }
    	       else{
    	       	  if(selIndex>0){
    	   	      	    swapIndex=selIndex-1;
    	   	      }
    	       }   
    	   	   
    	   	   if(swapIndex!=selIndex){
    	   	      	    var swapLabel=getSelectOptionLabel(selectBoxId, swapIndex);
    	   	      	    var swapValue=getSelectOptionValue(selectBoxId, swapIndex);
    	   	      	     setSelectOptionSelected(selectBoxId, swapIndex, false);
      	   	      	    setSelectOptionSelected(selectBoxId, selIndex,  false);
    	   	      	    setOption(selectBoxId, swapIndex, selLabel, selValue, true);
      	   	      	    setOption(selectBoxId, selIndex, swapLabel, swapValue, false);
    	   	   }
    	       
    	   }
	}
}

/**
* aktualisiert eine n-Liste
* @author Philipp Knöller
*/
function refreshCats(catSelectName, nr, leaveDefault, dsArray, dsLabelArray, dsValue, readyValue, rdsValue){
	var select0=gE(catSelectName + 'Select0').value;
	if(nr==0){
	     if(!leaveDefault){
	          var firstOptionValue=getOptionValue(catSelectName + 'Select0', 0);
	          if(firstOptionValue==dsValue){
	               deleteOption(catSelectName + 'Select0', 0);
	          }
	     }
	     if(select0!=dsValue&&select0!=rdsValue){
	          var selVal=cats[select0];
	          if(selVal.length>0){
	               var i=1;
	               var newOptions=new Array(new NewOptionsArray('[auswählen...]', dsValue));
	               for(var v in selVal){
	                    newOptions[i]=new NewOptionsArray(catLabels[v], v);
		                i++;
	               }
	               fillSelect(catSelectName + 'Select1', newOptions);
	               gE(catSelectName + 'Select1').style.visibility='visible';
	          }
	          else{
	              deleteAllOptions(catSelectName + 'Select1');
	              addOption(catSelectName + 'Select1', '[Fertig]', readyValue, true, true);
		          document.getElementById(catSelectName + 'Select1').style.visibility='hidden';
		          deleteAllOptions(catSelectName + 'Select2');
                  addOption(catSelectName + 'Select2', '[Fertig]', readyValue, true, true);
		          document.getElementById(catSelectName + 'Select2').style.visibility='hidden';
	          }
	     }
	     else{
	          deleteAllOptions(catSelectName + 'Select1');
	          addOption(catSelectName + 'Select1', dsLabelArray[1], dsArray[1] ? rdsValue : dsValue, true, true);
	          deleteAllOptions(catSelectName + 'Select2');
	          addOption(catSelectName + 'Select2', dsLabelArray[2], dsArray[2] ? rdsValue : dsValue, true, true);
	          gE(catSelectName + 'Select1').style.visibility='hidden';
	          gE(catSelectName + 'Select2').style.visibility='hidden';
	     }
	}
	else{
	    var select1=gE(catSelectName + 'Select1').value;
	    var selVal1=cats[select0][select1];
	   
        if(selVal1.length > 0){ //JavaScript sieht einen Array als object
	          var newOptions=new Array(new NewOptionsArray('[auswählen...]', dsValue));
	          for(i=0; i<selVal1.length; i++){
	               var v1=cats[select0][select1][i];
		           newOptions[i+1]=new NewOptionsArray(catLabels[v1], v1);
		      }
		      fillSelect(catSelectName + 'Select2', newOptions);
		      gE(catSelectName + 'Select2').style.visibility='visible';
	    }
	    else{
	          deleteAllOptions(catSelectName + 'Select2');
	          addOption(catSelectName + 'Select2', '[Fertig]', readyValue, true, true);
		      document.getElementById(catSelectName + 'Select2').style.visibility='hidden';
	    }    
	}
	
	//alert(selVal);
}

//#################Countdown

//Zeit herunterzaehlen
var ct;

//Countdown objekt
function CountdownTimer(h, m ,s){
         this.h=h;
         this.m=m;
         this.s=s;
         this.timer=null;
}

//Startet den Countdown
function startCountdown(h, m ,s){
         ct=new CountdownTimer(h, m, s);
         inte=window.setInterval("runDown()", 1000);
         ct.timer=inte;
}

//Zaelt runter(1 Sekunde)
function runDown(){
         ct.s--;
         if(ct.s<0){ 
              ct.s=59; 
              ct.m--
              if(ct.m<0){
                   ct.h--;
                   if(ct.h<0){
                        ct.h=0; 
                        window.clearInterval(ct.timer);
                   }
             }
         }
         document.getElementById('ctHSpan').firstChild.nodeValue=ct.h;
         document.getElementById('ctMSpan').firstChild.nodeValue=ct.m;
         document.getElementById('ctSSpan').firstChild.nodeValue=ct.s;
}  

//######################################
//##################Buttons#############
//######################################

function ffButtonChangeState(buttonId, newState){
    changeImgSrc(buttonId+'_img', buttonId+'_'+newState);
}     


//######################Drop Down Menu
/**
 * Functions to create, display and hide a drop down menu
 * @author Lyuben Manolov
 */
var FFDropDownMenu={
	/**
	 * Function creates the content of the drop down menu and fills it wit links from the DataCacheArray 
	 * @param dataCacheClass class name from the DataCacheArray (dataCacheClass, [link label], [link href])
	 */
	createFFDropDownMenu:function(dataCacheClass){
		var ffMenuContainerArray = getDataCacheArray(dataCacheClass);
		var tableBody = document.getElementById('ffDropDownMenuTableBody');
		if(tableBody.rows.length > 0){
			var rows = tableBody.rows.length;
			for(var i=0;i<rows;i++){
				tableBody.removeChild(tableBody.rows[tableBody.rows.length-1]);
			}
		}
		for(var element in ffMenuContainerArray){
			var tr = document.createElement('tr');
			tableBody.appendChild(tr);
			var td = document.createElement('td');
			tr.appendChild(td);
			var link = document.createElement('a');
			var linkText = document.createTextNode(element);
			link.href = ffMenuContainerArray[element];
			link.appendChild(linkText);
			td.appendChild(link);
			td.onmouseover = function(){ FFDropDownMenu.showFFDropDownMenu(); }
			td.onmouseout = function(){FFDropDownMenu.hideFFDropDownMenu(); }
		}
		var obj = document.getElementById('ffDropDownMenuCell_'+dataCacheClass);
		var pos = FFUniBrowser.getCurrentLocation(obj);
		var height = getComputedHeight('ffDropDownMenuCell_'+dataCacheClass);
		gE('ffDropDownMenuTable').style.top = (pos.top+height)+'px';
		gE('ffDropDownMenuTable').style.left = pos.left+'px';
		gE('ffDropDownMenuTable').style.display = "block";
	},
	
	/*
	 * Function displays the DropDownMenuContainer
	 */
	showFFDropDownMenu:function(){
		gE('ffDropDownMenuTable').style.display = "block";
	},
	
	/*
	 * Function hides the DropDownMenuContainer
	 */
	hideFFDropDownMenu:function(){
		gE('ffDropDownMenuTable').style.display = "none";
	}
};	    /////////////////////////////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////AJAX////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 /**
  * depricated
  */
 var http_request = false;

    function prepareRequest() {

        http_request = false;

        if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // zu dieser Zeile siehe weiter unten
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Ende :( Kann keine XMLHTTP-Instanz erzeugen');
            return false;
        }
   }
 
 function sendRequest(func, method, requestUrl){
         prepareRequest();
         http_request.onreadystatechange=func;
         http_request.open(method, requestUrl, true);
         http_request.send(null);
 }  
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////Image Cache///////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////    
    
//Array zum Cachen von Grafiken
var imageCache=new Array();

//schreibt ein Bild in den Image Cache
function setImageCache(cacheId, cacheSrc){
    imageCache[cacheId]=new Image();
    imageCache[cacheId].src=cacheSrc;
}

function changeImgSrc(imgId, cacheId){
   if(imageCache[cacheId]) document.getElementById(imgId).src=imageCache[cacheId].src;
}

var dataImageCache=new Array();
function createDataImageCacheClass(dataClass){
	  dataImageCache[dataClass]=new Array();

}

function setDataImageCacheSrc(dataClass, dataId, dataValue){
	 dataImageCache[dataClass][dataId]=new Image();
     dataImageCache[dataClass][dataId].src=dataValue;
}

function getDataImageCache(dataClass, dataId){
	 return dataImageCache[dataClass][dataId];
}

function getDataImageCacheArray(dataClass){
	 return dataImageCache[dataClass];
}

function getDataImageCacheArrayLength(dataClass){
	// alert(dataImageCache);
	 var a=dataImageCache[dataClass];
	 alert(dataImageCache[dataClass].join('a'));
	 return a.length;
}

function changeDataImgSrc(imgId, dataClass, dataId){
	//alert(dataImageCache[dataClass][dataId].src);
	 document.getElementById(imgId).src=dataImageCache[dataClass][dataId].src;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////URL Cache///////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//URL Cache
var urlCache=new Array();

function setUrlCache(cacheId, cacheUrl){
    urlCache[cacheId]=cacheUrl;
}

function getUrlCache(cacheId){
    return urlCache[cacheId];
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////Field Cache///////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//URL Cache
var fieldCache=new Array();

function setFieldCache(cacheId, cacheField){
    fieldCache[cacheId]=cacheField;
}

function getFieldCache(cacheId){
    return fieldCache[cacheId];
}

/**
* JavaScript DataCache for transfer custom data from html(php) to javascript
* @author Philipp Knoeller
*/
var dataCache=new Object();

/**
* @deprecated not needed anymore
*/
function createDataCacheClass(dataClass){
	  dataCache[dataClass]=new Object();
}

/**
* Puts a key/value pair to a dataClass of the DataCache
* If the dataClass does not exist, it will be created
* @author Philipp Knoeller
*/
function setDataCache(dataClass, dataId, dataValue){
	 if(!dataCache[dataClass]) dataCache[dataClass]=new Object();
	 dataCache[dataClass][dataId]=dataValue;
}

/**
* Gets a value of an entry of the class dataClass from the DataCache
* @author Philipp Knoeller
* @return mixed the value
*/
function getDataCache(dataClass, dataId){
	 return dataCache[dataClass][dataId];
}

/**
* Gets the content of a whole dataClass as an array
* @return array content of the dataClass
*/
function getDataCacheArray(dataClass){
	 return dataCache[dataClass];
}


var Funktor={
         FFLogo:{
	         href:'',
	         
	         blessLogo:function(logoId, href){
	              gE(logoId).removeAttribute("href"); 
	              gE(logoId).onmousedown=Funktor.FFLogo.logoMouseDown; 
	              gE(logoId).onmouseover=function(){ document.body.style.cursor='pointer'; };
	              gE(logoId).onmouseout=function() { document.body.style.cursor='default'; };
	              Funktor.FFLogo.href=href;
	              
	         },
	         
	         logoMouseDown:function(e){ 
	              var sac=FFUniBrowser.getShiftAltCtrl(e); 
	              
	              if(sac.ctrl) window.open("/ff"); else window.location=Funktor.FFLogo.href;
	         } 
         
         }
}


/**
 ******************************************************************
 *              Philipp Knöller Software Entwicklung              *
 *                        Framework Funktor                       *
 *                           Version 0.9b                         *
 *                                                                * 
 *                  http://pksoftware.de/funktor                  *
 *                                                                *
 ******************************************************************
 * 
 * FUtils.js
 * 
 * @author Philipp Knöller
 * @copyright Copyright &copy; 2006, Philipp Knöller
 * @link http://pksoftware.de/funktor
 * @version 1.0.0.1
 */

/**
 * PHP equivalent function for formating numbers
 * @author Philipp Knoeller
 */
function number_format (number, decimals, dec_point, thousands_sep){
	  var exponent = "";
	  var numberstr = number.toString ();
	  var eindex = numberstr.indexOf ("e");
	  if (eindex > -1){
	    exponent = numberstr.substring (eindex);
	    number = parseFloat (numberstr.substring (0, eindex));
	  }
	  
	  if (decimals != null){
	    var temp = Math.pow (10, decimals);
	    number = Math.round (number * temp) / temp;
	  }
	  var sign = number < 0 ? "-" : "";
	  var integer = (number > 0 ? 
	      Math.floor (number) : Math.abs (Math.ceil (number))).toString ();
	  
	  var fractional = number.toString ().substring (integer.length + sign.length);
	  dec_point = dec_point != null ? dec_point : ".";
	  fractional = decimals != null && decimals > 0 || fractional.length > 1 ? 
	               (dec_point + fractional.substring (1)) : "";
	  if (decimals != null && decimals > 0){
	       for (i = fractional.length - 1, z = decimals; i < z; ++i)
	          fractional += "0";
	  }
	  
	  thousands_sep = (thousands_sep != dec_point || fractional.length == 0) ? 
	                  thousands_sep : null;
	  if (thousands_sep != null && thousands_sep != ""){
		   for (i = integer.length - 3; i > 0; i -= 3)
	           integer = integer.substring (0 , i) + thousands_sep + integer.substring (i);
	  }
	  
	  return sign + integer + fractional + exponent;
}

/**
 * replaces a substring with another
 */
function replaceIt(string, suchen, ersetzen) {
    var 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;
}

/**
* cut off the px 
*/
function getPxValue(rawPx){
    if(rawPx==null){ return 0;}
    var tempX=rawPx.split('px');
    if(tempX.length==1){
         return tempX[0]=='px'?0:tempX[0];
    }
    else{
         return parseInt(tempX[0]);
    }
}

/**
 * Short form for document.getElementById
 */
function gE(elementId) { return document.getElementById(elementId); }

/**
 * Short form for document.getElementsByTagName
 */
function gT(tagName) { return document.getElementsByTagName(tagName); }


function findeFlash (flash) {
    if (document.all) {
      if (document.all[flash]) {
        return document.all[flash];
      }
      if (window.opera) {
        var movie = eval(window.document + flash);
        if (movie.SetVariable) {
          return movie;
        }
      }
      return;
    }
    if(document.layers) {
      if(document.embeds) {
        var movie = document.embeds[flash];
        if (movie.SetVariable) {
          return movie;
        }
      }
      return;
    }
    if (!document.getElementById) {
      return;
    }
    var movie = document.getElementById(flash);
    if (movie.SetVariable) {
      return movie;
    }
    var movies = movie.getElementsByTagName('embed');
    if (!movies || !movies.length) {
      return;
    }
    movie = movies[0];
    if (movie.SetVariable) {
      return movie;
    }
    return;
  }/**
 ******************************************************************
 *              Philipp Knoeller Software Entwicklung              *
 *                        Framework Funktor                       *
 *                           Version 0.9b                         *
 *                                                                * 
 *                  http://pksoftware.de/funktor                  *
 *                                                                *
 ******************************************************************
 * 
 * $Id: FWindows.js,v 1.1.2.2 2008/06/04 23:12:08 pknoeller Exp $
 * 
 * Module for managing Popups and Snap-Windows
 * 
 * @author Philipp Knoeller
 * @copyright Copyright &copy; 2006, Philipp Knoeller
 * @link http://pksoftware.de/funktor
 * @version 1.0.0.3
 * @package funktor_ffmain
 * @subpackage js
 */

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////Mouse Koordinaten////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////




//Maus Modus: normal, move
var windowMouseMode='normal';
var moveWindowId=null;









//////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////Window Blinking///////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////



//Componenten die blinken wollen (nach vollstaängigen Laden der seite + timeout) 
var wantBlinkWindows=new Array();
//Componenten die geschlossen werden wollen (nach vollstaängigen Laden der seite + timeout)
var wantCloseWindows=new Array();

//Alle Componenten der Seite
var xComponents=new Array();
function XComponent(componentId, componentType, shemeId, isMinimizable){
    this.componentId=componentId;
    this.componentType=componentType;
    this.width=0;
    this.blinkState=0;
    this.blinkTimer=null;
    this.shemeId=shemeId;
    this.isMinimizable=isMinimizable;
}

/**
* ein Component im JS System registrieren
*/
function registerComponent(componentId, componentType, shemeId, isMinimizable){
    var component=new XComponent(componentId, componentType, shemeId, isMinimizable);
    xComponents[componentId]=component;
}



/**
* setzt den Component auf die Blink Liste
*/
function setWindowBlink(windowId, timeout){
    wantBlinkWindows[windowId]=timeout;
}

/**
* setzt den Component auf die Schliess Liste
*/
function setWindowClose(windowId, timeout){
    wantCloseWindows[windowId]=timeout;
}

/**
* Component invertieren
*/
function invertComponent(componentId, invShemeId){
         var componentData=xComponents[componentId];
         if((componentData.blinkState%2)==0){
         	if(document.getElementById('xwindow_'+componentId+'_arrow_bg')){
              gE('xwindow_'+componentId+'_arrow_bg').style.display='none';
         	}
              setWindowShemeVariant(componentId, 'gelb');
         }
         else{
              resetWindowColors(componentId);
         }
         
         componentData.blinkState++;
         if(componentData.blinkState==4){
              window.clearInterval(componentData.blinkTimer);
         }
}

/**
* Component nach Verzoegerungs blinken lassen
*/
function startBlinkOnce(componentId, timeout){
        window.setTimeout("startStartBlink('"+componentId+"')", timeout);
}

/**
* Component sofort blinken lassen
*/
function startStartBlink(componentId, invShemeId){
	     if(xComponents[componentId]){
             var componentData=xComponents[componentId];
             if(componentData.blinkTimer){
                   window.clearInterval(componentData.blinkTimer);
                   componentData.blinkTimer=null;
                   componentData.blinkState=0;
             }
             componentData.blinkTimer=window.setInterval("invertComponent('"+componentId+"', '"+invShemeId+"')", 200);
	     }
}        

/**
* Componenten nach Verzoegerung schliessen(verstecken)
*/
function closeWindow(windowId, closeSeconds){
        if(gE('"+windowId+"')) window.setTimeout("gE('"+windowId+"').style.display='none';", closeSeconds*1000);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////Fester klappen///////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////

/**
* Standard Container ist der Zielcontainer wenn Zielcontainer nicht bestimmt werden kann
*/
var defaultContainerId=null;

/**
*setzt den Standard Container der aktuellen Seite
*/
function setDefaultContainer(containerId){
    defaultContainerId=containerId;
}

/**
*setzt den Standard Container der aktuellen Seite EINMAL
*/
function setDefaultContainerOnce(containerId){
    if(defaultContainerId==null){
         defaultContainerId=containerId;
    }
}

/**
*klappt ein Fenster auf/zu
*/
function klappWindow(windowId){
        if(windowMouseMode!='move'){
              setMinimized(windowId, !isMinimized(windowId));        
        }
}

//setzt die Eigenschaften des Fensters
function setWindowState(windowId, isMinimized, isAbsolut, isClosed){
       setMinimized(windowId, isMinimized);
}

/**
*prueft ob ein Fenster zugeklappt ist
*/
function isMinimized(windowId){
	var windowContentId='xw_window_'+windowId+'_content';
    if(!document.getElementById(windowContentId)){
         return false;
    }     
    return document.getElementById(windowContentId).style.display=='none';
}

/**
*minimiert ein Fenster
*/
function setMinimized(windowId, isMinimized){
	  var windowContentId='xw_window_'+windowId+'_content';
      if(!xComponents[windowId].isMinimizable && !document.getElementById(windowContentId)){
         return false;
      }
    //  if(isMinimized){
    //  	    xComponents[windowId].width=getComputedWidth(windowId);
    //  }
      document.getElementById(windowContentId).style.display=isMinimized==1?'none':'';
    //  if(!isMinimized){
    //  	     document.getElementById(windowId).style.width=xComponents[windowId].width+'px';
    //  }
      
      var arrowImgId='xw_window_'+windowId+'_arrow_bg';
      if(document.getElementById(arrowImgId)){
                document.getElementById(arrowImgId).className='xw_window_arrow_bg_' + (isMinimized==1 ? 'down' : 'up');
      }
      return true;
}

function setAllMinimized(isMinimized){
      for(var windowId in xComponents){
         component=xComponents[windowId];
         if((component.componentType=='xwindowsWindow') && component.isMinimizable=='1'){
              setMinimized(windowId, isMinimized);
         }
     }
}
var allMinimizedStatus=0;
function swapAllWindows(){
     var allOpen=0;
     var allClosed=0;
     for(var componentId in xComponents){
         component=xComponents[componentId];
         if(component.isMinimizable){
              var isMinimizedS=isMinimized(componentId);
              if(isMinimizedS){
                   allClosed++;
              }
              else{
                   allOpen++;
              }
         }
     }
         
     
     setAllMinimized(allOpen>allClosed ? 1 : 0);
//     document.getElementById('windowControlMinMaxIcon').src=imageCache[allMinimizedStatus ? 'xwindow_blue_arrowDown' : 'xwindow_blue_arrowUp'].src;
}
/**
*prueft ob ein Fenster in einem Container ist
*/
function isInContainer(windowId){
    if(!document.getElementById(windowId)){
       return false;
    }
    return document.getElementById(windowId).parentNode.className=='xwindowsContainer';
}

/**
*prueft on Object ein Container ist
*/
function isContainer(objectId){
    return document.getElementById(objectId).className=='xwindowsContainer';
}

/**
*prueft on Object ein Container ist
*/
function isWindow(objectId){
    return xComponents[objectId] && xComponents[objectId].componentType=='xwindowsWindow';
}

    
/**
*Funktion wird aufgerufen, wenn Maus Klick auf Fenster Titelleiste losgelassen wird
* klappt dieses Fenster(windowId) auf/zu wenn kein Fenster verschoben wird
* fuegt das verschobene Fenster vor diesem Fenster (windowId) ein
*/
function windowTitleMouseUp(windowId){
    if(windowMouseMode!='move'){
              if(xComponents[windowId].isMinimizable){
                   klappWindow(windowId);
              }
              windowMouseMode='normal';
         }
         else{
              if(isInContainer(windowId)){     
              windowBodyMouseUp(windowId);
              }
         } 
}

/**
*Funktion wird aufgerufen, wenn Maus Taste auf Fenster Titelleiste runtergedrueckt wurde
* setzt dieses Fenster(windowId) als "Verschiebe" Fenster
* speichert aktuelle Mauskoordinaten
*/
function windowTitleMouseDown(windowId){
    if(isInContainer(windowId)){     
         FFWindows.oldMouseX=FFUniBrowser.mouseX;
         FFWindows.oldMouseY=FFUniBrowser.mouseY;
         
         windowMouseMode='mouseDown';
         moveWindowId=windowId;
         
         setTextSelectEnabled(false);
    }
}



/**
*Funktion wird aufgerufen, wenn Maus Taste ueber Fenster Content losgelassen wird
*fuegt "Verschiebe" Fenster vor diesem Fenster(windowId) ein, falls Fenster verschoben wird
*/
function windowBodyMouseUp(windowId){
         if(windowMouseMode=='move'){
              if(isInContainer(windowId)){     
              if(windowId!=moveWindowId){
              
              resetWindowColors(moveWindowId);
              var moveWindow=document.getElementById(moveWindowId);
              moveWindow.style.position='';
              moveWindow.style.width='';
              
              moveWindowId=null;
              windowMouseMode='normal';
              
              var windowBottom=document.getElementById(windowId);
              windowBottom.style.borderColor='red';
              windowBottom.style.borderTopStyle='none';
              
              targetContainerId=windowBottom.parentNode.id;
              document.getElementById(targetContainerId).insertBefore(moveWindow, windowBottom);
              setTextSelectEnabled(true);
              
//            gE('inviteUserTextField').value=targetContainerId;
//            document.getElementById(targetContainerId).appendChild(moveWindow);
              
              }
              }
         }
}          

/**
*Funktion wird aufgerufen, wenn Maus Taste ueber restlicher Seite losgelassen wird
*/
function bodyMouseUp(){
        containerMouseUp(defaultContainerId);
}


         
/**
* setzt das Fenster auf Normal Farben zurueck
*/
function resetWindowColors(windowId){

        setWindowShemeVariant(windowId, xComponents[windowId].shemeId);         
        //if(xComponents[windowId].componentType=='xwindowsWindow'){
        if(document.getElementById('xwindow_'+windowId+'_arrow_bg')){
        document.getElementById('xw_window_'+windowId+'_arrow_bg').style.display='';              
        }
        //}
}

function setWindowShemeVariant(windowId, shemeId){
        document.getElementById(windowId).className=shemeId;
        return true;
}       

/**
*Funktion wird aufgerufen, wenn Maus Taste ueber einem Container losgelassen wird
* fuegt "Verschiebe" Fenster an letzter Stelle des Containers ein
*/
function containerMouseUp(containerId){
        if(windowMouseMode=='move'){
              resetWindowColors(moveWindowId);
              
              
              document.getElementById(moveWindowId).style.position='';
              document.getElementById(moveWindowId).style.width='';
              container= document.getElementById(containerId);
              container.appendChild(document.getElementById(moveWindowId));
              moveWindowId=null;
              windowMouseMode='normal';
            
              setTextSelectEnabled(true);
//              document.getElementById(containerId).style.borderColor='red';
            //  document.getElementById(containerId).style.backgroundColor='transparent';
              
         }
}

/**
*Funktion wird aufgerufen, wenn Maus ueber einem Container bewegt wird
*/
function containerMouseOver(containerId){
 
        if(windowMouseMode=='move'){
               //gE('inviteUserTextField').value='a' + containerId;
            //  document.getElementById(containerId).style.backgroundColor='red';
    //          document.getElementById(containerId).style.borderTopStyle='solid';
  //            document.getElementById(containerId).style.borderTopWidth='1px';
        }
}

/**
*Funktion wird aufgerufen, wenn Maus einen Container verlaesst
*/
function containerMouseOut(containerId){
        if(windowMouseMode=='move'){
             // document.getElementById(containerId).style.backgroundColor='transparent';
//              document.getElementById(containerId).style.borderTopStyle='none';
              
        }
}

/**
*Funktion wird aufgerufen, wenn Maus Taste ueber Fenster Content bewegt wird
* zeigt den oberen Rahmen des Fensters rot an
*/
function windowMouseMove(windowId){
         if(windowMouseMode=='move'){
              if(isInContainer(windowId)){     
                    if(windowId!=moveWindowId){
                           document.getElementById(windowId).style.borderColor='red';
                           document.getElementById(windowId).style.borderTopStyle='solid';
                    }
              }
         }
         
         //alert(autoOpen);
}

/**
*Funktion wird aufgerufen, wenn Maus den Fenster Koerper verlaesst
* schaltet den oberen Rahmen des Fensters wieder transparent
*/

function windowMouseOut(windowId){
        if(windowMouseMode=='move'){
              if(isInContainer(windowId)){     
              if(windowId!=moveWindowId){
              document.getElementById(windowId).style.borderColor='red';
              document.getElementById(windowId).style.borderTopStyle='none';
              }
              }
         }
         
}

/**
* aendert den Status eines Fensters inklusive Eltern Container
*/
function changeWindowState(windowId, containerId, containerIndex, isMinimized, isAbsolut, isClosed){
              if(document.getElementById(containerId) && isInContainer(windowId)){
                   container= document.getElementById(containerId);
                   if(document.getElementById(windowId)){
                        container.appendChild(document.getElementById(windowId));
                        setWindowState(windowId, isMinimized, isAbsolut, isClosed);
                   }
              }
}

/**
*speichert die States der Fenster einer Seite via AJAX auf dem Server ab
*/
function saveWindowsStates(saveWindowsUrl, userId, pageId){
         var getAdd='';
         
         var allCon=new Array();
         var allCells=document.getElementsByTagName('td');
         for(var i=0; i<allCells.length; i++){
              if(allCells[i].className=='xwindowsContainer'){
                   allCon.push(allCells[i].id);
              }
         }
         
         var allContainer=document.getElementsByTagName('div');
         for(var i=0; i<allContainer.length; i++){
              if(allContainer[i].className=='xwindowsContainer'){
                   allCon.push(allContainer[i].id);
              }
         }
         
         for(var i=0; i<allCon.length;i++){
                 var con=document.getElementById(allCon[i]);
                 var components=con.childNodes;
                 for(var j=0; j<components.length; j++){
                        if(xComponents[components[j].id] && xComponents[components[j].id].componentType=='xwindowsWindow'){
                        getAdd = getAdd + '&' + components[j].id  + '=' + allCon[i] + ',' + j + ',' +(isMinimized(components[j].id) ? 1 : 0)+',0,0';
                        }
                 }              
         }
         
         var sa=new FAjax(saveWindowsUrl, false);
         sa.setGetString('sId='+userId+'&pageId='+pageId + getAdd);
         if(!sa.sendRequest('GET', saveWindowsStatesResponse)){
                    prepareTitleTable('hintsSliderTable', 'white', '', 'Hinweis', '');
                  	addTitleTableSubRow('hintsSliderTable', '', 'Die Fenster konnten nicht gespeichert werden.');
                  	showSliderWindow('hintsSliderWindow', 0.1, 10)
         }
}

/**
* gibt die Antwort der Fenster State Speicherung zurueck
*/
function saveWindowsStatesResponse() {
        prepareTitleTable('hintsSliderTable', 'white', '', 'Hinweis', '');
        addTitleTableSubRow('hintsSliderTable', '', entrys[0].getAttribute('an') + ' Fenster wurden gespeichert.');
        showSliderWindow('hintsSliderWindow', 0.1, 10);             
} 



//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////Content Select Fenster///////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

var winsels=new Array();

function registerWinsel(winselId){
	  
	      winsels[winselId]=new Array();
	  
}

function registerWinselWindow(winselId, windowId){
	  winsels[winselId].push(windowId);
}

//versteckt alle Eingabefenster im Tagebuch
function hideWinselWindows(winselId){
        //alert(winselId);
	    var allWindows=winsels[winselId];
	     
        for(var i=0; i<allWindows.length; i++){
              gE(allWindows[i]).style.display='none';
        }
}

function ff_show_switch_option(switchId){
       ff_change_switch_option(switchId, gE('ff_switch_'+switchId).value);
}

function ff_change_switch_option(switchId, optionKey){
       hideWinselWindows(switchId);
	   gE('ff_switch_option_'+optionKey).style.display='';	 
	   gE('ff_switch_'+switchId).value=optionKey;
}

function ff_lock_switch(switchId, isLocked){
	   gE('ff_switch_'+switchId).disabled=isLocked? 'disabled': '';
}




/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////Popups//////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
function setPopupVisible(popupId, isVisible){
	 var popupLayer=document.getElementById(popupId+'Layer');
     
     var selectBoxes=document.getElementsByTagName('select');
     if(isVisible){
         
                 for(var j=0; j<selectBoxes.length; j++){
                        if(selectBoxes[j].style.zIndex!='300'){  //z-index:300 ist im Moment Kriterium für in jedem Fall sichtbar bleiben
                        selectBoxes[j].style.visibility='hidden';
                        }
                 }
         
         if(popupLayer){        
             var popupLayerStyle=popupLayer.style;
             var dimensions=getWindowDimensions();
             var pageDim=getPageDimensions();
             popupLayerStyle.width=dimensions[0]+'px';
             popupLayerStyle.height=pageDim[1]+'px';
             popupLayerStyle.display='';
         }
         gE(popupId).style.display='';
     }
     else{
         
         for(var j=0; j<selectBoxes.length; j++){
                        selectBoxes[j].style.visibility='visible';
         }
         if(popupLayer){
         	 var popupLayerStyle=popupLayer.style;
             popupLayerStyle.width='0px';
             popupLayerStyle.height='0px';
             popupLayerStyle.display='none';
         }
         gE(popupId).style.display='none';
     }            
}



////////////////////////////////////////////////////////////////////////////////
////////////////////FFWindow////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

var FFWindows={
         oldMouseX:0,
         oldMouseY:0,
         
         bodyOnloadWindowJobs:function(){
	         for(var windowId in wantBlinkWindows){
	              startBlinkOnce(windowId, wantBlinkWindows[windowId]);
	         } 
	         
	         for(var windowId in wantCloseWindows){
	              closeWindow(windowId, wantCloseWindows[windowId]);
	         }
	    },
	    
	    bodyOnmousemoveWindowJobs:function(){
	             var mX=FFUniBrowser.mouseX;
                 var mY=FFUniBrowser.mouseY;
	             var wantMove=false;
		         //windowsMouseMode auf "move" setzen falls Maus bei gerueckter Maustaste bewegt wird
		         if(windowMouseMode=='mouseDown'){
		              if((Math.abs(FFWindows.oldMouseX-mX)>20)||(Math.abs(FFWindows.oldMouseY-mY)>20)){
		                   wantMove=true;
		              }
		         }
         
		         //Fenster auf "move" Modus setzen
		         if(wantMove){
		              windowMouseMode="move";
		              document.getElementById(moveWindowId).style.position='absolute';
		              if(document.getElementById('xwindow_'+moveWindowId+'_arrow_bg')){
		              gE('xwindow_'+moveWindowId+'_arrow_bg').style.display='none';
		              }
		              setWindowShemeVariant(moveWindowId, 'gelb');
		         }
		         
		         //Fenster bewegen falls windowMouseMode="move"
		         if(windowMouseMode=='move'){
		                   document.getElementById(moveWindowId).style.left=mX+13+'px';
		                   document.getElementById(moveWindowId).style.top=mY+13+'px';
		                  // document.getElementById(moveWindowId).style.width=300+'px';
		         }
         }
}



/**
 ******************************************************************
 *              Philipp Knoeller Software Entwicklung              *
 *                        Framework Funktor                       *
 *                           Version 0.9b                         *
 *                                                                * 
 *                  http://pksoftware.de/funktor                  *
 *                                                                *
 ******************************************************************
 * 
 * $Id: FFSliderWindows.js,v 1.1.2.1 2008/04/06 20:41:44 pknoeller Exp $
 * 
 * Module for managing Slider-Windows
 * 
 * @author Philipp Knoeller
 * @copyright Copyright &copy; 2006, Philipp Knoeller
 * @link http://pksoftware.de/funktor
 * @version 1.0.0.2
 * @package funktor_ffmain
 * @subpackage js
 */
 
var FF_SLIDER_MAX_DIRECTION=1000;

/**
* Array for all slider window objects
**/
var ffSliderWindows=new Array();

/**
* Data holder for a slider window
*/
function SliderWindow(sliderId){
	this.sliderId=sliderId;
	
	this.width=null;
	this.height=null;
	
	this.side=null;
	this.timer=null;
	this.direction=0;
	this.waitTime=0;
	this.step=0;
	
	this.init=function(side, xy, slideStep, waitTime){
	     if(!side) side='top';
	     if(!xy) xy=0;
	     if(!slideStep) slideStep=4;
	     if(!waitTime) waitTime=1000;
	     
	     this.side=side;
	     this.direction=0;
         this.waitTime=waitTime;
	     
	     var sliderStyle=document.getElementById(this.sliderId).style;
	     var pageDim=getVisiblePageSize(); 
	     var scrollY=FFUniBrowser.getScrollY();	    
	     var scrollX=FFUniBrowser.getScrollX();
	     this.height=getComputedHeight(this.sliderId);
	     this.width=getComputedWidth(this.sliderId);
	            
	     
	     if(this.side=='top'){
	         sliderStyle.top=(scrollY-this.height-40)+'px';
	         this.step=slideStep;
	         if(xy) sliderStyle.left=xy+'px';
         }
         else if(this.side=='bottom'){
            sliderStyle.top=(pageDim.height+scrollY+40)+'px';
            this.step=-slideStep;
            if(xy) sliderStyle.left=xy+'px';
         }
         else if(this.side=='left'){
            sliderStyle.left=(scrollX-this.width-40)+'px';
            this.step=slideStep;
            if(xy) sliderStyle.top=xy+'px';
         }
         else if(this.side=='right'){
            sliderStyle.left=(pageDim.width+scrollX+40)+'px';
            this.step=-slideStep;
            if(xy) sliderStyle.top=xy+'px';
         }
         
         
         
	}
	
	this.isHorOrVert=function(){
	     return this.side=='left' || this.side=='right';
	}
	
	this.closeWindow=function(){
		 this.direction=this.waitTime;
	}
	
	this.getOpenLimit=function(newLeftTop){
	    var scrollY=FFUniBrowser.getScrollY();
	    var scrollX=FFUniBrowser.getScrollX();
	     var pageDim=getVisiblePageSize();
	    if(this.side=='top'){
	          return newLeftTop>scrollY ? scrollY : null;
	    }      
	    else if(this.side=='bottom'){
	          var limit=pageDim.height+scrollY-this.height;
	          return newLeftTop<limit ? limit : null;
	    }
	    else if(this.side=='left'){
	          return newLeftTop>scrollX ? scrollX : null;
	    }      
	    else if(this.side=='right'){
	          var limit=pageDim.width+scrollX-this.width;
	          return newLeftTop<limit ? limit : null;
	    }      
	 }    
	 
	 this.getCloseLimit=function(newLeftTop){
	      var scrollY=FFUniBrowser.getScrollY();
	      var scrollX=FFUniBrowser.getScrollX();
	     var pageDim=getVisiblePageSize();
	      if(this.side=='top'){ 
	          var limit=-(this.height+20);
	          return newLeftTop< limit ? limit : null;
	      }
	      else if(this.side=='bottom'){
	           var limit=pageDim.height+scrollY+20;
	           return newLeftTop>limit ? limit : null;
	      }
	      else if(this.side=='left'){ 
	          var limit=-(this.width+20);
	          return newLeftTop< limit ? limit : null;
	      }
	      else if(this.side=='right'){
	           var limit=pageDim.width+scrollX+20;
	           return newLeftTop>limit ? limit : null;
	      }
	          
	 }   
	 
	 this.openStep=function(){
	             var sliderStyle=document.getElementById(this.sliderId).style;
      	         var isHor=this.isHorOrVert();
      	         var oldLeftTop=getPxValue(isHor ? sliderStyle.left : sliderStyle.top);
      	         var newLeftTop=oldLeftTop+parseInt(this.step);
      	         var limit=this.getOpenLimit(newLeftTop);
      	         if(null != limit){
		         	   if(isHor)
		         	   sliderStyle.left=limit + 'px';
		         	   else
		         	   sliderStyle.top=limit + 'px';
		     	       
		     	       this.direction++;
		     	 }
		         else if(this.direction==0){
	                  if(isHor)
		         	   sliderStyle.left=newLeftTop + 'px';
		         	   else
		         	   sliderStyle.top=newLeftTop + 'px';	   
		         }
      }	
      
      this.closeStep=function(){
                 var sliderStyle=document.getElementById(this.sliderId).style;
	              var isHor=this.isHorOrVert();
	              var oldLeftTop=getPxValue(isHor ? sliderStyle.left : sliderStyle.top);
	             this.direction=this.waitTime;
		         var newLeftTop=oldLeftTop-parseInt(this.step);
	     	     var limit=this.getCloseLimit(newLeftTop);
	     	     if(null!=limit){ 
		                window.clearInterval(this.timer);
		                gE(this.sliderId).style.display='none';
		         }
		         else{
		         	   if(isHor)
		         	   sliderStyle.left=newLeftTop + 'px';
		         	   else
		         	   sliderStyle.top=newLeftTop + 'px';	      
		         }
      }	      
      
      this.slideStep=function(){
               if(this.direction<this.waitTime)
      	         this.openStep();
	           else  
	             this.closeStep();
	  }          
}



/**
* Registers/Shows a slider window
*/
function registerSliderWindow(sliderWindowId, intervalSeconds, slideStep, waitTime, xy, side){

	     gE(sliderWindowId).style.display='';
	     
	     if(!ffSliderWindows[sliderWindowId]){
	            ffSliderWindows[sliderWindowId]=new SliderWindow(sliderWindowId);
	     }
	     
	     
	     var sliderWindow=ffSliderWindows[sliderWindowId];
	     
	     sliderWindow.init(side, xy, slideStep, waitTime==0 ? Math.max(30, sliderWindow.height/4) : waitTime);
         if(intervalSeconds) sliderWindow.timer=window.setInterval("sliderWindowTimer('"+sliderWindowId+"')", intervalSeconds*1000);
         
}

/**
* Variable for universal slider timer
**/
var sliderWindowsTimer;

/**
* Starts the universal slider timer. It is responsible for all slider windows who do not have own timers.
**/
function startSliderTimer(intervalSeconds){
	  sliderWindowsTimer=window.setInterval("showSliderWindows()", intervalSeconds*1000)
}

/**
* Stops the universal slider timer
**/
function stopSliderTimer(){
	  window.clearInterval(sliderWindowsTimer);
}

/**
* Timer function for universal slider timer
**/
function showSliderWindows(){
	//alert(ffSliderWindows['instant_messaging']);
	  for(var wId in ffSliderWindows){
	  	     if(!ffSliderWindows[wId].timer) sliderWindowTimer(wId);
	  }
	
}

/**
* Timer function for a slider window
*/
function sliderWindowTimer(sliderWindowId){
	     if(!ffSliderWindows[sliderWindowId]) return;
	     ffSliderWindows[sliderWindowId].slideStep();
}

/**
* Makes a slider to close itself
*/
function closeSlideWindow(sliderWindowId){
	   if(!ffSliderWindows[sliderWindowId]) return;
	   ffSliderWindows[sliderWindowId].closeWindow();
}/**
 ******************************************************************
 *              Philipp Knoeller Software Entwicklung             *
 *                        Framework Funktor                       *
 *                           Version 1.0                          *
 *                                                                * 
 *                  http://pksoftware.de/funktor                  *
 *                                                                * 
 *                       ALL RIGHTS RESERVED                      *
 *                                                                *
 ******************************************************************
 * 
 * $Id: FFInstantMessaging.js,v 1.1.2.5 2008/04/24 11:14:07 pknoeller Exp $
 * 
 * @author Philipp Knoeller
 * @copyright Copyright &copy; 2006, Philipp Knoeller
 * @link http://pksoftware.de/funktor
 * @version 1.0.0.4
 * @package funktor_ffim
 * @subpackage js
 */

/**
 * fills IM Slider Window
 * @author Philipp Knöller
 * @access private
 */
  function _ffFillImWindow(xmldoc, requestId){
  	   var status=xmldoc.getElementsByTagName("status");
  	   
  	   if(status.length>0){
  	   var statusId=status[0].getAttribute('status_id');
  	   var statusMsg=status[0].getAttribute('status_msg');
  	   
  	   var actionStatusId=status[0].getAttribute('action_status');
  	   
  	   if(statusId=='MESSAGE_LIST'){
	  	   var entrys=xmldoc.getElementsByTagName("im");
	  	   for(var j=0; j<entrys.length; j++){
	  	   	    var entry=entrys[j];
	  	   	    var i=entry.getAttribute("id");
	  	        if(!ffSliderWindows['instant_messaging_'+ i]){
	  	             var imSubject=entry.getElementsByTagName('subject')[0].firstChild.nodeValue;
	  	             ffCreateImWindow('instant_messaging_'+ i, i);
	  	             registerSliderWindow('instant_messaging_'+ i, null, 20, 100000,20,'right');
	  	             gE('instant_messaging_'+ i+'_sender').firstChild.nodeValue=entry.getElementsByTagName('from')[0].firstChild.nodeValue;
	  	             //gE('instant_messaging_'+ i+'_receiver').value=entry.getAttribute("from_id");
	   	             gE('instant_messaging_'+ i+'_sender_subject').firstChild.nodeValue=imSubject;
	   	           	 gE('instant_messaging_'+ i+'_subject').value="Re: "+imSubject;
	  	             gE('instant_messaging_'+ i+'_sender_text').innerHTML=entry.getElementsByTagName('message')[0].firstChild.nodeValue;
	  	             gE('instant_messaging_'+ i+'_markAsRead').style.display='';
	  	             gE('instant_messaging_'+ i+'_showLater').style.display='';
	  	             gE('instant_messaging_'+ i+'_new_message_div').style.display='none';
	  	             gE('instant_messaging_'+ i+'_response_div').style.display='';
	  	             findeFlash('ffImNotifier').Play();
	  	             
	  	        }
	  	   }
  	   }
  	   
  	   if(actionStatusId!='NO_ACTION'){
  	          // alert(statusMsg);
  	          showHintMessage('Hinweis', actionStatusId);
  	   }
  	   }
  }
  
  /**
   * Funktor Ajax Objekt
   */
  var ffImService=new FAjax(null);
  
  /**
   * Message check 
   * @author Philipp Knöller
   * @access private
   */
  function _ffImService(){
  	     //ffImService.setGetString('sm=ass&search='+sString);
        // alert('f');
         ffImService.sendRequest('GET', _ffFillImWindow);
  }
  
  function ffImNewMessage(){
         ffCreateImWindow('instant_messaging_0', 0);
         gE('instant_messaging_0_new_message_div').style.display='';
	  	             gE('instant_messaging_0_response_div').style.display='none';
	  	 registerSliderWindow('instant_messaging_0', null, 20, 100000,20,'right');
  }
  
  function ffImSelectUserName(windowId){
         var toUserName=getSelectedOptionLabel(windowId+'_user_search_sugg_select');
         gE(windowId+'_user_search').value=toUserName;
         gE(windowId+'_user_search_sugg').style.display='none';
  }
  
  function ffImMarkAsRead(windowId, msgId){
  	     ffImService.sendRequest('GET', _ffFillImWindow, null, 'action=updateMessage&mi='+msgId);
  	     closeSlideWindow(windowId);
  }
  
  function ffImAnswer(windowId, msgId){
  	     var answerSubject=gE(windowId+'_subject').value;
  	     var answerText=gE(windowId+'_text').value;
  	     
  	     var toUserName=gE(windowId+'_user_search').value;
  	     
  	     ffImService.sendRequest('POST', _ffFillImWindow, null, 'action=sendMessage&mi='+msgId+'&toUser='+toUserName, 'subject='+answerSubject+'&text='+answerText);
  	     closeSlideWindow(windowId);
  }
  
  /**
   * starts IM Service
   * @author Philipp Knöller
   * @access public
   */
  function ffStartImService(url, interval){
  	   ffImService.setUrl(url);
  	   ffImService.start_search(_ffImService, interval*1000);
  	   _ffImService();
  } 
  
  /**
   * stops IM Service
   */
  function ffStopImService(){
      ffImService.stop_search();
      
  }
  
  

  /**
 * $Id: features.js,v 1.35.4.26 2008/07/08 13:46:13 pknoeller Exp $
 * 
 * @author Philipp Knoeller
 * @copyright Copyright &copy; 2006, Nutropoly GmbH
 * @link http://www.nutropoly.de
 * @version 1.0.0.1
 */
 
var NutropolyJavaScript={
        /**
		* Funktion wird aufgerufen wenn das Dokument im Browser fertig geladen wurde
		*/
		onLoadFunction:function(){
		         
		         FFWindows.bodyOnloadWindowJobs(); 
		         
		
		         
		         /** Test **/
		         var pageDim=getVisiblePageSize(); 
			     var scrollY=FFUniBrowser.getScrollY();
			     var scrollX=FFUniBrowser.getScrollX();
			   //  alert(pageDim.width+'-'+pageDim.height+'-'+scrollX+ '-'+scrollY);
			    // alert(document.body.offsetWidth);	
		},
		
		//der Maus folgen
		bodyOnMouseMove:function(evt) {
		    if (document.getElementById) {
		         //aktuelle Maus Koordinaten setzen
		         FFUniBrowser.refreshMouseCoordinates(evt);
		         var mX=FFUniBrowser.mouseX;
		         var mY=FFUniBrowser.mouseY;
		         
		         FFWindows.bodyOnmousemoveWindowJobs();
		         
		         if(document.getElementById('titleTable')){
			         //Popuptable bewegen
			         var obj = document.getElementById('titleTable').style; 
			         if(obj.display!='none'){
			             obj.left = parseInt(mX+(mX>500 ? - 320 : 20)) + 'px'; 
			             obj.top = parseInt(mY + (mY-FFUniBrowser.getScrollY()>400 ? -120 : 20)) + 'px';
			         }
		         }
		        
		    }
		    return true;
		} 
};
document.onmousemove=NutropolyJavaScript.bodyOnMouseMove;


/////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////Tagebuch suche starten/////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//DEPRECATED



var eatSearchTimer=null;

var searchMode=1;
var searchUrl=null;
var spFound=false;

function setSearchUrl(surl){
    searchUrl=surl;
}

function startEatSearch(sm, searchTextFieldName, searchHintElement){
         eatSearchTimer=window.setInterval("ajaxSearch('"+searchUrl+"', '" + sm + "', '" + searchTextFieldName + "', '"+ searchHintElement + "')", 500);
}

function setSearchMode(sm, searchTextFieldName, searchTargetField, searchHintElement){
   //Bei Klick nach erfolgreicher Suche Felder leeren
   if(spFound){
         document.getElementById(searchTextFieldName).value='';
         if(searchTargetField){
              document.getElementById(searchTargetField).value='';
         }
   }
   //Falls Suche laeuft --> anhalten
   if(eatSearchTimer){
       stopEatSearch();
   }
   //Neue Suche starten

   startEatSearch(sm, searchTextFieldName, searchHintElement);
}

function hasAjaxTextFieldChanged(textFieldId, minLength, notValue,doNotCacheField){
    var field=gE(textFieldId);
    var newSearchString=field.type=='checkbox' ? (field.checked?'1':'0') : field.value;
    var oldSearchString=getFieldCache(textFieldId);
    if ( (oldSearchString!=newSearchString) &&
             ((null==minLength) || (newSearchString.length>=minLength)) &&
             ((null==notValue) || newSearchString!=notValue) ) {
              
              if(!doNotCacheField) setFieldCache(textFieldId, newSearchString);
              return newSearchString;
              }
               return null;
}

function hasAjaxListChanged(textFieldId, notValue){
    var optionValues=getOptionValues(textFieldId);
    var newSearchString=optionValues.join(',');
    var oldSearchString=getFieldCache(textFieldId);
    return (oldSearchString!=newSearchString) && (newSearchString!=notValue)? newSearchString : null;
}

/**
 * depricated 24.04.2007
 * @author Philipp KnÃ¶ller
 */
function ajaxOnce(sm, searchTextFieldName, searchHintElement){
         return ajaxSearch(searchUrl,sm, searchTextFieldName, searchHintElement);
}

/**
 * depricated 24.04.2007
 * @author Philipp KnÃ¶ller
 */
function ajaxSearch(url, sm, searchTextFieldName, searchHintElement){

         if(sm=='con'){
              var newSearchString=hasAjaxTextFieldChanged(searchTextFieldName, 2);
              if(newSearchString){
                   //sm='bls';
                   sendRequest(fillConFormSelect, 'GET', url+'?sm='+sm+'&search='+newSearchString);
                   changeImgSrc('hourglassesImg', 'hourglasses');
                   setFirstNodeValue(searchHintElement, 'Bitte warten...');
                   setFieldCache(searchTextFieldName, newSearchString);
              }
        }

        
         else{
              return false;
         }
}


/**
   *
   * @author Philipp KnÃ¶ller
   * @depricated 26. 04. 2007
   */
function stopEatSearch(){
         window.clearInterval(eatSearchTimer);
}



  function showRezepteSearchZutatenPopup(){
//     document.getElementById('diarySearchWindow').style.display='none' ;
  //   return;
            var popupLayerStyle=document.getElementById('rezepteSearchZutatenPopup').style;
            if(popupLayerStyle.display=='none'){
                 setPopupVisible('rezepteSearchZutatenPopup', true);
           }
           else{
                 setPopupVisible('rezepteSearchZutatenPopup' , false);
           }
 }
   /**
   *
   * @author Philipp KnÃ¶ller
   * @depricated 26. 04. 2007
   */
   function fillDiarySearchSelect(){
          alertInhalt('', 'es_suggSelect', 'es_suggDiv', '', 'diarySearchHintTd' );
   }

   /**
   *
   * @author Philipp KnÃ¶ller
   * @depricated 26. 04. 2007
   */
   function fillMiniRezeptSearchSelect(){
          alertInhalt('', 'zutatSuggSelect', 'zutatSuggDiv', '', 'zutatHintDiv' );
   }


   /**
   *
   * @author Philipp KnÃ¶ller
   * @depricated 26. 04. 2007
   */
   function fillConFormSelect(){
          gE('conDataTable').style.display='none';
          alertInhalt('', 'zutatSuggSelect', 'zutatSuggDiv', '', 'zutatHintDiv' );
          fillConForm()
   }

   /**
   *
   * @author Philipp KnÃ¶ller
   * @depricated 26. 04. 2007
   */
   function fillInfoBls(){
   	      gE('infoLebensmittelContainer').style.display='none';
          alertInhalt('', 'zutatSuggSelect', 'zutatSuggDiv', '', 'zutatHintDiv' );
          fillBlsInfoForm()
   }

   /**
   *
   * @author Philipp KnÃ¶ller
   * @depricated 26. 04. 2007
   */
   function fillInfoBewegung(){
   	      gE('infoBewegungContainer').style.display='none';
          alertInhalt('', 'zutatSuggSelect', 'zutatSuggDiv', '', 'zutatHintDiv' );
         // alert('D');
          fillBewegungInfoForm();
   }



   /**
   * FÃ¼llt die SelectBox mit den entsprechenden EintrÃ¼gen
   * @author Philipp KnÃ¶ller
   * @depricated 26. 04. 2007
   */
   function alertInhalt(searchTextFieldName, searchSelectBox, searchSelectDiv, searchTargetField, searchHintElement) {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var xmldoc = http_request.responseXML;

               //alert(xmldoc.childNodes.length);
                   if(xmlToSelectBox(xmldoc, searchSelectBox, searchSelectDiv)){
                   	    setFirstNodeValue(searchHintElement, 'Zum AuswÃ¤hlen DOPPELT auf die AktivitÃ¤t klicken.');
                   }
                   else{
                  	    setFirstNodeValue(searchHintElement, 'Keine passenden EintrÃ¤ge.');
                   }
                     	   changeImgSrc('hourglassesImg', 'blankImg');
            }
          }
            else {
                 setFirstNodeValue(searchHintElement, 'Die Suche ist im Augenblick ausser Betrieb. Bitte versuchen Sie es zu einem spÃ¤teren Zeitpunkt noch einmal.');
                 gE(searchSelectDiv).style.display='none';
            }

    }

/**
* WÃ¤hlt einen Eintrag aus der Liste aus und setzt das Nummerfeld
* @author Philipp KnÃ¶ller
*/
function setProduktName(searchTextFieldName, searchSelectBox, searchSelectDiv, searchTargetField, searchHintElement){
      var selectedValue=gE(searchSelectBox).value;
      if((selectedValue!='')&&(selectedValue!='-1000')){
           document.getElementById(searchHintElement).firstChild.nodeValue='Geben Sie die PortionsgrÃ¶sse an. Klicken Sie auf das Textfeld um eine neue Suche zu starten.';
           document.getElementById(searchTargetField).value=selectedValue;
           document.getElementById(searchTextFieldName).value=document.getElementById(searchSelectBox).options[document.getElementById(searchSelectBox).selectedIndex].firstChild.nodeValue;
           document.getElementById(searchSelectDiv).style.display='none';
           spFound=true;
           stopEatSearch();
     }
}

function enableSendButton(){
     document.getElementById('sendButton').disabled='';
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////Rezepte/////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////


var mengeEinheiten=new Array();
/**
* laedt eine Gewichtseinheit in den JS Speicher
* @author Philipp KnÃ¶ller
*/
function setMengeEinheit(key, value){
    mengeEinheiten[key]=value;
}


var weightEinheiten=new Array();
/**
* laedt eine Gewichtseinheit in den JS Speicher
* @author Philipp KnÃ¶ller
*/
function setWeightEinheit(key, value){
    weightEinheiten[key]=value;
}










function conSearchIncomplete(){
   gE('zutatNameInput').value='CON_INCOMPLETE'+Math.round(Math.random()*100);
   ajaxOnce('con', 'zutatNameInput', 'zutatHintDiv');
  // fillConForm();
}

var conSearchId=0;
function conSearchDirect(a){
   conSearchId=parseInt(gE('con_id_input').value);
   if(isNaN(conSearchId)||conSearchId<0){
         conSearchId=0;
   }
   conSearchId+=a;
   gE('zutatNameInput').value='CON_'+conSearchId;
   ajaxOnce('con', 'zutatNameInput', 'zutatHintDiv');
}

/**
* fÃ¼lltdas Formular im Connector Editor
* @author Philipp KnÃ¶ller
*/
function fillBewegungInfoForm(){
	var conData=gE('zutatSuggSelect').value;
    if((conData!='')&&(conData!='-1000')){
          // document.getElementById('zutatSuggDiv').style.display='none';
          // spFound=true;
          // stopEatSearch();
    }
    var temp="";
	var conArray=conData.split(',');
    if(conArray.length>3){
	     var bewegungInfoLabel=getSelectedOptionLabel('zutatSuggSelect');
	     setFirstNodeValue('bewegungInfoLabelTd', bewegungInfoLabel)
	     setFirstNodeValue('info_10min', conArray[1]);
	     	     setFirstNodeValue('info_20min', conArray[2]);
	     	     	     setFirstNodeValue('info_30min', conArray[3]);
	     	     	     	     setFirstNodeValue('info_60min', conArray[4]);
	      gE('infoBewegungContainer').style.display='';
	      	      gE('infoBewegungIntroContainer').style.display='none';
	}
	else{
//	     setFirstNodeValue('conIdSpan', '');
//	     setFirstNodeValue('con_name_span', 'UNGÃœLTIG');

	}
}

function initConForm(){
   setFirstNodeValue('conIdSpan', '');
	     setFirstNodeValue('con_name_span', '');
	     document.getElementById('connectorForm').reset();
}


var catLabels=new Array();
var cats=new Array();
/**
* setzt eine Rezeptkategoerie
* @author Philipp KnÃ¶ller
*/
function addRsCat(catId, topCat, catLabel){
    if(catId==topCat){
         cats[catId]=new Array();
         catLabels[catId]=catLabel;
    }
}












  function rezeptSearchResponse(){
           iFrameResponse('rezepte', 'rezeptSearchInput', 'rezeptSearchFrame', 'rezeptSuggDiv', 'rezeptSearchHintDiv');
  }

  function uebungenSearchResponse(){
           iFrameResponse('uebungen', 'rezeptSearchInput', 'rezeptSearchFrame', 'rezeptSuggDiv', 'rezeptSearchHintDiv');
  }

  function xmlToIFrame(xmldoc, type, searchSelectBox, searchSelectDiv){
  	 var entrys=xmldoc.getElementsByTagName("entry");
                if(entrys.length==0){

                          var frameDocument=parent.frames.rezeptSearchFrame.document;
                          var oldLength=frameDocument.getElementsByTagName("tr").length;
                          for(var i=0; i<oldLength; i++){
                                  frameDocument.getElementById("rezeptSearchResultTable").deleteRow(0);
                          }
                          return false;
                 }
                 else{
                          var frameDocument=parent.frames.rezeptSearchFrame.document;
                          var oldLength=frameDocument.getElementsByTagName("tr").length;
                          for(var i=0; i<oldLength; i++){
                                  frameDocument.getElementById("rezeptSearchResultTable").deleteRow(0);
                          }

                          var tr = frameDocument.getElementById("rezeptSearchResultTable").insertRow(0);
                          var trId=frameDocument.createAttribute('id');
                          trId.nodeValue='groupListTableTitle';
                          tr.setAttributeNode(trId);

                          var nameCaptionLabel=type == 'rezepte' ? 'Rezepte' : 'Ãœbung';
                          createTdF(frameDocument, tr, nameCaptionLabel, 'defaultLabel8pt');
                          //  createTdF(frameDocument, tr, 'Portionen', 'defaultLabel8pt');
                         if(type=='rezepte') createTdF(frameDocument, tr, type=='rezepte' ? 'Nutry' : 'PNutry', 'defaultLabel8pt');
                          createTdF(frameDocument, tr, 'Zeit', 'defaultLabel8pt');
                          createTdF(frameDocument, tr, 'Schwierigkeit', 'defaultLabel8pt');
                          createTdF(frameDocument, tr, 'Bewertung', 'defaultLabel8pt');

                          for(var i=0; i<entrys.length; i++){
                                  var label=ffEntityDecode(entrys[i].firstChild.nodeValue);
                                  var value=entrys[i].getAttribute('value');
                                  var prefix=ffEntityDecode(entrys[i].getAttribute('prefix'));
                                  var search=ffEntityDecode(entrys[i].getAttribute('search'));
                                  var postfix=ffEntityDecode(entrys[i].getAttribute('postfix'));//alert(prefix+search+postfix);
                                  var tr = frameDocument.getElementById("rezeptSearchResultTable").insertRow(i+1);

                                  var trClass=frameDocument.createAttribute('class');
                                  trClass.nodeValue='groupListTableRow'+(i%2);
                                  tr.setAttributeNode(trClass);

                                  var td1 = frameDocument.createElement("td");
                                  var a1 = frameDocument.createElement("a");

                                  if(search.length>0){
                                       var span1=frameDocument.createElement("span");
                                       var span1Class=frameDocument.createAttribute('class');
                                       span1Class.nodeValue='rezeptSearchTitleMarker';
                                       span1.setAttributeNode(span1Class);
                                       var span1Text=frameDocument.createTextNode(search);
                                       span1.appendChild(span1Text);

                                       prefixText=frameDocument.createTextNode(prefix);
                                       postfixText=frameDocument.createTextNode(postfix);

                                       var rTitle=frameDocument.createElement("div");

                                       a1.appendChild(prefixText);
                                       a1.appendChild(span1);
                                       a1.appendChild(postfixText);
                                       rTitle.appendChild(a1);
                                       td1.appendChild(rTitle);
                                       if(type=='rezepte'){
                                            var rTitleZ=frameDocument.createElement("div");
                                            var rTitleZText=frameDocument.createTextNode(entrys[i].getAttribute('rezept_title_zusatz'));
                                            rTitleZ.appendChild(rTitleZText);
                                            var rzClass=frameDocument.createAttribute('class');
                                            rzClass.nodeValue='rezeptTitleZusatz';
                                            rTitleZ.setAttributeNode(rzClass);
                                            td1.appendChild(rTitleZ);
                                       }
                                  }
                                  else{
                                      labelText=frameDocument.createTextNode(label);
                                      a1.appendChild(labelText);
                                      td1.appendChild(a1);
                                  }

                                  var levelLabel="AnfÃ¤nger";
                                  var llev=entrys[i].getAttribute('level');
                                  if(llev==1){
                                  	levelLabel="Hobby";
                                  }
                                  else if(llev==2){
                                  	levelLabel="Profi";
                                  }

                                  tr.appendChild(td1);
                                  var a1Href=frameDocument.createAttribute('href');
                                  var a1Class=frameDocument.createAttribute('class');
                                  a1Class.nodeValue='defaultLink8pt';
                                  a1.setAttributeNode(a1Class);
                                  a1Href.nodeValue=type=='rezepte' ? "javascript:top.jumpToRezept('"+entrys[i].getAttribute('rezept_id')+"');" :
                                                                     "javascript:top.jumpToUebung('"+entrys[i].getAttribute('ex_id')+"');";
                                  a1.setAttributeNode(a1Href);
                             //   var td2 = createTdF(frameDocument,tr, entrys[i].getAttribute('portions'), 'defaultLabel8pt');
                             if(type=='rezepte') createTdF(frameDocument,tr, type=='rezepte' ? entrys[i].getAttribute('nutry_cache'):'', 'defaultLabel8pt');
                                  createTdF(frameDocument,tr, entrys[i].getAttribute('do_time')+' min', 'defaultLabel8pt');
                                  createTdF(frameDocument,tr, levelLabel, 'defaultLabel8pt');
                                  var rating=0;
                                  if(entrys[i].getAttribute('rate_times')>0){
                                       rating=Math.round(entrys[i].getAttribute('rating')/entrys[i].getAttribute('rate_times'))
                                  }

                                  tdR=frameDocument.createElement("td");
                                  imgR=frameDocument.createElement("img");
                                  imgRSrc=frameDocument.createAttribute("src");
                                  imgRSrc.nodeValue=getUrlCache('ratingImgSrcPrefix') + rating + '.gif';
                                  imgR.setAttributeNode(imgRSrc);
                                  tdR.appendChild(imgR);
                                  tr.appendChild(tdR);


                     }
                     return true;
                 }
  }

/**
   * FÃ¼llt die IFrame mit den Ergebnissen der Suche
   * @author Philipp KnÃ¶ller
   * @depricated
   */
   function iFrameResponse(type, searchTextFieldName, searchSelectBox, searchSelectDiv, searchHintElement) {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                var xmldoc = http_request.responseXML;
               if(xmlToIFrame(xmldoc, type, searchSelectBox, searchSelectDiv)){
               	      setFirstNodeValue(searchHintElement, 'Zum AuswÃ¤hlen auf den Rezeptnamen klicken.');
               }
               else{
               	   setFirstNodeValue(searchHintElement, 'Keine passenden EintrÃ¤ge');
               }

            }
            else {
                 setFirstNodeValue(searchHintElement, 'Die Suche ist im Augenblick ausser Betrieb. Bitte versuchen Sie es zu einem spÃ¤teren Zeitpunkt noch einmal.');
                 gE(searchSelectDiv).style.display='none';
            }
            changeImgSrc('hourglassesImg', 'blankImg');
        }

    }


////////////////////////////////////////////Bilder Uebungen////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////

var currentUebungenPic=0;
function changeUebungenPic(uebungId, direction){
	 //  var picLength=getDataImageCacheArrayLength('uebungen_pics');
	 var picLength=2;
	   if(direction>0){
	   	     currentUebungenPic+=direction;
	   	     if(currentUebungenPic>=picLength){
	   	     	    currentUebungenPic=0;
	   	     }
	   }
	   else{
	   	     currentUebungenPic+=direction;
	   	     if(currentUebungenPic<0){
	   	     	    currentUebungenPic=picLength-1;
	   	     }
	   }

	   changeDataImgSrc('uebungenImg', 'uebungen_pics', 'uebung_'+uebungId+'_'+currentUebungenPic);
}



function createTrF(fd, tableId, index, trClass){
   var tr = fd.getElementById(tableId).insertRow(index);
   var trClass=fd.createAttribute('class');
   trClass.nodeValue=trClass;
   tr.setAttributeNode(trClass);
}

function showSelectRezept(selectId){
	  var rezeptId=gE(selectId).value;
	  jumpToRezept(rezeptId);
}

function jumpToRezept(rezeptId){
    var url=getUrlCache('RezeptUrl');
    //alert(urlCache['RezeptUrl']);
    window.location.href=url+'&vRezept='+rezeptId+'&rezeptSearch='+top.document.getElementById('rezeptSearchInput').value;
}

function jumpToUebung(uebungId){
    var url=getUrlCache('UebungenUrl');
    //alert(urlCache['RezeptUrl']);
    window.location.href=url+'&vRezept='+uebungId+'&rezeptSearch='+top.document.getElementById('rezeptSearchInput').value;
}

function gotoPage(pageCode, parameter){
	var x='/'+pageCode+'.htm';
	if(parameter){
		   x=x+'?'+parameter;
	}
	window.location.href=x;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////Gewichtsblinker///////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
var blink=0;
function kgBlink(){
     var oldId='kgLabelSpan' + blink;
     blink=1-blink;
     var newId='kgLabelSpan' + blink;
  //   document.getElementById(oldId).id=newId;
}

window.setInterval("kgBlink()", 5000);

////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////Mouse Popup//////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Popup verstecken
function hideMouseImg(){
    document.getElementById('titleTableBigImg').src=imageCache['blankImg'].src;
    document.getElementById('titleTable').style.display='none';
 }

function showTitleTable(titleTableId){
         //Popup sichtbar machen
       if(document.getElementById){
         document.getElementById(titleTableId).style.display="";
       }
}         

//Alle Zeilen der rechten Untertabelle loeschen
function clearTitleTableSub(titleTableId){
      
        var cN=document.getElementById(titleTableId+'SubRightBody').childNodes.length;
       
      //  alert(cN.length);
        for(var i=0; i<cN; i++){
       // if(document.getElementById('titleTableSubRightBody').childNodes[i]){
              document.getElementById(titleTableId+'SubRightBody').removeChild(document.getElementById(titleTableId+'SubRightBody').firstChild);
       // }
        }
       
}        


//Popup vorbereiten: Farbe, Grosses Bild, Ueberschrift
function prepareTitleTable(titleTableId, color, imgId, caption, desc){
         //Farbe des Popups setzen
         document.getElementById(titleTableId).style.backgroundColor=color;
         
         if(imgId==''){
             document.getElementById(titleTableId+'LeftTd').style.display='none';
          }
         else{
             //Bild des Popups setzen
             document.getElementById(titleTableId+'LeftTd').style.display='';
             document.getElementById(titleTableId+'BigImg').src=imageCache[imgId].src;
         }
         //Ueberschrift
         document.getElementById(titleTableId+'CaptionDiv').firstChild.nodeValue=caption;
         
         if(desc==''){
              document.getElementById(titleTableId+'DescDiv').style.display='none';
         }
         else{
              document.getElementById(titleTableId+'DescDiv').style.display='';
              document.getElementById(titleTableId+'DescDiv').firstChild.nodeValue=desc;
         }
         
         clearTitleTableSub(titleTableId);
}

function addTitleTableSubRow(titleTableId, leftText, rightText, rightSmallImgId){
        var tdLeft = document.createElement("td");
        var textLeft = document.createTextNode(leftText);
        tdLeft.appendChild(textLeft);
        
        var cAtt=document.createAttribute("class");
        cAtt.nodeValue=titleTableId+"SubRightLeftTd";
        tdLeft.setAttributeNode(cAtt);
        
        var tdRight = document.createElement("td");
        
        if(rightSmallImgId){
              var rightSmallImg = document.createElement("img");
              var rightSmallImgSrc= document.createAttribute("src");
              rightSmallImgSrc.nodeValue=imageCache[rightSmallImgId].src;
              rightSmallImg.setAttributeNode(rightSmallImgSrc);
              var rightSmallImgWidth= document.createAttribute("width");
              rightSmallImgWidth.nodeValue=12;
              rightSmallImg.setAttributeNode(rightSmallImgWidth);
              var rightSmallImgHeight= document.createAttribute("height");
              rightSmallImgHeight.nodeValue=12;
              rightSmallImg.setAttributeNode(rightSmallImgHeight);
              var rightSmallImgId= document.createAttribute("id");
              rightSmallImgId.nodeValue=titleTableId+'SubRightSmallImg';
              rightSmallImg.setAttributeNode(rightSmallImgId);
              tdRight.appendChild(rightSmallImg);
        }
        
        var textRight = document.createTextNode(rightText);
        tdRight.appendChild(textRight);
        
        var dAtt=document.createAttribute("class");
        dAtt.nodeValue=titleTableId+"SubRightRightTd";
        tdRight.setAttributeNode(dAtt);
        
        var tr = document.createElement("tr");
        tr.appendChild(tdLeft);
        tr.appendChild(tdRight);
        document.getElementById(titleTableId+'SubRightBody').appendChild(tr);
}

//Textpopup anzeigen
function showDescPopup(color, imgId, caption, desc){

         if(windowMouseMode!='move'){
             prepareTitleTable('titleTable', color, imgId, caption, desc);
             showTitleTable('titleTable');
         }
}




//Spieler Popup anzeigen
function changeMouseImg(isMale, age, newId, username, region, interests, zeichen, occ){
          if(windowMouseMode!='move'){
         //Farbe des Popups setzen
         prepareTitleTable('titleTable', isMale ? '#F6FBFF' : '#FDEEF5', newId, username, '');

          //Alter
         if(age!=''){
                  addTitleTableSubRow('titleTable', 'Alter: ', age);;
         }

         //Region
         if(region!=''){
                  addTitleTableSubRow('titleTable', 'Region: ', region);
         }

         //Interessen
         if(interests!=''){
                  addTitleTableSubRow('titleTable', 'Interessen: ', interests);
         }

         //Beruf
         if(occ!=''){
                  addTitleTableSubRow('titleTable', 'Beruf: ', occ);
         }

         //Sternzeichen
         addTitleTableSubRow('titleTable', 'Sternzeichen: ', zeichen, zeichen);
         //Popup sichtbar machen
         showTitleTable('titleTable');
         }
}

var NutryCheckPopup = {

	showPopup:function(isLoggedIn){
	          var popupLayerStyle=document.getElementById('nutryCheckPopup').style;
	          if(popupLayerStyle.display=='none'){
	                  var gewicht = gE('gewicht').value;
	                  var alter = gE('alter').value;
	                  if(document.getElementsByName('gender')[0].checked == false && document.getElementsByName('gender')[1].checked == false){
	                  	prepareTitleTable('hintsSliderTable', 'white', '', 'Hinweis', '');
	                  	addTitleTableSubRow('hintsSliderTable', '', 'Bitte teilen Sie uns Ihr Geschlecht mit.');
	                  	showSliderWindow('hintsSliderWindow', 0.1, 10);
	                  }
	                  else if(alter<18){
	                  	 prepareTitleTable('hintsSliderTable', 'white', '', 'Hinweis', '');
		                   addTitleTableSubRow('hintsSliderTable', '', 'Nutropoly ist erst ab 18 Jahren geeignet.');
	                       showSliderWindow('hintsSliderWindow', 0.1, 10);
	                  }// if alter<18
	                  else{
	                  
	                  var isMale=document.getElementsByName('gender')[1].checked==true;
	                  
	                  setFirstNodeValue('resultTd', 'betrÃ¤gt: '+calcNutrySaldo(isMale, alter, gewicht));
	                  document.getElementById("nutryCheckPopup").style.top=(isLoggedIn?290:370)+"px";
	                
	                  setPopupVisible('nutryCheckPopup', true);
	                  }//else if alter<18
	          }
	          else{
	                  setPopupVisible('nutryCheckPopup' , false);
	          }
	 }
}
 
 function calcNutrySaldo(isMale, age, weightKg){
 	var CONST1=0.0252;
    	var const2=0;
    	var const3=0;
    	var CONST4=239.2;
    	var CONST5=12;
    	
    	if(age==18){
    		const2 = isMale ? 0.074 : 0.056;
    		const3 = isMale ? 2.754 : 2.898; 
    	}
    	else if(age>18 && age<=30){
    		const2 = isMale ? 0.063 : 0.062;
    		const3 = isMale ? 2.896 : 2.036;
    	}
    	else if(age>30 && age<=60){
    		const2 = isMale ? 0.048 : 0.034;
    		const3 = isMale ? 3.653 : 3.538;
    	}
    	else{
    		const2=isMale ? 0.049 : 0.038; //fÃ¼r >= 61
    	    const3=isMale ? 2.459 : 2.755; //fÃ¼r >= 61
    	}
    	return Math.floor(CONST1 * ((const2*weightKg + const3)*CONST4)-CONST5);
 }
 
 
///////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////// Typen-Test /////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////

var TypenTestEvaluation = {
	ttRedVal:0,
	ttGreenVal:0,
	ttYellowVal:0,
	ttCheckBoxNames:['../../shared/nutropoly/img/layout/checkbox.jpg', '../../shared/nutropoly/img/layout/checked_red.jpg', '../../shared/nutropoly/img/layout/checked_yellow.jpg', '../../shared/nutropoly/img/layout/checked_green.jpg'],
	ttCheckBoxPics:[],
	ttCheckBoxesVis:[],
	tempMax:0,
	finalMax:0,
	
	ttCheckBoxVisInit:function(){
	 	var i;
 		for(i=0;i<18;i++){
 			TypenTestEvaluation.ttCheckBoxesVis[i] = 0;
 		}
	},
	
	loadTypenTestButtonImages:function(){
		if(TypenTestEvaluation.ttCheckBoxesVis.length == 0){ TypenTestEvaluation.ttCheckBoxVisInit(); }
	 	var i;
	 	for(i=0;i<TypenTestEvaluation.ttCheckBoxNames.length;i++){
	 		TypenTestEvaluation.ttCheckBoxPics[i] = new Image();
	 		TypenTestEvaluation.ttCheckBoxPics[i].src = TypenTestEvaluation.ttCheckBoxNames[i];
	 	}
	 },
	 
	 evaluationPicExchange:function(n, t){
	   	 TypenTestEvaluation.loadTypenTestButtonImages();
	 	 var picName = 'ttCheckBox_'+n+'_'+t;
	 	
	 	 if(TypenTestEvaluation.ttCheckBoxesVis[n] == 0){
	 		if(t == 'red'){ document.images[picName].src = TypenTestEvaluation.ttCheckBoxPics[1].src; }
	 		if(t == 'yellow'){ document.images[picName].src = TypenTestEvaluation.ttCheckBoxPics[2].src; }
	 		if(t == 'green'){ document.images[picName].src = TypenTestEvaluation.ttCheckBoxPics[3].src; }
	 		if(t=='red') TypenTestEvaluation.ttRedVal++;
	 	  	if(t=='yellow') TypenTestEvaluation.ttYellowVal++;
	 	  	if(t=='green') TypenTestEvaluation.ttGreenVal++;
	 	  	TypenTestEvaluation.tempMax = Math.max(TypenTestEvaluation.ttRedVal, TypenTestEvaluation.ttYellowVal);
	 	  	TypenTestEvaluation.finalMax = Math.max(TypenTestEvaluation.tempMax, TypenTestEvaluation.ttGreenVal);
	 	  	
	 	  	if((TypenTestEvaluation.ttRedVal == TypenTestEvaluation.finalMax) && (TypenTestEvaluation.ttRedVal > 0)){ document.getElementById('ttResultDivRed').style.display = 'block'; }
	 	   		else{ document.getElementById('ttResultDivRed').style.display = 'none';}
	 	  	if((TypenTestEvaluation.ttYellowVal == TypenTestEvaluation.finalMax) && (TypenTestEvaluation.ttYellowVal > 0)){ document.getElementById('ttResultDivYellow').style.display = 'block'; }
	 	   		else{ document.getElementById('ttResultDivYellow').style.display = 'none'; }
	 	  	if((TypenTestEvaluation.ttGreenVal == TypenTestEvaluation.finalMax) && (TypenTestEvaluation.ttGreenVal > 0)){ document.getElementById('ttResultDivGreen').style.display = 'block'; }
	 	   		else{ document.getElementById('ttResultDivGreen').style.display = 'none'; }
	 		
	 		
	 		TypenTestEvaluation.ttCheckBoxesVis[n] = 1;
	 	 }
	 	 else{
	 		document.images[picName].src = TypenTestEvaluation.ttCheckBoxPics[0].src;
	 		
	 	  if(t=='red') TypenTestEvaluation.ttRedVal--;
	 	  if(t=='yellow') TypenTestEvaluation.ttYellowVal--;
	 	  if(t=='green') TypenTestEvaluation.ttGreenVal--;
	 	  TypenTestEvaluation.tempMax = Math.max(TypenTestEvaluation.ttRedVal, TypenTestEvaluation.ttYellowVal);
	 	  TypenTestEvaluation.finalMax = Math.max(TypenTestEvaluation.tempMax, TypenTestEvaluation.ttGreenVal);
	 	  //alert(tempMax+' '+finalMax);
	 	  
	 	  	if((TypenTestEvaluation.ttRedVal == TypenTestEvaluation.finalMax) && (TypenTestEvaluation.ttRedVal > 0)){ document.getElementById('ttResultDivRed').style.display = 'block'; }
	 	   		else{ document.getElementById('ttResultDivRed').style.display = 'none';}
	 	  	if((TypenTestEvaluation.ttYellowVal == TypenTestEvaluation.finalMax) && (TypenTestEvaluation.ttYellowVal > 0)){ document.getElementById('ttResultDivYellow').style.display = 'block'; }
	 	   		else{ document.getElementById('ttResultDivYellow').style.display = 'none'; }
	 	  	if((TypenTestEvaluation.ttGreenVal == TypenTestEvaluation.finalMax) && (TypenTestEvaluation.ttGreenVal > 0)){ document.getElementById('ttResultDivGreen').style.display = 'block'; }
	 	   		else{ document.getElementById('ttResultDivGreen').style.display = 'none'; } 		
	 	  
	 		document.images[picName].src = TypenTestEvaluation.ttCheckBoxPics[0].src;
	 		TypenTestEvaluation.ttCheckBoxesVis[n] = 0;
	 	 }
	 	 document.getElementById('typenTestEvaluationDisplayRed').innerHTML = TypenTestEvaluation.ttRedVal;
	 	 document.getElementById('typenTestEvaluationDisplayYellow').innerHTML = TypenTestEvaluation.ttYellowVal;
	 	 document.getElementById('typenTestEvaluationDisplayGreen').innerHTML = TypenTestEvaluation.ttGreenVal;
	 }
};

function showHintMessage(hintTitle, hintMessage){
                       prepareTitleTable('hintsSliderTable', 'white', '', hintTitle, '');
	                   addTitleTableSubRow('hintsSliderTable', '', hintMessage);
                       registerSliderWindow('hintsSliderWindow', 0.1, 10, 0, 10);
 }var mnTools=new Array();

function regMnTool(pageCode, text, sum, caption){
	mnTools[pageCode]=new Array(text, sum, caption);
}

function highlight(pageCode, isLoggedIn){
	 for(var pc in mnTools){
	     if(pc!='default'){
	         var style=document.getElementById('myNutropolyEntree_'+pc).style;
	         style.fontWeight='';
	         gE('strich_'+pc).style.visibility='hidden';
	     }
	 }
     newText="";
     newSum="";
     newCaption="";
     if(pageCode!='default'){
        var style=document.getElementById('myNutropolyEntree_'+pageCode).style;
        style.fontWeight='bold';	
        gE('strich_'+pageCode).style.visibility='visible';

        	newText=mnTools[pageCode][0];
     	     	newSum=mnTools[pageCode][1];
     	     	newCaption=mnTools[pageCode][2];   
     }
     
     document.getElementById('frau_blase_td').className='frau_'+(isLoggedIn ? '1' : '0')+'_'+(pageCode=='default' ? '0' : '1');
     
     
     	
     
     setFirstNodeValue('mnToolText', newText);
     setFirstNodeValue('mnToolSum', newSum);
     setFirstNodeValue('mnToolCaption', newCaption);
}/**
* fÃ¼lltdas Formular in der Info Bls
* @author Philipp KnÃ¶ller
*/
function fillConForm(){
	var conData=gE('zutatSuggSelect').value;
    if((conData!='')&&(conData!='-1000')){
          // document.getElementById('zutatSuggDiv').style.display='none';
          // spFound=true;
          // stopEatSearch();
    }
    //alert(conData);
	var conArray=conData.split(',');
    if(conArray.length>10){
	setFirstNodeValue('conIdSpan', conArray[0]);
	gE('con_id_input').value=conArray[0];
	gE('con_bls_key_input').value=conArray[1];
	gE('con_ef_key_input').value=conArray[2];
	gE('con_rs_key_input').value=conArray[3];
	gE('con_bls_link_input').value=conArray[4];

	gE('con_name_input').value=conArray[5];

	gE('con_singular_input').value=conArray[6];
	gE('con_plural_input').value=conArray[7];


	gE('con_name_key0_input').value=conArray[8];
	gE('con_name_key1_input').value=conArray[9];
	gE('con_name_key2_input').value=conArray[10];

	gE('con_alt_ef_key0_input').value=conArray[11];
    gE('con_alt_ef_key1_input').value=conArray[12];
	gE('con_alt_ef_key2_input').value=conArray[13];

	gE('con_less_g_input').value=conArray[14];
    gE('con_mid_g_input').value=conArray[15];
	gE('con_much_g_input').value=conArray[16];

		var t=17;
	for(var key in mengeEinheiten){
	   gE('con_e_'+ key+'_input', conArray[t]);
	   t++;}
	}
	else{
	    setFirstNodeValue('conIdSpan', '');
	    setFirstNodeValue('con_name_span', 'UNGÃœLTIG');
	   document.getElementById('connectorForm').reset();
	}
	//FFForms.clearTextField('zutatNameInput');
	gE('conDataTable').style.display='';
}/**
 * zeigt den JavaScript Nutry Rechner an
 * @author Philipp Knoeller
 */
function showNutryRechnerPopup(isLoggedIn){
          var popupLayerStyle=document.getElementById('nutryRechnerPopup').style;
          if(popupLayerStyle.display=='none'){
                  if(!isLoggedIn){
          	          // prepareTitleTable('hintsSliderTable', 'white', '', 'Bitte einloggen', '');
	                  // addTitleTableSubRow('hintsSliderTable', '', 'Bitte erst einloggen');
                      // showSliderWindow('hintsSliderWindow', 0.1, 10);
          	           window.location.href=getUrlCache('accountUpgrade');
          	           return;
                  }
                  document.getElementById('nr_form_element').reset();
                  reCalc();
                  setPopupVisible('nutryRechnerPopup', true);
          }
          else{
                  setPopupVisible('nutryRechnerPopup' , false);
          }
 }
 
 function nrToDiary(){
  document.getElementById('nr_form_element').submit();
 }
 
 function nrCalc(){
 	   var fett=gE('nr_fett_input').value;
 	   var ballast=gE('nr_ballast_input').value;
 	   var kcal=gE('nr_kcal_input').value;
 	   
 	   var af=gE('nr_af_portion_input').value;
 	   var portion=gE('nr_portion_input').value;
 	   
 	   var nutry=roundNutry(portion/af*calcBruttoNutry(fett, ballast, kcal));
 	   
 	   setFirstNodeValue('nutryResultSpan', nutry);
 	   gE('nutryResultDiv').style.display='';
 	   gE('nr_form').style.display='none';
 }
 
 function reCalc(){
 	   gE('nutryResultDiv').style.display='none';
 	   gE('nr_form').style.display='';
 }
 
 /**
 * 
 *errechnet den Nutry-Wert aus fett, ballas und energie werten
 */
function calcNutry(fett, ballast, energie){
    
    nutry = calcBruttoNutry(fett, ballast, energie);

	return roundNutry(nutry);
}
 
 function calcBruttoNutry(fett, ballast, energie){
	var fett_energie = fett*9.3;			// ein gramm fett = 9.3 kcal
	
	var nutry = energie/50;

	if (fett_energie > (0.3*energie)){
		nutry = nutry + (fett_energie/250);
	}

	nutry = nutry - Math.min(ballast/5 , 0.2*(energie/50));
	
	return nutry;
}
 
 function roundNutry(nutry){
	var vorkommanutry = parseInt(nutry);//alert(nutry);
	var nachkommanutry = nutry - vorkommanutry;
	if (nachkommanutry < 0.25) {
		nutry = vorkommanutry;
	}
	else if (nachkommanutry <= 0.5) {
		nutry = vorkommanutry + 0.5;
	}
	else if (nachkommanutry < 0.75) {
		nutry = vorkommanutry + 0.5;
	}
	else {
		nutry = vorkommanutry + 1;
	}
	
	return nutry;
}
 
/**
 ******************************************************************
 *              Philipp Knoeller Software Entwicklung             *
 *                        Framework Funktor                       *
 *                           Version 1.0                          *
 *                                                                * 
 *                  http://pksoftware.de/funktor                  *
 *                                                                * 
 *                       ALL RIGHTS RESERVED                      *
 *                                                                *
 ******************************************************************
 * 
 * $Id: FFUserSearch.js,v 1.1.2.3 2008/06/22 21:04:07 pknoeller Exp $
 * 
 * @author Philipp Knoeller
 * @copyright Copyright &copy; 2006, Philipp Knoeller
 * @link http://pksoftware.de/funktor
 * @version 1.0.0.1
 * @package funktor_ffmain
 * @subpackage js
 */

var FFUserSearch={
  searchInput:null,
  
  suggSelect:null,
  suggDiv:null,
  
  searchHint:null,
  waitImg:null,
  
  columnDefinitions:null,

/**
 * fuellt die <Select> Liste mit den gefundenen Spielernamen
 * @author Philipp Knöller
 * @access private
 */
  response:function(xmldoc){
  	   FFUserSearch.columnDefinitions=xmldoc.getElementsByTagName("field_definition")[0].getAttribute('value');
  	   var entrys=xmldoc.getElementsByTagName("entry");
  	   if(ffArrayToSelectBox(entrys, FFUserSearch.suggSelect, FFUserSearch.suggDiv, 'Keine passenden Einträge')){
  	   	      setFirstNodeValue(FFUserSearch.searchHint, 'Zum Auswählen DOPPELT auf den Spielernamen klicken.');
  	   }
  	   else{       
  	          setFirstNodeValue(FFUserSearch.searchHint, 'Keine passenden Einträge');
  	   }
  	     	   changeImgSrc(FFUserSearch.waitImg, 'blankImg');
  },
  
  /**
   * Funktor Ajax Objekt
   */
  ajaxObject:new FAjax(null),
  
  /**
   * sucht nach Spielern 
   * @author Philipp Knöller
   * @access private
   */
  search:function(){
  	      var newSearchString=ffHasInputChanged(FFUserSearch.searchInput, 2);         
          if(newSearchString){
                   FFUserSearch.ajaxObject.setGetString("search="+newSearchString);
                   FFUserSearch.ajaxObject.request(true, 'GET', FFUserSearch.response);
          }
  },
  
  /**
   * startet die periodische User Suche
   * @author Philipp Knöller
   * @access public
   */
  startSearch:function(url, searchInput, suggSelect, suggDiv, searchHint, waitImg){
  	   FFUserSearch.searchInput=searchInput;
  	   FFUserSearch.suggSelect=suggSelect;
  	   FFUserSearch.suggDiv=suggDiv;
  	   FFUserSearch.searchHint=searchHint;
  	   FFUserSearch.waitImg=waitImg;
  	   
  	   FFUserSearch.ajaxObject.setUrl(url);
  	   FFUserSearch.ajaxObject.start_search(FFUserSearch.search, 1000);
  }, 
  
  /**
   * stoppt die Assistent Suche
   */
  stopSearch:function(){
      FFUserSearch.ajaxObject.stop_search();
      
  },
  
  /**
   * zeigt das gewählte User Profil an
   * @author Philipp Knöller
   * @access public
   */
  showUserProfile:function(url, selectBox){
       window.location.href=url+'&profileId='+gE(selectBox).value;
  },  
  
  fillUserProperties:function(){
       var properties=gE(FFUserSearch.suggSelect).value.split('qq,qq');
       var fieldDef=FFUserSearch.columnDefinitions.split('qq,qq');
     
       for(var i=0;i<fieldDef.length; i++){
          var field=fieldDef[i];
          // f+=','+field;
          if(properties[i]==''){ 
               gE('ffUserSearch_property_'+field).value='';
          }   
          else{
               if(!gE('ffUserSearch_property_'+field)) alert(field);
               gE('ffUserSearch_property_'+field).value=properties[i];
               if(field=='user_id') gE('ffUserSearchPrimaryKeySpan').innerHTML=properties[i];
          }    
          if(fieldDef[i]=='user_id') gE('ffUserManagerDeleteHiddenInput').value=properties[i];
       }
  }
  
};         	   