<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/homepages/32/d107009679/htdocs/conframe_NGO/conframe/MAIN/media.class.php</b> on line <b>231</b><br />
/**
 * 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('dom');

/**
 * 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 dom(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
 */
dom.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
 */
dom.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
 */
dom.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
 */
dom.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
 */
dom.prototype.append = function(parent) {  
      parent.appendChild(this.node);
}

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

/**
 * Handle the client side language pack
 * 
 * @version 1.0
 */
function lang() {      
      this.enterPassword = 'Please enter password';
      this.passwordCorrect = 'The password is correct';
      this.passwordFalse = 'The password is wrong';
        
      this.itemMenuedit = '{img.editIcon} Edit';
      this.itemMenuview = '{img.viewIcon} View';
      this.itemMenudelete = '{img.deleteIcon} Delete';      
      this.itemMenunew = '<img src="/imageCache/1/" class="icon" alt="New" /> Create new';            
      this.itemMenusub = '{img.subfolderIcon} New subfolder';        
      this.itemMenumodule = '{img.openfolderIcon} Open folder'; 

      /*{con.moduleCount}*/
      
      this.userIcon_w = '{img.selectWorld}';
      this.userIcon_g = '{img.moduleIcon_19}';
      this.userIcon_u = '{img.moduleIcon_5}';

      this.parameterIcon = '<img src="/imageCache/25/" class="icon" alt="Presences" />';      
      
      
      this.userRemove = '{img.deleteIcon}';
      this.name = 'Name';
                  
      this.extractArchive = 'Unzip in current folder';                  
                  
      this.fileBrowse = '<img src="/imageCache/7/" class="icon" alt="File selector" />';
      
      this.tableFilter = '<img src="/imageCache/21/" class="icon" alt="tableFilter" />';
      
      this.root = 'Root' //'Wurzel';
      
      this.requiredField = 'Fill out required field!';
      this.requiredMissing = 'Not all required fields are filled!';
      
      this.back = 'Back';
      this.forward = 'Forward';
      this.page = 'Page';    
      this.image = 'Image';
      this.of = 'of';
      this.closeImg = 'Close <img src="/imageCache/41/" class="icon" alt="Close" />';
      
}




/**
 * Handles global vars
 *
 */
 
var conWebDir = '{con.webdir}';
var conWebPresDir = '{con.webpresdir}';
var conImageDir = '{con.imagedir}';

var conUserLang = '{con.userLang}';
/*
 */
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;
      }
      
}
