/********************************************************

(c)lotek.info - - live quote javascript calculator

*********************************************************/


function calculate() {
// Get the user's input from the form. Assume it is all valid.

	var page_multiplier = document.fastquote.pages.value;
	var output_format = document.fastquote.format.value;
	var delivery = document.fastquote.timeframe.value;
	
	// Now compute the live estimate
	
	switch (output_format)
	{
	case 'html5':
	var format_total = 28.88;
	break;
	case 'xhtml_strict':
	var format_total = 9.99;
	break;
	case 'xhtml_trans':
	var format_total = 9.99;
	break;
	case 'html1':
	var format_total = 48.88;
	break;
	
	default:
	// the only time we hit this is if someone force feeds the form data
	alert('form data tampering detected, and logged');
	}
	
	switch(delivery)
	{
	
	case 'five':
	var delivery_total = 109.99;
	break;
	case 'rush':
	var delivery_total = 209.99;
	break;
	case 'ten':
	var delivery_total = 73.99;
	break;
	
	default:
	// the only time we hit this is if someone force feeds the form data
	alert('form data tampering detected, and logged');
	}

	var total_extras = 0.00;
	
	for (var i = 0; i < document.fastquote.extras.length; i++)
				{
				
				if(document.fastquote.extras[i].checked)
					{
					if(document.fastquote.extras[i].value == "blog")
						{
						total_extras = total_extras + 199.99;
						}
				
					if(document.fastquote.extras[i].value == "cms")
						{
						total_extras = total_extras + 299.99;
						}
				
					if(document.fastquote.extras[i].value == "gallery")
						{
						total_extras = total_extras + 199.99;
						}
				
					if(document.fastquote.extras[i].value == "custom")
						{
						total_extras = total_extras + 399.99;
						}
				}

				
	}
				
	var estimated_cost = total_extras + page_multiplier * ( format_total + delivery_total );

	if( estimated_cost < 999)
		{
		document.getElementById("price_text").setAttribute("class", "price_text_3digit");
		}

	if( estimated_cost > 999)
		{
		document.getElementById("price_text").setAttribute("class", "price_text_4digit");
		}

	if (estimated_cost > 2000)
		{
		document.getElementById("price_text").setAttribute("class", "price_text_call_now");
		var visible_price = document.getElementById('price_text').firstChild;
		visible_price.data = 'call now!';
		}
	else
		{
		var visible_price = document.getElementById('price_text').firstChild;
		visible_price.data = '$' + estimated_cost.toFixed(2);
		}


}


		    
function increment(){
    if (document.fastquote.pages.value != 99)
	    {
	    document.fastquote.pages.value = parseFloat(document.fastquote.pages.value) + 1;
	    calculate();
	    }
}
		    
function decrement(){
    if (document.fastquote.pages.value > 1)
		{
		document.fastquote.pages.value = parseFloat(document.fastquote.pages.value) - 1;
		calculate();
	}
}