// System- & Browserabfrage

var is = new Object();
{
	is.ver = navigator.appVersion.substring(0,1);

	if (navigator.appName == "Netscape")
	{
		is.ns = true;
		eval("is.ns" + is.ver + " = true;")
		if (is.ver >= 3 && is.ver <= 4)
			is.ng3 = true;
		if (is.ver > 4)
			is.ng5 = true;
	}
	else if (navigator.appName.indexOf("Microsoft") >= 0)
	{
		is.ie = true;
		eval("is.ie" + is.ver + " = true;")
		if (is.ver >= 3)
			is.ig3 = true;
	}
	else
		is.bu = true;

	if (navigator.appVersion.indexOf("Win") > 0)
		is.win = true;
	else if (navigator.appVersion.indexOf("Mac") > 0)
		is.mac = true;
	else if (navigator.appVersion.indexOf("X11") > 0)
		is.x11 = true;
	else
		is.osu = true;
}

// Navi-Highlight-Bilder vorladen
if (document.images)
{
  var stuff = new imgs
  (
	""
  )
}

// Preloads images ;-)
function imgs()
{
	this.length = imgs.arguments.length;
	for (var i = 0; i < this.length; i++)
  	{
		this[i+1] = new Image();
		this[i+1].src = imgs.arguments[i];
    }
}

// BildTausch / Button-Highlights
function SwapImage()
{
	args_images_SFI = SwapImage.arguments;
	args_images_SFI[1].src = args_images_SFI[0];
}

// Layer ausblenden
function hideLayer(layer_name)
{
	if (is.ns){
		if(is.ng5 && document.getElementById(layer_name)){ document.getElementById(layer_name).style.visibility = "hidden"; }
		if(is.ng3 && document.layers[layer_name]){ document.layers[layer_name].visibility = "hide"; }
	}
	else{
		if(document.all[layer_name]){
			document.all[layer_name].style.visibility = "hidden";
		}
	}
}

// Layer einblenden
function showLayer(layer_name)
{
	if (is.ns){
		if(is.ng5 && document.getElementById(layer_name)){ document.getElementById(layer_name).style.visibility = "visible"; }
		if(is.ng3 && document.layers[layer_name]){ document.layers[layer_name].visibility = "show"; }
	}
	else{
		if(document.all[layer_name]){
			document.all[layer_name].style.visibility = "visible";
		}
	}
}

function showHelpLayer(e,layer_name)
{
	var screen_X = 0;
	var screen_Y = 0;

	screen_X = (is.ns) ? e.pageX : event.clientX + document.body.scrollLeft;
	screen_Y = (is.ns) ? e.pageY : event.clientY + document.body.scrollTop;

	screen_X = screen_X - 155;
	screen_Y = screen_Y - 5;

	if (is.ns){
		if(is.ng5 && document.getElementById(layer_name)){
			document.getElementById(layer_name).style.top = screen_Y;
			document.getElementById(layer_name).style.left = screen_X;
		}
		if(is.ng3 && document.layers[layer_name]){
			document.layers[layer_name].top = screen_Y;
			document.layers[layer_name].left = screen_X;
		}
	}
	else{
		if(document.all[layer_name]){
			document.all[layer_name].style.top = screen_Y;
			document.all[layer_name].style.left = screen_X;
		}
	}

	showLayer(layer_name);
}

// Allgemeingültiger PopUp-Aufruf
// BSP für Funktionsaufruf: <a href="Javascript:popWin('http://www.arcor.de','1','400','200')">Link</a>
// der Wert '1' steht für scrollbares Popup! Kann auch '0' sein, für nicht scrollbares Popup!

var wFlag;

function popWin(sUrl,bScroll,winW,winH,title,winPosx,winPosy,winToolbar,winStatus,winResizeable,winMenubar,winLocation)
{
	if(winPosx			== null){winPosx = 20;}
	if(winPosy			== null){winPosy = 20;}
	if(winToolbar		== null){winToolbar = 0;}
	if(winStatus		== null){winStatus = 0;}
	if(winResizeable	== null){winResizeable = 1;}
	if(winMenubar		== null){winMenubar = 0;}
	if(winLocation		== null){winLocation = 0;}

	if(title == null)
	{
		title = document.location.href;
		endpos = title.lastIndexOf("?");
		if (endpos > 0)
			title = title.substring(0, endpos-1);
		slashpos = title.lastIndexOf("/");
		if (slashpos<0)
		{
		   title = "undef";
		}
		else
		{
		    title = title.substring(slashpos+1,title.length);
			endpos = title.indexOf(".");
			if (endpos>=0)
			{
				title = title.substring(0,endpos-1);
			}
		}
	}

	sTmp	=	"width="		+ winW			+
				",height="		+ winH			+
				",scrollbars="	+ bScroll		+
				",status="		+ winStatus		+
				",left="		+ winPosx		+
				",top="			+ winPosy		+
				",resizable="	+ winResizeable	+
				",toolbar="		+ winToolbar	+
				",menubar="		+ winMenubar	+
				",location="	+ winLocation;

	if(!window.newWin || window.newWin.closed || wFlag != title)
	{
		window.newWin = window.open(sUrl,title,sTmp);
	}
    else{
		window.newWin.close();
		window.newWin = null;
		window.newWin = window.open(sUrl,title,sTmp);
    }
	window.newWin.focus();
	wFlag = title;
}

