document.charset="utf-8";
var oe=function(Fehler,Datei,Zeile){alert('Es ist der JS- Fehler: '+Fehler+', in der Datei: '+Datei+', in der Zeile: '+Zeile+'Aufgetreten.');};
var oe2=function(){return true;};
window.onerror=oe2;// Wenn Projekt fertig, bitte auf oe2 setzen. Mit der Funktion oe wird das errorhandlich auf "scharf" gestellt. und fehler werden als alerts ausgegeben
window.opera = window.opera;
window.$GLOBALS = {};
$GLOBALS.hiddens = [];
$GLOBALS.tmr = null;
$GLOBALS.maxArrays = [];
$GLOBALS.IE = false;
$GLOBALS.IE6 = false;
$GLOBALS.IE7 = false;
$GLOBALS.IE8 = false;
$GLOBALS.toolTipps = null;
$GLOBALS.maxInhouds = 5;
$GLOBALS.checkedInputs = [];
if(navigator.appVersion.match(/MSIE/)&&!navigator.appVersion.match(/Macintosh/)&&!opera&&!navigator.appVersion.match(/Konqueror/)){
	$GLOBALS.IE=true;
	if(navigator.appVersion.match(/MSIE 6/))$GLOBALS.IE6 = true;
	if(navigator.appVersion.match(/MSIE 7/))$GLOBALS.IE7 = true;
	if(navigator.appVersion.match(/MSIE 8/))$GLOBALS.IE8 = true;
}
function _(id, Doc) {
	return typeof id == 'string' ? (Doc||document).getElementById(id) : id == 'object' ? id : null;
};
var _T = function(Tag,Parent)
{// TOM:: Hiermit zieht man bestimmte tags als Objekte, auch mit Angabe eines bestimmten Parents möglich
	Tag=Tag?Tag:'*';
	return ((Tag=='*') && !document.getElementsByTagName('*').length)?(Parent||document).all:(Parent||document).getElementsByTagName(Tag);
}
var _C = function(className, Tag)
{// TOM:: Hiermit zieht man alle tags mit einem bestimmten className als Objekte, auch mit Angabe eines bestimmten Tags möglich
    var muster = new RegExp("(^| )" + className + "($| )");
    var alles = _T();
    var gefunden = [];
	for(i=0;i<alles.length;i++){
		if (alles[i].tagName && (alles[i].tagName.toLowerCase() == Tag) && alles[i].className && (alles[i].className != "")) {
            if (alles[i].className.match(muster)) {
                gefunden[gefunden.length] = alles[i];
			}
        }
	}
    return gefunden;
};
function _A(Obj)
{
	// TOM:: Hiermit konvertiert man zu einem Array, zB aus nem Objectrange ein Array machen, damit man alle funktionen eines Arrays sicher anwenden kann..
	var ret = [];
	for(var i=0;i<Obj.length;i++){
		ret[i] = Obj[i];
	}
	return ret;
}
function makeHiddenField(Form,Name,Value){
	if(_(Name)){
		var myHidd = _(Name);
	}
	else{
		var myHidd=Form.appendChild($GLOBALS.IE==true?document.createElement('<INPUT TYPE=HIDDEN />'):document.createElement('input'));
		if(!$GLOBALS.IE){
			myHidd.setAttribute('type','hidden');
		}
		myHidd.id=Name;
		myHidd.name=Name;
	}
	myHidd.value=Value;
}
function openCenteredWindow(url, n, w, h) {
	var l = (screen.availWidth / 2) - (w / 2);
	var t = (screen.availHeight / 2) - (h / 2);
	return openWindow(url, n, w, h, l, t);
};
function openWindow(url, n, w, h, l, t, s) {
	if(l == undefined) l = 200;
	if(t == undefined) t = 100;
    if(s == undefined) s = 'no';

	var params = new Array();

	if(w > 0) params.push('width='  + w);
	if(h > 0) params.push('height=' + h);
	params.push('left=' + l);
	params.push('top='  + t);

	params.push('location=no');
	params.push('statusbar=no');
	params.push('scrollbars=' + s);
	return window.open(url, n+ Math.round(Math.random() * 100000), params.join(','));
};
// Bestellformular abschicken
function send_form(id, action, target)
{
	$(id).value = action;
	var frm = $(id).form;
	if(target != undefined) {
		frm.action = target;
	}
	if(typeof frm.onsubmit == 'function')frm.onsubmit();else frm.submit();
};
// Lieferadresse ausgrauen	#1
function disable()
{
if ($('CheckoutUseBillingAddress').checked)
	{
	$('ShippingAddressCompany').disabled=true;
	$('ShippingAddressSalutation').disabled=true;
	$('ShippingAddressForename').disabled=true;
	$('ShippingAddressSurname').disabled=true;
	$('ShippingAddressStreet').disabled=true;
	$('ShippingAddressStreetNr').disabled=true;
	$('ShippingAddressZipcode').disabled=true;
	$('ShippingAddressCity').disabled=true;
	$('ShippingAddressCountry').disabled=true;
	}
else
	{
	$('ShippingAddressCompany').disabled=false;
	$('ShippingAddressSalutation').disabled=false;
	$('ShippingAddressForename').disabled=false;
	$('ShippingAddressSurname').disabled=false;
	$('ShippingAddressStreet').disabled=false;
	$('ShippingAddressStreetNr').disabled=false;
	$('ShippingAddressZipcode').disabled=false;
	$('ShippingAddressCity').disabled=false;
	$('ShippingAddressCountry').disabled=false;
	}
};
// Lieferadresse ausgrauen #2
function disable_update()
{
	$('ShippingAddressSalutation').disabled=true;
	$('ShippingAddressForename').disabled=true;
	$('ShippingAddressSurname').disabled=true;
	$('ShippingAddressStreet').disabled=true;
	$('ShippingAddressStreetNr').disabled=true;
	$('ShippingAddressZipcode').disabled=true;
	$('ShippingAddressCity').disabled=true;
	$('ShippingAddressCountry').disabled=true;
};
// Produktansicht: Bild aufpoppen
function zoom(id, width, height)
{
	window.open('/images/' + id + '/' + width + 'x' + height + '.jpg', 'PopUp', 'left=300, top=50,width=' + width + ',height=' + height + ',status=no,scrollbars=no,resizable=yes');
};
// IE form submit ohne submit-Button fixen und für alle anderen ohne submit UND ohne image Button, wobei Textarea ein
// Return haben darf und es wird geschaut, ob es ein form onsubmit="... gibt, wenn ja wird dann dieser auch ausgeführt
// ...und das auch für die Beriche, wo kein Mootools eingebunden ist, die  wir langsam nach und nach entfernen sollten.
function addInputSubmitEvent(form) {
    if($GLOBALS.IE){    
        form.onkeydown = function(e) {
            e = window.event;
            if (e.keyCode == 13) {
            	if(e.srcElement.tagName == 'TEXTAREA'){
            		return true;
            	}
                if(typeof form.onsubmit == 'function')form.onsubmit(); else form.submit();
                return false;
            }
        };
    }
    else{
    	form.onkeydown = function(e) {
            if (e.keyCode == 13) {
            	if(e.target.tagName == 'TEXTAREA'){
            		return true;
            	}
		    	var is_submit_tag = false;
		    	for(var i=0;i<_A(form.elements).length;i++){
		    		var El = _A(form.elements)[i];
		    		if((El.type == 'image') || (El.type == 'submit')){
		    			is_submit_tag = true;
		    		}
		    	}
		    	if(!is_submit_tag){
		    		var input = new Element('input', {
						'type' : 'submit',
						styles: {
							'display'  	: 'none'
						}
					}).inject(form);
		    		return true;
		    	}
            }
    	};
    }
};
function str2float(num)
{// TOM:: hat die gleich Funktionalität wie die UserIO::str2float, nur js seitig
	num = num + '';
	return num.indexOf(',') != -1 ? num.replace(/\./g,'').replace(',','.') * 1 : num * 1;
}
function float2str(num)
{// TOM:: hat die gleich Funktionalität wie die UserIO::float2str, nur js seitig
	num+= '';
	if(num.indexOf(',') != -1 ) return num;
	num*=1;
	num = num.toFixed(2);
	num+= '';
	var num2 = num.substr(num.length-2);
	var num1 = num.substring(0,num.length-3);
	var ctr = 0;
	var num3 = '';
	for(var i=num1.length-1;i>=0;i--){
		ctr++;
		num3+=num1.substr(i,1);
		if(ctr%3==0 && i>0){
			num3+='.';
		}
	}
	num1 = '';
	for(i=num3.length-1;i>=0;i--){
		num1+=num3.substr(i,1);
	}
	return num1 + ',' + num2;
}
/*position of the tooltip relative to the mouse in pixel */
var offsetx = 20;
var offsety =  8;
function newelement(newid)
{
    if(document.createElement)
    {
        var el = document.createElement('div');
        el.id = newid;
        with(el.style)
        {
            display = 'none';
            position = 'absolute';
        }
        el.innerHTML = '&nbsp;';
        document.body.appendChild(el);
    }
};
var ie5 = (document.getElementById && document.all);
var ns6 = (document.getElementById && !document.all);
var ua = navigator.userAgent.toLowerCase();
var isapple = (ua.indexOf('applewebkit') != -1 ? 1 : 0);
function getmouseposition(e)
{
    if(document.getElementById)
    {
        var iebody=(document.compatMode &&
        document.compatMode != 'BackCompat') ?
        document.documentElement : document.body;
        pagex = (isapple == 1 ? 0:(ie5)?iebody.scrollLeft:window.pageXOffset);
        pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset);
        mousex = (ie5)?event.x:(ns6)?clientX = e.clientX:false;
        mousey = (ie5)?event.y:(ns6)?clientY = e.clientY:false;

        var lixlpixel_tooltip = _('tooltip');
        lixlpixel_tooltip.style.left = (mousex+pagex+offsetx) + 'px';
        lixlpixel_tooltip.style.top = (mousey+pagey+offsety) + 'px';
    }
};
function tooltip(tip)
{
    if(!_('tooltip')) newelement('tooltip');
    var lixlpixel_tooltip = _('tooltip');
    lixlpixel_tooltip.innerHTML = tip;
    lixlpixel_tooltip.style.display = 'block';
    document.onmousemove = getmouseposition;
};
function exit()
{
    _('tooltip').style.display = 'none';
};
function checkAll(formId, fieldName, state) {
    var frm = _(formId);

    var inputs = frm.getElementsByTagName('input');

    for(var i=0; i < inputs.length; i++) {
        var inp = inputs[i];
        if(inp.name != fieldName) continue;

        inp.checked = state;
    }
};

