var functions=new Array();var ranges=new Array();var documents=new Array();function Function(d,c){this.id=d;this.libelle=c}function Range(e,c,d){this.id=e;this.libelle=c;this.idFunction=d}function Document(f,c,d,e){this.id=f;this.libelle=c;this.idFunction=d;this.idRange=e}function rangeActivation(c,e,d){if(c!=""){document.range_form.p_ranges.disabled=false}else{document.range_form.p_ranges.disabled=true;document.range_form.p_ranges.options[0].selected=true}document.document_form.p_documents.disabled=true;document.document_form.p_documents.options[0].selected=true;document.getElementById("submitButton").style.display="none";document.getElementById("submitButtonHide").style.display="inline";fillRangeList(c,e,d)}function legacyRangeActivation(c,d){if(c!=""){document.range_form.p_ranges.disabled=false}else{document.range_form.p_ranges.disabled=true;document.range_form.p_ranges.options[0].selected=true}document.getElementById("submitButton").style.display="none";document.getElementById("submitButtonHide").style.display="inline";fillRangeList(c,d);document.getElementById("document_legacy_message").innerHTML="<p/>"}function documentActivation(e,d,h,f,c,g){if(e!=""&&d!=""){document.document_form.p_documents.disabled=false}else{document.document_form.p_documents.disabled=true;document.document_form.p_documents.options[0].selected=true}document.getElementById("submitButton").style.display="none";document.getElementById("submitButtonHide").style.display="inline";fillDocumentList(e,d,h,f,c,g)}function formActivation(c){document.getElementById("submitButton").style.display="none";document.getElementById("submitButtonHide").style.display="inline";if(c!=""&&c!=0){document.getElementById("submitButton").style.display="inline";document.getElementById("submitButtonHide").style.display="none"}}function formLegacyActivation(d,c,f,h){document.getElementById("submitButton").style.display="none";document.getElementById("submitButtonHide").style.display="inline";if(d!=""&&d!=0){if(f=="true"&&hashMapAvailableContentTypeFromPrep!=null){var e=c.split(",");var g=0;for(j=0;j<e.length;j++){if(hashMapAvailableContentTypeFromPrep.get(e[j])!=null&&hashMapAvailableContentTypeFromPrep.get(e[j])!=""){g++}}if(g>0){document.getElementById("submitButton").style.display="inline";document.getElementById("submitButtonHide").style.display="none";document.getElementById("document_legacy_message").innerHTML="<p/>"}else{document.getElementById("submitButton").style.display="none";document.getElementById("submitButtonHide").style.display="inline";document.getElementById("document_legacy_message").innerHTML="<p>"+h+"</p>"}}else{document.getElementById("submitButton").style.display="inline";document.getElementById("submitButtonHide").style.display="none";document.getElementById("document_legacy_message").innerHTML="<p/>"}}else{document.getElementById("document_legacy_message").innerHTML="<p/>"}}function fillFunctionList(d){var c=document.function_form.p_functions;c.options.length=1;c.options[0]=new Option(d,0);for(i=0;i<functions.length;i++){c.options[c.options.length]=new Option(functions[i].libelle,functions[i].id)}}function fillRangeList(c,f,e){var d=document.range_form.p_ranges;d.options.length=1;d.options[0]=new Option(f,0);for(i=0;i<ranges.length;i++){if(c!=""&&ranges[i].idFunction==c){d.options[d.options.length]=new Option(ranges[i].libelle,ranges[i].id)}}if(d.options.length==1){d.disabled=true}if(document.document_form!=null){var g=document.document_form.p_documents;if(g!=null){g.options.length=1;g.options[0]=new Option(f,0)}}}function getAllContentTypesForASpecificRange(e,d){var f={};f={set:function(h,k){this[h]=k},get:function(h){return this[h]}};var c="";for(i=0;i<documents.length;i++){if(e!=""&&d!=""&&documents[i].idRange==e&&documents[i].idFunction==d){var g=documents[i].id.split(",");for(j=0;j<g.length;j++){if(f.get(g[j])!=g[j]){c+=g[j]+",";f[g[j]]=g[j]}}}}c=c.substr(0,c.length-1);return c}function fillDocumentList(o,l,h,e,q,c){var k=document.getElementById("p_documents");while(k.options.length!=0){k.options[k.options.length-1]=null}var p={};p={set:function(r,s){this[r]=s},get:function(r){return this[r]}};var d=document.document_form.p_documents;if(e=="true"&&hashMapAvailableContentTypeFromPrep!=null){d.options.length=1;d.options[0]=new Option(h,0);var n=0;for(i=0;i<documents.length;i++){if(o!=""&&l!=""&&documents[i].idRange==o&&documents[i].idFunction==l){var m=documents[i].id.split(",");var f=0;var g="";for(j=0;j<m.length;j++){if(p.get(m[j])!=m[j]&&hashMapAvailableContentTypeFromPrep.get(m[j])!=null&&hashMapAvailableContentTypeFromPrep.get(m[j])!=""){f++;n++;if(f==1){g=hashMapAvailableContentTypeFromPrep.get(m[j])}p.set(m[j],m[j])}}if(f>0){if(q=="true"&&f==1){d.options[d.options.length]=new Option(g,documents[i].id)}else{d.options[d.options.length]=new Option(documents[i].libelle,documents[i].id)}}}}if(d.options.length==1){d.disabled=true}if(n==0){d.options[0]=new Option(c,0);d.disabled=true}}else{d.options.length=1;d.options[0]=new Option(h,0);for(i=0;i<documents.length;i++){if(o!=""&&l!=""&&documents[i].idRange==o&&documents[i].idFunction==l){d.options[d.options.length]=new Option(documents[i].libelle,documents[i].id)}}if(d.options.length==1){d.disabled=true}}}function getContentTypesFromResource(url){var sousChaine1Position=eval(url.indexOf("%26c=",0)+5);var sousChaine2Position=url.indexOf("~",0);var contentTypes=url.substring(sousChaine1Position,sousChaine2Position);return contentTypes}function getXMLHttpRequest(){var d=null;if(window.XMLHttpRequest){d=new XMLHttpRequest()}else{if(window.ActiveXObject){try{d=new ActiveXObject("Msxml2.XMLHTTP")}catch(c){try{d=new ActiveXObject("Microsoft.XMLHTTP")}catch(c){}}}else{d=false}}return d}function execute(h,l,k,g,e,f,d,m,c){xhrPrep=getXMLHttpRequest();hashMapAvailableContentTypeFromPrep=null;xhrPrep.onreadystatechange=function(){handleHttpResponse();fillDocumentList(k,g,f,d,m,c)};xhrPrep.open("GET",h+replaceByHexadecimalValue(l)+"%26p="+k+"%26c="+getAllContentTypesForASpecificRange(k,g)+"%26L="+e,true);xhrPrep.send(null);return true}function executeLegacy(g,d,h,k,c,e,f){xhrPrep=getXMLHttpRequest();hashMapAvailableContentTypeFromPrep=null;xhrPrep.open("GET",g+replaceByHexadecimalValue(d)+"%26p="+h+"%26c="+c+"%26L="+k,true);xhrPrep.send("");xhrPrep.onreadystatechange=function(){handleHttpResponse();formLegacyActivation(h,c,e,f)};return true}function nodeCleaner(c){if(!c.data.replace(/\s/g,"")){c.parentNode.removeChild(c)}}function cleanXML(c){var d=c.getElementsByTagName("*");for(i=0;i<d.length;i++){a=d[i].previousSibling;if(a&&a.nodeType==3){nodeCleaner(a)}b=d[i].nextSibling;if(b&&b.nodeType==3){nodeCleaner(b)}}return c}function handleHttpResponse(){if(xhrPrep.readyState==4&&xhrPrep.status==200){response=xhrPrep.responseXML.documentElement;if(response!=null){response=cleanXML(xhrPrep.responseXML.documentElement);hashMapAvailableContentTypeFromPrep=getAvailableDocumentsTypes(response)}}}function displayResult(g){var e="";var l=g.getElementsByTagName("range_id").item(0).firstChild.nodeValue;var d=g.getElementsByTagName("contains_doc").item(0).firstChild.nodeValue;var c=g.getElementsByTagName("content_type");e+="<h1>Range (id: "+l+", contains_doc: "+d+")</h1>";for(i=0;i<c.length;i++){var h=c.item(i).getElementsByTagName("id").item(0).firstChild.nodeValue;var f=c.item(i).getElementsByTagName("title").item(0).firstChild.nodeValue;var k=c.item(i).getElementsByTagName("contains_doc").item(0).firstChild.nodeValue;e+="<p>content type (id: "+h+",title: "+f+", contains_doc: "+k+"</p>"}document.getElementById("content").innerHTML=e}function getAvailableDocumentsTypes(g){var l={set:function(m,n){this[m]=n},get:function(m){return this[m]}};var f=g.getElementsByTagName("contains_doc");var d=0;for(i=0;i<f.length;i++){if(f[i].parentNode.tagName=="check_content"){d=f[i].firstChild.nodeValue}}if(d==1){var c=g.getElementsByTagName("content_type");for(i=0;i<c.length;i++){var h=getNodeValue(c.item(i).getElementsByTagName("id").item(0));var e=getNodeValue(c.item(i).getElementsByTagName("title").item(0));var k=getNodeValue(c.item(i).getElementsByTagName("contains_doc").item(0));if(k==1&&h!=""){l.set(h,e)}}}return l}function getNodeValue(c){var d="";if(c!=null&&c.hasChildNodes()){d=c.firstChild.nodeValue}return d}function replaceByHexadecimalValue(c){c=c.replace("?","%3F","g");c=c.replace("&","%26","g");return c};