/* 
oPlatform is used to conditionally create methods, some of which are platform dependent.
It evaluates to -1 if the platform is NOT Macintosh. Check for it with this syntax:

if (oPlatform > 0){
	*declare method here*
}

JK 7/24/01
*/
//var oPlatform = navigator.appName.indexOf("Mac");

function checkRetAddNS(obj){
	
	//var oBrowser = (navigator.appName.indexOf("Microsoft") != -1);
	var oName = obj.name;
	//if (oBrowser){
		return true;
	//}else{
	//	if (!document.form1.imp_ret_address.checked){
	//		clearReturnAddress();
	//		if (oName != 'imp_ret_address'){
	//			alert("You must check the 'Return Address' box \n in order to create a return address");
	//		}
	//		return false;
	//	}else{
	//		return true;
	//	}
	//}
}
//this function checks whether return address has been selected. If not, it clears the values in the box.

function checkRetAddSelect(obj){
	if (obj.checked){
		
	}else{
		clearReturnAddress();
		return false;
	}
}

function clearReturnAddress(){
	document.form1.imp_ret_address.checked = false;
	document.form1.imp_ret_address.value = '';
	document.form1.imp_return_address_name.value = '';
	document.form1.imp_return_address_1.value = '';
	document.form1.imp_return_address_2.value = '';
	document.form1.imp_return_city.value = '';
	document.form1.imp_return_state.value = '';
	document.form1.imp_return_zip.value = '';
	//document.form1.imp_ret_address_ink_color.selectedIndex = 0;
	document.form1.imp_ret_address_ink_color.value = '';
	document.form1.imp_envelope_font.value = '';
	//document.form1.imp_envelope_font.options[document.form1.imp_envelope_font.selectedIndex].text = 'Please Select';
	document.form1.imp_ret_address.focus();
}


function checkReturnAddress(obj){
	//var oBrowser = (navigator.appName.indexOf("Microsoft") != -1);
	var oName = obj.name;
	var oValue = obj.value;
	
	//if (oBrowser){
		if(obj.checked)
		{
			obj.value = "Yes";
			if(oName == 'imp_ret_address')
			{
				document.getElementById('returnAddress').style.display = '';
				document.form1.imp_ret_address.value = "Yes";
				document.form1.h_imp_ret_address.value="Return Address"
				document.form1.imp_ret_address_ink_color(0).checked=true;
				
			}			
		}
		else
		{
			document.form1.imp_ret_address.value = "";
			document.form1.h_imp_ret_address.value = "";
			obj.value = "";
			if(oName == 'imp_ret_address')
			{
				document.getElementById('returnAddress').style.display = 'none';
				clearReturnAddress();
			}	
			document.form1.imp_ret_address_ink_color(0).checked=false;
			document.form1.imp_ret_address_ink_color(1).checked=false;
			document.form1.imp_ret_address_ink_color(2).checked=false;
			document.form1.imp_ret_address_ink_color(3).checked=false;
			document.form1.imp_ret_address_ink_color(4).checked=false;
			if (document.form1.imp_ret_address_ink_color(5))
				document.form1.imp_ret_address_ink_color(5).checked=false;
			if (document.form1.imp_ret_address_ink_color(6))
				document.form1.imp_ret_address_ink_color(6).checked=false;
			if (document.form1.imp_ret_address_ink_color(7))
				document.form1.imp_ret_address_ink_color(7).checked=false;
			if (document.form1.imp_ret_address_ink_color(8))
				document.form1.imp_ret_address_ink_color(8).checked=false;
						
		}		

	//}else{
	//	if(obj.checked){
	//		obj.value = "Yes";
	//		document.form1.imp_ret_address.value = "Yes";			
	//	}
	//	else{
	//		document.form1.imp_ret_address.value = "";
	//		obj.value = "";
	//		clearReturnAddress(); 
	//		
	//	}	
	//}	
}
function checkRetAddressKit(obj){
	
	if ((obj.checked) || (document.form1.imp_ret_address.value == 'Yes')){	
		if(document.form1.kittedItem2.value == ''){
			productNumber = productNumber + 2;	//updating the global variable--this imprint adds 2 products (envelope set-up and per card charge)
				document.form1.productid.value = addProdID(document.form1.productid.value, document.form1.EnvSetUpID.value + "|" + document.form1.RetAddressID.value);
			//	document.form1.productid.value = addProdID(document.form1.productid.value, document.form1.RetAddressID.value);								
		}		
		document.form1.kittedItem2.value = 'yes'; //set the kitted flag to prevent repeat submission of the same kit item.
		//alert("document.form1.productid.value" + document.form1.productid.value );					
	}
	else {
		if (document.form1.kittedItem2.value == 'yes'){
			productNumber = productNumber - 2;	//updating the global variable--this imprint adds 2 products (envelope set-up and per card charge)
			document.form1.productid.value = remProdID(document.form1.productid.value, document.form1.EnvSetUpID.value + "|" + document.form1.RetAddressID.value);
			//document.form1.productid.value = remProdID(document.form1.productid.value, document.form1.RetAddressID.value);
		}		
		document.form1.kittedItem2.value = ''; //set the kitted flag				
		//alert("document.form1.productid.value" + document.form1.productid.value );	
	}
	
	checkKitID();		
	
}
/*
checkChangeRetAdd() stops Netscape users from selecting envelope fonts without first checking the 
Return Address checkbox. JK 7/5/01
*/
function checkChangeRetAdd(){
	var oValue = document.form1.imp_ret_address.value;
	if (oValue.toUpperCase() != "YES"){
		document.form1.imp_ret_address.focus();
		alert("You must check 'Return Address' in order to \n select envelope fonts.");
		document.form1.imp_ret_address_ink_color.selectedIndex = 0;		
		return false;
	}else{
		return true;
	}
}

