function showMenu(eid)
{
    document.getElementById(eid).style.display = "";
}

function hideMenu(eid)
{
    document.getElementById(eid).style.display = "none";
}

var _init = function() {
	var $effect = YAHOO.widget.Effects;
	var $dom = YAHOO.util.Dom;
	var $connect = YAHOO.util.Connect;
	var $event = YAHOO.util.Event;
	var $GEQL = cssQuery;
	
	return {
		start : function() {
			_init.golbalRules();
		},
		
		golbalRules : function() {
			$event.on($GEQL('input[type="text"]'), 'focus', function(el){ this.style.backgroundColor = '#F9F9F9'; this.style.color = '#000'; });
			$event.on($GEQL('input[type="text"]'), 'blur', function(el){ this.style.backgroundColor = '#FFF'; this.style.color = '#999';});
			$event.on($GEQL('input[type="password"]'), 'focus', function(el){ this.style.backgroundColor = '#F9F9F9'; this.style.color = '#000';});
			$event.on($GEQL('input[type="password"]'), 'blur', function(el){ this.style.backgroundColor = '#FFF'; this.style.color = '#999';});
			$event.on($GEQL('textarea'), 'focus', function(el){ this.style.backgroundColor = '#F9F9F9'; this.style.color = '#000'; });
			$event.on($GEQL('textarea'), 'blur', function(el){ this.style.backgroundColor = '#FFF'; this.style.color = '#999';});
			
			$anzNavTopics = $GEQL('#headNav li.topic').length;
			for(i=0; i<$anzNavTopics; i++) {
				var param = { id:i };
				$event.on($GEQL('#headNav li.topic')[i], 'click', _init.topgleNavPanle, param);
			}
			
		},
		
		resetAllNavPanels : function(ignoreId) {
			$anzNavTopics = $GEQL('#headNav li.topic').length;
			for(i=0; i<$anzNavTopics; i++) {
				if(ignoreId != i) {
					$dom.setStyle($GEQL('#headNav li.navElement')[i], 'display', 'none');
				}
			}
			return true;
		},
		
		topgleNavPanle : function(elm, param) {
			var elementId = param.id;
			_init.resetAllNavPanels(elementId);
			
			var navElement = $GEQL('#headNav li.navElement')[elementId];
			var display = $dom.getStyle(navElement, 'display');
			
			if(display == 'none') {
				$dom.setStyle(navElement, 'display', '');
			}else {
				_init.resetAllNavPanels();
			}
		}
	}
}();

String.prototype.ellipse = function(maxLength){
    if(this.length > maxLength){
        return this.substr(0, maxLength-3) + '...';
    }
    return this;
};

var charsToGo;

function charCounter(charInputSrcName, maxCharCount, outputTargetName) {

   var charInputSrc = document.getElementById(charInputSrcName);
   var outputTargetSrc = document.getElementById(outputTargetName);

   if (charInputSrc != null) {
      if (charInputSrc.value.length <= maxCharCount) {
         charsToGo = maxCharCount - charInputSrc.value.length;
         outputTargetSrc.innerHTML = '(' + charsToGo + '&nbsp;Zeichen)';
      } 
      else 
         charInputSrc.value = charInputSrc.value.substring(0, maxCharCount);
         charsToGo = maxCharCount - charInputSrc.value.length;
   }
}

function counterOutput(charInputSrcName, maxCharCount, outputTargetName)
{
   var charInputSrc = document.getElementById(charInputSrcName);

   if (charsToGo == null) {
      charsCount = maxCharCount - charInputSrc.value.length; 
   } 
   else
      charsCount = charsToGo;
      document.write('<span name=\"'+ outputTargetName + '\" id=\"' + outputTargetName +'\">('+ charsCount + '&nbsp;Zeichen)</span>');
}

YAHOO.util.Event.on(window, 'load', _init.start);
