//<!--

function setNamedItemClass(id, classname) {
	var el
	el = document.getElementById(id);
	if (el) {
		//el.setAttribute('class',classname);
		el.className = classname;
	}
}

function LBF()
{
	document.getElementById("passtxt").style.display = "none";
	document.getElementById("headerinputpasswd").style.display = "inline";
	document.getElementById("headerinputpasswd").focus();
}
	
function LBE()
{
	if(document.getElementById("headerinputpasswd").value == '')
	{
		document.getElementById("headerinputpasswd").style.display = "none";
		document.getElementById("passtxt").style.display = "inline";
	}
}

var ipbopen=false;
function ipbasketclick(){
		var img = null;
		var imageopen="/gifs/basket/open.gif";
		var imageclose="/gifs/basket/close.gif";
		img = document.getElementById("ipopener");
		if (img){
			if (ipbopen){
				img.src=imageopen;	
				ipbopen=false;
				cC('BT','ipbasketdetail','ipbasketitemsc');
			}else{
				img.src=imageclose;
				cC('BT','ipbasketdetail','ipbasketitemso');
				ipbopen=true;
			}
		}
}
	function ipbasketclose(){
		var img = null;
		var imageopen="../gifs/basket/open.gif";
		var imageclose="../gifs/basket/close.gif";
		img = document.getElementById("ipopener");
		if (ipbopen){
			img.src=imageopen;	
			ipbopen=false;
			cC('BT','ipbasketdetail','ipbasketitemsc');
		}
}
// Alte funktionen

var calcIt = true; /* Finanzierungspreise selbst berechnen oder Übergabeparameter verwenden? */

function setText(node, text) {
	if (node.nodeType==3) {
		var newnode=document.createTextNode(""+text);
		node.parentNode.replaceChild(newnode, node);
		alert("nodeType 3");
	} else {
		var childs=node.childNodes;
		for (var i=0; i<childs.length; i++) setText(childs[i],text);
		alert("nodeType "+ node.nodeType);
	}
}

function setPrice(container, price) {
	var childs=container.childNodes;
	// alten preis killen:
	//for (var i=0; i<childs.length; i++) {
	//	container.removeChild(childs[i]);
	//}
	while (childs.length > 0) {
		container.removeChild(childs[0]);
	}
	var ch;
	var result = "";
	for (var i=0; i<price.length; i++) {
		ch = price.charAt(i);
		if (ch==",") ch="komma";
		if (ch==".") ch="punkt";
		if (ch=="-") ch="strich";
		result += ch;
		//var newNode = document.createNode(1, "imgxy", "");
		var newNode = document.createElement("img");
		var newAttr = document.createAttribute("src");
		newAttr.nodeValue = "/gifs/2008/ziffern/klein/" + ch + ".jpg";
		newNode.setAttributeNode(newAttr);
		container.appendChild(newNode);
	}
	//alert("nodeType "+ container.nodeType + ":" + price + "->" + result);
}


function calcFinancing(price, month, price24, price36, price48) {
	var financingPrice = "";
	var addPrice = 0;
	if (calcIt) {
		//if ((month-0)==06) { addPrice = ((price/100)*4.29); }
		if ((month-0)==12) { addPrice = ((price/100)* 5.2075619 ); }
		if ((month-0)==24) { addPrice = ((price/100)* 10.16970  ); }
		if ((month-0)==36) { addPrice = ((price/100)* 15.2804162); }
		if ((month-0)==48) { addPrice = ((price/100)* 20.5390213); }
		// Monatsrate auf 10ct abrunden:
		financingPrice = ((price + addPrice)/month);
		financingPrice = financingPrice.toFixed(2).replace(",","").replace("\.",",");
	}else {
		if ((month-0)==24) { financingPrice = price24; }
		if ((month-0)==36) { financingPrice = price36; }
		if ((month-0)==48) { financingPrice = price48; }
	}
	//alert(month+"/"+(price/100)+"/" + addPrice + "/"+financingPrice+"/12.20/"+((price/100)*12.20));
	var textNode=document.getElementById("financing_price");
	if (textNode!=null) {
		//financingPrice = financingPrice + " €";
		setText(textNode,financingPrice);
	}
	// alert(financingPrice)
}
function calcFinancing_eff(price, month, financingRatePercent) {
	var financingPrice = "";
	var mZF =0.5;
	var eJZ = financingRatePercent; 
	if (eJZ == 0.0) {
		financingPrice = price / month;
	} else {
		mZF =Math.pow((eJZ/100.0+1.0),(1./12.0));
		financingPrice = price*((Math.pow(mZF,month))/(Math.pow(mZF,month)-1))*(mZF-1);
	}
	financingPrice = financingPrice.toFixed(2).replace(",","").replace("\.",",");
	var priceNode=document.getElementById("financing_price"); 
	if (priceNode!=null) {
		//financingPrice = financingPrice + " €";
		setPrice(priceNode,financingPrice);
		//alert("setText:" + financingPrice);
	} else {
		//alert("nö");
	}
}

