/**
 * Ajax Comments
 * @param String nom
 * @param String prenom
 * @param String email
 * @param String entreprise
 * @param String comment
 */
function Comments(nom, prenom, email, entreprise, comment)
{
	this.nom		= nom;
	this.prenom		= prenom;
	this.email		= email;
	this.entreprise	= entreprise;
	this.comment	= comment;
};

Comments.splashElement = 'comment_over'; // YAHOO.util.Dom.get

Comments.prototype.send = function()
{
	if(!this.nom || !this.prenom || !this.email || !this.comment)
	{
		return false;
	}
	var sUrl = '/php/script.php?pg=coordonnees';
	var sPostData = 'nom=' + this.nom + '&prenom=' + this.prenom + '&email='
					+ this.email + '&entreprise=' + this.entreprise + '&comment=' + this.comment;
	
	var transaction = YAHOO.util.Connect.asyncRequest('POST', sUrl, Comments.sendCallback, sPostData);
	return false;
};

Comments.disableSplashMessage = function()
{
	var splashDiv = YAHOO.util.Dom.get(Comments.splashElement);
	splashDiv.style.opacity = 0.0;
	splashDiv.style.display = 'none';
};

Comments.hideSplashMessage = function()
{
	var hideAnim = new YAHOO.util.Anim(Comments.splashElement,
										 {opacity: {from: 1.0, to: 0.1}},
										 0.5, YAHOO.util.Easing.easeOut);
	hideAnim.onComplete.subscribe(Comments.disableSplashMessage);
	hideAnim.animate();
};

Comments.pendingHideSplashMessage = function()
{
	YAHOO.util.Dom.get('comments').reset();
	setTimeout("Comments.hideSplashMessage()", 2000);
};

Comments.showSplashMessage = function()
{
	var splashDiv = YAHOO.util.Dom.get(Comments.splashElement);
	splashDiv.style.opacity = 0.0;
	splashDiv.style.display = 'block';
	
	var showAnim = new YAHOO.util.Anim(Comments.splashElement,
										 {opacity: {from: 0.0, to: 1.0}},
										 0.5, YAHOO.util.Easing.easeOut);
	showAnim.onComplete.subscribe(Comments.pendingHideSplashMessage);
	showAnim.animate();
};

Comments.sendCallback = {
	success:	function(o)
				{
					Comments.showSplashMessage(); 
				},
	failure:	function(o)
				{
					alert('Une erreur s\'est produite.');
				}
};