
var btn_pre_src = "";

function actimg(img_name) {
	if (document.images["btn_"+ img_name]) {
		btn_pre_src = document.images["btn_"+ img_name].src;
		document.images["btn_"+ img_name].src = eval("btn_"+ img_name +"_on").src;
	}
}

function deactimg(img_name) {
	if (document.images["btn_"+ img_name]) {
		if (btn_pre_src=="") btn_pre_src = eval("btn_"+ img_name +"_off").src;
		document.images["btn_"+ img_name].src = btn_pre_src;
		btn_pre_src = "";
	}
}


function openimgwin(imgurl) {
	imgwin=window.open(imgurl, "cgbigimg", "top=10,left=10,width=600,height=580,scrollbars=yes,resizable=yes")
}

function openglossar(searchterm) {
	window.open("../shop/glossar.asp?t="+searchterm, "cgglossar", "width=360,height=260,scrollbars=yes");
}

function openpictures(id) {
	window.open("../shop/bilder.asp?id="+ id, "ipcglossar", "width=580,height=470,scrollbars=yes,resizable=yes");
}

function openmsjumppage() {
	window.open("/shop/msgjp.asp", "msjumppage", "top=50,left=50,width=900,height=580,scrollbars=yes,resizable=yes");
}


function hl(elem) {
	if (elem.style) elem.style.backgroundColor="#ffffff";
}

function dl(elem) {
	if (elem.style) elem.style.backgroundColor="";
}


function ekpopup(param) {
	var strParam = "";
	if (param.length>0) var strParam = "?"+ param;
	window.open("/shop/popup.asp"+ strParam, "_blank", "dependent=yes, width=440, height=260, menubar=no, location=no, resizable=no, scrollbars=no, status=no, toolbar=no");
}


var btn_produkte_off = new Image(); btn_produkte_off.src = "/gfx/btn_produkte_off.gif";
var btn_produkte_on = new Image(); btn_produkte_on.src = "/gfx/btn_produkte_on.gif";
var btn_service_off = new Image(); btn_service_off.src = "/gfx/btn_service_off.gif";
var btn_service_on = new Image(); btn_service_on.src = "/gfx/btn_service_on.gif";
var btn_kontakt_off = new Image(); btn_kontakt_off.src = "/gfx/btn_kontakt_off.gif";
var btn_kontakt_on = new Image(); btn_kontakt_on.src = "/gfx/btn_kontakt_on.gif";
var btn_vertriebspartner_off = new Image(); btn_vertriebspartner_off.src = "/gfx/btn_vertriebspartner_off.gif";
var btn_vertriebspartner_on = new Image(); btn_vertriebspartner_on.src = "/gfx/btn_vertriebspartner_on.gif";
var btn_company_off = new Image(); btn_company_off.src = "/gfx/btn_company_off.gif";
var btn_company_on = new Image(); btn_company_on.src = "/gfx/btn_company_on.gif";
var btn_neukunden_off = new Image(); btn_neukunden_off.src = "/gfx/btn_neukunden_off.gif";
var btn_neukunden_on = new Image(); btn_neukunden_on.src = "/gfx/btn_neukunden_on.gif";



/*
	Klasse ImageToggler (für automatisierte Dia-Show)
*/

function ImageToggler_addImage(url) {
	this.imageList[this.imageList.length] = url;
}

function ImageToggler_run() {
	if (this.imageList.length>0) {
		if (document.all && document.images[this.imageName].filters) document.images[this.imageName].filters.blendTrans.Apply();
		document.images[this.imageName].src = this.imageList[this.nextImage];
		if (document.all && document.images[this.imageName].filters) document.images[this.imageName].filters.blendTrans.Play();
		
		this.nextImage++;
		if (this.nextImage>=this.imageList.length) this.nextImage = 0;
	}
	window.setTimeout(this.variableName +'.run();', this.duration);
}

function ImageToggler(varname, imagename, duration) {
	this.variableName = varname;
	this.imageName = imagename;
	this.imageList = new Array();
	this.nextImage = 0;
	if (duration) this.duration = duration; else this.duration = 5000;
	
	this.addImage = ImageToggler_addImage;
	this.run = ImageToggler_run;
	this.run();
}



/*
	Microsoft "genuine Windows"-Tooltip Code
*/

/* 
Netscape 4, Ice, Escape, Omniweb 4.2- 
    if( document.layers ) 

Explorer 4+, Opera 6+, iCab, Ice, Omniweb 4.2- 
    if( document.all ) 	

Mozilla, Explorer 5+, Opera 5+, Konqueror, Safari, iCab, Ice, OmniWeb 4.5 
    if( document.getElementById ) 
*/
var divLayer = 'genuineTooltip';
var mouseX   = 0;
var mouseY   = 0;

var arrTimers = new Array(21);
arrTimers[0] = 0;


if( document.layers ) 
{
	document.captureEvents( Event.MOUSEMOVE );
}

document.onmousemove = GetCursor; 


