function getHTTPObject() 
     {
         var xmlhttp=false;
         try
         {  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
         }
         catch (e)
         {try
          {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
          }catch (e){xmlhttp = false;}
         }
         
         if (!xmlhttp && typeof XMLHttpRequest != "undefined")
         {xmlhttp = new XMLHttpRequest();
         }
         return xmlhttp;
     }
	 
function vider_cache(xmlhttp){
  var xmlhttp = xmlhttp;
  xmlhttp.setRequestHeader("Pragma","no-cache");
  xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
}

function URLEncode(texte)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";
	var plaintext = texte;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
};


function select_content_arbre(nominput,id_select)
{
	window.open('/v2/admin/cms/selectionner_objet.asp?nom_champ=' + nominput + '&id='+id_select,'popup','height=560,width=620,location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes');	
}

function trim(str) {
   return str.replace(/(^\s*)|(\s*$)/g,"");
}



function no_accent(my_string) {
var new_string = String (my_string);
new_string = new_string.replace(/(&#x40|&#064;|@|&commat;|&#x41|&#065;|A|&#x61|&#097;|&#xC0|&#192;|À|&Agrave;|&#xC1|&#193;|Á|&Aacute;|&#xC2|&#194;|Â|&Acirc;|&#xC3|&#195;|Ã|&Atilde;|&#xC4|&#196;|Ä|&Auml;|&#xC5|&#197;|Å|&Aring;|&#xE0|&#224;|à|&agrave;|&#xE1|&#225;|á|&aacute;|&#xE2|&#226;|â|&acirc;|&#xE3|&#227;|ã|&atilde;|&#xE4|&#228;|ä|&auml;|&#xE5|&#229;|å|&aring;)/gi,'a');
new_string = new_string.replace(/(&#xC7|&#199;|Ç|&Ccedil;|&#xE7|&#231;|ç|&ccedil;)/gi,'c');
new_string = new_string.replace(/(&#xD0|&#208;|Ð|&ETH;)/gi,'d');
new_string = new_string.replace(/(&#x45;|&#069;|E|&#x65;|&#101;|&#xC8;|&#200;|È|&Egrave;|&#xC9;|&#201;|É|&Eacute;|&#xCA;|&#202;|Ê|&Ecirc;|&#xCB;|&#203;|Ë|&Euml;|&#xE8;|&#232;|è|&egrave;|&#xE9;|&#233;|é|&eacute;|&#xEA;|&#234;|ê|&ecirc;|&#xEB;|&#235;|ë|&euml;)/gi,'e');
new_string = new_string.replace(/(&#x49|&#073;|I|&#x69|&#105;|&#xCC|&#204;|Ì|&Igrave;|&#xCD|&#205;|Í|&Iacute;|&#xCE|&#206;|Î|&Icirc;|&#xCF|&#207;|Ï|&Iuml;|&#xEC|&#236;|ì|&igrave;|&#xED|&#237;|í|&iacute;|&#xEE|&#238;|î|&icirc;|&#xEF|&#239;|ï|&iuml;)/gi,'i');
new_string = new_string.replace(/(&#x4E|&#078;|N|&#x6E|&#110;|&#xD1|&#209;|Ñ|&Ntilde;|&#xF1|&#241;|ñ|&ntilde;)/gi,'n');
new_string = new_string.replace(/(&#x4F|&#079;|O|&#x6F|&#111;|&#xD2|&#210;|Ò|&Ograve;|&#xD3|&#211;|Ó|&Oacute;|&#xD4|&#212;|Ô|&Ocirc;|&#xD5|&#213;|Õ|&Otilde;|&#xD6|&#214;|Ö|&Ouml;|&#xF2|&#242;|ò|&ograve;|&#xF3|&#243;|ó|&oacute;|&#xF4|&#244;|ô|&ocirc;|&#xF5|&#245;|õ|&otilde;|&#xF6|&#246;|ö|&ouml;|&#xF8|&#248;|ø|&oslash;)/gi,'o');
new_string = new_string.replace(/(&#x55|&#085;|U|&#x75|&#117;|&#xD9|&#217;|Ù|&Ugrave;|&#xDA|&#218;|Ú|&Uacute;|&#xDB|&#219;|Û|&Ucirc;|&#xDC|&#220;|Ü|&Uuml;|&#xF9|&#249;|ù|&ugrave;|&#xFA|&#250;|ú|&uacute;|&#xFB|&#251;|û|&ucirc;|&#xFC|&#252;|ü|&uuml;)/gi,'u');
new_string = new_string.replace(/(&#x59|&#089;|Y|&#x79|&#121;|&#xDD|&#221;|Ý|&Yacute;|&#xFD|&#253;|ý|&yacute;|&#xFF|&#255;|ÿ|&yuml;)/gi,'y');
new_string = new_string.replace(/(&#xC6|&#198;|Æ|&AElig;|&#xE6|&#230;|æ|&aelig;)/gi,'ae');
new_string = new_string.replace(/(&#x8C|&#140;|Œ|&OElig;|&#x9C|&#156;|œ|&oelig;)/gi,'oe');
return new_string;
}

function affiche_sous_categorie(id_pere, url, nom_div, nom_champ, id_type_objet) {
	var complement_get;
	complement_get = '';
	if (id_type_objet) { complement_get = '&id_type_objet='+id_type_objet; }
	 var xmlhttp = getHTTPObject();
  	 var element1 = document.getElementById(nom_div);
	 element1.innerHTML = '';
  	 var D = new Date();
	 xmlhttp.open('GET', url+'?id_element='+id_pere+'&nom_champ='+nom_champ+complement_get, true);	
	 vider_cache(xmlhttp);
     xmlhttp.onreadystatechange = function() {
	    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			var reponse = xmlhttp.responseText;
			element1.innerHTML = reponse;
        }
		else
		{
		  //element1.innerHTML = 'ERREUR';//+xmlhttp.status;
		}
	}
  	xmlhttp.send(null); 
}
