/* <![CDATA[ */
var timerID = null;
var timerOn = false;
var timecount = 1000;
var what = null;
var newbrowser = true;
var check = false;
var opera = navigator.userAgent.toLowerCase().indexOf('opera') >= 0 ? true: false;
var safari = navigator.userAgent.toLowerCase().indexOf('safari') >= 0 ? true: false;
var ie7 = navigator.userAgent.toLowerCase().indexOf('msie 7') >= 0 ? true: false;
var ie6 = navigator.userAgent.toLowerCase().indexOf('msie 6') >= 0 ? true: false;
var IE = (document.all)?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
var assistentMaxFontSize = 15;
var assistentMinFontSize = 10;

document.onmousemove = getMouseXY;

var tempX = 0
var tempY = 0
var tempMWX = 0
var tempMWY = 0

function markall2() {
  if (document.Form_Liste.id.length == undefined) {
    if (document.Form_Liste.id.checked == true) {
      document.Form_Liste.id.checked = false;
    }
    else {
      document.Form_Liste.id.checked = true;
    }
  }
  else {
    for (var x = 0; x < document.Form_Liste.id.length; x++) {
      if (document.Form_Liste.id[x].checked == true) {
        document.Form_Liste.id[x].checked = false;
      }
      else {
        document.Form_Liste.id[x].checked = true;
      }
    }
  }
}
// Suchform auf standard setzen
/*function resetall() {
  for (var x = 0; x < document.Form_Suche.length; x++) {
    if ((document.Form_Suche.elements[x].type == 'text') || (document.Form_Suche.elements[x].type == 'checkbox')) {
      document.Form_Suche.elements[x].value = '';
    }
    if (document.Form_Suche.elements[x].type == 'select-one') {
      if (document.Form_Suche.elements[x].name == 'secialfield') {
        document.Form_Suche.elements[x].value = 'all';
      }
      else {
        document.Form_Suche.elements[x].value = '';
      }
    }
  }
}
*/

function MM_findObj(n, d) { //v4.01
  var p, i, x;
  if (!d) d = document;
  if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
    d = parent.frames[n.substring(p + 1)].document;
    n = n.substring(0, p);
  }
  if (! (x = d[n]) && d.all) x = d.all[n];
  for (i = 0; ! x && i < d.forms.length; i++) x = d.forms[i][n];
  for (i = 0; ! x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
  if (!x && d.getElementById) x = d.getElementById(n);
  return x;
}

function getMouseXY(e) {
  if (!e) var e = window.event;
  if (IE) { // grab the x-y pos.s if browser is IE
    //tempX = e.clientX + document.body.scrollLeft;
    //tempY = e.clientY + document.body.scrollTop;
    tempX = e.clientX + document.documentElement.scrollLeft;
    tempY = e.clientY + document.documentElement.scrollTop;

    tempMWX = e.clientX; // + document.body.scrollLeft
    tempMWY = e.clientY; // + document.body.scrollTop		    
  } else { // grab the x-y pos.s if browser is NS

    tempX = e.pageX;
    tempY = e.pageY;
    tempMWX = e.pageX;
    tempMWY = e.pageY;
  }
  if (tempX < 0) {
    tempX = 0;
  }
  if (tempY < 0) {
    tempY = 0;
  }
  return true
}

function SetDiVAtMousePos(MyDiV) {
  var i, p, v, obj
  if ((obj = MM_findObj(MyDiV)) != null) {
    //alert(tempX);
    //alert(tempY);
    obj.style.left = tempX + 'px';
    obj.style.top = tempY + 'px';
  }
}

function DiVOnOff(MyDiV, MyArt) {
  document.getElementById(MyDiV).style.visibility = MyArt;
}
// DiV Timer 
// Globalos Variablos
// ABOptionsTime
var MyDiVTimeout;

function StartDiVTimer(MyTimeOut, MyDiV) {
  if (isNaN(MyTimeOut)) MyTimeOut = 1000;
  if (MyDiVTimeout != null) {
    clearTimeout(MyDiVTimeout);
  }
  MyDiVTimeout = setTimeout("DiVOnOff('" + MyDiV + "', 'hidden')", MyTimeOut);
  //MyDiVTimeout = setTimeout("alert('asdfsd')", MyTimeOut);
}

// Stoppt den Timer, wird benutzt bei OnMouseIn um das ausblenden zu verhindern
function StopDiVTimer() {
  clearTimeout(MyDiVTimeout);
}

