﻿<!-- Begin Change Value In Paypal Form
// Copyright Maxbal Genealogy 2007 - All rights reserved
// This script may not be used without permission

// Updates price and item number in PaypPal form depending on option selected
// and validates that an item has been selcted

function UpdateItemCode(form)
{

// Blank Charts Page 1 Code

 valid = true;
 promo = "FHM1108";
 promoname = " Promotion - Family History Monthly 20% discount voucher ";
 ispromo = "No"; 	// Yes If Promotion
 					// No If No Promotion

form.on0.value = "";
 
 price = 5;
 promoprice = 4;
 qty = form.os1.selectedIndex;
 
if ( qty == 0 )
   		{
        	alert ( "Please select the length of chart from the dropdown box." );
        	return valid = false;
    	}

if ( form.handling_cart.selectedIndex == 0 )
   		{
        	alert ( "Please select the postage zone from the dropdown box.");
        	return valid = false;
    	}

if ( form.os0.value )
  {
  	if ( ispromo == "No" )
  		{
  		  alert ("There are no current promotions on this item");
  		  form.os0.value = "";
  		  return valid = false;
  		}

	 else if ( form.os0.value != promo )
   		{
          alert ("You have entered an invalid promotion code" + '\n\n' + "The code is case sensitive so it must be entered using the correct upper and lower case letters." + '\n\n' + "Check that the code entered is still valid");
  		  form.os0.value = "";
          return valid = false;
        }
   	 else if ( form.os0.value == promo )
   	 	{
 	 		price = promoprice;
 			form.on0.value = promoname;
		}
   }

if (form.item_name.value == "Working Chart 20 Generations")
  		{
 		  form.item_number.value = "C-WORK-20";
  		}
if (form.item_name.value == "Working Chart 15 Generations")
  		{
 		  form.item_number.value = "C-WORK-15";
  		}

form.amount.value = price * qty;

// alert (form.name + " " + form.item_number.value + " " + form.amount.value + " " + form.on0.value + " " + form.os0.value + " " + form.item_name.value);
return valid;
}

// End -->

