document.observe("dom:loaded", function() {
    if (application.getcookie('debug')=='1') debug=new Debug()
    $$('#photos div.attachment').sort(function(){Math.round(Math.random())-0.5;})
    $$('#photos div.attachment').invoke('show');
});

centerAttachment=function(_img,contW,contH){
    _img=$(_img);
    var _w=_img.getWidth(); var _h=$(_img).getHeight();
    _img.style.marginTop=parseInt((100-_h)/2)+'px';
    _img.style.marginLeft=parseInt((100-_img.offsetWidth)/2)+'px';

    
}
envoiFormulaire=function(formId){ // vérifie, valide et envoi le contenu du formulaire
    myform=new msForm($(formId));
    myform.valider(function(){
        if (formId=='contactAgence') {
            myform.setFrom(myform.datas.nom, myform.datas.email )
            myform.setTo(application.config["mail_to"])
        }
        myform.envoyer(function(r){
            myform.formulaire.enable();
            datas=r.responseText.split("\n");
            if (datas[0]=='ok'){
                myform.formulaire.addClassName('sent');
                if (formId!='contactAgence') alert("Le message a été envoyé.")
                if ($('applicationUserPromptBox')) destroyUserPromptBox(0);
            } else {
                alert(datas[1])
            }
        });
    });
}


