// Mimeo.com Online Pricing Calculator
// Author: Taulant Balla, Marketing Communications
// Last Updated: 02.23.2009
	
function getPosterBtnName(SetName) {
  
  var sel = document.getElementsByName(SetName);
  var fnd = -1;
  var str = '';
  for (var i=0; i<sel.length; i++) {
    if (sel[i].checked == true) { str = sel[i].value;  fnd = i; }
  }
  return fnd;   // return option index of selection
}	

function posterPrice(form) {
 	
	len = document.calcForm.poster_size.length; 
	i = 0;
	chosen = "";

	for (i = 0; i < len; i++) {
		if (document.calcForm.poster_size[i].selected) {
			chosen = chosen + document.calcForm.poster_size[i].value + "\n"
		}
	}	
	
	if (chosen == 1) {
	  // 12x18 Poster Paper Stock Prices By Turnaround	
	  var poster_stock_prices = [	
		  ['7.50','9.375','11.250'], // 96 Hrs	
		  ['8.50','10.625','12.75'], // 48 Hrs	
		  ['10.00','12.50','15.00'] // 24 Hrs		  
	  ]; 
	  //Poster Finishing Options Prices By Turnaround
	  var poster_fo_prices = [		  
		  ['0','2.625','8.500'],  // 96 Hrs
		  ['0','2.975','9.000'], // 48 Hrs
		  ['0','3.500','10.000']  // 24 Hrs
	  ]; }	
	
	else if (chosen == 2) {
	  // 18x24 Poster Paper Stock Prices By Turnaround	
	  var poster_stock_prices = [	
		  ['7.50','12.38','18.00'], // 96 Hrs	
		  ['8.50','14.03','20.40'], // 48 Hrs	
		  ['10.00','16.50','24.00'] // 24 Hrs		  
	  ]; 
	  //Poster Finishing Options Prices By Turnaround
	  var poster_fo_prices = [		  
		  ['0','4.55','12.00'],  // 96 Hrs
		  ['0','5.20','13.60'], // 48 Hrs
		  ['0','6.50','16.00']  // 24 Hrs
	  ]; }
	  
	else if (chosen == 3) {
	  // 24x36 Poster Paper Stock Prices By Turnaround	
	  var poster_stock_prices = [
		  ['12.75','22.50','33.00'], // 96 Hrs	
		  ['14.45','25.50','37.40'], // 48 Hrs	
		  ['17.00','30.00','44.00']  // 24 Hrs								 								 
	  ]; 
	  // 24x36 Poster Finishing Options Prices By Turnaround
	  var poster_fo_prices = [		  
		  ['0','9.10','21.375'],  // 96 Hrs
		  ['0','10.40','24.225'], // 48 Hrs
		  ['0','13.00','28.500']  // 24 Hrs
	  ]; }
	  
	else if (chosen == 4) {
	  // 36x48 Poster Paper Stock Prices By Turnaround
	  var poster_stock_prices = [
		  ['22.50','43.50','60.00'], // 96 Hrs	
		  ['22.50','49.30','68.00'], // 48 Hrs	
		  ['30.00','58.00','80.00']  // 24 Hrs									 
	];
	  // 36x48 Poster Finishing Options Prices By Turnaround
	  var poster_fo_prices = [		  
		  ['0','17.500','33.750'],  // 96 Hrs
		  ['0','20.000','38.250'], // 48 Hrs
		  ['0','25.000','45.000']  // 24 Hrs
	  ]; }
	  
	  
	   // disable same-day turnaround if finishing options is mounted	
	 if (document.calcForm.poster_fo.selectedIndex == 2 || document.calcForm.poster_fo.selectedIndex == 1)
	 {
		if (document.calcForm.poster_turnaround[2].checked == true)
		{
			document.calcForm.poster_turnaround[2].checked = false;
			document.calcForm.poster_turnaround[0].checked = true;		
		}
		document.calcForm.poster_turnaround[2].disabled = true;
		
		document.getElementById('no-sameday').style.display = "block";	
		
		
	 }
	 else 
	 {
		document.calcForm.poster_turnaround[2].disabled = false;	
		document.getElementById('no-sameday').style.display = "none"; 
		
		
	 }
	 
	 // get prices based on selections
		var pndx = getPosterBtnName('poster_turnaround');
	  // set poster paper stock variable
	  poster_selected_Item = document.calcForm.poster_paper_stock.selectedIndex;
	  var poster_stock = parseFloat(poster_stock_prices[pndx][poster_selected_Item]); 	
	  
	  // set poster finishing options variable
	  fo_selected_Item = document.calcForm.poster_fo.selectedIndex;
	  var poster_fo = parseFloat(poster_fo_prices[pndx][fo_selected_Item]);   
	  

	
	 
	
	// set number of posters
	// set total number of copies
	var num_posters = 0;
   	if (document.calcForm.num_posters.value!="" && !isNaN(document.calcForm.num_posters.value)) 
   	{
   		num_posters = parseFloat(document.calcForm.num_posters.value);
	}
	
	var poster_max_discount = 1000; //50% off first order, max of $1000
	var poster_discount = new Number(00);
	var poster_total_cost = new Number(00); // total cost before 50% discount
	var poster_price_quote = new Number(00); // final price for this quote after discount
		
	poster_total_cost = parseFloat(num_posters * (poster_stock + poster_fo) ); 
		
	//display total cost
	if (poster_total_cost != 0)
	{
		document.getElementById('postercost').innerHTML = "&nbsp;&nbsp;$" + poster_total_cost.toFixed(2);
	}
	else
	{
		document.getElementById('postercost').innerHTML = "&nbsp;&nbsp;0";
	}

	// display discount and final cost	
	if (poster_total_cost >= poster_max_discount) 
	{
		poster_discount = poster_max_discount/2;
		document.getElementById('posterdiscount').innerHTML = "- $" + poster_discount.toFixed(2);
		poster_price_quote = poster_total_cost - poster_discount;
		document.getElementById('posterquote').innerHTML = "&nbsp;&nbsp;$" + poster_price_quote.toFixed(2);		
	}
	else if (poster_total_cost != 0)
	{
		poster_discount = poster_total_cost/2;
		document.getElementById('posterdiscount').innerHTML = "- $" + poster_discount.toFixed(2);
		poster_price_quote = poster_total_cost - poster_discount;
		document.getElementById('posterquote').innerHTML = "&nbsp;&nbsp;$" + poster_price_quote.toFixed(2);		
	}
	else
	{
		document.getElementById('posterdiscount').innerHTML = "&nbsp;&nbsp;0";
		document.getElementById('posterquote').innerHTML = "&nbsp;&nbsp;0";
	}

	Analytics();
	
 //CHECK NUMBERS 
	//document.getElementById('poster_results').innerHTML = "<b>Numbers Check (for one set):</b> <br>Poster Size:&nbsp; " + chosen + "<br>Poster Stock:&nbsp; " + poster_stock + "<br>Finishing Options&nbsp;:" + poster_fo;

}

function Analytics()	{
	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	irtrn = MyMEGA.conditionalSetInt("calc", 1, false);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
}
