%@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.SupZip) {
f.SupZip.onchange = doZipChange;
}
if (f.SupCtrID) {
f.SupCtrID.onchange = doCountryChange;
}
if (f.SupPhone) {
f.SupPhone.onchange = doPhoneChange;
}
if (f.SupFax) {
f.SupFax.onchange = doFaxChange;
}
}
}
function doSubmit() {
mf = document.forms[0];
//gestion des champs obligatoires, si il en manque un, retourner false;
if (mf.SupTitle.value == '') {
window.alert("");
mf.SupTitle.focus();
return false;
}
if (mf.SupWeb.value != '' && mf.SupWeb.value.substring(0,7) != 'http://') {
mf.SupWeb.value = 'http://' + mf.SupWeb.value;
}
prepNumsForSubmit(separateurDecimal, separateurMilliers, mf.SupSpecimenNb, mf.SupPageNb, mf.SupLocking, mf.SupPutting, mf.SupRotation);
if (mf.SupSpecimenNb.value == '' || mf.SupSpecimenNb.value == '0') {
window.alert("");
mf.SupSpecimenNb.focus();
return false;
}
if (mf.SupRotation.value == '' || mf.SupRotation.value == '0') {
window.alert("");
mf.SupRotation.focus();
return false;
}
if (eraseFaxOnSubmit) {
mf.SupFax.value = '';
}
prepAutoNumsForSubmit();
presentFieldsValue();
return true;
}
function doChangeEditor() {
window.open('/select.fl?type=Editor&field=SupEdiID' , 'ChoixGroupe' , 'menubar=no,status=yes,toolbar=no,scrollbars=yes,resizable=yes,width=500,height=500');
}
function doCountryChange() {
var f = document.forms[0];
var field = f.SupCtrID;
var oldCountry = f.country;
retrieveCity(field.options[field.selectedIndex].value, f.SupZip.value, 'SupCity');
doEpureTel(f.SupPhone, f.SupPhone, oldCountry);
doEpureTel(f.SupFax, f.SupFax, oldCountry);
oldCountry.value = field.options[field.selectedIndex].value;
doFormatTel(f.SupPhone, ' :', field);
doFormatTel(f.SupFax, ' :', field);
doVerifMatchCode();
}
function doPhoneChange() {
var f = document.forms[0];
var phoneField = f.SupPhone;
var faxField = f.SupFax;
var countryField = f.SupCtrID;
if (faxField.value == '' && phoneField.value.length > 3) {
faxField.value = phoneField.value.substring(0, phoneField.value.length - 3);
eraseFaxOnSubmit = true;
}
doFormatTel(phoneField, ' :', countryField);
}
function doFaxChange() {
var f = document.forms[0];
var faxField = f.SupFax;
var countryField = f.SupCtrID;
doFormatTel(faxField, ' :', countryField);
eraseFaxOnSubmit = false;
}
function doZipChange() {
var f = document.forms[0];
retrieveCity(f.SupCtrID.options[f.SupCtrID.selectedIndex].value, f.SupZip.value, 'SupCity');
}
function matchCode() {
var countryID = document.forms[0].SupCtrID.options[document.forms[0].SupCtrID.selectedIndex].value;
var phone = doEpurePhone(document.forms[0].EPhone.value);
var result = countryID;
result += '#' + phone.substring(0, phone.length - 3) ;
return result;
}
function doVerifMatchCode() {
var f = document.forms[0];
if (f.SupPhone.value != '' && f.SupCtrID.options[f.SupCtrID.selectedIndex].value != '') {
var url = "/matchcode.fl?matchcode=" + encodeURIComponent(matchCode());
if (f.id.value != '') {
url += "&id=" + encodeURIComponent(f.id.value);
}
doAjax(url);
}
}