function disCart() {
	var bV = navigator.userAgent;
	if (bV.indexOf('MSIE 7.0') == -1) {
		getCart();
		$('.cartshow').toggle("fast");
		return false;
	} else {
		var u = 'http://store.projectorsuperstore.com/showcart.cfm?' + $("#utkn").val();
		window.location.href(u);
	}
};

function getCart() {
	var u = 'http://store.projectorsuperstore.com/cfc/Cart.cfc?method=getCurrentCartRemote&callback=?&' + $('#utkn').val();
	$.getJSON(u, function(data) {
		var colMap = {}
				
		for (var i = 0; i < data.COLUMNS.length; i++) {
			colMap[data.COLUMNS[i]] = i
		}
		
		emptyCrt();
		if (data.DATA.length > 0) {
			for (var i = 0; i < data.DATA.length; i++) {
				$('#cartlist5').append("<li class=\"cartitem last\"><div class=\"cartimg\"><img src=\"dw/img_products/" + data.DATA[i][colMap["IMAGE_B"]] + "\" width=\"50\" height=\"50\" /></div><div class=\"cartcontent\"><span class=\"carttitle\">" + data.DATA[i][colMap["TITLE"]] + "</span><br/><span class=\"cartdetail\">PRICE: $" + data.DATA[i][colMap["ITEMTOTAL"]] + "<br/>QTY: " + data.DATA[i][colMap["QT"]] + "</span></div>");
			}
		} else {
			$('#cartlist5').append("<li class=\"cartitem last\"><div class=\"cartimg\"></div><div class=\"cartcontent\"><span class=\"cartdetail\">Your cart is currently empty!</span></div>");
		}
		
		bldFooter();
	});
	
}

function emptyCrt() {
	$('#cartlist5').empty();
}

function bldFooter() {
	var u = 'http://store.projectorsuperstore.com/cfc/Cart.cfc?method=getCartSumRemote&callback=?&' + $('#utkn').val();
	$.getJSON(u, function(data){
		//$('#viewcart').html("Cart Total: $" + CurrencyFormatted(data.DATA[0]));
		$('#cartlist5').append("<li class=\"cartfooter last\"><div id=\"viewcart\">Cart Total: $" + CurrencyFormatted(data.DATA[0],'$') + "</div><div id=\"checkout\"><a href=\"http://store.projectorsuperstore.com/showcart.cfm?" + $('#utkn').val() + "\">Checkout</a></div><div style=\"clear:both;\"></div></li>");
	});
	
}

function numberFormat(nStr,prefix){
    var prefix = prefix || '';
    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 prefix + x1 + x2;
}

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 + .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;
}

