function setNewPrice(opt_count,price_view,price_format,discount,product_discount,discount_available,currency_symbol,symbol_position,product_price,product_tax,exchange)
{
	var opt_price_all = new Array();
	opt_price_all[0] = 0;
	opt_price_all[1] = 0;
	
	// get the option price(s)
	for (i=1; i<opt_count; i++)
	{
		var opt_val = document.form_details.elements["option"+i].value;
		var ar_val = opt_val.split(";");
		var opt_price = getFloat(ar_val[1]);
		
		ar_opt_price = getPrice(opt_price,product_tax,price_view,price_format,discount,product_discount,discount_available);
		
		opt_price_all[0] = opt_price_all[0] + ar_opt_price[0];
		opt_price_all[1] = opt_price_all[1] + ar_opt_price[1];
	}
	
	// get the product price
	price = getPrice(product_price,product_tax,price_view,price_format,discount,product_discount,discount_available); 
	
	product_price = new Array();
	product_price[0] = (price[0] + opt_price_all[0]) * exchange; // netto
	product_price[1] = (price[1] + opt_price_all[1]) * exchange; // brutto
	
	switch (price_view)
	{
		case 0: // netto
			document.getElementById("price0").innerHTML = currency_symbol + " " + numberFormat(product_price[0],2,",",".");
		break
		
		case 1: // butto
			document.getElementById("price0").innerHTML = currency_symbol + " " + numberFormat(product_price[1],2,",",".");
		break
		
		case 2: // netto & brutto
			document.getElementById("price0").innerHTML = currency_symbol + " " + numberFormat(product_price[0],2,",",".");
			document.getElementById("price1").innerHTML = currency_symbol + " " + numberFormat(product_price[1],2,",",".");
		break
		
		case 3: // brutto & netto
			document.getElementById("price0").innerHTML = currency_symbol + " " + numberFormat(product_price[1],2,",",".");
			document.getElementById("price1").innerHTML = currency_symbol + " " + numberFormat(product_price[0],2,",",".");
		break
	}
	
	
	//document.getElementById("price0").innerHTML = currency_symbol + " " + numberFormat(product_price[0],2,",",".");
	//document.getElementById("price1").innerHTML = currency_symbol + " " + numberFormat(product_price[1],2,",",".");
}

// returns the unformated price and tax
function getPrice(price,tax,price_view,price_format,discount,product_discount,discount_available)
{		
	if (discount_available == 0) // price gets no disocunt
	{
		return getPriceNoDiscount(price,tax,price_view,price_format);
	}
	
	// check and get the max. product discount
	discount = product_discount < discount ? product_discount : discount;
	
	if (price_format == 0)
	{
		price_discount = price - (price * discount / 100); // Nettopreis - Rabatt
		price_netto = price_discount; // Nettopreis - Rabatt
		price_tax = price_discount * tax / 100; // MwSt.
		price_brutto = price_discount + price_tax; // Bruttopreis - Rabatt
	}
	else // brutto price
	{
		price_no_tax = price * 100 / (100 + tax); // Nettopreis - Netto
		price_netto = price_no_tax - (price_no_tax * discount / 100); // Nettopreis - Rabatt
		price_brutto = price - (price * discount / 100); // Bruttopreis - Rabatt
		price_tax = price_brutto - (price_brutto / (100 + tax) * 100); // MwSt.
	}
	
	//price_netto = (price_netto * 100) / 100;
	//price_brutto = (price_brutto * 100) / 100;
	price_netto = Math.round(price_netto * 100) / 100;
	price_brutto = Math.round(price_brutto * 100) / 100;
	price_tax = price_tax; // round(price_tax,2);
	ar = new Array(price_netto, price_brutto, tax, price_tax);
	
	return ar;
}

// returns the unformated price and tax
function getPriceNoDiscount(price,tax,price_view,price_format)
{	
	if (price_format == 0)
	{
		price_netto = price; // Nettopreis
		price_tax = price * tax / 100; // MwSt.
		price_brutto = price + price_tax; // Bruttopreis
	}
	else // brutto price
	{
		price_netto = price * 100 / (100 + tax); // Nettopreis
		price_brutto = price; // Bruttopreis
		price_tax = price - (price / (100 + tax) * 100); // MwSt.
	}
	
	//price_netto = (price_netto * 100) / 100;
	//price_brutto = (price_brutto * 100) / 100;
	price_netto = Math.round(price_netto * 100) / 100;
	price_brutto = Math.round(price_brutto * 100) / 100;
	price_tax = price_tax; // round(price_tax,2);
	ar = new Array(price_netto, price_brutto, tax, price_tax);
	
	return ar;
}


function getFloat(val)
{
	var reg = /^[0-9-+]*[,\.][0-9]*$|^[0-9-+]*$/;
	
	// get the float value 
	val = String(val);
	val = val.length == 0 || !reg.test(val) ? "0" : val;
	val = val.replace(/,/,".");
	val = parseFloat(val);
	
	return val; // val is numeric not a string
}

function numberFormat(val,decimals,decimal_sep,thousand_sep)
{
	var dec = "";
	var new_val = "";
	var reg = /^[0-9-+]*[,\.][0-9]*$|^[0-9-+]*$/;
	
	// get the float value 
	val = String(val);
	val = val.length == 0 || !reg.test(val) ? "0" : val;
	val = val.replace(/,/,".");
	val = parseFloat(val);
	
	// round the value and get the needed decimal places
	val = Math.round(val * Math.pow(10,decimals)) / Math.pow(10,decimals);
	
	// check if the rounded value has decimal places
	val = String(val);
	
	if (val.indexOf(".") >= 0)
	{
		ar_val = val.split(".");
		val = ar_val[0];
		dec = ar_val[1];
		
		// check if there are enough decimal places 
		if (dec.length < decimals)
		{
			var needed_dec = decimals-dec.length;
			for (i=0; i<needed_dec; i++) dec += "0";
		}
		
	}
	else dec = String(Math.pow(10,decimals)).substr(1);
	
	// separate the thousand places by the given separator
	if(val >= 1000)
	{
		var pos_start = 0;
		var pos_end = val.length % 3;
		
		pos_end = pos_end == 0 ? 3 : pos_end;
		
		// split the thousand places
		while ((val.length - pos_end) >= 0)
		{
			new_val += val.substring(pos_start, pos_end);
			new_val = (val.length - pos_end) > 0 ? new_val + thousand_sep : new_val;
			
			pos_start = pos_end;
			pos_end = pos_end + 3;
		}
	}
	else new_val = val;

	// check if a decimal place is needed
	new_val = decimals == 0 ? new_val : new_val + decimal_sep + dec;
	
	return new_val;
}