function chronologieDate(date1, champ1, date2, champ2) { var d1 = new Date(date1.value.substring(6,10), date1.value.substring(3,5) - 1, date1.value.substring(0,2)); var d2 = new Date(date2.value.substring(6,10), date2.value.substring(3,5) - 1, date2.value.substring(0,2)); if (d1>d2) { alert("Le champ '" + champ1 + "' est superieur au champ '" + champ2 + "'."); date2.focus(); return false; } return true; } ///// function setNow(obj) { var date = new Date(); obj.value = (date.getDate() < 10) ? '0' + date.getDate() : date.getDate(); var month = date.getMonth() + 1; obj.value += (month < 10) ? '/0' + month: '/' + month; var year = date.getYear() % 100; obj.value += '/200' + year;//marche jusqu'en 2009 ;-) } ///// function setLater(obj) { obj.value = '31/12/2035'; } ///// var isFilterShown; function showFilter(show) { var val = (show) ? 'block' : 'none' document.getElementById('filtre').style.display = val; if (document.getElementById('filtreInit')) document.getElementById('filtreInit').style.display = val; isFilterShown = show; } ///// function replaceString(oldS, newS, fullS) { for (var i=0; i < fullS.length; i++) { if (fullS.substring(i, i+oldS.length) == oldS) { fullS = fullS.substring(0,i) + newS + fullS.substring(i+oldS.length, fullS.length); } } return fullS; } ///// function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } ///// function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); } return null; } /********************/ /* DEPLACE CRITERE */ /********************/ /* * NONSTABLE : Détermine si un noeud est enfant d'un autre * @param : oNode : node : Noeud potentiellement enfant * @param : other : node : Noeud potentiellement parent * @return : bIsChildNodeOf : booleen : true si oNode est enfant de other, false sinon **/ function isChildNodeOf(oNode,other) { if (oNode.compareDocumentPosition) { return (oNode.compareDocumentPosition(other)==10); } else if (other.contains) { return other.contains(oNode); } var bIsChildNodeOf = false; function _isChildNodeOf(oNode,other) { while (other) { if (other==oNode) { bIsChildNodeOf = true; return; } else _isChildNodeOf(oNode,other.firstChild); other = other.nextSibling; } } _isChildNodeOf(oNode,other.firstChild); return bIsChildNodeOf; } /* * NONSTABLE : Clone un élément optgroup dans une liste déroulante (l'insertion de fait après tri) * si un optgroup au même libellé existe déjà, c'est cet élément qui est pris en compte * @param : elOptgroup : node : élément optgroup à cloner * @param : elSelect : node : élément select ou doit se faire le clonage * @param : elStart : node : noeud optionnel représentant le noeud de départ utilisé pour le tri et l'insertion * (position dans la liste : évite de commencer à trier depuis la première option) * @return : elNewOptgroup : node : élément optgroup cloné ou au même libellé **/ function cloneOptgroup(elOptgroup, elSelect, elStart) { var oNode, compare, elNewOptgroup; if (elStart) { oNode = (elStart.parentNode.nodeName.toLowerCase()=='optgroup')? elStart.parentNode:elStart; } else { oNode = elSelect.firstChild; } while (oNode) { if ( (oNode.nodeName.toLowerCase()!='optgroup') && (oNode.nodeName.toLowerCase()!='option') ) { oNode = oNode.nextSibling; continue; } compare=(oNode.nodeName.toLowerCase()=='option')?oNode.text:oNode.label; if (elOptgroup.label == compare) { elNewOptgroup = oNode; break; } else if (elOptgroup.label < compare) { elNewOptgroup = elOptgroup.cloneNode(false); oNode.parentNode.insertBefore(elNewOptgroup,oNode); break; } oNode = oNode.nextSibling; } if (!elNewOptgroup) { elNewOptgroup = elOptgroup.cloneNode(false); elSelect.appendChild(elNewOptgroup); } return elNewOptgroup; } /* * NONSTABLE : déplace (avec tri alpha) les options sélectionnées d'une liste vers une autre (en conservant les optgroup) * @param : elFromSelect : node : élément select qui contient les options sélectionnées à déplacer * @param : elToSelect : node : élément select vers lequel déplacer les options **/ function DeplaceCritere(elFromSelect, elToSelect) { function _fixe_msieIndexOption(elOption) { var optionIndex, oNode; optionIndex=0; if (elOption.parentNode.nodeName.toLowerCase()=='optgroup') { oNode = elOption.previousSibling; while (oNode) { if (oNode.nodeName.toLowerCase()!="option") { oNode = oNode.previousSibling; continue; } break; } if (!oNode || (oNode.nodeName.toLowerCase()!="option")) { oNode = elOption.parentNode.previousSibling; } } else {oNode = elOption.previousSibling;} while (oNode) { if ( (oNode.nodeName.toLowerCase()!='optgroup') && (oNode.nodeName.toLowerCase()!='option') ) { oNode = oNode.previousSibling; continue; } if (oNode.nodeName.toLowerCase()=='option') { optionIndex = oNode.index+1; break; } else { oNode = oNode.lastChild; while (oNode) { if (oNode.nodeName.toLowerCase()=='option') { optionIndex = oNode.index+1; break; } oNode = oNode.previousSibling; } break; } } return optionIndex; } var fromIndex, toIndex, elOption, nToParent, nFromParent, oNode; fromIndex = toIndex = 0; elOption = elFromSelect.options[0]; fromOptions : while (elOption) { if (!elOption.selected) { elOption = elFromSelect.options[elOption.index+1]; continue; } nToParent = elToSelect; nFromParent = elOption.parentNode; oNode = elToSelect.options[toIndex]; if (nFromParent.nodeName.toLowerCase()=='optgroup') { nToParent = cloneOptgroup(nFromParent, elToSelect,elToSelect.options[toIndex]); if (oNode && !isChildNodeOf(oNode,nToParent)) { oNode = nToParent.firstChild; } } else { if ( oNode && (oNode.parentNode.nodeName.toLowerCase()=='optgroup') ) { oNode = oNode.parentNode; } } var compare; while (oNode) { if ( (oNode.nodeName.toLowerCase()!='optgroup') && (oNode.nodeName.toLowerCase()!='option') ) { oNode = oNode.nextSibling; continue; } compare=(oNode.nodeName.toLowerCase()=='option')?oNode.text:oNode.label; if (elOption.text <= compare) { fromIndex = elOption.index; nToParent.insertBefore(elOption, oNode); toIndex = elOption.index; if (toIndex > elToSelect.options.length) { toIndex = _fixe_msieIndexOption(elOption); } elOption = elFromSelect.options[fromIndex]; continue fromOptions; } oNode = oNode.nextSibling; } fromIndex = elOption.index; nToParent.appendChild(elOption); toIndex = elOption.index; if (toIndex > elToSelect.options.length) { toIndex = _fixe_msieIndexOption(elOption); } elOption = elFromSelect.options[fromIndex]; } var cFromOptgroup = elFromSelect.getElementsByTagName('optgroup'); var aFromOptgroupRemove = new Array(); for (var k=0;cFromOptgroup[k]; k++) { if (cFromOptgroup[k].getElementsByTagName('option').length==0) { aFromOptgroupRemove.push(cFromOptgroup[k]); } } for (var l=0; aFromOptgroupRemove[l]; l++) { aFromOptgroupRemove[l].parentNode.removeChild(aFromOptgroupRemove[l]); } } /**********/ /* COVER */ /**********/ var popupCover = null; var timeoutCover = null; function ownWindowOpen(url, name, feature) { showCover(); if (feature) { feature += ",resizable,scrollbars,modal=yes"; } else { feature = "resizable,scrollbars,modal=yes"; } if (!name) name = 'POPUP'; popupCover = window.open(url, name, feature); timeoutCover = window.setInterval('intervalCover()', 500); return false; } function intervalCover() { if (!popupCover || popupCover.closed) { window.clearInterval(timeoutCover); hideCover(); } } function showCover() { var oTemplatecover = document.getElementById("bo_cover"); if (oTemplatecover) { oTemplatecover.style.display = "block"; minHeight = window.innerHeight if (isNaN(minHeight)) minHeight = window.document.body.offsetHeight oHeight = document.getElementById('document').offsetHeight; if (minHeight > oHeight) oHeight = minHeight; oTemplatecover.style.height = oHeight + 'px'; } } function hideCover() { var oTemplatecover = document.getElementById("bo_cover"); if (oTemplatecover) oTemplatecover.style.display = "none"; }