function clearStates(prefix) { var stateValue = ""; var elm = document.getElementById(prefix+"_state_select"); if (elm) { stateValue = elm.value; var i, iMax; iMax = elm.options.length; for (i=(iMax-1); i >= 0; i--) { elm.remove(i); elm.options[i] = null; } } return stateValue; } function populateStates(country,prefix,restoreValue) { var stateValue = clearStates(prefix); var elm = document.getElementById(prefix+"_state_select"); if(!CountriesStates[country.value]) { if (elm) { elm.options[0] = new Option("Select one...", 0); } initStates(); return; } if (elm) { var assignedStates = new Array(); var i = 0; if (CountriesStates[country.value] && CountriesStates[country.value].length > 0) { elm.options[i++] = new Option("Select one...", 0); assignedStates.push(0); } elm.options[i++] = new Option("Other", -1); assignedStates.push(-1); if (CountriesStates[country.value] && CountriesStates[country.value].length > 0) { var j; for(j=0; j 0) { if (correctStateSelectOne) { stateValue = 0; } else { stateValue = -1; } } else { stateValue = -1; } } i = 0; while(elm.value != stateValue) { i ++; elm.value = stateValue; // for Opera compatibility if (i>1000) { break; } } } } initStates(); } function changeState(state, prefix) { obj = document.getElementById(prefix+'_custom_state_body'); if (obj && state) { obj.style.display = (state.value == -1) ? "" : "none"; } }