// *** fonctions publiques *** // function limitLength(object, length) {literal}{{/literal} if (object.value.length > length) object.value = object.value.substring(0,length); } function checkThisCheckBoxBox(id, value) {literal}{{/literal} findDOM(id).checked = value; } // * convertit valeur objet en float * function toGoodFloat(object) {literal}{{/literal} object.value = verifyContain(object.value, "0123456789.", ",.", 0); } // * convertit valeur objet en integer * function toGoodInt(object) {literal}{{/literal} object.value = verifyContain(object.value, "0123456789","", 0); } // * convertit valeur objet en code couleur * function toGoodColor(color) {literal}{{/literal} return verifyContain(color, "0123456789ABCDEF","aAbBcCdDeEfF", 6); } // * change couleur fond objet et inverse couleur ecriture * function changeBackground(objectToColorize) {literal}{{/literal} objectToColorize.value = toGoodColor(objectToColorize.value); var color = toGoodColor(objectToColorize.value); if (color.length == 6) {literal}{{/literal} objectToColorize.style.background = '#'+color; objectToColorize.style.color = '#'+inverseHtmlColor(color); } } // * Varie la visibilité en fonction ID * function alternateVisibility(objectID) {literal}{{/literal} var domStyle = findDOM(objectID,1); if (domStyle.display =='block') {literal}{{/literal} domStyle.display='none'; } else {literal}{{/literal} domStyle.display='block'; } return false; } function alternateVisibilityInline(objectID) {literal}{{/literal} var domStyle = findDOM(objectID,1); if (domStyle.display =='inline') {literal}{{/literal} domStyle.display='none'; } else {literal}{{/literal} domStyle.display='inline'; } return false; } // * rend visible * function toVisible(objectID) {literal}{{/literal} var domStyle = findDOM(objectID,1); if (domStyle.display =='block') return false; domStyle.display ='block'; return false; } function toNotVisible(objectID) {literal}{{/literal} var domStyle = findDOM(objectID,1); if (domStyle.display =='none') return false; domStyle.display ='none'; return false; } function alternateVisibilityDble(objectID, objectID1) {literal}{{/literal} alternateVisibility(objectID); alternateVisibility(objectID1); return false; } function alternateVisibilityInlineDble(objectID, objectID1) {literal}{{/literal} alternateVisibilityInline(objectID); alternateVisibilityInline(objectID1); return false; } function miniMaxi(objectID, type) {literal}{{/literal} var div_prefix="div_"; var pict_prefix="pict_"; var prefix; var src_on; var src_off; switch(type) {literal}{{/literal} case "windows": prefix="win"; src_on="button/bt_detail_on.jpg"; src_off="button/bt_detail_off.jpg"; break; case "tree": prefix="tree"; src_on="icon/folder_close.gif"; src_off="icon/folder_open.gif"; break; case "detail": prefix="detail"; src_on="icon/folder_close.gif"; src_off="icon/folder_open.gif"; break; default: prefix=""; src_on=""; src_off=""; break; } var domDiv = findDOM(div_prefix+prefix+'_'+objectID,1); var domPicture = findDOM(pict_prefix+prefix+'_'+objectID); if ('block'==domDiv.display) {literal}{{/literal} domPicture.src='{$picture_path_bo}'+src_on; domDiv.display='none'; } else {literal}{{/literal} domPicture.src='{$picture_path_bo}'+src_off; domDiv.display='block'; } return false; } // *ouvrir pop-up pour sélection couleur * function openChooseColor(url) {literal}{{/literal} window.open(url, '_blank','resizable=yes, alwaysLowered=yes, alwaysRaised=yes, dependent=yes, width=800, height=450'); return false; } // * Prévisu image avant upload * function previewImg(objectID) {literal}{{/literal} var objectFile = findDOM(objectID); var canIPreview = true; if (objectFile==null) canIPreview = false; if (objectFile.value == "") canIPreview = false; if (canIPreview == false) {literal}{{/literal} alert("{'lang_str_nopicturetopreview'|tr:'VALUE'}"); return false; } popImage("file://"+objectFile.value,"{"lang_str_previsutitle"|tr:"JS"}"); return false; } // fonction demandant confirmation d'une action // envoi vrai si action = OK function askConfirm(message) {literal}{{/literal} if (confirm(message)) {literal}{{/literal} return true; }else{literal}{{/literal} return false; } } // fonction qui permet d'afficher une image en popup avec les bonnes dimensions function popImage(imageURL,imageTitle ){literal}{{/literal} var canIPreview = true; if (imageURL=="") canIPreview = false; if (canIPreview == false) {literal}{{/literal} alert("{'lang_str_nopicturetosee'|tr:'VALUE'}"); return false; } if (isNN) {literal}{{/literal}imgWin=window.open('about:blank','',optNN);} else /*if (isIE)*/ {literal}{{/literal}imgWin=window.open('about:blank','',optIE);} with (imgWin.document){literal}{{/literal} writeln('
');writeln(''); writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){literal}{{/literal}'); writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}'); writeln('function reSizeToImage(){literal}{{/literal}');writeln('if (isIE){literal}{{/literal}');writeln('window.resizeTo(100,100);'); writeln('width=100-(document.body.clientWidth-document.images[0].width);'); writeln('height=100-(document.body.clientHeight-document.images[0].height);'); writeln('window.resizeTo(width,height);}');writeln('if (isNN){literal}{{/literal}'); writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}'); writeln('function doTitle(){literal}{{/literal}document.title="'+imageTitle+'";}');writeln(''); if (!AutoClose) writeln('
') else writeln('
'); writeln(''); writeln('
{'lang_str_navigtornofonctionality'|tr:'JS'}
'); writeln('
'); close(); } return false; } // Gestion Menu function displayMenuList() {literal}{{/literal} // code for IE //if(!document.body.currentStyle) return; // var subs = document.getElementsByName('submenu'); // for(var i=0; i maxlength) result = result.substring(0, maxlength); return result; } function hexToDec(hex) {literal}{{/literal} return parseInt(toGoodColor(hex),16); } function decToHex(dec) {literal}{{/literal} var hexa="0123456789ABCDEF"; var hex=""; while (dec>15) {literal}{{/literal} tmp=dec-(Math.floor(dec/16))*16; hex=hexa.charAt(tmp)+hex; dec=Math.floor(dec/16); } hex=hexa.charAt(dec)+hex; if (hex.length == 1) hex = '0'+hex; return (hex); } function inverseHtmlColor(fc) {literal}{{/literal} sr = 255; sg = 255; sb = 255; if (fc.length >= 2) sr = hexToDec(fc.substring(0,2)); if (fc.length >= 4) sg = hexToDec(fc.substring(2,4)); if (fc.length >= 6) sb = hexToDec(fc.substring(4,6)); var decalage = 2; sr = (sr+(51*decalage)) % 255; sg = (sg+(51*decalage)) % 255; sb = (sb+(51*decalage)) % 255; return decToHex(sr)+decToHex(sg)+decToHex(sb); } function findDOM(objectID,withStyle) {literal}{{/literal} var menuArea = "menuArea"; if (withStyle == 1) {literal}{{/literal} if (isID) {literal}{{/literal} return (document.getElementById(objectID).style) ; } else {literal}{{/literal} if (isAll) {literal}{{/literal} return (document.all[objectID].style); } else {literal}{{/literal} if (isLayers) {literal}{{/literal} return (document.layers[menuArea].layers[objectID]); } };} } else {literal}{{/literal} if (isID) {literal}{{/literal} return (document.getElementById(objectID)) ; } else {literal}{{/literal} if (isAll) {literal}{{/literal} return (document.all[objectID]); } else {literal}{{/literal} if (isLayers) {literal}{{/literal} return (document.layers[menuArea].layers[objectID]); } };} } return false; } // Pour savoir si une variable est définie function isNotDefined(var_name) {literal}{{/literal} return 'undefined' == typeof(eval(var_name)); /* var VAR_UNDEFINED=false; function handleError() {literal}{{/literal} VAR_UNDEFINED=true; return true; } var oldOnError=window.onerror; window.onerror=handleError; try {literal}{{/literal} eval(var_name); }catch (e){literal}{{/literal} VAR_UNDEFINED=true; } window.onerror=oldOnError; return VAR_UNDEFINED; */ } // used for InfoBulle Collapse style var isDHTML = 0; var isLayers = 0; var isAll = 0; var isID = 0; if (!isNotDefined(document) && document.getElementById) {literal}{{/literal} isID = 1; isDHTML = 1; } else {literal}{{/literal} browserVersion = parseInt(navigator.appVersion); if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {literal}{{/literal} isLayers = 1; isDHTML = 1; } else {literal}{{/literal} if (document.all) {literal}{{/literal} isAll = 1; isDHTML = 1; } } } // use for openning a popup with the exact image size // Script Source: CodeLifter.com // Copyright 2003 // Do not remove this notice. // SETUPS: // =============================== // Set the horizontal and vertical position for the popup var PositionX = 100; var PositionY = 100; // Set these value approximately 20 pixels greater than the // size of the largest image to be used (needed for Netscape) var defaultWidth = 500; var defaultHeight = 500; // Set autoclose true to have the window close automatically // Set autoclose false to allow multiple popup windows var AutoClose = true; // Do not edit below this line... // ================================ if (parseInt(navigator.appVersion.charAt(0))>=4){literal}{{/literal} var isNN=(navigator.appName=="Netscape")?1:0; var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;} var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',resizable=yes, top='+PositionY; var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',resizable=yes ,top='+PositionY; // ********* START FOR PRINTING METHOD ************ function replaceIntoTags(start_separator, end_separator, replaceString, content, case_sensitive) {literal}{{/literal} mustNotStop = true; i = 0; contentForFind = content; if (!case_sensitive) {literal}{{/literal} contentForFind = contentForFind.toUpperCase(); start_separator = start_separator.toUpperCase(); end_separator = end_separator.toUpperCase(); } for (i=0; (i<10 && mustNotStop); i++) {literal}{{/literal} tmp=""; tmp2=""; start_index = contentForFind.indexOf(start_separator); end_index = contentForFind.indexOf(end_separator); if (start_index>=0 && end_index>=0) {literal}{{/literal} tmp += content.substring(0, start_index); tmp += replaceString; tmp += content.substring(end_index+end_separator.length); content = tmp; tmp2 += contentForFind.substring(0, start_index); tmp2 += replaceString; tmp2 += contentForFind.substring(end_index+end_separator.length); contentForFind = tmp2; } else {literal}{{/literal} mustNotStop = false; } } return content; } // bodyLine = getIntoTagsFirst("", contentNoBorder, false); // function getIntoTagsFirst(start_separator, end_separator, content, case_sensitive) {literal}{{/literal} stringFinded = ""; mustNotStop = true; i = 0; contentChanged = content; if (!case_sensitive) {literal}{{/literal} contentChanged = contentChanged.toUpperCase(); start_separator = start_separator.toUpperCase(); end_separator = end_separator.toUpperCase(); } start_index = contentChanged.indexOf(start_separator); end_index = contentChanged.indexOf(end_separator); //alert(start_index+"<=>"+end_index); if (start_index>=0 && end_index>=0) {literal}{{/literal} stringFinded = content.substring(start_index, end_index+end_separator.length); } return stringFinded; } function popForPrinting(){literal}{{/literal} contentNoBorder = replaceIntoTags("" , "" , "" , document.getElementsByTagName('html')[0].innerHTML , false); contentNoBorder = replaceIntoTags("" , "" , "

" , contentNoBorder , false); // on remplace pour le tag de haut niveau si il existe eXpr = new RegExp("id=(['\"]?)body(['\"]?)([ >])"); contentNoBorder = contentNoBorder.replace(eXpr, "id=$1body_print$2$3"); // il faut supprimer les SCRIPTS du header, car ca perturbe IE fortement contentNoBorder = replaceIntoTags("<"+"SCRIPT" , "/"+"SCRIPT"+">" , "" , contentNoBorder); contentNoBorder = contentNoBorder.replace("", "<"+"SCRIPT"+" language='javascript'> window.print();<"+"/"+"SCRIPT"+">"); content = contentNoBorder; pageWin=window.open('about:blank','_blank', 'menubar=yes'); pageWin.document.writeln(contentNoBorder); pageWin.document.close(); return false; } // ********* END FOR PRINTING METHOD ************ // ******* START for menu : astuce pour passer au dessus des IFRAME ******* function DivSetVisible(state) {literal}{{/literal} var DivRef = findDOM('global_bo_menu'); var IfrRef = findDOM('DivShim'); if(state) {literal}{{/literal} DivRef.style.display = "block"; IfrRef.style.width = DivRef.offsetWidth; IfrRef.style.height = DivRef.offsetHeight; IfrRef.style.top = DivRef.style.top; IfrRef.style.left = DivRef.style.left; IfrRef.style.zIndex = DivRef.style.zIndex - 1; IfrRef.style.display = "block"; } else {literal}{{/literal} DivRef.style.display = "none"; IfrRef.style.display = "none"; } } // ******* END for menu : astuce pour passer au dessus des IFRAME ******* // ******* START for FCK : astuce pour FCK dans des divs ******* function displayHtmlEditor(html_editor_name) {literal}{{/literal} // This is a hack for Gecko... it stops editing when the editor is hidden. if ( !document.all ) {literal}{{/literal} var oEditor = FCKeditorAPI.GetInstance( html_editor_name ) ; if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG ) oEditor.MakeEditable() ; } } // ******* END for FCK : astuce pour FCK dans des divs ******* function quickAccessValidate(form_object, object_select, objet_f_id, objet_hidden, value) {literal}{{/literal} objet_hidden.value = value; if ((value == "product_list")&&(object_select.value == "")) {literal}{{/literal} form_object.action = "{$root_http_current}pNOUVEAU_PRODUIT/product/add_modify.html"; } else if (value == "product_list") {literal}{{/literal} form_object.action = "{$root_http_current}pPRODUITS2/product/list.html"; } objet_f_id.value = object_select.value; form_object.submit(); return false; }