$(function(){
	$('li[class^=productColor]').click(function(){
		switchColor(this);//Color Button has been clicked		
	});
	$('li.sizeText24x24,li.productSize24x24').click(function(){
		setSize24(this);//Size Button has been clicked
	});
	$('li.sizeText24x48,li.productSize24x48').click(function(){
		setSize48(this);//Size Button has been clicked
	});
	$('input.quantityInput').keyup(function(event){
		updateQuantity(this);//Quantity Input has been changed
	});
	$('div#pricingLink').click(function(){
		//console.log('pricing link clicked');
		switchPricing();
	});
});
var mi = "#mainImage";
var pNum = "#partNumber";
var mii = "#mainImageImg";
var mifl = "#mainImageFloatLeft";
var qiv = parseInt($(qi).attr('value'));
var qi2v = 0;
var pct = "#productColorTitle";
var pct2 = "#productColorTitle2";
var pt = "#productTitle";
var mvl = "#moreViewsLink";
var mvl2 = "#moreViewsLink2";
var totalp = "#totalPrice";
var totalp2 = "#totalPrice2";
var tilep = "#tilePrice";
var atcb = "#addToCartButton";
var colorandSizeIndex = 0;
var pst = "#productSizeTitle";
var pst2 = "#productSizeTitle2";
var pst24 = "#productSizeTitle24x24";
var pst48 = "#productSizeTitle24x48";
var pst1and2 = '#productSizeTitle, #productSizeTitle2';
var qi = "#quantityInput";
var qi2 = "#quantityInput2";
var qat = "#qtyAppendText";
var vdil = "#volumeDiscountInformationLink, #volumeDiscountInformationLink2";	
//hidden input value that sends the quantity of tiles selected by the user
var atcq = "#addtoCartQuantity";
//hidden input value that sends the productid of the tile selected by the user
var atcpid = "#addtoCartProductID";
var mp = "#minimumPrice";
var productID = 0;
var tileProductID = 35;
var link = "";
var linkMVL = "/moreViews/index.cfm?height=555&width=700";
var linkVDIL = "/volumeDiscountInformation/index.cfm?height=230&width=465";
var tilePrice = 0; 
var dollars = 0; 
var miiSRC = "";
var miiMIFLH = "";
var miiNextSRC = ""; 
var miiNextMIFLH = "";
//Update prices when quantity is changed(keyup)
function updateQuantity(input){
	//console.log("quantity");
	//Set the array index for the current color
	colorandSizeIndex = getColorIndex(pct,pst);
	//Set the productID based on the color array index. 
	tileProductID = ListGetAt(productDetails.productid,colorandSizeIndex);
	
	i = $(input);
	if ( i.attr('value') == undefined || parseInt(i.attr('value')) == NaN ) {
		qiv = 0;
		$(i).attr("value","");
		$(qi2).empty().append('0');	
	}
	else {
		qiv = $(i).attr("value");
		qatv = $(qat).text();
		$(qi2).empty().append(qiv);
		if(qiv == 1 && (qatv == " Cases")) {
			$(qat).empty().append(" Case");
		}
		else if(qiv > 1 && (qatv == " Case")) {
			$(qat).empty().append(" Cases");			
		}	
	}
	//qiv = $(qi2).text();
	//alert('q2'+qi2v);
	/*if ( $(pst).text() == '24" x 48"' ) {
		colorandSizeIndex++;	
	}*/
	
	//Set the price based on the quantity, size and color array index
	qivPlusTotalTileCount = parseInt(totalTileCountNonSamples) + parseInt(qiv);
	if (tileProductID == undefined) {
		tileProductID = productDetails.productid;
		tilePrice = productDetails.pricelevels[0];
	}
	else {
		tilePrice = setTilePrice(qivPlusTotalTileCount,colorandSizeIndex);	
	}

	//Update text in spans with new price
	dollarsTotal = CurrencyFormatted(qiv*tilePrice);
	//alert('d'+dollars);
	$(tilep).empty().append(DollarFormat(tilePrice));
	$(totalp).empty().append(DollarFormat(dollarsTotal));
	$(totalp2).empty().append(DollarFormat(dollarsTotal));
	link = "&selectedTilePrice="+tilePrice+"&productID="+tileProductID+"&quantity="+qivPlusTotalTileCount+"&color="+$(pct).text()+"&size="+URLEncodedFormat($(pst).text())+"&title="+URLEncodedFormat($(pt).text()+"&modal=true&TB_iframe=true&KeepThis=true");
	$(mvl).attr("href",linkMVL+link);	
	$(vdil).attr("href",linkVDIL+link);
	$(atcq).attr("value",qiv);		
	$(atcpid).attr("value",tileProductID);			
	
	//POSSIBLE NEW FEATURE BELOW
	//Show the customer what they have saved from the base ceiling tile price
	//unDiscountedTilePrice = setTilePrice(1,colorandSizeIndex,productDetails);
	//unDiscountedTotalDollars = CurrencyFormatted(qiv*unDiscountedTilePrice - qiv*tilePrice);
	//console.log(unDiscountedTotalDollars);
	//$(totalp).append(" <i>You Saved "+DollarFormat(unDiscountedTotalDollars)+"</i>");
   reloadPricingGrid(qiv,tileProductID,tilePrice);
}
//Updates prices when a color is clicked
function switchColor(li){
	//console.log("switchcolor");
	//console.log(productDetails.pricelevels[2]);
	l = $(li);
	/*if (li.search(/productColorSig/i) != -1) {
		ulTag = 'Sig';
	} 
	else {
		ulTag = '';
	}*/
	
	//Set the quantity 
	qiv = $(qi2).text();
	//Set the array index for the current color		
	//productID = l.attr('productID');
	//console.log(productID); 
	colorandSizeIndex = getColorIndex(l.attr('productColorName'),pst);
	
	//colorandSizeIndex = ListFind(productDetails.productid,productID);
	//console.log(colorandSizeIndex);	

	//alert("switchColor: " + colorandSizeIndex + " " + l.attr('productColorName'));
	/*for(var index=0;index<productDetails.RECORDCOUNT; index++) {
		//console.log(productDetails.DATA['ATTR2'][index]);
		if (l.attr('productColorName') == productDetails.DATA['ATTR2'][index]) {
		 	colorandSizeIndex = index;
		 	break;
		}
	}	
	//Set the color index based on the size selected
	if ( $(pst).text() == '24" x 48"' ) {
		colorandSizeIndex++;
	}*/
	var highestPriceBreak = ListGetAt(productDetails.pricebreaks[colorandSizeIndex], ListLen(productDetails.pricebreaks[colorandSizeIndex]));
	//Set the "as low as" price based on the size and color selected.
	$(mp).empty().append('$'+setTilePrice(highestPriceBreak,colorandSizeIndex));
	tileProductID = ListGetAt(productDetails.productid,colorandSizeIndex);
	//Set the tile price for the color and quantity that has been chosen by the user 
	//+ the quantity of tiles already in the cart
	qivPlusTotalTileCount = parseInt(totalTileCountNonSamples) + parseInt(qiv);
	tilePrice = setTilePrice(qivPlusTotalTileCount,colorandSizeIndex);
	
	//Empty and update prices based on the price breaks  	
	if (isNaN(tilePrice)) {
		//console.log('nan tileprice');
		//console.log(colorandSizeIndex);
		
		tilePrice = ListGetAt(productDetails.pricelevels[colorandSizeIndex]);
	}
	dollarsTotalPrice = CurrencyFormatted(qiv*tilePrice);
	$(tilep).empty().append(DollarFormat(tilePrice));
	$(totalp).empty().append(DollarFormat(dollarsTotalPrice));
	$(totalp2).empty().append(DollarFormat(dollarsTotalPrice));
	
	// FeatherLight
	var csl = "ul.colorSelectList li";
	$(csl).css("border","3px solid #393837");
	$(csl).css("cursor","pointer");	
	// Signature
	var cslSig = "ul.colorSelectListSig li";
	$(cslSig).css("border","3px solid #393837");
	$(cslSig).css("cursor","pointer");	
	
	// FeatherLight
	var liAllButtons = "ul#colorSelectList li";
	$(liAllButtons).css("border","0px");
	// Signature
	var liAllButtonsSig = "ul#colorSelectListSig li";
	$(liAllButtonsSig).css("border","0px");
	
	$(l).css("border","2px solid #3FBBEF");
	$(l).css("width","19px");
	$(l).css("height","19px");
		
	/* Update the Product Color Name Spans */
	$('#productColorTitle, #productColorTitle2').empty().append(l.attr('productColorName'));
	//Update the thickbox window links	
	link = "&selectedTilePrice="+tilePrice+"&productID="+tileProductID+"&quantity="+qivPlusTotalTileCount+"&color="+$(pct).text()+"&size="+URLEncodedFormat($(pst).text())+"&title="+URLEncodedFormat($(pt).text()+"&modal=true&TB_iframe=true&KeepThis=true");
	$(mvl).attr("href",linkMVL+link);
	$(mvl2).attr("href",linkMVL+link);
	$(vdil).attr("href",linkVDIL+link);
	$(atcq).attr("value",qiv);
	$(atcpid).attr("value",tileProductID);
	var cif = ListGetAt(productDetails.filename,colorandSizeIndex);	
	//alert("color size index: " + colorandSizeIndex + "\ncif: " + cif);
		
	if (!cif.match('thumb')) {
		cif = cif.replace('.jpg','_thumb.jpg');
		$(mii).attr("src",cdnProductImageURL+cif);
	}
	else {
		$(mii).attr("src",cdnProductImageURL+cif);
	}

	h = 150;
	//alert("pct: " + $(pct).text() + "\npt: " + $(pt).text().substr(0,9) + "\npst: " + $(pst).text());
	if (($(pct).text() == 'White' || ($(pt).text().substr(0,9) == 'Cambridge'))  && $(pst).text() == '24" x 48"' ) {
		$(mi).css("height","300px");
		$(mii).css("height","300px");
		$(mifl).css("height","285px");
		//console.log('1');
	}
	else if (($(pct).text() != 'White'  && $(pst).text() == '24" x 48"' ) || ($(pst).text() == '24" x 24"') || ($(pst).text() == '23 3/4" x 23 3/4"' || ($(pst).text() == '24" Length'))) {
		$(mii).css("height",h+"px");
		$(mifl).css("height",h+25+"px");
		$('#mainImage').css("height",h+"px");
		//console.log('2');
		$('.fadeHelp').css("display","none");
	
	}
	else {
		$(mii).css("height","300px");
		$(mifl).css("height","285px");				
		//console.log('3');
	}			
	//if (productDetails.allowSample[colorandSizeIndex]) {
	if (1) {
		$('#addsampletocartbutton').css('display','inline');
	}
	else {
		$('#addsampletocartbutton').css('display','none');
	}	
   reloadPricingGrid(qiv,tileProductID,tilePrice);
}	
function setSize24(li){
	//alert("setSize24");
	//console.log("setSize48");
	s = $('li.productSize24x24');	
	//Set the height 
	$(mifl).css("height",'200px');
	//w = productDetails.DATA['WIDTH'][colorandSizeIndex];	
	$(mii).css("height","150px");
	miiMIFLH = s.attr('heightPixels')+'px';
	$(mi).css("height",miiMIFLH);
	$(pst).empty().append(s.attr('productSizeName')); 
	$(pst2).empty().append(s.attr('productSizeName')); 
	//qiv = parseInt($('span#quantityInput2').attr('value'));		
	qiv = $(qi2).text();
	//alert('q'+qiv);
	//alert('q2'+qi2v);
	//Set the array index for the color that was chosen by the user
	colorandSizeIndex = getColorIndex(pct,'24" x 24"');
	//console.log(colorandSizeIndex);
	var highestPriceBreak = ListGetAt(productDetails.pricebreaks[colorandSizeIndex], ListLen(productDetails.pricebreaks[colorandSizeIndex]));
	//Set the "as low as" price based on the size and color selected.	
	$(mp).empty().append('$'+setTilePrice(highestPriceBreak,colorandSizeIndex));
	tileProductID = ListGetAt(productDetails.productid,colorandSizeIndex);

	//Set the tile price for the color and quantity that has been chosen by the user
	qivPlusTotalTileCount = parseInt(totalTileCountNonSamples) + parseInt(qiv);
	
	//Empty and update prices based on the price breaks  	
	tilePrice = setTilePrice(qivPlusTotalTileCount,colorandSizeIndex);
	//console.log(qiv);
	//console.log(tilePrice);	
	dollarsTotalPrice = CurrencyFormatted(qiv*tilePrice);
	$(tilep).empty().append(DollarFormat(tilePrice));
	$(totalp).empty().append(DollarFormat(dollarsTotalPrice));
	$(totalp2).empty().append(DollarFormat(dollarsTotalPrice));
	link = "&selectedTilePrice="+tilePrice+"&productID="+tileProductID+"&quantity="+qivPlusTotalTileCount+"&color="+$(pct).text()+"&size="+URLEncodedFormat($(pst).text())+"&title="+URLEncodedFormat($(pt).text()+"&modal=true&TB_iframe=true&KeepThis=true");
	$(mvl).attr("href",linkMVL+link);		
	$(mvl2).attr("href",linkMVL+link);		
	$(vdil).attr("href",linkVDIL+link);
	$(atcq).attr("value",qiv);
	$(atcpid).attr("value",tileProductID);		
	$(pst48).css("text-decoration","underline");
	$(pst48).css("cursor","pointer");
	$(pst24).css("cursor","default");
	$(pst24).css("text-decoration","none");
	boldBorder24x24();
	//Get the 2by2 color image filename that is stored in the color li element with classname .productColor____
	var productColorClassName = ".productColor"+$(pct).text();
	//console.log(productColorClassName);
	productColorClassName = Replace(productColorClassName," ","");
	var cif = ListGetAt(productDetails.filename,colorandSizeIndex);	
			
	if (!cif.match('thumb')) {
		cif = cif.replace('.jpg','_thumb.jpg');
		$(mii).attr("src",cdnProductImageURL+cif);
	}
	else {
		$(mii).attr("src",cdnProductImageURL+cif);
	}

	//$(mii).attr("src",cdnProductImageURL+cif);
	//$(mii).attr("src",$(mii).attr("src").replace('.jpg','_thumb.jpg'));

	var temp = $(mii).attr("src");
	//console.log(temp);

	// 8/5/09: I'M NOT SURE WHY WE'RE REPLACING WHITE IMAGES WITH 2X4 PICS, SO I'M COMMENTING IT OUT FOR NOW
/*	if ($(pct).text() == 'White') {
		$(mii).attr("src",cdnProductImageURL+img24);
		//console.log('white');
	}*/	
	if ($(mii).attr("src") == '/CeilingTiles/') {
		$(mii).attr("src","/CeilingTiles/imageNotAvailable24X24.jpg");
	}
	$(mii).css("width","150px");
	
	var linkPDF24 = "/productPDFS/"+filenamePDF24;
	$('.productPDFLink').attr("href",linkPDF24);
	var galleryLink = ListGetAt(productDetails.gallerylink,colorandSizeIndex);
	if (galleryLink != "") {
		$('p.custinstallButton').html('<img src="/images/custinstall_button.jpg" align="center">');	
		$('.galleryLink').attr('href',galleryLink);
	}
	else {
		$('p.custinstallButton').html("");	
	}
   reloadPricingGrid(qiv,tileProductID,tilePrice);
	$('#addsampletocartbutton').css('display','inline');
	//console.log('2x2');
	if (productDetails.allowsample[colorandSizeIndex]) {
		$('#addsampletocartbutton').css('display','inline');
	}
	else {
		$('#addsampletocartbutton').css('display','none');
	}	
}
function setSize48(li){
	//console.log("setSize48");
	s = $('li.productSize24x48');
	colorIndex =  getColorIndex(pct,'24" x 48"');
	colorandSizeIndex = colorIndex;
	//console.log(colorandSizeIndex);
	//Add one because this is size 24" x 48"
	//colorandSizeIndex = colorIndex+1;
	$('#mainImage').css("height","300px");
	var cif = ListGetAt(productDetails.filename,colorandSizeIndex);	
	//w = productDetails.DATA['WIDTH'][colorandSizeIndex];	
	h = 150;
	//alert('pct: '+ $(pct).text() + ', pt.text: '+ $(pt).text());
	//alert('not white and not cambridge: ' + $(pct).text() != 'White' && ($(pt).text().substr(0,9) != 'Cambridge'));
	if ($(pct).text() != 'White' && ($(pt).text().substr(0,9) != 'Cambridge')) {
		$(mii).css("height",h+"px");
		$(mifl).css("height",h+25+"px");
		$('#mainImage').css("height",h+"px");
	}
	else {
		$(mii).css("height","300px");
		$(mifl).css("height","285px");			
		$(mifl).css("padding-bottom","35px");				
	}			
	//var cif = ListGetAt(productDetails.filename,1);
	//alert(colorandSizeIndex + " " + cif);
	
	if (!cif.match('thumb')) {
		cif = cif.replace('.jpg','_thumb.jpg');
		$(mii).attr("src",cdnProductImageURL+cif);
	}
	else {
		$(mii).attr("src",cdnProductImageURL+cif);
	}
	$(mii).css("width","150px");
	//$('li[@class^=productColor]').css("display","none"); //hide the colors that are available in the other size
	//$('li[@class^=productColor2by4]').css("display","inline");  //show the colors that are available in this size
	miiNextMIFLH = $(mifl).css("height");		
	miiMIFLH = s.attr('heightPixels')+'px';
	$(pst).empty().append(s.attr('productSizeName')); 
	$(pst2).empty().append(s.attr('productSizeName')); 
	qiv = $(qi2).text();
	//Set the tile price for the color and quantity that has been chosen by the user
	qivPlusTotalTileCount = parseInt(totalTileCountNonSamples) + parseInt(qiv);

	var highestPriceBreak = ListGetAt(productDetails.pricebreaks[colorandSizeIndex], ListLen(productDetails.pricebreaks[colorandSizeIndex]));
	//Set the "as low as" price based on the size and color selected.
	$(mp).empty().append('$'+setTilePrice(highestPriceBreak,colorandSizeIndex));
	//Based on the quantity (qiv), the size, and the color set the tile price and set the productID 
	tileProductID = ListGetAt(productDetails.productid,colorandSizeIndex);	
	//console.log(ListGetAt(priceLevelsAll,1+((colorandSizeIndex)*7)));
	//console.log(qiv);
	tilePrice = setTilePrice(qivPlusTotalTileCount,colorandSizeIndex);	
	dollarsTotal = CurrencyFormatted(qiv*tilePrice);
	//console.log(qiv);console.log(tilePrice);console.log(dollars);
	$(tilep).empty().append(DollarFormat(tilePrice));
	//tilePartNumber = productDetails.DATA['PARTNUMBER'][colorandSizeIndex];
	//$(pNum).empty().append(tilePartNumber);
	$(totalp).empty().append(DollarFormat(dollarsTotal));
	$(totalp2).empty().append(DollarFormat(dollarsTotal));
	link = "&selectedTilePrice="+tilePrice+"&productID="+tileProductID+"&quantity="+qivPlusTotalTileCount+"&color="+$(pct).text()+"&size="+URLEncodedFormat($(pst).text())+"&title="+URLEncodedFormat($(pt).text()+"&modal=true&TB_iframe=true&KeepThis=true");
	var linkMVL = "/moreViews/index.cfm?height=520&width=700";
	$(mvl).attr("href",linkMVL+link);		
	$(mvl2).attr("href",linkMVL+link);
	$(vdil).attr("href",linkVDIL+link);
	$(atcpid).attr("value",tileProductID);		
	$(atcq).attr("value",qiv);
	$(pst24).css("text-decoration","underline");
	$(pst24).css("cursor","pointer");
	$(pst48).css("cursor","default");
	$(pst48).css("text-decoration","none");
	boldBorder24x48();
	var linkPDF48 = "/productPDFS/"+filenamePDF48;
	$('.productPDFLink').attr("href",linkPDF48);		
	
	
	
	var galleryLink = ListGetAt(productDetails.gallerylink,colorandSizeIndex);
	if (galleryLink != "") {
		$('p.custinstallButton').html('<img src="/images/custinstall_button.jpg" align="center">');	
		$('.galleryLink').attr('href',galleryLink);
	}
	else {
		$('p.custinstallButton').html("");	
	}
	
	
	
	reloadPricingGrid(qiv,tileProductID,tilePrice);
	
	//$('#addsampletocartbutton').css('display','none');
	//console.log('2x4');
	if (productDetails.allowsample[colorandSizeIndex]) {
		$('#addsampletocartbutton').css('display','inline');
	}
	else {
		$('#addsampletocartbutton').css('display','none');
	}	
}

