/* Definition Browsertypen ----------------------------------------------------------*/
   var b=2;
   var mac=0;
   br = navigator.userAgent.toLowerCase();
   //alert(br);
   if(br.indexOf("msie 4")!=-1){b=1;}//ie old
   if((br.indexOf("msie 5")!=-1) || (br.indexOf("msie 6")!=-1)){b=2;}//ie new
   if((br.indexOf("mozilla/4.0")!=-1) && (br.indexOf("msie")==-1)){b=3;}//NN 4.0x
   if((br.indexOf("mozilla/4.5")!=-1) || (br.indexOf("mozilla/4.6")!=-1) ||  (br.indexOf("mozilla/4.7")!=-1)){b=3;}//NN 4.7x
   if(br.indexOf("mozilla/5")!=-1){b=4;}//NN 6.x
   if(br.indexOf("opera")!=-1){b=5;}//opera
   if(navigator.userAgent.indexOf("Mac")>-1){mac=1;}

/* Flash-Plugin Detection ----------------------------------------------------------*/
fp='';
url=document.URL;

function detectIE(ClassID,name) { 
	result = false; 
	document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCR'+'IPT>\n'); 
	if (result) return name+','; 
	else return ''; 
}

function detectNS(ClassID,name) {

	n = ""; if (nse.indexOf(ClassID) != -1) 
	if (navigator.mimeTypes[ClassID].enabledPlugin != null) 
		n = name+","; 
	return n; 
}

	if (url.indexOf("fp=1")==-1 && url.indexOf("fp=2")==-1 && window.location.pathname.indexOf("surface")!=-1 && window.location.pathname.indexOf("pop")==-1) // falls Wert "fp" nicht vorhanden
	{
	//script- By Frederic (fw4@tvd.be)
	if (b<3 && mac==0) { pluginlist = detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") }

	if (b>2 || mac==1) {
			nse = ""; for (var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes[i].type.toLowerCase();
			pluginlist = detectNS("application/x-shockwave-flash","Shockwave Flash");
	}

//pluginlist += navigator.javaEnabled() ? "Java," : "";
if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1);

if (pluginlist.indexOf("Flash")!=-1)
fp = 1; // falls Plugin vorhanden
else fp=2; // falls Plugin nicht vorhanden
if (url.indexOf("?")==-1) adstr="?fp=";
else adstr="&fp=";
document.location.href=url+adstr+fp;

/* ----------------------------------------------------------------------------------*/
}
   
   
/* Überprüfung Auflösung und Browser -------------------------------------------------------------*/
function checkresolution(target){

	url=document.URL;
	sprachID = document.topform.sprachID.value;
	pnr = document.topform.pnr.value;
	//br = document.topform.br.value; //US 28.05.2009
	b = document.topform.br.value;
	ref = document.topform.ref.value;
	sel_1 = document.topform.select_1.value;
	sel_2 = document.topform.select_2.value;
	main = document.topform.main.value;

	if (b<3) {
		x=document.body.offsetWidth;
		y=document.body.offsetHeight;

		if(y<590){ res=1; }
		else if ( x>1100 && x<1180) { res=4; }
		else if ( x>1160) { res=3; }
		else { res=2; }
	}
	else
	{
		x=window.outerWidth;
		y=window.outerHeight;
		if(y<=760) res=1;
		else if (x>1100 && x<1180) res=4;
		else if (x>1160) res=3;
		else res=2;
	}
	//alert (x+"   "+y);

//	res=3;


	//Sonderfälle Problem-Browser
	br = navigator.userAgent.toLowerCase();
	if (br.indexOf("netscape6")!=-1) res=1;
	// Prüft, ob die Werte im URL-String noch mit den echten Werten übereinstimmen
	url_res=url.substr(url.indexOf("res=")+4,1);
	url_br=url.substr(url.indexOf("br=")+3,1);
	url_fp=url.substr(url.indexOf("fp=")+3,1);
	//alert("url_res="+url_res+" - res="+res+" - url_br="+url_br+" - url_fp="+url_fp); // US 28.05.2009

	if (isNaN(url_fp)) fp=MM_checkPlugin();
	else fp=url_fp;

	if (url.indexOf(".php")==-1) // falls Index-Seite
		document.location.href=target+"?res="+res+"&br="+b+"&sprachID="+sprachID+"&fp="+fp;
	
	else if (url_res!=res || url_br!=b && url.indexOf(".php")!=-1) 
		document.location.href=target+"?res="+res+"&br="+b+"&sprachID="+sprachID+"&fp="+fp+"&pnr="+pnr+"&ref="+ref+"&select_1="+sel_1+"&select_2="+sel_2;
		
}


function MM_checkPlugin()
{
plgIn='Shockwave Flash';
  var ok=false; document.MM_returnValue = false;
  with (navigator) if (appName.indexOf('Microsoft')==-1 || (plugins && plugins.length)) {
    ok=(plugins && plugins[plgIn]);
  } else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
    if (window.MM_flash!=null) ok=window.MM_flash;
    }
  if (!ok) fp = 2; // kein Plugin
  else fp = 1;

return fp;
}


