// JavaScript Document

function vider(cible) {
	document.getElementById(cible).innerHTML = "";
}

function getReturn(cible, vrai, faux) {
	return (document.getElementById(cible).checked ? vrai : faux);
}

function Selectionner(champ) {
	// on récupère un pointeur sur le sélecteur désiré, puis le nombre d'options disponibles.
		var selecteur = document.getElementById(champ);
		var nombre = selecteur.length;
		
	var index, courant = 0;
	var selection = new Array();
	
	// pour chaque option, on vérifie si elle est sélectionnée, on renvoie sa valeur dans un tableau le cas échéant.
		for (index=0; index<nombre; index++)
		{
			option = selecteur.options[index];
			if (option.selected)
				selection[courant++]=option.value;
		}
	return selection;
}

function Exploser(chaine, separateur) {
	var retour = new Array();
	var position=chaine.indexOf(separateur);
	
	while (position!=-1)
	{
		retour.push(chaine.slice(0, position));
		chaine=chaine.slice(position+1);
		position=chaine.indexOf(separateur);
	}
	
	if (chaine.length>0)
		retour.push(chaine);
	
	return retour;
}

function LireDepuisUrl (champ) {
	var url=document.location.toString();
	var debut=url.indexOf(champ + "=");
	var longueur=champ.length + 1;
	var fin, retour=false;
	
	if (debut!=-1) {
		retour="";
		fin=url.indexOf("&", debut);
		
		if (fin!=-1)
			retour=url.slice(debut + longueur, fin);
		else
			retour=url.slice(debut + longueur, url.length);
	}
	return retour.valueOf();
}

function Executer(url) {
    var xmlhttp;

    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();
	var date = new Date();
	url += "&time=" + date.getTime();
    xmlhttp.open("GET", url, false);
    xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlhttp.send(null);
    return xmlhttp.responseText;
}

function creerColonne(taille, classe, url, contenu) {
	return ("<td class=\"" + classe +  "\" onclick=\"window.open('" + url + "')\">" + contenu + "</td>\n");
}

function creerColonneSite(taille, classe, contenu) {
	if(contenu !== "")
	{
		contenu = "http://" + contenu;
		return ("<td class=\"" + classe +  "\"><a onclick=\"window.open('" + contenu + "')\"><img src='/images/web.gif' alt='web' /></a></td>\n");
	}
	else
		return ("<td class=\"" + classe +  "\"></td>\n");
}

function load(address) {
    if (GBrowserIsCompatible()) {
		var geocoder = new GClientGeocoder();
		
		geocoder.getLatLng(
		    address,
		    function(point) {
		      if (point) {
			    document.getElementById("map").style.visibility = "visible";
		        document.getElementById("map").style.height = "200px";
				var map = new GMap2(document.getElementById("map"));
				map.addControl(new GSmallMapControl());
				map.addControl(new GMapTypeControl());
		        map.setCenter(point, 13);
		        var marker = new GMarker(point);
		        map.addOverlay(marker);
		      }
		    }
		);
	}
}