/**
 * Add an eventHandler to a node
 * 
 * @version 1.0
 * @param object obj The node at which event will be added
 * @param string evType Which event will be called
 * @param string fn The function that will be called
 * @param boolean useCapture
 */
function addEvent(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 {
    alert("Handler could not be attached");
  }
}


function removeEvent(obj, evType, fn, useCapture){
  if (obj.removeEventListener){
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent){
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
}




function initObj() {      
      this.path = 'js/';       
}

initObj.prototype.load = function(param) {       
	
      init.param = param;      
}

initObj.prototype.call = function() {         
	    
      if(extJs) return true;
        
      for(var i = 0; i < init.param.length; i++) {
            eval(init.param[i] + 'Prot = new ' + init.param[i] + '()');        
      }         
}

extJs = false;
var init = new initObj();
var initParam = new Array(); 
var initFunctions = new Array();

if(!extJs) addEvent(window, 'load', init.call, false);
/**
 * Checks if an value is contained in an array
 * 
 * @version 1.0
 * @param object obj The value to check for
 */
Array.prototype.contains = function(obj) {
	for (var i = 0; i < this.length; i++) {
		if (this[i] == obj) {
			return true;
		}
	}
	return false;
}

/**
 * deletes an element from an array
 * 
 * @version 1.0
 * @param object obj The value to remove
 */
Array.prototype.remove = function(obj) {
	for (var i = 0; i < this.length; i++) {
		if (this[i] == obj) {
			this.splice(i,1);
		}
	}
}
/**
 * Add the node to the DOM-Tree
 * 
 * @version 1.0
 * @param string sep The seperator of the keyValuePairs
 * @param string split How the name and the value is seperated
 * @return array
 */
String.prototype.toAttributes = function(sep, split) {

      att = new Object();
      keyValuePairs = new Array();        

      if(this.length > 0) var q = this;
      else var q = null;
            
      if(q) {
            for(var i=0; i < q.split(sep).length; i++) {
                  keyValuePairs[i] = q.split(sep)[i];
                  
            }
            
            for(var i=0; i < keyValuePairs.length; i++) {
                  
                  if(keyValuePairs[i].split(split)[0].indexOf('[]') != -1) {
                        if(typeof(att[keyValuePairs[i].split(split)[0]]) != 'object') {
                              att[keyValuePairs[i].split(split)[0]] = new Array();                              
                        }                
                        
                        att[keyValuePairs[i].split(split)[0]][att[keyValuePairs[i].split(split)[0]].length] = keyValuePairs[i].split(split)[1];                              
                  } else {             
                        var splitArray = keyValuePairs[i].split(split);
                        splitArray.shift();

                        att[keyValuePairs[i].split(split)[0]] = splitArray.join(split);
                  }
            }
            
      }
            
      return att;

}
/*
 */
document.getElementsByClass = function(cssName) {

}

/**
 * Get all elements that have a certain css class attached to them
 * 
 * @version 1.0
 * @param string type The type of node (ex. <div>)
 * @param string cssName The classname to search for
 * @return array
 */
document.getElementsByNameClass = function(type, cssName) {

      var ret = new Array();
      var elements =  document.getElementsByTagName(type);
      
      for(var i = 0; i < elements.length; i++) {
      	if(elements[i].className.indexOf(cssName) != -1) {        	     
                  ret.push(elements[i]); 
            }
      }

      return ret;
}

/**
 * Get all elements that have a certain value in the id
 * 
 * @version 1.0
 * @param string type The type of node (ex. <div>)
 * @param string cssName The classname to search for
 * @return array
 */
document.getElementsByTypeId = function(type, cssName) {

      var ret = new Array();
      var elements =  document.getElementsByTagName(type);
      
      for(var i = 0; i < elements.length; i++) {                 
      	if(elements[i].className.indexOf(cssName) != -1) {        	     
                  ret.push(elements[i]); 
            }
      }

      return ret;
}

/**
 * Line up all elements of a certain cssName and give them equal width
 * 
 * @version 1.0
 * @param string label The css class that will be adjusted
 */
document.adjustForm = function(label) {

	var labels = document.getElementsByTagName('label');
	var changeDiv = new Array();
	var length = 0;
	
	for(var i = 0; i < labels.length; i++) {
		var css = labels[i].className;
		if(css.indexOf(label) != -1) {                             	
			length = (labels[i].offsetWidth - 5 > length) ? labels[i].offsetWidth - 5 : length;
			changeDiv.push(labels[i]);
		}
	}

      if(length == 0) length = 150;

	for(var i = 0; i < changeDiv.length; i++) {
		changeDiv[i].style.width = length;
	}

}

document.attachClass = function(elements, cssName) {

}


/*
 */
initParam.push('domMan');

/**
 * Object that can create DOM nodes of any kind
 * Configurable through att which features all the settings of the node
 * 
 * @version 1.0
 * @param string type Which HTML-Tag will be created
 * @param object att The attributes that will be set
 * @param object parent The parentnode where the created node will be attached
 */
function domMan(type, att, parent) {
      
      this.type = type;
      this.att = att;
      this.parent = parent;
      
      if(this.tags.contains(type)) {
            this.node = this.create(type);                                                
            if(typeof(att) == "object") this.setAttributes(att);
      
            if(typeof(parent) == "object") this.append(parent);
            
      }
      else if(typeof(type) == "object") {
            this.node = type;
      }
}

/**
 * The allowed HTML-Tags as array
 */
domMan.prototype.tags = "address applet area a base basefont big blockquote body br b caption center cite code dd dfn dir div dl dt em font form h1 h2 h3 h4 h5 h6 head hr html img input isindex i kbd label link li map menu meta ol option param pre p samp script select small span strike strong style sub sup table tbody td textarea th title tr tt ul u var".split(" ");

/**
 * Create the node
 * 
 * @version 1.0
 * @param string type Which HTML-Tag will be created
 */
domMan.prototype.create = function(type) {
       return document.createElement(type);
}

/**
 * Sets the attributes of the node, has special handling for eventHandlers
 * 
 * @version 1.0
 * @param object att The attributes
 */
domMan.prototype.setAttributes = function(att) {

      handler = "onAbort onBlur onChange onClick onDblClick onError onFocus onKeydown onKeypress onKeyup onLoad onMousedown onMousemove onMouseout onMouseover onMouseUp onReset onSelect onSubmit onUnload".split(" ");

      for(var i in att) {
            if(handler.contains(i)) this.setHandler(i, att[i]);
            else if(i == 'innerHTML') this.node.innerHTML = att[i];
            else if(i == 'class') this.node.className = att[i];
            else this.node.setAttribute(i, att[i]);
             
      }
}

/**
 * Sets the eventHandlers
 * 
 * @version 1.0
 * @param string handler Which handler will be set
 * @param string call The function to call when event sets off
 */
domMan.prototype.setHandler = function(handler, call) {

      //addEvent(this.node, 'submit', new Function(call), false);
      switch(handler) {            
            case 'onAbort':
            this.node.onabort = new Function(call);
            break;
            case 'onBlur': 
            this.node.onblur = new Function(call);
            break;
            case 'onChange': 
            this.node.onchange = new Function(call);
            break;
            case 'onClick':
            this.node.onclick = new Function(call);
            break;
            case 'onDblClick':
            this.node.ondblclick = new Function(call);
            break;
            case 'onError':
            this.node.onerror = new Function(call);
            break;
            case 'onFocus':
            this.node.onfocus = new Function(call);
            break;
            case 'onKeydown':
            this.node.onkeydown = new Function(call);
            break;
            case 'onKeypress':
            this.node.onkeypress = new Function(call);
            break;
            case 'onKeyup':
            this.node.onkeyup = new Function(call);
            break;
            case 'onLoad':
            this.node.onload = new Function(call);
            break;
            case 'onMousedown':
            this.node.onmousedown = new Function(call);
            break;
            case 'onMousemove':
            this.node.onmousemove = new Function(call);
            break;
            case 'onMouseout':
            this.node.onmouseout = new Function(call);
            break;
            case 'onMouseover':
            this.node.onmouseover = new Function(call);
            break;
            case 'onMouseUp':
            this.node.onmouseup = new Function(call);
            break;
            case 'onReset':
            this.node.onreset = new Function(call);
            break;
            case 'onSelect':
            this.node.onselect = new Function(call);
            break;
            case 'onSubmit':
            this.node.onsubmit = new Function(call);      
            break;
            case 'onUnload':
            this.node.onunload = new Function(call);
            break;
      }

      
      //node = new Function(call);
      //alert(this.node.onsubmit);

}

/**
 * Add the node to the DOM-Tree
 * 
 * @version 1.0
 * @param object parent The parentnode
 */
domMan.prototype.append = function(parent) {  
      parent.appendChild(this.node);
}

/**
 * Get rid of a created node
 * 
 * @version 1.0
 */
domMan.prototype.remove = function() {
      this.node.parentNode.removeChild(this.node);
}


/**
 * Get rid of a created node
 * 
 * @version 1.0
 */
domMan.prototype.addEventListener = function() {
    
}


/*
 */
initParam.push('lang');

/**
 * Handle the client side language pack
 * 
 * @version 1.0
 */
function lang() {      
      this.enterPassword = 'Bitte Passwort eingeben';
      this.passwordCorrect = 'Das Passwort ist korrekt';
      this.passwordFalse = 'Das Passwort ist falsch';
        
      this.itemMenuedit = '<img src="/robots.txt/imageCache/17/" class="icon" alt="Bearbeiten" /> Bearbeiten';
      this.itemMenuview = '<img src="/robots.txt/imageCache/23/" class="icon" alt="Ansehen" /> Ansehen';
      this.itemMenudelete = '<img src="/robots.txt/imageCache/22/" class="icon" alt="Löschen" /> Löschen';      
      this.itemMenunew = '<img src="/robots.txt/imageCache/1/" class="icon" alt="Neuen Inhalt erzeugen" /> Neu erstellen';            
      this.itemMenusub = '<img src="/robots.txt/imageCache/71/" class="icon" alt="Neuer Unterordner" /> Neuer Unterordner';        
      this.itemMenumodule = '<img src="/robots.txt/imageCache/19/" class="icon" alt="Ordner öffnen" /> Ordner öffnen'; 

      
this.itemMenu_module1 = '<img src="/robots.txt/imageCache/31/" class="icon" alt="Module" /> {lang.moduleName_1}';
this.itemMenu_module2 = '<img src="/robots.txt/imageCache/32/" class="icon" alt="moduleInputs" /> {lang.moduleName_2}';
this.itemMenu_module3 = '<img src="/robots.txt/imageCache/30/" class="icon" alt="Komponenten" /> {lang.moduleName_3}';
this.itemMenu_module4 = '<img src="/robots.txt/imageCache/24/" class="icon" alt="Language" /> {lang.moduleName_4}';
this.itemMenu_module5 = '<img src="/robots.txt/imageCache/16/" class="icon" alt="userData" /> {lang.moduleName_5}';
this.itemMenu_module6 = '<img src="/robots.txt/imageCache/25/" class="icon" alt="presences" /> {lang.moduleName_6}';
this.itemMenu_module7 = '{img.moduleIcon_7} {lang.moduleName_7}';
this.itemMenu_module8 = '<img src="/robots.txt/imageCache/26/" class="icon" alt="content" /> {lang.moduleName_8}';
this.itemMenu_module9 = '<img src="/robots.txt/imageCache/48/" class="icon" alt="Whatever" /> {lang.moduleName_9}';
this.itemMenu_module10 = '{img.moduleIcon_10} {lang.moduleName_10}';
this.itemMenu_module11 = '{img.moduleIcon_11} {lang.moduleName_11}';
this.itemMenu_module12 = '{img.moduleIcon_12} {lang.moduleName_12}';
this.itemMenu_module13 = '<img src="/robots.txt/imageCache/2/" class="icon" alt="Text" /> Normaler Text';
this.itemMenu_module14 = '<img src="/robots.txt/imageCache/27/" class="icon" alt="News" /> News';
this.itemMenu_module15 = '<img src="/robots.txt/imageCache/28/" class="icon" alt="Administration" /> Administration';
this.itemMenu_module16 = '<img src="/robots.txt/imageCache/29/" class="icon" alt="Navigatoren" /> Navigator';
this.itemMenu_module17 = '<img src="/robots.txt/imageCache/30/" class="icon" alt="Formular" /> Formular';
this.itemMenu_module18 = '<img src="/robots.txt/imageCache/30/" class="icon" alt="Komponenten" /> {lang.moduleName_18}';
this.itemMenu_module19 = '<img src="/robots.txt/imageCache/15/" class="icon" alt="userGroups" /> {lang.moduleName_19}';
this.itemMenu_module20 = '<img src="/robots.txt/imageCache/16/" class="icon" alt="User Backend" /> {lang.moduleName_20}';
this.itemMenu_module21 = '<img src="/robots.txt/imageCache/36/" class="icon" alt="Konstante" /> Konstante';
this.itemMenu_module22 = '<img src="/robots.txt/imageCache/37/" class="icon" alt="Script-Code" /> Script-Code';
this.itemMenu_module23 = '<img src="/robots.txt/imageCache/38/" class="icon" alt="templatesLists" /> Auflistung';
this.itemMenu_module24 = '<img src="/robots.txt/imageCache/30/" class="icon" alt="Komponenten" /> {lang.moduleName_24}';
this.itemMenu_module25 = '<img src="/robots.txt/imageCache/37/" class="icon" alt="Fortgeschritten" /> {lang.moduleName_25}';
this.itemMenu_module26 = '{img.moduleIcon_26} {lang.moduleName_26}';
this.itemMenu_module27 = '<img src="/robots.txt/imageCache/40/" class="icon" alt="Bildergallerie" /> Bildergallerie';
this.itemMenu_module28 = '<img src="/robots.txt/imageCache/42/" class="icon" alt="Vorlage Bild" /> Bild';
this.itemMenu_module29 = '<img src="/robots.txt/imageCache/25/" class="icon" alt="Präsenz Alias" /> {lang.moduleName_29}';
this.itemMenu_module30 = '<img src="/robots.txt/imageCache/32/" class="icon" alt="Präsenz Parameter" /> {lang.moduleName_30}';
this.itemMenu_module31 = '<img src="/robots.txt/imageCache/16/" class="icon" alt="Camper" /> {lang.moduleName_31}';
this.itemMenu_module32 = '<img src="/robots.txt/imageCache/48/" class="icon" alt="Supercamps" /> {lang.moduleName_32}';
this.itemMenu_module34 = '<img src="/robots.txt/imageCache/49/" class="icon" alt="Benachrichtigung" /> Benachrichtigung';
this.itemMenu_module35 = '<img src="/robots.txt/imageCache/46/" class="icon" alt="Anmeldungen" /> {lang.moduleName_35}';
this.itemMenu_module36 = '<img src="/robots.txt/imageCache/15/" class="icon" alt="Extra Kid" /> {lang.moduleName_36}';
this.itemMenu_module37 = '<img src="/robots.txt/imageCache/15/" class="icon" alt="Kooperation" /> Kooperation';
this.itemMenu_module39 = '{img.moduleIcon_39} {lang.moduleName_39}';
this.itemMenu_module40 = '<img src="/robots.txt/imageCache/60/" class="icon" alt="Supercamper" /> Supercamper';
this.itemMenu_module41 = '<img src="/robots.txt/imageCache/16/" class="icon" alt="Coach" /> {lang.moduleName_41}';
this.itemMenu_module42 = '<img src="/robots.txt/imageCache/16/" class="icon" alt="Coaches" /> {lang.moduleName_42}';
this.itemMenu_module43 = '<img src="/robots.txt/imageCache/78/" class="icon" alt="Programm" /> {lang.moduleName_43}';
this.itemMenu_module44 = '<img src="/robots.txt/imageCache/81/" class="icon" alt="Backup" /> {lang.moduleName_44}';
this.itemMenu_module46 = '<img src="/robots.txt/imageCache/31/" class="icon" alt="Hook" /> Hook Funktion';
this.itemMenu_module47 = '<img src="/robots.txt/imageCache/27/" class="icon" alt="Campnews" /> Campnews';
this.itemMenu_module48 = '<img src="/robots.txt/imageCache/77/" class="icon" alt="Wettkampf" /> Wettkämpfe';
this.itemMenu_module49 = '<img src="/robots.txt/imageCache/77/" class="icon" alt="Wettkampf" /> Wettkampf';
this.itemMenu_module50 = '<img src="/robots.txt/imageCache/85/" class="icon" alt="Ergebnisse" /> Ergebnisse';
this.itemMenu_module51 = '<img src="/robots.txt/imageCache/87/" class="icon" alt="Camp-Talk" /> Camp-Talk';
this.itemMenu_module52 = '<img src="/robots.txt/imageCache/0/" class="icon" alt="Nightjam-Anmeldung" /> Nightjam-Anmeldung';
this.itemMenu_module53 = '<img src="/robots.txt/imageCache/0/" class="icon" alt="Akademie Anmeldung" /> Akademie Anmeldung';
this.itemMenu_module54 = '<img src="/robots.txt/imageCache/18790/" class="icon" alt="Produkte" /> Produkte';
      
      this.userIcon_w = '<img src="/robots.txt/imageCache/20/" class="icon" alt="selectWorld" />';
      this.userIcon_g = '<img src="/robots.txt/imageCache/15/" class="icon" alt="userGroups" />';
      this.userIcon_u = '<img src="/robots.txt/imageCache/16/" class="icon" alt="userData" />';

      this.parameterIcon = '<img src="/robots.txt/imageCache/25/" class="icon" alt="presences" />';      
      
      
      this.userRemove = '<img src="/robots.txt/imageCache/22/" class="icon" alt="Löschen" />';
      this.name = 'Name';
                  
      this.extractArchive = 'Archiv in diesen Ordner entpacken';                  
                  
      this.fileBrowse = '<img src="/robots.txt/imageCache/7/" class="icon" alt="Datei Selector" />';
      
      this.tableFilter = '<img src="/robots.txt/imageCache/21/" class="icon" alt="tableFilter" />';
      
      this.root = 'Wurzelknoten' //'Wurzel';
      
      this.requiredField = 'Pflichtfeld bitte ausfüllen!';
      this.requiredMissing = 'Es sind nicht alle Pflichtfelder ausgefüllt!';
      
      this.back = 'Zurück';
      this.forward = 'Weiter';
      this.page = 'Seite';    
      this.image = 'Bild';
      this.of = 'von';
      this.closeImg = 'Schließen <img src="/robots.txt/imageCache/41/" class="icon" alt="Schließen" />';
      
      this.uploadFiles = '{lang.uploadFiles}';
      
}




/**
 * Handles global vars
 *
 */
 
var conWebDir = '/camps/../';
var conWebPresDir = '/camps/';
var conImageDir = 'imageCache/';

var conUserLang = 'DE';
/*
 */
initParam.push('layoutObj');

layoutObj = function() {
      this.init();
}

layoutObj.prototype.init = function() {
      this.setTableStyles();
}

/**
 * sets for each table cellspacing and cellpadding to zero, because it cannot be changed by css
 * 
 * @version 1.0
 */
layoutObj.prototype.setTableStyles = function() {
      
      var tables = document.getElementsByTagName('table');
      
      for(var i = 0; i < tables.length; i++) {
            tables[i].cellSpacing = (tables[i].cellSpacing == '') ? 0 : tables[i].cellSpacing;
            tables[i].cellPadding = (tables[i].cellPadding == '') ? 2 : tables[i].cellPadding;
      }
      
}
/*
 */
initParam.push('templateListObj');

/**
 * Maintains a tree from nested lists
 * 
 * @version 1.0
 */
function templateListObj() {
      this.init();
}

/**
 * Build all the necessary items for the tree layout
 * 
 * @version 1.0
 */
templateListObj.prototype.init = function() { 
    
    var uls = document.getElementsByNameClass("ul", "conList");
    
    for (var uli=0;uli<uls.length;uli++) {       
            listColorDoIt(uls[uli], uls[uli].id);
    }                   
    
}  

/**
 * colors a list by placing the cssClass even on every second item
 * 
 * @version 1.0
 */
listColorDoIt = function(input, id) {

      var tri = 0;
      
      for(var i = 0; i <  input.childNodes.length; i++) {
            var item = input.childNodes[i];
            
            if(item.nodeName == "LI") {                
                  item.className = (tri%2 == 0) ? item.className + ' even' : item.className;            
                  tri++;
            }
      }           
} 
/*
Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2.4.0
*/
if(typeof YAHOO=="undefined"||!YAHOO){var YAHOO={};}YAHOO.namespace=function(){var A=arguments,E=null,C,B,D;for(C=0;C<A.length;C=C+1){D=A[C].split(".");E=YAHOO;for(B=(D[0]=="YAHOO")?1:0;B<D.length;B=B+1){E[D[B]]=E[D[B]]||{};E=E[D[B]];}}return E;};YAHOO.log=function(D,A,C){var B=YAHOO.widget.Logger;if(B&&B.log){return B.log(D,A,C);}else{return false;}};YAHOO.register=function(A,E,D){var I=YAHOO.env.modules;if(!I[A]){I[A]={versions:[],builds:[]};}var B=I[A],H=D.version,G=D.build,F=YAHOO.env.listeners;B.name=A;B.version=H;B.build=G;B.versions.push(H);B.builds.push(G);B.mainClass=E;for(var C=0;C<F.length;C=C+1){F[C](B);}if(E){E.VERSION=H;E.BUILD=G;}else{YAHOO.log("mainClass is undefined for module "+A,"warn");}};YAHOO.env=YAHOO.env||{modules:[],listeners:[]};YAHOO.env.getVersion=function(A){return YAHOO.env.modules[A]||null;};YAHOO.env.ua=function(){var C={ie:0,opera:0,gecko:0,webkit:0,mobile:null};var B=navigator.userAgent,A;if((/KHTML/).test(B)){C.webkit=1;}A=B.match(/AppleWebKit\/([^\s]*)/);if(A&&A[1]){C.webkit=parseFloat(A[1]);if(/ Mobile\//.test(B)){C.mobile="Apple";}else{A=B.match(/NokiaN[^\/]*/);if(A){C.mobile=A[0];}}}if(!C.webkit){A=B.match(/Opera[\s\/]([^\s]*)/);if(A&&A[1]){C.opera=parseFloat(A[1]);A=B.match(/Opera Mini[^;]*/);if(A){C.mobile=A[0];}}else{A=B.match(/MSIE\s([^;]*)/);if(A&&A[1]){C.ie=parseFloat(A[1]);}else{A=B.match(/Gecko\/([^\s]*)/);if(A){C.gecko=1;A=B.match(/rv:([^\s\)]*)/);if(A&&A[1]){C.gecko=parseFloat(A[1]);}}}}}return C;}();(function(){YAHOO.namespace("util","widget","example");if("undefined"!==typeof YAHOO_config){var B=YAHOO_config.listener,A=YAHOO.env.listeners,D=true,C;if(B){for(C=0;C<A.length;C=C+1){if(A[C]==B){D=false;break;}}if(D){A.push(B);}}}})();YAHOO.lang=YAHOO.lang||{isArray:function(B){if(B){var A=YAHOO.lang;return A.isNumber(B.length)&&A.isFunction(B.splice);}return false;},isBoolean:function(A){return typeof A==="boolean";},isFunction:function(A){return typeof A==="function";},isNull:function(A){return A===null;},isNumber:function(A){return typeof A==="number"&&isFinite(A);},isObject:function(A){return(A&&(typeof A==="object"||YAHOO.lang.isFunction(A)))||false;},isString:function(A){return typeof A==="string";},isUndefined:function(A){return typeof A==="undefined";},hasOwnProperty:function(A,B){if(Object.prototype.hasOwnProperty){return A.hasOwnProperty(B);}return !YAHOO.lang.isUndefined(A[B])&&A.constructor.prototype[B]!==A[B];},_IEEnumFix:function(C,B){if(YAHOO.env.ua.ie){var E=["toString","valueOf"],A;for(A=0;A<E.length;A=A+1){var F=E[A],D=B[F];if(YAHOO.lang.isFunction(D)&&D!=Object.prototype[F]){C[F]=D;}}}},extend:function(D,E,C){if(!E||!D){throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");}var B=function(){};B.prototype=E.prototype;D.prototype=new B();D.prototype.constructor=D;D.superclass=E.prototype;if(E.prototype.constructor==Object.prototype.constructor){E.prototype.constructor=E;}if(C){for(var A in C){D.prototype[A]=C[A];}YAHOO.lang._IEEnumFix(D.prototype,C);}},augmentObject:function(E,D){if(!D||!E){throw new Error("Absorb failed, verify dependencies.");}var A=arguments,C,F,B=A[2];if(B&&B!==true){for(C=2;C<A.length;C=C+1){E[A[C]]=D[A[C]];}}else{for(F in D){if(B||!E[F]){E[F]=D[F];}}YAHOO.lang._IEEnumFix(E,D);}},augmentProto:function(D,C){if(!C||!D){throw new Error("Augment failed, verify dependencies.");}var A=[D.prototype,C.prototype];for(var B=2;B<arguments.length;B=B+1){A.push(arguments[B]);}YAHOO.lang.augmentObject.apply(this,A);},dump:function(A,G){var C=YAHOO.lang,D,F,I=[],J="{...}",B="f(){...}",H=", ",E=" => ";if(!C.isObject(A)){return A+"";}else{if(A instanceof Date||("nodeType" in A&&"tagName" in A)){return A;}else{if(C.isFunction(A)){return B;}}}G=(C.isNumber(G))?G:3;if(C.isArray(A)){I.push("[");for(D=0,F=A.length;D<F;D=D+1){if(C.isObject(A[D])){I.push((G>0)?C.dump(A[D],G-1):J);}else{I.push(A[D]);}I.push(H);}if(I.length>1){I.pop();}I.push("]");}else{I.push("{");for(D in A){if(C.hasOwnProperty(A,D)){I.push(D+E);if(C.isObject(A[D])){I.push((G>0)?C.dump(A[D],G-1):J);}else{I.push(A[D]);}I.push(H);}}if(I.length>1){I.pop();}I.push("}");}return I.join("");},substitute:function(Q,B,J){var G,F,E,M,N,P,D=YAHOO.lang,L=[],C,H="dump",K=" ",A="{",O="}";for(;;){G=Q.lastIndexOf(A);if(G<0){break;}F=Q.indexOf(O,G);if(G+1>=F){break;}C=Q.substring(G+1,F);M=C;P=null;E=M.indexOf(K);if(E>-1){P=M.substring(E+1);M=M.substring(0,E);}N=B[M];if(J){N=J(M,N,P);}if(D.isObject(N)){if(D.isArray(N)){N=D.dump(N,parseInt(P,10));}else{P=P||"";var I=P.indexOf(H);if(I>-1){P=P.substring(4);}if(N.toString===Object.prototype.toString||I>-1){N=D.dump(N,parseInt(P,10));}else{N=N.toString();}}}else{if(!D.isString(N)&&!D.isNumber(N)){N="~-"+L.length+"-~";L[L.length]=C;}}Q=Q.substring(0,G)+N+Q.substring(F+1);}for(G=L.length-1;G>=0;G=G-1){Q=Q.replace(new RegExp("~-"+G+"-~"),"{"+L[G]+"}","g");}return Q;},trim:function(A){try{return A.replace(/^\s+|\s+$/g,"");}catch(B){return A;}},merge:function(){var D={},B=arguments;for(var C=0,A=B.length;C<A;C=C+1){YAHOO.lang.augmentObject(D,B[C],true);}return D;},later:function(H,B,I,D,E){H=H||0;B=B||{};var C=I,G=D,F,A;if(YAHOO.lang.isString(I)){C=B[I];}if(!C){throw new TypeError("method undefined");}if(!YAHOO.lang.isArray(G)){G=[D];}F=function(){C.apply(B,G);};A=(E)?setInterval(F,H):setTimeout(F,H);return{interval:E,cancel:function(){if(this.interval){clearInterval(A);}else{clearTimeout(A);}}};},isValue:function(B){var A=YAHOO.lang;return(A.isObject(B)||A.isString(B)||A.isNumber(B)||A.isBoolean(B));}};YAHOO.util.Lang=YAHOO.lang;YAHOO.lang.augment=YAHOO.lang.augmentProto;YAHOO.augment=YAHOO.lang.augmentProto;YAHOO.extend=YAHOO.lang.extend;YAHOO.register("yahoo",YAHOO,{version:"2.4.0",build:"733"});/*
 */
initParam.push('formObj');
initParam.push('tabObj');

// STYLING FILE INPUTS 1.0 | Shaun Inman <http://www.shauninman.com/> | 2007-09-07
if (!window.SI) { var SI = {}; };
SI.Files =
{
	htmlClass : 'SI-FILES-STYLIZED',
	fileClass : 'file',
	wrapClass : 'cabinet',
	
	fini : false,
	able : false,
	init : function()
	{
		this.fini = true;
		
		var ie = 0 //@cc_on + @_jscript_version
		if (window.opera || (ie && ie < 5.5) || !document.getElementsByTagName) { return; } // no support for opacity or the DOM
		this.able = true;
		
		var html = document.getElementsByTagName('html')[0];
		html.className += (html.className != '' ? ' ' : '') + this.htmlClass;
	},
	
	stylize : function(elem)
	{
		if (!this.fini) { this.init(); };
		if (!this.able) { return; };
		
		elem.parentNode.file = elem;
		elem.parentNode.onmousemove = function(e)
		{
			if (typeof e == 'undefined') e = window.event;
			if (typeof e.pageY == 'undefined' &&  typeof e.clientX == 'number' && document.documentElement)
			{
				e.pageX = e.clientX + document.documentElement.scrollLeft;
				e.pageY = e.clientY + document.documentElement.scrollTop;
			};

			var ox = oy = 0;
			var elem = this;
			if (elem.offsetParent)
			{
				ox = elem.offsetLeft;
				oy = elem.offsetTop;
				while (elem = elem.offsetParent)
				{
					ox += elem.offsetLeft;
					oy += elem.offsetTop;
				};
			};

			var x = e.pageX - ox;
			var y = e.pageY - oy;
			var w = this.file.offsetWidth;
			var h = this.file.offsetHeight;

			this.file.style.top		= y - (h / 2)  + 'px';
			this.file.style.left	= x - (w - 30) + 'px';
		};
	},
	
	stylizeById : function(id)
	{
		this.stylize(document.getElementById(id));
	},
	
	stylizeAll : function()
	{
		if (!this.fini) { this.init(); };
		if (!this.able) { return; };
		
		var inputs = document.getElementsByTagName('input');
		for (var i = 0; i < inputs.length; i++)
		{
			var input = inputs[i];
			if (input.type == 'file' && input.className.indexOf(this.fileClass) != -1 && input.parentNode.className.indexOf(this.wrapClass) != -1)
			{
				this.stylize(input);
			};
		};
	}
};


/**
 * Initializes the form
 * 
 * @version 1.0
 */
formObj = function() {
        this.display();
}

/**
 * Initializes the form
 * 
 * @version 1.0
 */
formObj.prototype.display = function() {
      
      //document.adjustForm('');
      this.styleFileInput();
      SI.Files.stylizeAll();
      
}


/**
 * Uses the method from http://www.quirksmode.org/dom/inputfile.html
 * to style a file upload field differently
 * 
 * @version 1.0
 */
formObj.prototype.styleFileInput = function()
{
      var fileInputs = document.getElementsByNameClass('input', 'file');
      
      for(var i = 0; i < fileInputs.length; i++) {

            var inputName = fileInputs[i].name;

            //create the container div
            var att = new Object();
            att['class'] = 'fileUpload';
            att['id'] = inputName + 'DIV';   
            
            var container = new domMan('div', att, fileInputs[i].parentNode.parentNode);

            //create the placeholder where the filename will be displayed
            var att = new Object();            
            var text = new domMan('span', att, fileInputs[i].parentNode.parentNode);             
            
            //change the input file name to have an extra FILE at the end
            var inputName = fileInputs[i].name;
            fileInputs[i].name = inputName + 'FILE';
            
            //create a hidden input that will store the file name that is submitted to the DB
            var att = new Object();                        
            att['name'] = inputName;
            att['type'] = 'hidden';  
            
            if(fileInputs[i].className.indexOf('required') != -1) {
            	att['class'] = 'required';	
            }
            
            var hiddenInput = new domMan('input', att, container.node);
            
            fileInputs[i].textNode = text.node;
            fileInputs[i].relatedHidden = hiddenInput.node;
            
            fileInputs[i].onchange = function() {
                  checkFileUpload(this, this.textNode, this.relatedHidden);
            }
            
            //this input has already a file associated
            if(document.getElementsByName(inputName + 'Keep').length > 0) {
                  if(document.getElementsByName(inputName + 'Keep')[0].checked) switchFileInput(inputName);                  
            }
      }
}


/**
 * Uses the method from http://www.quirksmode.org/dom/inputfile.html
 * to style a file upload field differently
 * 
 * @version 1.0
 */
checkFileUpload = function(input, text, hidden) { 
                
      text.innerHTML = input.value; 
            
      if(input.className.indexOf('regular') < 0) {    
                       
            //if this is unix style structure replace / with \
            var filePath = input.value.replace(/\//g, '\\');        
            
            //extract the filename from the value
            var indexPos = filePath.lastIndexOf('\\');
            var fileName = filePath.substring(indexPos + 1);
            
            hidden.value = fileName;            
            
            search = /(zip|tar|gz)$/i;
            
            if(search.test(fileName)) {
                  createArchiveCheck(input);
            }
      }      
}


createArchiveCheck = function(input) {

            var att = new Object();
            att['innerHTML'] = '<br />';
            var archiveSpan = new domMan('span', att, input.textNode); 

            var att = new Object();                        
            att['name'] = 'extractArchive';
            att['type'] = 'checkbox';
            att['value'] = 1;
            
            var archiveInput = new domMan('input', att, archiveSpan.node);      
            
            archiveInput.node.checked = 'checked';
            
            var text = document.createTextNode(langProt.extractArchive);
            archiveSpan.node.appendChild(text);            
}


/**
 * When we have a file field that already has a value we need a possiblity to change that file
 * 
 * @version 1.0
 */
switchFileInput = function(name) {
      
      var inputHidden = document.getElementsByName(name)[0];
      var inputFile   = document.getElementsByName(name + 'FILE')[0];
      var container   = document.getElementById(name + 'DIV');
      
      if(inputHidden.disabled) {
            inputHidden.disabled = false;
            inputFile.disabled = false;
            container.style.display = 'block';
            inputFile.textNode.style.display = 'block';            
      } else {       
            inputHidden.disabled = true;
            inputFile.disabled = true;
            container.style.display = 'none'; 
            inputFile.textNode.style.display = 'none';        
      }                  
      
}

    
/**
 * Manages tabs for different layered input forms
 * 
 * @version 1.0
 */
tabObj = function() {
      this.activePanel = false;
      this.createTabs()
}

tabObj.prototype.createTabs = function() {
      
      var tabBar = document.getElementById('tabWrapper');
      
      var tabs = document.getElementsByNameClass('fieldset', 'panel');
            
      if(tabs.length > 0) {
            var att = new Object();            
            var ul = new domMan('ul', att, tabBar);
            
            var current = false;
            var j = false;
            
            for(var i = 0; i < tabs.length; i++)
            {            
                  j = i;      
                  var att = new Object();                  
                  att['id'] = tabs[i].id + 'Tab';                  
                  if((i == 0 && !panelState[activeModule]) || tabs[i].id == panelState[activeModule]) {  
                        current = true;
                        this.activePanel = tabs[i].id;
                        att['class'] = 'current';
                        var panel = document.getElementById(this.activePanel);
                        panel.className = 'panel current';                         
                        
                  } 
                           
                  var li = new domMan('li', att, ul.node);                  
                  
                  var att = new Object();                  
                  att['innerHTML'] = tabs[i].id;
                  att['href'] = '#';
                  att['onClick'] = 'tabObjProt.displayTab("' + tabs[i].id + '"); return false;';                  
                  
                  var a = new domMan('a', att, li.node);  
            }
      
            if(!current) {                  
                  this.activePanel = tabs[j].id;
                  document.getElementById(tabs[j].id).className = 'panel current';      
            }
            
      }
      
      if(typeof(tinyMCE) != 'undefined') { 
            tinyMCE.execCommand('mceResetDesignMode');
      }          
}

tabObj.prototype.displayTab = function(name) {
      
      if(typeof(closeImageGallery) != 'undefined') {
            closeImageGallery();
      }
      
      //hide active panel
      if(this.activePanel) {
            var tab = document.getElementById(this.activePanel + 'Tab');
            tab.className = '';
      
            var panel = document.getElementById(this.activePanel);
            panel.className = 'panel';  
      }    
      
      //display new panel
      this.activePanel = name;
      
      //set the panel globally to remember state
      panelState[activeModule] = name;
      
      var tab = document.getElementById(this.activePanel + 'Tab');
      tab.className = 'current';
      
      var panel = document.getElementById(this.activePanel);
      panel.className = 'panel current';  
      
      if(typeof(tinyMCE) != 'undefined') {    
            tinyMCE.execCommand('mceResetDesignMode');
      }
                
}
     
switchInput = function(name) {
      inputs = document.getElementsByName(name);
      
      for(var i = 0; i < inputs.length; i++) {
            inputs[i].disabled = (inputs[i].disabled) ? false : true;
      }
}   

//****************************************************************************//
// These are custom functions for administration modules
//

/**
 * Convert date output to a different format
 *
 * @version 1.0
 */
convertDateLang = function(date) {
      var lang = 'DE';
            
      switch(lang) {
            case 'DE':
            var parts = date.split('-');
            date = parts[2] + '.' + parts[1] + '.' + parts[0];
            break;
      }

      return date;      
}

selectCalculateDate = function(name) {
      var year = document.getElementsByName(name + 'Years')[0].value;
      var month = document.getElementsByName(name + 'Months')[0].value;
      var day = document.getElementsByName(name + 'Days')[0].value;
      
      document.getElementsByName(name)[0].value = year + '-' + month + '-' + day;
}

/**
 * Used to check in Input Module what options need to be set
 * for a certain column type
 * 
 * @version 1.0
 */
moduleInputCheckOptions = function(select) {
      var type = select.value;
      
      if(typeof(select.required) != 'undefined') {        
            divNode = new domMan(document.getElementById('option.' + select.required));      
            divNode.remove(); 
            delete select.required;           
      }       
      
      switch(type) {
            case 'INT':
            case 'VARCHAR':                  
                  var text = moduleOptionsGetText('options', 'length');            
                  moduleOptionsCreateOption('length', text, '', true);                  
                  
                  select.required = 'length';
                  
            break;
                                    
            case 'ENUM':            
                  var text = moduleOptionsGetText('options', 'length');            
                  moduleOptionsCreateOption('length', text, '', true);                               
                  
                  select.required = 'length';
                  
                  var text = moduleOptionsGetText('options', 'enum');            
                  moduleOptionsCreateOption('enum', text, '', true);                               
                  
                  select.required = 'enum';                  
            break;                                             
      }
}    

/**
 * Used to check in Input Module what options need to be set
 * for a certain column type
 * 
 * @version 1.0
 */
moduleInputCheckTypesOptions = function(select) {

}                                                             



/**
 * for the different list options
 * 
 * @version 1.0
 */
moduleListCheckType = function(select) {
      var type = select.value;
      
      var types = new Array('content','media','module','hook');
      
      for(var i = 0; i < types.length; i++) {
            var input = document.getElementsByName(types[i] + 'Type')[0];
            input.parentNode.style.display = 'none';  
                      
            if(types[i] == 'hook') input.value = '';
            else input.selectedIndex = 0;      
            
            if(typeof(input.onchange) == 'function') input.onchange();
      }

      if(type != '') {
            select.activeType = type + 'Type';
      
            var input = document.getElementsByName(select.activeType)[0];
            input.parentNode.style.display = '';  
      }     
}

/**
 * for the different list options
 * 
 * @version 1.0
 */
moduleListCheckContentType = function(select) {
      var type = select.value;
      
      var types = new Array('contentTypeType','contentTypeStructure');
      
      for(var i = 0; i < types.length; i++) {
            var input = document.getElementsByName(types[i])[0];
            input.parentNode.style.display = 'none';  
                      
            switch(types[i]) {
                  case 'contentTypeType':
                        input.selectedIndex = 0;
                  break;
                  
                  case 'contentTypeStructure':
                        input.value = '';                         
                        var desc = document.getElementById('contentTypeStructureDesc');
                        desc.innerHTML = '';
                  break;            
            }      
      }      

      if(type != '') {
            
            switch(type) {
                  case 'type':
                        select.activeType = 'contentTypeType';
                        var input = document.getElementsByName(select.activeType)[0];
                        input.parentNode.style.display = ''; 
                  break;
                  
                  case 'structure':
                        select.activeType = 'contentTypeStructure';                  
                        var input = document.getElementsByName(select.activeType)[0];
                        input.parentNode.style.display = '';                         
                  break;
                  
                  case 'activeStructure':
                  case 'contentPage':
                                               
                  break;
      
            } 
      }     
}    

/**
 * for the different list options
 * 
 * @version 1.0
 */
moduleListCheckMediaType = function(select) {
      var type = select.value;
      
      var types = new Array('mediaTypeStructure');
      
      for(var i = 0; i < types.length; i++) {
            var input = document.getElementsByName(types[i])[0];
            input.parentNode.style.display = 'none';  
                      
            switch(types[i]) {                       
                  case 'mediaTypeStructure':
                        input.value = '';                         
                        var desc = document.getElementById('mediaTypeStructureDesc');
                        desc.innerHTML = '';
                  break;            
            }      
      }      

      if(type != '') {
            
            switch(type) {                  
                  case 'folder':
                        select.activeType = 'mediaTypeStructure';                  
                        var input = document.getElementsByName(select.activeType)[0];
                        input.parentNode.style.display = '';                         
                  break;

                  case 'contentPage':
                                               
                  break;       
            } 
      }     
}

moduleDisplayFormCheckType = function(select) {
      var type = select.value;
      
      var types = new Array('registerGroup');
      
      for(var i = 0; i < types.length; i++) {

            var input = document.getElementsByName(types[i])[0];
            input.parentNode.style.display = 'none';  
            
            switch(types[i]) {      
                  case 'registerGroup':                   
                        input.value = '';                         
                        var desc = document.getElementById('registerGroupDesc');
                        desc.innerHTML = '';                                    
                  break;
            } 
      }

      if(type != '') {
            
            switch(type) {   
            
                  case 'register':
                        var input = document.getElementsByName('registerGroup')[0];
                        input.parentNode.style.display = ''; 
                  break;
            } 
      }  
}

moduleNavigatorCheckRoot = function(select) {
      var type = select.value;
      
      var types = new Array('root', 'rootLevel');
      
      for(var i = 0; i < types.length; i++) {

            var input = document.getElementsByName(types[i])[0];
            input.parentNode.style.display = 'none';  
            
            switch(types[i]) {      
                  case 'root':                   
                        input.value = '';                         
                        var desc = document.getElementById('rootDesc');
                        desc.innerHTML = '';                                    
                  break;      
                  
                  case 'rootLevel':                   
                        input.value = '';                                       
                  break;
            } 
      }

      if(type != '') {
            
            switch(type) {   
                  case 'level':
                        var input = document.getElementsByName('rootLevel')[0];
                        input.parentNode.style.display = ''; 
                  break;
            
                  case 'custom':
                        var input = document.getElementsByName('root')[0];
                        input.parentNode.style.display = ''; 
                  break;
            } 
      }  
}   

moduleNavigatorCheckChild = function(select) {
      var type = select.value;
      
      var types = new Array('childLevels');
      
      for(var i = 0; i < types.length; i++) {

            var input = document.getElementsByName(types[i])[0];
            input.parentNode.style.display = 'none';       
            input.value = '';         
      }        

      if(type != '') {
            
            switch(type) {   
                  case 'active':
                  case 'nested':
                        var input = document.getElementsByName('childLevels')[0];
                        input.parentNode.style.display = ''; 
                  break;
            } 
      }  
}    

moduleNavigatorCheckParent = function(select) {
      var type = select.value;
      
      var types = new Array('parentLevels');
      
      for(var i = 0; i < types.length; i++) {

            var input = document.getElementsByName(types[i])[0];
            input.parentNode.style.display = 'none';       
            input.value = '';         
      }        

      if(type != '') {
            
            switch(type) {   
                  case 'active':
                        var input = document.getElementsByName('parentLevels')[0];
                        input.parentNode.style.display = ''; 
                  break;
            } 
      }  
}

moduleStructureLinkType = function(select) {
      var type = select.value;
      
      var types = new Array('internalPage', 'externalPage', 'internalStructure');
      
      for(var i = 0; i < types.length; i++) {
            var input = document.getElementsByName(types[i])[0];
            input.parentNode.style.display = 'none'; 
            
            switch(types[i]) {      
                  case 'internalPage':                                                
                        var desc = document.getElementById('internalPageDesc');
                        desc.innerHTML = '';  
                        
                  case 'internalStructure':                                                
                        var desc = document.getElementById('internalStructureDesc');
                        desc.innerHTML = '';                                   
                  
                  default: 
                        input.value = ''; 
            } 
            
      }
      
      if(type != '') {             
            switch(type) {                              
                  case 'internal':
                        var input = document.getElementsByName('internalPage')[0];
                        input.parentNode.style.display = ''; 
                  break;                                   
                  case 'internalStructure':
                        var input = document.getElementsByName('internalStructure')[0];
                        input.parentNode.style.display = ''; 
                  break;                          
                  case 'external':
                        var input = document.getElementsByName('externalPage')[0];
                        input.parentNode.style.display = ''; 
                  break;
            } 
      }       
      
}/*
 */
initParam.push('listObj');

/**
 * Maintains a tree from nested lists
 * 
 * @version 1.0
 */
function listObj() {
      this.init();
}

/**
 * Build all the necessary items for the tree layout
 * 
 * @version 1.0
 */
listObj.prototype.init = function() {

    var lists = document.getElementsByNameClass("table", "listRoot");
    
    for (var listi=0;listi<lists.length;listi++) {           
            this.initList(lists[listi], lists[listi].id);
    }                     
    
}  


listObj.prototype.initList = function(table) {                
        
      listFilterDo(table, 0);
                                                  
      var dd = [];    
      var tri = 0;
      
      for (var j=0;j<table.childNodes.length;j++) { 
            
            //get the table body                       
            if(table.childNodes[j].nodeName == "TBODY") {           
                  //loop through the rows
                  for (var k=0;k<table.childNodes[j].childNodes.length;k++) {            
                        var item = table.childNodes[j].childNodes[k];
            
                        
                        if(item.nodeName == "TR") {
                              //zebra tables
                              //item.className = (tri%2 == 0) ? item.className + ' even' : item.className;
                         
                              //make row draggable
                              if(document.getElementById(item.id + "Handle") != null) {            
                              	dd[j] = new listObjDrag(item.id, 'listNode');
                              	//dd[j].setHandleElId(item.id + "Handle");
                              }
                              
                              tri++;
                        }
                  }
            }			
      }          
      
      if(YAHOO.util.DDM) YAHOO.util.DDM.mode = 0;

}


/**
 * @class a YAHOO.util.DDProxy implementation. During the drag over event, the
 * dragged element is inserted before the dragged-over element.
 *
 * @extends YAHOO.util.DDProxy
 * @constructor
 * @param {String} id the id of the linked element
 * @param {String} sGroup the group of related DragDrop objects
 */
function listObjDrag(id, sGroup) {

	if (id) {
		this.init(id, sGroup);
		this.initFrame();
		this.conType = 'listNode';
	}

	var s = this.getDragEl().style;	
}



if(YAHOO.util.DDProxy) listObjDrag.prototype = new YAHOO.util.DDProxy();

listObjDrag.prototype.startDrag = function(x, y) {

	var dragEl = this.getDragEl();
	var clickEl = this.getEl();

      //style the dragged Element
	dragEl.innerHTML = clickEl.innerHTML;
	dragEl.className = clickEl.className + ' dragList';
	dragEl.style.border = "0px solid #000000";
      
      //style the element being dragged
      clickEl.className = clickEl.className + ' dragged';
      
};

var inAction = false;

listObjDrag.prototype.endDrag = function(e) {
	var clickEl = this.getEl();
     
      //style the element being dragged
      clickEl.className = clickEl.className.replace(/dragged/, '');
      
      if(this.activeId && !inAction) {
      
            inAction = true;
            
            //extract the getVar of the module            
            var indexPos = clickEl.id.indexOf('_');
            var indexPosTarget = this.activeId.indexOf('_');
            
            var getVar = clickEl.id.substr(indexPos + 1, 33);
            var id = clickEl.id.substring(4, indexPos);            
            
            var target = this.activeId.substring(4, indexPosTarget); 
            var targetGetVar = this.activeId.substr(indexPosTarget + 1, 33);
            
            targetGetVar = (targetGetVar != getVar) ? targetGetVar : false;
            
            moduleCommit(getVar, id, this.activeType, false, target, targetGetVar);
      }
       
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();         
};

listObjDrag.prototype.onDrag = function(e, id) {    
};

listObjDrag.prototype.onDragOver = function(e, id) {
      var el;
      var clickEl = this.getEl();
      var oDD;
   
      if ("string" == typeof id) {
            el = YAHOO.util.DDM.getElement(id);
      } else { 
            el = YAHOO.util.DDM.getBestMatch(id).getEl();
      }     
      
      //check if this element is a target -> folder
      if ("string" == typeof id) {
        oDD = YAHOO.util.DDM.getDDById(id);
      } else {
        oDD = YAHOO.util.DDM.getBestMatch(id);
      }
      
      if(oDD.conType == 'listNode') this.activeType = 'sort'; 
      else this.activeType = 'changeRef';      
     
      this.activeId = el.id;

};

listObjDrag.prototype.onDragEnter = function(e, id) {  
      var el;
      var clickEl = this.getEl();
      var oDD;
   
      if ("string" == typeof id) {
            el = YAHOO.util.DDM.getElement(id);
      } else { 
            el = YAHOO.util.DDM.getBestMatch(id).getEl();
      } 

      //check if this element is a target -> folder
      if ("string" == typeof id) {
        oDD = YAHOO.util.DDM.getDDById(id);
      } else {
        oDD = YAHOO.util.DDM.getBestMatch(id);
      }      

      if(oDD.conType == 'listNode') el.className = el.className + ' sort';
      else el.className = el.className + ' target'; 

};

listObjDrag.prototype.onDragOut = function(e, id) {
      var el;
    
      if ("string" == typeof id) {
            el = YAHOO.util.DDM.getElement(id);
      } else { 
            el = YAHOO.util.DDM.getBestMatch(id).getEl();
      }
      el.className = el.className.replace(/sort/, '');
      el.className = el.className.replace(/target/, '');

      this.activeId = false;
}
/////////////////////////////////////////////////////////////////////////////

function listObjDragBoundary(id, sGroup) {
	if (id) {
		this.init(id, sGroup);
		this.isBoundary = true;
	}
}

if(YAHOO.util.DDTarget) listObjDragBoundary.prototype = new YAHOO.util.DDTarget();


/**
 * creates an input to filter a list by column
 * 
 * @version 1.0
 */
listFilter = function(span) {      
                                  
      var cell = span.parentNode;
      var cellWidth = cell.offsetWidth - 4;
      
      span.style.display = 'none';
            
      for (var j=0;j<cell.parentNode.childNodes.length;j++) { 
            if(cell.parentNode.childNodes[j] == cell) break;
      }
      
      var value = (typeof(cell.filterValue) != 'undefined') ? cell.filterValue : '';
      
      var att = new Object();
      att['id']   = 'filter';
      att['type'] = 'text';                     
      att['name'] = 'filterCol';
      att['class'] = 'text filter';
      att['onKeyup'] = 'listFilterDo(this, ' + j + ')';  
      att['onBlur'] = 'listFilterRemove(this, ' + j + ')';
      att['style'] = 'width: ' + cellWidth + 'px;';
      att['value'] = value;
      
      var input = new domMan('input', att, cell); 
      
      input.node.focus();                                     
}


/**
 * creates an filter through the whole table by a className
 * 
 * @version 1.0
 */
listFilterTable = function(span, css) {      
                                  
      var table = span.parentNode;
      
      while(table.nodeName != 'TABLE') {
            table = table.parentNode;
      }
      
      if(typeof(table.filter) != 'undefined') table.filter = (table.filter == css) ? '' : css;      
      else table.filter = css;    
      
      
      listFilterDo(table, 0);
      
                                            
}

listFilterRemove = function(input, cellId) {
            var inputNode = new domMan(document.getElementById(input.id));
                                    
            inputNode.node.parentNode.childNodes[0].style.display = 'inline';
            
            inputNode.remove();
}

/**
 * filters a list by an input value
 * 
 * @version 1.0
 */
listFilterDo = function(input, cellId) {

      if(input.nodeName != 'TABLE') {

            var inputNode = new domMan(document.getElementById(input.id));
            
            var value = input.value.toLowerCase();
            
            inputNode.node.parentNode.filterValue = value;
           
            var table = inputNode.node.parentNode;
            while(table.nodeName != 'TABLE') {
                  table = table.parentNode;
            }

      } else {
            var table = input;
            cellId = 0;
            var value = '';
      }        
                                     
      var tableFilter = (typeof(table.filter) != 'undefined') ? table.filter : '';                           
                           
      var tri = 0;
      
      for (var j=0;j<table.childNodes.length;j++) { 
            
            //get the table body                       
            if(table.childNodes[j].nodeName == "TBODY") {           
                  //loop through the rows
                  for (var k=0;k<table.childNodes[j].childNodes.length;k++) {            
                        var item = table.childNodes[j].childNodes[k];
                        
                        if(item.nodeName == "TR") { 
                              //remove the highlighting on the rows
                              item.className = item.className.replace(/even/, '');
                              item.style.display = '';
                                              
                              //this row has the searched value
                              if(item.childNodes[cellId].innerHTML.toLowerCase().indexOf(value) != -1 && item.className.indexOf(tableFilter) != -1) {
                                    item.className = (tri%2 == 0) ? item.className + ' even' : item.className;
                                    tri++;      
                              }
                              else
                              {
                                    item.style.display = 'none';                                          
                              }
                        }
                  }
            }			
      }            
} 
/* */
moduleCampsSignUpKidsInit = function() {
      var input = document.getElementsByName('camperID')[0];
      
      var value = (input.value == '') ? 'manual' : 'id';
      
      var check = document.getElementsByName('signUpType');
      
      for(var i = 0; i < check.length; i++) {
            if(check[i].value == value) {
                  check[i].checked = true;
                  moduleCampsSignUpKidsCheck(check[i]);
            }
      }   
}
      
moduleCampsSignUpKidsCheck = function(checkbox) {
     
      var idInputs = new Array('camperID');      
      var manualInputs = new Array('generateCamperId', 'firstName', 'name', 'birthday', 'school', 'clubs', 'sports', 'gender', 'allergies', 'drugs', 'meat', 'vegetarian', 'guardianFirstName', 'guardianName', 'street', 'zip', 'city', 'email', 'phone', 'phoneDaily', 'mobile');
      
      var requiredInputs = new Array('camperID', 'firstName', 'name', 'birthday', 'gender', 'guardianFirstName', 'guardianName', 'street', 'zip', 'city', 'email');
      
      for(var i = 0; i < idInputs.length; i++) {
            var input = document.getElementsByName(idInputs[i])[0];
            input.parentNode.style.display = 'none';
            input.className = input.className.replace(/required/, '');
			input.disabled = true;    
      }     
      
      for(var i = 0; i < manualInputs.length; i++) {
            var input = document.getElementsByName(manualInputs[i])[0];
            if(typeof(input) != 'undefined') {	
	            input.parentNode.style.display = 'none'; 
	            input.className = input.className.replace(/required/, '');	
				input.disabled = true;		
		}   
      }

	var fieldSets = new Array('camperFieldset', 'infoFieldset', 'guardianFieldset');

      switch(checkbox.value) {
            case 'id':
                  var inputs = idInputs;
	
			for(var i = 0; i < fieldSets.length; i++) {
				var panel = document.getElementById(fieldSets[i]);
				if(panel != null) panel.style.display = 'none';
			}			
			                  
            break;
            
            case 'manual':
                  var inputs = manualInputs;
      			
			for(var i = 0; i < fieldSets.length; i++) {
				var panel = document.getElementById(fieldSets[i]);
				if(panel != null) panel.style.display = '';
			}          
                  
            break;            
      }      

      for(var i = 0; i < inputs.length; i++) {
            var input = document.getElementsByName(inputs[i])[0];
            if(typeof(input) != 'undefined') {
            	input.disabled = false;
	            input.parentNode.style.display = '';
	            if(requiredInputs.contains(inputs[i])) input.className = input.className + ' required';
            }
      }      
}

moduleCampsContestName = function(select) {
      document.getElementsByName('name')[0].value = select.options[select.selectedIndex].text;
}
  

moduleShowTerms = function() {
      var terms = document.getElementById('termsLong');
            
      terms.style.display = (terms.style.display == 'none') ? '' : 'none';      	
}  