function GetCursor( e ) 
{
	if( document.layers ) 
	{
		mouseX = e.pageX;
		mouseY = e.pageY;
	}
	else if( document.all ) 
	{
		mouseX = event.clientX + document.body.scrollLeft;
		mouseY = event.clientY + document.body.scrollTop;
	}
	else if( document.getElementById )
	{
	    mouseX = e.pageX;
		mouseY = e.pageY;
	}
	
	var tip = GetHandle( "imageToolTip" );
	if (arrTimers[0] == 0 &&
			(	(document.layers && tip.visibility == "show") ||
				(document.all && tip.visibility == "visible") ||
				(document.getElementById && tip.visibility == "visible"))
		)
	{
		tip.left = mouseX;
		tip.top  = mouseY + 24;
	}
	
	
	return true;
}

function GetHandle( name ) 
{
	if( document.layers ) 
	{
		return ( document.layers[name] );
	}
	
	if( document.getElementById ) 
	{
	    return document.getElementById( name ).style;
	}
	
	if( document.all ) 
	{
		var block = eval( 'document.all.' + name + '.style' );
		
		return ( block );
	}
	
}

function ShowToolTip() 
{
	var tip = GetHandle( divLayer );
	
	tip.left = mouseX;
	tip.top  = mouseY + 20;
	
	if( document.layers )
	{
		tip.visibility = "show";
	}
	else if( document.all )
	{
		tip.visibility = "visible";
	}
	else if( document.getElementById )
	{
	    tip.visibility = "visible";
	}
}

function HideToolTip()
{
	window.setTimeout( 'HideToolTip2(\''+ divLayer +'\')', 4000 );	
}

function HideToolTip2(name)
{
	var tip = GetHandle( name );
	
	if( document.layers )
	{
		tip.visibility = "hide";
	}
	else if( document.getElementById )
	{
	    tip.visibility = "hidden";
	}
	else if( document.all )
	{
		tip.visibility = "hidden";
	}
}



function ShowImageToolTip(url)
{
	var tip = GetHandle( "imageToolTip" );
	
	tip.left = mouseX;
	tip.top  = mouseY + 24;
	
	for (var i = 0; i<arrTimers.length; i++)
	{
		window.clearTimeout(arrTimers[i]);
		arrTimers[i] = 0;
	}
	
	document.images["imageToolTipImg"].src = url;
	
	if( document.layers )
	{
		tip.visibility = "show";
	}
	else if( document.getElementById )
	{
		tip.visibility = "visible";
		document.getElementById("imageToolTip").className = 'o100';
	}
	else if( document.all )
	{
		tip.visibility = "visible";
	}
}

function HideImageToolTip2(name)
{
	var tip = GetHandle( name );
	
	if( document.layers )
	{
		tip.visibility = "hide";
	}
	else if( document.getElementById )
	{
	    tip.visibility = "hidden";
	}
	else if( document.all )
	{
		tip.visibility = "hidden";
	}
	
	arrTimers[0] = 0;
}

function HideImageToolTip()
{
	if (document.getElementById)
	{
		fadeOut("imageToolTip");
	}
	else
	{
		arrTimers[0] = window.setTimeout( 'HideImageToolTip2(\'imageToolTip\')', 500 );
	}
}


function fadeOut(name)
{
	var step = 20;
	
	arrTimers[0] = window.setTimeout("document.getElementById('"+ name +"').className = 'o100'", step*1);
	arrTimers[1] = window.setTimeout("document.getElementById('"+ name +"').className = 'o095'", step*2);
	arrTimers[2] = window.setTimeout("document.getElementById('"+ name +"').className = 'o090'", step*3);
	arrTimers[3] = window.setTimeout("document.getElementById('"+ name +"').className = 'o085'", step*4);
	arrTimers[4] = window.setTimeout("document.getElementById('"+ name +"').className = 'o080'", step*5);
	arrTimers[5] = window.setTimeout("document.getElementById('"+ name +"').className = 'o075'", step*6);
	arrTimers[6] = window.setTimeout("document.getElementById('"+ name +"').className = 'o070'", step*7);
	arrTimers[7] = window.setTimeout("document.getElementById('"+ name +"').className = 'o065'", step*8);
	arrTimers[8] = window.setTimeout("document.getElementById('"+ name +"').className = 'o060'", step*9);
	arrTimers[9] = window.setTimeout("document.getElementById('"+ name +"').className = 'o055'", step*10);
	arrTimers[10] = window.setTimeout("document.getElementById('"+ name +"').className = 'o050'", step*11);
	arrTimers[11] = window.setTimeout("document.getElementById('"+ name +"').className = 'o045'", step*12);
	arrTimers[12] = window.setTimeout("document.getElementById('"+ name +"').className = 'o040'", step*13);
	arrTimers[13] = window.setTimeout("document.getElementById('"+ name +"').className = 'o035'", step*14);
	arrTimers[14] = window.setTimeout("document.getElementById('"+ name +"').className = 'o030'", step*15);
	arrTimers[15] = window.setTimeout("document.getElementById('"+ name +"').className = 'o025'", step*16);
	arrTimers[16] = window.setTimeout("document.getElementById('"+ name +"').className = 'o020'", step*17);
	arrTimers[17] = window.setTimeout("document.getElementById('"+ name +"').className = 'o015'", step*18);
	arrTimers[18] = window.setTimeout("document.getElementById('"+ name +"').className = 'o010'", step*19);
	arrTimers[19] = window.setTimeout("document.getElementById('"+ name +"').className = 'o005'", step*20);
	arrTimers[20] = window.setTimeout("HideImageToolTip2('"+ name +"');", step*21);
}