function reloadPricingGrid(qiv,tileProductID,tilePrice) {
	//console.log(qiv);
	if (qiv == '' || isNaN(qiv)) {
		qiv = 0;
	}
	//console.log(qiv);

	$.ajax({
					type: "GET",
					url: "/getVolumeDiscountGrid.cfm?productID="+tileProductID+"&quantity="+qiv+"&selectedTilePrice="+tilePrice,
					cache:false,
					success: function(data){
						if(data.error){
							//console.log(data.error);
						}
	               		else{
							$('#containerVolumePricing').html(data);
							//console.log(tileProductID);
						}
					}
	});
}
	
function setTilePrice(qiv,colorandSizeIndex) {
	var result = 0;
	//console.log(qiv);
	/*console.log(pl);
	//console.log(pb);*/
	var priceLevelsList = productDetails.pricelevels[colorandSizeIndex-1];
	//console.log(priceLevelsList);
	//console.log(colorandSizeIndex);
	
	var priceBreaksList = productDetails.pricebreaks[colorandSizeIndex-1];
	var pl = new Array();
	var pb = new Array();
	for (i = 0; i < ListLen(priceLevelsList); i++) {
		pl[i]=parseFloat(ListGetAt(priceLevelsList, i+1));	
	}
	for (i = 0; i < ListLen(priceBreaksList); i++) {
		pb[i]=parseInt(ListGetAt(priceBreaksList, i+1));	
	}
	for (i=pb.length;i>=1;i--) {
		if (qiv >= pb[i]) {
			result = pl[i];
			break;
		} 
	}
	if (result == 0) {
		result = pl[0];
	}
	return result;
}
//Set the array index for the current color and size
function getColorIndex(pct,pst) {
	//console.log(pct);
	//console.log(pst);
	var pctText = '';
	if (pct.search(/product/i) != -1) {
		pctText = $(pct).text();
	}
	else {
		pctText = pct;	
	}
	var pstText = '';
	if (pst.search(/product/i) != -1) {
		pstText = $(pst).text();
	}
	else {
		pstText = pst;	
	}
	//alert("PCT: " +pctText+"\nPST: "+pstText);
	
	for(var index=0;index<ListLen(productDetails.productid)+1; index++) { 
		//console.log(ListGetAt(productDetails.color,index));
		if ((pctText == ListGetAt(productDetails.color,index)) && (pstText == ListGetAt(productDetails.size,index)))
		{
			//alert(pct + " matched: "+$(pct).text() + "\n" + pst + " matched: "+pst + "\nat " + index + "\n" + productDetails.DATA['FILENAME'][index]);
		 //console.log(index);
		 return index;
		}
	}
}