/* Aufruf Popup-Fenster -------------------------------------------------------------*/
function popwin(val1, val2, val3)
{
if (!val3) val3='';
var url = document.URL;
var selfp = url.substr(url.lastIndexOf("/")+1,(url.lastIndexOf(".php")-url.lastIndexOf("/")-1));
var sprachID = document.topform.sprachID.value;
var produktid = document.topform.produktid.value;
var pnr = document.topform.pnr.value;
var popwin = window.open(val1+".php?produktid='"+produktid+"'&selfp="+selfp+"&zo_id="+val3+"&cont="+val2+"&pnr="+pnr+"&br="+b+"&sprachID="+sprachID+"", val1,"scrollbars=yes,width=480,height=580");
popwin.focus();
}
/* Aufruf Popup-Fenster Newsletter----------------------------------------------------*/
function popwinNewsletter(url,subscribe)
{
var sprachID = document.topform.sprachID.value;
var produktid = document.topform.produktid.value;
var pnr = document.topform.pnr.value;
var popwin = window.open(url+".php?subscribe="+subscribe+"&pnr="+pnr+"&br="+b+"&sprachID="+sprachID+"", "newsletter","scrollbars=yes,width=480,height=580");
popwin.focus();
}

/* Aufruf Popup-Fenster -------------------------------------------------------------*/
function popwinsuche(val1, val2, val3, val4, val5, val6, val7)
{
var sprachID = document.topform.sprachID.value;
var res = document.topform.res.value;
subs="&cont="+val2;
if (val1.indexOf("popinfo")!=-1)
	subs="&produktid="+val2;

// Popup aufrufen
var popwin = window.open(val1+".php?selfp="+val5+"&parentp="+val6+subs+"&zo_id="+val3+"&pnr="+val4+"&br="+b+"&sprachID="+sprachID+"&produktid="+val7, "popwin","scrollbars=yes,width=480,height=580");
popwin.focus();

// Dazugehörige Opener-Seite aufrufen
document.location.href=val5+".php?br="+b+"&sprachID="+sprachID+"&res="+res;
}


/* Aufruf Zoom-Fenster für Bildvergrößerung -------------------------------------------------------------*/
function popzoom(val1, val2, val3, val4)
{
var url = document.URL;
var selfp = url.substr(url.lastIndexOf("/")+1,(url.lastIndexOf(".php")-url.lastIndexOf("/")-1));
var sprachID = document.topform.sprachID.value;
var popzoom = window.open(val1+".php?selfp="+selfp+"&cont="+val2+"&br="+b+"&sprachID="+sprachID+"", "popzoom","scrollbars=auto,width="+val3+",height="+val4+"");
popzoom.focus();
}

/* Aufruf Popup für Druckansicht -------------------------------------------------------------*/
function popprint(val1)
{
var url = document.URL;
var selfp = url.substr(url.lastIndexOf("/")+1,(url.lastIndexOf(".php")-url.lastIndexOf("/")-1));
var sprachID = document.topform.sprachID.value;
var ref = document.topform.ref.value;
var sel_1 = document.topform.select_1.value;
var sel_2 = document.topform.select_2.value;
var popprint = window.open(selfp+".php?br="+b+"&sprachID="+sprachID+"&pnr="+val1+"&ref="+ref+"&select_1="+sel_1+"&select_2="+sel_2+"&print=1", "popprint","menubar=yes,scrollbars=yes,width=715,height=570");
popprint.focus();

//if (b==5 && mac!=1) alert("Zum Drucken bitte 'Strg+P' drücken!");
//else if (mac==1 && b<3) alert("Zum Drucken bitte 'Apfel+P' drücken!");
//else popprint.print();
}

