var helpURL = '/helpcenter/popup/calculator';
var estimateURL = '/products/estimate';

var confirmText = 'IMPORTANT: PLEASE CHECK YOUR JOB SPECIFICATIONS CAREFULLY!\n\nDue to high volume and fast turnaround, please check order specifications carefully. After a job is ordered, no specifications may be changed, except shipping for an additional fee. Incorrect orders must be canceled and reordered. Partially processed orders will incur fees.\n\nPlease click "Ok" if you want to continue OR "Cancel" if you want to review your specifications.';

var hideProduct = 1;
var priceWrapper = false;
var timer = false;

var useCoupon = true;
var showUnitPrice = true;


function estimatePopup(win_name){ 
	var pop = window.open('', win_name,'width=425,height=600,toolbar=no,resizable=yes,location=no,directories=no,menubar=no,scrollbars=no,copyhistory=no');

	if(pop.focus){ pop.focus(); }

	return true;
}

function calcFI_TPL(title, item, help, classNames) {
	if (! classNames) { classNames = ''; } 
	var trClassNames = classNames.replace('TD', 'TR');
	classNames += ' fiTitle fiItem';
	var tpl = '<tr class="' + trClassNames + '"><td class="' + classNames + '" colspan="2">';
	tpl += title;
	if (title != '')
		tpl += '<br />';
	tpl += item;
	if (help != '')
		tpl += '<a href="' + helpURL + '#a_name_' + help + '" rel="quickhelp"><img class="helpIMG" src="/img/ui/help.png" /></a>';
	tpl += '</td></tr>';
	return tpl;
}

function calcTotalFI_TPL(title, item) {		
/*
	var tpl = '<tr class="priceTR"><td class="fiTitle fiItem">';
	tpl += title;
	tpl += '</td><td class="price">';
	tpl += item;
	tpl += '</td></tr>';
	return tpl;
*/
	clearTimeout(timer);

	var inner = '<div class="priceTitle">' + title + '</div>';
			inner += '<div class="price">' + item + '</div>';
			inner += '<div class="clear"></div>';
			

	var points = false;
	if (EC_LithoCalc.points) {
		points = '<div class="rewardTitle">Reward Points</div>';
		points += '<div id="points" class="price">' + EC_LithoCalc.points + '</div>';
		points += '<div class="clear"></div>';
	}

	if (priceWrapper != false) {
	
		priceWrapper += inner;
		
		var func = (function() { 
			$('priceWrapper').set('html', priceWrapper); 
			priceWrapper = false; 
			
			if (points != false && $('rewardsWrapper') != null) {
				$('rewardsWrapper').set('html', points); 
			}
			
			SqueezeBox.assign($$('a[rel=quickhelp]'), {
				size: {x: 330, y: 400},
				scrollingParent: 'qh_container'
			});
		});
		timer = func.delay(100);
		
		return '';
	} else {
		priceWrapper = inner;
		
		var tpl = '<tr class="priceTR"><td colspan="2">';
		tpl += '<div id="priceWrapper">';
		tpl += priceWrapper;
		tpl += '</div>';
		
		if (points != false) {
			tpl += '<div id="rewardsWrapper">';
			tpl += points;
			tpl += '</div>';
		}
		
		tpl += '</td></tr>';
	
		return tpl;
	}	
}

function calcHeading_TPL(item) {
	var tpl = '<tr><td colspan="2" class="formHeading" id="product_name">';
	tpl += item;
	tpl += '</td></tr>';
	return tpl;
}

function calcBTN_TPL(val, func, classNames) {
/*
	if (classNames == 'orderBTN') {
		return '<a class="orderBTN" onclick="' + func + '">' + val + '</a>';
	}
	return '<input type="button" class="fiBTN" value="' + val + '" onclick="' + func + '" />';
*/
	return '<a class="' + classNames + '" onclick="' + func + '">' + val + '</a>';
}

function calcHR_TPL() {
	return '';
}

function calcShipGrid_TPL(body) {
	return '<tr><td colspan="2"><div id="shipGrid">' + body + '</div></td></tr>';
}

function postageWarning() {
	return '<tr><td colspan="2"><p class="error"><b>Note: Please note that postage is estimated. We will not charge the credit card on file for postage until your list is uploaded and verified.</b></p></td></tr>';
};

function pennyFormat(amt) {
	return '$' + (Math.round(amt * 1000) / 1000);
}


window.addEvent('domready', function() {
	if (window.customConfirmText) {
		confirmText = customConfirmText;
	}	
});
