function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2) {var x = Math.round(num * Math.pow(10,dec));if (x >= 0) n1=n2='';var y = (''+Math.abs(x)).split('');var z = y.length - dec; if (z<0) z--; for(var i = z; i < 0; i++) y.unshift('0');y.splice(z, 0, pnt); while (z > 3) {z-=3; y.splice(z,0,thou);}var r = curr1+n1+y.join('')+n2+curr2;return r;}

function f(dokument,width,height) {
	d = new Date();
	var z = d.getTime();
	window.open(dokument,z,"width="+width+",height="+height+
	",screenX=100,screenY=100,dependent=yes,resizable=no,"+
	"menubar=no,toolbar=no,status=no,location=no,scrollbars=yes");
	}

function testUrl(str) {
	if (str=='' || str=='http://') return;
	var r = /^[a-z0-9]+:[/]{2}[^/]/i;
	if (!r.test(str)) str = 'http://'+str;
	window.open(str);
	}

function printSpecial(divId,ueberschrift,style) {
	var style = style;
	var gAutoPrint = true; // Flag for whether or not to automatically call the print function
	if (document.getElementById != null) {
		if (!style || style == '') {
			var html = '\n<html>\n<head>\n<title>Adomino Domainvermietung</title>\n<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\n<script language="JavaScript" src="global.js"></script>\n<link href="print.css" rel="stylesheet" type="text/css">\n</head>\n<body>\n<div id="container"><h1>'+ueberschrift+'</h1>';
		}
		else if (style == 'main') {
			var html = '\n<html>\n<head>\n<title>Adomino Domainvermietung</title>\n<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\n<script language="JavaScript" src="global.js"></script>\n<link href="style.css" rel="stylesheet" type="text/css">\n<link href="printmain.css" rel="stylesheet" type="text/css">\n</head>\n<body>\n<div id="container"><h1>'+ueberschrift+'</h1>';
		}
		var printReadyElem = document.getElementById(divId); 
			if (printReadyElem != null && (!style || style == '')) {
				html += printReadyElem.innerHTML.replace(/<[/]?a[^>]*>/gi,'');
				html += '\n</div>\n</body>\n</html>'
			} 
			else if (printReadyElem != null) {
				html += printReadyElem.innerHTML.replace(/<[/]?a[^>]*>/gi,'').replace('setDomainDetailsPrep(true);','').replace('setDomainDetails(\'t30d\', true, "t9","t100","t1d","tx");','');
				html += '\n</div>\n</body>\n</html>'
			} 
		else { 
			alert("Could not find the printReady section in the HTML"); return;
			}
		var printWin = window.open("","printSpecial"); 
		printWin.document.open(); 
		printWin.document.write(html); 
		printWin.document.close(); 
		if (gAutoPrint) printWin.print(); 
	}
	else print();
}

//DomainDetails
function setDomainDetailsPrep(istFrei) {
	p1 = new Image();  p1.src = 'img/katList/warenkorb.gif';
	p2 = new Image();  p2.src = 'img/katList/warenkorbI.gif';
	p3 = new Image();  p3.src = 'img/katList/flex.gif';
	p4 = new Image();  p4.src = 'img/katList/flexI.gif';
//	p3 = new Image();  p3.src = 'img/katList/flex'+(flexA ? '' : 'I')+'.gif';
	frei = istFrei;
	}

