
var _bt_addcart = 'Add to Cart';
var _bt_sporder = 'Special Order';
var _bt_bkorder = 'Back Order';
var _bt_preorder = 'Pre-Order';
var _bt_outofstock = 'Out of Stock';
var _bttntexts = new Array();
_bttntexts["IS"]=_bt_addcart;
_bttntexts["SO"]=_bt_sporder;
_bttntexts["BO"]=_bt_bkorder;
_bttntexts["PO"]=_bt_preorder

printd("Time taken to call AEC (or local cache): " + (((new Date()).getTime())-tm) + "ms<br>");
debugaec=false;
tm=(new Date()).getTime();
if (typeof(DTL_LCC)!='undefined'&&DTL_LCC) {

	if(!(window.$prices)) {$prices=$("span._price");}
	if(!(window.$bttntext)) {$bttntext=$("span._bttntext");}

	for(var i=0,l=DTL_LCC.length;i<l;i++) {
		cursku=DTL_LCC[i];
		if_error = ((DTL_ERR[i]==3)||(DTL_SCID[i]=="67"&&DTL_AVAIL[i]!="IS"))? 1:0;
		printd(cursku+' AEC('+DTL_TITLE[i]+'~~'+DTL_FORMAT[i]+'~~'+DTL_AVAIL[i]+'~~'+DTL_SCID[i]+'~~'+DTL_RELDATE[i]+'~~'+DTL_UPC[i]+'~~'+DTL_PRICE[i]+') <b>' + ((if_error)? "INVALID/DISCONTINUED SKU":"VALID SKU") + '</b>');

		jquerysku="." + cursku.replace(/\./,"\\.").replace(/\//,"\\/");
		if(!(if_error)) {
			$prices.filter(jquerysku).each(function() {
				printd(cursku+': Updating price from $' + $(this).text() + ' to $' + DTL_PRICE[i]);
				$(this).text(DTL_PRICE[i]);
			});
			$bttntext.filter(jquerysku).each(function() {
				printd(cursku+': Updating cart from ' + $(this).text() + ' to ' + _bttntexts[DTL_AVAIL[i]]);
				$(this).text(_bttntexts[DTL_AVAIL[i]]);
			});
		} else {
			$bttntext.filter(jquerysku).each(function() {
				printd("<b>"+cursku+': Updating cart from ' + $(this).text() + ' to ' + _bt_outofstock+"</b>");
				$buylink=$(this).parent();
				$buylink.text(_bt_outofstock);
				$buylink.css("cursor","default");
				$buylink.click(function() {return false;});
				$buylink.css("background-color","#aaaaaa");
				$buylink.css("background","#aaaaaa");
			});
		}
		printd("------------------------------------------------------------------------");
	}
}

printd( "Time taken to update display: " + (((new Date()).getTime())-tm) + "ms");