/* Aufruf Popup Seite "Export" -------------------------------------------------------------*/
function popexport(val1,val2)
{
var url = document.URL;
var selfp = url.substr(url.lastIndexOf("/")+1,(url.lastIndexOf(".php")-url.lastIndexOf("/")-1));
var sprachID = document.topform.sprachID.value;
var popexport = window.open("export.php?br="+b+"&sprachID="+sprachID+"&pnr="+val1+"&tnr="+val2+"", "popexport","scrollbars=yes,width=670,height=660");
popexport.focus();
}

/* Aufruf Popup für Sitemap -------------------------------------------------------------*/
function popsitemap(val1,val2)
{
var fp = document.topform.fp.value;
var url = document.URL;
var selfp = url.substr(url.lastIndexOf("/")+1,(url.lastIndexOf(".php")-url.lastIndexOf("/")-1));
var sprachID = document.topform.sprachID.value;
var popsitemap = window.open(val1+".php?res="+val2+"&br="+b+"&sprachID="+sprachID+"&fp="+fp+"", "popsitemap","scrollbars=yes,resizable=yes,width=800,height=600");
popsitemap.focus();
}

/*  Ebene verbergen ----------------------------------------------------------------*/
function hideDiv(val)
{
	if (b==4) document.getElementById('div'+val).style.visibility="hidden"
    else if (b==3) document.layers['div'+val].visibility = "hide"
	else document.all['theme'].innerHTML="";
}

/*  alle Ebenen verbergen ----------------------------------------------------------*/
function hideAllDiv(val)
{
  for (i=1; i<=val; i++)
  {
   	if (b==4) 
	{
	 Ausgabebereich = document.getElementById('theme');	
 	 txt = document.createTextNode("");	 
  	 Ausgabebereich.replaceChild(txt, Ausgabebereich.firstChild);
	}
   else if (b==3) document.layers['div'+i].visibility = "hide"
   else document.all['theme'].innerHTML="";
  }
}

/*  Ebene zeigen -------------------------------------------------------------------*/
function showDiv(val,text)
{
	if (b==4) 
	{
	 Ausgabebereich = document.getElementById('theme');	
 	 txt = document.createTextNode(text);	 
  	 Ausgabebereich.replaceChild(txt, Ausgabebereich.firstChild);
	}
    else if (b==3) document.layers['div'+val].visibility = "show"
	else document.all['theme'].innerHTML=text;
}

function moveDiv(val)
{
if (b<3) {
 x=document.body.offsetWidth;
 x=document.getElementById('div1').offsetTop;
 }
 else
 {
 x=window.outerWidth;
 y=window.outerHeight;
 }
}


vtime=0;
function initbuttons(val)
{
/* Definition of all Button-Images -----------------------------------------------------------------------------*/
pval=val;
nname = new Array();
nav_0 = new Array();
nav_1 = new Array();
y = 0;
for (g=0; g<=(document.images.length-1); g++){
	if (document.images[g].name.substr(0,1) == 'i')
	{
	y++;
	nname[y] = document.images[g].name;
	nav_0[y] = nname[y] + '.gif';
	nav_1[y] = nname[y] + '-over.gif';
	}
}
vtime=1;
}

/* Swap Button-Images ------------------------------------------------------------------------------------------------*/	
function swap_pics(which, what, dval)
{	
if (vtime == 1)
{
	 //var mark = parseInt(document.is_activ.activ.value);
	 //var nbmark = parseInt(document.is_activ.nbactiv.value);

	  if (what == 0)  // onMouseOver -----------------------------------------------------------
	  {
         //if (which<=y)
		 {
		 for (h=1; h<=y; h++) 
		 	{
		   	document[nname[h]].src = '../image/leistungen/items_'+pval+'/'+nav_0[h];
		   	}
		   	document[nname[which]].src = '../image/leistungen/items_'+pval+'/'+nav_1[which];
			showDiv(dval);
		 }
	  }

	  if (what == 1)   // onMouseOut -------------------------------------------------------------
	  {
		   	document[nname[which]].src = '../image/leistungen/items_'+pval+'/'+nav_0[which];
			hideDiv(dval);
	  }
	  
	  if(what == 2) // onClick ----------------------------------------------------------------
	  {	
	  } 
}
}