if(window['addEvent'])window.addEvent('domready', function() {
	$GLOBALS.content = {};
	if(window!=window.top){
		$GLOBALS.content = $('content').clone();
		$each($$('body')[0].childNodes, function(Obj,ix){
			if((Obj!=undefined)){
				if(Obj.style){
					Obj.style.display = 'none';
				}
			}
		});
		$GLOBALS.content.style.padding = '10px';
		$GLOBALS.content.inject($$('body')[0]);
		$each($$('div.Navigation,h1'),function(Nav){
			Nav.style.display = 'none';
			if(Nav.getPrevious('p'))Nav.getPrevious('p').style.display = 'none';
		});
	}
	if($GLOBALS.IE6){
		document.body.style.behavior = 'url(/js/csshover3.htc);';
		$each($$('img.png,input.png'), function(img){
			img.style.behavior = 'url(/js/iepngfix.htc);';
		});
	}
 	$each($$('form'),function(Obj){addInputSubmitEvent(Obj);});
    var a = $$('a,input[type="button"],input[type="image"],input[type="submit"],input[type="radio"],input[type="checkbox"]');
    $each(a, function(Obj){
    	Obj.onmousedown = function()
		{
			this.onfocus = function()
			{
				this.blur();
			};
		};
		Obj.onmouseout = function()
		{
			this.onfocus = $empty;
		};
		Obj.onmousemove = Obj.onmouseout;
		Obj.style.cursor = 'pointer';
    });
	
	if($('registerform'))$('registerform').getElement('a.button.left').addEvent('click', function(){
		$('CustomerAddressZipcode').value = $('CustomerAddressZipcode').value.trim();
		if(($('CustomerAddressZipcode').value.length<5)||isNaN($('CustomerAddressZipcode').value*1)||($('CustomerAddressZipcode').value.indexOf('.')>-1)||($('CustomerAddressZipcode').value.indexOf('e')>-1)||($('CustomerAddressZipcode').value.indexOf('E')>-1)){
			alert('Bitte gebe eine korrekte Postleitzahl ein.');
			$('CustomerAddressZipcode').select();
			return false;
		}
		else{
			$('registerform').submit();
		}
	});
	if($('BillingAddressZipcode')&&$('addressform'))$('addressform').getElement('div.shipping a.button').addEvent('click', function(){
		$('BillingAddressZipcode').value = $('BillingAddressZipcode').value.trim();
		if(($('BillingAddressZipcode').value.length<5)||isNaN($('BillingAddressZipcode').value*1)||($('BillingAddressZipcode').value.indexOf('.')>-1)||($('BillingAddressZipcode').value.indexOf('e')>-1)||($('BillingAddressZipcode').value.indexOf('E')>-1)){
			alert('Bitte gebe eine korrekte Postleitzahl ein.');
			$('BillingAddressZipcode').select();
			return false;
		}
		else{
			send_form('CheckoutAction', 'proceed');return false;
		}
	});
	$GLOBALS.checkedProduct = null;
	$GLOBALS.checkedKreis = null;
	$each($$('div#chocolates div.image a'), function(bimg,j){
		if(j%2==0 && !bimg.className){
			bimg.className = 'hoverImages';
			$GLOBALS.checkedProduct = $(bimg.getElement('img').title.replace('schokolade','').replace(' Schokolade','').replace('ß','ss').toLowerCase());
		}
	});
	$each($$('div#chocolates div.image a'), function(aimg,i){
		if (i % 2 == 0) {
			aimg.onmouseover = function(){
				this.style.zIndex = '1';
				$this = this;
				var next = this.getParent('div').getNext('div').getElement('a');
				next.style.zIndex = '2';
			};
			var next = aimg.getParent('div').getNext('div').getElement('a');
			next.onclick = function(){
				// Hier noch class dem aktiuellen wegenhemen und dem neuen berpassen!!!!
				$$('h1')[0].firstChild.data = this.getElement('img').title;
				$GLOBALS.checkedProduct.id = this.getElement('img').title.replace('schokolade','').replace(' Schokolade','').replace('ß','ss').toLowerCase();
				$GLOBALS.checkedProduct.firstChild.data = this.getElement('img').title;
				
				$('CartBack').value = this.href.replace('http://' + window.location.hostname,'');
				$('CartProductId').value = $('CartBack').value == '/p/Vollmilchschokolade.html' ? 1 : ($('CartBack').value == '/p/Zartbitterschokolade.html' ? 2 : ($('CartBack').value == '/p/Weisse-Schokolade.html' ? 3 : ('')));
				if($GLOBALS.checkedKreis)$GLOBALS.checkedKreis.src = $GLOBALS.checkedKreis.oldsrc;
				$GLOBALS.checkedKreis = this.getParent('div').getPrevious('div').getElement('img');
				$GLOBALS.checkedKreis.oldsrc = $GLOBALS.checkedKreis.src;
				$GLOBALS.checkedKreis.src = this.getElement('img').src;
				return false;
			};
			if(next.style.zIndex==2){
				next.onclick();
			}
			if(next.getParent('div').getNext('div.description'))next.getParent('div').getNext('div.description').getElement('a').onclick = function()
			{
				next.onclick();
				return false;
			}
		}
		else if (aimg.getParent('div').getPrevious('div').getElement('a').className){
			aimg.onmouseover = function(){
				this.onmouseout = function(){			
					this.style.zIndex = '1';
					$this = this;
					var prev = this.getParent('div').getPrevious('div').getElement('a');
					prev.style.zIndex = '2';
				}
			};
		}
	});
	$each($$('div#krassschoko img,div#schoko_laden img,div#schokoladen img,div#schokofaq img'), function(img){
		img.setStyle('cursor','pointer');
		img.onclick = function()
		{
			location.href = $(this).getNext('a').getProperty('href');
		}
	});
	$each($$('body#category a.mousehover_from_pic'), function(a){
		a.addEvent('mouseover', function(event){
			this.setStyle('z-index', '1');
			this.getParent('div').getNext('div').getElement('a').setStyle('z-index','2');
			this.getParent('div').getNext('div').getElement('a').onmouseout = function()
			{
				this.setStyle('zIndex','1');
				this.getParent('div').getPrevious('div').getElement('a').setStyle('zIndex','2');
			};
			this.getParent('div').getNext('div').getElement('a').onclick=function()
			{
				window.location.href = $(this).getParent('div.box').getElement('a.boxes').getProperty('href');
				return false;
			};
		});
	});
	if(window['focus_field'])focus_field();

	if($('price') && $priceArray){
		var inp = $$('form#productform input');
		$each(inp,function(Obj){
			if(Obj.getParent('div.konfigurator') && Obj.type != 'text'){
				Obj.onclick = changePrice;
			}
			else if(Obj.getParent('div.konfigurator')){
				Obj.onkeyup = changePrice;
			}
		});
		changePrice(-1);
	}
	if($('productform')){
		$each($$('form#productform div.konfigurator span,form#productform div.konfigurator a,form#productform div.konfigurator img'), function (Obj){
			Obj.style.cursor = 'pointer';
			if((Obj.className == 'name') || (Obj.className == 'check_the_box') || (Obj.className == 'thumb') || (Obj.className == 'price'))Obj.addEvent('click', function(){
				var check = $(this).getParent('div').getElement('input[type="checkbox"]');
				if (check && check.tagName) {
					check.checked = true;
					check.onclick();
					return false;
				}
			});
		});
	}
	if($$('div.cart div.box_middle tr div.main')[0] && $$('div.cart div.box_middle tr td.quantity input')[0]){
		$GLOBALS.myFx = [];
		$each($$('div.cart div.box_middle tr div.main'), function(Obj,i){
			$GLOBALS.myFx[i] = new Fx.Slide(Obj,{duration: 600,transition: Fx.Transitions.Pow.easeOut});
			if(document.URL.indexOf('cart/popup') === -1)$GLOBALS.myFx[i].hide();
			$this = Obj.getParent('tr').getPrevious('tr.product');
			if($this.getElement('td.description p'))$this.style.cursor = 'pointer';
			$this.addEvent('click', function(event)
			{
				if (!this.getElement('input[type="file"]')) {
					event.stop();
					$GLOBALS.myFx[i].toggle();
					if (this.getElement('td.description p')) 
						this.getElement('td.description p').style.backgroundPosition = $GLOBALS.myFx[i].open ? '120px 12px' : '120px -21px';
				}
			});
			$this.getElements('td.quantity a')[0].addEvent('click',function(event){
				var Inp = $(this).getParent('td').getElement('input[type="text"]');
				if(!Inp.value){
					if(confirm(window['javascript.inputs.really_delete_product'])){
						Inp.value = '0';
						send_form('CartAction', 'update');
					}
					else{
						Inp.value = '1';
					}
				}
				else{
					send_form('CartAction', 'update');
				}
				event.stop();
			});
			$this.getElements('td.quantity a')[1].addEvent('click',function(event){
				if(confirm(window['javascript.inputs.really_delete_product']))location.href=this.href;;
				event.stop();
			});
			$this.getElement('td.quantity input[type="text"]').addEvent('click',function(event){
				event.stop();
			});
		});
	}
	if($$('div.box_middle table.cart ul.side')[0]){
		$GLOBALS.myFx2 = [];
		$GLOBALS.myPrice = [];
		$each($$('div.box_middle table.cart ul.side'), function(Obj,i){
			$GLOBALS.myFx2[i] = new Fx.Slide(Obj,{duration: 600,transition: Fx.Transitions.Pow.easeOut});
			$GLOBALS.myFx2[i].hide();
			if($this = Obj.getParent('td').getElement('strong.group')){
				$this.style.cursor = 'pointer';
				$this.addEvent('click', function(event)
				{
					$GLOBALS.myFx2[i].toggle();
					this.style.backgroundPosition = $GLOBALS.myFx2[i].open ? '80px 6px' : '80px -27px';	
				});
			}
		});
	}
	if($$('div.cart table.cart td.quantity input[type="text"]')[0]){
		$each($$('div.cart table.cart td.quantity input[type="text"]'), function(Inp){
			Inp.addEvent('keyup', function(event){
				mindestens = 1;
				if ((hidden = this.getParent('td').getPrevious('td.description').getElement('span.hidden')) && hidden.firstChild && hidden.firstChild.data) {
					mindestens = hidden.firstChild.data;
				}
				if(event.key=='up'){
					if((this.value*1) >= 999){
						this.value = 999;
						return;
					}
					this.value = (this.value*1)+1+'';
				}
				if(event.key=='down'){
					this.value = (this.value*1)-1+'';
					if((hidden = this.getParent('td').getPrevious('td.description').getElement('span.hidden')) && hidden.firstChild  && hidden.firstChild.data){
						if(this.value < (hidden.firstChild.data*1)){
							this.value = hidden.firstChild.data;
							alert('Du musst mindestens ' + this.value + ' Stück von diesem Artikel einkaufen!');
						}
					}
				}
				if(this.value=='0'){
					this.value = !confirm(window['javascript.inputs.really_delete_product']) ? mindestens  : '0';
					if (this.value == 0) {
						this.form.submit();
					}
				}
				while(isNaN(this.value.trim()))this.value = this.value.substr(0,this.value.length-1);
			});
			Inp.addEvent('change', function(event){
				if((hidden = this.getParent('td').getPrevious('td.description').getElement('span.hidden')) && hidden.firstChild  && hidden.firstChild.data){
					if(this.value < (hidden.firstChild.data*1)){
						this.value = hidden.firstChild.data;
						alert('Du musst mindestens ' + this.value + ' Stück von diesem Artikel einkaufen!');
					}
				}
			});
		});
	}
	
	if ($$('body#schokoladen')[0] && $("zutaten")) {

		$GLOBALS.toolTipps = [];
		$GLOBALS.toolTipps[0] = new Tips('div.tooltip_zutaten', {
			className: 'tooltipp',
			offset: {
				y: -56
			}
		});
		$GLOBALS.toolTipps[1] = new Tips('span.tooltipp_hinweise',{className:'tooltipp',offset:{y:-56}});
		$GLOBALS.toolTipps[1].addEvent('show', function(tip, el){
			tip.getElement('div.tip-title').innerHTML = tip.getElement('div.tip-title').innerHTML.replace(/\n/g,'<br />');
			tip.hide();
			el.onclick = function()
			{
				tip.show();
				$$('div.tooltipp')[0].hide();
			};
		});
		$GLOBALS.toolTipps[1].addEvent('hide', function(tip, el){
			$$('div.tooltipp')[0].show();
		});
	}
	
	if(window.$tooltipArr){
		$GLOBALS.toolTipps = [];
		$GLOBALS.toolTipps[0] = new Tips('div.tooltip_zutaten',{className:'tooltipp',offset:{y:-56}});
		$GLOBALS.toolTipps[1] = new Tips('div.tooltipp_hinweise',{className:'tooltipp',offset:{y:-56}});
		$GLOBALS.toolTipps[1].addEvent('show', function(tip, el){
			tip.getElement('div.tip-title').innerHTML = tip.getElement('div.tip-title').innerHTML.replace(/\n/g,'<br />');
			tip.hide();
			el.onclick = function()
			{
				tip.show();
				$$('div.tooltipp')[0].hide();
			};
		});
		$GLOBALS.toolTipps[1].addEvent('hide', function(tip, el){
			$$('div.tooltipp')[0].show();
		});
	}
	if(window.pluginFunc)pluginFunc();
	if($$('div.konfigurator')[0] && $('komponenten')){
		var myTitle = '';
		$each($$('div.konfigurator'), function(Obj){
			if(Obj.title && (Obj.title = Obj.title.trim())){
				myTitle = Obj.title;
				var inputs = Obj.getElements('input[type="radio"],input[type="checkbox"]');
				$each(inputs, function(inp){
					if(inp.checked){
						var div = new Element('div',{'class': myTitle});
						var h2 = new Element('h2',{title: myTitle, styles : {'color':'#444444','margin':'5px 0 0','background':'url(/img/icons/bg_config_img.gif) 0 1px no-repeat','padding-left':'12px'}});
						//h2.innerHTML = myTitle.replace('_pppp_','&#x2B;').replace('_klamuf_','&#x28;').replace('_klamzu_','&#x29;').replace('_nbsp_',' ').replace('_komma_',',').replace('_onquot_',"'").replace(/\_(.*?)\_/g,'&$1;') + ':';
						div.inject($('komponenten').getElement('div'));
						h2.inject(div);
						var iDiv =  new Element('div',{'title': myTitle});
						iDiv.inject(div);
						var span = new Element('span', {styles : {'display' : 'block'}});
						span.innerHTML = '1 x ' + inp.getNext('span').firstChild.data;
						span.inject(iDiv);
						h2.style.cursor = 'pointer';
					}
				});
			}
		});
	}
	$GLOBALS.tmr = null;
	$GLOBALS.topPosition = 0;
	$GLOBALS.lastTopPosition = 0;

	if($$('textarea.freetext')[0]){
		$each($$('textarea.freetext'), function(Txt){
			Txt.addEvent('keyup', function (){
				if(this.value.trim())makeHiddenField(this.form,'data[Cart][freetext_hooks][' + (this.id.replace('freetext_','')) + ']', this.value);
				else if($('data[Cart][freetext_hooks][' + (this.id.replace('freetext_','')) + ']')) $('data[Cart][freetext_hooks][' + (this.id.replace('freetext_','')) + ']').destroy();
			});
			Txt.addEvent('blur', function (){
				if(!this.value.trim()){
					if($('data[Cart][freetext_hooks][' + (this.id.replace('freetext_','')) + ']'))$('data[Cart][freetext_hooks][' + (this.id.replace('freetext_','')) + ']').destroy();
				}
			});
			Txt.addEvent('click', function (){
				return false;
			});
		});
	}

	$GLOBALS.done = false;
	if($('nonform')){
		$each($A($('nonform').elements), function(Elm){
			if(!$GLOBALS.IE)Elm.removeEvents();
			else if(Elm.type && (Elm.type=='radio')){Elm.disabled=true;}
			Elm.onfocus = function(){this.blur();return false;};
			Elm.onmousedown = function(){this.blur();return false;};
			Elm.onclick = function(){this.blur();return false;};
			Elm.onkeydown = function(){this.blur();return false;};
			Elm.oncontextmenu = function(){this.blur();return false;};
		});
	}
});
else{
	window.onload = function()
	{
		var forms = document.forms;
	    for (var i=0;i < forms.length;i++) {
	    	addInputSubmitEvent(forms[i]);
	    }
	    var a = _A(_T('a'));
	    var inp = _T('input');
	    for(var x=0;x<inp.length;x++){
	    	if(inp[x].type == 'image'||inp[x].type == 'submit'||inp[x].type == 'radio'||inp[x].type == 'checkbox'){
				inp[x].style.cursor = 'pointer';
				a = a.concat(inp[x]);
			}
	    }
		for(var i=0;i<a.length;i++){// http://www.tomislav.net/gestrichelte-linie-um-link-verstecken.htm
			a[i].onmousedown = function()
			{
				this.onfocus = function()
				{
					this.blur();
				};
			};
			a[i].onmouseout = function()
			{
				this.onfocus = function(){};
			};
			a[i].onmousemove = a[i].onmouseout;
		}
	};
}
function changePrice(e)
{/* Preiswechsel für den Konfigurator */
	if(!e)e=window.event;
	$this = $(this);
	if(this !== window && (inpnm = $this.getParent('div').getElement('input[type="checkbox"]'))){
		if(inpnm && !inpnm.name){
			return false;
		}
	}
	if(e!=-1)$name = $this.name ? $this.name : $this.getParent('div').getElement('input[type="checkbox"]').name;
	if((e!=-1) && ($this.type != 'radio')){
		var $inp = $this.getParent('div').getElement('input[type="checkbox"]') ? $this.getParent('div').getElement('input[type="checkbox"]') : null;
		var math_id = $this.getParent('div').getProperty('id');
		var max_key = $inp.getProperty('name');
		var value = $this.value;
		var sum = 0;
		if($this.type == 'text'){
			if(e.keyCode == '13'){
				 return false;
			}
			if(isNaN($this.value) || ($this.value === '')){
				$this.value = '0';
				$inp.checked = false;
			}
			else if(!isNaN($this.value)){
				$inp.checked = true;
			}
			if(e.keyCode){
				 if(e.keyCode == '38'){
					 $this.value = $this.value*1+1;
					 $inp.checked = true;
				 }
				 if(e.keyCode == '40'){
					 $this.value = $this.value*1-1;
					 if($this.value<=0){
						 $this.value = 0;
						 $inp.checked = false;
					 }
				 }
				 if(e.keyCode == '8'){
					 $this.value = '';
				 }
			}
		}
		$this.addEvent('blur', function(event){
			this.value = this.value ? this.value : '0';
		});
		var inps = $$('form#productform input[type="checkbox"]');
		$each(inps, function(Obj){
			if(Obj.checked){
				sum++;
			}
		});
		if(sum > $maxArray[max_key][math_id]){
			if($this.type == 'text'){
				$this.value = $this.value*1 - (sum*1 - $maxArray[max_key][math_id]*1);
				if($this.value<=0){
					$this.value = 0;
					$inp.checked=false;
				}
			}
			else if($this.type == 'checkbox'){
				$this.getParent('div').getElement('input[type="text"]').value='0';
				$this.checked = false;
			}
			if($this.getNext('textarea'))$this.getNext('textarea').blur();
			alert(window['javascript.messages.max_multi_availibles_1'] + ' ' + $maxArray[max_key][math_id] + ' ' + window['javascript.messages.max_multi_availibles_2']);
		}
		if($this.checked || ($this.type=="text" && $inp.checked)){
			if(!$('komponenten').getElement('div.' + $name)){
				var div = new Element('div',{'class': $name});
				var h2 = new Element('h2',{title: $name, styles : {'color':'#444444','margin':'5px 0 0','background':'url(/img/icons/bg_config_img.gif) 0 1px no-repeat','padding-left':'12px'}});
				//h2.innerHTML = $name.replace('_pppp_','&#x2B;').replace('_klamuf_','&#x28;').replace('_klamzu_','&#x29;').replace('_nbsp_',' ').replace('_komma_',',').replace('_onquot_',"'").replace(/\_(.*?)\_/g,'&$1;') + ':';
				div.inject($('komponenten').getElement('div'));
				h2.inject(div);
				var iDiv =  new Element('div',{'title': $name});
				iDiv.inject(div);
			}
			else{
				iDiv = $('komponenten').getElement('div[title="' + $name + '"]');
			}
			if(!$('komponenten').getElement('span#' + 'span_' + math_id.replace('math_',''))){
				var span = new Element('span', { styles : {'display' : 'block'}, id: 'span_' + math_id.replace('math_','')});
				span.innerHTML = 1 + ' x ' + $this.getNext('span').firstChild.data;
				span.inject(iDiv);
			}
			else{
				$('komponenten').getElement('span#' + 'span_' + math_id.replace('math_','')).innerHTML = $this.getParent('div').getElement('input[type="text"]').value + ' x ' + $this.getNext('span').firstChild.data;
			}
		}
		else if(!$this.checked){;
			if($('komponenten').getElement('span#' + 'span_' + math_id.replace('math_',''))){
				$('komponenten').getElement('span#' + 'span_' + math_id.replace('math_','')).destroy();
				if(!$('komponenten').getElement('div[title="' + $name + '"] span')){
					if($('komponenten').getElement('div[title="' + $name + '"]'))$('komponenten').getElement('div[title="' + $name + '"]').destroy();
					if(!$('komponenten').getElement('div.' + $name + ' span')){
						if($('komponenten').getElement('div.' + $name))$('komponenten').getElement('div.' + $name).destroy();
					}
				}
			}
		}
	}
	else if((e!=-1) && ($this.type == 'radio')){
		math_id = $this.getParent('div').getProperty('id');
		max_key = $this.getParent('div').getElement('input[type="radio"]').getProperty('name');
		if($this.checked){
			if($('komponenten').getElement('div.' + $name + ' span')){
				$('komponenten').getElement('div.' + $name + ' span').destroy();
			}
			if(!$('komponenten').getElement('div.' + $name)){
				var div = new Element('div',{'class': $name});
				var h2 = new Element('h2',{title: $name, styles : {'color':'#444444','margin':'5px 0 0','background':'url(/img/icons/bg_config_img.gif) 0 1px no-repeat','padding-left':'12px'}});
				//h2.innerHTML = $name.replace('_pppp_','&#x2B;').replace('_klamuf_','&#x28;').replace('_klamzu_','&#x29;').replace('_nbsp_',' ').replace('_komma_',',').replace('_onquot_',"'").replace(/\_(.*?)\_/g,'&$1;') + ':';
				div.inject($('komponenten').getElement('div'));
				h2.inject(div);
				var iDiv =  new Element('div',{'title': $name});
				iDiv.inject(div);
			}
			else{
				iDiv = $('komponenten').getElement('div[title="' + $name + '"]');
			}
			if(math_id){
				if(!$('komponenten').getElement('span#' + 'span_' + math_id.replace('math_',''))){
					var span = new Element('span', { styles : {'display' : 'block'}, id: 'span_' + math_id.replace('math_','')});
					span.innerHTML = 1 + ' x ' + $this.getNext('span').firstChild.data;
					span.inject(iDiv);
				}
				else{
					$('komponenten').getElement('span#' + 'span_' + math_id.replace('math_','')).innerHTML = 1 + ' x ' + $this.getNext('span').firstChild.data;
				}
			}
			else if($('komponenten').getElement('div.' + $name)){
				$('komponenten').getElement('div.' + $name).destroy();
			}
		}
	}
	if((e!=-1) && h2 && $$('h2[title="' + $name + '"]')[0]){
		h2.style.cursor = 'pointer';
	}
	if($GLOBALS.hiddens.length){
		$each($GLOBALS.hiddens, function(Obj){
			if($(Obj))$(Obj).destroy();
		});
		$GLOBALS.hiddens = [];
	}
	// Alle Inputs in Form ziehen (außer die generierten Hiddens)
	var inp = $$('form#productform input[type="radio"],form#productform input[type="checkbox"],form#productform input[type="text"]'), id= null, price = $priceArray[0]*1, text = null;
	// Beim Starten, onLoad
	$each(inp,function(Obj){
		if(Obj.type=='radio'){
			if(Obj.checked && (id = Obj.getParent('div').getProperty('id'))){
				makeHiddenField(Obj.form,'data[Cart][accessories][' + (id.replace('math_','')) + ']', 1);
				$GLOBALS.hiddens[$GLOBALS.hiddens.length] = 'data[Cart][accessories][' + (id.replace('math_','')) + ']';
				price += $priceArray[Obj.name][id]*1;
			}
		}
		if(e!=-1 && (Obj.type == 'checkbox')){
			if(Obj.checked && (id = Obj.getParent('div').getProperty('id'))){
				text = Obj.getParent('div').getElement('input[type="text"]');
				text.value = text.value > '0' ? text.value*1 : 1;
				makeHiddenField(Obj.form,'data[Cart][accessories][' + (id.replace('math_','')) + ']', text.value);
				$GLOBALS.hiddens[$GLOBALS.hiddens.length] = 'data[Cart][accessories][' + (id.replace('math_','')) + ']';
				price += $priceArray[Obj.name][id]*1*text.value;
			}
			else if(!Obj.checked && (id = Obj.getParent('div').getProperty('id'))){
				text = Obj.getParent('div').getElement('input[type="text"]');
				if(($this === text) && ($this.value === '')){
					text.value = '';
				}
				else{
					text.value = '0';
				}
			}
		}
	});
	var zut = {};
	if ((e != -1)) {
		if(!$GLOBALS.checkedInputs[$inp.name + $inp.tabIndex]){
			$GLOBALS.checkedInputs[$inp.name + $inp.tabIndex] = 1;
		}
		else if($GLOBALS.checkedInputs[$inp.name + $inp.tabIndex] == -1){
			$GLOBALS.checkedInputs[$inp.name + $inp.tabIndex] = false;
		}
		else{
			alert('Diese Zutat hast Du bereits im Warenkorb' + "\n" + 'Jede Zutat kann nur einmal ausgewählt werden!');
		}
		$GLOBALS.toolTipps[0].titleElement.firstChild.data = $GLOBALS.toolTipps[0].titleElement.firstChild.data.replace(/noch (\d+)/,'noch ' + ($GLOBALS.maxInhouds - sum)).replace('-1','0');
		$GLOBALS.toolTipps[0].addEvent('show', function(tip){
			tip.getElement('div.tip-title').firstChild.data = tip.getElement('div.tip-title').firstChild.data.replace(/noch (\d+)/,'noch ' + ($GLOBALS.maxInhouds - sum)).replace('-1','0');
		});	
	}
	if((e!=-1)&&(sum<=5)&&(zut = $('zutatenliste'))&&(sum==($('zutatenliste').getChildren('div').length+1))){
		var zudv = new Element('div',{'class':'zutatchen'}).inject(zut);
		var zumg = this.getParent('div').getElement('img.thumb').clone();
		zumg.src = zumg.src.replace('[w]=160','[h]=86').replace('[w]=80','[h]=42');
		zumg.inject(zudv);
		var zudv2 = new Element('div',{'class':'info'}).inject(zudv);
		zudv2.innerHTML = this.getParent('div').getElement('span.name').firstChild.data;
		var zudv3 = new Element('div',{'class':'euro'}).inject(zudv);
		zudv3.innerHTML = this.getParent('div').getElement('span.price').firstChild.data;
		var nimg = new Element('img',{'class':'close','src':'/img/close.gif','width':'11','height':'11'}).inject(zudv);
		nimg.setProperty('alt',$this.getParent('div').id);
		nimg.addEvent('click', function(img){
			var $inpt = $(this.alt).getElement('input[type="checkbox"]');
			$GLOBALS.checkedInputs[$inpt.name + $inpt.tabIndex] = -1;
			$inpt.checked=false;
			$inpt.onclick();
			this.getParent('div').destroy();
		});
	}
	$('price').firstChild.data = '€ ' +  float2str(price);
}
function showClickedThumbs(clsName)
{
	if(clsName == 'All'){
		$$('div#is_scrollbar div.konfigurator').show();
	}
	else{
		$$('div#is_scrollbar div.konfigurator').hide();
		$$('div#is_scrollbar div.' + clsName).show();
	}
	$$('div#Zutatengruppen div').removeClass('act');
	$$('div#Zutatengruppen div.' + clsName).addClass('act');
}
function multiSubmit(myForm, id, value)
{
	if($('ifrm'))return;
	new Element('iframe',{'name':'ifrm','id':'ifrm','height':'1','width':'1','src':myForm.action+'?id='+id+'&value='+value}).inject($$('body')[0]);
	myForm.target = 'ifrm';
	myForm.action = $('ifrm').src;
	myForm.submit();
}
