/* 
 * $Date: 2009-07-24 11:23:24 +0200 (ven, 24 lug 2009) $
 * $Rev: 138 $
 */

////////////////////////////////////////////////////////////////////////////////
//========== COOKIE =======================================================
////////////////////////////////////////////////////////////////////////////////

/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.noConflict();

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

 
////////////////////////////////////////////////////////////////////////////////
//*********** JQUERY METADATA **************************************************
////////////////////////////////////////////////////////////////////////////////

/*
 * Metadata - jQuery plugin for parsing metadata from elements
 *
 * Copyright (c) 2006 John Resig, Yehuda Katz, Jï¿½Ã¶rn Zaefferer, Paul McLanahan
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id$
 *
 */

/**
 * Sets the type of metadata to use. Metadata is encoded in JSON, and each property
 * in the JSON will become a property of the element itself.
 *
 * There are three supported types of metadata storage:
 *
 *   attr:  Inside an attribute. The name parameter indicates *which* attribute.
 *          
 *   class: Inside the class attribute, wrapped in curly braces: { }
 *   
 *   elem:  Inside a child element (e.g. a script tag). The
 *          name parameter indicates *which* element.
 *          
 * The metadata for an element is loaded the first time the element is accessed via jQuery.
 *
 * As a result, you can define the metadata type, use $(expr) to load the metadata into the elements
 * matched by expr, then redefine the metadata type and run another $(expr) for other elements.
 * 
 * @name $.metadata.setType
 *
 * @example <p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p>
 * @before $.metadata.setType("class")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from the class attribute
 * 
 * @example <p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p>
 * @before $.metadata.setType("attr", "data")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from a "data" attribute
 * 
 * @example <p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>
 * @before $.metadata.setType("elem", "script")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from a nested script element
 * 
 * @param String type The encoding type
 * @param String name The name of the attribute to be used to get metadata (optional)
 * @cat Plugins/Metadata
 * @descr Sets the type of encoding to be used when loading metadata for the first time
 * @type undefined
 * @see metadata()
 */

(function($) {

$.extend({
	metadata : {
		defaults : {
			type: 'class',
			name: 'metadata',
			cre: /({.*})/,
			single: 'metadata'
		},
		setType: function( type, name ){
			this.defaults.type = type;
			this.defaults.name = name;
		},
		get: function( elem, opts ){
			var settings = $.extend({},this.defaults,opts);
			// check for empty string in single property
			if ( !settings.single.length ) settings.single = 'metadata';
			
			var data = $.data(elem, settings.single);
			// returned cached data if it already exists
			if ( data ) return data;
			
			data = "{}";
			
			if ( settings.type == "class" ) {
				var m = settings.cre.exec( elem.className );
				if ( m )
					data = m[1];
			} else if ( settings.type == "elem" ) {
				if( !elem.getElementsByTagName )
					return undefined;
				var e = elem.getElementsByTagName(settings.name);
				if ( e.length )
					data = $.trim(e[0].innerHTML);
			} else if ( elem.getAttribute != undefined ) {
				var attr = elem.getAttribute( settings.name );
				if ( attr )
					data = attr;
			}
			
			if ( data.indexOf( '{' ) <0 )
			data = "{" + data + "}";
			
			data = eval("(" + data + ")");
			
			$.data( elem, settings.single, data );
			return data;
		}
	}
});

/**
 * Returns the metadata object for the first member of the jQuery object.
 *
 * @name metadata
 * @descr Returns element's metadata object
 * @param Object opts An object contianing settings to override the defaults
 * @type jQuery
 * @cat Plugins/Metadata
 */
$.fn.metadata = function( opts ){
	return $.metadata.get( this[0], opts );
};

})(jQuery);



/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate:2008-11-04 11:51:37 +0100 (mar, 04 nov 2008) $
 * $Rev:259 $
 *
 * Version 2.1
 */

