
var Tabrubrique=new Array();


		function affiche2(idelt,ici){
			var elt=document.getElementById(idelt);
			var eltemp;
			//alert(elt.className);
			if(elt.className=="liste-sous-menu"){
				for(rub in Tabrubrique){
					//alert('liste-sous-menu'+Tabrubrique[rub]);
					eltemp=document.getElementById('liste-sous-menu'+Tabrubrique[rub]);
					eltemp.style.display="none";
					eltemp=document.getElementById('menu'+Tabrubrique[rub]);
					eltemp.className="menu-off";
					eltemp=document.getElementById('lien-menu'+Tabrubrique[rub]);
					eltemp.className="menu-off-lien";
					eltemp=document.getElementById('menu-barre'+Tabrubrique[rub]);
					eltemp.className="";
				}
				if(elt.style.display=="none"){
					elt.style.display="";
					//alert(pere.className);
					ici.parentNode.parentNode.className="menu-on";
					ici.parentNode.className="menu-barre";
					ici.className="menu-on-lien";
				}
				else{
					elt.style.display="none";
					ici.parentNode.parentNode.className="menu-off";
					ici.parentNode.className="";
					ici.className="menu-off-lien";
				}
			}
		}

		var Tabrubrique;
		Tabrubrique=new Array();


//START - GET ELEMENT FOR ALL BROWSERS
function getElement(elementId){
	if (document.getElementById)
	{
		return document.getElementById(elementId);
	}
	else
	{
		return document.all[elementId];
	}
}
//END - GET ELEMENT FOR ALL BROWSERS


//START - CLEAR TEXT BOXES WHEN FIRST CLICKED I.E. EMAIL ADDRESS BOX ETC. TAKES ELEMENTID OF TEXT FIELD & CASE SENSITIVE
function emptyTextField(elementId, defaultText){
	var fieldText = getElement(elementId).value;
	//var defaultText = defaultText;
	if(getElement(elementId).value == defaultText){
		getElement(elementId).value = '';
	}
}
//END - CLEAR TEXT BOXES



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function getHttpObject() {
 var xmlhttp;
 /*@cc_on
 @if (@_jscript_version >= 5)
   try {
     xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
     try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
     } catch (E) {
       xmlhttp = false;
     }
   }
 @else
 xmlhttp = false;
 @end @*/
 if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
   try {
     xmlhttp = new XMLHttpRequest();
   } catch (e) {
     xmlhttp = false;
   }
 }
 if(!xmlhttp) alert("pas bon");
 return xmlhttp;
}

