<!--
function get_element(id) {
	if(document.getElementsByName(id)[0])
		return document.getElementsByName(id)[0];
	else false;
}

function changeprice(i){
	
	/* Variablen initialisieren START */
	newprice = 0;
	
	option_element = get_element('option['+i+']');
	input_element = get_element('input['+i+']');
	
	if(option_element) h = Number(option_element.options.selectedIndex);
	option_price_element = get_element('addoptionprice['+i+']['+h+']');
	option_calc_element = get_element('optioncalculation['+i+']['+h+']');
	
	value_price = Number(get_element('valueprice['+i+']').value);
	value_calc = get_element('valuecalculation['+i+']').value;
	
	if(input_element) input_val = Number(input_element.value);
	if(option_element) option_val = Number(option_element.options[h].text);
	if(option_price_element) option_price = Number(option_price_element.value);
	
	if(option_calc_element) option_calc = option_calc_element.value;
	else option_calc = false;
	
	nomprice_element = get_element('nomprice');
	nomprice = Number(nomprice_element.value);
	price_element = get_element('price['+i+']');
	price = price_element.value;
	price = Number(price.substring(0,(price.length - 4)));
	price_total_element = get_element('pricetotal');
	price_total = price_total_element.value.replace(",","."); 
	if(price_total) price_total = Number(price_total.substring(0,price_total.length-2));
	/* Variablen initialisieren ENDE */
	
	switch(value_calc) {
		case "+": 	newprice = newprice + value_price; break;
		case "-": 	newprice = newprice - value_price; break;
		case "*": 	newprice = 0;
					break;
		case "*x":	nomprice = price_total - price;
					newprice = (input_val - 1) * nomprice; break;					
	}

	switch(option_calc){
		case "+": 	newprice = newprice + option_price; break;
		case "-": 	newprice = newprice - option_price; break;
		case "*": 	newprice = newprice + (option_val * option_price); break;
		case "%": 	newprice = 0;
					break;			
	}

	addtonomprice = Number(newprice);
	
	cat_value_element = get_element('catvalue['+i+']');
	value_element = get_element('value['+i+']');

	if(option_calc && option_calc != "%" && value_calc != "*"){
				
		if(cat_value_element){
								
			if(cat_value_element.type=="checkbox"){
						
				if(cat_value_element.checked == true){
										
					if(option_element) option_element.disabled = false;
					if(price != "") nomprice_element.value = nomprice + addtonomprice - price;
					else nomprice_element.value = nomprice + addtonomprice;
				} else if(option_element) option_element.disabled = true;
			} else {
				if(price != "") nomprice_element.value = nomprice + addtonomprice - price;
				else nomprice_element.value = nomprice + addtonomprice;
			}
		}
				
		if(value_element) {
								
			if(value_element.type=="checkbox"){
						
				if(value_element.checked == true){
				
					if(option_element) option_element.disabled = true;
					if(price != "") nomprice_element.value = nomprice + addtonomprice - price;
					else nomprice_element.value = nomprice + addtonomprice;
				} else if(option_element) option_element.disabled = false;
								
			} else {
									 	
			if(price !="") nomprice_element.value = nomprice + addtonomprice - price;
			else nomprice_element.value = nomprice + addtonomprice;
			}
						
		}

	} else nomprice_element.value = nomprice;
	
	if(newprice == 0) newprice="";
	else newprice = addtonomprice.toFixed(2) + shopcurrency;

	price_element.value = newprice;
	
	displayprice();
}

function addnomprice(i){
		
	/* Variablen initialisieren START */
	check = true;
		
	cat_value_element = get_element('catvalue['+i+']');
	value_element = get_element('value['+i+']');
	option_element = get_element('option['+i+']');
	price_element = get_element('price['+i+']');
	price = price_element.value;
	price = Number(price.substring(0,price.length - 4));
	nomprice_element = get_element('nomprice');
	nomprice = Number(nomprice_element.value);
		
	if(cat_value_element) add = cat_value_element.checked;
	else add = value_element.checked;
	/* Variablen initialisieren ENDE */
		
	if(option_element){
						
		if(option_element.type == "hidden") h = 0;
		else h=Number(option_element.options.selectedIndex);
		
		option_calc_element = get_element('optioncalculation['+i+']['+h+']');
		if(option_calc_element) option_calc = option_calc_element.value;
		if(option_calc == "%") check = false;	
	}
	if(get_element('valuecalculation[' + i + ']').value == "*") check = false;
	
	if(check==true){

		if(add == true){
				
			if(price != "") nomprice_element.value = nomprice + price;
								
		} else {
	
			if(price != "") nomprice_element.value = nomprice - price;
		
		}
	} else price_element.value = "";

	displayprice();
}