(function($){

/**
 * The bgiframe is chainable and applies the iframe hack to get 
 * around zIndex issues in IE6. It will only apply itself in IE 
 * and adds a class to the iframe called 'bgiframe'. The iframe
 * is appeneded as the first child of the matched element(s) 
 * with a tabIndex and zIndex of -1.
 * 
 * By default the plugin will take borders, sized with pixel units,
 * into account. If a different unit is used for the border's width,
 * then you will need to use the top and left settings as explained below.
 *
 * NOTICE: This plugin has been reported to cause perfromance problems
 * when used on elements that change properties (like width, height and
 * opacity) a lot in IE6. Most of these problems have been caused by 
 * the expressions used to calculate the elements width, height and 
 * borders. Some have reported it is due to the opacity filter. All 
 * these settings can be changed if needed as explained below.
 *
 * @example $('div').bgiframe();
 * @before <div><p>Paragraph</p></div>
 * @result <div><iframe class="bgiframe".../><p>Paragraph</p></div>
 *
 * @param Map settings Optional settings to configure the iframe.
 * @option String|Number top The iframe must be offset to the top
 *      by the width of the top border. This should be a negative 
 *      number representing the border-top-width. If a number is 
 *      is used here, pixels will be assumed. Otherwise, be sure
 *      to specify a unit. An expression could also be used. 
 *      By default the value is "auto" which will use an expression 
 *      to get the border-top-width if it is in pixels.
 * @option String|Number left The iframe must be offset to the left
 *      by the width of the left border. This should be a negative 
 *      number representing the border-left-width. If a number is 
 *      is used here, pixels will be assumed. Otherwise, be sure
 *      to specify a unit. An expression could also be used. 
 *      By default the value is "auto" which will use an expression 
 *      to get the border-left-width if it is in pixels.
 * @option String|Number width This is the width of the iframe. If
 *      a number is used here, pixels will be assume. Otherwise, be sure
 *      to specify a unit. An experssion could also be used.
 *      By default the value is "auto" which will use an experssion
 *      to get the offsetWidth.
 * @option String|Number height This is the height of the iframe. If
 *      a number is used here, pixels will be assume. Otherwise, be sure
 *      to specify a unit. An experssion could also be used.
 *      By default the value is "auto" which will use an experssion
 *      to get the offsetHeight.
 * @option Boolean opacity This is a boolean representing whether or not
 *      to use opacity. If set to true, the opacity of 0 is applied. If
 *      set to false, the opacity filter is not applied. Default: true.
 * @option String src This setting is provided so that one could change 
 *      the src of the iframe to whatever they need.
 *      Default: "javascript:false;"
 *
 * @name bgiframe
 * @type jQuery
 * @cat Plugins/bgiframe
 * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 */
$.fn.bgIframe = $.fn.bgiframe = function(s) {
    // This is only for IE6
    if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) {
        s = $.extend({
            top     : 'auto', // auto == .currentStyle.borderTopWidth
            left    : 'auto', // auto == .currentStyle.borderLeftWidth
            width   : 'auto', // auto == offsetWidth
            height  : 'auto', // auto == offsetHeight
            opacity : true,
            src     : 'javascript:false;'
        }, s || {});
        var prop = function(n){return n&&n.constructor==Number?n+'px':n;},
            html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+
                       'style="display:block;position:absolute;z-index:-1;'+
                           (s.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+
                           'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+
                           'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+
                           'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+
                           'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+
                    '"/>';
        //alert(html);
        return this.each(function() {
            
            if ( $('> iframe.bgiframe', this).length == 0 )
                this.insertBefore( document.createElement(html), this.firstChild );
        });
    }
    return this;
};

})(jQuery);

/*
 * Copyright (c) 2009 Massimiliano Balestrieri
 * 
 * $Date:2008-11-04 11:51:37 +0100 (mar, 04 nov 2008) $
 * $Rev:259 $
 * @requires jQuery v1.3.2
 * 
 * Copyright (c) 2008 Massimiliano Balestrieri
 * Examples and docs at: http://maxb.net/blog/
 * Licensed GPL licenses:
 * http://www.gnu.org/licenses/gpl.html
 */
 
 
jQCss = {}; 

(function($){
////////////////////////////////////////////////////////////////////////////////
//========== CARICAMENTO CSS ===================================================
////////////////////////////////////////////////////////////////////////////////


jQCss.Css = {
    load   : function(options){
    	if(options.constructor === String)
    		var _options = {url : options, media : "screen"};
    	else
    		var _options = $.extend({media : "screen"}, options);
    	
    	$('head').append('<link type="text/css" href="'+_options.url+'" rel="stylesheet" media="'+_options.media+'" />'); 
    }
};

$.fn.loadcss = jQCss.Css.load;

//carica il css dei nifty corners. SUBITO
$("window").loadcss('/ris/css/generaliV3/jquery/niftyCorners.css');
$("window").loadcss('/ris/css/generaliV3/jquery/tooltip_errore.css');


//ESEMPI
// jQuery("window").loadcss('include/nifty-demo.css');
// jQuery("window").loadcss('../plugins/nifty/0.9/nifty.css');
// jQuery("window").loadcss({url : 'css.css', media : 'print'});

})(jQuery);

/*
 * Copyright (c) 2009 Massimiliano Balestrieri
 * 
 * $Date:2008-11-04 11:51:37 +0100 (mar, 04 nov 2008) $
 * $Rev:259 $
 * @requires jQuery v1.3.2
 * 
 * Copyright (c) 2008 Massimiliano Balestrieri
 * Examples and docs at: http://maxb.net/blog/
 * Licensed GPL licenses:
 * http://www.gnu.org/licenses/gpl.html
 */

(function($){
	
jQApri = {}; 

////////////////////////////////////////////////////////////////////////////////
//========== APERTURA FINESTRE =================================================
////////////////////////////////////////////////////////////////////////////////

jQApri.Apri = {
    build   : function(options)
    {
    	
    	var _options = $.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 = $(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;});
         });
    }
};
   
