



function prepare_step4()
	{
	$('continue-button').setStyle('display', 'block');
	$('status').setStyle('display', 'block');
	$('printed-card-button').setStyle('display', 'none');
	$('e-card-button').setStyle('display', 'none');
	$('terms_conditions_checkbox').setStyle('display', 'none');
	
		if( ($('input-type').value == 'ecard') || (!$('input-logo-file').value && !$('input-greeting').value))
		{
		$('ecard-quantity-note').setStyle('display', 'block');
		$('paper-quantity-note').setStyle('display', 'none');
		} else {
		$('ecard-quantity-note').setStyle('display', 'none');
		$('paper-quantity-note').setStyle('display', 'block');
		}
	
	
	var designID = document.getElementById('input-n').value;
	
		if($('input-type').value == 'ecard')
		{
		document.getElementById('calculator-design-preview').innerHTML = '<img src="system/cards/'+cards[designID]['id']+'-thumb.jpg" alt="" height="55" /><br /> <span id="quantity-price"></span>';
		} else {
		document.getElementById('calculator-design-preview').innerHTML = '<img src="system/cards/'+cards[designID]['id']+'-thumb.jpg" alt="" height="55" /><br /> <span id="quantity-price">at $'+cards[designID]['price']+' each</span>';
		}

	calculate_price();
	}





function reset_calculator()
	{
	document.getElementById('input-quantity').value = '';
	document.getElementById('input-surcharge').value = '';
	document.getElementById('input-total').value = '';
	document.getElementById('quantity').value = '25';

	calculate_price();
	}


	
	
function calculate_price()
	{
	var div_price = document.getElementById('quantity-price');
	var div_surcharge = document.getElementById('quantity-surcharge');
	var div_total = document.getElementById('quantity-total');

	var designID = document.getElementById('input-n').value;
	var quantity = parseInt(document.getElementById('quantity').value);
	var price;
	var surcharge;
	var total;


		if(quantity > 24)
		{

		
			if($('input-type').value == 'ecard')
			{
			if (quantity <= 250) 	{ price = 0.66; } else 
			if (quantity <= 500) 	{ price = 0.63; } else 
			if (quantity <= 1000) 	{ price = 0.55; } else 
			if (quantity <= 1500) 	{ price = 0.50; } else 
			if (quantity <= 2000) 	{ price = 0.47; } else 
			if (quantity <= 2500) 	{ price = 0.46; } else 
			if (quantity <= 3000) 	{ price = 0.45; } else 
			if (quantity <= 3500) 	{ price = 0.44; } else 
			if (quantity <= 4000)	{ price = 0.43; } else 
			if (quantity <= 4500)	{ price = 0.42; } else 
			if (quantity <= 5000)	{ price = 0.41; } else 
			if (quantity > 5000)	{ price = 0.41; }
			
			surcharge = 300;
			
			} else {

				if((quantity > 300) || (!$('input-logo-file').value && !$('input-greeting').value))
				{
				surcharge 	= 0;
				} else {
				surcharge 	= 50;
				}
				
			price 		= parseFloat(cards[designID]['price']);
			}

		total = (price * quantity) + surcharge;	
		$('quantity-price').innerHTML = 'at $'+price.toFixed(2)+' each';
		
		div_surcharge.innerHTML = '$'+surcharge;
		update_step4_inputs(price, quantity, surcharge, total);
		
/*
			if(console.log)
			{
			console.log(total+' = '+strlen(total.toFixed(2)));
			}
*/
		
			if(strlen(total) > 6)
			{
			div_total.innerHTML = '$'+total.toFixed(2);
			div_total.style.fontSize = '25px';
			} else if(strlen(total) > 3) {
			div_total.innerHTML = '$'+total.toFixed(2);
			div_total.style.fontSize = '33px';
			} else {
			div_total.innerHTML = '$'+total;
			div_total.style.fontSize = '38px';
			}
		
		
		update_statusbar('When you are ready click Continue to preview your card.', 'normal', true);
		} else {
		update_step4_inputs(price, quantity, 'N/A', 'N/A', 'N/A');
		
		update_statusbar('You must order at least 25 cards.', 'error', true);

			if($('input-type').value == 'ecard')
			{
			div_price.innerHTML = '';
			div_surcharge.innerHTML = '-';
			div_total.innerHTML = '-';
			} else {
			price = parseFloat(cards[designID]['price']);
			div_price.innerHTML = 'at $'+price.toFixed(2)+' each';
			div_surcharge.innerHTML = '-';
			div_total.innerHTML = '-';
			}

		}


	}


function is_custom_greeting(greeting)	
	{
	
		if($('greeting4').checked)
		{
		return true;
		} else {
		return false;
		}
	
	}
	
	
function update_step4_inputs(price_value, quantity_value, surcharge_value, total_value)
	{
	document.getElementById('input-price').value = price_value;
	document.getElementById('input-quantity').value = quantity_value;
	document.getElementById('input-surcharge').value = surcharge_value;
	document.getElementById('input-total').value = total_value;
	}
	
	
	

	
	
	
	
	
	
	
	
