var clicked=-1;

// ----------------------------------------------------------------------------
// the function getDocumentHeight needs the Tag "<div id="marker"/>"
// at the end of the document, standing in front of the </body>-Tag 
function getDocumentHeight() {

  if(document.getElementById ) {
    return document.getElementById("marker").offsetTop;
  } else if(document.all) {
    return document.all.marker.offsetTop;
   } else {
    return document.height;
   }
}

// ----------------------------------------------------------------------------

function getWindowHeight() {
  if (document.all) {
    return document.body.offsetHeight;
  } else {
    return window.innerHeight;
  }
}

// ----------------------------------------------------------------------------

function reDo() 
{
  if (innerWidth != origWidth || innerHeight != origHeight) {
    location.reload();
  }
}   

// ----------------------------------------------------------------------------

function printPage()
{
 var content;
 var newWin;

 newWin = false;
 content = "";

 if (document.all)
 {
  for (i=0;i<document.all.tags("div").length;i++)
  {
   if (document.all.tags("div")[i].id == "printPage")
   {
    
 content = content + "<table border=0 width=600><tr><td>";
    
 content = content + document.all.tags("div")[i].innerHTML ;
    newWin=true;
    content = content + "</td></tr></table><p><br>";
 
   }
  }
 }
 
 if (!document.all && document.getElementsByName)
 {
  for (i=0;i<document.getElementsByTagName("div").length;i++)
  {
   if (document.getElementsByTagName("div")[i].id == "printPage")
   {
 content = content + "<table border=0 width=600><tr><td>";
    content = content + document.getElementsByTagName("div")[i].innerHTML;
    newWin=true;
    content = content + "</td></tr></table><p><br>";
   }
  }
 }

 if ((content == "") && (newWin == false))
 {
  window.print()
 }
 else
 {
  printIt = window.open("","Druckansicht","width=450,height=600");
  printIt.document.open()
  printIt.document.write("<font face=arial,helvetica,sans-serif size=3><b>Druckansicht der Seite</b></font><br><br>");
  printIt.document.write("<font face=arial,helvetica,sans-serif size=2>Dateiname: "+ window.location + "</font><br><br>");
  printIt.document.write(content);
  printIt.document.write("<font face=arial,helvetica,sans-serif size=2><a href=javascript:window.print()>Drucken</a></font>")
  printIt.document.close()
  printIt.focus()
 }
}

// ----------------------------------------------------------------------------

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

// ----------------------------------------------------------------------------

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

// ----------------------------------------------------------------------------

function MM_openBrWindow(theURL,winName,features) { //v2.0
  win = window.open(theURL,winName,features);
  win.focus();
}

// ----------------------------------------------------------------------------

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 MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

// ----------------------------------------------------------------------------

function dynPos()
{
/*
   var abbinder_height = 80;
   var yPlus = 0;

   if (getDocumentHeight()+abbinder_height<= getWindowHeight())
   {
       posLayer('abbinder',0,getWindowHeight()-abbinder_height)
       showLayers('abbinder')
   }
   else
   {
    if (document.layers)
   	{
   		yPlus = abbinder_height;
   		document.height = document.height +abbinder_height;
   	}
   	else
   	{
   	   yPlus = 0
   	}
    posLayer('abbinder',0,getDocumentHeight()-yPlus);
    showLayers('abbinder');
   }
*/
}

// ----------------------------------------------------------------------------

function filterZ(c) 
{
var w=c.charCodeAt(0);
var out=-1;
 if ((w>=48) & (w<=57)) out=w;
if (out==-1) {return ''} else {return String.fromCharCode(out)};
};

// ----------------------------------------------------------------------------

function filterZtxt(tmp) 
{
var out='';
var i;
if (tmp.length>0) 
{
 for (i=0;i<tmp.length;i++) 
{
  out=out + filterZ(tmp.charAt(i));
};
};
return out;
};

// ----------------------------------------------------------------------------

function filterZKeypress() 
{
	var tmp=filterZ(String.fromCharCode(window.event.keyCode))
	if (tmp=='') 
	{
	 window.event.returnValue=false;
	}
	else
	{
	 window.event.keyCode=tmp.charCodeAt(0);
	 window.event.returnValue=true;
	};
};

// ----------------------------------------------------------------------------

function filterZPaste() 
{
 event.returnValue= false;
 document.selection.createRange().text=filterZtxt(window.clipboardData.getData("Text"));
}; 

// ----------------------------------------------------------------------------

function filterZChange() 
{
 event.returnValue= true;
 window.event.srcElement.value=filterZtxt(window.event.srcElement.value);
};

// ----------------------------------------------------------------------------

function posLayer(_layerid, _l, _t) {
  

  
  var agt=navigator.userAgent.toLowerCase();
  var net6 = ((((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1))) && ( parseInt(navigator.appVersion) >= 5));
  
  
  if (net6) {
  		  document.getElementById(_layerid).style.top=_t + "px";
   		  document.getElementById(_layerid).style.left=_l + "px";
  } else {
  
	  if (navigator.appName == "Netscape") {
	  	eval("window.document." + _layerid + ".left = " + _l);
	  	eval("window.document." + _layerid + ".top = " + _t);
	  } else {
	    eval("window.document.all." + _layerid + ".style.pixelLeft = " + _l);
	  	eval("window.document.all." + _layerid + ".style.pixelTop = " + _t);
	  }

  }

}

