
jQuery(document).ready( function() {

    //read th value of the cookie
    monId=LireCookie("vmenu");
    $(".elementmenu").hide(); 
	$(".widget_sidebarlogin h3").css("text-decoration","none");
	$(".widget_navt h3").css("text-decoration","none");
    
    if(monId!=null){
        $("#"+monId).show();         
        $("#"+monId).prev().css("text-decoration","underline"); 
        }
        
		
		
		
	$(".widget_navt h3").hover(function(){
		$(this).css("text-decoration","underline");
	},function(){
		if($(this).next().attr("id")!=LireCookie("vmenu"))
			$(this).css("text-decoration","none");
	});

	$(".widget_sidebarlogin h3").hover(function(){
		$(this).css("text-decoration","underline");
	},function(){
		if($(this).next().attr("id")!=LireCookie("vmenu"))
			$(this).css("text-decoration","none");
	});

    //on clic on the title
    jQuery(".widget_navt h3").click(function() {

        //get the id of the title
        var monId=$(this).next().attr("id");
        
        if(monId!=LireCookie("vmenu")){
            EcrireCookie("vmenu",monId, null, "/");
            $(".elementmenu").slideUp(); 
            $("#"+monId).slideDown();
			$(".widget_sidebarlogin h3").css("text-decoration","none");
			$(".widget_navt h3").css("text-decoration","none");
			$(this).css("text-decoration","underline"); 
        }else{
            $("#"+monId).slideUp();
            EcrireCookie("vmenu",null, null, "/");
			$(this).css("text-decoration","none"); 
        }
    });
	
	    jQuery(".widget_sidebarlogin h3").click(function() {

        //get the id of the title
        var monId=$(this).next().attr("id");
        
        if(monId!=LireCookie("vmenu")){
            EcrireCookie("vmenu",monId, null, "/");
            $(".elementmenu").slideUp(); 
            $("#"+monId).slideDown();
			$(".widget_sidebarlogin h3").css("text-decoration","none");
			$(".widget_navt h3").css("text-decoration","none");
			$(this).css("text-decoration","underline"); 
        }else{
            $("#"+monId).slideUp();
            EcrireCookie("vmenu",null, null, "/");
			$(this).css("text-decoration","none"); 
        }
    });
	
	
	
	
	
	
	
	
});


function EcrireCookie(nom, valeur)
{
var argv=EcrireCookie.arguments;
var argc=EcrireCookie.arguments.length;
var expires=(argc > 2) ? argv[2] : null;
var path=(argc > 3) ? argv[3] : null;
var domain=(argc > 4) ? argv[4] : null;
var secure=(argc > 5) ? argv[5] : false;
document.cookie=nom+"="+escape(valeur)+
((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
((path==null) ? "" : ("; path="+path))+
((domain==null) ? "" : ("; domain="+domain))+
((secure==true) ? "; secure" : "");
}


function getCookieVal(offset)
{
var endstr=document.cookie.indexOf (";", offset);
if (endstr==-1) endstr=document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}


function LireCookie(nom)
{
var arg=nom+"=";
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while (i<clen)
{
var j=i+alen;
if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
i=document.cookie.indexOf(" ",i)+1;
if (i==0) break;

}
return null;
}
