window.addEvent('domready',function() {
//	$$('#big_image a').addEvent('click',function(event) {
//		event.stop();
//		window.open(this.href,'', 'scrollbars=yes,width=400,height=400,resizable');
//	});
//	$$('#image a.lupe').addEvent('click',function(event) {
//		event.stop();
//		window.open(this.href,'', 'scrollbars=yes,width=400,height=400,resizable');
//	});
//	$$('.thumbs a').addEvent('click',function(event) {
//		event.stop();
//		window.open(this.href,'', 'scrollbars=yes,width=400,height=400,resizable');
//	});
	$$('a.info_i').addEvent('mouseover',function() {
		$$('#'+this.get('name')+'_tooltip').addClass('tooltip_show');
		$$('#'+this.get('name')+'_tooltip').removeClass('tooltip');
	});
	$$('a.info_i').addEvent('mouseout',function() {
		$$('#'+this.get('name')+'_tooltip').removeClass('tooltip_show');
		$$('#'+this.get('name')+'_tooltip').addClass('tooltip');
	});
});

var img_path = ws_images+'product_images/popup_images/';

function change_description(id,type,image,width,height) {
	$$('img#products_image').set('src',image);
	$$('img#products_image').set('width',width);
	$$('img#products_image').set('height',height);
}

window.addEvent('domready',function() {
	$$('#choose select.longer_field').addEvent('change',function() {
		window.location.href = this.get('value');
	});
	$$('#choose div.choose_radio input').addEvent('click',function() {
		window.location.href = this.get('value');
	});
});

window.addEvent('domready',function() {
	$each($$('.thumbs a'),function(el) {
		var img = el.getElement('img');
		var src = img.get('src');
		var new_element_img = new Element('img',{
			'src':'images/blind.gif',
			'width':'35',
			'height':'35',
			'class':'no_border',
			'rel':'nofollow',
			'styles': {
				'background-image':'url('+src+')'
			},
			'class': 'thumb_img'});
		img.destroy();
		new_element_img.inject(el);
	});
});

function newPrice(price){
	if(document.getElementById('newPrice').title == '')
		document.getElementById('newPrice').title = document.getElementById('newPrice').innerHTML;
	if(document.getElementById('products_id').title == '')
		document.getElementById('products_id').title = document.getElementById('products_id').value;
	if(price != ""){
		var idold = '';
		var newid = '';
		var oldPrice = 0;
		var newPrice = 0;
		var id = 0;
		idold = document.getElementById('products_id').title;
		oldPrice = document.getElementById('newPrice').title.split(" ");
		oldPrice[0] = oldPrice[0].replace((/,/g), ".");
		price = price.split('|');
		id = price[1];
		price = price[0];
		if(price > 0 || price != '' || id > 0){
			newPrice = parseFloat(oldPrice[0]) + parseFloat(price);
			var newPricestring = newPrice.toFixed(2);
			document.getElementById('newPrice').innerHTML = formatZahl(newPrice, 2, true) + ' &euro;';
			newid =	idold + ',' + id;
			document.getElementById('products_id').value = newid;
		}else{
			document.getElementById('newPrice').innerHTML = document.getElementById('newPrice').title;
			document.getElementById('products_id').value = document.getElementById('products_id').title;
		}
	}else{
		document.getElementById('newPrice').innerHTML = document.getElementById('newPrice').title;
		document.getElementById('products_id').value = document.getElementById('products_id').title;
	}
}

function formatZahl(zahl, k, fix) {
    if(!k) k = 0;
    var neu = '';
	var dec_point = ',';
	var thousands_sep = '.';
    // Runden
    var f = Math.pow(10, k);
    zahl = '' + parseInt(zahl * f + (.5 * (zahl > 0 ? 1 : -1)) ) / f ;
    // Komma ermittlen
    var idx = zahl.indexOf('.');
    // fehlende Nullen einfügen
    if(fix) {
         zahl += (idx == -1 ? '.' : '' )
         + f.toString().substring(1);
    }
	var sign = zahl < 0;
	if(sign) zahl = zahl.substring(1);
    idx = zahl.indexOf('.');
	// Nachkommastellen ermittlen
    if( idx == -1) idx = zahl.length;
    else neu = dec_point + zahl.substr(idx + 1, k);
    while(idx > 0)    {
        if(idx - 3 > 0)
        neu = thousands_sep + zahl.substring( idx - 3, idx) + neu;
        else
        neu = zahl.substring(0, idx) + neu;
        idx -= 3;
    }
    return (sign ? '-' : '') + neu;
}
