function sendData(data, page, method, destination, nextfct)
{
	if(document.all)
    {
    	//Internet Explorer
		var XhrObj = new ActiveXObject("Msxml2.XMLHTTP") ;
	}//fin if
 	else
  	{
   		//Mozilla
 	    var XhrObj = new XMLHttpRequest();
    }//fin else

	//d&eacute;finition de l'endroit d'affichage:
	if (document.getElementById(destination))
	 	var content = document.getElementById(destination);

    //si on envoie par la m&eacute;thode GET:
    if(method == "GET")
    {
    	if(data == 'null')
        {
        	//Ouverture du fichier s&eacute;lectionn&eacute;:
            XhrObj.open("GET", page);
        }//fin if
        else
        {
            //Ouverture du fichier en methode GET
            XhrObj.open("GET", page+"?"+data);
        }//fin else
    }//fin if
    else if(method == "POST")
    {
        //Ouverture du fichier en methode POST
        XhrObj.open("POST", page);
    }//fin elseif
    //Ok pour la page cible
    XhrObj.onreadystatechange = function()
    {

        if (XhrObj.readyState == 4 && XhrObj.status == 200 && document.getElementById(destination))
        {
			//document.getElementById('loadbloc').innerHTML = "&nbsp;";
			content.innerHTML = XhrObj.responseText;
			fct = new Function(nextfct);
			fct();
		}
    }
    if(method == "GET")
    {
        XhrObj.send(null);
    }//fin if
    else if(method == "POST")
    {
        XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        XhrObj.send(data);
    }//fin elseif
}

function popup(url, nom, largeur, hauteur, options) {
    var coordY  = ( screen.height - hauteur ) / 2;
    var coordX  = ( screen.width - largeur ) / 2;
    window.open( url, nom, "top=" + coordY + ",left=" + coordX + ", width=" + largeur + ", height=" + hauteur + ", status=no, resizable=yes, location=no, directories=no, scrollbars=yes");
}
function popupC(url, nom, largeur, hauteur, options) {
    var coordY  = ( screen.height - hauteur ) / 2;
    var coordX  = ( screen.width - largeur ) / 2;
    window.open( url, nom, "top=" + coordY + ",left=" + coordX + ", width=" + largeur + ", height=" + hauteur + ", status=no, resizable=yes, location=no, directories=no, scrollbars=yes");
}
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 rechercheFormValid( info ) {
	alert(document.rechercheForm.nomprod.value);
    if( info == 0) {
        document.rechercheForm.action   = 'rechercher.php4';
        document.rechercheForm.method   = 'get';
		alert(document.rechercheForm.nomprod.value);
        document.rechercheForm.submit();
    }
    else {
        document.rechercheForm.action   = 'rechercher_traitement.php4';
		document.rechercheForm.nomprod.value='%'+document.rechercheForm.nomprod.value+'%';
		alert(document.rechercheForm.nomprod.value);
        document.rechercheForm.method   = 'post';
        document.rechercheForm.submit();
    }
}

function createCookie(nom, valeur, expire, path, domaine, securise) {
    document.cookie = nom + "=" + escape (valeur) + ((expire) ? "; expires=" + expire.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domaine) ? "; domain=" + domaine : "") + ((securise) ? "; secure" : "");
}

