/* 	*******************************
	Allgemeine Funktionen 
	******************************* */
function findPosTop(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return curtop;
}

function makehidden(id){
	document.getElementById(id).style.display = 'none';
}
	
function makevisible(id){
	document.getElementById(id).style.display = 'block';
}

function box_change(id) {
	var currentStatus;
	currentStatus = document.getElementById(id).style.display;
	if (currentStatus == 'none') {
		makevisible(id);
		setCookie(id, 'block', '365');
	} else {
		makehidden(id);
		setCookie(id, 'none', '365');
	}
}

function box_check(id) {
	//alert(getCookie(id));
	if (getCookie(id) != '') {
		document.getElementById(id).style.display = getCookie(id);
	}
}

function aktuellezeit() {
		var jetzt = new Date();
    	var tag = jetzt.getDate();
    	var monat = jetzt.getMonth() + 1;
    	var jahr = jetzt.getYear();
    	var stunden = jetzt.getHours();
    	var minuten = jetzt.getMinutes();
    	var sekunden = jetzt.getSeconds();
		return 	tag + '.' + monat + '.' + jahr + ' ' + stunden + ':' + minuten + ':' + sekunden
}

function GetXmlHttpObject(handler) { 
	var objXmlHttp=null;

	if (navigator.userAgent.indexOf("Opera")>=0) {
		alert("This example doesn't work in Opera");
		return;
	}
	if (navigator.userAgent.indexOf("MSIE")>=0) { 
		var strName="Msxml2.XMLHTTP";
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0) {
			strName="Microsoft.XMLHTTP";
		} 
		try { 
			objXmlHttp=new ActiveXObject(strName);
			objXmlHttp.onreadystatechange=handler;
			return objXmlHttp;
		} 
		catch(e) { 
			alert("Error. Scripting for ActiveX might be disabled");
			return; 
		} 
	} 

	if (navigator.userAgent.indexOf("Mozilla")>=0) {
		objXmlHttp=new XMLHttpRequest();
		objXmlHttp.onload=handler;
		objXmlHttp.onerror=handler; 
		return objXmlHttp;
	}
} 


/* 	*******************************
	Mailbox Funktionen 
	******************************* */
function openMSG(msgID) {
	var msgURL = '/_mail/readmsg.asp?msgid=' + msgID;
	msgWin = window.open(msgURL, "Nachricht", "width=640,height=500,left=100,top=200,resizable=yes,scrollbars=yes");
  	msgWin.focus();
}


/* 	*******************************
	Chat Funktionen 
	******************************* */

var chatscroll = new Object();
	chatscroll.Pane = function(scrollContainerId)
    {
        this.bottomThreshold = 25;
        this.scrollContainerId = scrollContainerId;
    }

	chatscroll.Pane.prototype.activeScroll = function()
    {
        var scrollDiv = document.getElementById(this.scrollContainerId);
        var currentHeight = 0;
        
        if (scrollDiv.scrollHeight > 0)
            currentHeight = scrollDiv.scrollHeight;
        else 
            if (objDiv.offsetHeight > 0)
                currentHeight = scrollDiv.offsetHeight;

        if (currentHeight - scrollDiv.scrollTop - ((scrollDiv.style.pixelHeight) ? scrollDiv.style.pixelHeight : scrollDiv.offsetHeight) < this.bottomThreshold)
            scrollDiv.scrollTop = currentHeight;

        scrollDiv = null;
    }
	
/* 	*******************************
	Cookie Funktionen 
	******************************* */
function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name) {
	if (document.cookie.length>0) {
		c_start=document.cookie.indexOf(c_name + "=");
  		if (c_start!=-1) { 
	    	c_start=c_start + c_name.length+1;
    		c_end=document.cookie.indexOf(";",c_start);
    		
			if (c_end==-1) c_end=document.cookie.length
    			return unescape(document.cookie.substring(c_start,c_end));
    		} 
  		}
	return "";
}




// Color Picker Script from Flooble.com
// For more information, visit 
//	http://www.flooble.com/scripts/colorpicker.php
// Copyright 2003 Animus Pactum Consulting inc.
// You may use and distribute this code freely, as long as
// you keep this copyright notice and the link to flooble.com
// if you chose to remove them, you must link to the page
// listed above from every web page where you use the color
// picker code.
//---------------------------------------------------------
var perline = 9;
var divSet = false;
var curId;
var colorLevels = Array('0', '3', '6', '9', 'C', 'F');
var colorArray = Array();
var ie = false;
var nocolor = 'none';
if (document.all) { ie = true; nocolor = ''; }
function getObj(id) {
if (ie) { return document.all[id]; } 
else {	return document.getElementById(id);	}
}

