function validateStateList(countrySelectId, stateSelectId, stateCANSelectId, locked) {
	countrySelectEle = document.getElementById(countrySelectId);
	stateSelectEle = document.getElementById(stateSelectId);
	stateCANSelectEle = document.getElementById(stateCANSelectId);
	stateRequiredEle = document.getElementById(stateSelectId + "Required");

	if (!countrySelectEle) return;
	if (!stateSelectEle && !stateCANSelectEle) return;
	if (locked == undefined) locked = false;

	if (countrySelectEle.value != "United States of America" && countrySelectEle.value != "Canada") {
		if (countrySelectEle.value != "") {
			var intlOptionEle = document.createElement('option');
			intlOptionEle.text = 'International';
			intlOptionEle.value = 'IT';
	
			try {
				stateSelectEle.add(intlOptionEle, null); // does not work in IE
			}
			catch(ex) {
				stateSelectEle.add(intlOptionEle); // IE compliant
			}
			stateSelectEle.value = "IT";
		} else {
			stateSelectEle.value = "";
		}
		stateCANSelectEle.style.display = 'none';
		stateCANSelectEle.style.visibility = 'hidden';
		stateSelectEle.style.display = 'inline';
		stateSelectEle.style.visibility = 'visible';
		stateSelectEle.disabled = true;
		if (stateRequiredEle) {
			stateRequiredEle.style.display = 'none';
			stateRequiredEle.style.visibility = 'hidden';
		}
	} else {
		if (countrySelectEle.value == "United States of America") {
			// remove the "International" option
			var i;
			for (i = stateSelectEle.length - 1; i>=0; i--) {
				if (stateSelectEle.options[i].value == "IT") {
					stateSelectEle.remove(i);
					stateSelectEle.value = "";
				}
			}
			stateCANSelectEle.style.display = 'none';
			stateCANSelectEle.style.visibility = 'hidden';
			stateSelectEle.style.display = 'inline';
			stateSelectEle.style.visibility = 'visible';
			if (!locked) stateSelectEle.disabled = false;
			
		} else if (countrySelectEle.value == "Canada") {

			stateCANSelectEle.style.display = 'inline';
			stateCANSelectEle.style.visibility = 'visible';
			stateSelectEle.style.display = 'none';
			stateSelectEle.style.visibility = 'hidden';
			if (!locked) stateCANSelectEle.disabled = false;
		}
		if (stateRequiredEle) {
			stateRequiredEle.style.display = 'inline';
			stateRequiredEle.style.visibility = 'visible';
		}
	}
}

/* the following functions are adapted from WCM with tab logic removed */

/*
append an error to be displed in header
*/
function append_error(fields, error_message) 
{

    isFormError = true;
    /* Retrieve error element */
    elmError = document.getElementById('displayErrorMessage');
    
    /* Split field into an array */
    var field_array = fields.split(",");
    /* String that will hold the name of the field in the label */
    description_field = '';
    for (var ii=0; ii < field_array.length; ii++)
    {
        /* Set id with prefix */
        prefixedFieldId = 'lbl_' + field_array[ii];
        // Find element

        elmLabel = document.getElementById(prefixedFieldId);
        
        // if found set style
        if(elmLabel)
        {
            /* Add up all the field to be displayed */
            description_field = description_field + elmLabel.innerHTML + '<br />';
            elmLabel.style.color = '#990000';
            elmLabel.style.fontWeight = 'bold';
        }
    }
    
    /* Set a string with html formated error*/
    errorString = '<table class="nnsError"><tr><td class="nnsErrorField">' + description_field + '</td><td></td><td class="nnsErrorMessage">' + error_message + '</td></tr></table>';

    /* Display error*/
    elmError.innerHTML = elmError.innerHTML + errorString;
    //elmError.style.border = '1px doted #880000';

    elmError.style.display = 'block';
    elmError.style.visibility = 'visible';
}

/* Clear all error */
function clear_errors() {

    isFormError = false

    /* Get tab to show error */
    elmError = document.getElementById('displayErrorMessage');
    /* Clear error messages */
    elmError.innerHTML = '';
    /* Get the numbers of forms in the page */
    nfrm = document.forms.length;
    for(h=0;h<nfrm;h++)
    {
       /* Clear all fields by Looping all labels */
        for(ii=0;ii<document.forms[h].elements.length;ii++)
        {
            elmLabel = document.getElementById('lbl_' + document.forms[h].elements[ii].name);
            if(elmLabel) 
            {
                elmLabel.style.color = '#000000';
                elmLabel.style.fontWeight = 'normal';
            }

        }
    
    }
    elmError.style.display = 'none';
    elmError.style.visibility = 'hidden';
}