if(document.getElementById) {
	onContent(function() {
		document.getElementsByTagName('body')[0].className = 'js';
		addTggleHiddenItemContent();
		layoutControler();
	});
}

function layoutControler() {
	var n;
	var m;
	if(document.getElementById) {
		if(document.getElementById("col-left")){
			n = document.getElementById("col-left");
		}
		if(document.getElementById("col-right")){
			m = document.getElementById("col-right");
		}
		
		if(n != null) {
			var parentHeight = n.parentNode.offsetHeight;
			n.style.height = parentHeight+ "px";
			m.style.height=  parentHeight+ "px";
			
			
		}
	}
}


ImageRotator = function(img, imgs, largeDir) {

	this.img = img;
	this.imgs = imgs;
	this.actImg = 0;
	this.totalImgs = this.imgs.length;
	this.largeDir = largeDir;
	
	this.next = function() {
		this.actImg = (this.actImg >= (this.totalImgs - 1)) ? 0: this.actImg + 1;
		this.setSrc();
		return false;
	}

	this.prev = function() {
		this.actImg = (this.actImg == 0) ? (this.totalImgs - 1): this.actImg - 1;
		this.setSrc();
		return false;
	}
	
	this.open = function() {
		openPic('/picviewer.php?bild=' + this.largeDir, 'img', true);
		return false;
	}
	
	this.setSrc = function() {
		this.img.src = this.imgs[this.actImg];
	}
}


function addTggleHiddenItemContent() {
	var items = document.getElementsBySelector('div.item-content-collapse');
	for(var i = 0; i < items.length; i++) {
		var h = items[i].getElementsByTagName('h4')[0];
		var d = h.parentNode.getElementsByTagName('div');
		var c = false;
		for(var y = 0; y < d.length; y++)  {
			if(d[y].className.indexOf('hidden') > -1) {
				c = true;
			}
		}
		if(c) {
			h.title = 'Details ein-/ausblenden';
			h.style.cursor = 'pointer';
			h.onclick = function() {
				var d = this.parentNode.parentNode.getElementsByTagName('div');
				var s = null;
				for(var i = 0; i < d.length; i++)  {
					if(d[i].className.indexOf('hidden') > -1) {
						s = d[i].style.display = (d[i].style.display != 'block') ? 'block': 'none';
					}
				}
				if(s == 'block') {
					this.className = 'open';
				} else {
					this.className = '';
				}
			}
		}
	}
}


// 	Funktion oeffent Browser Fenster mit vergroesserter Ansicht des Bildes (aufrufen mit 'url' und 'name')
function openPic(url,name, menu) {
	if(menu) { 
		if ((navigator.appName.indexOf("Explorer") != -1) && (navigator.platform.indexOf("Mac") != -1)) {
			window.open(url, name,'height=330,width=400,locationbar=no,menubar=no,resizable=no,status=yes');
		} else {
			window.open(url, name,'height=380,width=450,locationbar=no,menubar=no,resizable=no,status=yes');
		}
	} else { 
		if ((navigator.appName.indexOf("Explorer") != -1) && (navigator.platform.indexOf("Mac") != -1)) {
			window.open(url, name,'height=300,width=400,locationbar=no,menubar=no,resizable=no,status=yes');
		} else {
			window.open(url, name,'height=350,width=450,locationbar=no,menubar=no,resizable=no,status=yes');
		}
	}
}

// 	Funktion oeffent Browser Fenster mit vergroesserter Ansicht des Bildes (aufrufen mit 'url' und 'name')
function openPlan(url,name,hight,width) {
    if ((navigator.appName.indexOf("Explorer") != -1) && (navigator.platform.indexOf("Mac") != -1)) {
		optStr = 'height=' + hight + ',width=' + width + ',locationbar=no,menubar=no,resizable=no,status=yes';
		window.open(url, name, optStr);
	} else {
		optStr = 'height=' + hight + ',width=' + width + ',locationbar=no,menubar=no,resizable=no,status=yes';
		window.open(url, name, optStr);
   	}
}


/*
   The following code is Copyright (C) Simon Willison 2004.
   Version 0.4 - Simon Willison, March 25th 2003
*/
function getAllChildren(e) {
  // Returns all children of element. Workaround required for IE5/Windows. Ugh.
  return e.all ? e.all : e.getElementsByTagName('*');
}

