// JavaScript Document

function BlockUI(titolo, testo, callback,chiudi) {
	if (!callback) callback = "";
	
	var str;
	str = '<div style="background:#FFF; color:#006A9A;"><div style="padding:10px;"><span class="fs12 bold">'+titolo+'</span><div class="spacer5"></div><div class="fs11">';
	str = str + testo;
	str = str + '</div>';
	
	if (!chiudi) {
		str = str + '<div class="taR testo_rosso fs10"><span class="chiudiBlockUI btn redHover">Chiudi</span></div>';
	}
	
	str = str + '</div>';

	$.blockUI({

		css: { 
			border: 'none', 
			padding: '0', 
			backgroundColor: 'transparent', 
			color: '#464646',
			cursor: 'default',
			left: '50%',
			margin:'0 0 0 -195px',
			top: '20%',
			width: '390px',
			fontSize: '16px',
			textAlign: 'left',
			zIndex: 5000
		},
		message: str,
		overlayCSS: {
			cursor: 'default',
			backgroundColor:'#000', 
			opacity:'0.5',
			zIndex: 4000
		},
		
		onBlock: function(){
			
		}
		
	});
	if (callback.indexOf("http://") != -1) {
		$(".chiudiBlockUI").click(function() {	   
			document.location.href = callback;							   
		}); 
	} else if (callback == "home") {
		$(".chiudiBlockUI").click(function() {	   
			document.location.href = LINK_HOME;							   
		}); 
	} else if (callback == "cover") {
		$(".chiudiBlockUI").click(function() {	   
			document.location.href = BASE_URL;							   
		}); 
	} else if(callback=='refresh'){
		$(".chiudiBlockUI").click(function() {
			document.location.href = document.location;							   
		}); 
	} else if(callback=='login'){
		$(".chiudiBlockUI").click(function() {
			document.location.href = LINK_LOGIN;	
		});
	} else {
		$(".chiudiBlockUI").click(function() {
			$.unblockUI();		
		});	
	}
}

function LoadingBlockUI() {
	
	str = '<div class="testo"><p class="titolo">Caricamento in corso..</p></div>';
	
	$.blockUI({

		css: { 
			border: 'none', 
			padding: '0', 
			backgroundColor: '#FFF', 
			color: '#0f99ad',
			cursor: 'default',
			left: '50%',
			margin:'0 0 0 -190px',
			top: '20%',
			width: '380px',
			fontSize: '13px',
			opacity:'0.8'
		},
		message: str,
		overlayCSS: {
			cursor: 'default',
			backgroundColor:'#000', 
			opacity:'0.3' 
		},
		
		onBlock: function(){
			
		}
		
	});
}
