﻿if (document.all) defaultStep=6; else defaultStep=3 ;
step=defaultStep;
timer = 0;
var tinyMCE;
var gImage = false;

function scrollDivDown(id,n){
	if (n) stepN = n*step; else stepN = step;
	document.getElementById(id).scrollTop+=stepN 
	if (!n) timer=setTimeout("scrollDivDown('"+id+"')",10) 
} 

function scrollDivUp(id,n){ 
	if (n) stepN = n*step; else stepN = step;
	document.getElementById(id).scrollTop-=stepN 
	if (!n) timer=setTimeout("scrollDivUp('"+id+"')",10) 
} 

var Dom = {
  get: function(el) {
    if (typeof el === 'string') return document.getElementById(el);
    else return el;
  },
  add: function(el, dest) {
    var el = this.get(el);
    var dest = this.get(dest);
    dest.appendChild(el);
  },
  remove: function(el) {
    var el = this.get(el);
    el.parentNode.removeChild(el);
  }
};

function setOpacity(obj,opacity) {
	var object = obj.style; 
	object.opacity = (opacity / 10);
	object.MozOpacity = (opacity / 10);
	object.KhtmlOpacity = (opacity / 10);
	object.filter = "alpha(opacity=" + opacity*10 + ")";
}

// onLoad...
// onLoad...
// window.onunload=chPix; 

function init() {
	if (gImage == true) {t=document.getElementById('gImage'); t.style.filter = 'alpha(opacity = 0)';t.style['opacity'] = 0;	t.style['-moz-opacity'] = 0;}
	// if(document.getElementById('gImage')) document.getElementById('gImage').style.visibility = 'hidden';// setOpacity(document.getElementById('gImage'),0);
	if (arguments.callee.done) return;
	arguments.callee.done = true;
	
	// kill the timer for Safari
	if (_timer) {
		clearInterval(_timer);
		_timer = null;
	}
	
	// start do something
	if (tinyMCE) return;
	
	if ((browser.isIE55 || browser.isIE6x) && browser.isWin32) {
		// document.getElementById('navigation').style.filter = 'alpha(opacity=85)';
		// if (document.getElementById('content')) document.getElementById('content').style.filter = 'alpha(opacity=85)';
		// if (document.getElementById('sidebar')) document.getElementById('sidebar').style.filter = 'alpha(opacity=85)';
	}
	
	// Makes page look like it appeared after startpage every time a main-menu changed
	// Vorabmanipulation... geht auch ohne Cookies, aber...
	// alert('oldNav='+getCookie('oldNav')+'\nstart='+getCookie('start')+'\nsidebar='+getCookie('sidebar'));
	//////// if (sessvars.oldNav != getURLVar('nav')) sessvars.start ='start';
	// if (sessvars.start != 'start') showSidebar();
	// 1ste und 2te Spalte
	if (window.location.search == '' || window.location.search == '?' || window.location.search == '?lang=en') {
		sessvars.start = 'start';
		document.getElementById('navigation').style.display = 'none';
		document.getElementById('contentshader').style.display = 'none';
		if (document.getElementById('workmenu')) document.getElementById('workmenu').style.display = 'none';
		document.getElementById('navigation').style.overflow = 'hidden';
		t1 = new Tween(document.getElementById('navigation').style,'width',Tween.strongEaseInOut,0,170,1.2,'px');
		t1.onMotionStarted = function(){document.getElementById('navigation').style.display = '';}
		t1.onMotionFinished = function(){document.getElementById('navigation').style.width = '196px';}
		setTimeout('t1.start()',1650);
	} else if (sessvars.start == 'start' && document.getElementById('content')) {
		sessvars.start = '';
		document.getElementById('contentshader').style.overflow = 'hidden';
		document.getElementById('contentshader').style.display = 'none';
		document.getElementById('content').style.display = 'none';
		document.getElementById('content').style.overflow = 'hidden';
		if (document.getElementById('workmenu')) document.getElementById('workmenu').style.display = 'none';
		// document.getElementById('content').style.display = 'none';
		t1 = new Tween(document.getElementById('contentshader').style,'width',Tween.strongEaseInOut,1,(browser.isIE)?436:436,0.8,'px');
		t2 = new Tween(document.getElementById('content').style,'height',Tween.strongEaseInOut,1,(browser.isIE)?507:507,0.8,'px');
		if (document.getElementById('workmenu')) t3 = new Tween(document.getElementById('workmenu').style,'height',Tween.strongEaseInOut,1,(browser.isIE)?404:404,0.8,'px');
		t1.onMotionStarted = function() {
			if(document.getElementById('scrollbar')) document.getElementById('scrollbar').style.display = 'none';
			document.getElementById('contentshader').style.display = '';
		}
		t2.onMotionStarted = function() {
			// document.getElementById('content').style.height = '10px';
			document.getElementById('content').style.display = '';
		}
		t2.onMotionFinished = function() {
			document.getElementById('content').style.overflow = 'auto';
		}
		if (document.getElementById('workmenu')) t3.onMotionStarted = function(){
			if (document.getElementById('workmenu')) document.getElementById('workmenu').style.overflow = 'hidden';
			if (document.getElementById('workmenu')) document.getElementById('workmenu').style.display = '';
			// t3.start();
		}
		if (document.getElementById('workmenu')) t3.onMotionFinished = function(){document.getElementById('workmenu').style.overflow = '';}
		t1.onMotionFinished = function(){
			if(document.getElementById('scrollbar')) document.getElementById('scrollbar').style.display = '';
			t2.start();
			if (document.getElementById('workmenu')) setTimeout('t3.start()',340);
		}
		t1.start();
	}
	// 3te Spalte vestecken
	
	sessvars.oldNav = getURLVar('nav');
};
var shade = function() {
	if (gImage == true) {
		document.getElementById('gImage').style.filter = 'alpha(opacity = 0)';
		shPix(document.getElementById('gImage')); 
	}
}