var frei;
var wantShowLoadingBox;
function setDomainDetails(fg,a,i1,i2,i3,i4) {
	//switch button image
	var gr = 'warenkorb';
	wantShowLoadingBox = false;
	if (document.preselection.tx) {
		if (document.preselection.tx.checked==true) {
			wantShowLoadingBox = true;
			gr = 'flex';
			}
		}
	img = new Image();  img.src = 'img/katList/'+gr+(frei ? '' : 'I')+'.gif';
	document.mieten.src=img.src;
	if (a) {
		if (document.getElementById('addToCartPreselection')) {
			document.getElementById('addToCartPreselection').style.display = '';
			}
		if (document.getElementById('addToCartKostenberechnung')) {
			document.getElementById('addToCartKostenberechnung').style.display = 'none';
			}
		}
	else {
		if (document.getElementById('addToCartPreselection')) {
			document.getElementById('addToCartPreselection').style.display = 'none';
			}
		if (document.getElementById('addToCartKostenberechnung')) {
			document.getElementById('addToCartKostenberechnung').style.display = '';
			}
		}
	
	//BackgroundColor
	document.getElementById('domKatDetailRow-'+fg).style.backgroundImage='url(img/katList/domKatDetailRowBg.gif)';
	//document.getElementById('domKatDetailCol6-'+fg).style.backgroundColor='transparent';
	document.getElementById('domKatDetailCol6-'+fg).style.backgroundImage='url(img/katList/domKatDetailColBg.gif)';

	if (document.getElementById('domKatDetailRow-'+i1)) {
		document.getElementById('domKatDetailRow-'+i1).style.backgroundImage='';
		document.getElementById('domKatDetailCol6-'+i1).style.backgroundColor='';
		document.getElementById('domKatDetailCol6-'+i1).style.backgroundImage='none';
		}


	if (document.getElementById('domKatDetailRow-'+i2)) {
		document.getElementById('domKatDetailRow-'+i2).style.backgroundImage='';
		document.getElementById('domKatDetailCol6-'+i2).style.backgroundColor='';
		document.getElementById('domKatDetailCol6-'+i2).style.backgroundImage='none';
		}
		
	if (document.getElementById('domKatDetailRow-'+i3)) {
		document.getElementById('domKatDetailRow-'+i3).style.backgroundImage='';
		document.getElementById('domKatDetailCol6-'+i3).style.backgroundColor='';
		document.getElementById('domKatDetailCol6-'+i3).style.backgroundImage='none';
		}
		
	if (document.getElementById('domKatDetailRow-'+i4)) {
		document.getElementById('domKatDetailRow-'+i4).style.backgroundImage='';
		document.getElementById('domKatDetailCol6-'+i4).style.backgroundColor='';
		document.getElementById('domKatDetailCol6-'+i4).style.backgroundImage='none';
		}
	}

function setDomainDetails2(fg, a) {
	if (fg=='tx') setReiterGoto('kost');
	if (fg=='p8') setReiterGoto('p8');

	//switch button image
	var gr = 'warenkorb';
	wantShowLoadingBox = false;
	if (document.preselection.tx) {
		if (document.preselection.tx.checked==true) {
			wantShowLoadingBox = true;
			gr = 'flex';
			}
		}
	if (document.preselection.p8) {
		if (document.preselection.p8.checked==true) {
			wantShowLoadingBox = true;
			gr = 'p8';
			frei = true;
			}
		}
	img = new Image();  img.src = 'img/katList/'+gr+(frei ? '' : 'I')+'.gif';
	document.mieten.src=img.src;
	if (a) {
		if (document.getElementById('addToCartPreselection')) {
			document.getElementById('addToCartPreselection').style.display = '';
			}
		if (document.getElementById('addToCartP8')) {
			document.getElementById('addToCartP8').style.display = 'none';
			}
		if (document.getElementById('addToCartKostenberechnung')) {
			document.getElementById('addToCartKostenberechnung').style.display = 'none';
			}
		}
	else {
		if (fg=='tx') {
			if (document.getElementById('addToCartPreselection')) {
				document.getElementById('addToCartPreselection').style.display = 'none';
				}
			if (document.getElementById('addToCartKostenberechnung')) {
				document.getElementById('addToCartKostenberechnung').style.display = '';
				}
			}
		if (fg=='p8') {
			if (document.getElementById('addToCartPreselection')) {
				document.getElementById('addToCartPreselection').style.display = 'none';
				}
			if (document.getElementById('addToCartP8')) {
				document.getElementById('addToCartP8').style.display = '';
				}
			}
		}
	
	//BackgroundColor
	document.getElementById('domKatDetailRow-'+fg).style.backgroundImage='url(img/katList/domKatDetailRowBg.gif)';
	//document.getElementById('domKatDetailCol6-'+fg).style.backgroundColor='transparent';
	document.getElementById('domKatDetailCol6-'+fg).style.backgroundImage='url(img/katList/domKatDetailColBg.gif)';

	var rows = new Array('t9', 't100', 't1d', 't30d', 'tx', 'tf', 'p8');
	while (rows.length>0) {
		var row = rows.pop();
		if (row==fg) continue;
		if (document.getElementById('domKatDetailRow-'+row)) {
			document.getElementById('domKatDetailRow-'+row).style.backgroundImage='';
			document.getElementById('domKatDetailCol6-'+row).style.backgroundColor='';
			document.getElementById('domKatDetailCol6-'+row).style.backgroundImage='none';
			}
		}
	}

