%@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 && f.name == 'Enterprise_form') {
if (f.EntZip) {
f.EntZip.onchange = doZipChange;
}
/*
if (f.EntCtrID) {
f.EntCtrID.onchange = doCountryChange;
}
*/
if (f.EntPhone) {
f.EntPhone.onchange = doPhoneChange;
}
if (f.EntFax) {
f.EntFax.onchange = doFaxChange;
}
if (f.EntAcronym.value == '') {
f.EntAcronym.value = f.EntCorpName.value;
}
if (f.EntCity.value != '') {
f.EntCity.value = checkString(f.EntCity.value, 'upper')
}
}
}
// Si vous changez l'algorithm ici, merci de la changer aussi dans EnterpriseBeanExtension.preSave()
/*function matchCode() {
var countryID = document.forms[0].EntCtrID.options[document.forms[0].EntCtrID.selectedIndex].value;
var phone = doEpurePhone(document.forms[0].EntPhone.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.EntMatchCode.value = matchCode();
if (eraseFaxOnSubmit) {
f.EntFax.value = '';
}
return true;
}
function doZipChange() {
var f = document.forms[0];
retrieveCity(f.EntCtrID.options[f.EntCtrID.selectedIndex].value, f.EntZip.value, 'EntCity');
}
function doCountryChange() {
var f = document.forms[0];
var field = f.EntCtrID;
var oldCountry = f.country;
retrieveCity(field.options[field.selectedIndex].value, f.EntZip.value, 'EntCity');
doEpureTel(f.EntPhone, f.EntPhone, oldCountry);
doEpureTel(f.EntFax, f.EntFax, oldCountry);
oldCountry.value = field.options[field.selectedIndex].value;
doFormatTel(f.EntPhone, ' :', field);
doFormatTel(f.EntFax, ' :', field);
doDisplayEntIntraVAT();
//doVerifMatchCode();
}
function doPhoneChange() {
var f = document.forms[0];
var phoneField = f.EntPhone;
var faxField = f.EntFax;
var countryField = f.EntCtrID;
if (faxField.value == '' && phoneField.value.length > 3) {
faxField.value = suppressNcarac(phoneField.value, 3);
eraseFaxOnSubmit = true;
}
doFormatTel(phoneField, ' :', countryField);
//doVerifMatchCode();
}
function suppressNcarac(string, nbcarac) {
var cpt = 0;
var tempValue = string;
for (i = string.length - 1; i > 0 && cpt < nbcarac ; i--) {
if (tempValue[i] != ' ') {
cpt ++;
}
tempValue = tempValue.substring(0, i);
}
return tempValue;
}
function doFaxChange() {
var f = document.forms[0];
var faxField = f.EntFax;
var countryField = f.EntCtrID;
doFormatTel(faxField, ' :', countryField);
eraseFaxOnSubmit = false;
}
/*function doVerifMatchCode() {
var f = document.forms[0];
if (f.EntPhone.value != '' && f.EntCtrID.options[f.EntCtrID.selectedIndex].value != '') {
var url = "/matchcodeEnt.fl?matchcode=" + encodeURIComponent(matchCode());
if (f.id.value != '') {
url += "&id=" + encodeURIComponent(f.id.value);
}
doAjax(url);
}
}*/
function doChangeSector() {
var strActID = document.forms[0].EntActID.value;
if (strActID != '') {
window.open('/select_sector.fl?id=' + strActID + '&field=EntSector', 'ChoixSecteur', 'menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,width=500,height=250');
} else {
window.alert('');
}
}