/**
 * 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="/imageCache/17/" class="icon" alt="Bearbeiten" /> Bearbeiten';
      this.itemMenuview = '<img src="/imageCache/23/" class="icon" alt="Ansehen" /> Ansehen';
      this.itemMenudelete = '<img src="/imageCache/22/" class="icon" alt="Löschen" /> Löschen';      
      this.itemMenunew = '<img src="/imageCache/1/" class="icon" alt="Neuen Inhalt erzeugen" /> Neu erstellen';            
      this.itemMenusub = '<img src="/imageCache/71/" class="icon" alt="Neuer Unterordner" /> Neuer Unterordner';        
      this.itemMenumodule = '<img src="/imageCache/19/" class="icon" alt="Ordner öffnen" /> Ordner öffnen'; 

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

      this.parameterIcon = '<img src="/imageCache/25/" class="icon" alt="presences" />';      
      
      
      this.userRemove = '<img src="/imageCache/22/" class="icon" alt="Löschen" />';
      this.name = 'Name';
                  
      this.extractArchive = 'Archiv in diesen Ordner entpacken';                  
                  
      this.fileBrowse = '<img src="/imageCache/7/" class="icon" alt="Datei Selector" />';
      
      this.tableFilter = '<img src="/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="/imageCache/41/" class="icon" alt="Schließen" />';
      
      this.uploadFiles = '{lang.uploadFiles}';
      
}




/**
 * Handles global vars
 *
 */
 
var conWebDir = '/';
var conWebPresDir = '/';
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++;
            }
      }           
} 
/*
 */
initParam.push('listSimpleObj');

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

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


listSimpleObj.prototype.initList = function(table) {                
        
      listSimpleFilterDo(table, 0);
                                          
}


/**
 * filters a list by an input value
 * 
 * @version 1.0
 */
listSimpleFilterDo = 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';                                          
                              }
                        }
                  }
            }			
      }            
} 
/*
 */
initParam.push('campOverviewObj');
var conCampOverviewObj = new Array();

/**
 * Creates a gallery with images from an array of links
 *
 */
campOverviewObj = function() {
      this.init();
}

/**
 * Draw each gallery on a page (possible more than one)
 *
 */
campOverviewObj.prototype.init = function() {
      this.loadData();
      this.div = document.getElementById('conCampOverview');

      var types = new Array('Term', 'Type');
      type = (types.contains(conCampOverviewInitial)) ? conCampOverviewInitial : 'Type';
      
      eval('this.create' + type + 'Overview()');
}


campOverviewObj.prototype.loadData = function() {
      this.data = conCampOverviewObj;
      this.camps = new Object();
      
      this.years = new Array();
      this.types = new Array();
      this.typesReal = new Array();
      this.terms = new Array();
      
      this.campType = new Object();
      this.termType = new Object();
            
      for(var i = 0; i < this.data.length; i++) {                                
            
            if(!this.years.contains(this.data[i][6])) {
                  this.years.push(this.data[i][6]); 
                  this.campType[this.data[i][6]] = new Object();
                  this.termType[this.data[i][6]] = new Object();                     
            }
      }
      
      for(var i = 0; i < this.data.length; i++) {            
            var campID = this.data[i][0];
            this.camps[campID] = new Object();
                                                                                                                  
            this.camps[campID]['campID'] = this.data[i][0];
            this.camps[campID]['name'] = this.data[i][1];
            this.camps[campID]['type'] = this.data[i][2];
            this.camps[campID]['start'] = this.data[i][3];
            this.camps[campID]['end'] = this.data[i][4];
            this.camps[campID]['term'] = this.data[i][5];
            this.camps[campID]['year'] = this.data[i][6];  
            this.camps[campID]['typeReal'] = this.data[i][7];   
                  
            if(!this.types.contains(this.data[i][2])) {
                  this.types.push(this.data[i][2]);
                  for(var j = 0; j < this.years.length; j++) {
                        this.campType[this.years[j]][this.data[i][2]] = new Array();
                  }
                        
            } 
      
            if(!this.terms.contains(this.data[i][5])) {
                  this.terms.push(this.data[i][5]);
                  for(var j = 0; j < this.years.length; j++) {
                        this.termType[this.years[j]][this.data[i][5]] = new Array();
                  }
                        
            }
      
            //array in form of [2007][basic]
            this.campType[this.data[i][6]][this.data[i][2]].push(campID);      
            
            //array in form of [2007][Winter]
            this.termType[this.data[i][6]][this.data[i][5]].push(campID);           
      }       
      
} 