function deleteCookie(nom,path,domaine) {
      document.cookie = nom + "=" + ((path) ? "; path=" + path : "") + ((domaine) ? "; domain=" + domaine : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function gereCookie( valeur ) {

    if( document.forms[0].selectcookie.checked ) {
        createCookie("selection", valeur , null, "/" , null, false);
    }
    else {
        deleteCookie("selection", "/");
    }

}

function gereCookieAccueil() {
	var expdate = new Date ();
    expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
    if( document.forms[0].accueil.checked ) {
        createCookie("accueil", "journalistes.php4" , expdate, "/" , null, false);
    }
    else {
        deleteCookie("accueil", "/");
    }

}


function isEmail(email) {
	if( email.match( /^[-_A-Za-z0-9]+(\.[-_A-Za-z0-9]+)*@[-A-Za-z0-9]+(\.[-A-Za-z0-9]+)+$/ ) ) {
		return true;
	}
	else {
		return false;
	}
}

/* éfinit les taille max des images */
var THUMB_MAX_WIDTH  = 100;
var THUMB_MAX_HEIGHT = 100;
var SHOW_MAX_WIDTH   = 350;
var SHOW_MAX_HEIGHT  = 350;

new Event.observe(window, 'load', function() {
	// gestion des onglets
  /*try {
    $('tab').makePositioned();
    $('tab').show();
    aButtons = $$('#buttonTab div[class="btNormal"] a');
    aButtons.each(function(element){new Effect.Opacity(element, {duration:0, from:1.0, to:0.35})});
    new Effect.Opacity($(aButtons.first()), {duration:0, from:0.35, to:1.0})

    aButtons.each( function(element){
      new Event.observe(element, 'click', function(event) {
      	//if ( !element.hasClassName('active') ){
	        Event.stop(event);
	        //aButtons.each( function(elt){element.removeClassName('active')});
	        //element.addClassName('active');
	        f_show_tab_content(element);
	      //}
      })
    } );
  }
  catch(e) {}*/

  try {
  	// gestion de la galerie photo
  	f_redim_image('photo_principale', 'show');
  	$('photo_principale').show();
    aImgs  = $$('#menu_photo img');
    aImgs.each( function(oImg){
      f_redim_image(oImg, 'thumb');
      new Event.observe(oImg, 'click', function(event) {
        Event.stop(event);
        $('photo_principale').src = $(oImg).readAttribute('src');
        $('photo_invisible').src = $(oImg).readAttribute('src');
        f_redim_image('photo_principale', 'show');
        $('photo_principale').title = $(oImg).readAttribute('title');
        $('lien_photo').title = $(oImg).readAttribute('title');
        $('lien_photo').href = $(oImg).readAttribute('src');
      })
    } );
  }
  catch(e) {}
  
  add_alternance();
});

function add_alternance()
{
	//Ajoute une alternance de couleur sur les divs a l'intérieur d'une classe "alternate"
	$$(".alternate>div")
	    .findAll(function(row,i){ return i % 2 == 1; })
	    .invoke("addClassName", "odd");
}

function f_show_tab_content(oThis) {
  Id_to_show = $(oThis).readAttribute('rel');
  aTabs    = $$('#tab div[class="tab_content"]');
  aButtons = $$('#buttonTab div[class="btNormal"] a');
  aTabs.each( function(elt){
    if ( elt.style.display != 'none' ) {
		elt.style.position = 'absolute';
    	new Effect.Parallel([ new Effect.Fade(elt),
                            new Effect.Appear(Id_to_show)],
                          {duration: 0, beforeStart: function(effect){
                            aButtons.each(function(element){new Effect.Opacity(element, {duration:0, from:1.0, to:0.35})});
                            new Effect.Opacity($(oThis), {duration:0, from:0.35, to:1.0});
                          }});
        elt.style.position = 'relative';
    }
   } );
}

function f_redim_image(oImg, type){
	var dimensions;
	var img_width  = 0;
	var img_height = 0;

	switch(type){
		case 'thumb':
			dimensions = $(oImg).getDimensions();
			img_width  = (dimensions.width >= THUMB_MAX_WIDTH) ? THUMB_MAX_WIDTH : dimensions.width;
			img_height = (dimensions.height >= THUMB_MAX_HEIGHT) ? THUMB_MAX_HEIGHT : dimensions.height;
			break;
		case 'show':
			dimensions = $('photo_invisible').getDimensions();
			img_width  = (dimensions.width >= SHOW_MAX_WIDTH) ? SHOW_MAX_WIDTH : dimensions.width;
			img_height = (dimensions.height >= SHOW_MAX_HEIGHT) ? SHOW_MAX_HEIGHT : dimensions.height;
			break;
	}
	if (dimensions.width >= dimensions.height){
		// mode paysage
		$(oImg).setAttribute('width',img_width);
		$(oImg).removeAttribute('height');
	}
	else {
		// mode portrait
		$(oImg).removeAttribute('width');
		$(oImg).setAttribute('height',img_height);
	}
}

function GetId(id)
{
return document.getElementById(id);
}
var popAffiche=false; // La variable i nous dit si la bulle est visible ou non

function move(e) {
    if (navigator.appName!="Microsoft Internet Explorer") { // Si on est pas sous IE
    curX=e.pageX + "px";
    curY=e.pageY + "px";
    }
    else { // Modif proposÃ© par TeDeum, merci Ã  lui
    if(document.documentElement.clientWidth>0) {
	curX=0+event.x-3+document.documentElement.scrollLeft+"px";
	curY=0+event.y-3+document.documentElement.scrollTop+"px";
    } else {
	curX=0+event.x-3+document.body.scrollLeft+"px";
	curY=0+event.y-3+document.body.scrollTop+"px";
	     }
    }

}

function switchLoca(text) {
   	GetId("prod" + text).style.left=curX;
	GetId("prod" + text).style.top=curY;
    GetId("prod" + text).style.visibility="visible";

  /*else
  {	popAffiche=false;
  	window.setTimeout("hideLoca("+text+")",3000);	}*/
}
function hideLoca(text) {
	GetId("prod" + text).style.visibility="hidden"; // Si la bulle etais visible on la cache
}

function switchGenre(val){
	if(document.getElementById('type_hebergement'))
	{
		document.getElementById('type_hebergement').value=val;	
		document.getElementById('type_hebergement').onchange();	
	}
}
	function lbl_tracker()
	{
		var chaine="";
		type_heber = document.getElementById('type_hebergement').options[document.getElementById('type_hebergement').selectedIndex].value;
		switch (type_heber) {
			case '30000011':
				chaine += 'hotels/';
			break;
			case '30000014':
				chaine += 'gites_ruraux/';
			break;
			case '30000015':
				chaine += 'meubles/';
			break;
			case '30000016':
				chaine += 'gites_enfants/';
			break;
			case '30000017':
				chaine += 'auberge_jeunesse/';
			break;
			case '30000018':
				chaine += 'gite_etape/';
			break;
			case '30000019':
				chaine += 'chambre_hotes/';
			break;
			case '30000021':
				chaine += 'structures_polyvalentes/';
			break;
			case '30000022':
				chaine += 'villages_vacances/';
			break;
			case '30000023':
				chaine += 'hameaux_gites/';
			break;
			case '3000025':
				chaine += 'hotellerie_pleinair/';
			break;
			case '30000026':
				chaine += 'camping_ferme/';
			break;
			case '30000027':
				chaine += 'aire_naturelle_camping/';
			break;
			case '30000029':
				chaine += 'restaurants/';
			break;
			case '30000030':
				chaine += 'fermes_auberges/';
			break;
			case '30000031':
				chaine += 'fastfood/';
			break;
			case '30000032':
				chaine += 'cafeteria/';
			break;
			case '30000033':
				chaine += 'brasseries/';
			break;
			case '30000034':
				chaine += 'restaurants_specialises/';
			break;
			case '30000035':
				chaine += 'expos_permanentes/';
			break;
			case '30000036':
				chaine += 'chateaux/';
			break;
			case '30000037':
				chaine += 'musees/';
			break;
			case '30000038':
				chaine += 'monuments/';
			break;
			case '30000039':
				chaine += 'edifices_religieux/';
			break;
			case '30000041':
				chaine += 'sites_naturels/';
			break;
			case '30000042':
				chaine += 'lacs_plansdeau/';
			break;
			case '30000043':
				chaine += 'parcs_jardin/';
			break;
			case '30000045':
				chaine += 'visites_entreprise/';
			break;
			case '30000046':
				chaine += 'produits_regionaux/';
			break;
			case '30000047':
				chaine += 'parcs_animaliers/';
			break;
			case '30000048':
				chaine += 'visites_guidees/';
			break;
			case '30000117':
				chaine += 'salon_the/';
			break;
			case '30000105':
				chaine += 'centres_art/';
			break;
			case '30000118':
				chaine += 'plus_beaux_villages/';
			break;
			case '30000119':
				chaine += 'routes_historiques/';
			break;
			case '30000123':
				chaine += 'architecture_urbaine/';
			break;
			case '30000124':
				chaine += 'aire_camping_car/';
			break;
			case '30000131':
				chaine += 'produits_terroir/';
			break;
			case '30000132':
				chaine += 'bistrots_pays/';
			break;
			case '30000133':
				chaine += 'vestiges_archeo/';
			break;
			case '30000134':
				chaine += 'ouvrages_dart/';
			break;
			case '30000135':
				chaine += 'points_vue_amenages/';
			break;
			case '30000136':
				chaine += 'villages_fleuris/';
			break;
			case '30000137':
				chaine += 'savoir_faire/';
			break;
			case '30000138':
				chaine += 'visites_agricoles/';
			break;
			case '30000151':
				chaine += 'sentiers_interpretation/';
			break;
			case '30000152':
				chaine += 'sorties_nature/';
			break;
			case '30000153':
				chaine += 'clevacances/';
			break;
			case '30000164':
				chaine += 'circuits_decouverte/';
			break;
			case '30000165':
				chaine += 'chalets_mobilhome/';
			break;
			case '30000166':
				chaine += 'residence_tourisme/';
			break;
			case '30000174':
				chaine += 'village_etapes/';
			break;
			case '30000175':
				chaine += 'cites_caractere/';
			break;
			case '30000187':
				chaine += 'auberge_pays/';
			break;
			case '30000189':
				chaine += 'specialites_gastronomiques/';
			break;
			default:
				chaine += 'tous/';
			break;
		}
		if($('destination_sejour_select_hv').checked)
		{	chaine +='haute_vienne/';	}
		if($('destination_sejour_select_cr').checked)
		{	chaine +='creuse/';	}
		if($('destination_sejour_select_cor').checked)
		{	chaine +='correze/';	}
		if($('destination_sejour_select_tt').checked)
		{	chaine +='tous/';	}
		return chaine;
	}
document.onmousemove=move; // des que la souris bouge, on appelle la fonction move pour mettre a jour la position de la bulle.
//-->