var max_page_height = 700;
var agt=navigator.userAgent.toLowerCase();
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
               && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
               && (agt.indexOf('webtv')==-1));
var is_major = parseInt(navigator.appVersion);
var is_opera = (agt.indexOf("opera") != -1);
var not_nav6 = (is_nav && (is_major < 5));
var isNN=(navigator.appName=="Netscape");

var is_opera7 = (is_opera && agt.indexOf("7.")!=-1);
var is_opera6 = (is_opera && !is_opera7);

if(!document.getElementById){
	if(eval){
	   document.getElementById = eval
	}
}

var my_height;
function detect_height(){
	if(isNN){
		if(not_nav6){
			my_height=window.innerHeight+5;
		}else{
			my_height=window.innerHeight;
		}
	}else if(is_opera){
		my_height=window.innerHeight;
	}else{
		my_height=document.body.clientHeight;
	}
}
//detect_height()

//window.onresize = resizer
//window.onerror = handle_error
var msg_array = new Array()
var url_array = new Array()
var lno_array = new Array()

function handle_error(msg,url,lno){
   msg_array[msg_array.length] = msg
   url_array[url_array.length] = url
   lno_array[lno_array.length] = lno
   pom = "*** Mssg No. : "+msg_array.length
   pom+= (lno_array.length>0) ? " (ln:"+lno_array[0]+")" : ""
   window.status = pom
   return true
}

function starer(){
	detect_height()
	sredi_sadrzaj()
}
function resizer(){
	detect_height()
//	setTimeout("sredi_sadrzaj()",100)
	sredi_sadrzaj()
}
function sredi_sadrzaj(){
	if(document.getElementById){

		if(document.getElementById("authorlogo") && document.getElementById("authorlogo").style){
   		document.getElementById("authorlogo").style.visibility       = "hidden"
   		document.getElementById("partTCLevelX0").style.visibility    = "hidden"
      }


/*
		t_height = (document.getElementById("news").offsetHeight>document.getElementById("central").offsetHeight)?document.getElementById("news").offsetHeight:document.getElementById("central").offsetHeight
		t_height = (t_height>document.getElementById("partMLLevelX0").offsetHeight-document.getElementById("partMCLevelX1").offsetHeight)?t_height:document.getElementById("partMLLevelX0").offsetHeight-document.getElementById("partMCLevelX1").offsetHeight

		p_height = my_height - t_height - document.getElementById("partMCLevelX1").offsetHeight - document.getElementById("partBCLevelX0").offsetHeight - document.getElementById("authorlogo").offsetHeight
		if(p_height>0)
		   t_height += p_height
      if(document.getElementById("authorlogo")){
   		t_height  = my_height
   		t_height -= document.getElementById("partTCLevelX0").offsetHeight
   		t_height -= document.getElementById("authorlogo").offsetHeight
   		if(t_height > document.getElementById("partMLLevelX1").offsetHeight)
   		   document.getElementById("partMLLevelX0").height = t_height
      }

*/

//		document.getElementById("partMLLevelX0").height = t_height
//		document.getElementById("news").height = t_height


		if(document.getElementById("authorlogo") && document.getElementById("authorlogo").style){
   		document.getElementById("partTCLevelX0").style.visibility    = "visible"
   		document.getElementById("authorlogo").style.visibility       = "visible"
   	}
	}
}

function printOrder(_url) {
	printWindow = window.open(_url,
							  "printWindow","toolbar=0, location=0, status=1, resizable=1, menubar=1, "+
							  "scrollbars=1, width=750, height=540");
	printWindow.focus();
}

var windowVar = null
//function myZoom(pic,w,h,_width,_height,_align,_valign){
function myZoomImage(pic,w,h,_width,_height,_align,_valign){
	my_screen_width = screen.width
	my_screen_height = screen.height
	my_screen_avail_width = my_screen_width - 0
	my_screen_avail_height = my_screen_height - 30 - 27

	def_win_border_height = 0//29 do 52
	def_win_border_width = 0//9 do 10

	def_align = "center"
	def_valign = "middle"
	def_width = 800
	def_height = 600

	_scroll = "no"
	if(_width == null){
		_width = w + 30
	}
	if(_height == null){
		_height = h + 50
//		_height = h
	}
	if(_height>my_screen_avail_height || h>my_screen_avail_height){
		_width += 16
		_height = my_screen_avail_height
		_scroll = "yes"
	}
	if(_align==null){
		_align = def_align
	}else{
		if(_align!="left" && _align!="right"){
			_align = def_align
		}
	}
	if(_valign==null){
		_valign = def_valign
	}else{
		if(_valign!="top" && _valign!="bottom"){
			_valign = def_valign
		}
	}

	_left = (my_screen_avail_width - def_win_border_width - _width)
	_top = (my_screen_avail_height - def_win_border_height - _height)
//		alert(my_screen_avail_height+", "+my_screen_height)
	if(_left < 0 || _align == "left"){
		_left = 0
	}
	if(_align == "center"){
		_left = Math.round(_left/2)
	}

	if(_top < 0 || _valign == "top"){
		_top = 0
	}
	if(_valign == "middle"){
		_top = Math.round(_top/2)
	}


   if(windowVar && windowVar.close){
      windowVar.close()
   }
	windowVar = window.open("index.php?st_location=home&st_version=active&structure_template_type=zoom&image_id="+pic+"&w="+w+"&h="+h,"Zoom","toolbar=no,location=no,diretories=no,scrollbars="+_scroll+",status=no,menubar=no,resizable=yes,top="+_top+",left="+_left+",height="+_height+",width="+_width+"");
	windowVar.focus();
}