campOverviewObj.prototype.createInner = function() {
      var inner = document.getElementById('conCampOverviewInner');

      if(inner != null) {
            var innerDom = new domMan(inner);
            innerDom.remove();
      }
      
      var att = new Object();
      att['id'] = 'conCampOverviewInner'; 
       
      this.innerNode = new domMan('div', att, this.div); 
}

campOverviewObj.prototype.createHeader = function(value) {
      var att = new Object();
      att['innerHTML'] = value;
             
      var header = new domMan('h2', att, this.innerNode.node);          
}                                        

campOverviewObj.prototype.createTable = function(value, icon) {
      var att = new Object();      
      this.tableNode = new domMan('table', att, this.innerNode.node); 
      
      var id = this.year + '_' + value;
      var img = '<img src="/imageCache/campOverview' + icon + '/" />';
      this.tableNode.node.outerHTML = '<table id="' + id + '" class="listRoot" cellspacing="0" cellpadding="2"><thead><tr class="listHeader"><th class="listname">' + img + '</th><th colspan="4" class="listname">' + value + '</th></tr></thead></table>'
      
      //needed browser specific workaround because one doesn't support innerHTML on tables, the other not outerHTML
      if(!document.getElementById(id)) {
            this.tableNode.node.innerHTML = '<thead><tr class="listHeader"><th class="listname">' + img + '</th><th colspan="4" class="listname">' + value + '</th></tr></thead>';        
            this.tableNode.node.id = id;
            this.tableNode.node.className = 'listRoot';
      }   

      tableNode = new domMan(document.getElementById(id));

      var att = new Object();     
      att['id'] = id + 'Body';    
      this.tbodyNode = new domMan('tbody', att, tableNode.node);  
         
}
                                      
campOverviewObj.prototype.createCampRow = function(campID, type) {
            
      var camp = this.camps[campID];
      
      var dates = camp['start'].split('.');
                              
      var today = new Date();
      var campDate = new Date(dates[2], dates[1] - 1, dates[0]);
                               
      var att = new Object();
      att['onClick'] = ((campDate.getTime() - today.getTime()) < 0) ? 'location.href = "http://camps.kispo.de/' + campID + '/news/";' : 'location.href = "/' + campID + '/";';
      //att['onClick'] = 'location.href = "/' + campID + '/";';
      rowNode = new domMan('tr', att, false); 
      
      
      //Row Icon
      var att = new Object();        
      att['innerHTML'] = '';      
      cellNode = new domMan('td', att, rowNode.node);       
      
      var icon = (type == 'term') ? camp['typeReal'] : camp['term'];    
      
      var att = new Object();        
      att['src'] = '/imageCache/campOverview' + icon + '/'; 
      imgNode = new domMan('img', att, cellNode.node);      
      
      //remember to change colspan of head when adding new fields
      var rowOrder = new Array('campID', 'name', 'start', 'end');
      
      for(var i = 0; i < rowOrder.length; i++) {
            var att = new Object();        
            att['innerHTML'] = camp[rowOrder[i]];
            
            cellNode = new domMan('td', att, rowNode.node);      
      }

      rowNode.append(this.tbodyNode.node);                      
}

campOverviewObj.prototype.createTypeOverview = function() {
      
      this.createInner();
      
      for(var year in this.campType) {
            this.year = year;
            this.createHeader(year);
            
            for(var type in this.campType[year]) {
            
                  if(this.campType[year][type].length > 0) {
                        this.createTable(type, this.camps[this.campType[year][type][0]]['typeReal']);
                  
                        for(var i = 0; i < this.campType[year][type].length; i++) {
                              this.createCampRow(this.campType[year][type][i], 'type');
                        }
                  
                        var id = year + '_' + type;
                  
                        listSimpleObjProt.initList(document.getElementById(id));                         
                  }                      
            }
      }                     
}    

campOverviewObj.prototype.createTermOverview = function() {
      
      this.createInner();
      
      for(var year in this.campType) {
            this.year = year;
            this.createHeader(year);
            
            for(var type in this.termType[year]) {
            
                  if(this.termType[year][type].length > 0) {
                        this.createTable(type, this.camps[this.termType[year][type][0]]['term']);
                  
                        for(var i = 0; i < this.termType[year][type].length; i++) {
                              this.createCampRow(this.termType[year][type][i], 'term');
                        }
                  
                        var id = year + '_' + type;
                  
                        listSimpleObjProt.initList(document.getElementById(id));                         
                  }                      
            }
      }                     
}

/* */
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';      	
}  