function addColor(r, g, b) {
	var red = colorLevels[r];
	var green = colorLevels[g];
	var blue = colorLevels[b];
	addColorValue(red, green, blue);
}

function addColorValue(r, g, b) {
	colorArray[colorArray.length] = '#' + r + r + g + g + b + b;
}

function setColor(color) {
	var link = getObj(curId);
	var field = getObj(curId + 'field');
	var picker = getObj('colorpicker');
	field.value = color;
	if (color == '') {
 	link.style.background = nocolor;
 	link.style.color = nocolor;
 	color = nocolor;
	} else {
 	link.style.background = color;
 	link.style.color = color;
}
	picker.style.display = 'none';
eval(getObj(curId + 'field').title);
}
   
function setDiv() {     
	if (!document.createElement) { return; }
   var elemDiv = document.createElement('div');
   if (typeof(elemDiv.innerHTML) != 'string') { return; }
   genColors();
   elemDiv.id = 'colorpicker';
elemDiv.style.position = 'absolute';
   elemDiv.style.display = 'none';
   elemDiv.style.border = '#000000 1px solid';
   elemDiv.style.background = '#FFFFFF';
   elemDiv.innerHTML = '' 
   	+ getColorTable();

   document.body.appendChild(elemDiv);
   divSet = true;
}

function pickColor(id) {
	if (!divSet) { setDiv(); }
	var picker = getObj('colorpicker');     	
if (id == curId && picker.style.display == 'block') {
picker.style.display = 'none';
return;
}
	curId = id;
	var thelink = getObj(id);
	picker.style.top = getAbsoluteOffsetTop(thelink) + 20;
	picker.style.left = getAbsoluteOffsetLeft(thelink);     
picker.style.display = 'block';
}

function genColors() {
   addColorValue('0','0','0');
   addColorValue('3','3','3');
   addColorValue('6','6','6');
   addColorValue('8','8','8');
   addColorValue('9','9','9');                
   addColorValue('A','A','A');
   addColorValue('C','C','C');
   addColorValue('E','E','E');
   addColorValue('F','F','F');                                

   for (a = 1; a < colorLevels.length; a++)
addColor(0,0,a);
   for (a = 1; a < colorLevels.length - 1; a++)
addColor(a,a,5);

   for (a = 1; a < colorLevels.length; a++)
addColor(0,a,0);
   for (a = 1; a < colorLevels.length - 1; a++)
addColor(a,5,a);

   for (a = 1; a < colorLevels.length; a++)
addColor(a,0,0);
   for (a = 1; a < colorLevels.length - 1; a++)
addColor(5,a,a);


   for (a = 1; a < colorLevels.length; a++)
addColor(a,a,0);
   for (a = 1; a < colorLevels.length - 1; a++)
addColor(5,5,a);

   for (a = 1; a < colorLevels.length; a++)
addColor(0,a,a);
   for (a = 1; a < colorLevels.length - 1; a++)
addColor(a,5,5);

   for (a = 1; a < colorLevels.length; a++)
addColor(a,0,a);			
   for (a = 1; a < colorLevels.length - 1; a++)
addColor(5,a,5);

  	return colorArray;
}
function getColorTable() {
    var colors = colorArray;
 	 var tableCode = '';
    tableCode += '<table border="0" cellspacing="1" cellpadding="1">';
    for (i = 0; i < colors.length; i++) {
         if (i % perline == 0) { tableCode += '<tr>'; }
         tableCode += '<td bgcolor="#000000"><a style="outline: 1px solid #000000; color: ' 
         	  + colors[i] + '; background: ' + colors[i] + ';font-size: 10px;" title="' 
         	  + colors[i] + '" href="javascript:setColor(\'' + colors[i] + '\');">&nbsp;&nbsp;&nbsp;</a></td>';
         if (i % perline == perline - 1) { tableCode += '</tr>'; }
    }
    if (i % perline != 0) { tableCode += '</tr>'; }
    tableCode += '</table>';
 	 return tableCode;
}
function relateColor(id, color) {
	var link = getObj(id);
	if (color == '') {
 	link.style.background = nocolor;
 	link.style.color = nocolor;
 	color = nocolor;
	} else {
 	link.style.background = color;
 	link.style.color = color;
}
eval(getObj(id + 'field').title);
}
function getAbsoluteOffsetTop(obj) {
	var top = obj.offsetTop;
	var parent = obj.offsetParent;
	while (parent != document.body) {
		top += parent.offsetTop;
		parent = parent.offsetParent;
	}
	return top;
}

function getAbsoluteOffsetLeft(obj) {
	var left = obj.offsetLeft;
	var parent = obj.offsetParent;
	while (parent != document.body) {
		left += parent.offsetLeft;
		parent = parent.offsetParent;
	}
	return left;
}