function ChangeDiV() {
  document.getElementById('MyCategorys').innerHTML = document.getElementById('mcg').innerHTML
  document.getElementById('mcg').innerHTML = '';
}

function ConfirmMyAction(MyURI, MyMsg) {
  var MyCheck;
  MyCheck = confirm(MyMsg);
  if (MyCheck == true) {
    document.location.href = MyURI;
  }
}
//### fügt eine class hinzu oder entfernt diese wenn vorhanden
function addRemoveClass(objID, strClass, anzahl) {
	// 3. parameter ist optional
	if (anzahl == undefined) anzahl = 0;
	// nur ausführen wenn beide parameter angegeben sind
	if (objID == '' || strClass == '') {}
	else {
		// nur einzelne objekte
		var i = 0;
		var nr = '';
		for (i=0;i<=anzahl;i++) {
		
			if (anzahl > 0) {var obj = document.getElementById(objID + i);}
			else {var obj = document.getElementById(objID);}
			
			if (obj == undefined || obj == null) continue;
			if (obj.className.search(strClass) > -1) {obj.className = obj.className.replace(strClass,'');}
			else {		
				if (obj.className == '') { obj.className = strClass;}
				else { obj.className = obj.className + ' ' + strClass;}
			}
		}
	}
}
function changeCssClass(className, styleName, styleValue) {
	var i=0, j=0;
	var cssRules = 'cssRules';
	if (document.all) {cssRules = 'rules';}
	className = '.' + className;
	for (i=0;i<document.styleSheets.length;i++) {
		for (j=0;j<document.styleSheets[i][cssRules].length;j++) {
			if (document.styleSheets[i][cssRules][j].selectorText == className) {				
				//alert(document.styleSheets[i][cssRules][j].selectorText);
				if (styleName == 'background') {
					document.styleSheets[i][cssRules][j].style.background = styleValue;
				} else if (styleName == 'font-family') {
					document.styleSheets[i][cssRules][j].style.fontFamily = styleValue;
				} else if (styleName == 'border-color') {
					document.styleSheets[i][cssRules][j].style.borderLeftColor =  styleValue;
					document.styleSheets[i][cssRules][j].style.borderRightColor =  styleValue;
					document.styleSheets[i][cssRules][j].style.borderTopColor =  styleValue;
					document.styleSheets[i][cssRules][j].style.borderBottomColor =  styleValue;
				} else if (document.styleSheets[i][cssRules][j].style[styleName]) {
					//alert(document.styleSheets[i][cssRules][j].style.cssText);
					//alert('hier');
					if (cssRules == 'rules' && styleName == 'background' && styleValue == '') {
						//alert('hier');
						document.styleSheets[i][cssRules][j].style.cssText = document.styleSheets[i][cssRules][j-1].style.cssText;
					} else {
						//alert('hier');
						document.styleSheets[i][cssRules][j].style[styleName] = styleValue;
					}
				} else {
					//alert('hier');
					if (styleName.substring(0,7) == 'border-') {
						document.styleSheets[i][cssRules][j].style.cssText =  document.styleSheets[i][cssRules][j].style.cssText + ';' + styleName + ':' + styleValue;
					}					
					if (cssRules == 'cssRules' && styleValue == '') document.styleSheets[i][cssRules][j].style.cssText =  styleName + ':' + styleValue;
					if (cssRules == 'cssRules' && styleName == 'background') document.styleSheets[i][cssRules][j].style.background =  styleValue;
					if (cssRules == 'rules' && !(styleName == 'border-color')) document.styleSheets[i][cssRules][j].style[styleName] = styleValue;
					if (styleName == 'text-align') document.styleSheets[i][cssRules][j].style.cssText = document.styleSheets[i][cssRules][j].style.cssText + ";text-align:" + styleValue;
				}
			}
		}
	}
}
function changeFontSizeNr(objID,toChangeObjID,change){
	var obj = document.getElementById(objID);
	var toChangeObj = document.getElementById(toChangeObjID);
	var objValue = Number(obj.value);
	if (change == undefined) change = 0;
	if (objValue+change < assistentMinFontSize) {objValue = assistentMinFontSize;}
	else if (objValue+change > assistentMaxFontSize) {objValue = assistentMaxFontSize;}
	obj.value = objValue + change;
	toChangeObj.style.fontSize = obj.value + 'px';
}

