/* 
 * $Date: 2009-10-30 11:40:28 +0100 (ven, 30 ott 2009) $
 * $Rev: 223 $
 */

/*
 *
 * Copyright (c) 2009 C. F., Wong (<a href="http://cloudgen.w0ng.hk">Cloudgen Examplet Store</a>)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 * See details in: <a href="http://cloudgen.w0ng.hk/javascript/javascript.php">Javascript Examplet</a>
 *
 */
// updated on 2009/09/21 by Cloudgen
// 1. accept selectors with regular expression construct and flags (igm), e.g: /\d+/g, /[aeiou]/ig, etc.
// 2. accept selectors with attribute name in the format: [attr,regex]
// 3. add regex() plugin
;(function($){
	function regex(d,a,c){
		var k=new RegExp("\/(.(?!\/))*.\/[gim]*"),
		m=new RegExp(/\[([^\,]+)\,([^\]]+)\]/),
		f=c[3],e,b;
		if (m.test(f)){
			f=f.replace(m,function(s,s1,s2){b=d.getAttribute(s1);return s2})
		} else {
			b=("text"===d.type)?d.value:d.innerHTML;
		}
		e=(k.test(f))? eval("("+f+")") : new RegExp(f,"ig");
		return(b=="")?true:(e.exec(b))
	}
	$.extend($.expr[":"],{
		regex:function(d,a,c){
			return regex(d,a,c);
		}
	});
	$.fn.regex=function(s1,s2){
		var ret=[];
		this.each(function(i,v){
			var e,b;
			if(typeof s2==="undefined"){
				if(Object.prototype.toString.call(s1)==="[object RegExp]")
					e=new RegExp(s1);
				else
					e=new RegExp(s1,"ig");
				b=(typeof this.value!="undefined")?this.value:this.innerHTML;
			} else {
				if (typeof s1==="string"){
					if(Object.prototype.toString.call(s2)==="[object RegExp]")
						e=new RegExp(s2);
					else
					e=new RegExp(s2,"ig");
					b=this.getAttribute(s1);
				}
			}
			if (b!="" && e.test(b)) {
				ret.push(this);
			}
		});
		return this.pushStack(ret);
	};
})(jQuery);


////////////////////////////////////////////////////////////////////////////////
//========== 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 : "no", resizable : "no", width : 790, height : 440});
    $("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});
});

})(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 6
 
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)
				_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, input:submit, input:reset, input:button").overouthandler();
    }
});

})(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");
					var _ie6 = typeof document.body.style.maxHeight === "undefined";
					if(_ie6)
						_target.bgiframe();
                })
                .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);

