function getPublisherPrice(ppu, ppm2, m2)
{
	return ppu+(ppm2*m2);
}

//~ function getPublisherPrice(amount, priceAtStartLimit, priceAtStopLimit, startLimit, stopLimit)
//~ {
	//~ amount = isNaN(amount) ? 0 : calc_Number(amount.toString());
	//~ priceAtStartLimit = calc_Number( priceAtStartLimit );
	//~ priceAtStopLimit = calc_Number( priceAtStopLimit );
	//~ startLimit = calc_Number( startLimit );
	//~ stopLimit = calc_Number( stopLimit );
	
	//~ if ( amount <= startLimit )
	//~ {
		//~ return priceAtStartLimit;
	//~ }
	
	//~ if ( amount >= stopLimit )
	//~ {
		//~ var pricePerM2 = priceAtStopLimit/stopLimit;
		//~ return pricePerM2*amount;
	//~ }
	
	//~ var amountspan = stopLimit - startLimit;
	//~ var pricespan = priceAtStopLimit - priceAtStartLimit;
	
	//~ var whereInSpan = 1-(amount/amountspan);
	
	//~ return priceAtStopLimit-(pricespan*whereInSpan);
//~ }

function getPrice(c, s, e, min, max)
{
	c = isNaN(c) ? 0 : calc_Number(c.toString());
	s = calc_Number( calc_Number(s) );
	e = calc_Number( calc_Number(e) );
	min = calc_Number( min );
	max = calc_Number( max );
	
	var p = 0;
	var amountspan = max - min;
	var pricespan = s - e;
	
	// For each additional unit price should be reduced with this amount
	var reductionPerUnit = pricespan/amountspan;
	
	var numItemsWithMaxPrice = min;
	var numItemsWithMinPrice = c < max ? 0: c-max+1;
	var numItemsWithVariablePrice = c - numItemsWithMaxPrice - numItemsWithMinPrice;
	
	var numReductions = (numItemsWithVariablePrice)*(1+(numItemsWithVariablePrice))/2;
	
	p = 0;
	// Add price for the items below lower amount limit
	p += numItemsWithMaxPrice*s;
	
	// Add price for the items above upper amount limit
	p +=numItemsWithMinPrice*e;
	
	// Add price for the items in the middle
	if ( numItemsWithVariablePrice > 0 )
	{
		p +=(numItemsWithVariablePrice*s)-(numReductions*reductionPerUnit);
	}
	
	// Added round here instead
	return Math.round(p*100)/100;
}

function calc_Number(x) { if(typeof(x) == "undefined") return 0; x = x.toString().replace(/\s/g, ""); return x == "-" ? 0 : Number(x.replace(/,/g, ".")); }
	
function radio_GetSelectedIndex(radio)
{
	for (i=0;i<radio.length;i++)
	{
		if (radio[i].checked)
		{
			return i;
		}
	}
}

function radio_GetSelectedValue(radio)
{
	for (i=0;i<radio.length;i++)
	{
		if (radio[i].checked)
		{
			return radio[i].value;
		}
	}
}

function insertParam(key, value)
{
	key = escape(key); value = escape(value);

	var kvp = document.location.search.substr(1).split('&');

	var i=kvp.length; var x; while(i--) 
	{
		x = kvp[i].split('=');

		if (x[0]==key)
		{
			x[1] = value;
			kvp[i] = x.join('=');
			break;
		}
	}

	if ( i<0 )
	{
		kvp[kvp.length] = [key,value].join('=');
	}

	return kvp.join("&");
}