/* for Mozilla */
if (document.addEventListener && !/Opera/i.test(navigator.userAgent)) { //  maybe not?? => && !/Opera/i.test(navigator.userAgent)
	document.addEventListener("DOMContentLoaded", init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
	document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
	var script = document.getElementById("__ie_onload");
	script.onreadystatechange = function() {
		if (this.readyState == "complete") {
			init(); // call the onload handler
		}
	};
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
	var _timer = setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
			init(); // call the onload handler
		}
	}, 10);
}

/* for other browsers */
window.onload = init;
window.onload = shade;


function BG_Scroll() {
}

function getURLVar(urlVarName) {
	//divide the URL in half at the '?' 
	var urlHalves = String(document.location).split('?');
	var urlVarValue = '';
	if(urlHalves[1]){
		//load all the name/value pairs into an array 
		var urlVars = urlHalves[1].split('&');
		//loop over the list, and find the specified url variable 
		for(var i=0, uvl=(urlVars.length); i<=uvl; i++){
			if(urlVars[i]){
				//load the name/value pair into an array 
				var urlVarPair = urlVars[i].split('=');
				if (urlVarPair[0] && urlVarPair[0] == urlVarName) {
				//I found a variable that matches, load it's value into the return variable 
				urlVarValue = urlVarPair[1];
				}
			}
		}
	}
	return urlVarValue;   
}

function getQueryArgs(global)
{
  var args = {};
  var loc = window.location.href;
  var q = loc.indexOf("?");
  if (q==-1) return false;
  loc = loc.substring(q+1);
  var pairs = loc.split("&");
  for (var i=0; i<pairs.length;i++){
    if (global) eval(pairs[i]);
    var keyval = pairs[i].split("=");
    args[keyval[0]] = unescape(keyval[1]);
  }
  return args;
}