/* Wechsel Selects bei Bauteile/Anwendungen -----------------------------------------------------------------------*/
function change_sel(val1,val2)
{
var url = document.URL;
var selfp = url.substr(url.lastIndexOf("/")+1,(url.lastIndexOf(".php")-url.lastIndexOf("/")-1));
var sprachID = document.topform.sprachID.value;
var fp = document.topform.fp.value;
for(i=0;i<document.sel_bt.bauteil.length;i++)
{
  if(document.sel_bt.bauteil.options[i].selected == true)
   var sel_1=document.sel_bt.bauteil.options[i].value;
}
if (val2==2)
{
 for(i=0;i<document.sel_bt.einsatz.length;i++)
 {
   if(document.sel_bt.einsatz.options[i].selected == true)
    var sel_2=document.sel_bt.einsatz.options[i].value;
 }
}
else sel_2=0;
document.location.href=selfp+".php?res="+val1+"&br="+b+"&sprachID="+sprachID+"&fp="+fp+"&select_1="+sel_1+"&select_2="+sel_2;
}


/* Wechsel Selects bei Dokumente/Downlaods -----------------------------------------------------------------------*/
function change_dd(val1,val2)
{
var url = document.URL;
var selfp = url.substr(url.lastIndexOf("/")+1,(url.lastIndexOf(".php")-url.lastIndexOf("/")-1));
var sprachID = document.topform.sprachID.value;
var fp = document.topform.fp.value;
for(i=0;i<document.sel_bt.kategorie1.length;i++)
{
  if(document.sel_bt.kategorie1.options[i].selected == true)
   var sel_1=document.sel_bt.kategorie1.options[i].value;
}
if (val2==1)
	sel_2=0; 
else
	sel_2=document.sel_bt.kategorie2.value;

if (val2==3)
	sel_3=document.sel_bt.kategorie3.value;
else
	sel_3=0;
	
document.location.href=selfp+".php?res="+val1+"&br="+b+"&sprachID="+sprachID+"&fp="+fp+"&select_1="+sel_1+"&select_2="+sel_2+"&pnr="+sel_3;
}


/* Formular-Überprüfung --------------------------------------------------------------------------------------------*/
function checksuche() {
document.topform.pnr.value=0;
var searchstr=document.topform.SearchStr.value;
if (searchstr.length<3) 
{
alert("Der gesuchte Begriff muss mindestens 3 Zeichen beinhalten");
document.topform.SearchStr.focus();
return false;
}
else document.topform.submit();

}

/* Formular-Überprüfung --------------------------------------------------------------------------------------------*/
function checkrequired(which, MsgArr) {

var pass=true;
if (document.images) 
{
	for (i=0;i<which.length;i++) 
	{
		var tempobj=which.elements[i];
		//prüft korrekte E-Mail-Eingabe
		if (tempobj.name.indexOf("mail")!=-1 && (tempobj.value.indexOf("@")==-1 || tempobj.value.indexOf(".")==-1)) 
		{
			pass=false;
			break;
			tempobj.focus();
		}
		else if (tempobj.name.substring(0,3)=="req") 
		{
			if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==0)) 
			{
				pass=false;
				break;
			}
		}
	}
}
if (!pass) {
shortFieldName=tempobj.name.substring(3,30).toUpperCase();
if (shortFieldName.indexOf("KOMMENTAR")!=-1) alert (MsgArr["checkfield3"]);
else if (shortFieldName.indexOf("STELLE")!=-1) alert (MsgArr["checkfield4"]);
else alert(MsgArr["checkfield1"]+" \""+MsgArr[shortFieldName.toLowerCase()]+"\" "+MsgArr["checkfield2"]);
tempobj.focus();
return false;
}
else
return true;
}


/* Mail-Verschlüsselung umwandeln und mailto-Aufruf --------------------------------------------------------------------------*/
function callMail(adr) { 
	var adrArr=adr.split(";");
	var adrStr="";
	for(i=0; i<adrArr.length-1; i++)
	{
	 if (parseInt(adrArr[i])>=32 && parseInt(adrArr[i])<=126)
		adrStr += String.fromCharCode(parseInt(adrArr[i]));
	}

	document.location.href="mailto:"+adrStr;
}


function showPage(x)
{
	for(i=0;i<5;i++)
	{
		if(document.getElementById('page_'+i))
			document.getElementById('page_'+i).style.display="none";
	}		
	document.getElementById('page_'+x).style.display="block";
}