var totalRubriques = 8;
		
function showMenu(sId, rubrique_courante) {
	
	aId = sId.split("_");
	id = aId[1];
	for(var i = 1 ; i <= totalRubriques ; i++) {
		
		var menu = document.getElementById('rubrique_' + i);
		if(menu && menu.className == 'niveau_un_courant' && rubrique_courante && rubrique_courante != i) {
			menu.className = 'niveau_un';
		}

		var sousmenu = getSubElements('liste_sous_rubriques_conteneur', 'div', document.getElementById('rubrique_' + i));
		if(sousmenu) {
			sousmenu.style.display = 'none';
		}
		
	}

	var menu = document.getElementById('rubrique_' + id);
	if(menu && menu.className == 'niveau_un') {
		menu.className = 'niveau_un_courant';
	}
	
	var sousmenu = getSubElements('liste_sous_rubriques_conteneur', 'div', document.getElementById('rubrique_' + id));
	if(sousmenu) {
		sousmenu.style.display = 'block';
	}
}

function hideMenu(rubrique_courante) {
	for(var i = 1 ; i <= totalRubriques ; i++) {	
		
		var menu = document.getElementById('rubrique_' + i);
		if(menu && menu.className == 'niveau_un_courant' && rubrique_courante && rubrique_courante != i) {
			menu.className = 'niveau_un';
		}

		var sousmenu = getSubElements('liste_sous_rubriques_conteneur', 'div', document.getElementById('rubrique_' + i));
		if(sousmenu) {
			sousmenu.style.display = 'none';
		}
		
	}
}

function getSubElements(className, tag, elm){
	
	var testClass = new RegExp("(^|s)" + className + "(s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i ];
		if(testClass.test(current.className)){
			return current;
		}
	}
	return false;
}




function afficheCommentairePopup() {

    return affichePopup('conteneur_popup_commentaire_post');
}

function affichePopup(div) {

    var myWidth = 0, myHeight = 0;
    document.documentElement.style.overflow    = "hidden";
    document.body.style.overflow               = "hidden";
    if( typeof( window.innerWidth ) == 'number' ) {

        //Non-IE
        myWidth    = window.innerWidth;
        myHeight   = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {

        //IE 6+ in 'standards compliant mode'
        myWidth    = document.documentElement.clientWidth;
        myHeight   = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {

        //IE 4 compatible
        myWidth    = document.body.clientWidth;
        myHeight   = document.body.clientHeight;
    }
    document.getElementById(div).style.height   = myHeight +  'px';
    document.getElementById(div).style.width    = myWidth + 'px';
    document.getElementById(div).style.display  = 'block'; 
    return false;
}


function cachePopup(div) {

    document.documentElement.style.overflow = "auto";
    document.body.style.overflow = "auto";
	document.getElementById(div).style.display = 'none'; 
	return false;
}


jQuery().ready(function(){
	 // add a "rel" attrib if Opera 7+
    if(window.opera) {
        if (jQuery("a.jqbookmark").attr("rel") != ""){ // don't overwrite the rel attrib if already set
        	jQuery("a.jqbookmark").attr("rel","sidebar");
        }
    }
   
    jQuery("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('Ville de Chennevieres sur Marne', window.location ,"");
        } else if( window.external ) { // IE Favorite
            window.external.AddFavorite( window.location, 'Ville de Chennevieres sur Marne');
        } 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('Unfortunately, this browser does not support the requested action, please bookmark this page manually.');
        }
    });	
});