/* Javascripts utilisés sur le site
 * Mettez l'ensemble de vos fonctions générique javascript ici
 *
 * La liaison avec les page se fait à l'aide du code ci-dessous :
 * <script type="text/javascript" src="css-js/scripts.js"></script>
 */

/* CORRECTION DU BUG DE FLASH AVEC IE */
function bugFlash() {
	//Determine browser, we only need this for Internet Explorer
	if (navigator.appName == "Microsoft Internet Explorer") {
		
		//Array of elements to be replaced
		var arrElements = new Array(3);
		arrElements[0] = "object";
		arrElements[1] = "embed";
		arrElements[2] = "applet";
	
		
		//Loop over element types
		for (n = 0; n < arrElements.length; n++) {
		
			//set object for brevity
			replaceObj = document.getElementsByTagName(arrElements[n]);
			
			//loop over element objects returned
			for (i = 0; i < replaceObj.length; i++ ) {
			
				//set parent object for brevity
				parentObj = replaceObj[i].parentNode;
				
				//grab the html inside of the element before removing it from the DOM
				newHTML = parentObj.innerHTML;
				
				//remove element from the DOM
				parentObj.removeChild(replaceObj[i]);

				//stick the element right back in, but as a new object
				parentObj.innerHTML = newHTML;

				}
			}
		}
	}



function montre(id) {
		var myStretch = document.getElementsByClassName('stretch');
		var myStretcher = document.getElementsByClassName('stretcher');
		var myAccordion = new fx.Accordion(myStretch, myStretcher, {opacity: true});
                myAccordion.showThisHideOpen(myStretcher[id]);
}

/* changeToMail
-----------------------------------------------------------------------------*/
var mails = new Array();
mails[0] = "cas"+"qu"+"e-"+"ho"+"use"+"@"+"wa"+"nad"+"oo.fr";
mails[1] = "";

function changeToMail(id,i,title){
    if (!title) title = "Envoyez-nous un e-mail";
    if (document.getElementById(id)) {
        document.getElementById(id).innerHTML = "<a href='" + "mai" + "lto:" + mails[i] + "' title='" + title + "'>" + mails[i] + "</a>";
    }
}
/* changeToMail
-----------------------------------------------------------------------------*/
jQuery.noConflict();
function logout(){
	callAjax({method:7}, function(){
			document.location = "index.php";
			endLoading();
		});
}
function userConnect()
{
	callAjax({method:6, user:jQuery("#sidebar-username").val(), pass:jQuery("#sidebar-password").val()}, function(result){
		if (result)
        {
    //location.reload(true);

			jQuery("#sidebar-login").slideUp("slow", function(){

                out = "<p><strong>Bonjour,<br /><a href='mon_compte.php' title='Mon Compte'>" + result.firstname + " " + result.lastname + "</a> !</strong></p>";
				out += "<p style='border-top: 1px solid #8B8B81; padding-top: 5px; margin-top: 5px;'>";
                out += "<a href='mon_compte.php' title='Mon Compte' class='user'>Mon Compte</a>";
                out += "</p>";
                out += "<p style='border-top: 1px solid #8B8B81; padding-top: 5px; margin-top: 5px;'>";
				out += "<a href='javascript:logout();' id='sidebar-logout' title='D&eacute;connexion'>D&eacute;connexion</a>";
                out += "</p>";
	    		jQuery(this).html(out).slideDown("slow");

			});
        }
		else
			jError( "<strong>Identifiant</strong> ou <strong>Mot de passe</strong> invalide.", "Erreur");
		    endLoading();
	    });
}

jQuery(document).ready(function() {
//	jQuery("#rightConnect").click(function(){
//    	  userConnect();
//      });
    changeToMail("mails-place0",0);
});