// ----------------------------------------------------------------------------

function showLayers(){

  var agt=navigator.userAgent.toLowerCase();
  var net6 = ((((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1))) && ( parseInt(navigator.appVersion) >= 5));
  
  var _x = showLayers.arguments;
  
  for (var _t=0; _t<_x.length; _t++) {
	  if(net6) {
	  
	  	document.getElementById(_x[_t]).style.visibility='visible';
	  
	  } else {

		  if (navigator.appName == "Netscape") {
		   	eval("window.document." + _x[_t] + ".visibility = \"show\"");
		  } else {
		   	eval("window.document.all." + _x[_t] + ".style.visibility = \"visible\"");
		  }
	  }
   }
}

// ----------------------------------------------------------------------------

function searchObj(n, d) 
{ //FTgoodie 1.0
  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=searchObj(n,d.layers[i].document); 
	return x;
}

// ----------------------------------------------------------------------------

function openSELSaveFilterWindow() {
  win = window.open('searchSaveFilterPopup.faces','selPopup','scrollbars=no,resizable=no,width=595,height=360');
  win.focus();
}

// ----------------------------------------------------------------------------

function openSELLoadFilterWindow() {
  win = window.open('searchLoadFilterPopup.faces','selPopup','scrollbars=no,resizable=no,width=595,height=360');
  win.focus();
}

// ----------------------------------------------------------------------------

function DoMouseOver(bildnr)
 {
  if(document.images&&bildnr!=clicked)
  {
   if(brname=="Netscape")
    dest=eval("document.images.mo" + bildnr);
   else
    dest=eval("mo" + bildnr);
   isrc=eval("ba" + bildnr);
   dest.src=isrc.src;
  }
}

// ----------------------------------------------------------------------------
 
function DoMouseOut(bildnr)
 {
  if(document.images&&bildnr!=clicked)
  {
   if(brname=="Netscape")
    dest=eval("document.images.mo" + bildnr);
   else
   dest=eval("mo" + bildnr);
   isrc=eval("bp" + bildnr);
   dest.src=isrc.src;
  }
}

// ----------------------------------------------------------------------------
 
function OpenStahlOnlineWindow(locale, link)
  {
	var hrefToOpen; 
	
  	if(link == 'manual')
  	{
  	  hrefToOpen="${requestScope.privPath}/manual/${requestScope.attrLocale}/manual.pdf";
  	}
  	else if(locale == 'en') 
  	{
  	  if(link == '0')
  	    hrefToOpen="http://www.stahl-online.de/english/the_stahlzentrum/stahl_zentrum_english.asp";
  	  else if(link == '1')
  	    hrefToOpen="http://www.stahl-online.de/stahlanwendung/faszination_stahl/start.asp";
 	  else if(link == '2')
  	    hrefToOpen="http://www.stahl-online.de/publikationen/publikationen.asp";
  	  else if(link == '3')
  	    hrefToOpen="http://www.stahl-online.de/termine/termineAktuelle.asp";
  	  else if(link == 'impressum')
  	    hrefToOpen="http://www.stahl-online.de/english/legal_notes/legal_notes.htm";
  	  else if(link == 'datenschutz')
  	    hrefToOpen="http://www.stahl-online.de/english/information_about_data_protectio/data_protection.htm";
   	} 
  	else 
  	{
  	  if(link == '0')
  	    hrefToOpen="http://www.stahl-online.de/stahl_zentrum/stahl_zentrum.asp";
  	  else if(link == '1')
  	    hrefToOpen="http://www.stahl-online.de/stahlanwendung/faszination_stahl/start.asp";
 	  else if(link == '2')
  	    hrefToOpen="http://www.stahl-online.de/publikationen/publikationen.asp";
  	  else if(link == '3')
  	    hrefToOpen="http://www.stahl-online.de/termine/termineAktuelle.asp";
  	  else if(link == 'impressum')
  	    hrefToOpen="http://www.stahl-online.de/impressum/impressum.htm";
  	  else if(link == 'datenschutz')
  	    hrefToOpen="http://www.stahl-online.de/datenschutzinformation/datenschutzinformation.htm";
   	  else if(link == 'manual')
  	    hrefToOpen="http://www.stahl-online.de/english/information_about_data_protectio/data_protection.htm";
  	}
  	
  	win = window.open(hrefToOpen, "stahlOnlinePopup", "width=800,height=600,resizable=yes,scrollbars=yes,toolbar=yes,status=yes,left=0,top=0");
  	win.focus();
}

// ----------------------------------------------------------------------------

function checkEnterAndClickDefault(form) 
{
  var keycode; 

  if (window.event) keycode = window.event.keyCode;
  else if (event) keycode = event.which;
  else return true; 

  if (keycode != 13) 
    return true; 
  
  for(i=0; i<form.elements.length; i++)
  {
    if(form.elements[i].name.indexOf('defaultButton') != -1) {
  	  form.elements[i].click();
  	  return false;
    }
  }
  
  return true; 
}

// ----------------------------------------------------------------------------

function showPleaseWait() {

  if(document.getElementById && document.getElementById("divsubmit")) {
    document.getElementById("divsubmit").style.display = 'none';  
    document.getElementById("divpleasewait").style.display = 'block';  
  }
    
  return true;
}  

// ----------------------------------------------------------------------------

