umz_lo='#FFFFFF';
umz_hi='#B9CFDE';
umz_delHi='#F00000';
umz_id=0;
umz_vol=0;
umz_aKat=new Array();
umz_aColor=new Array();
umz_aDelColor=new Array();

function umz_dec2hex(dec){
var hex='';
var h=Math.floor(dec/16);
if (h>=10)hex+=String.fromCharCode(h+55);else hex+=h.toString();
var h=dec-h*16;
if (h>=10)hex+=String.fromCharCode(h+55);else hex+=h.toString();
return hex;
}

function umz_hex2dec(hexColor){
var bgcolor=hexColor.toUpperCase();
aHex=new Array();
aHex['0']=0;
aHex['1']=1;
aHex['2']=2;
aHex['3']=3;
aHex['4']=4;
aHex['5']=5;
aHex['6']=6;
aHex['7']=7;
aHex['8']=8;
aHex['9']=9;
aHex['A']=10;
aHex['B']=11;
aHex['C']=12;
aHex['D']=13;
aHex['E']=14;
aHex['F']=15;
if (bgcolor.substring(0,4)!='RGB('){
	bgcolor=bgcolor.replace(/[^0-9ABCDEF]/g,'');
	if(bgcolor.length==3){bgcolor=bgcolor.substring(0,1)+bgcolor.substring(0,1)+bgcolor.substring(1,2)+bgcolor.substring(1,2)+bgcolor.substring(2,3)+bgcolor.substring(2,3)}
	while(bgcolor.length<6)bgcolor+='0';
	var temp='';
	for(var k=0;k<5;k+=2){
		var wert=aHex[bgcolor.substring(k,k+1)]*16+aHex[bgcolor.substring(k+1,k+2)];
		temp+=wert;
		if(k<4)temp+=',';
	}
	bgcolor=temp;
}
else{
	bgcolor=bgcolor.replace(/[^0-9,]/g,'');
}
return bgcolor
}

function umz_computeVerlauf(von,nach,steps,sGlobalArray){
var aIst=umz_hex2dec(von).split(',');
var aSoll=umz_hex2dec(nach).split(',');
var aDiff=new Array();
var globalArray=eval(sGlobalArray);
for(var c=0;c<=2;c++){
aIst[c]=parseInt(aIst[c]);
aSoll[c]=parseInt(aSoll[c]);
aDiff[c]=aSoll[c]-aIst[c]
}
for (var d=0;d<=steps;d++){
	globalArray[d]='#'+umz_dec2hex(aIst[0]+Math.floor(1.0*d*aDiff[0]/steps))+umz_dec2hex(aIst[1]+Math.floor(1.0*d*aDiff[1]/steps))+umz_dec2hex(aIst[2]+Math.floor(1.0*d*aDiff[2]/steps));
}
}

function umz_reset(){
document.getElementById('umz_basket').innerHTML='<ul><div></div></ul>';
umz_vol=0;
document.getElementById('umz_vol').innerHTML=String(Math.round(umz_vol/100000.0)/10.0).replace('.',',');
return false;
}

function umz_fade(nr){
var el=document.getElementById('umz_'+nr);
var colNr=el.getAttribute('umzCol');
if(colNr>0){
	el.style.backgroundColor=umz_aColor[colNr];
	colNr--;
	el.setAttribute('umzCol',colNr);
	setTimeout('umz_fade('+nr+')',40);
}
else{
	el.style.backgroundColor=umz_aColor[0];
}
}

function umz_delfade(nr){
var el=document.getElementById('umz_'+nr);
var colNr=el.getAttribute('umzDel');
if(colNr>0){
	el.style.color=umz_aDelColor[colNr];
	colNr-=2;
	el.setAttribute('umzDel',colNr);
	if(colNr>=0)el.style.height=colNr+'px';
	setTimeout('umz_delfade('+nr+')',40);
}
else{
	el.style.color=umz_aDelColor[0];
	var korb=document.getElementById('umz_basket').firstChild.firstChild;
	korb.removeChild(el);
}
}

function umz_ovDoc(evt){
evt = (evt) ? evt : ((window.event) ? window.event : "");
var el = (evt.target) ? evt.target : evt.srcElement;
if (el.getAttribute('umzBHT')){
	el.style.backgroundColor=umz_hi;
}
if (el.getAttribute('umzDel')==null&&el.getAttribute('umzBHTneu')){
	el.style.color=umz_delHi;
}
}

function umz_ouDoc(evt){
evt = (evt) ? evt : ((window.event) ? window.event : "");
var el = (evt.target) ? evt.target : evt.srcElement;
if (el.getAttribute('umzBHT'))el.style.backgroundColor=umz_lo;
if (el.getAttribute('umzDel')==null&&el.getAttribute('umzBHTneu'))el.style.color='#000000';
}

function umz_clDoc(evt){
evt = (evt) ? evt : ((window.event) ? window.event : "");
var el = (evt.target) ? evt.target : evt.srcElement;

if (el.getAttribute('umzBHT')){

var sBHT=el.getAttribute('umzBHT');
var aBHT=sBHT.split('x');
var korb=document.getElementById('umz_basket').firstChild.firstChild;
var li = el.cloneNode(true);
var bht=li.getAttribute('umzBHT');
li.removeAttribute('umzBHT');
li.setAttribute('umzBHTneu',bht);
li.setAttribute('umzCol',20);
li.setAttribute('id','umz_'+(umz_id++));
li.innerHTML=li.innerHTML+' ('+bht+' cm)';
var newLi=korb.appendChild(li);
document.getElementById('umz_basket').scrollTop=document.getElementById('umz_basket').firstChild.offsetHeight;
umz_fade(li.getAttribute('id').slice(4));
umz_vol+=aBHT[0]*aBHT[1]*aBHT[2];
document.getElementById('umz_vol').innerHTML=String(Math.round(umz_vol/100000.0)/10.0).replace('.',',');
}

if (el.getAttribute('umzDel')==null&&el.getAttribute('umzBHTneu')){
var aBHT=el.getAttribute('umzBHTneu').split('x');
el.setAttribute('umzDel',18);
umz_delfade(el.getAttribute('id').slice(4));
umz_vol-=aBHT[0]*aBHT[1]*aBHT[2];
document.getElementById('umz_vol').innerHTML=String(Math.round(umz_vol/100000.0)/10.0).replace('.',',');
}

}


function umz_ssDoc(evt){
evt = (evt) ? evt : ((window.event) ? window.event : "");
var el = (evt.target) ? evt.target : evt.srcElement;
if (el.getAttribute('umzBHT'))return false;
if (el.getAttribute('umzBHTneu')!=null)return false;
}

function umz_init(){
if (document.getElementById){
umz_computeVerlauf(umz_lo,umz_hi,20,'umz_aColor');
umz_computeVerlauf(umz_lo,umz_delHi,20,'umz_aDelColor');
document.onmouseover = umz_ovDoc
document.onmouseout = umz_ouDoc
document.onclick = umz_clDoc
document.onselectstart = umz_ssDoc
}
}
