//*************************************************************************
//** This function handles the kit-on-fly option						***
//** Developed On: 05/26/04												***
//** Update History:													***
//**	06/07/04:														***
//**	Reason: Initially there was only one charge for envelope foil	***
//**			Set up. Client decided to add per envelope charge along ***
//**			with the set up charge. -- Sree							***
//**	04/26/06:														***
//**		Users were still getting billed for return address envelope ***
//**		font even though they unchecked the return address checkbox ***
//*************************************************************************

function checkRetAddressInkColorKit1(obj){
	var selectval = "";
	var myReturnAddress = document.form1.imp_ret_address.value;
	//selectval = document.form1.imp_ret_address_ink_color.value;
	
	for(i=0;i < document.form1.imp_ret_address_ink_color.length;i++){
		if(document.form1.imp_ret_address_ink_color[i].checked){
			selectval = document.form1.imp_ret_address_ink_color[i].value;
		}
	}
	
	if (myReturnAddress == "Yes"){
		if (((selectval == "Red Foil"))||((selectval == "Gold Foil"))||((selectval == "Silver Foil"))||((selectval == "Blue Foil"))){
			if(document.form1.kittedItem4.value != 'yes'){	
				productNumber = productNumber + 2; //updating the global variable--this imprint adds 2 products (envelope foil set-up and per envelope charge)
				document.form1.productid.value = addProdID(document.form1.productid.value, document.form1.EnvColorSetUpID.value + "|" + document.form1.PerEnvColorChargeID.value);
				
				//document.form1.productid.value = addProdID(document.form1.productid.value, document.form1.PerEnvColorChargeID.value);
				document.form1.productid.value = remProdID(document.form1.productid.value, document.form1.RetAddressID.value);
				document.form1.productid.value = remProdID(document.form1.productid.value, document.form1.EnvSetUpID.value);
								
				//productNumber = ++productNumber;	//updating the global variable
				//document.form1.productid.value = addProdID(document.form1.productid.value,document.form1.EnvColorSetUpID.value);
				document.form1.kittedItem4.value = 'yes'; //set the kitted flag to prevent repeat submission of the same kit item. 
			}	
		}
		else {
			if (document.form1.kittedItem4.value == 'yes'){
				document.form1.kittedItem4.value = ''; //set the kitted flag		
				productNumber = productNumber - 2; //updating the global variable -- this impring deduct 2 products (envelope foil set-up and per envelope charge)
				document.form1.productid.value = remProdID(document.form1.productid.value, document.form1.EnvColorSetUpID.value + "|" + document.form1.PerEnvColorChargeID.value);
				
				//document.form1.productid.value = remProdID(document.form1.productid.value, document.form1.PerEnvColorChargeID.value);
				//document.form1.productid.value = addProdID(document.form1.productid.value, document.form1.RetAddressID.value);
				
				//productNumber = --productNumber	//updating the global variable
				//document.form1.productid.value = remProdID(document.form1.productid.value,document.form1.EnvColorSetUpID.value);				
			}		
			
			//If it's not foil and it is a in with return Address. Add them back...
			  if (document.form1.imp_ret_address.checked || document.form1.imp_ret_address.value == 'Yes')
				{
					productNumber = productNumber + 2; //updating the global variable 
					document.form1.productid.value = addProdID(document.form1.productid.value, document.form1.EnvSetUpID.value + "|" + document.form1.RetAddressID.value);	
				}			
		}
	}else{
		if (document.form1.kittedItem4.value == 'yes'){
			document.form1.kittedItem4.value = ''; //set the kitted flag		
			productNumber = productNumber - 2; //updating the global variable -- this impring deduct 2 products (envelope foil set-up and per envelope charge)
			document.form1.productid.value = remProdID(document.form1.productid.value, document.form1.EnvColorSetUpID.value + "|" + document.form1.PerEnvColorChargeID.value);
			
			//document.form1.productid.value = remProdID(document.form1.productid.value, document.form1.PerEnvColorChargeID.value);
			
			//productNumber = --productNumber	//updating the global variable
			//document.form1.productid.value = remProdID(document.form1.productid.value,document.form1.EnvColorSetUpID.value);
		}		
	}
	checkKitID();		
	//alert('\n' + 'selectval=' + selectval + '\n' + 'productNumber=' + productNumber + '\n' + 'prodid=' + document.form1.productid.value  + '\n' + 'kitval=' + document.form1.kittedItem4.value);
	return true;
}
//************************************ TEST DONE ***************************
//oImprint.checkRetAddressInkColorKit1=checkRetAddressInkColorKit1;
envelope.checkRetAddressInkColorKit1=checkRetAddressInkColorKit1;