$.fn.apri = jQApri.Apri.build;

////////////////////////////////////////////////////////////////////////////////
//*********** AUTOLOAD *********************************************************
////////////////////////////////////////////////////////////////////////////////


$(document).ready(function(){
    $("a.apri").apri({toolbar : "yes", location : "yes", directories : "yes", status : "yes", menuBar : "yes", scrollbars : "yes", resizable : "yes", width : 800, height : 600, top : 0, left : 0});
    $("a.apricontatti").apri({scrollbars : "no", resizable : "no", width : 510, height : 260});
    $("a.aprihelp").apri({scrollbars : "yes", resizable : "no", width : 790, height : 480});
    $("a.aprihelpwin").apri({width : 790, height : 570, top : 0, left : 0});
    $("a.apricredits").apri({width : 600, height : 250, top : 0, left : 0});
    $("a.apriglossario").apri({width : 790, height : 570, top : 0, left : 0});
    $("a.aprifaq").apri({width : 790, height : 570, top : 0, left : 0});
	$("a.apriinfo").apri({scrollbars : "yes", resizable : "no", width : 790, height : 500});
	$("a.apricerca").apri({scrollbars : "yes", resizable : "no", width : 790, height : 580});
	
	$("area.apriavviso").apri({scrollbars : "no", resizable : "no", width : 510, height : 260});
    $("area.apripagina").apri({toolbar : "yes", location : "yes", directories : "yes", status : "yes", menuBar : "yes", scrollbars : "yes", resizable : "yes", width : 800, height : 600, top : 0, left : 0});
	$("area.apriaccessi").apri({scrollbars : "no", resizable : "no", width : 510, height : 260});

	$("a.apripresentazioneITA").apri({scrollbars : "no", resizable : "no", width : 1170, height : 650,message: "il link si apre su una nuova finestra"});
	$("a.apripresentazioneUK").apri({scrollbars : "no", resizable : "no", width : 1170, height : 650,message: "il link si apre su una nuova finestra"});
	$("a.apripresentazioneFR").apri({scrollbars : "no", resizable : "no", width : 1170, height : 650,message: "il link si apre su una nuova finestra"});
	$("a.apripresentazioneRO").apri({scrollbars : "no", resizable : "no", width : 1170, height : 650,message: "atentie acest link se deschide intr-o noua fereastra"});
	$("a.apripresentazioneESP").apri({scrollbars : "no", resizable : "no", width : 1170, height : 650,message: "il link si apre su una nuova finestra"});
	$("a.apripresentazioneAR").apri({scrollbars : "no", resizable : "no", width : 1170, height : 650,message: "il link si apre su una nuova finestra"});

});

})(jQuery);


(function($){

jQMenu = {};

////////////////////////////////////////////////////////////////////////////////
//========== MENU ==============================================================
////////////////////////////////////////////////////////////////////////////////


jQMenu.MMenu = {
	build: function(options){
		
		var _options = $.extend({
			target : "div.submenu, ul.submenu"	
		}, options);
		
		var _handlers = $(".menu");
		_handlers
		.click(function(){
			var _hid = this.id;
			var _id = _hid.split("-")[1];
				$("#submenu-"+_id).toggle();
			return false;
		});
		
		return this.each(function(){ 
			
			var that = this;
			
			var _jtarget = $(_options.target);
			
			var _hid = this.id;
			var _id = _hid.split("-")[1];
			
			var _jhandler = $("#menu-"+_id);
			var _c = $(_jhandler).attr("class");
			var _c1 = _c.split(" ")[0];//0 o 1
			
			if(_c1.indexOf("open") !== -1)
				_jtarget.show();
			else	
				_jtarget.hide();
			
			
		});
		
		
	}
};

$.fn.mmenu = jQMenu.MMenu.build;

////////////////////////////////////////////////////////////////////////////////
//*********** AUTOLOAD *********************************************************
////////////////////////////////////////////////////////////////////////////////

$(document).ready(function(){
	$(".submenu").mmenu();
});

})(jQuery);

