var productListURL = "";
var products = new Array();
var currentProductNum = 0;
var doRetail = true;

var sitePriceLabel = "";
var salePriceLabel = "";


/**
* Contains a record for each product on the page
*/
function product() {
	this.smallImage = "";
	this.smallImageAlt = "";
	this.largeImage = "";
	this.largeImageAlt = "";
	this.shortDescription = "";
	this.retailPriceLabel = "";	
	this.retailPrice = "";
	this.salePrice = "";
	this.showOnSale = false;
	this.regularPrice = "";
	this.startingPrice = "";
	this.detailsURL = "";
	this.numPaymentLabel = "";
	this.isFJC = false;	
	this.numPayments = 0;
	this.payment = 0;
}

//function which updates product details
function changeProduct(proIndex){

	currentProductNum = proIndex;
	var activeProduct = products[currentProductNum];
	
	//workaround to convert &amp; to &
	var urlSplit = activeProduct.detailsURL.split("&amp;");
	var url = urlSplit[0];
	for(var i=1;i<urlSplit.length;i++)
	{
		url += "&" + urlSplit[i]; 
	}

	document.getElementById("proBigImg").src = activeProduct.largeImage;
	document.getElementById("proBigImg").alt = activeProduct.largeImageAlt;
	document.getElementById("proName").innerHTML = activeProduct.shortDescription;
	document.getElementById("proBigImgHRef").href = url;
	document.getElementById("proBigImgHRef1").href = url;

	if(activeProduct.retailPrice != "" && activeProduct.retailPrice != "$0.00"){
		document.getElementById("retailPriceText").innerHTML = "Retail Value:";
		document.getElementById("proRPrice").innerHTML = activeProduct.retailPrice;
	} else {
		document.getElementById("retailPriceText").innerHTML = "";
		document.getElementById("proRPrice").innerHTML = "";
	}
	if(!activeProduct.isFJC) {
		if(activeProduct.showOnSale) {
			document.getElementById("onSale").style.display="inline";
			document.getElementById("onSaleRegularPriceLabel").style.display="inline";
			document.getElementById("onSaleRegularPriceAmt").style.display="inline";
			document.getElementById("onSaleSalePriceLabel").style.display="inline";
			document.getElementById("onSaleSalePriceAmt").style.display="inline";

			document.getElementById("noSalePrice").style.display="none";			

			document.getElementById("icePriceText").style.display="none";
			document.getElementById("proPrice").style.display="none";
			
			document.getElementById("onSaleRegularPriceLabel").innerHTML = sitePriceLabel;
			document.getElementById("onSaleRegularPriceAmt").innerHTML = '<span class="on_sale_strike"><span class="ice_price">' + activeProduct.regularPrice + '</span></span>';

			document.getElementById("onSaleSalePriceLabel").innerHTML = salePriceLabel;
			document.getElementById("onSaleSalePriceAmt").innerHTML = activeProduct.salePrice;

			document.getElementById("icePriceText").innerHTML = "";
			document.getElementById("proPrice").innerHTML = "";

		} else {
			document.getElementById("onSale").style.display="none";
			document.getElementById("onSaleRegularPriceLabel").style.display="none";
			document.getElementById("onSaleRegularPriceAmt").style.display="none";
			document.getElementById("onSaleSalePriceLabel").style.display="none";
			document.getElementById("onSaleSalePriceAmt").style.display="none";
			
			document.getElementById("noSalePrice").style.display="inline";			
			document.getElementById("icePriceText").style.display = "inline";
			document.getElementById("proPrice").style.display = "inline";
			
			document.getElementById("icePriceText").innerHTML = sitePriceLabel;
			document.getElementById("proPrice").innerHTML = activeProduct.salePrice;
		}


	}else{
		document.getElementById("onSale").style.display="none";
		document.getElementById("onSaleRegularPriceLabel").style.display="none";
		document.getElementById("onSaleRegularPriceAmt").style.display="none";
		document.getElementById("onSaleSalePriceLabel").style.display="none";
		document.getElementById("onSaleSalePriceAmt").style.display="none";
		
		document.getElementById("noSalePrice").style.display="inline";			
		document.getElementById("icePriceText").innerHTML = "inline";
		document.getElementById("proPrice").innerHTML = "inline";

		document.getElementById("icePriceText").innerHTML = "Starting at:";
		document.getElementById("proPrice").innerHTML = activeProduct.startingPrice;
	}
	
	if(activeProduct.numPayments > 1) {
		document.getElementById("proPayments").innerHTML = activeProduct.numPayments + " payments of " + activeProduct.payment;
	} else {
		document.getElementById("proPayments").innerHTML = "";
	}
	
//	document.getElementById("proPrice").innerHTML = activeProduct.salePrice;
}


