/* To compress, visit: http://dean.edwards.name/packer/ */
function $(i){
	return document.getElementById(i);
}
var menu_direction = "down";
var isIE = false;
var isSafari = false;
var isOpera = false;
var preloads;
var imageLoader = {};
var undefined;
function loaded(){
	try{
		document.attachEvent('load',function(){});
		isIE = true;
	}catch(e){};
	if(navigator.userAgent.indexOf('Safari') != -1){
		isSafari = true;	
	};
	if(navigator.userAgent.indexOf('Opera') != -1){
		isOpera = true;
		isIE = false;
	};
	if(isIE){
		$('footer_text').style.fontSize = "9px";	
		$('footer_text').style.letterSpacing = "-1px";	
		$('iefix').style.display="none";
	};
};

var tally = {
	total : 0,
	set : function(obj, amount){
		if(obj.checked == true){
			tally.total += parseFloat(amount);
		}else{
			tally.total -= parseFloat(amount);
		}
		$('error_msg').innerHTML = "";
			$('submit_btn').removeAttribute('disabled');
		var total = Math.round(tally.total * 100)/100;
		if(total > 4000){
			$('error_msg').innerHTML = "You may not pay more than $4000 per transaction. <br />Please remove an item, or contact us for support.";	
			$('submit_btn').setAttribute('disabled', 'disabled');
		}
		total = total.toString();
		
		if(total.indexOf(".") == -1){
			total = total + ".00";	
		}
		if(total.substr(total.indexOf(".")).length < 3){
			total = total + "0";	
		}
		
		var decimal = total.substr(total.indexOf(".")).toString();
		while(parseInt(total.charAt(0)) <= 0){
			total = total.substr(1);
		}
		total = total.toString();
		var int = total.substr(0, total.indexOf("."));
		var tmp = int.split('');
		tmp = tmp.reverse();
		for(var i=0; i<Math.floor(tmp.length/3); i++){
			 tmp.splice((i*4)+3, 0, ",");
		}
		tmp = tmp.reverse();
		tmp = tmp.join('');
		if(tmp.charAt(0) == ","){
			 tmp = tmp.substr(1);
		}
		if(tmp.charAt(0) == ","){
			 tmp = tmp.substr(1);
		}
		if(tmp.charAt(0) == ","){
			 tmp = tmp.substr(1);
		}
		if(tmp.charAt(tmp.length-1) == ","){
			 tmp = tmp.substr(0,tmp.length-1);
		}
		if(tmp.length==0){
		tmp = "0";	
		}
		$('amountdiv').innerHTML = "$" + tmp + "" + decimal;
	}
	
};