$(document).ready(function()
{
	// PRELOAD IMMAGINI

	$("img.rollover").each(function(i)
	{
		src = $(this).attr('src');
		$('<img>').attr('src', src.substring(0, src.search(/(\.[a-z]+)$/)) + '_h' + src.match(/(\.[a-z]+)$/)[0]);
	});


	$("img.rollover").hover(
		function() {
			src = $(this).attr('src');
			src = src.substring(0, src.search(/(\.[a-z]+)$/)) + '_h' + src.match(/(\.[a-z]+)$/)[0];
			$(this).attr('src',src);
		},
		function() {
			$(this).attr('src', $(this).attr('src').replace(/_h\./,'.'));
		}
	);




	// BLOCKUI

	$.blockUI.defaults.message = 'caricamento...<br /><br /><img src="' + IMG_PATH + '/loader.gif" />';

	$.blockUI.defaults.css =
	{
        padding:        '10px',
        margin:         0,
        width:          '30%',
        top:            '35%',
        left:           '35%',
        textAlign:      'center',
        color:          '#333',
        border:         '2px solid #333',
        backgroundColor:'#FFF',
        cursor:         'wait',
        position:		'absolute'
    };

	$.blockUI.defaults.overlayCSS =
	{
		backgroundColor: '#EEE',
		opacity: 		  0.55,
		cursor:			 'wait'
	};


	/*

	// STILI NOTIFICHE GROWL

	self.growlCSS_info =
	{
		position: 'fixed',
		width:    '350px',
		height:   '60px',
		bottom:   '10px',
		left:     '10px',
		top:	  '',
		right:    '',
	    border:   '1px solid #0080FF',
	    padding:  '5px',
	    opacity:  0.8,
	    color:    '#0080FF',
	    cursor:   'default',
	    backgroundColor: '#C1E0FF',
	    '-webkit-border-radius': '10px',
	    '-moz-border-radius':    '10px'
	};

	self.growlCSS_ok =
	{
		position: 'fixed',
		width:    '350px',
		height:   '60px',
		bottom:   '10px',
		left:     '10px',
		top:	  '',
		right:    '',
	    border:   '1px solid #090',
	    padding:  '5px',
	    opacity:   0.8,
	    color:    '#090',
	    cursor:   'default',
	    backgroundColor: '#CBFFD8',
	    '-webkit-border-radius': '10px',
	    '-moz-border-radius':    '10px'
	};

	self.growlCSS_error =
	{
		position: 'fixed',
		width:    '350px',
		height:   '60px',
		bottom:   '10px',
		left:     '10px',
		top:	  '',
		right:    '',
	    border:   '1px solid #C00',
	    padding:  '5px',
	    opacity:   0.8,
	    color:    '#C00',
	    cursor:   'default',
	    backgroundColor: '#FFD6D6',
	    '-webkit-border-radius': '10px',
	    '-moz-border-radius':    '10px'
	};




	// NOTIFICHE GROWL

	growlUI_close = function(class)
	{
		$('div.'+class+' #close').click(function()
		{
			$.unblockUI();
		});
	}

	growlUI_unblock = function(class)
	{
		$('div.'+class+':not(div.'+class+':first)').remove();
		$('div.'+class).replaceWith('<div class="growlUI '+class+'"></div>');
	}

	growlUI_error = function(h1,h2,timeout)
	{
		timeout = timeout || 4000;
		$('div.growlUI-error').html('<div id="close">X</div><h1>' + h1 + '</h1><h2>' + h2 + '</h2>');
		$.blockUI({
	    	message: $('div.growlUI-error'),
	        fadeIn: 700,
	        fadeOut: 700,
	        timeout: timeout,
	        showOverlay: false,
	        centerY: false,
	        css: self.growlCSS_error,
	        onUnblock: growlUI_unblock('growlUI-error')
	    });
	    growlUI_close('growlUI-error');
	}

	growlUI_ok = function(h1,h2,timeout)
	{
		timeout = timeout || 4000;
		$('div.growlUI-ok').html('<div id="close">X</div><h1>' + h1 + '</h1><h2>' + h2 + '</h2>');
		$.blockUI({
	    	message: $('div.growlUI-ok'),
	        fadeIn: 700,
	        fadeOut: 700,
	        timeout: timeout,
	        showOverlay: false,
	        centerY: false,
	        css: self.growlCSS_ok,
	        onUnblock: growlUI_unblock('growlUI-ok')
	    });
	    growlUI_close('growlUI-ok');
	}

	growlUI_info = function(h1,h2,timeout)
	{
		timeout = timeout || 4000;
		$('div.growlUI-info').html('<div id="close">X</div><h1>' + h1 + '</h1><h2>' + h2 + '</h2>');
		$.blockUI({
	    	message: $('div.growlUI-info'),
	        fadeIn: 700,
	        fadeOut: 700,
	        timeout: timeout,
	        showOverlay: false,
	        centerY: false,
	        css: self.growlCSS_info,
	        onUnblock: growlUI_unblock('growlUI-info')
	    });
	    growlUI_close('growlUI-info');
	}
	*/


	// APERTURA POPUP
	popup = function(w, h, name, url)
	{
		attr = 'scroll=auto';
		window.open(url, name, attr + ",width=" + w + ",height=" + h + ",top=" + 10 + ",left=" + 10);
	}

});

