/*
var allocampings = new Object();
allocampings.response = function(params)
{
	getEl("l_content").style.display = "none";
	getEl("wait").style.display = "";
	if(typeof params == "undefined")
	{
		if (getEl("search_region_id")) tmpregion = getEl("search_region_id").value; else tmpregion = "";
		if (getEl("search_dep_id")) tmpdep = getEl("search_dep_id").value; else tmpdep = "";
		if (getEl("search_ville_id")) tmpVille = getEl("search_ville_id").value; else tmpVille = "";
		if (getEl("date")) tmpdate = getEl("date").value; else tmpdate = "";
		if (getEl("duree")) tmpduree = getEl("duree").value; else tmpduree = "";
	
		var siteId = getEl("siteId").value;
		params = "siteId="+siteId+"&region_id="+tmpregion+"&dep_id="+tmpdep+"&ville_id="+tmpVille+"&date="+tmpdate+"&duree="+tmpduree+"&nump=1";
	}
	var xhr = getXhr();
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			getEl("l_body").innerHTML = xhr.responseText;
			getEl("l_content").style.display = "";
			getEl("wait").style.display = "none";
			
			//carte
	        var flashvars = {};
	        var params = {wmode: "transparent"};
	        var attributes = {};  
	        swfobject.embedSWF("/templates/allo-campings/swf/carte.swf", "h_carte", "247", "239", "9.0.0","", flashvars, params, attributes);

		}
	}

	xhr.open("GET", "/scripts/allo-campings/response.php?"+params+"&d="+ (new Date()).getTime(), true);
    xhr.send(null);
}
*/

var allocampings = new Object();
allocampings.response = function(params)
{
	getEl("l_content").style.display = "none";
	getEl("wait").style.display = "";
	if(typeof params == "undefined")
	{
		if (getEl("search_region_id")) tmpregion = getEl("search_region_id").value; else tmpregion = "";
		if (getEl("search_dep_id")) tmpdep = getEl("search_dep_id").value; else tmpdep = "";
		if (getEl("search_ville_id")) tmpVille = getEl("search_ville_id").value; else tmpVille = "";
		if (getEl("date")) tmpdate = getEl("date").value; else tmpdate = "";
		if (getEl("nuite_id")) tmpNuite = getEl("nuite_id").value; else tmpNuite = "";
		if (getEl("capacite")) tmpcapacite = getEl("capacite").value; else tmpcapacite = "";
		if (getEl("theme_res_1")) tmpthemeres1 = getEl("theme_res_1").value; else tmpthemeres1 = "";
		if (getEl("theme_res_3")) tmpthemeres3 = getEl("theme_res_3").value; else tmpthemeres3 = "";
		if (getEl("theme_res_4")) tmpthemeres4 = getEl("theme_res_4").value; else tmpthemeres4 = "";
		
		
		var paramTheme1 = "";
		var paramTheme2 = "";
		var paramTheme3 = "";
		var paramTheme4 = "";
		
		if (tmpthemeres1 != ""){
			paramTheme1 = "&theme_res_1="+tmpthemeres1;
		}
		if (tmpthemeres3 != ""){
			paramTheme3 = "&theme_res_3="+tmpthemeres3;
		}
		if (tmpthemeres4 != ""){
			paramTheme4 = "&theme_res_4="+tmpthemeres4;
		}
		
		paramTheme = paramTheme1 + paramTheme2 + paramTheme3 + paramTheme4;
	
		//var siteId = getEl("siteId").value;
		params = "siteId=9&region_id="+tmpregion+"&dep_id="+tmpdep+"&ville_id="+tmpVille+"&date="+tmpdate+"&nuite_id="+tmpNuite+"&capacite_id="+tmpcapacite+"&nump=1"+paramTheme;
		//alert(params);
	}
	var xhr = getXhr();
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			getEl("l_content").innerHTML = xhr.responseText;
			//alert(xhr.responseText);
			getEl("l_content").style.display = "";
			getEl("wait").style.display = "none";
			
		}
	}

	xhr.open("GET", "/scripts/allo-campings/response_search.php?"+params+"&d="+ (new Date()).getTime(), true);
    xhr.send(null);
}


function getPrixDispo(produitId, duree)
{
	priceGrid.display3(produitId, duree,"");
}

var tabActive = "Hebergement";
var tabs = new Array("Hebergement", "CAC_10", "CAC_20", "CAC_30", "CAC_40", "CAC_50", "CAC_60", "prixDispo");
var indOnglet;
function tab(t, div)
{
	if(tabActive != div)
	{
		t.className = "onglet selected";
		getEl("tab_"+tabActive).className = "onglet inactif";
		
		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_",""));
			}
		}
	}
}

/*allocampings.reserve = function() {
	priceGrid.reserve3("containPrixDispo");
}*/
allocampings.reserve = function(code) {
	priceGrid.reserve4(code);
}

var popUpHebActive = "";
function popUpHeb(div)
{
	if(popUpHebActive != "")
	{
		getEl(popUpHebActive).style.display = "none";
	}
	popUpHebActive = div;
	getEl(div).style.display = "";
}

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/allo-campings/imgs.php?"+params+"&d="+ (new Date()).getTime(), true);
    xhr.send(null);
}

allocampings.forward = function()
{
	var xhr = getXhr();
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			location.href = xhr.responseText;
		}
	}

	xhr.open("GET", "/scripts/allo-campings/getPageRetour.php?d="+ (new Date()).getTime(), true);
    xhr.send(null);
}

allocampings.submitStep = function(step)
{
	document.onkeypress = function(e)
	{
	    if(window.event)
	    {
	        e = window.event;
	    }
	    if(e.keyCode == 13)
	    {
	       switch(step)
	       {
	       	case 1 : verifPart();
	       			 break;
	       	case 2 : document.nbPart.submit();
	       			 break;
	       	case 3 : document.nbPart.submit();
  			 		 break;
	       	case 4 : document.nbPart.submit();
		 		 break;
	       	case 5 : document.nbPart.submit();
	       			 break;
	       	case 6 : document.nbPart.submit();
  			 		 break;
	       }
	    }
	}
}

function beforeGetPricesGrid()
{
	getEl("tarifs").innerHTML = "<p style='text-align:center;color:#FFFFFF; font-size:14px;'><br />Recherche des prix<br /><img src='/commun/images/common/loading.gif' style='margin:3px;' /></p><br />";
}

function afterGetPricesGrid(xhr)
{

	getEl("tarifs").innerHTML = xhr.responseText;
	setTimeout('scrolldiv("tarifs_right",0,0,"tarifs_left")', 1000) ;
	
}

function afterReserve()
{
	location.href = 'reservation_1.html';
	//getPanier();
}
