// Anti-mail non prévu.
// Usage : NoMail( 'fin DNS', 'compte', 'début DNS', 'title du lien' );
function NoMail( s1, s2, s3, title )
{
	document.write( "<a title='" + title + "' href='mailto:" + s2 + "@" + s3 + s1 + "'>" + s2 + "@" + s3 + s1 + "</a>" );
}

// Dessine un flash (correctif pour IE, afin d'éviter le cadre clignotant désagréable)
function draw_flash( name, width, height )
{
	document.write( "<object type=\"application/x-shockwave-flash\" data=\"" + name + "\" style=\"width: " + width + "px; height: " + height + "px\">" );
	document.write( "<param name=\"movie\" value=\"" + name + "\">" );
	document.write( "<param name=\"quality\" value=\"high\">" );
	document.write( "<param name=\"menu\" value=\"false\">" );
	document.write( "</object>" );
}

function rechercheCaviste()
{
	ville = document.caviste.ville.value;
	valid = true;
	if (ville=="")
	{
		alert("Vous devez préciser votre numéro de département ou votre code postale");
		document.caviste.ville.focus();
		valid=false;
	}
	if (ville.length!=2 && ville.length!=5 && valid){
		alert("Merci de saisir un numéro de département à 2 chiffres ou votre code postal à 5 chiffres");
		document.caviste.ville.focus();
		valid=false;
	}
	if (valid)
	{
		if (document.location.search.indexOf("caviste",1) == -1 )
		{
			if (document.location.search == "")
			{
				document.location.href = location + "?caviste="+ville;
			}
			else
			{
				document.location.href = location + "&caviste="+ville;
			}
		}
		else
		{
			document.location.href = document.location.href.split("caviste=")[0] + "caviste="+ville;
		}
	}
}
function accesPro()
{
	login = document.pros.login.value;
	password = document.pros.password.value;
	
	valid = true;
	if (login=="" || password=="")
	{
		alert("Le champ login et/ou password est vide");
		document.pros.password.focus();
		valid=false;
	}
	if (valid)
	{
		if(document.location.pathname=="/")
		{
			document.pros.action = "/default.aspx";
		}
		document.pros.submit();
	}

}
function accesProEgare()
{
	login = document.pros.login.value;
	
	valid = true;
	if (login=="")
	{
		alert("Le champ login est vide");
		document.pros.login.focus();
		valid=false;
	}
	if (valid)
	{
		if(document.location.pathname=="/")
		{
			document.pros.action = "/default.aspx";
		}
		document.pros.submit();
	}

}
function recherche()
{
	texte = document.Recherche.Texte.value;
	valid = true;
	if (texte=="")
	{
		alert("Le champ de recherche est vide");
		document.Recherche.Texte.focus();
		valid=false;
	}
	if (valid)
	{
		document.location.href = document.location.href.split("?")[0] + "?p=Search&search="+texte;
	}

}

function motdepasse()
{
	if (document.location.search != "")
		document.location.href = document.location.href + "&MotDePasseEgare=true";
	else
		document.location.href = document.location.href + "?MotDePasseEgare=true";
	
}

function aide()
{
	if (document.location.search != "")
		document.location.href = document.location.href + "&Aide=true";
	else
		document.location.href = document.location.href + "?Aide=true";
	
}

function closeAide()
{
	if (document.location.search.indexOf("?Aide=true")>=0)
	{
		motif = new RegExp("?Aide=true","g");
		document.location.href = document.location.href.replace(motif,"");
	}
	
	if (document.location.search.indexOf("&Aide=true")>=0)
	{
		motif = new RegExp("&Aide=true","g");
		document.location.href = document.location.href.replace(motif,"");
	}
}

function Deconnexion()
{
	res = confirm("Voulez-vous vraiment quitter votre espace professionnel?");
	if (res)
	{
		document.location.href = "/?dec=true";
	}
	else
		return false;
}

function envoiSMS()
{
	if (document.sms.textesms.value == "")
	{
		alert("Merci d'indiquer votre message dans le champ prévu à cet effet.");
		document.sms.textesms.focus();
	}
	else
		document.sms.submit();
}