/////////////////////
// à ajouter pour la version 2 du tableau de tarifs
var tab_v2 = new Object();
tab_v2.reserve = function(code) {
	priceGrid.reserve4(code);
}

function setSearchEngine()
{
	var se = new SearchEngine({method: 'get'});

	se.addSelect({htmlEl:"moteurSejour", title: 'Votre séjour', type:"sejour", nativeScroll: true, optionInput:"checkbox"});
	se.addSelect({htmlEl:"moteurDate", title: 'Date de départ', type:"dateBySejour", optionInput:"checkbox", nativeScroll: true, filterFields: ["moteurSejour"]});
	se.addSelect({htmlEl:"moteurPart", title: 'Participants', type:"nbPart", nativeScroll: true});
	se.addSelect({htmlEl:"moteurRegion", title: 'Destination', type:"region", multiple: true, nativeScroll: true, optionInput:"checkbox", sub:{type: "departement", multiple:true, nativeScroll: true, optionInput: "checkbox"}});
	se.addSelect({htmlEl:"moteurHeb", title: "Hébergements", type:"typeHeb", multiple: true, optionInput:"checkbox", nativeScroll: true});
	se.addSelect({htmlEl:"moteurDemande", title: "Demandes particulières", type:"demandes", multiple: true, optionInput:"checkbox", nativeScroll: true});
	se.setSummary({'id': 'moteurRecap'});
	se.setLoader({'id': "moteurLoader", attachedElement: "moteur"});
	se.setSubmit({method: "get", action: "/recherche", htmlEl: "moteurSubmit"})
	se.setReset({htmlEl: "moteurReset"})
	
	se.display();
}

window.onload = function()
{
	for(var i = 1; i < 8; i++)
	{
		//document.getElementById("header-link-"+i).onmouseover = function()
		//{
		/*
			for(var j = 1; j < 8; j++)
			{
				document.getElementById("ss-menu-"+j).style.display="none";
			}
			tmp = this.id.split("-");
			document.getElementById("ss-menu-"+tmp[2]).style.display="";
			*/
		//}
	}
}

function afterGetPricesGrid(xhr)
{

	getEl("tarifs").innerHTML = xhr.responseText;
	setTimeout('scrolldiv("tarifs_right",0,0,"tarifs_left")', 1000) ;
	
	
}

function afterReserve()
{
	//location.href = '/locations-vacances-reservation_1.html';
	getPanier();
	getEl("tarifs_right_1").style.display = "";
}
var tabActive = "CAC_10";
var tabs = new Array("CAC_10", "CAC_20", "CAC_30", "CAC_40", "CAC_50", "CAC_60", "CAC_70");
var indOnglet;
function tab(t, div)
{
	if(tabActive != div)
	{
		t.className = "onglet selected";
		getEl("tab_"+tabActive).className = "onglet inactif";
		//alert("test");
		getEl(tabActive).style.display = "none";
		getEl(div).style.display = "";
		
		tabActive = div;
		
	}
}
function initTab()
{
	for(indOnglet=0; indOnglet < tabs.length; indOnglet++)
	{
	
	
		if(getEl("tab_"+tabs[indOnglet]))
		{
			getEl("tab_"+tabs[indOnglet]).onclick = function(){
			
			tab(this, this.id.replace("tab_",""));
			}
			if(tabActive != tabs[indOnglet]){
				getEl(tabs[indOnglet]).style.display = "none";
			}
		}
	}
}
var CarteActive = "carte_france";
var tabsCarte = new Array("carte_france", "carte_espagne", "carte_portugal", "carte_italie");
var indCarte;
function tabCarte(t, div)
{
	if(CarteActive != div)
	{
		t.className = "onglet selected";
		getEl(CarteActive).className = CarteActive+"_inactive";
		getEl(div).className = div+"_active";
		swfobject.embedSWF("/templates/regional/images/"+div+"_ELV.swf", "home_swf", "184", "178", "9.0.0");
		//alert("div = "+div+" carte active = "+CarteActive+" t="+t);
		CarteActive = div;
		
	}
}
function initCarte()
{
	for(indCarte=0; indCarte < tabsCarte.length; indCarte++)
	{
	
	
		if(getEl(tabsCarte[indCarte]))
		{
			getEl(tabsCarte[indCarte]).onclick = function(){
			
			tabCarte(this, this.id);
			}
			if(CarteActive != tabsCarte[indCarte]){
			
				getEl(tabsCarte[indCarte]).className = tabsCarte[indCarte]+"_inactive";
			}
		}
	}
}
/* ancienne
function getImgs(produitId, start, end)
{
	var xhr = getXhr();
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			getEl("img_small").innerHTML = xhr.responseText;
		}
	}
	
	params = "produitId="+produitId+"&start="+start+"&end="+end;

	xhr.open("GET", "/scripts/elv/imgs.php?"+params+"&d="+ (new Date()).getTime(), true);
    xhr.send(null);
}
*/
function getImgs(produitId, start, end)
{
	var xhr = getXhr();
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			getEl("imgs").innerHTML = xhr.responseText;
		}
	}
	
	params = "produitId="+produitId+"&start="+start+"&end="+end;

	xhr.open("GET", "/scripts/regional/imgs.php?"+params+"&d="+ (new Date()).getTime(), true);
    xhr.send(null);
}
function getImgs_v2(produitId, start, end, saison)
{
	var xhr = getXhr();
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			getEl("img_thumbs").innerHTML = xhr.responseText;
		}
	}
	
	params = "produitId="+produitId+"&start="+start+"&end="+end+"&saison="+saison;

	xhr.open("GET", "/scripts/regional/imgs.php?"+params+"&d="+ (new Date()).getTime(), true);
    xhr.send(null);
}
function saveNewsletter() {
	var xhr = getXhr();

	var adresse = document.getElementById('adresseNewsletter').value;

	xhr.onreadystatechange = function() {
		if(xhr.readyState == 4 && xhr.status == 200) {
			if (xhr.responseText == "") alert ("Votre adresse électronique a bien été enregistrée.");
		}
	}

	var params = "adresse=" + adresse;

	xhr.open("GET", "/ajax/fonctions.php?action=saveNewsletter&" + params + "&d="+ (new Date()).getTime(), true);
	xhr.send(null);
}
function obtenirBrochure() {
	document.getElementById("boutonBrochure").innerHTML = "<b>Veuillez patienter, votre brochure est en cours de constitution. L'attente prend entre 15 et 60 secondes en fonction du nombre de pages.</b>";
	document.leFormulaire.submit();
}
function sendSearch(div){
	document.getElementById(div).style.display = "inline";
	document.getElementById(div+"Content").style.display = "inline";
}