function showHide(objID, action, pfeil) {	
	var obj = document.getElementById(objID);
	if (obj == undefined) return false;
	if (action == undefined || action == '') action = 'toggle';
	if (pfeil == undefined || pfeil == '') pfeil = false;
	switch (action) {
		case 'toggle':
			if (obj.style.display == 'block') showHide(objID, 'hide');
			else showHide(objID, 'show');
			break;
		case 'show':
			obj.style.display = 'block';
			einAusblenden(objID, 1);
			break;
		case 'hide':
			obj.style.display = 'none';
			einAusblenden(objID, 0);
			break;
		}
	if (pfeil) togglePfeil(objID);
}
function highlight(objID) {
	addRemoveClass(objID, 'highlightLink');
}
function togglePfeil(objID) {
	if (objID == undefined || objID == '') return false;
	var obj = document.getElementById('pfeil_' + objID);
	obj.className = (obj.className == 'pfeil1')?'pfeil3':'pfeil1';
}

function initEinAusblenden() {
	var theCookie = trim(getCookieEinAusblenden().replace('spAdmMnu=',''));
	var theCookieValues = theCookie.split(',');
	var theCookieValue;
	var i;
	var action;
	for (i=0;i<theCookieValues.length-1;i++) {
		theCookieValue = theCookieValues[i].split(':');
		action = (theCookieValue[1]==0)?'hide':'show';
		showHide(theCookieValue[0],action);
		if (action=='show') highlight('link_' + theCookieValue[0]);
	}
}

function einAusblenden(objID, val) {
if(!safari) {
	var theCookie = getCookieEinAusblenden();
	var theCookieValues = theCookie.split(',');
	var theCookieValue;
	var i;
	var cookieStr;
	if (val==0) {
		cookieStr = theCookie.replace(objID + ':1', objID + ':0');
	} else {
		cookieStr = theCookie.replace(objID + ':0', objID + ':1');
	}
	document.cookie = cookieStr;
}
}

function getCookieEinAusblenden() {
	var theCookies;
	var theCookie = '-';
	var i;
	var objs;
	var cookieStr;	
	if (document.cookie) {
		theCookies = document.cookie.split(';');
		for (i=0;i<theCookies.length;i++) {
			if (theCookies[i].match(/spAdmMnu/)) theCookie = theCookies[i];			
		}
		if (theCookie == '-' || theCookie == 'spAdmMnu=') {
			cookieStr = 'spAdmMnu=';
			objs = document.getElementsByTagName('div');
			for (i=0;i<objs.length;i++) {
				if (objs[i].id.match(/lm/)) {
					cookieStr += objs[i].id + ':0,';
				}
			}
			document.cookie = cookieStr;
			theCookie = getCookieEinAusblenden();
		}
	}
	return theCookie;
}

function trim (zeichenkette) {
  // Erst führende, dann Abschließende Whitespaces entfernen
  // und das Ergebnis dieser Operationen zurückliefern
  // dann noch alle zeilenumbrüche weg und tabs
  zeichenkette = zeichenkette.replace(/\r|\n|\r\n/g, ' ')
  zeichenkette = zeichenkette.replace(/\t*/g,'');
  zeichenkette = zeichenkette.replace (/^\s+/, '').replace (/\s+$/, '');
  return zeichenkette;
}

function createTarget(t){
	window.open("", t, "width=500,height=350");
	return true;
}
function showHideAsi2Boxes(objID, action) {
	var boxStr = 'c1,c2,c3,c4,c5,c6,b1,b2,b3,b4,f1';
	var boxArr = boxStr.split(',');
	for (i = 0; i < boxArr.length; i++) {
		if (boxArr[i] != objID) {
			showHide(boxArr[i], 'hide');
		}
	}
	showHide(objID);
}
function toHexString(dec) {
	if (dec > 255) dec = 255;
	if (dec == null) dec = 999;
	if (dec < 10) dec = '00' + dec;
	if (dec < 100) dec = '0' + dec;
	if (dec == 999) dec = '000';

	var hex = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
	var h = Math.floor(dec / 16);
	var l = dec - h * 16;
	return hex[h] + hex[l];
}

function initScript() {
 if (!window.location.href.match(/masteradmin/) && !window.location.href.match(/public/)) {
	if(!safari) {initEinAusblenden();}
 }
}

window.onload = initScript;
/* ]]> */