
//------------------------------

var UPS_options =  new Array(
"UPS Red",
"UPS Blue",
"UPS Ground"
);

var FedEx_options =  new Array(
"FedEx P1",
"FedEx Std Overnight",
"FedEx Economy",
"FedEx Ground"
);


//document.forms[0].shippingService.options[i].value = new Option(FedEx_options[i]);
//document.forms[0].shippingService.options[i].text = new Option(FedEx_options[i]);

//---------------------------------------

function selectShippingOptions(field, index) {
}


//---------------------------------------

function showOptions(field, index, type) {

//type = select,change
//alert("inside showOptions");
var form = document.forms[0];
var shippingOptions =document.forms[0].shippingCompany.options;
var selectedOption = shippingOptions[index].value;
//var optionText = shippingOptions[index].text

//shipperServiceId
var shipperServices = document.forms[0].shippingService;


if( type != null && type == "change") {
	document.forms[0].shippingService.options.length = 0;
}

var sValue = document.forms[0].shippingService.value;

//alert("selectedOption [shippingCompany] = " + selectedOption );
//alert("shippingService Value = " + sValue );
//alert("shippingOptions length =" + shippingOptions.length );

if ( selectedOption == "UPS" ) {


	//alert("service Value=" + sValue );
	//alert("UPS is selected");
	for(var i=0; i< UPS_options.length; i++ ) {
		document.forms[0].shippingService.disabled = false;
		document.forms[0].shippingService.options[i] = new Option(UPS_options[i]);
		if(sValue != null && sValue != "" && sValue == UPS_options[i] ) {
			document.forms[0].shippingService.selectedIndex = i;
		}
		//document.forms[0].shippingService.focus();
	}

}
else  if(selectedOption == 'FedEx') {

	//alert("service Value=" + sValue );

	//alert("FedEx is selected");
	for(var i=0; i< FedEx_options.length; i++ ) {
		document.forms[0].shippingService.disabled = false;
		document.forms[0].shippingService.options[i] = new Option(FedEx_options[i]);
		if(sValue != null && sValue != "" && sValue == FedEx_options[i] ) {
			document.forms[0].shippingService.selectedIndex = i;
		}
		//document.forms[0].shippingService.focus();
	}
}
else if(selectedOption == 'Other') {
	//enable other text field

}
else {

	//clear all
	var shipperServices = document.forms[0].shippingService.options;
	//alert("shipping service length =" + shipperServices.length );
	if(shipperServices && shipperServices.length > 0 ) {
		document.forms[0].shippingService.options[i] = null;
	}
		document.forms[0].shippingService.options.length = 0;
		document.forms[0].shippingService.disabled = true;
}




//if (form.shippingCompany.options != null && form.frameType.length >  50  ) {
//					error += " Frame Type  can not exceed 50 characters !\n";
//}

}




//------------------------------------------------


function processShipToStateDisplay(index) {


var selectedCountryValue = document.forms[0].shipToCountry.options[index].value;
//alert("selectedCountryValue = " + selectedCountryValue);

if( selectedCountryValue != null && selectedCountryValue == "US" ) {
	document.forms[0].shipToOtherState.value = "";
	document.forms[0].shipToOtherState.disabled = true;
	document.forms[0].shipToState.disabled = false;
	document.forms[0].shipToState.focus();
}
else {
	document.forms[0].shipToState.value = "";
	document.forms[0].shipToState.disabled = true;
	document.forms[0].shipToOtherState.disabled = false;
	document.forms[0].shipToOtherState.focus();
}


}


//------------------------------------------------

function processBillToStateDisplay(index) {


var selectedCountryValue = document.forms[0].billToCountry.options[index].value;
//alert("selectedCountryValue = " + selectedCountryValue);

if( selectedCountryValue != null && selectedCountryValue == "US" ) {
	document.forms[0].billToOtherState.value = "";
	document.forms[0].billToOtherState.disabled = true;
	document.forms[0].billToState.disabled = false;
	document.forms[0].billToState.focus();
}
else {
	document.forms[0].billToState.value = "";
	document.forms[0].billToState.disabled = true;
	document.forms[0].billToOtherState.disabled = false;
	document.forms[0].billToOtherState.focus();
}


}


//------------------------------------------------

