// JavaScript Document

function popup(url,width,height) {
	var zoomwindow;
	var features;
	features = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=" + width + ",height=" + height + "'";
	if (zoomwindow != null) {
		if (!zoomwindow.closed)
			zoomwindow.close();
	}
	zoomwindow = window.open(url,"ZOOMWINDOW",features);
}

// share on facebook
function shareOnFacebook() {
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'partager','toolbar=0,status=0,width=630,height=440');
	return false;
}
//share on myspace
function ShareOnMySpace(T, C, U, L){
var targetUrl = 'http://www.myspace.com/Modules/PostTo/Pages/?' + 't=' + encodeURIComponent(T) + '&c=' + encodeURIComponent(C) + '&u=' + encodeURIComponent(U) + '&l=' + L;
window.open(targetUrl);
}

function afficher(elem){
	document.getElementById(elem).style.display = "block";
}

function masquer(elem){
	document.getElementById(elem).style.display = "none";
}

function ShowDesc( NewDesc )
{
	if(PreviousDesc != null )
	{
		document.getElementById(PreviousDesc + "_on").style.display 	= "none";
		document.getElementById(PreviousDesc + "_off").style.display 	= "block";
		document.getElementById(PreviousDesc + "_desc").style.display 	= "none";
	}
	document.getElementById(NewDesc + "_on").style.display 		= "block";
	document.getElementById(NewDesc + "_off").style.display 	= "none";
	document.getElementById(NewDesc + "_desc").style.display 	= "block";
	PreviousDesc = NewDesc;
}

function showDiv(elem) {
	etat = document.getElementById(elem).style.display;
	if(etat == "none"){
		document.getElementById(elem).style.display = "block";
	} else {
		document.getElementById(elem).style.display = "none";
	}
}

function disparait() {
	new Effect.SwitchOff('box2');
} 

function createbox(mess) {
	$('box_contenu').innerHTML = mess;
	new Effect.BlindDown('box2');
	new Draggable('box2', {revert:true});
	setTimeout(disparait, 8000); 
}

function checkFormDA(id, ville){
	
	divId 		= 'donnerAvis'+id;				// ID of Div which will recover the result.
	url 		= '/module.avis.inc.php?ville='+ville+'&idresto='+id+'&action=connect_member';		// 'HTML file to be called' ext *.php, *.inc, ...
	loader 		= false;						// 'html for loading' or false
	effect 		= 'appear';						// 'appear' , 'blind' , 'highlight' or false
	ecache 		= false;						//cache for html file true or false
	$ajaxload(divId, url, loader, effect, ecache);
}

function sendFormDA(f, ville)
{
	var v_login = f.login.value;
	var v_passw = f.password.value;	
	var v_id 	= f.idresto.value;	
	
	if(IsEmpty(v_login) == true){
		alert("Veuillez préciser votre login");
		f.login.focus();
		return false;
	}
	
	if(IsEmpty(v_passw) == true){
		alert("Veuillez préciser votre mot de passe");
		f.password.focus();
		return false;
	}
	
	divId 		= 'donnerAvis'+v_id; // ID of Div which will recover the result.
	url 		= '/module.avis.inc.php?login='+v_login+'&pass='+v_passw+'&idresto='+v_id+'&ville='+ ville +'&action=connect_member'; // 'HTML file to be called'
	loader 		= '<p>loading</p>';					// 'html for loading' or false
	effect 		= 'appear';						// 'appear' , 'blind' , 'highlight' or false
	ecache 		= false;						//cache for html file true or false
	$ajaxload(divId, url, loader, effect, ecache);
	return false;
}

function DisplayDAItem()
{
	if ( document.getElementById("donnerAvis").style.display == "none" )
	{
		document.getElementById("donnerAvis").style.display = "block";
	} else {
		document.getElementById("donnerAvis").style.display = "none";
	}
	
}