function statusWrite(_what, _when){
   if(_what == null)
      _what = "";
   if(_when == null)
      _when = 10;
   statusTimeout = setTimeout("window.status='"+_what+"'",_when)
}

function popup(_url) {
	popupWindow = window.open(_url,
							  "popupWindow","toolbar=0, location=0, status=1, resizable=1, menubar=0, "+
							  "scrollbars=1, width=790, height=540");
	popupWindow.focus();
}

function mailpage(_str)
{
   mail_str = "";
   if(!_str){
      mail_str += location.href;
   }else{
      chek = _str.substr(0,_str.indexOf('%title%')) + "'" + document.title + "'"
      bodi = _str.substr(_str.indexOf('%title%')+7,_str.length)
      bodi = bodi.substr(0,bodi.indexOf('%title%')) + "'" + document.title + "'" + bodi.substr(bodi.indexOf('%title%')+7,bodi.length)
      bodi = bodi.substr(0,bodi.indexOf('%url%')) + location.href + bodi.substr(bodi.indexOf('%url%')+5,bodi.length)

      mail_str = "mailto:?subject=" + chek;
      mail_str += "&body=" + bodi;
   }
location.href = mail_str;
}
function sendmail(_to,_subject,_body)
{
   _code = "utf-8";
   _to = "info@erlebniswelt-waldbronn.de"
   _subject = "Internetpraesenz%20&quot;Erlebniswelt%20Waldbronn&quot;"
   _body = "Firma:%20%0D%0AName:%20%0D%0AVorname:%20%0D%0AStrasse:%20%0D%0APLZ/Stadt:%20%0D%0ALand:%20%0D%0ATelefon:%20%0D%0ATelefax:%20%0D%0A"

   mail_str = "";
   mail_str += "mailto:"+_to
   mail_str += "?subject=" + _subject;
//   mail_str += "&charset=" + _code;
//   mail_str += "&char-set=" + _code;
//   mail_str += "&hreflang=" + _code;
//   mail_str += "&href-lang=" + _code;
   mail_str += "&body=" + _body;
   mail_str = "mailto:info@erlebniswelt-waldbronn.de?subject=Internetpraesenz%20&quot;Erlebniswelt%20Waldbronn&quot;&body=Firma:%20%0D%0AName:%20%0D%0AVorname:%20%0D%0AStrasse:%20%0D%0APLZ/Stadt:%20%0D%0ALand:%20%0D%0ATelefon:%20%0D%0ATelefax:%20%0D%0A"
   location.href = mail_str;
}

function backfrompopup()
{
//   mrt
}

function table_data_over(id,lvl)
{
   // uradjeni samo overi nad tabelom, treba uraditi overe nad linkovima!?!?!?
   if(id==null)
      return
   if(lvl==null)
      return
   if(!id.hasChildNodes())
		return
   for(var i=0; i<id.childNodes.length; i++){
      switch(id.childNodes[i].nodeType){
         // element node
         case 1:
            t_tabl = id.childNodes[i];
            break;
         // text node
         case 3:
            break;
      }
   }
   t_klas = t_tabl.className;
	if(t_klas)
		if(	t_klas.indexOf("item")!=-1 &&
			t_klas.indexOf("Level")!=-1)
			if(	t_klas.substr(t_klas.length-2,t_klas.length-1)!="on" &&
				t_klas.substr(t_klas.length-2,t_klas.length-1)!="ov")
				t_tabl.className = t_klas + "ov"
}

function table_data_out(id,lvl)
{
   // uradjeni samo overi nad tabelom, treba uraditi overe nad linkovima!?!?!?
   if(id==null)
      return
   if(lvl==null)
      return
   if(!id.hasChildNodes())
		return
   for(var i=0; i<id.childNodes.length; i++){
      switch(id.childNodes[i].nodeType){
         // element node
         case 1:
            t_tabl = id.childNodes[i];
            break;
         // text node
         case 3:
            break;
      }
   }
   t_klas = t_tabl.className;
	if(t_klas)
		if(	t_klas.indexOf("item")!=-1 &&
			t_klas.indexOf("Level")!=-1)
			if(	t_klas.substr(t_klas.length-2,t_klas.length-1)!="on" &&
				t_klas.substr(t_klas.length-2,t_klas.length-1)=="ov")
				t_tabl.className = t_klas.substr(0,t_klas.length-2)
}

function table_data_click(targetAddress,targetWindow)
{
	if(targetAddress != "empty"){
		if(targetWindow == "_self"){
			location = targetAddress;
		}else if(targetWindow == "_blank"){
			window.open(targetAddress);
		}
	}
}

function button_over(id)
{
	if(id==null)
		return
	if(id.src)
		srs = id.src
	if(srs.substr(srs.lastIndexOf(".")-3,3)!="_on" &&
		srs.substr(srs.lastIndexOf(".")-3,3)!="_ov")
		srs = srs.substr(0,srs.lastIndexOf("."))+"_ov"+srs.substring(srs.lastIndexOf("."),srs.length)
	id.src = srs
}

function button_out(id)
{
	if(id==null)
		return
	if(id.src)
		srs = id.src
	if(srs.substr(srs.lastIndexOf(".")-3,3)!="_on" &&
		srs.substr(srs.lastIndexOf(".")-3,3)=="_ov")
		srs = srs.substr(0,srs.lastIndexOf(".")-3)+srs.substring(srs.lastIndexOf("."),srs.length)
	id.src = srs
}

