jQbobbio = {}; 

// apertura finestre

jQbobbio.Apri = {
    build   : function(options)
    {
    	
    	var _options = jQuery.extend({
    	   message     : "Attenzione: questo link si apre in una nuova finestra",
	       toolbar     : "no",
           location    : "no",
           directories : "no",
           status      : "no",
           menuBar     : "no",
           scrollbars  : "yes",
           resizable   : "yes",
           width       : 400,
           height      : 300,
           top         : false,
           left        : false,
           screenX     : false,
           screenY     : false
    	}, options);
    	
        return this.each(function(nr){
                var _prop = '';
                for (_option in _options)
                    if (_options[_option])
                        _prop += _option + "=" + _options[_option] + ",";
                
                var that = this;
                var _j = jQuery(that);
                var _t = _j.attr("title") ? _j.attr("title") : _j.text();  
                _j.attr("title", _t + " - " + _options.message);

			    var _href = _j.attr("href");
			    _j.click(function () {window.open(_href, '_blank', _prop); return false;});
         });
    }
};
   
jQuery.fn.apri = jQbobbio.Apri.build;

// autoload

jQuery(document).ready(function(){
	jQuery("a.esterno").apri({toolbar : "yes", location : "yes", directories : "yes", status : "yes", menuBar : "yes", scrollbars : "yes", resizable : "yes", width : 800, height : 600, top : 0, left : 0});
	jQuery("a.pdf").apri({message: "Attenzione: questo link scarica un file pdf e si apre in una nuova finestra", location : "yes", scrollbars : "no", resizable : "no", width : 800, height : 600});
	jQuery("a.xls").apri({message: "Attenzione: questo link scarica un file excel e si apre in una nuova finestra", location : "yes", scrollbars : "no", resizable : "no", width : 800, height : 600});
	jQuery("a.ppt").apri({message: "Attenzione: questo link scarica un file powerpoint e si apre in una nuova finestra", location : "yes", scrollbars : "no", resizable : "no", width : 800, height : 600});
	jQuery("a.doc").apri({message: "Attenzione: questo link scarica un file word e si apre in una nuova finestra", location : "yes", scrollbars : "no", resizable : "no", width : 800, height : 600});
	jQuery("a.zip").apri({message: "Attenzione: questo link scarica un file compresso e si apre in una nuova finestra", location : "yes", scrollbars : "no", resizable : "no", width : 800, height : 600});	
});

// overlay

jQuery(document).ready(function(){
    jQuery("#elenco_iniziative").find("h2 > a").hover(
        function(){
            jQuery(this).parent().parent().addClass("over");
        },
        function(){
            jQuery(this).parent().parent().removeClass("over");
        }
    );
});

jQuery(document).ready(function(){
    jQuery("ul.menu_in").find("li > a").hover(
        function(){
            jQuery(this).parent().addClass("over");
        },
        function(){
            jQuery(this).parent().removeClass("over");
        }
    );
});

// visualizza / nascondi

jQuery(document).ready(function(){
    jQuery("div.box_content").each(function(nr){

        var _id = nr + 1;
        //jQuery(this).before('<div class="link_close"><a href="#box_content_'+_id+'">visualizza approfondimenti</a></div>');
        jQuery(this).before('<div class="link_close"><a id="box_link_'+_id+'" href="#box_link_'+_id+'">visualizza approfondimenti</a></div>');
        jQuery(this).attr("id", "box_content_" + _id);
        jQuery(this).parent().find("a").eq(0).click(function(){
            var _target = jQuery(this).parent().parent().find("div.box_content").toggle();
            if(_target.css("display") == "none"){
                jQuery(this).text("visualizza approfondimenti").removeClass("close").addClass("open");
            }else{
                jQuery(this).text("nascondi approfondimenti").removeClass("open").addClass("close");
            }
            
            return false;//
        }).trigger("click");
    });
});

