$().ready(function()
{
    //menu_init('menu');
    
    // -------------------------
    // --- Temoignages clients (droite)
    // -------------------------
    new Scroll({
        id: 'divScroll', // id de la div qui entourre le tout
        tag: 'div', // fait défiler toutes les div à l'interrieur de divScroll
        top: true,
        offset: 350, // height de divScroll
        speed: 3,
        pause: 5000
    });
    
    // -------------------------
    // --- Maps google Analytics
    // -------------------------
    var current_url = document.location.href;
    var reg = new RegExp("maps.php", "g");
    //var reg2 = new RegExp("espace-membre.html#form1", "g");
    
    //if( reg.test(current_url) || reg2.test(current_url) )
    if( reg.test(current_url) )
    {
        initNXGMap(document.getElementById('map'));
    }

    // -------------------------
    // --- Ajout aux favoris (http://jquery.jarodxxx.com/bonus/Fonctions-utiles/Ajouter-aux-favoris/)
    // -------------------------

    // add a "rel" attrib if Opera 7+
    if(window.opera) {
        if ($("a.jqbookmark").attr("rel") != ""){ // don't overwrite the rel attrib if already set
            $("a.jqbookmark").attr("rel","sidebar");
        }
    }
   
    $("a.jqbookmark").click(function(event){
        event.preventDefault(); // prevent the anchor tag from sending the user off to the link
        var url = this.href;
        var title = this.title;
       
        if (window.sidebar) { // Mozilla Firefox Bookmark
            window.sidebar.addPanel(title, url, "");
        } else if( window.external ) { // IE Favorite
            window.external.AddFavorite( url, title);
        } else if(window.opera) { // Opera 7+
            return false; // do nothing - the rel="sidebar" should do the trick
        } else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
            alert('Malheureusement, ce navigateur ne prend pas en charge l\'action demandée, s\'il vous plaît ajouté manuellement cette page à vos Favoris.');
        }
    });
    
    
    // -------------------------
    // --- Onglets Réseau sociaux (http://www.queness.com/post/106/jquery-tabbed-interfacetabbed-structure-menu-tutorial)
    // -------------------------
    
    //Get all the LI from the #ulDModuleN1 UL
    $('.ulDModuleN1 > li > a').click(function()
    {
        //perform the actions when it's not selected
        if (!$(this).hasClass('selected'))
        {
            //remove the selected class from all LI    
            $('.ulDModuleN1 > li > a').removeClass('selected');
            //$('.ulDModuleN1 > li > a').removeAttr("disabled");
            
            //Reassign the LI
            $(this).addClass('selected');
            
            //Hide all the DIV in .boxBody
            $('.ulDModuleN2').slideUp('1500');
            
            //Look for the right DIV in boxBody according to the Navigation UL index, therefore, the arrangement is very important.
            $('.ulDModuleN2:eq(' + $('.ulDModuleN1 > li > a').index(this) + ')').slideDown('1500');
        }
        
    }).mouseover(function()
    {
        //Add and remove class
        $(this).addClass('mouseover');
        $(this).removeClass('mouseout');
        
    }).mouseout(function()
    {
        //Add and remove class
        $(this).addClass('mouseout');
        $(this).removeClass('mouseover');
    });

}); 


// affiche les vignettes de la page online
function toggle_menu(idmenu)
{  
	var btn = document.getElementById("menu"+idmenu);
	var menu = document.getElementById("sousmenu"+idmenu);
	
	if (menu.style.display == 'none')
	{
		btn.className = "menu-on";
		menu.style.top = (btn.offsetTop+30)+"px";
		menu.style.left = (btn.offsetLeft+0)+"px";
		menu.style.display='';
	}
	else
	{
		btn.className = "menu-off";
		menu.style.display='none';
	}
}

function callCrea(mapage)
{
	document.getElementById('type').update("<img src=\"./images/ajax_item.gif\" alt=\"\" /> Patientez");
	new Ajax.Request('ajax.php',
	{
		method: 'post',
		parameters: 'mapage='+mapage,
		onSuccess: function(ajax)
		{
			document.getElementById('type').update(ajax.responseText);
		}
	});
}



// affiche vignette de la page on_line
function vignette_online(site)
{	
	document.getElementById(site).style.display = 'block';
	
	//si click sur smiley mécontent, le rendre non visible
	if(site == "homePlus")
	{		
		document.getElementById("puce_triste").style.display = 'none';
	}
}
function vignette_offline(site){
	
	document.getElementById(site).style.display = "none";
}

function affichDiv(photo)
{
	if(photo.style.display == 'block') {photo.style.display ='none'}
	else {photo.style.display ='block'}
}


// Afficher ou cacher le contact msn
function affContact(id)
{
	if(document.getElementById(id).style.display == "none") document.getElementById(id).style.display = "block";
	else document.getElementById(id).style.display = "none";
}


// Afficher ou cacher un block
function affMenu(ul)
{
	ul.getElementsByTagName("ul")[0].style.display = "block";
	ul.className = "hoverBO";
	//ul.style.backgroundColor = "#ff6600";
}

function closeMenu(ul)
{
	ul.getElementsByTagName("ul")[0].style.display = "none";
	ul.style.backgroundColor = ""; 
}

function affPhoto(id)
{
	for(i=1;i<=3;i++)
	{
		document.getElementById("photo" + i).style.display = "none";
	}
	
	document.getElementById("photo" + id).style.filter = "alpha(opacity=0)";
	document.getElementById("photo" + id).style.opacity = "0";
	document.getElementById("photo" + id).style.display = "inline";
	opacitePhoto(id,0)
}

function opacitePhoto(id,num)
{
	if(num != 100)
	{
		document.getElementById("photo" + id).style.filter = "alpha(opacity=" + num + ")";
		document.getElementById("photo" + id).style.opacity = num / 100;
		num++;
		setTimeout("opacitePhoto('" + id + "','" + num + "')",20);
	}
}
