// START SCIPTS FOR NEW GLOBAL STYLE

function Fenster(Link,WinWidth,WinHeight,WindowName,posLeft,posTop) {
  newWindow=top.window.open(Link,WindowName,'toolbar=0,width='+WinWidth+',left=230,top=100,height='+WinHeight+',location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0');
  newWindow.focus();
}










// END SCIPTS FOR NEW GLOBAL STYLE

function _gel(obj_id) {
	return document.getElementById(obj_id);
}

function _geln(obj_id) {
	return document.getElementsByName(obj_id);
}

function openLayer(itemId){
	var myLayer = _gel(itemId);
	myLayer.style.display="block";
}

function closeLayer(itemId){
	var myLayer = _gel(itemId);
	myLayer.style.display="none";
}

// Function to calculate the correct cent and euro amount if it exceeds 99 cent
function correctCent(euro, cent) {
	if (cent > 99) {
		rest = cent % 100;
		add_euro = Math.floor(cent/100);

		return new Array(add_euro+euro,rest);
	} else
		return new Array(euro,cent);
}

// Check if value x is 0 - than add leading 0 for correct cent display
function leadingZero(x) {
	return (x>9)?x:'0'+x;
}

// Function opens/close one or two layer based on the same link
// changeLayer2 is optional and can be ignored for changing single objects
function changeLayer(changeLayer1, changeLayer2) {
	if(_gel(changeLayer1).style.display == "none") {
		_gel(changeLayer1).style.display = "inline";
	}
	else {
		_gel(changeLayer1).style.display = "none";
	}

	if(typeof changeLayer2 != 'undefined') {
		if(_gel(changeLayer2).style.display == "none") {
			_gel(changeLayer2).style.display = "inline";
		}
		else {
			_gel(changeLayer2).style.display = "none";
		}
	}
}

// Function changes text in an id-defined span-tag
function changeText(idText, changeText1, changeText2) {
	var statusContent = _gel(idText).innerHTML;

	if(statusContent == changeText1) {
		_gel(idText).innerHTML = changeText2;
	}
	else {
		_gel(idText).innerHTML = changeText1;
	}
}

// Function changes classname
function changeClass(idText, changeClass1, changeClass2) {
	var statusClass = _gel(idText).className;

	if(statusClass == changeClass1) {
		_gel(idText).className = changeClass2;
	}
	else {
		_gel(idText).className = changeClass1;
	}
}

// Function changes classname
function changeClassName(id, name) {
	_gel(id).className = name;
}

// Function changes the Price on the Product_detail Page if the radio-button is selected
function PriceChange(euro,cent) {
//	_gel('PriceTagRight').innerHTML = euro + ",<span class=\"superscriptCent\">" + cent + "</span>&nbsp;&euro;";
 	_gel('PriceTagDigits').innerHTML = euro + ",<span class=\"superscriptCent\">" + cent + "</span>&nbsp;&euro;";
}

// Function changes the Tarif-Link on the Product_detail Page if the radio-button is selected
function TarifChange(tarifname,tarifprice) {
	_gel('detailTarif').innerHTML = tarifname;
 	_gel('detailTarifPrice').innerHTML = tarifprice;

	if (tarifname == "") {
		_gel('tarifTag').style.visibility = "hidden";
		_gel('n_tb_2').style.visibility = "hidden";
		_gel('n_tb_3').style.visibility = "hidden";
	}
	else {
		_gel('tarifTag').style.visibility = "visible";
		_gel('n_tb_2').style.visibility = "visible";
		_gel('n_tb_3').style.visibility = "visible";
	}
}

// Function changes the Recommended Tarif on the Product_detail Page if the radio-button is selected
/*
function TarifEmpfehlung(value) {
	try{
		for (i=1;i<99;i++){
			_gel('tb_et_'+i).className = "TabBoxContentTarif TabBoxContent_hidden";
		}
	} catch(e){}

	if ( value != "" )
		_gel('tb_'+value).className = "TabBoxContentTarif TabBoxContent_visible";
}
*/

// Function for TabBox to selected different tabs
function tabBoxSwitch(obj_id, tabbox_name) {
	var n = _gel(tabbox_name);
	var t = n.getElementsByTagName('div');
	for (var i = 0; i < t.length; i++) {
		if ( t[i].className == "TabBoxContent_visible" )
			t[i].className = "TabBoxContent_hidden";
		else if ( t[i].className == "current" )
			t[i].className = "none";
	}
	_gel('n_'+obj_id).className = "current";
	_gel('c_'+obj_id).className = "TabBoxContent_visible";
}

 // Open a centered popup
 // <a href="fehlerseite.html" onClick="return openPopup('moduleP3A_var1.html',this.target,'628','451')">Modul P3A Var 1</a>
function openPopup(url,wName,w,h) {
	var wl = (screen.width-w)/2;
	var wt = (screen.height-h)/2;
	var params  ='height='+h+',width='+w+',top='+wt+',left='+wl;
	params +=",scrollbars,resizable";
	popWin = window.open(url, wName, params);
	return false;
}

function popup_zentriert(url, name, width, height, parms) {
   var left = Math.floor( (screen.width - width) / 2);
   var top = Math.floor( (screen.height - height) / 2);
   var winParms = "top=" + top + ",left=" + left + ",height=" + height + ",width=" + width;
   if (parms) { winParms += "," + parms; }
   var win = window.open(url, name, winParms);
   if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

// If open, close. If closed open. This function assumes first item is open at start
function toggleMe(itemId){
	// by default, first item is expanded and the rest are collapsed
	var myLayer = _gel("item"+itemId);
	if(myLayer.style.display=="none" || (myLayer.style.display=="" && itemId!=1)){
		myLayer.style.display="block";
		_gel("arr"+itemId).src=arrowDownObj.src;
	}
	else{
		myLayer.style.display="none";
		_gel("arr"+itemId).src=arrowRightObj.src;
	}
}

// If open, close. If closed open. This function assumes NO items are open at start
function toggleMe2(itemId){
	var myLayer = _gel("item"+itemId);
	if(myLayer.style.display=="none" || myLayer.style.display==""){
		myLayer.style.display="block";
		_gel("arr"+itemId).src=arrowDownObj.src;
	}
	else{
		myLayer.style.display="none";
		_gel("arr"+itemId).src=arrowRightObj.src;
	}
}

// If open, close. If closed, open. This function assumes ALL items are open at start
function toggleMe3(itemId){
	var myLayer = _gel("item"+itemId);
	if(myLayer.style.display=="block" || myLayer.style.display==""){
		myLayer.style.display="none";
		_gel("arr"+itemId).src=arrowRightObj.src;
	}
	else{
		myLayer.style.display="block";
		_gel("arr"+itemId).src=arrowDownObj.src;
	}
}

// Will open a hidden object/div passed as expandId and hide another object/div passed as collapseId
function expand(expandId,collapseId){
	_gel(expandId).style.display="block";
	_gel(collapseId).style.display="none";
}

// Basic functions for rollover effects
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