function popWinTab(sUrl,bScroll,ix,iy)
{
	popWin(sUrl,bScroll,ix,iy);
}

function openPopuphilfe(myurl,mytitle,mytype)
{
	if ((mytitle == null) || (mytype == null))
		//popWin(myurl,'1','796','600','hilfe','','','1');
		window.open(myurl,'hilfe').focus();
	else
		openWindow(myurl,mytitle,mytype);
}

function Extern_CityLocator_dsl(bereich,daten,produkt){
	var adr = NG_UFIX+"/privat/asb_forward_pop.jsp?style=";

	if(bereich=="privat"){
		if(produkt == "isdn") var style = "isdnshop";
		else var style = "dslshop";
		var winW = '796';
		var winH = '522';
	}
	else{
		if(produkt == "isdn"){
			var style = "isdnentgk";
			var winH = '580';
		}else{
			var style = "dslentgk";
			var winH = '580';
		}
		var winW = '592';
	}

	adr += style;
	if(daten) adr += daten;

	window.open(adr);
}

function Extern_CityLocator_isdn(bereich,daten){
	Extern_CityLocator_dsl(bereich,daten,'isdn');
}

// extern/intern_track als Javascriptfunktion

function tryGetVariable(variable)
{
  var tmpVar="";

  if(is.ns && is.ver>=5 || is.ie && is.ver>=4 || is.bu) {
    eval("try { tmpVar="+variable+"; } catch(ex){ }");
  } else {
    // this may fail
    eval("tmpVar="+variable);
  }

  return tmpVar;
}

function internTrack(path,name,popup)
{
  var kat=tryGetVariable("pageKat");
  var ufix=tryGetVariable("NG_UFIX");

  if(popup==null) {
    popup=false;
  }

  if(path.indexOf(ufix)==0) {
  	path = path.substring(ufix.length,path.length);
  }

  var URL=ufix+"/home/intern_track.php?path="+escape(path)+"&name="+escape(name)+"&kat="+escape(kat);

  if(popup) {
    window.open(URL);
  } else {
    document.location.href=URL;
  }
}

function externTrack(u, name, popup)
{
  var kat=tryGetVariable("pageKat");

  if(popup==null) {
    popup=false;
  }

  var URL="/home/extern_track.php?url="+escape(u)+"&name="+escape(name)+"&kat="+escape(kat);

  if(popup) {
    window.open(URL);
  } else {
    document.location.href=URL;
  }
}

function btTrack(bID,wmID,wtID,affID,name,popup)
{
  if(popup==null) {
    popup=false;
  }

  var path="/beemto/servlet/beemClick?beemID="+escape(bID)+"&wmID="+escape(wmID)+"&wtID="+escape(wtID)+"&affID="+escape(affID);

  internTrack(path, name, popup);
}

function cpTrack(bID,tracking,name,popup)
{
  if(popup==null) {
    popup=false;
  }

  var path="/beemto/servlet/beemClick?beemID="+escape(bID)+"&"+tracking;

  internTrack(path, name, popup);
}

// classTausch, z.B. bei Tabellen
function SwapClass(obj,newClass)
{
	if (!is.ng3){
		obj.className = newClass;
	}
}

function changeClass(obj,newClass)
{
	document.getElementById(obj).className = newClass;
}

// arcor business
function checkBusinessSuchesubmit()
{
	if( document.selecterBusinessSuche.selectBusinessSucheOptions.value != 'none')
	{
		document.selecterBusinessSuche.action = NG_UFIX +
						document.selecterBusinessSuche.selectBusinessSucheOptions.value;
		document.selecterBusinessSuche.submit();
	}
}

// IE-Formular-Button-Highlight
ieButtonHover = function() {
	var INPUTs = document.getElementsByTagName("input");
	for (i=0; i<INPUTs.length; i++) {
		INPUTs[i].onmouseover = function() {
			if (this.getAttributeNode("class").nodeValue.search("back") != -1)
				this.className += " back_h";
			else if (this.getAttributeNode("class").nodeValue.search("top") != -1)
				this.className += " top_h";
			else if (this.getAttributeNode("class").nodeValue.search("red") != -1)
				this.className += " red_h";
			else if (this.getAttributeNode("class").nodeValue.search("button") != -1)
				this.className += " button_h";
		}
		INPUTs[i].onmouseout = function() {
			this.className = this.className.replace(new RegExp(" button_h"), "");
			this.className = this.className.replace(new RegExp(" back_h"), "");
			this.className = this.className.replace(new RegExp(" top_h"), "");
			this.className = this.className.replace(new RegExp(" red_h"), "");
		}
	}
}
if(window.attachEvent) window.attachEvent("onload", ieButtonHover);


function SwapTab(obj,content) {
	var TabBox = obj.parentNode.parentNode.id;
	var TabBoxNav = document.getElementById(TabBox).getElementsByTagName("li");

	for (i=0; i<TabBoxNav.length; i++) {
		TabBoxNav[i].className = TabBoxNav[i].className.replace("on","");
		if(content)
		{
			var cDiv = document.getElementById(content+(i+1));
			cDiv.className = cDiv.className.replace(new RegExp("show"), "hide");
			if(TabBoxNav[i] == obj.parentNode) cDiv.className = cDiv.className.replace(new RegExp("hide"), "show");
		}
	}

	obj.parentNode.className = "on";
	if(TabBoxNav[0] == obj.parentNode) TabBoxNav[0].className = "on first on-first";
	else TabBoxNav[0].className = "first";
}