function Replace(s,sb1,sb2,sc) {
	s += "";
	if(!sc || sc.toUpperCase() != "ALL"){
		sc = "";
	} else {
		sc ="g";
	} 	
	var re = new RegExp(sb1,sc);
	return s.replace(re,sb2);
}
function URLDecode(s) {
	return unescape(s);
}
function URLEncodedFormat(s) {
	return encodeURI(s);
}
function ListGetAt(l, p, d) {
	l += ""; // cheap way to convert to a string
	if(!d){d = ",";}
	return l.split(d)[p - 1];
}
function ListLen(l,d) {
	l += ""; // cheap way to convert to a string
	if(!d){d = ",";}
	if(l.length){return l.split(d).length;}
	return 0;
}
function ListFind(l,v,d){
		l += ""; // cheap way to convert to a string
		if(!d){d = ",";}
		var r = 0;
		var listToArray = l.split(d);
		for (var i=0; i < listToArray.length; i++){
			if (listToArray[i] == v){
				r = i + 1;
				break;
			}
		}
		return r;
}
function boldBorder24x24() {
	$('.productSize24x24').css("border","2px solid #3FBBEF");
	$('.productSize24x24').css("height","20px");
	$('.productSize24x24').css("width","20px");
	$('.productSize24x48').css("border","1px solid #393837");
	$('.productSize24x48').css("height","20px");
	$('.productSize24x48').css("width","40px");
	$('.productSize24x48').css("cursor","pointer");
	$('.productSize24x24').css("cursor","default");		
}
function boldBorder24x48() {
	$('.productSize24x24').css("border","1px solid #393837");
	$('.productSize24x24').css("height","20px");
	$('.productSize24x24').css("width","20px");
	$('.productSize24x48').css("border","2px solid #3FBBEF");
	$('.productSize24x48').css("height","20px");
	$('.productSize24x48').css("width","40px");
	$('.productSize24x24').css("cursor","pointer");
	$('.productSize24x48').css("cursor","default");	
}
function CurrencyFormatted(amount) {
	var i = parseFloat(amount);
	if(isNaN(i)) { i = 0.00; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + 0.005) * 100);
	i = i / 100;
	s = new String(i);
	if(s.indexOf('.') < 0) { s += '.00'; }
	if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}
function	DollarFormat(n) {
	var _n = n.toString().replace(/\$|\,/g,'');
	_n = _n.toString().replace('(','-');
	_n = _n.toString().replace(')','');
	if(isNaN(_n)){
		_n = 0;
	}
	var	sign = (_n == (_n = Math.abs(n)));
		_n = Math.floor(_n*100+0.50000000001);
	var	cents = _n%100;
		_n = Math.floor(_n/100).toString();		
	if(cents < 10){
		cents = "0" + cents;
	}
	_n += "." + cents;
	return (((sign)?'':'(') + '$' + _n + ((sign)?'':')'));
}