function DisplayDA(id, ville)
{
	if( global_idDisplay != 0 && global_idDisplay != id )
	{
		document.getElementById("donnerAvis"+global_idDisplay).style.display 	= "none";
		document.getElementById("donnerAvis"+global_idDisplay).innerHTML 		= "";
	}
	if( global_idDisplay == id )
	{
		document.getElementById("donnerAvis"+id).style.display 					= "none";
		document.getElementById("donnerAvis"+id).innerHTML 						= "";
		global_idDisplay = 0;
	}
	else{
		if ( document.getElementById("donnerAvis"+id).style.display == "none" )
		{
			document.getElementById("donnerAvis"+id).style.display = "inline";
		}
		global_idDisplay = id;
		checkFormDA(id, ville);
	}
}

function SetRechercheHome ()
{	
	var starturl = "restaurants-resultats-recherche.php?";
	starturl += "idville=" 				+ document.F_SEARCH_AVANCE.idville.options[document.F_SEARCH_AVANCE.idville.selectedIndex].value;
	if(document.F_SEARCH_AVANCE.idquartier.options[document.F_SEARCH_AVANCE.idquartier.selectedIndex].value != "")
	{
	starturl += "&amp;idquartier=" 		+ document.F_SEARCH_AVANCE.idquartier.options[document.F_SEARCH_AVANCE.idquartier.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.nom.value != "")
	{
	starturl += "&amp;nom=" 			+ document.F_SEARCH_AVANCE.nom.value;
	}
	if(document.F_SEARCH_AVANCE.idtheme.options[document.F_SEARCH_AVANCE.idtheme.selectedIndex].value != "")
	{
	starturl += "&amp;idtheme=" 		+ document.F_SEARCH_AVANCE.idtheme.options[document.F_SEARCH_AVANCE.idtheme.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.idtype_cuisine.options[document.F_SEARCH_AVANCE.idtype_cuisine.selectedIndex].value != "")
	{
	starturl += "&amp;idtype_cuisine=" 	+ document.F_SEARCH_AVANCE.idtype_cuisine.options[document.F_SEARCH_AVANCE.idtype_cuisine.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.idbudget.options[document.F_SEARCH_AVANCE.idbudget.selectedIndex].value != "")
	{
	starturl += "&amp;idbudget=" 		+ document.F_SEARCH_AVANCE.idbudget.options[document.F_SEARCH_AVANCE.idbudget.selectedIndex].value;
	}
	document.location 	= starturl 		+ '&amp;searchmode=1';
	return false;
}

function SetRechercheHomepage ()
{	
	var starturl = "restaurants-resultats-recherche.php?";
	starturl += "idville=" 				+ document.F_SEARCH_AVANCE.idville.options[document.F_SEARCH_AVANCE.idville.selectedIndex].value;
	if(document.F_SEARCH_AVANCE.idquartier.options[document.F_SEARCH_AVANCE.idquartier.selectedIndex].value != "")
	{
	starturl += "&amp;idquartier=" 		+ document.F_SEARCH_AVANCE.idquartier.options[document.F_SEARCH_AVANCE.idquartier.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.idarr.options[document.F_SEARCH_AVANCE.idarr.selectedIndex].value != "")
	{
	starturl += "&amp;idarr=" 			+ document.F_SEARCH_AVANCE.idarr.options[document.F_SEARCH_AVANCE.idarr.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.nom.value != "")
	{
	starturl += "&amp;nom=" 			+ document.F_SEARCH_AVANCE.nom.value;
	}
	if(document.F_SEARCH_AVANCE.idtype.options[document.F_SEARCH_AVANCE.idtype.selectedIndex].value != "")
	{
	starturl += "&amp;idtype=" 			+ document.F_SEARCH_AVANCE.idtype.options[document.F_SEARCH_AVANCE.idtype.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.idtheme.options[document.F_SEARCH_AVANCE.idtheme.selectedIndex].value != "")
	{
	starturl += "&amp;idtheme=" 		+ document.F_SEARCH_AVANCE.idtheme.options[document.F_SEARCH_AVANCE.idtheme.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.idtype_cuisine.options[document.F_SEARCH_AVANCE.idtype_cuisine.selectedIndex].value != "")
	{
	starturl += "&amp;idtype_cuisine=" 	+ document.F_SEARCH_AVANCE.idtype_cuisine.options[document.F_SEARCH_AVANCE.idtype_cuisine.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.idspecialite.options[document.F_SEARCH_AVANCE.idspecialite.selectedIndex].value != "")
	{
	starturl += "&amp;idspecialite=" 	+ document.F_SEARCH_AVANCE.idspecialite.options[document.F_SEARCH_AVANCE.idspecialite.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.idbudget.options[document.F_SEARCH_AVANCE.idbudget.selectedIndex].value != "")
	{
	starturl += "&amp;idbudget=" 		+ document.F_SEARCH_AVANCE.idbudget.options[document.F_SEARCH_AVANCE.idbudget.selectedIndex].value;
	}
	document.location 	= starturl 		+ '&amp;searchmode=1';
	return false;
}

function SetRechercheAvancee ()
{	
	var starturl = "restaurants-resultats-recherche.php?";
	starturl += "idville=" 			+ document.F_SEARCH_AVANCE.idville.options[document.F_SEARCH_AVANCE.idville.selectedIndex].value;
	if(document.F_SEARCH_AVANCE.idquartier.options[document.F_SEARCH_AVANCE.idquartier.selectedIndex].value != "")
	{
	starturl += "&idquartier=" 		+ document.F_SEARCH_AVANCE.idquartier.options[document.F_SEARCH_AVANCE.idquartier.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.idarr.options[document.F_SEARCH_AVANCE.idarr.selectedIndex].value != "")
	{
	starturl += "&idarr=" 			+ document.F_SEARCH_AVANCE.idarr.options[document.F_SEARCH_AVANCE.idarr.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.nom.value != "")
	{
	starturl += "&nom=" 			+ document.F_SEARCH_AVANCE.nom.value;
	}
	if(document.F_SEARCH_AVANCE.idtype.options[document.F_SEARCH_AVANCE.idtype.selectedIndex].value != "")
	{
	starturl += "&idtype=" 			+ document.F_SEARCH_AVANCE.idtype.options[document.F_SEARCH_AVANCE.idtype.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.idtheme.options[document.F_SEARCH_AVANCE.idtheme.selectedIndex].value != "")
	{
	starturl += "&idtheme=" 		+ document.F_SEARCH_AVANCE.idtheme.options[document.F_SEARCH_AVANCE.idtheme.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.idtype_cuisine.options[document.F_SEARCH_AVANCE.idtype_cuisine.selectedIndex].value != "")
	{
	starturl += "&idtype_cuisine=" 	+ document.F_SEARCH_AVANCE.idtype_cuisine.options[document.F_SEARCH_AVANCE.idtype_cuisine.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.idspecialite.options[document.F_SEARCH_AVANCE.idspecialite.selectedIndex].value != "")
	{
	starturl += "&idspecialite=" 	+ document.F_SEARCH_AVANCE.idspecialite.options[document.F_SEARCH_AVANCE.idspecialite.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.idoption.options[document.F_SEARCH_AVANCE.idoption.selectedIndex].value != "")
	{
	starturl += "&idoption=" 		+ document.F_SEARCH_AVANCE.idoption.options[document.F_SEARCH_AVANCE.idoption.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.idbudget.options[document.F_SEARCH_AVANCE.idbudget.selectedIndex].value != "")
	{
	starturl += "&idbudget=" 		+ document.F_SEARCH_AVANCE.idbudget.options[document.F_SEARCH_AVANCE.idbudget.selectedIndex].value;
	}
	if(document.F_SEARCH_AVANCE.cacher.checked == true)
	{
	starturl += "&cacher=" 	+ document.F_SEARCH_AVANCE.cacher.value;
	}
	document.location 	= starturl 	+ '&searchmode=1';
	return false;
}