document.getElementsBySelector = function(selector) {
  // Attempt to fail gracefully in lesser browsers
  if (!document.getElementsByTagName) {
    return new Array();
  }
  // Split selector in to tokens
  var tokens = selector.split(' ');
  var currentContext = new Array(document);
  for (var i = 0; i < tokens.length; i++) {
    token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
    if (token.indexOf('#') > -1) {
      // Token is an ID selector
      var bits = token.split('#');
      var tagName = bits[0];
      var id = bits[1];
      var element = document.getElementById(id);
     if(element == null) {
     	return new Array();
     }
      if (tagName && element.nodeName.toLowerCase() != tagName) {
        // tag with that ID not found, return false
        return new Array();
      }
      // Set currentContext to contain just this element
      currentContext = new Array(element);
      continue; // Skip to next token
    }
    if (token.indexOf('.') > -1) {
      // Token contains a class selector
      var bits = token.split('.');
      var tagName = bits[0];
      var className = bits[1];
      if (!tagName) {
        tagName = '*';
      }
      // Get elements matching tag, filter them for class selector
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        if (tagName == '*') {
            elements = getAllChildren(currentContext[h]);
        } else {
            elements = currentContext[h].getElementsByTagName(tagName);
        }
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      continue; // Skip to next token
    }
    // Code to deal with attribute selectors
    if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
      var tagName = RegExp.$1;
      var attrName = RegExp.$2;
      var attrOperator = RegExp.$3;
      var attrValue = RegExp.$4;
      if (!tagName) {
        tagName = '*';
      }
      // Grab all of the tagName elements within current context
      var found = new Array;
      var foundCount = 0;
      for (var h = 0; h < currentContext.length; h++) {
        var elements;
        if (tagName == '*') {
            elements = getAllChildren(currentContext[h]);
        } else {
            elements = currentContext[h].getElementsByTagName(tagName);
        }
        for (var j = 0; j < elements.length; j++) {
          found[foundCount++] = elements[j];
        }
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      var checkFunction; // This function will be used to filter the elements
      switch (attrOperator) {
        case '=': // Equality
          checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
          break;
        case '~': // Match one of space seperated words 
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
          break;
        case '|': // Match start with value followed by optional hyphen
          checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
          break;
        case '^': // Match starts with value
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
          break;
        case '$': // Match ends with value - fails with "Warning" in Opera 7
          checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
          break;
        case '*': // Match ends with value
          checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
          break;
        default :
          // Just test for existence of attribute
          checkFunction = function(e) { return e.getAttribute(attrName); };
      }
      currentContext = new Array;
      var currentContextIndex = 0;
      for (var k = 0; k < found.length; k++) {
        if (checkFunction(found[k])) {
          currentContext[currentContextIndex++] = found[k];
        }
      }
      // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
      continue; // Skip to next token
    }
    // If we get here, token is JUST an element (not a class or ID selector)
    tagName = token;
    var found = new Array;
    var foundCount = 0;
    for (var h = 0; h < currentContext.length; h++) {
      var elements = currentContext[h].getElementsByTagName(tagName);
      for (var j = 0; j < elements.length; j++) {
        found[foundCount++] = elements[j];
      }
    }
    currentContext = found;
  }
  return currentContext;
}

function onContent(f){//(C)webreflection.blogspot.com
var a=onContent,b=navigator.userAgent,d=document,w=window,c="onContent",e="addEventListener",o="opera",r="readyState",
s="<scr".concat("ipt defer src='//:' on",r,"change='if(this.",r,"==\"complete\"){this.parentNode.removeChild(this);",c,".",c,"()}'></scr","ipt>");
a[c]=(function(o){return function(){a[c]=function(){};for(a=arguments.callee;!a.done;a.done=1)f(o?o():o)}})(a[c]);
if(d[e])d[e]("DOMContentLoaded",a[c],false);
if(/WebKit|Khtml/i.test(b)||(w[o]&&parseInt(w[o].version())<9))(function(){/loaded|complete/.test(d[r])?a[c]():setTimeout(arguments.callee,1)})();
else if(/MSIE/i.test(b))d.write(s);
};
