function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

// JavaScript Document

//-- SNAP 
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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function run_ajax(url, tocontent){
	new Ajax.Request(url, {
		  method: 'get',
		  onSuccess: function(transport) 
		  {
		  	if( tocontent != '')
		  		run_ajax_complet( transport.responseText , MM_findObj( tocontent ) );
		  }
		});
}

function run_ajax_complet(data, tocontent){
	tocontent.innerHTML = data;
}

function montre(text) {
	GetId("curseur").style.visibility="visible";
	GetId("curseur").innerHTML = text;
}

function cache() {
	GetId("curseur").style.visibility="hidden";
}

function montre2(text) {
	GetId("curseur2").style.visibility="visible";
}

function cache2() {
	GetId("curseur2").style.visibility="hidden";
}

function GetId(id) {
	return document.getElementById(id);
}

function PopupPic(sPicURL) { 
	window.open("/fr/popup.htm?"+sPicURL, "", "resizable=1,HEIGHT=200,WIDTH=200");
}

function pop_it() {
	window.open("formulaire_envoyer_tempete_visualiser.php", "popup", "height=440,width=640,menubar='no',toolbar='no',location='no',status='no',scrollbars='no'");
}

function EcrireCookie(value) {
	var expire = new Date ();
	expire.setTime (expire.getTime() + (24 * 60 * 60 * 1000) + 1);
	document.cookie = "listeStation=" + escape(value) + "; expires=" + expire.toGMTString() + "; path=/";
}

function ajouterCooki(cb, form) {
	var i = 0;
	var listeStationTemp = new Array();
	for (i=0;i<cb.length;i++) {
		if (cb[i].checked == true) {
			listeStationTemp[listeStationTemp.length] = cb[i].value
		}
	}
	if (listeStationTemp.length > 0) {
		EcrireCookie(listeStationTemp.toString());
		form.submit();
	} else {
		alert("Veillez faire votre choix des stations");
	}
}

function selectOptions(the_form, the_select, do_check)
{
    var selectObject = document.forms[the_form].elements[the_select];
    var selectCount  = selectObject.length;

    for (var i = 0; i < selectCount; i++) {
        selectObject.options[i].selected = do_check;
    }

    return true;
}

function submit()
{
document.form1.submit();
}