var valReiterGoto = 'kost';
function setReiterGoto(str) { 
	valReiterGoto = str;
	}

function reiterGoto() {
	return valReiterGoto;
	}

function checkShowLoadingBox() {
	if(wantShowLoadingBox){
		if (valReiterGoto!='') r = valReiterGoto;
		else r = 'kost'; 
		showLoadingBox();
	}
}

function radioValue(e) {
	for (i = 0; i<e.length; i++) {
		if (e[i].checked) return e[i].value;
		}
	return false;
	}


function showLoadingBox() {
	var imgPreLoad = new Image();
	imgPreLoad.src = 'img/loading/loadingAni.gif';

	switch (r) {
		case 'stat':
		case 'statj':
			document.getElementById('loadingText').innerHTML = 'Statistiken werden geladen';
			break;
		case 'det':
			document.getElementById('loadingText').innerHTML = 'Domain-Details werden geladen';
			break;
		case 'kost':
			document.getElementById('loadingText').innerHTML = 'Kostenberechnung wird geladen';
			break;
		case 'p8':
			document.getElementById('loadingText').innerHTML = 'Seite wird geladen';
			break;
		default:
			document.getElementById('loadingText').innerHTML = 'Seite wird geladen';
			break;
	}

	if (navigator.appName == "Microsoft Internet Explorer") {
		var loadingBoxTop = document.body.scrollTop+'px';
		var loadingBoxLeft = document.body.scrollLeft+'px';
	}
	else {
		//var loadingBoxTop = '';
		var loadingBoxTop = window.pageYOffset+'px';
		var loadingBoxLeft = window.pageXOffset+'px';
	}
	if (navigator.appName == "Microsoft Internet Explorer") {
		var loadingBoxInnerTop = (document.body.clientHeight/2)+document.body.scrollTop+'px';
		var loadingBoxInnerLeft = (document.body.clientWidth/2)+document.body.scrollLeft+'px';
	}
	else {
		//var loadingBoxInnerTop = '';
		var loadingBoxInnerTop = (window.innerHeight/2)+window.pageYOffset+'px';
		var loadingBoxInnerLeft = (window.innerWidth/2)+window.pageXOffset+'px';
	}

	document.getElementById('loadingBox').style.top = loadingBoxTop;
	document.getElementById('loadingBox').style.left = loadingBoxLeft;
	document.getElementById('loadingBoxInner').style.top = loadingBoxInnerTop;
	document.getElementById('loadingBoxInner').style.left = loadingBoxInnerLeft;

	//document.body.style.overflow = 'hidden';
	//document.body.style.paddingRight = '16px';
	if(document.getElementById('sliderFlash') && document.getElementById('sliderFlashInactive')) {
		document.getElementById('sliderFlash').style.display = 'none';
		document.getElementById('sliderFlashInactive').style.display = 'block';
	}
	document.getElementById('loadingBox').style.display = 'block';
	document.getElementById('loadingBoxInner').style.display = 'block';
	if (navigator.appName == "Microsoft Internet Explorer" && document.getElementById('selKat') && document.getElementById('selKatScreen')) {
		document.getElementById('selKat').style.display = 'none';
		document.getElementById('selKatScreen').style.display = 'block';
		}
	}

