// JavaScript Document

/* var products_prices_net = new Array();
var products_prices_gross = new Array();
var products_actionprices_net = new Array();
var products_actionprices_gross = new Array();
var last_activated_pricelist = null; */

var sid = '';
var category_id = 0;







function display_divs() {
	// alert(category_id);
	
	
	//alert(sid + ' ' + category_id);
	if(sid == 'd289da2b5e34619bcd7b8be5ec7a5df9' && intVal(category_id == 7957)) {
		
		alert('Hallo Welt');
		
		
	
	
	}

}



function change_product_pricelist(fieldname) {
	var f = document.forms['shopform'];
	var html_id = null;
	
	if(last_activated_pricelist > 0) {
		html_id = 'pricelist' + last_activated_pricelist;
		if(document.all) {
			if(document.all[html_id]) document.all[html_id].className = 'product-pricelist-normal';
		} else if(document.getElementById) {
			if(document.getElementById(html_id)) document.getElementById(html_id).className = 'product-pricelist-normal';
		}
	}
	last_activated_pricelist = f.elements[fieldname].value;
	
	
	html_id = 'pricelist' + f.elements[fieldname].value;
	if(document.all) {
		if(document.all[html_id]) document.all[html_id].className = 'product-pricelist-active';
	} else if(document.getElementById) {
		if(document.getElementById(html_id)) document.getElementById(html_id).className = 'product-pricelist-active';
	}
	
	// Auswechseln der Produktnummer
	var product_id = parseInt(f.elements[fieldname].value);
	if(products_numbers[product_id]) {
		if(document.all) {
			if(document.all['product-number']) document.all['product-number'].innerHTML = products_numbers[product_id];
		} else if(document.getElementById) {
			if(document.getElementById('product-number')) document.getElementById('product-number').innerHTML = products_numbers[product_id];
		}
	}
	
	// Feststellen, ob ein Produkt im Warenkorb liegt und Klassennamen der HTML-Elemente ändern
	
	var classname = 'inbasket' + products_in_basket[product_id];
	if(document.all) {
		if(document.all['inbasket']) document.all['inbasket'].className = classname;
	} else if(document.getElementById) {
		if(document.getElementById('inbasket')) document.getElementById('inbasket').className = classname;
	}
	if(products_basket_amount[product_id] == 0) {
		f.elements[amount_fieldname].value = 1;
	} else {
		f.elements[amount_fieldname].value = products_basket_amount[product_id];
	}
	
	
	
}



function set_delivery_radiobutton(radio_id) {
	for(i=0; i<document.forms['shopform'].elements.length; i++) {
		
		if(document.forms['shopform'].elements[i].name == 'delivery_address_id') {
			if(parseInt(document.forms['shopform'].elements[i].value) == parseInt(radio_id)) {
				document.forms['shopform'].elements[i].checked = true;
				break;
			}
		}
	}
}




var zoomimagediv = null;
function display_image(img_src, width, height) {
	width = parseInt(width);
	height = parseInt(height);

	if(document.getElementById) {	
		if(document.getElementById('zoomimage-div')) {
			zoomimagediv = document.getElementById('zoomimage-div');
		} else {
			return false;
		}
	} else if(document.all) {
		if(document.all['zoomimage-div']) {
			zoomimagediv = document.all['zoomimage-div'];
		} else {
			return false;
		}
	} else {
		return false;
	}
	
	if(zoomimagediv != null) {
		zoomimagediv.style.display = 'block';
		zoomimagediv.style.width = width + 'px';
		zoomimagediv.style.height = (height + 20) + 'px';
		zoomimagediv.style.marginLeft = (-1 * parseInt(width/2)) + 'px';
		zoomimagediv.style.marginTop = (-1 * parseInt((height + 20)/2)) + 'px';
		document.images['zoomimage'].src = img_src;
	}

}


function hide_image() {
	if(zoomimagediv != null) {
		zoomimagediv.style.display = 'none';
	}
}


function set_delivery_radiobutton(radio_id) {
	for(i=0; i<document.forms['shopform'].elements.length; i++) {
		if(document.forms['shopform'].elements[i].name == 'delivery_address_id') {
			if(parseInt(document.forms['shopform'].elements[i].value) == parseInt(radio_id)) {
				document.forms['shopform'].elements[i].checked = true;
				break;
			}
		}
	}
}


function set_bankaccount_radiobutton(radio_id) {
	for(i=0; i<document.forms['shopform'].elements.length; i++) {
		if(document.forms['shopform'].elements[i].name == 'paymentdata_id') {
			if(parseInt(document.forms['shopform'].elements[i].value) == parseInt(radio_id)) {
				document.forms['shopform'].elements[i].checked = true;
				break;
			}
		}
	}
}