function initCarto(url_site){
	document.getElementById('liste_rub').value='';
	var map = new GMap2(document.getElementById('map'));
	//Modifier les vues
	map.removeMapType(G_HYBRID_MAP);
	map.addMapType(G_NORMAL_MAP);
	map.addMapType(G_SATELLITE_MAP);
	map.addMapType(G_PHYSICAL_MAP);
	//controle zoom
	map.addControl(new GSmallZoomControl());
	//controle vecto/satellite
	map.addControl(new GMapTypeControl());
	var coordCenterX = document.getElementById('coordsX').value;
	var coordCenterY = document.getElementById('coordsY').value;
	var zoom = document.getElementById('zoom').value;
	var center = new GLatLng(parseFloat(coordCenterX), parseFloat(coordCenterY));
	map.setCenter(center, parseInt(zoom));
	var polygon = new GPolygon([
	new GLatLng(42.82562425459303,	0.85693359375),
	new GLatLng(42.79338522116173,	0.90911865234375),
	new GLatLng(42.78532283730215,	0.933837890625),
	new GLatLng(42.805476827860275,	0.9613037109375),
	new GLatLng(42.78532283730215,	0.9832763671875),
	new GLatLng(42.78733853171998,	1.07940673828125),
	new GLatLng(42.72280375732725,	1.131591796875),
	new GLatLng(42.70867781741311,	1.17279052734375),
	new GLatLng(42.72683914955442,	1.23046875),
	new GLatLng(42.72078596277834,	1.351318359375),
	new GLatLng(42.71977704089521,	1.3568115234375),
	new GLatLng(42.73087427928485,	1.3643646240234375),
	new GLatLng(42.72835235396481,	1.385650634765625),
	new GLatLng(42.78481890344226,	1.4096832275390625),
	new GLatLng(42.8417374697878,	1.443328857421875),
	new GLatLng(42.899106654303075,	1.492767333984375),
	new GLatLng(42.921234883592945,	1.43096923828125),
	new GLatLng(42.9524020856897,	1.429595947265625),
	new GLatLng(42.97250158602597,	1.4357757568359375),
	new GLatLng(42.984055825278524,	1.483154296875),
	new GLatLng(42.99862111927107,	1.52984619140625),
	new GLatLng(43.02472955416351,	1.5222930908203125),
	new GLatLng(43.033764503405315,	1.542205810546875),
	new GLatLng(43.05534260980123,	1.4508819580078125),
	new GLatLng(43.039285206566355,	1.3897705078125),
	new GLatLng(43.04028891741493,	1.363677978515625),
	new GLatLng(43.03276068583203,	1.3300323486328125),
	new GLatLng(43.043299951444496,	1.3011932373046875),
	new GLatLng(43.030753001428344,	1.270294189453125),
	new GLatLng(43.03577208929465,	1.219482421875),
	new GLatLng(43.06788453128748,	1.2139892578125),
	new GLatLng(43.08493742707592,	1.2339019775390625),
	new GLatLng(43.078919299859656,	1.2160491943359375),
	new GLatLng(43.13656870471118,	1.174163818359375),
	new GLatLng(43.13155786840375,	1.1638641357421875),
	new GLatLng(43.15360247702298,	1.12884521484375),
	new GLatLng(43.139575009419644,	1.0601806640625),
	new GLatLng(43.147591099354834,	1.036834716796875),
	new GLatLng(43.10649752839693,	1.028594970703125),
	new GLatLng(43.12654662152539,	1.0100555419921875),
	new GLatLng(43.09998015877999,	0.9922027587890625),
	new GLatLng(43.08443593905342,	1.0052490234375),
	new GLatLng(43.07039260770445,	0.981903076171875),
	new GLatLng(43.049321576177284,	0.9867095947265625),
	new GLatLng(43.03276068583203,	0.9812164306640625),
	new GLatLng(43.01167672405555,	1.028594970703125),
	new GLatLng(42.984055825278524,	1.003875732421875),
	new GLatLng(42.96144767344319,	0.9633636474609375),
	new GLatLng(42.95340721665942,	0.8823394775390625),
	new GLatLng(42.93430692117159,	0.8878326416015625),
	new GLatLng(42.91419494510531,	0.8349609375),
	new GLatLng(42.87596410238254,	0.828094482421875),
	new GLatLng(42.82562425459303,	0.85693359375)], "#6B9368", 2, 1, "#B0CAA6", 0.3);
	map.addOverlay(polygon);
}
function addRubCartoPat(link,id_rubrique,url_site_spip){
    var elt = document.getElementById('liste_rub');

    if (elt.value == "")
            elt.value = id_rubrique+",";
    else {
            if(elt.value.search(id_rubrique+",") != -1)
                    elt.value = elt.value.replace(id_rubrique+",","");
            else
                    elt.value = elt.value+id_rubrique+",";
    }

    if(link!=null){
            if(link.className == "actif"){
                    link.className = '';
            //si non cliqué => cliqué
            }else{
                    link.className = "actif";
            }
    }

    if (elt.value != ""){
            var xmlhttp = getHttpObject() ;
            //le substr permet de supprimer la virgule en fin de chaine
            xmlhttp.open("GET", url_site_spip + "/spip.php?page=ajoutRubCartoPat&liste_rub=" + elt.value.substr(0,elt.value.length-1), true);
            xmlhttp.onreadystatechange = function(){
                    if(xmlhttp.readyState == 4){
                            //ce qui se passe dans le cas ou le fichier a fini de charger ...
                            //éxécute le code JS qui est retourné
                            var resultat_ajax = xmlhttp.responseText;
                            //alert(resultat_ajax);
                            //penser a supprimer le cookie de correspondance partie admin apres chaque login
                            eval(resultat_ajax);
                    }
            }
            xmlhttp.send(null);
    } else
            initCarto();
    return false;
}

function show_hide(link,id_div,extension){
    if(link.style.backgroundImage != 'url(img-pat/carto-moins.' + extension + ')'){
		link.style.backgroundImage = 'url(img-pat/carto-moins.' + extension + ')';
		link.style.backgroundRepeat = 'no-repeat';
		link.style.fontSize="12px";
    } else {
            link.style.backgroundImage = 'url(img-pat/carto-plus.' + extension + ')';
		link.style.fontSize="11px";
    }

    var divToModif = document.getElementById(id_div);
    if(divToModif.className == 'rub_vis')
            divToModif.className = 'rub_unvis';
    else
            divToModif.className = 'rub_vis';
    return false;
}