function TransNum(Wert) { //Komma durch Punkt ersetzen
	var PosPunkt = Wert.indexOf(".",0);
	var PosKomma = Wert.indexOf(",",0);
	if (PosKomma < 0) PosKomma = Wert.length;
	
	while ((0 <= PosPunkt) && (PosPunkt < PosKomma)) {
		Wert = Wert.substring(0, PosPunkt) + Wert.substring(PosPunkt + 1, Wert.length);
		PosPunkt = Wert.indexOf(".",0);
		PosKomma--;
	}
	
	PosKomma = Wert.indexOf(",",0);
	if (PosKomma >= 0) {
		Wert = Wert.substring(0, PosKomma) + "." + Wert.substring(PosKomma + 1, Wert.length);
	}
	
	return parseFloat(Wert);
}
  
function setKontoData(mwst) {
	var kontoErhFormBetrag = TransNum(document.kontoErh.kontoBetrag.value);
/*	var kontoErhFormBetragMwSt = kontoErhFormBetrag/100*20;	*/
/*	var kontoErhFormBetragGesamt = kontoErhFormBetrag*1.2;	*/
	var kontoErhFormBetragMwSt = kontoErhFormBetrag*mwst;
	var kontoErhFormBetragGesamt = kontoErhFormBetrag+kontoErhFormBetragMwSt;

	if (document.kontoErh.kontoBetrag.value!='' && (kontoErhFormBetrag<9.90 || kontoErhFormBetrag>10000 || isNaN(kontoErhFormBetrag))) {
		document.getElementById('kontoErhFormBetrag').style.color='#DD1C1C';
		document.getElementById('kontoBetrag').style.color='#DD1C1C';
		document.getElementById('kontoBetrag').style.borderColor='#DD1C1C';
		document.getElementById('comment').style.color='#DD1C1C';
		}
	else {
		document.getElementById('kontoErhFormBetrag').style.color='';
		document.getElementById('kontoBetrag').style.color='';
		document.getElementById('kontoBetrag').style.borderColor='';
		document.getElementById('comment').style.color='';
		}
	
	if (isNaN(kontoErhFormBetrag) && document.kontoErh.kontoBetrag.value!='') {
			document.getElementById('kontoErhFormBetrag').innerHTML = 'ungültige Zahl';
			if (mwst>0) document.getElementById('kontoErhFormBetragMwSt').innerHTML = '-';
			document.getElementById('kontoErhFormBetragGesamt').innerHTML = '<span style="font-weight:normal">-</span>';
	}
	else if (document.kontoErh.kontoBetrag.value=='') {
			document.getElementById('kontoErhFormBetrag').innerHTML = '&euro; 0,00';
			if (mwst>0) document.getElementById('kontoErhFormBetragMwSt').innerHTML = '&euro; 0,00';
			document.getElementById('kontoErhFormBetragGesamt').innerHTML = '&euro; 0,00';
	}
	else {
		document.getElementById('kontoErhFormBetrag').innerHTML = formatNumber(kontoErhFormBetrag,2,'.',',','€ ','','');
		if (mwst>0) document.getElementById('kontoErhFormBetragMwSt').innerHTML = formatNumber(kontoErhFormBetragMwSt,2,'.',',','€ ','','');
		document.getElementById('kontoErhFormBetragGesamt').innerHTML = formatNumber(kontoErhFormBetragGesamt,2,'.',',','€ ','','');
		
		document.getElementById('kontoN').value = kontoErhFormBetrag;
		document.getElementById('kontoMwSt').value = kontoErhFormBetragMwSt;
		document.getElementById('kontoB').value = kontoErhFormBetragGesamt;
	}
}