//	JAVASCRIPT für EMPFEHLUNGS-POPUP
var wnd
function showFinanPopUp(month)
{
	/*
	if (wnd != null)  wnd.close();
	if (month == 6){
		wnd=window.open('','Finanpopup','width=350,height=60,status=no,scrollbars=no,resizable=no');
		wnd.focus();
		wnd.document.write('<span style="font-family: Verdana, Arial, sans serif;font-size:12px;"><b>Finanzierungswochen bei Avitos!</b> <br><br>Vom 01.05. - 30.06.05 bieten wir Ihnen den Aktionszins von nur 3,9% an.</span>')
		wnd.document.close();	
		}else if(month == 12){
		wnd=window.open('','Finanpopup','width=350,height=60,status=no,scrollbars=no,resizable=no');
		wnd.focus();
		wnd.document.write('<span style="font-family: Verdana, Arial, sans serif;font-size:12px;"><b>Finanzierungswochen bei Avitos!</b> <br><br>Vom 01.05. - 30.06.05 bieten wir Ihnen den Aktionszins von nur 9,9% an.</span>')

	}
	*/
}
function open_recommendationpopup(product_code) {
	var wnd=window.open('/shop/recommend.asp?product_group=100&product_code='+product_code,'sendrecommendation','width=520,height=560,status=yes,scrollbars=yes,resizable=yes');
	wnd.focus();
}
//	Javascript für Agenten-Popup
function open_agentpopup(product_code) {
	var wnd=window.open('/shop/agents.asp?product_group=100&product_code='+product_code,'agentwindow','width=390,height=555,status=yes,scrollbars=yes,resizable=yes');
	wnd.focus();
}
//	Javascript für FAQ Frage Popup	
function open_popup( popup_url, popup_windowname, width, height) {
	var wnd=window.open(popup_url,popup_windowname,'width=' + width + ',height=' + height + ',status=yes,scrollbars=yes,resizable=yes');
	wnd.focus();
}
var targetWin ;
function targetLink(URL)
{
    /* if (targetWin) {
		targetWin.Document.close;
	}*/
    targetWin = open(URL,"na_detail","resizable=yes,width=330,height=550,left=10,top=10");
}
function evalComp(product_code, pgroup_id)
{
	var comp_str;
	var targetWin ;
	var nw = new Date(); 
	
	comp_str="?compare=" + product_code + "&product_group=" + pgroup_id + "&id=" + nw.getMinutes() + nw.getSeconds()

	targetWin = open("pcompare.asp" + comp_str, "na_compare","resizable=yes,width=700,height=400,left=1,top=1,scrollbars=yes");
   targetWin.focus();
   
   return false;
}
function showAvailablePage()
{
	targetWin = open("/shop/ext/Lieferfaehigkeit.html", "availibility", "width=400,height=250,left=320,top=120,scrollbars=yes");
   targetWin.focus();
   
   return false;
}

//Image wechseln bei MosuseOver
function flipImage (imgid, src) {
	img = document.getElementById(imgid);
	if (img) {
		img.src = src;
	}
}



// -->