
var menuAssagenti = {
        "btn_assagenti": [
        {"menuLbl": "Circolari", "menuLnk": "http://www.assagenti.it/index.php/viewcircolari","target":""},
        {"menuLbl": "Elenco soci", "menuLnk": "http://www.assagenti.it/index.php/associati","target":""},
        {"menuLbl": "Leggi", "menuLnk": "http://www.assagenti.it/index.php/leggi","target":""},        
        {"menuLbl": "Tariffe e servizi", "menuLnk": "http://www.assagenti.it/index.php/tariffeservizi","target":""},
        {"menuLbl": "Attivit&agrave;", "menuLnk": "http://www.assagenti.it/index.php/attivita","target":""},
        {"menuLbl": "Formazione", "menuLnk": "http://www.assagenti.it/index.php/corsi","target":""}
    ],
        "btn_giovani": [
        {"menuLbl": "Comitato direttivo", "menuLnk": "http://www.assagenti.it/index.php/gconsiglio","target":""},
        {"menuLbl": "Membri", "menuLnk": "http://www.assagenti.it/index.php/gassociati","target":""},
        {"menuLbl": "Regolamento", "menuLnk": "http://www.assagenti.it/index.php/regolamento","target":""},
        {"menuLbl": "Seminari/Incontri", "menuLnk": "http://www.assagenti.it/index.php/seminari","target":""},
        {"menuLbl": "Iscriviti", "menuLnk": "http://www.assagenti.it/index.php/iscrizione","target":""},
        {"menuLbl": "Contattaci", "menuLnk": "http://www.assagenti.it/index.php/contattaci","target":""}
    ],
        "btn_press": [
        {"menuLbl": "Assagenti News", "menuLnk": "http://www.assagenti.it/index.php/assanew","target":""},
        {"menuLbl": "Comunicati stampa", "menuLnk": "http://www.assagenti.it/index.php/comunicati","target":""},
        {"menuLbl": "Dicono di noi", "menuLnk": "http://www.assagenti.it/index.php/rassegne","target":""},
        {"menuLbl": "Rassegna stampa", "menuLnk": "http://www.ecostampa.it/Servizi/RasClienti/Certif/CertifUte.asp","target":""},
        {"menuLbl": "Media", "menuLnk": "http://www.assagenti.it/index.php/media","target":""},
        {"menuLbl": "&nbsp;", "menuLnk": "#","target":""}
    ],
        "btn_about": [
        {"menuLbl": "Consiglio", "menuLnk": "http://www.assagenti.it/index.php/consiglio","target":""},
        {"menuLbl": "Commissioni", "menuLnk": "http://www.assagenti.it/index.php/commissioni","target":""},
        {"menuLbl": "Segreteria", "menuLnk": "http://www.assagenti.it/index.php/segreteria","target":""},
        /*{"menuLbl":"Statuto","menuLnk":"http://www.assagenti.it/index.php/statuto"},*/
        {"menuLbl":"Statuto","menuLnk":"http://www.assagenti.it/statuto/index.html","target":'_new'},
        {"menuLbl":"Assemblea","menuLnk":"http://www.assagenti.it/index.php/assemblea","target":""}        
    ]
};

function pop_menu(id_menu,label_menu,target){
    target = target || "";
    if (id_menu == ''){
        $('menu').hide('fast');
        return;
    }
    if(id_menu == 'btn_job' || id_menu == 'btn_home') {
         $('#menu').hide('fast');
         return;
    }
    
    
    
    tmpHtml = '<ul class="menu_list" id="nav_chisiamo"><li>&nbsp;</li>';
    for (sub in menuAssagenti[id_menu]){
        if (menuAssagenti[id_menu][sub].menuLbl == '&nbsp;'){
            tmpHtml += '<br />';
            continue;
        }
        
        tmpHtml += "<li><a class='lnk menuLnk' target='"+menuAssagenti[id_menu][sub].target+"' href='"+menuAssagenti[id_menu][sub].menuLnk+"'>"+menuAssagenti[id_menu][sub].menuLbl+"</a></li>";
    }
    tmpHtml += '</ul>';
    $('#menu').html(tmpHtml);
    

    offs = $("#" + id_menu).offset();   
    var toppa = offs.top;
    var leftta = offs.left;    
    $('#menu')[0].style.left = (leftta -7) + "px";
    $('#menu')[0].style.top = (toppa + 45 ) + "px";
    $('#menu').show('fast');
    
    $('#menu').mouseout(
        function (e) {
            var targ = (e.relatedTarget) ? e.relatedTarget : e.toElement;           
            if ((targ.nodeName != 'LI' && targ.nodeName != 'A')  || targ.id == id_menu){
                 $('#menu').hide('fast');
            }
        }
    );
    
}

function showCommissione(id_commi){
    $('.commiOpen').hide("fast");
    if ($(".commiOpen:visible").attr("id") == "comm_"+id_commi) return;
    $('#comm_'+id_commi).show("slow");
}

function showSoci(id_socio){    
    if ($(".assoOpen:visible").attr("id") == "asso_"+id_socio){
        $('.assoOpen:visible').hide("slow");
        return;
    }
    else{
        $('.assoOpen:visible').hide("fast");
        $('#asso_'+id_socio).show("slow");
        return;
    }
}

function closePop(){

        $('#modalDivPlugin').remove(); $(".modalmeSelector").css("display","none"); $("body").css("overflow","auto"); 
        
}

(function( $ ){
  $.fn.modalme = function(id_circolare) {
       
        return this.each(function() {                
                var $this = $(this);                
                if (!$('#modalDivPlugin')[0]){                        
                        jQuery('<div />', {  
                                id: 'modalDivPlugin',                                  
                                style: 'background-color:#003366;height:100%;width:100%;position:absolute;top:0px;z-index:3000'    
                            }).fadeTo("slow", 0.33).appendTo('body');
                        $("body").css("overflow","hidden");
                        $this.css("position","absolute");
                        $this.css("z-index","5000");
                        $this.addClass("modalmeSelector");
                        $this.css("top","50%");
                        $this.css("left","50%");
                        $this.css("z-index","5000");
                        
                        var oriWidth = $this.css("width");
                        var oriHeight = $this.css("height");
                        
                        $this.css("height","10px");
                        $this.css("width","10px");
                        
                        $.post("http://www.assagenti.it/ajax/viewAttachments.php", { id: id_circolare },function (data){ $this.html(data) } );
                        
                        $('#modalDivPlugin').click(function () { $('#modalDivPlugin').remove(); $this.css("display","none"); $("body").css("overflow","auto"); });
                        
                        
                        
                        var marginTop = parseInt(oriHeight.replace("px","")) / 2 * -1;
                        $this[0].style.marginTop = marginTop+"px";
                        
                        var marginLeft = parseInt(oriWidth.replace("px","")) / 2 * -1;
                        $this[0].style.marginLeft = marginLeft+"px";                    
                        
                        $this.animate({ width:oriWidth, height:oriHeight },"slow").appendTo('body');
                        
                }
        });

  };
})( jQuery );




