// CONTENTS ====================================================================
/*
- DEFAULT 							- common code that runs on every page.
*/

// DEFAULT --------------------------------------------------------------
function InitDefault(){
	
	// call other Init functions
	InitStyles();
	InitPrintLinks();

}

function InitPrintLinks() {
	$('li.print').show();
	$('li.print').click(function() { window.print(); return false; });
}

function InitStyles(){
	// helper styles 
	$('#account-details ul li:even').addClass('alt');
	$('#sections-latest li:even').css('clear', 'both');
	if( $('#cart-progress li').length < 5 ){
		$('#cart-progress li').width( $('#cart-progress').width() / $('#cart-progress li').length );
	}
	$('#shopping-process tr').each(function(){
		$(this).children('td:last').css('border-right', 'none');
	});
	$('.listing li').addClass('bigger-click');
	SetBiggerClick();
	
	if( $('#section-nav li').length < 5 ) {
		$('#section-nav li').css('width', 'auto');
		$('#section-nav li').css('margin-right', 15);
	}	
}

function updateAddToCartTotals(ddl) {
    var qty = ddl.options[ddl.selectedIndex].value;
    var price = $('#item-price-value').text().replace("$", "");
    var totalCost = qty * price;
    $('.total-cost').text("$" + CurrencyFormatted(totalCost));
}

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;
}

    

// ======================================================================