function checkEmptyRetAddress(){	
	if ((document.form1.imp_return_address_name.value != '') || (document.form1.imp_return_address_1.value != '') ||(document.form1.imp_return_address_2.value != '') ||(document.form1.imp_return_city.value != '') ||(document.form1.imp_return_state.value != '') ||(document.form1.imp_return_zip.value != '')){
		document.form1.imp_ret_address.checked;
		checkZips();		
		checkRetAddressKit(document.form1.imp_ret_address);		
	}
}
function checkRetAddressFont(){		
	if (document.form1.imp_ret_address.checked){
		if(document.form1.imp_envelope_font.value == ''){
			alert('Please select a font style for your envelope return address.');
			return false;
		}				
	}
	return true;
}

//********************************** TEST 05/28/04 ***********************

function checkRetAddressInkColorKit(obj){
	var selectval = "";
	selectval = document.form1.imp_ret_address_ink_color.value;
	
	// Loop through the options. It is looking for the checked value
	// and then working on validation 
	
	//alert (selectval);
	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 (((selectval == "Red Foil"))||((selectval == "Gold Foil"))){
		if(document.form1.kittedItem3.value != 'yes'){	
			productNumber = ++productNumber;	//updating the global variable
			document.form1.productid.value = addProdID(document.form1.productid.value,document.form1.EnvColorSetUpID.value);
			document.form1.kittedItem3.value = 'yes'; //set the kitted flag to prevent repeat submission of the same kit item. 
		}	
	}
	else {
		if (document.form1.kittedItem3.value == 'yes'){
			document.form1.kittedItem3.value = ''; //set the kitted flag		
			productNumber = --productNumber	//updating the global variable
			document.form1.productid.value = remProdID(document.form1.productid.value,document.form1.EnvColorSetUpID.value);
		}		
	}
	//alert('in checkColorKit selectval = ' + selectval);
	checkKitID();		
	//alert('\n' + 'selectval=' + selectval + '\n' + 'productNumber=' + productNumber + '\n' + 'prodid=' + document.form1.productid.value  + '\n' + 'kitval=' + document.form1.kittedItem3.value);
	return true;
}

//********************************** /TEST FUNCTION **********************

//if (oPlatform > 0){
//	oImprint.checkEmptyRetAddress=checkEmptyRetAddress;
//}
//oImprint.checkRetAddressFont=checkRetAddressFont;
//oImprint.checkRetAddressKit=checkRetAddressKit;

