// JavaScript Document
function cent(amount)
{
// returns the amount in the .99 format
	amount -= 0;
	return (amount == Math.floor(amount)) ? amount + '.00' : (  (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}


var RetailPrice = ex_attr15;

if(RetailPrice == "")
{
	if (document.getElementById("RetailBlock") != null)
	{
		document.getElementById("RetailBlock").style.display="none";
	}
	var RetailPrice ="";
	var RetailPriceValue ="";
}
else
{
	var RetailPrice = RetailPrice.replace(/\,/g,'');
	var RetailPrice = parseFloat(RetailPrice);
	var RetailPriceValue = cent(RetailPrice);
	var RetailPriceValue = addCommas(RetailPriceValue);
	
	if (document.getElementById("RetailBlock") != null)
	{
		document.getElementById("RetailBlock").style.display="block";
	}
}	

var CurrentPrice = au_bid_low;
if(CurrentPrice == "")
{
	var CurrentPrice ="";
}
else
{
	var CurrentPrice = CurrentPrice.replace(/,/,"");
	var CurrentPrice = parseFloat(CurrentPrice);
}

if(RetailPrice == "" || CurrentPrice == "")
{
	var Savings ="";
}
else
{
	var Savings = RetailPrice - CurrentPrice;
	var Savings = Math.round(Savings*100)/100;
	var Savings = parseFloat(Savings); 
	var SavingsValue = cent(Savings);
	var SavingsValue = addCommas(SavingsValue);
}


var PercentSave = Savings/RetailPrice*100;
if(Savings == "")
{
	var PercentSave ="";
}
else
{
	var PercentSave = Math.round(PercentSave);
	var PercentSaveInt = parseFloat(PercentSave);
}

if(PercentSave != "")
{
	if(PercentSaveInt >= 15)
	{
		if (document.getElementById("SavingBlock") != null)
		{
			document.getElementById("SavingBlock").style.display="block";
		}
	}
	else
	{
		if (document.getElementById("SavingBlock") != null)
		{
			document.getElementById("SavingBlock").style.display="none";
		}
		//var RetailPrice ="";
		//var CurrentPrice ="";
		var Savings ="";
		var PercentSave ="";
	}
}
else
{
	if (document.getElementById("SavingBlock") != null)
	{
		document.getElementById("SavingBlock").style.display="none";
	}
	//var RetailPrice ="";
	//var CurrentPrice ="";
	var Savings ="";
	var PercentSave ="";
}
//alert(PercentSaveInt);
//alert(RetailPrice+"Retail");
//alert(CurrentPrice+"price");
//alert(Savings+"save");
//alert(PercentSave+"percent");