function displayprice(){

	/* Variablen initialisieren START */
	product_price = Number(get_element('productprice').value);
	i = Number(get_element('nr').value);
		
	for(i; i > 0;i--){
	
		price_element = get_element('price['+i+']');
		price = price_element.value;
		price = Number(price_element.value.substring(0,price.length - 4));
		cat_value_element = get_element('catvalue['+i+']');
		value_element = get_element('value['+i+']');
		input_element = get_element('input['+i+']');
		option_element = get_element('option['+i+']');
		input_element = get_element('input['+i+']');
		/* Variablen initialisieren ENDE */
		
		if(cat_value_element){
								
			if(cat_value_element.type=="checkbox"){
						
				if(cat_value_element.checked == true){
																		
					if(document.getElementsByName('input['+i+']')[0]){
						input_element.disabled = false;
						input_element.style.backgroundColor = "#FFFFFF";
					}
					if(option_element){
						option_element.disabled = false;
						option_element.style.backgroundColor = "#FFFFFF";
					}
					if(price != "") product_price = product_price + price;
										
				} else {
					if(option_element){
						option_element.disabled = true;
						option_element.style.backgroundColor = "#EEEEEE";
					}
					if(input_element){
						input_element.disabled = true;
						input_element.style.backgroundColor="#EEEEEE";
						input_element.value = "";
					}
				}
						
			} else if(price != "") product_price = product_price + price;					
		
		} else {
						 
			if(value_element){
						 
				if(value_element.type=="checkbox"){
						
					if(value_element.checked == true){
																		
						if(input_element){
							input_element.disabled=false;
							input_element.style.backgroundColor="#FFFFFF";
						}
						if(option_element){
							option_element.disabled=false;
							option_element.style.backgroundColor="#FFFFFF";
						} 
						if(price != "") product_price = product_price + price;
										
					} else {
						if(option_element){
							option_element.disabled=true;
							option_element.style.backgroundColor="#EEEEEE";
						}
						if(input_element){
							input_element.disabled=true;
							input_element.style.backgroundColor="#EEEEEE";
							input_element.value = "";
						}
					}
						
				} else {
					
					if(price != "") product_price = product_price + price;
				}
			}
		}
				
	}
	
	get_element('pricetotal').value = (get_element('number').value * product_price).toFixed(2) + " " + get_element('productcurrency').value;
	
	update_elements();

}

function init_value_elements (id, calc) {

	cat_value_element = get_element('catvalue['+id+']');
	value_element = get_element('value['+id+']');
	price_total = 0;

	if(cat_value_element)
		if(cat_value_element.checked == true) check = true;
		else check = false;
	
	if(value_element)
		if(value_element.checked == true) check = true;
		else check = false;

	price_element = get_element('price[' + id + ']');
	price = price_element.value;
	price = Number(price.substring(0,(price.length - 4)));
	price_total_element = get_element('pricetotal');
	nomprice_element = get_element('nomprice');
	nomprice = Number(nomprice_element.value); 

	if(calc == "*") {
		value = get_element('valueprice[' + id + ']').value;
		newprice = nomprice * value - nomprice;
		price_total = nomprice + newprice;

		option_element = get_element('option[' + id + ']'); 
		if(option_element) {
			h = option_element.selectedIndex;
			option_price = get_element('addoptionprice[' + id + '][' + h + ']');
			if(option_price) {
				option_calc_element = get_element('optioncalculation['+id+']['+h+']');
				if(option_calc_element.value == "%") {
					newprice = price_total * option_price.value * 0.01;
					if(newprice < price_total) newprice = -newprice;
					price_total = price_total + newprice;
					newprice = price_total - nomprice;
				}
			}
		}
	}
  
	if(calc == "%") {
		value_calc = get_element('valuecalculation[' + id + ']').value;
		if(value_calc == "*") return false;
		else {
			price_total = nomprice;
			option_element = get_element('option[' + id + ']'); 
			h = option_element.selectedIndex;
			
			value = get_element('addoptionprice[' + id + '][' + h + ']').value;
			newprice = price_total * value * 0.01;
			if(newprice < price_total) newprice = -newprice;
			price_total = price_total + newprice;
			newprice = price_total - nomprice;
		}
	}
	
	if(newprice){
		price_element.value = newprice.toFixed(2) + " " + get_element('productcurrency').value;
		if(check == true){		
			price_total_element.value = price_total.toFixed(2) + " " + get_element('productcurrency').value;
		}
	} else	return false;

}


function window_open(seite,titel,breite,hoehe) {
   window.open(seite,""+titel+"","width="+breite+",height="+hoehe);
}


function checkinput(obj){
		
	//Prüft ob eine Zahl eingegeben wurde
	count=obj.value.length-1;
		
	if(obj.value.charAt(count)==","){
		obj.value=obj.value.replace(",",".");
		return true;
	}
	if(obj.value.charAt(count)==".")return true;
	if(isNaN(obj.value.charAt(count)))check=false;else check=true;
		
	if(check==false){
			
		obj.value="";
		return false;
					
	} else return true;
		
}
//-->