function show_listentext(posnr) {
	document.getElementById("listenText"+posnr).style.display="block";
	document.getElementById("detailText"+posnr).style.display="none";
	
}

function show_detailtext(posnr) {
	document.getElementById("detailText"+posnr).style.display="block";
	document.getElementById("listenText"+posnr).style.display="none";
}


function show_alt_Lieferadresse(id)
{
	$("#alt"+id).show();
	$("#neu"+id).hide();
}

function show_neu_Lieferadresse(id)
{
	$("#neu"+id).show();
	$("#alt"+id).hide();
}

function hide_divs(id)
{
	$("#neu"+id).hide();
	$("#alt"+id).hide();
}


/* Konfigurator */

var externalShop = false;
var percentVAT = 0;

function extend(preis,showplus) {
	preis=(Math.round(preis*100)/100).toString();
	preis=preis.replace(/\./,",");
	var pos=preis.indexOf(",");
	if (pos>=0) {
		if (preis.indexOf(",")==preis.length-2) preis+="0";
	} else {
		preis=preis+",00"
	}
	if (preis.length>7 || (preis.charAt(0)!='-' && preis.length>6)) preis=preis.substr(0,preis.length-6)+"."+preis.substring(preis.length-6,preis.length);
	if (showplus && preis.charAt(0)!=0 && preis.charAt(0)!="-") preis="+"+preis;
	return preis+" ";
}

function updateprice(elname) {
	var preis, linkid, preisausblenden, ges;
	
	if (document.forms["configform"].elements[elname].type=="checkbox") {
		preis = document.forms["configform"].elements[elname].checked ? document.forms["configform"].elements[elname].value : "0";
	} else {
		if (document.forms["configform"].elements[elname].options) {
//			Opera 6 can't handle property selectedIndex !
//			preis = document.forms["configform"].elements[elname].options[document.forms["configform"].elements[elname].selectedIndex].value;
			for (var i=0; i<document.forms["configform"].elements[elname].options.length; i++)
				if (document.forms["configform"].elements[elname].options[i].selected) {
					preis = document.forms["configform"].elements[elname].options[i].value;
				}
			
			linkid = preis.substr(0, preis.indexOf("|"));
			if (linkid!="" && document.forms["configform"].elements["altimg_"+ linkid])
				document.images["setimg"].src="images\\"+document.forms["configform"].elements["altimg_"+linkid].value;
			
			var parent = $(document.forms["configform"].elements[elname].parentNode);
			parent.children("div.hinwtext").remove();
			
			if (linkid!="" && document.forms["configform"].elements["hinwtxt_"+ linkid])
				parent.append("<div class=\"hinwtext\">" + document.forms["configform"].elements["hinwtxt_"+ linkid].value + "<\/div>");
		} else {
			preis=document.forms["configform"].elements[elname].value;
		}
	}
	
	preisausblenden = (preis.substr(preis.indexOf("|")+1, 1) == "X");
	
	if (document.forms["configform"].elements["a"+elname]) {
		preis = preis.substr(preis.lastIndexOf("|")+1, preis.length);
		document.forms["configform"].elements["a"+elname].value=preis;
		
		if (document.forms["configform"].elements["dummy_a"+elname])
			if (preis!=0) {
				if (!preisausblenden || externalShop) document.forms["configform"].elements["dummy_a"+elname].value = "€ "+extend(preis,true);
				else document.forms["configform"].elements["dummy_a"+elname].value = "Systempreis";
			} else {
				document.forms["configform"].elements["dummy_a"+elname].value="";
			}
	}
	
	
	ges = 0;
	for (var i=0; i<document.forms["configform"].elements.length; i++)
		if (document.forms["configform"].elements[i].name.substr(0,2)=="ak")
			ges+=parseFloat(document.forms["configform"].elements[i].value);
	
	if (document.forms["configform"].gesp) document.forms["configform"].gesp.value=extend(ges, false);
	if (document.forms["configform"].ust) document.forms["configform"].ust.value = extend(ges*percentVAT, false);
	if (document.forms["configform"].brutto) document.forms["configform"].brutto.value = extend(ges*(1+percentVAT), false);
}

function firstcalc() {
	for (var i=0; i<document.forms["configform"].elements.length; i++)
		if (document.forms["configform"].elements[i].name.charAt(0)=="k") updateprice(document.forms["configform"].elements[i].name);
	updateprice("ak0");
}