(function($) {
	
////////////////////////////////////////////////////////////////////////////////
//========== NIFTY CORNERS =====================================================
////////////////////////////////////////////////////////////////////////////////

/* Nifty for jQuery is a modified and optimized version of Nifty Corners Cube.
 * The new one has been programmed by Paul Bakaus (paul.bakaus@gmail.com), read below
 * for further copyright information.
 */

/* Nifty Corners Cube - rounded corners with CSS and Javascript
Copyright 2006 Alessandro Fulciniti (a.fulciniti@html.it)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

var Nifty = function(options){

	if((document.getElementById && document.createElement && Array.prototype.push) == false) return;
	options = options || "";
	h = (options.indexOf("fixed-height") >= 0) ? this.offsetHeight : 0;
	this.each(function(){ 
		var i,top="",bottom="";
		if(options != ""){
		    options=options.replace("left","tl bl");
		    options=options.replace("right","tr br");
		    options=options.replace("top","tr tl");
		    options=options.replace("bottom","br bl");
		    options=options.replace("transparent","alias");
		    if(options.indexOf("tl") >= 0) { top="both"; if(options.indexOf("tr") == -1) top="left"; } else if(options.indexOf("tr") >= 0) top="right";
		    if(options.indexOf("bl") >= 0) { bottom="both"; if(options.indexOf("br") == -1) bottom="left"; } else if(options.indexOf("br") >= 0) bottom="right";
		}
		if(top=="" && bottom=="" && options.indexOf("none") == -1){top="both";bottom="both";}
		
	    // IE Fix
		if(this.currentStyle!=null && this.currentStyle.hasLayout!=null && this.currentStyle.hasLayout==false)
    		$(this).css("display","inline-block");
			
	    if(top!="") {
	    	//add top		
			var d=document.createElement("b"),lim=4,border="",p,i,btype="r",bk,color;
			$(d).css("marginLeft","-"+_niftyGP(this,"Left")+"px");
			$(d).css("marginRight","-"+_niftyGP(this,"Right")+"px");
			if(options.indexOf("alias") >= 0 || (color=_niftyBC(this))=="transparent"){
			    color="transparent";bk="transparent"; border=_niftyPBC(this);btype="t";
			    }
			else{
			    bk=_niftyPBC(this); border=_niftyMix(color,bk);
			    }
			$(d).css("background",bk);
			d.className="niftycorners";
			p=_niftyGP(this,"Top");
			if(options.indexOf("small") >= 0){
				$(d).css("marginBottom",(p-2)+"px");
			    btype+="s"; lim=2;
			    }
			else if(options.indexOf("big") >= 0){
			    $(d).css("marginBottom",(p-10)+"px");
			    btype+="b"; lim=8;
			    }
			else $(d).css("marginBottom",(p-5)+"px");
			for(i=1;i<=lim;i++)
			    $(d).append(CreateStrip(i,top,color,border,btype));
			$(this).css("paddingTop", "0px");
			$(this).prepend(d);				
		}
	    if(bottom!="") {
			//add bottom
			var d=document.createElement("b"),lim=4,border="",p,i,btype="r",bk,color;
			$(d).css("marginLeft","-"+_niftyGP(this,"Left")+"px");
			$(d).css("marginRight","-"+_niftyGP(this,"Right")+"px");
			if(options.indexOf("alias") >= 0 || (color=_niftyBC(this))=="transparent"){ color="transparent";bk="transparent"; border=_niftyPBC(this);btype="t"; } else { bk=_niftyPBC(this); border=_niftyMix(color,bk); }
			$(d).css("background",bk);
			d.className="niftycorners";
			p=_niftyGP(this,"Bottom");
			if(options.indexOf("small") >= 0){
			    $(d).css("marginTop",(p-2)+"px");
			    btype+="s"; lim=2;
			    }
			else if(options.indexOf("big") >= 0){
			    $(d).css("marginTop",(p-10)+"px");
			    btype+="b"; lim=8;
			    }
			else $(d).css("marginTop",(p-5)+"px");
			for(i=lim;i>0;i--)
			    $(d).append(CreateStrip(i,bottom,color,border,btype));
			$(this).css("paddingBottom", "0");
			$(this).append(d);			
		};
	});
   
	if(options.indexOf("height") >= 0)
	{		
		this.each(function(){
	    	if(this.offsetHeight>h) h=this.offsetHeight;
	    	$(this).css("height", "auto");
	
	    	var gap=h-this.offsetHeight;
	    	if(gap>0)
			{
	        	var t=document.createElement("b");t.className="niftyfill";$(t).css("height",gap+"px");
	        	nc=this.lastChild;
	        	nc.className=="niftycorners" ? this.insertBefore(t,nc) : $(this).append(t);
	    	}		
		});
	}
	
	
    function CreateStrip(index,side,color,border,btype){
    	var x=document.createElement("b");
    	x.className=btype+index;
    	$(x).css("backgroundColor", color).css("borderColor", border);
    	if(side=="left") $(x).css("borderRightWidth", "0").css("marginRight", "0");
    	else if(side=="right") $(x).css("borderLeftWidth", "0").css("marginLeft", "0");
    	return(x);
    }
    
    function _niftyPBC(x){
    	var el=x.parentNode,c;
    	while(el.tagName.toUpperCase()!="HTML" && (c=_niftyBC(el))=="transparent")
    	    el=el.parentNode;
    	if(c=="transparent") c="#FFFFFF";
    	return(c);
    }
    
    function _niftyBC(x){
    	var c=$(x).css("backgroundColor");
    	if(c==null || c=="transparent" || c.indexOf("rgba(0, 0, 0, 0)") >= 0) return("transparent");
    	if(c.indexOf("rgb") >= 0) {
    		var hex="";
    		var regexp=/([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/;
    		var h=regexp.exec(c);
    		for(var i=1;i<4;i++){
    		    var v=parseInt(h[i]).toString(16);
    		    if(v.length==1) hex+="0"+v; else hex+=v;
    		}
    		c = "#"+hex;	
    	}
    	return(c);
    }
    
    function _niftyGP(x,side){
    	var p=$(x).css("padding"+side);
    	if(p==null || p.indexOf("px") == -1) return(0);
    	return(parseInt(p));
    }
    
    function _niftyMix(c1,c2){
    	var i,step1,step2,x,y,r=new Array(3);
    	c1.length==4 ? step1=1 : step1=2;
    	c2.length==4 ? step2=1 : step2=2;
    	for(i=0;i<3;i++){
    	    x=parseInt(c1.substr(1+step1*i,step1),16);
    	    if(step1==1) x=16*x+x;
    	    y=parseInt(c2.substr(1+step2*i,step2),16);
    	    if(step2==1) y=16*y+y;
    	    r[i]=Math.floor((x*50+y*50)/100);
    	    r[i]=r[i].toString(16);
    	    if(r[i].length==1) r[i]="0"+r[i];
    	}
    	return("#"+r[0]+r[1]+r[2]);
    }
	
};

$.fn.nifty = Nifty;

////////////////////////////////////////////////////////////////////////////////
//*********** AUTOLOAD *********************************************************
////////////////////////////////////////////////////////////////////////////////


$(document).ready(function() {
	
	if(!($.browser.msie && $.browser.version == 5)){
	 	$("#colonnaDestra").find("h3.primo").nifty("small");
	 	$("#colonna > h3").nifty("small");
	 	$("#colonna > h4").nifty("small");
	 	$("#colonnaCont > h3").nifty("small");
	 	$("#colonnaDestra > h3").nifty("small");
	 	$("#colonnaDestra > h4").nifty("small");
	 	$("div#infoConth").nifty("small");
	 	$("div#nav > h3").nifty("small");
		
		$("div#content > h3").nifty("small");
		$("div#menuDiNavigazioneSisp2 > h3").nifty("small");
		$("#colonnaCentrale > h3").nifty("small");
		$(".popupscroll > h3, .popupscroll > h4").nifty("small");
		$(".scroll > h4").nifty("small");
	}
});

})(jQuery);

(function($) {

////////////////////////////////////////////////////////////////////////////////
//========== OVER OUT HANDLER ==================================================
////////////////////////////////////////////////////////////////////////////////
// Solo Internet Explorer
 
var jQOverOutHandler = {
    build   : function(options)
    {
		return this.each(function(){
			var _classes = $(this).attr("class");
            var _a = _classes.split(" ");
            var _old = _a[0] ? _a[0] : false;
            if(_old){
            	 var _ch = _old + "Hover";
            	 $(this).hover(
            	 	function(){
            	 		$(this).removeClass(_old);
            	 		$(this).addClass(_ch);            	 	
            		},
            	 	function(){
            	 		$(this).removeClass(_ch);
            	 		$(this).addClass(_old);
            	 	}
            	 );
            }
		});
   }
};

$.fn.overouthandler = jQOverOutHandler.build;

////////////////////////////////////////////////////////////////////////////////
//*********** AUTOLOAD *********************************************************
////////////////////////////////////////////////////////////////////////////////

$(document).ready(function(){
    if($.browser.msie){
    	$(".overouthandler").overouthandler();
    }
});

})(jQuery);

(function($) {


////////////////////////////////////////////////////////////////////////////////
//========== BOX A SCOMPARSA ===================================================
////////////////////////////////////////////////////////////////////////////////

var jQTogglePanel = {
	count  : 0,
	build  : function(options){
		
		//console.log(this.size());
		//if(this.size() == 0)
		//    return;
		
		var _options = $.extend({
			link 		  : 'span',
			pattern_panel : 'togglepanel_',
			pattern_link  : 'togglelink_',
			pattern_handle: 'toggle_',
			label_on	  : 'Apri',
			label_off	  : 'Chiudi',
			open_onstart  : '.toggle_open',
			hide_onstart  : '.toggle_close',
			menu 		  : false,
			menu2 		  : false,
			menu_on 	  : 'visualizza tutte le sezioni',
			menu_off 	  : 'nascondi tutte le sezioni',
			menu_on_class : 'visualizza',
			menu_off_class: 'nascondi',
			menu_sep	  : '&nbsp;|&nbsp;',
			after_click	  : false
		}, options);
		
		jQTogglePanel.count++;
		
		
		
		//if(jQlib.TogglePanel.count == 1 && _options.menu){
		if(_options.menu){
			var _that = this;
			var _start = $(_options.menu).hasClass("parti_chiuso");
			var _c1 = _start ? _options.menu_off_class : _options.menu_on_class;
			var _c2 = _start ? _options.menu_on : _options.menu_off;
			
			var _menu = '<a href="#" class="' + _c1 + '">' + _c2 + '</a>';
			$(_options.menu).html(_menu);
			var _handles = $(_options.menu).find("a");
			_handles.each(function(){
				$(this).click(function(){
					var _flag = $(this).text() == _options.menu_on;
					var _h = $(".toggle_handle");
					var _handle = this;
					_h.each(function(){
						if(_flag){
							$(_handles).text(_options.menu_off);
							$(_handles).removeClass(_options.menu_off_class).addClass(_options.menu_on_class);
							_h.trigger("apri");
						}else{
							$(_handles).text(_options.menu_on);
							$(_handles).removeClass(_options.menu_on_class).addClass(_options.menu_off_class);
							_h.trigger("chiudi");
						}
					//	$(this).trigger("click");
					});
					//alert(_h);
					return false;//TODO: sistemare l'attivazione di questo plugin
				});
			});
		}
		
		if(_options.menu2){
			var _menu_on = '<a href="#" class="'+_options.menu_on_class+'">' + _options.menu_on + '</a>';
			var _menu_off = '<a href="#" class="'+_options.menu_off_class+'">' + _options.menu_off + '</a>';
			var _sep = _options.menu_sep;
			$(_options.menu2).html(_menu_on + _sep + _menu_off);
			
			$(_options.menu2).each(function(){
				var _handles = $(this).find("a");
				
				_handles.eq(0).click(function(){
					_click(true);
				});
				_handles.eq(1).click(function(){
					_click(false);
				});
			});
			var _click = function(flag){
				var _h = $(".toggle_handle");
				_h.each(function(){
					if(flag){
						_h.trigger("apri");
					}else{
						_h.trigger("chiudi");
					}
				//	$(this).trigger("click");
				});
				//alert(_h);
				return false;
			};
		}
		
		return this.each(function(){
			//alternate
			var _is_alternate = $(this).is(".togglepanel_alternate");
			_options.alternate = _is_alternate;
			//console.log(_options.alternate)
			
			jQTogglePanel.auto_hide(this,_options);
			jQTogglePanel.add_link(this, _options);
			
		});
	},
	
	auto_hide : function(el, options){
		$(options.hide_onstart).hide();
	},
	add_link : function(el, options){
		
		var _options = options;//jQlib.TogglePanel.expando(el);
		var _links = $(_options.link, el);
		//se trova il link.
		_links.each(function(){
		    //se trova l'id
		    
			if(this.id && this.id.indexOf(_options.pattern_handle) !== -1){
			
			
    			var that = this;
    		    if(!that.expando)
    				that.expando = {};
    			
    			if(!that.expando.togglepanel){
    			    that.expando.togglepanel = {};
    			    that.expando.togglepanel.options = _options;
    			}else{
    			    //console.log("gia usato");
    			    return;
    			}
			    //console.log("fatto");
			    
			    var _target = jQTogglePanel.link_to_target(el, this);
			    var _id = jQTogglePanel.id(this, this.id);
				var _link = $('<a class="toggle_handle" href="#" id="'+ _options.pattern_link + _id + '"></a>');
				
				
				_link.bind("text", function(){
					//	console.log($(this).text() == _options.label_off);
					//$(this).text() == _options.label_off ? $(this).text(_options.label_on) : $(this).text(_options.label_off); 	
					
					var _c1 = _clean_html_for_ie($(this).html());
					var _c2 = _clean_html_for_ie(_options.label_off);
					var _flag = _c1 == _c2;
					
					_flag ? $(this).html(_options.label_on) : $(this).html(_options.label_off);
					//$(this).after(_c1 + ' ' + _c2);
					if(_options.after_click)
						_options.after_click(this, _flag);
					
					
					function _clean_html_for_ie(str){
						str = str.toString().toLowerCase().replace(/\"/g, '');
						return str;
					}	
						
				});
				
				_link.bind("apri",function(){
					$("#" + _target).show();	
				    $(this).html(_options.label_off);
				    return false;
				});
				_link.bind("chiudi", function(){
					//console.log(_target)
					$("#" + _target).hide();	
				    $(this).html(_options.label_on);
				    return false;
				});
				
				_link.click(function(){
					if(_options.alternate){
						$('.toggle_handle').not(this).trigger("chiudi").html(_options.label_on);
						//console.log(_links)
						$(this).trigger("apri").html(_options.label_off);
					}else{
						$("#" + _target).toggle();	
					    $(this).trigger("text");	
					}
				    return false;
				});
				
				
				if($("#" + _target).css('display') != 'none'){
					_link.html(_options.label_off);
				}else{
					_link.html(_options.label_on);
				}
				
				//.empty()
				$(this)
				.append(_link);
				
			}	
		});
		
	},
	id : function(link, str){
		var _options = jQTogglePanel.expando(link);
		str = str.replace(_options.pattern_panel,"");
		str = str.replace(_options.pattern_link,"");
		str = str.replace(_options.pattern_handle,"");
		return str;
	},
	link_to_target : function(el, link){
		var _options = jQTogglePanel.expando(link);//era el
		var _id = jQTogglePanel.id(link,link.id);
		return _options.pattern_panel + _id;
	},
	expando : function(el){
		return el.expando.togglepanel.options;
	}
};

$.fn.togglepanel = jQTogglePanel.build;

})(jQuery);


(function($){
	
jQTooltip = {}; 

////////////////////////////////////////////////////////////////////////////////
//========== TOOLTIP ===========================================================
////////////////////////////////////////////////////////////////////////////////

jQTooltip.Tooltip = {
	build: function(options){
        
        var _options = $.extend({}, options);
        //$("span.txt_errore span").css({color:"auto",display:"inline",});//fontWeight: "normal"
            
        return this.each(function(nr){
            
            var that = this;
            var _img = $(this).find("img").eq(0);
            if(_img.hasClass("im_error")){
                
                var _id = nr + 1;
                $(_img).after('<a href="#toolt_'+ _id +'" class="link_errore">&nbsp;</a>');
                var _target = $(this).find("span").eq(0).attr("id", "toolt_" + _id).addClass("elenco_errori_invisibile");
                $(this).find("a").eq(0)
                .bind("mostra", function(){
                    //console.log(_target);
                    _target.removeClass("elenco_errori_invisibile").addClass("elenco_errori_visibile");
                })
                .bind("nascondi", function(){
                    //console.log(_target);
                    _target.removeClass("elenco_errori_visibile").addClass("elenco_errori_invisibile");
                })
                .bind("mytoggle", function(){
                    if(_target.hasClass("elenco_errori_invisibile")){
                         $(this).trigger("mostra");
                    }else{
                         $(this).trigger("nascondi");
                    }
                })
                .click(function(){
                    $(this).trigger("mytoggle");
                    return false;
                })
                .hover(
                    function(){
                        $(this).trigger("mostra");

                    },
                    function(){
                        $(this).trigger("nascondi");
                    }
                );
                
            }
          
        });
	}
};

$.fn.tooltip = jQTooltip.Tooltip.build;


////////////////////////////////////////////////////////////////////////////////
//*********** AUTOLOAD *********************************************************
////////////////////////////////////////////////////////////////////////////////
$(document).ready(function(){
	$("span.txt_errore").tooltip();
});

})(jQuery);


(function($){

////////////////////////////////////////////////////////////////////////////////
//========== PULSANTI FUNZIONALI================================================
////////////////////////////////////////////////////////////////////////////////

var jQButton = {
    build : function(options){
        var _options = $.extend({
            text     : 'bottone',
            callback : function(){}  
        }, options);
        
        return this.each(function(){
            $('<a href="#">'+_options.text+'</a>')
            .attr("rel",_options.text)
            .click(function(){
                _options.callback();
                return false;
            })
            .appendTo(this);    
        });
    }    
};

$.fn.jbutton = jQButton.build;

////////////////////////////////////////////////////////////////////////////////
//*********** AUTOLOAD *********************************************************
////////////////////////////////////////////////////////////////////////////////
$(document).ready(function(){
	$("span.chiudi").jbutton({text : 'chiudi', callback : function (){window.close();} });
	$("span.stampa").jbutton({text : 'stampa', callback : function (){window.print();} });
});

})(jQuery);

(function($){

////////////////////////////////////////////////////////////////////////////////
//========== OVER OUT TR =======================================================
////////////////////////////////////////////////////////////////////////////////

var jQOverOutTr = {
    build : function(){
        return this.each(function(){
            var that = this;
            
            $("tr", this).hover(
               function(){
                   $("td",this).addClass("hover");
               },
               function(){
                   $("td",this).removeClass("hover");
               }
            );
            
            $("tr", this).click(function(e){
            	var _target =  e.target || e.srcElement;
            	var _tag = _target.tagName.toString().toLowerCase();
				//prendo solo il click sul td
				//se ci fossero tag di tipo blocco dentro il td sarebbe un problema
				//se invece clicco su una input o su una label gestisco tutto con l'evento -> VEDI SOTTO 
            	if(_tag === 'td'){
	            	var _tr = $(this);
	            	_highlight_row(_tr, true);
            	}
            	//return false;
            });

            //vedi sotto A
            $("tr", this).find("input:checkbox, input:radio").bind("click", function(){
            	var _tr = $(this).parents("tr:eq(0)");
            	//console.log(_tr)
				_highlight_row(_tr, true);
            });
            //vedi sotto B
            $("tr", this).find("input:checkbox").bind("checked", function(){ 
				//console.log(this)
            	var _tr = $(this).parents("tr");
            	_highlight_row(_tr, false);
            });
            
            var _highlight_row = function(_tr, flag){
            	//il flag è per selezionare la checkbox/radio forzatamente
            	//checkbox gestisce la "multiselezione"
            	
            	var _checkbox = $("input:checkbox",_tr).length > 0;
            	
            	//nel caso dei radio cancello le altre colorazioni
            	if(!_checkbox){
            		$("td",that).removeClass("selected");
            		$("tr",that).removeClass("selected");
            		$("td",_tr).addClass("selected");
	            	_tr.addClass("selected");
	            	
	            	if(flag){
            			$("input:radio",_tr).attr("checked", "checked");
            		}
	            	
            	}else{
            		var _selected = _tr.is(".selected");
            		if(_selected){
            			$("td",_tr).removeClass("selected");
	            		_tr.removeClass("selected");
	            		$("input:checkbox",_tr).attr("checked", "");
            		}else{
            			$("td",_tr).addClass("selected");
	            		_tr.addClass("selected");
	            		$("input:checkbox",_tr).attr("checked", "checked");
            		}
            	}
            	
            	
            };
            
            //A: triggero click per colorare la riga
            $("input:radio:checked", that).trigger("click");
            //B: triggero checked -> se usassi il click la checkbox si deselezionerebbe
            $("input:checkbox:checked", that).trigger("checked");
           
        });
    }    
};

$.fn.overouttr = jQOverOutTr.build;

////////////////////////////////////////////////////////////////////////////////
//*********** AUTOLOAD *********************************************************
////////////////////////////////////////////////////////////////////////////////
$(document).ready(function(){
	$('table.overouttr').overouttr();
});

})(jQuery);

(function($){

var jQToggleTargetSisp = function(){
	
	//1.2.6 non ha la proprietà core .selector
	//console.log($(this).selector);	
	//console.log(this.selector);	
	return this.each(function(){
		
		var that = this;

		var _id = that.id;
		
		var _css_on = 'espandi';
		var _css_off = 'collapse';
		
		var _title_on = 'espandi sezione';
		var _title_off = 'chiudi sezione';
		var _span_title_on = '<span class="nascosto">visualizza </span>';
		var _span_title_off = '<span class="nascosto">nascondi </span>';
		
		
		var _container = $(this).parents(".toggle_alternate");
		var _is_alternate = _container.length > 0;
		
		//console.log(_is_alternate);
		
		var _classes = $(that).attr("class");
		var _state = $(that).is(".collapse");
		var _title = _state ?  _title_off : _title_on;
		
		var _text = $(that).text();
		var _handler = $('<a id="'+_id+'" class="'+_classes+'" title="'+_title+'" href="#">'+ _text + '</a>');
		
		$(that).empty().removeAttr("class").removeAttr("id").removeAttr("title");
		$(that).append(_handler);
		
		
		if(!_id)
			return;
			
		var _target = _id.split("_").slice(2);//toggle_handle_1 -> 1
		var _css_target = '.toggle_target_' + _target;
		
		//console.log(_state);
		if(!_state){
			$(_css_target).hide();
			$(_handler).prepend(_span_title_on);
		}else{
			$(_handler).prepend(_span_title_off);
		}
		
		
		$(_handler)
		.bind("apri", function(){
			$(this).find("span").remove();
			$(this).removeClass(_css_on).addClass(_css_off);
			$(this).attr("title", _title_off);
			$(this).prepend(_span_title_off); 
			_state = true;  	
			
			$(_css_target).show();
		})
		.bind("chiudi", function(){
			$(this).find("span").remove();
			$(this).removeClass(_css_off).addClass(_css_on);
			$(this).attr("title", _title_on);
			$(this).prepend(_span_title_on); 
			_state = false; 
			
			$(_css_target).hide();
		})
		.bind("mytoggle", function(){
			$(this).find("span").remove();
			!_state ? $(this).removeClass(_css_on).addClass(_css_off) : $(this).removeClass(_css_off).addClass(_css_on);
			!_state ? $(this).attr("title", _title_off) : $(this).attr("title", _title_on);
			!_state ? $(this).prepend(_span_title_off) : $(this).prepend(_span_title_on); 
			_state = !_state;  	
			
			$(_css_target).toggle();
		})
		.click(function(){
			//avrei usato .selector per rendere dinamico il plugin
			if (_is_alternate) {
			//console.log($('.toggle_handle', _container))
				$('.toggle_handle', _container).not(this).trigger("chiudi");
				$(_handler).trigger("apri");
			} else {
				$(_handler).trigger("mytoggle");
			}
			return false;
		});;
		
	});
};

$.fn.toggletargetsisp = jQToggleTargetSisp;	

 
////////////////////////////////////////////////////////////////////////////////
//*********** AUTOLOAD *********************************************************
////////////////////////////////////////////////////////////////////////////////

$(document).ready(function(){
	$(".toggle_handle").toggletargetsisp();
});

})(jQuery);