/* ######################################################################################################
** # yellow-design
** 
**  Version: 0.1
**  Dateiversion: 16.08.2008 
    Hinweise:
    - die onload Aufrufe befinden sich am Dokumenten ende
**
*/
/*Ein und ausklappen der Mitglieder*/
function openKategorie(me){
  if(me.parentNode.className == "kategorie"){
    me.parentNode.className = "kategorieAktiv"
  }
  else{
    me.parentNode.className = "kategorie"
  }
}

/*Ein und ausklappen der Dokumenteninformation*/
function openDescription(me){
  if(me.parentNode.className == "description"){
    me.parentNode.className = "descriptionAktiv"
  }
  else{
    me.parentNode.className = "description"
  }
}

/*Passt den Inhalt auf die Höhe des Browserfensters an*/
function scaleContentHeight(){
 if( document.getElementById('portal-column-content') )
  {
    //if( parseInt(document.getElementById('portal-column-content').offsetHeight) < 360) document.getElementById('portal-column-content').style.height = 360 + 'px';
  }

  var newHeight = parseInt(document.body.clientHeight)-238;
  
  if ( newHeight > 50 ) {
    document.getElementById('portal-columns').style.height = newHeight +"px";
    //if( parseInt(document.getElementById('portal-columns').offsetHeight) < 400 ) document.getElementById('portal-columns').style.height = 400 + 'px';
  }
  if( document.getElementById('darkenContent') ){
    document.getElementById('darkenContent').style.height = parseInt(document.body.clientHeight)-168 +'px';
  }
}



/////////////////////////////////////////////////////////////////////////////////
// Library 
/////////////////////////////////////////////////////////////////////////////////

/*for Node */
/************************************************************************************************************************************************/

function insertAfter(newElement,targetElement) {
  var parent = targetElement.parentNode;
  if (parent.lastChild == targetElement) {
    parent.appendChild(newElement);
  } else {
    parent.insertBefore(newElement,targetElement.nextSibling);
  }
}

/*onload */
/************************************************************************************************************************************************/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function doRandom( value )
{
  var a = 0;
  a = Math.random();
  a *= value;
  a = Math.ceil(a);
  return a;
}
/*open Window */
/************************************************************************************************************************************************/

var LastWindowOpened = "";

function LocationPath(){
	var myLoc = location.href;
	myPath = myLoc.substring(0,myLoc.lastIndexOf(myRoot))+myRoot;
	return myPath;
	}
	
var thisY=0;
var thisX=0;

function makePopUp(thiswidth,thisheight,thisDocument,thisWindowName,thisXPosition,thisYPosition,thisScrollbar,thisResize) {
	if (bw.ie) {
	  thisX = window.screenLeft + thisXPosition;
	  thisY = window.screenTop + thisYPosition;
	}
	else{
	  thisX = window.screenX +  thisXPosition + 10;
	  thisY = window.screenY + thisYPosition + 114;
	  if(bw.mac)
			thisY = window.screenY + thisYPosition + 90;
	}
	
	myProperty = 'toolbar=0,location=0,directories=0,status=0,scrollbars=' + thisScrollbar + ',resizable=' + thisResize + ',width=' + thiswidth + ',height=' + thisheight + ',top=' + thisY + ',left=' + thisX;
	
	
	if(self.my_window == null){
		delete my_window;
		my_window = window.open(thisDocument,thisWindowName,myProperty);
		if(my_window != null){
			my_window.focus();
		}
	}
	else{
		if(!(my_window.closed)){
			self.my_window.close();
			my_window  = window.open(thisDocument,thisWindowName,myProperty);
		}
		else{
			my_window  = window.open(thisDocument,thisWindowName,myProperty);
		}
	}
}


function get_windowInnerSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [ myWidth, myHeight ];

}

function get_documentInnerSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.document.width ) == 'number' ) {
    //Non-IE
    myWidth = window.document.width;
    myHeight = window.innerHeight + 17;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  // IE
  //document.body.scrollWidth;
  //document.body.scrollHeight;

  return [ myWidth, myHeight ];

}

function get_scrollXY() {
	var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		scrOfY = window.pageYOffset; scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft;
	}
	return [ scrOfX, scrOfY ];
}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

/////////////////////////////////////////////////////////////////////////////////
// onLoad 

function set_bestpracticeNavigation() {
  if( !document.getElementById('division-subnav') ) return false;
  var myList = document.getElementById('division-subnav');
  for ( var i = 0, elements = myList.getElementsByTagName('strong'), count = elements.length; i < count; i++ ){
    elements[i].onclick = function(){
      var myList = document.getElementById('division-subnav');
       for ( var i = 0, elements = myList.getElementsByTagName('strong'), count = elements.length; i < count; i++ ){
        elements[i].parentNode.className = elements[i].parentNode.className.replace(new RegExp(' active\\b'), '');
        elements[i].className = elements[i].className.replace(new RegExp(' active\\b'), '');
        
       }
      if(this.innerHTML != window.name ){
        this.parentNode.className += ' active';
        this.className += ' active';
        window.name = this.innerHTML;
      }
      else{
        window.name = '';
      }
    }
  }
}

sfHover = function() {
  if( !document.getElementById('division-subnav') ) return false;
	var sfEls = document.getElementById("division-subnav").getElementsByTagName("strong");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" selected";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" selected\\b"), "");
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);

addLoadEvent(set_bestpracticeNavigation);

function pageInit(){
  if( !document.getElementById('division-subnav') ) return false;
    var myList = document.getElementById('division-subnav');
      for ( var i = 0, elements = myList.getElementsByTagName('a'), count = elements.length; i < count; i++ ){
        element = elements[i];
        var tmpWindowLocation = window.location.href.toLowerCase().replace(/%20/,' ');
        var tmpHref           = element.href.toLowerCase().replace(/%20/,' ');
        if(tmpWindowLocation.indexOf( tmpHref ) > -1 ){
          var tmpParent = element.parentNode.parentNode.parentNode;
          tmpParent.className += ' active';
          if(tmpParent.getElementsByTagName('strong')[0]){
            tmpParent.getElementsByTagName('strong')[0].className += ' active';
          }
          break;
        }
      }
  }


  if (document.addEventListener) {
       document.addEventListener("DOMContentLoaded", pageInit, false);
   }
  /*@cc_on @*/
    /*@if (@_win32)
    var dummy = (location.protocol == "https:") ? "//:" : "javascript:void(0)";
    document.write("<script id=__ie_onload defer src="+ dummy + "><\/script>");
    var script = document.getElementById("__ie_onload");
    script.onreadystatechange = function() {
    	if (this.readyState == "complete") {
    		pageInit();; // call the onload handler
    	}
    };
    /*@end @*/

