/* This file contains functions for general use */

// -----------------------------------------------
// Correcting the scrolling of the content layer. 
// -----------------------------------------------
function checkheight() {
  var lwidth   = 165;
  var lheight  = 130;
  var myHeight = 0, myWidth = 0;
  
  //Non-IE
  if( typeof( window.innerWidth ) == 'number' ) {
    myWidth  = document.documentElement.clientWidth-lwidth;
    myHeight = window.innerHeight-lheight; }
  
  //IE 6+ in 'standards compliant mode'
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myWidth  = document.documentElement.clientWidth-lwidth;
    myHeight = document.documentElement.clientHeight-lheight;
  }
  
  //IE 4 compatible
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myWidth  = document.body.clientWidth-lwidth;
    myHeight = document.body.clientHeight-lheight;
  }
  document.getElementById('right').style.width  = myWidth+"px";
  document.getElementById('right').style.height = myHeight+"px";
}
window.onresize = checkheight;

frame_1     = new Image();
frame_1.src = "/fileadmin/img/frame.gif";
frame_2     = new Image();
frame_2.src = "/fileadmin/img/frame2.gif";

function chgOff(lay)  {
  laynum = lay.replace(/k/,"");
  document.images[lay].src = frame_1.src;
  document.getElementById("l"+laynum).style.color = "#000000";
}
function chgOn(lay)  {
  laynum = lay.replace(/k/,"");  
  document.images[lay].src = frame_2.src;
  document.getElementById("l"+laynum).style.color = "#EF9418";
}

function imgOpen(id,w,h,L,T) {
  h = h+20;
  Show=window.open('/picshow.php?id='+id+'&w='+w+'&h='+h+'&L='+L+'&T='+T,'iwin','width='+w+',height='+h+',resizable=0,scrollbars=0,toolbar=0,status=no,left=250,top=250');
  Show.focus();
}

function detailOpen(id,i,a,L,w,h) {
  Show=window.open('/typo3conf/ext/user_arbeit/detailshow.php?id='+id+'&detail='+i+'&at='+a+'&L='+L,'iwin','width='+parseInt(w)+',height='+parseInt(h)+',resizable=0,scrollbars=0,toolbar=0,status=no,left=250,top=250');
  Show.focus();
}

function gothere(x,L){
  xid           = document.goform.xgo.options[document.goform.xgo.options.selectedIndex].value;
  location.href = x+"?xid="+xid+"&L="+L;
}

// ----------------
// print-a-page. 
// ----------------

function printOpen(id) {
    Show=window.open('/index.php?id='+id+'&type=1','pwin','width=740,height=750,resizable=0,scrollbars=yes,toolbar=0,status=no,left=150,top=150');
    Show.focus();
}

// ------------------------
// related to the newspage 
// ------------------------

var actlay = 1;
var top    = 12;
var clip   = "rect(0px 370px 280px 0px)";
var xtx     = "";
function lshow(num) {
  if(num != actlay) {
	  $('tDiv'+num).show();
		$('tDiv'+actlay).hide();
		$('tDiv'+actlay).style.top = '12px';
		$('tDiv'+actlay).style.left = '10px';
		$('tDiv'+actlay).style.clip = 'rect(0px 370px 280px 0px)';
		$('l'+num).addClassName('topnav2');
		$('l'+num).removeClassName('topnav1');
		$('l'+actlay).addClassName('topnav1');
		$('l'+actlay).removeClassName('topnav2');
		$('l'+actlay).removeClassName('topnav2');
		actlay = num;
	}
}

function setActlay() { actlay = document.getElementById("act").value; }

function scd() { xtx = window.setInterval('scmove(-1)',1); }
function scu() {  xtx = setInterval('scmove(1)',1); }

function scdstop() {
	window.clearInterval(xtx);
	xtx = "";
}

function iov(elm) {
  pfimg = (elm == 'arrbot') ? '/fileadmin/img/dpfeil_2.gif' : '/fileadmin/img/upfeil_2.gif';
  $('i_'+elm).src = pfimg;
}

function iot(elm) {
  pfimg = (elm == 'arrbot') ? '/fileadmin/img/dpfeil_1.gif' : '/fileadmin/img/upfeil_1.gif';
  $('i_'+elm).src = pfimg;
}

function scmove(dir) {
  top = $('tDiv'+actlay).offsetTop;
  $('tDiv'+actlay).style.top = (top+dir)+'px';
	$('tDiv'+actlay).style.clip="rect("+(12-top)+"px 370px "+(292-top)+"px 0px)";
	if($('tDiv'+actlay).offsetTop >= 12 && dir == 1) {
	  $('tDiv'+actlay).style.top = "12px";
		$('tDiv'+actlay).style.clip = "rect(0px 370px 280px 0px)";
	  scdstop();
	}
	
	if($('tDiv'+actlay).offsetTop <= (292-$('tDiv'+actlay).offsetHeight) && dir == -1) {
	  $('tDiv'+actlay).style.top = (292-$('tDiv'+actlay).offsetHeight)+"px";
		top = $('tDiv'+actlay).offsetTop;
		$('tDiv'+actlay).style.clip="rect("+(12-top)+"px 370px "+(292-top)+"px 0px)";
	  scdstop();
	}
}

// Suchefeld markieren
function markieren() {
  document.getElementById('suche').select();
}

function show2() {
  document.getElementById('xp2').style.display="block";document.getElementById('xp1').style.display="none";
}

function show1() {
  document.getElementById('xp1').style.display="block";document.getElementById('xp2').style.display="none";
}

