﻿/*
 * Calculate the Price of a Note Pad — 1.0.0
 *
 * Copyright (c) 2009 Wayne Kolenchuk (wayne@kolenchuk.com)
 * $Date: 2009-02-21 
 * You can use or modify this script as long as you display this attribution
 * Variables :  size, quantity, sides, paper, rounded_corners, uv_coating
 * These can be passed to the shopping cart
 */


function NotePadPrice() //calculate postcard price
{
		
	if (document.getElementById('number_of_sheets').selectedIndex==0) { 	
		
	var sheetnumber = new Array();
	//create a new array for 20 sheet prices 
	
	sheetnumber[0] = [1.33,.94,.82,.75,.73,.72,.7];
    sheetnumber[1] = [1.05,.67,.54,.48,.46,.45,.43];
	sheetnumber[2] = [.92,.54,.41,.35,.33,.32,.3];
	sheetnumber[3] = [.85,.47,.35,.28,.26,.25,.23];
	sheetnumber[4] = [.81,.43,.31,.24,.22,.21,.19];

	}
	else if ((document.getElementById('number_of_sheets').selectedIndex)==1) { 	
	var sheetnumber = new Array();
	//create a new array for 45 sheet prices
	
	sheetnumber[0] = [1.85,1.46,1.34,1.27,1.25,1.24,1.22];
    sheetnumber[1] = [1.33,.94,.82,.75,.73,.72,.7];
	sheetnumber[2] = [1.11,.73,.6,.54,.52,.51,.49];
	sheetnumber[3] = [1,.62,.49,.43,.41,.4,.38];
	sheetnumber[4] = [.94,.56,.43,.37,.35,.33,.32];

	}
 
 if (document.getElementById('color1').selectedIndex==0){
		document.getElementById("color_swatch1").src = "mississauga-printing-services-printing-services-mississauga-images/transparent.gif"; 
		 }

	else if (document.getElementById('color1').selectedIndex==1){
		document.getElementById("color_swatch1").src = "mississauga-printing-services-printing-services-mississauga-images/navy_swatch.gif";
		 }
	else if (document.getElementById('color1').selectedIndex==2){
		document.getElementById("color_swatch1").src = "mississauga-printing-services-printing-services-mississauga-images/blue_swatch.gif";
		 }
    else if (document.getElementById('color1').selectedIndex==3){
		document.getElementById("color_swatch1").src = "mississauga-printing-services-printing-services-mississauga-images/burgandy_swatch.gif";
		 }
    else if (document.getElementById('color1').selectedIndex==4){
		document.getElementById("color_swatch1").src = "mississauga-printing-services-printing-services-mississauga-images/red_swatch.gif";
		 }
   else if (document.getElementById('color1').selectedIndex==5){
		document.getElementById("color_swatch1").src = "mississauga-printing-services-printing-services-mississauga-images/black_swatch.gif";
		 }
      else if (document.getElementById('color1').selectedIndex==6){
		document.getElementById("color_swatch1").src = "mississauga-printing-services-printing-services-mississauga-images/sky_blue_swatch.gif";
		 }
		 
	  else if (document.getElementById('color1').selectedIndex==7){
		document.getElementById("color_swatch1").src = "mississauga-printing-services-printing-services-mississauga-images/brown_swatch.gif";
		 }
	  else {
		document.getElementById("color_swatch1").src = "mississauga-printing-services-printing-services-mississauga-images/transparent.gif"; 
	  }
     //get the path to the first color swatch

    
	if (document.getElementById('color2').selectedIndex==0){
		document.getElementById("color_swatch2").src = "mississauga-printing-services-printing-services-mississauga-images/transparent.gif"; 
		 }

	else if (document.getElementById('color2').selectedIndex==1){
		document.getElementById("color_swatch2").src = "mississauga-printing-services-printing-services-mississauga-images/navy_swatch.gif";
		 }
	else if (document.getElementById('color2').selectedIndex==2){
		document.getElementById("color_swatch2").src = "mississauga-printing-services-printing-services-mississauga-images/blue_swatch.gif";
		 }
    else if (document.getElementById('color2').selectedIndex==3){
		document.getElementById("color_swatch2").src = "mississauga-printing-services-printing-services-mississauga-images/burgandy_swatch.gif";
		 }
    else if (document.getElementById('color2').selectedIndex==4){
		document.getElementById("color_swatch2").src = "mississauga-printing-services-printing-services-mississauga-images/red_swatch.gif";
		 }
   else if (document.getElementById('color2').selectedIndex==5){
		document.getElementById("color_swatch2").src = "mississauga-printing-services-printing-services-mississauga-images/black_swatch.gif";
		 }
      else if (document.getElementById('color2').selectedIndex==6){
		document.getElementById("color_swatch2").src = "mississauga-printing-services-printing-services-mississauga-images/sky_blue_swatch.gif";
		 }
		 
	  else if (document.getElementById('color2').selectedIndex==7){
		document.getElementById("color_swatch2").src = "mississauga-printing-services-printing-services-mississauga-images/brown_swatch.gif";
		 }
	  else {
		document.getElementById("color_swatch2").src = "mississauga-printing-services-printing-services-mississauga-images/transparent.gif"; 
	  }
	  
	   //get the path to the second color swatch
 
 if ((document.getElementById('color1').value)=="PMS Match"){
	 
	 var pms_match1 = 35;
     }
	 else {
	 var pms_match1 = 0;	 
	 }
	 // add $35 if color 1 is pms match
if ((document.getElementById('color2').value)=="PMS Match"){
	 
	 var pms_match2 = 35;
     }
	 else {
	 var pms_match2 = 0;	 
	 }
	  // add $35 if color 2 is pms match
	 
if ((document.getElementById('color1').value)=="PMS Match") {
	document.getElementById("first_plus35").innerHTML = "Add $35";
	}
	else {
	document.getElementById("first_plus35").innerHTML = "";	
		
	}
	// display notice if color 1 is pms match
if ((document.getElementById('color2').value)=="PMS Match") {
	document.getElementById("second_plus35").innerHTML = "Add $35";
	}
	else {
	document.getElementById("second_plus35").innerHTML = "";		
	}
    // display notice if color 2 is pms match
	
     var unit_price = sheetnumber[document.getElementById('size').selectedIndex][document.getElementById('number_of_pads').selectedIndex];
	// get the price per unit
	

    var quantity = document.getElementById('number_of_pads').value;
	// get the quantity

	var total_price = ((unit_price * quantity) + pms_match1 + pms_match2).toFixed(2);
	//add everything up and round to 2 decimals
	
	document.getElementById("Price").value = total_price;
	//put the price in a form field and display it
	
     document.getElementById("unit_price").value = unit_price;
	//display unit price

}