/* Browserart prüfen */
// Level 1 DOM   (Netscape 6, Explorer 5) 
var DOM1   = ( document.getElementById );
// IE4 DOM 
var DOMIE4 = ( document.all );
// Netscape 4
var NN4    = ( document.layers );
// W3C DOM 
var W3CDOM = (document.createElement && document.getElementsByTagName);



var popup;

/*
var drop_breite = 160;
var sieben="aäbdeghnoöpqsuüAÄFLFTVXYZ1234567890";
var neun=  "wCDGHMNOÖQRUÜ";
var drei=  " fijltI";
var acht=  "BEKPS";
var fuenf= "vxyz";
var sechs= "ckJ";
var vier=  "r-";
var elf=   "mW";
*



/*****   blendet TopNav-Link aus wenn nicht benötigt   *****/
function CheckDocumentLength () {
	// Browserhöhe innen und Höhe Content-Div ermitteln
	var ContentHeight;
	var innerHeight = window.innerHeight;
	var objContent = getLayerRef ("Content");
	var objTopNav = getLayerRef ("pagenavtop");
	var margin = 295;
	
	if (NN4) {
		ContentHeight = objContent.height;
	}
	else if (DOMIE4) {
		var o = objContent;
		while (o.offsetParent) {
			innerHeight = document.body.offsetHeight;
			ContentHeight = parseInt (o.offsetHeight);
			o = o.offsetParent;
		}
	}
	else if (document.defaultView.getComputedStyle) {
		var o = document.defaultView.getComputedStyle ( objContent, '');
		ContentHeight = parseInt (o.getPropertyValue('height'));
	}

	// TopNav ausblenden, wenn nicht benötigt	
	if (ContentHeight + margin < innerHeight) {
		if (NN4) {
			objTopNav.visibility = "hide";
		}
		else {
			objTopNav.style.visibility = "hidden";
		}
	}
}



function Coord (x, y) {
	this.x = (!x) ? 0 : x;
	this.y = (!y) ? 0 : y;
}



function setVisibility (objLayer, visible) {
	if (document.layers) {
		objLayer.visibility = (visible == true) ? 'show' : 'hide';
	} else {
		objLayer.style.visibility = (visible == true) ? 'visible' : 'hidden';
	}
}


function ShowPopup (id) {
	/*
	alert (window.pageYOffset);
	alert (window.document.body.scrollTop);
	*/
	var popupdiv = getLayerRef (id);
	var actvis   = popupdiv.style.display;

	popuppos = new Coord (50, 50 + document.body.scrollTop);
	setPosition (popupdiv, popuppos);
	setvis = actvis == 'block' ? 'none' : 'block';
	popupdiv.style.display = setvis;
}



/*****   positioniert einen Layer   *****/
function setPosition (objLayer, coords) {
	if (document.layers) {
		objLayer.top  = coords.y;
		objLayer.left = coords.x;
	} else if (window.opera) {
		objLayer.style.top  = coords.y;
		objLayer.style.left = coords.x;
	} else if (document.all) {
		/*
		objLayer.style.top = coords.y + document.body.scrollTop;
		objLayer.style.pxelLeft = coords.x + document.body.scrollLeft;
		*/
		objLayer.style.top = coords.y;
		objLayer.style.pxelLeft = coords.x;
	} else if (document.getElementById) {
		objLayer.style.top  = coords.y + 'px';
		objLayer.style.left = coords.x + 'px';
	}
}



/*****   gibt Referenz auf einen Layer zurück   *****/
function getLayerRef (id, document) {
	if (!document)
		document = window.document;

	if (NN4) {
		for (var l = 0; l < document.layers.length; l++)
			if (document.layers[l].id == id)
				return document.layers[l];
		for (var l = 0; l < document.layers.length; l++) {
			var result = getLayerRef (id, document.layers[l].document);
			if (result)
				return result;
		}
		return null;
	}
	else if (DOMIE4) {
		return document.all[id];
	}
	else if (DOM1) {
		return document.getElementById (id);
	}
}



function windowOpener(url, name, args) {
	if ( typeof( popupWins[name] ) != "object" ) {
		popupWins[name] = window.open(url,name,args);
	} else {
		if (!popupWins[name].closed) {
			popupWins[name].location.href = url;                                        
		} else {
			popupWins[name] = window.open(url, name,args);
		}
	}
	popupWins[name].focus();
}



function sitemap (language) {
	var url = "/sitemap.php?lang=" + language;
	var name = "Sitemap";
	var args = "width=550,height=600,resizable=yes,scrollbars=yes,screenx=0,screeny=0,top=0,left=0";
	window.open (url, name, args);
}



function winclose () {
	self.close();
}



function gotoPage (url) {
	if (opener != null) {
		opener.location.href = url;
	}
}


function drop(dd, self) {
	url=dd.options[dd.selectedIndex].value;
	if (self) {
		window.location.assign (url);
		return true;
	}
	if(url!=""){
		if(url.substr(0,4)=="http") window.open(url,'','location=yes,menubar=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes')
		else document.location.href=url;
	}
	for(i=0; i<dd.length; i++)
		if(dd.options[i].defaultSelected == true) break;
	if(i==dd.length) i=0;
	dd.options[i].selected=true;
}




