%@page session="true"%><%@ taglib uri="http://www.e-deal.com/taglib/fl" prefix="fl" %><%
response.setContentType("application/x-javascript");
%>
var eraseFaxOnSubmit = false;
function doOnLoad() {
var f = window.document.forms[0];
if (f) {
if (f.SilZip) {
f.SilZip.onchange = doZipChange;
}
if (f.SilCtrID) {
f.SilCtrID.onchange = doCountryChange;
}
if (f.SilPhone) {
f.SilPhone.onchange = doPhoneChange;
}
if (f.SilFax) {
f.SilFax.onchange = doFaxChange;
}
}
}
function matchCode() {
var countryID = document.forms[0].SilCtrID.options[document.forms[0].SilCtrID.selectedIndex].value;
var phone = doEpurePhone(document.forms[0].SilPhone.value);
var result = countryID;
result += '#' + phone.substring(0, phone.length - 3) ;
return result;
}
function lnkDoReturn() {
setTimeout(refreshLnks, 20);
}
function doSubmit() {
var f = document.forms[0];
f.SilMatchCode.value = matchCode();
if (eraseFaxOnSubmit) {
f.SilFax.value = '';
}
return true;
}
function doZipChange() {
var f = document.forms[0];
retrieveCity(f.SilCtrID.options[f.SilCtrID.selectedIndex].value, f.SilZip.value, 'SilCity');
}
function doCountryChange() {
var f = document.forms[0];
var field = f.SilCtrID;
var oldCountry = f.country;
retrieveCity(field.options[field.selectedIndex].value, f.SilZip.value, 'SilCity');
doEpureTel(f.SilPhone, f.SilPhone, oldCountry);
doEpureTel(f.SilFax, f.SilFax, oldCountry);
oldCountry.value = field.options[field.selectedIndex].value;
doFormatTel(f.SilPhone, ' :', field);
doFormatTel(f.SilFax, ' :', field);
doVerifMatchCode();
}
function doPhoneChange() {
var f = document.forms[0];
var phoneField = f.SilPhone;
var faxField = f.SilFax;
var countryField = f.SilCtrID;
if (faxField.value == '' && phoneField.value.length > 3) {
faxField.value = phoneField.value.substring(0, phoneField.value.length - 3);
eraseFaxOnSubmit = true;
}
doFormatTel(phoneField, ' :', countryField);
doVerifMatchCode();
}
function doFaxChange() {
var f = document.forms[0];
var faxField = f.SilFax;
var countryField = f.SilCtrID;
doFormatTel(faxField, ' :', countryField);
eraseFaxOnSubmit = false;
}
function doVerifMatchCode() {
var f = document.forms[0];
if (f.SilPhone.value != '' && f.SilCtrID.options[f.SilCtrID.selectedIndex].value != '') {
var url = "/matchcode.fl?matchcode=" + encodeURIComponent(matchCode());
if (f.id.value != '') {
url += "&id=" + encodeURIComponent(f.id.value);
}
doAjax(url);
}
}