var div = document.getElementById('zDialog');

//Fonction appellée si la connexion est ok
var handleSuccess = function(o){
	if(o.responseText !== undefined){
        if (o.responseText.substr(0,4) == "url:") {
            window.location = o.responseText.substr(4);
        }
        else {
    		div.innerHTML = o.responseText;
        }
	}
}

//Fonction appellée si la connexion est ko
var handleFailure = function(o){
	if(o.responseText !== undefined){
		div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
		div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
		div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
	}
}

var callback =
{
  success:handleSuccess,
  failure:handleFailure
};


// This example facilitates a POST transaction.
// An HTTP GET can be used as well.
function valid(formId){
    // argument formId can be the id or name attribute value of the HTML form, or an HTML form object.
    var formObject = document.getElementById(formId);
    YAHOO.util.Connect.setForm(formObject);    
    var cObj = YAHOO.util.Connect.asyncRequest('POST', formObject.action, callback);
	
}