function Generate(name,Mas,Mas_V)
{  
  MaxLength = check_max_length(Mas);
  //alert(MaxLength);  
  
  Length = Mas.length;  
  if(MaxLength<drop_breite){
    for(i = 0; i < Length; i++) {    
		/*
      text = Mas[i];
      value = Mas_V[i];
	  */
      value = Mas[i];
      text = Mas_V[i];
      name.options[i+1] = new Option(text);
      name.options[i+1].value = value;    
      }  
    //name.length = Length+1;   
  }
  else
  {
    var Flag=0,j=1;   
    for(i = 0; i < Length; i++){
      Menu_Name = Mas[i];
      Menu_Value = Mas_V[i];
      
      if(name.options[j-1].value!=-2){       
        name.options[j] = new Option("-------------------------------");
        name.options[j].value = -2;
        j++;
        }       
      while(check_length(Menu_Name)>drop_breite)
      {          
      
        for(let_count=1; let_count<=Menu_Name.length; let_count++)
        {           
          Menu_Name_Tmp=Menu_Name.substr(0,let_count);                     
          if(check_length(Menu_Name_Tmp)>drop_breite){                        
            var Space = Menu_Name.substr(0,let_count-1).lastIndexOf(" ");
            if(Space!=-1) let_count=Space+2;            
            name.options[j] = new Option(Menu_Name.substr(0,let_count-1));
            name.options[j].value = Menu_Value;   
            j++; 
            Menu_Name = Menu_Name.substr(let_count-1,Menu_Name.length);            
            break;
          }
        }
        while(Menu_Name.indexOf(" ")==0) Menu_Name=Menu_Name.substr(1,Menu_Name.length);        
      }
      name.options[j] = new Option(Menu_Name);
      name.options[j].value = Menu_Value;   
      j++;      
     
      name.options[j] = new Option("-------------------------------");
      name.options[j].value = -2;
      j++;          
    }
  //name.length = j;      
  }  
}

/*
function clear(name)
{
for(i = 1; i < name.length; i++) name.options[i] = null;      
name.options[0].text = ""; name.length = 1; name.selectedIndex = 0;
}
*/


function check_max_length(Mas)
{
  Max=0;
  for(i=0; i<Mas.length; i++){
    Str = Mas[i];   
    Length = check_length(Str);
    if(Length > Max) Max = Length;
    }
  return(Max);
}

function check_length(str)
{
  str_len=0;
  for(j=0; j<str.length; j++)
  {
    letter=str.charAt(j);
    if(sieben.indexOf(letter)!=-1) str_len+=7;
    if(neun.indexOf(letter)!=-1) str_len+=9;
    if(drei.indexOf(letter)!=-1) str_len+=3;
    if(acht.indexOf(letter)!=-1) str_len+=8;
    if(fuenf.indexOf(letter)!=-1) str_len+=5;
    if(sechs.indexOf(letter)!=-1) str_len+=6;
    if(vier.indexOf(letter)!=-1) str_len+=4;
    if(elf.indexOf(letter)!=-1) str_len+=11;
  }
  return(str_len+25);
}



function checkmail(mail){
	return mail.match(/^[a-z][a-z0-9._-]+\@[^.]+\.[a-z]{2,5}$/i);
}



function checkphone(phone){
	return phone.match(/^[0-9._+ -]+$/);
}



function change(name,PageID)
{
for(i = 1; i < name.length; i++){
  if(name.options[i].value ==PageID){
    name.selectedIndex = i; break;      
    }
  }  
}



function submitSearch () {
	document.forms["locations"].submit();
}
function init () {
	var counter = 0;	
	for (i = 1; i < BereichStr.length; i++) {
		if (BereichStr[i] != null) {
			opt = new Option (BereichStr[i], i);
			workarea.options[counter++] = opt;
		}
	}
}
function changeArea () {
	var area = workarea.value;
	clearSelect (land);
	opt = new Option (chooseCountry, -1);
	land.options[0] = opt;
	for (i = 0; i < countries[area].length; i++) {
		opt = new Option (Land[countries[area][i]], countries[area][i]);
		land.options[i + 1] = opt;
	}
}
function clearSelect (name) {
	for (i = 0; i < name.options.length; i++) {
		name.options[i] = null;
	}
}



function openSite (url) {
	window.open (url);
}


function printout (page) {
	var url = "/printout.php?source="+page;
	var name = "Printpreview";
	var args = "width=680,height=700,resizable=yes,scrollbars=yes,screenx=0,screeny=0,top=0,left=0";
	window.open (url, name, args);
}

function openPopup(popuptitel,popupbild,popupbreite,popuphoehe,lang)
	{
		popup = window.open ("/popup.php?popuptitel="+popuptitel+"&popupbild="+popupbild+"&lang="+lang,"popup","width="+popupbreite+",height="+popuphoehe+",left=50,top=50,resizeable=no,scrollbars=no,toolbar=no,status=0");
		popup.focus();
	}

function openPopup2(popuptitel,popupbild,popupbreite,popuphoehe,lang)
	{
		popup = window.open ("/popup.php?popuptitel="+popuptitel+"&popupbild="+popupbild+"&lang="+lang,"popup2","width="+popupbreite+",height="+popuphoehe+",left=90,top=90,resizeable=no,scrollbars=no,toolbar=no,status=0");
		popup.focus();
	}

function PopupFocus () {
	popup.focus ();
}


function txtpop(el){
	    var child=el.childNodes;
		    for (i=0;i<child.length;i++){
				        if(child[i].tagName == 'DIV') {
							            txt=child[i];
										        }
						    }
			    txt.style.display=txt.style.display=='block'?'none':'block';
}


function MailPopup (target, language) {
	mailpop = window.open ("/mailpopup.php?email=" + target + "&lang=" + language, "mail", "width=370, height=615, left=50, top=50, resizeable=no,scrollbars=no,toolbar=no,status=0");
	mailpop.focus ();
}

function MailPopups (language) {
	mailpop = window.open ("/contactform.php?lang=" + language, "mail", "width=370, height=690, left=50, top=50, resizeable=no,scrollbars=no,toolbar=no,status=0");
	mailpop.focus ();
}



//document.onload = CheckDocumentLength ();

