
var W3CDOM;

var mouseOvers;
var mouseOuts;

function getHeight() {

  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 myHeight;
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
}

function resize(){
  //var headerHeight =  document.getElementById("header").style.height;
  //var menutopDivHeight =  document.getElementById("menutopDiv").style.height;
  // var height = windowheight - (headerHeight + menutopDivHeight) + "px";

  var frame = document.getElementById("contentcenter");
  var height = (getHeight() - 166 - 20) + "px";
  frame.style.height = height;

  var banner = document.getElementById("banner");
  var bannerHeight = 225;
  var bannerMinMarginTop = 10;
  var bannerMinTop = 277 + bannerMinMarginTop;
  var bannerThreshold = 109;

  var navfixed = document.getElementById("navfixed");
  var navfixedHeight = 110; /*height 100 + 10 padding*/
  var navfixedMinMarginTop = 10;
  var navfixedMinTop = bannerMinTop + bannerHeight + navfixedMinMarginTop;

  try {
    var contentcentertypo = document.getElementById("contentcentertypo");
    var contentcenterfooter = document.getElementById("contentcenterfooter");
    var contentcentertypoWidth = contentcentertypo.clientWidth || contentcentertypo.scrollWidth;
    if (contentcentertypoWidth > 0 && contentcentertypoWidth < 535) {
      contentcentertypo.style.paddingRight = "5px";
      contentcenterfooter.style.marginRight = "25px";
    } else {
      contentcentertypo.style.paddingRight = "21px";
      contentcenterfooter.style.marginRight = "41px";
    }
  } catch(err) {
    alert("err: " + err);
  }

  var navfixedTop = getHeight() - navfixedHeight;
  var bannerMarginTop = (navfixedTop - bannerMinTop - bannerHeight) / 2;

  if (navfixedTop < navfixedMinTop) navfixedTop = navfixedMinTop; /* do not move over banner */
  if (bannerMarginTop < bannerMinMarginTop) bannerMarginTop = bannerMinMarginTop; /* do not move over search */
  //if (top < 500) top = 500; /* do not move over banner */
  //if (top < 300) top = 300;
  navfixed.style.top = navfixedTop + "px";
  /*if (bannerMarginTop < bannerThreshold) {*/
    banner.style.marginTop = bannerMarginTop + "px";
  /*}*/
  banner.style.visibility = "visible";

}

window.onload = function(){
    // pass the function the id of the top level UL
    activateMenu('menutop');
    resize();
    try {
      W3CDOM = (document.createElement && document.getElementsByTagName);
      mouseOvers = new Array();
      mouseOuts = new Array();
      initImageSwap();
    } catch (err) {
      alert("err: " + err);
    }
}

window.onresize = function() {
  resize();
}

var activateMenu = function(nav) {
  var navroot = document.getElementById(nav);
  // Get all the list items within the menu
  var lis=navroot.getElementsByTagName("LI");
  //var lis = navroot.childNodes;
  for (i=0; i<lis.length; i++) {
     // If the LI has another menu level
      if(lis[i].lastChild.tagName=="UL"){
        // assign the function to the LI
       	lis[i].onmouseover=function() {
             // display the inner menu
             /*this.lastChild.style.opacity="0.0";*/
             this.lastChild.style.display="block";
             /*new Effect.Opacity(this.lastChild,
                { duration: 0.1,
                  transition: Effect.Transitions.linear,
                  from: 0.0, to: 1.0 });*/

          }
          lis[i].onmouseout=function() {
             /*this.lastChild.style.opacity="1.0";
             new Effect.Opacity(this.lastChild,
                { duration: 0.1,
                  transition: Effect.Transitions.linear,
                  from: 1.0, to: 0.0 });*/
             this.lastChild.style.display="none";
          }
      }
  }
}

function Print() {
     var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,";
       sOption+="scrollbars=yes,width=750,height=600,left=100,top=25";

   var sWinHTML = document.getElementById('contentcentertypo').innerHTML;

   var winprint=window.open("","",sOption);
       winprint.document.open();
       winprint.document.write('<html><head>');
       winprint.document.write('<base href="http://www.ubitronix.com:8080/" />');
       winprint.document.write('<link href="/fileadmin/template/include/layout.css" rel="stylesheet" type="text/css" />');
       winprint.document.write('<link href="/fileadmin/template/include/all.css" rel="stylesheet" type="text/css" />');
       winprint.document.write('<link href="/fileadmin/template/include/ubitronix.css" rel="stylesheet" type="text/css" />');
       winprint.document.write('<link href="/fileadmin/template/include/print.css" rel="stylesheet" type="text/css" />');
       winprint.document.write('<link href="/fileadmin/template/include/news.css" rel="stylesheet" type="text/css" />');
       winprint.document.write('<link href="/typo3temp/stylesheet_d1e3232fa0.css" rel="stylesheet" type="text/css" />');
       winprint.document.write('</head>');
       winprint.document.write('<body onload="window.print();">'); //style="margin:1%;font-size:11px;"
       winprint.document.write(sWinHTML);
       winprint.document.write('</body></html>');
       winprint.document.close();
       winprint.focus();
}


/*
inspired by: http://www.quirksmode.org/js/mouseov.html
*/



/*window.onload = init;*/

function mouseGoesOver() {
  //alert("over");
	this.src = mouseOvers[this.number].src;
}

function mouseGoesOut() {
  //alert("out");
	this.src = mouseOuts[this.number].src;
}

function initImageSwap() {
	if (!W3CDOM) return;

  var index = 0;

	var imgs = document.getElementsByTagName('img');
	for (var i=0;i<imgs.length;i++) {
		var classes = imgs[i].className;
		if (classes && classes.match(/swapImage/)) {
      imgs[i].onmouseover = mouseGoesOver;
  		imgs[i].onmouseout = mouseGoesOut;
  		//alert(imgs[i]);
  		var suffix = imgs[i].src.substring(imgs[i].src.lastIndexOf('.'));
  		mouseOuts[index] = new Image();
  		mouseOuts[index].src = imgs[i].src;
  		mouseOvers[index] = new Image();
  		mouseOvers[index].src = imgs[i].src.substring(0,imgs[i].src.lastIndexOf('.')) + "_red" + suffix;
  		imgs[i].number = index++;
  	}
	}

	var inputs = document.getElementsByTagName('input');
	for (var i=0;i<inputs.length;i++) {
	  var type = inputs[i].getAttribute("type");
	  if (type && type.match(/image/)) {
  		var classes = inputs[i].className;
  		if (classes && classes.match(/swapImage/)) {
        inputs[i].onmouseover = mouseGoesOver;
    		inputs[i].onmouseout = mouseGoesOut;
    		var suffix = inputs[i].src.substring(inputs[i].src.lastIndexOf('.'));
    		mouseOuts[index] = new Image();
    		mouseOuts[index].src = inputs[i].src;
    		mouseOvers[index] = new Image();
    		mouseOvers[index].src = inputs[i].src.substring(0,inputs[i].src.lastIndexOf('.')) + "_red" + suffix;
    		inputs[i].number = index++;
    	}
    }
	}
}

