function AlertUI(var1){
			W = 600;
			H = 300;	
					
			jQuery("#alertUI").dialog({
			resizable: false,
			height: H,
			width: W,
			bgiframe: true, 
			overlay: {opacity: 0.8, background: "black"},
			modal: true,
			buttons: {
				Chiudi: function() {
					$(this).dialog('close');
				}
			},
			open: function() {
				jQuery("#alertUI").html('<div class="alertUI"><p>'+var1+'</p></div>'); 
				jQuery('.alertUI').css('width', W+'px').css('height', H+'px').css('line-height',H-20+'px');
				jQuery('.alertUI p').css('line-height',H-20+'px');				
			}
		});
	

}

function DimensionDiv(H, W, H2){
	jQuery('.formcontent').css('width', W+'px').css('height', H+'px');	
	jQuery('.loading').css('width', W+'px').css('height', H+'px');
	jQuery('.thanks').css('width', W+'px').css('height', H+'px').css('line-height',H+'px');	
	jQuery('.title-bar').css('width',W-20+'px').css('height', H2-1+'px');		
	jQuery('.ui-fix').css('width', W-20+'px').css('height', H2-1+'px');
	jQuery('.choosepanel').css('width', W-20+'px').css('height', H+'px');
	jQuery('.step').css('width', W-60+'px').css('height', H-200+'px');;		
	jQuery('#PreventivoPersonalizzato').css('width', W/2-50+'px');	
	jQuery('#MaggioriInformazioni').css('width', W/2+'px');		

}
function FormatInput(){
	// css via js per ovviare al probl di visualizzazione su ie6
	jQuery('input').css('border', '1px solid #bbb').css('font-size','13px');
	jQuery('input').css('padding', '3px');
	jQuery('input').css('margin','0px 3px 0px 3px');	
    jQuery('input:button').css('padding', '3px').css('cursor','pointer').css('background-color','#dfdfdf');	
    jQuery('input:reset').css('padding', '3px').css('cursor','pointer').css('background-color','#dfdfdf');
    jQuery('input:submit').css('padding', '3px').css('cursor','pointer').css('background-color','#dfdfdf');
    jQuery('input:checkbox').css('border', '0px').css('margin','0px 3px 0px 3px');
    jQuery('textarea').css('border', '1px solid #bbb');
    jQuery('select').css('border', '1px solid #bbb');
   	jQuery('.b1').css('background-color', '#ccc').css('border', '1px solid #777');
}

function ShowPrivacy(var1,var2,altezza, larghezza){
	
	jQuery(var1).click(function() {

		jQuery(var2).dialog({
			resizable: false,
			height: altezza,
			width: larghezza,
			bgiframe: true, 
			overlay: {opacity: 0.8, background: "black"},
			modal: false,
			open: function() {
				jQuery('.contentStep').fadeOut();
				jQuery('#privacyUi').show();				
			},
			buttons: {
				Chiudi: function() {
					$(this).dialog('close');
					jQuery('.contentStep').fadeIn();					
				jQuery('#privacyUi').hide();									
				}
			}

		});

	});


}

//--------------------------------------------------------------------

function HtmlContent(ID_content, form){


	var lang = jQuery('body').attr('class');
	
	if(form == 'frm_guestbook'){
		var dir = "guestbook";
		location.href = lang+"/"+dir+"_"+ID_content+".html";	 // rimando alla pagina dei commenti
	}
	if(form == 'frm_contatti'){

		location.href = window.location.href // refresho la pagina
	}
	
	
	
}


function UiTbasNav(choosetab,opt){

	if(choosetab=='Empty'){
		jQuery('#privacyUi').dialog('close');
		jQuery(opt).dialog('close');
		jQuery('.formcontent').remove();
		if(opt=='#guestbookUi'){
			toConsole(opt);
			HtmlContent(225);	
		}
		
	}
	if(choosetab=='home'){
	
	jQuery('#contentStep').hide();
	jQuery('#choosepanel').show();	
	jQuery('.ui-fix').hide();

	}
	
	
	if(choosetab=='PreventivoPersonalizzato'){
		// modifica attr
		jQuery('#frm_tipo_richiesta').attr('value','richiesta preventivo');

		// da nascondere
		jQuery('#tabMaggioriInformazioni').hide();
		jQuery('#MaggioriInformazioni').hide();						

		jQuery('#choosepanel').hide();

		// da visualizzare
		jQuery('.ui-fix').show();
		jQuery('.contentStep').show();			
		jQuery('#tabPreventivoPersonalizzato').show();	
		jQuery('#PreventivoPersonalizzato').show();		

		
		
		
	}else if(choosetab=='MaggioriInformazioni'){
			// modifica attr
		jQuery('#frm_tipo_richiesta').attr('value','richiesta informazioni');
		
		// da nascondere
		jQuery('#tabPreventivoPersonalizzato').hide();	
		jQuery('#PreventivoPersonalizzato').hide();		

		jQuery('#choosepanel').hide();

		// da visualizzare
		jQuery('.ui-fix').show();
		jQuery('.contentStep').show();			
		jQuery('#tabMaggioriInformazioni').show();
		jQuery('#MaggioriInformazioni').show();						

		
	}
	
	
	//alert(choosetab);	
	
	
}



function loadBook(id, div, request) {

	jQuery(div).html('<div id="loading"></div>');
	jQuery(div).load("index.php?l=it&option=content&id="+id+"&"+request+"=on");	

}

function mainHeight()
{
	try
	{
	var html = 					jQuery('html');
	var header = 					jQuery('#header');
	var footer = 					jQuery('#footer');
	var colonnaSX = 			jQuery('#colonnaSX');
	var speciali_offerte_top = jQuery('#speciali_offerte_top');	
	var speciali_offerte_middle = jQuery('#speciali_offerte_middle');
	var speciali_offerte_bottom = jQuery('#speciali_offerte_bottom');	
	var mceContentBody = jQuery('#mceContentBody'); 
	var container = 			jQuery('#container');
	var box = 			jQuery('#box');
	var box_sx = 			jQuery('#box_sx');
	var box_dx = 			jQuery('#box_dx');		
	
	var boxH			= Math.max(box_sx.height(),box_dx.height());
	
	var containerH			= Math.max(colonnaSX.height(),mceContentBody.height());
	container.css('height',containerH);
	footer.css('top',0);	
		
//	var speciali_offerte_middleH = mceContentBody.height()-speciali_offerte_top.height()-speciali_offerte_bottom.height();
//	speciali_offerte_middle.css('height',speciali_offerte_middleH);
	
	box.css('height',boxH);	

	
	
	// DEBUG
	toConsole('#mceContentBody: ' + mceContentBody.height());	
	toConsole('#header: ' + header.height());
	toConsole('#footer: ' + footer.height());
	toConsole('#colonnaSX: ' + colonnaSX.height());
	toConsole('#speciali_offerte_middle: ' + speciali_offerte_middle.height());
	toConsole('#container: ' + container.height());
	toConsole('#box: ' + box.height());
	toConsole('#box_sx: ' + box_sx.height());	
	toConsole('#box_dx: ' + box_dx.height());	
	// DEBUG
		
	}
	catch(e) {toDebug(e);}
}

function SubmitForm(divpadre, formName, load, fields, thanks, secure, var1)
{
	var d = new Date()
	var param = d.getTime();
	var Secure = jQuery('#'+secure);
	var DivPadre = jQuery('#'+divpadre);	
	var Form = jQuery('#'+formName);
	var Load = jQuery('#'+load);
	var Field = jQuery('#'+fields);
	var Thanks = jQuery('#'+thanks);
	var Var1 = jQuery('#'+var1);	
	
	jQuery(Secure).val(param); // -> <input type="hidden" name="secure" id="secure" value="">
	
		
	toConsole('parametro Sicurezza: '+param);
	toConsole('div richiesto: #'+divpadre);	
	toConsole('div richiesto: #'+secure);	
	toConsole('div richiesto: #'+formName);	
	toConsole('div richiesto: #'+load);	
	toConsole('div richiesto: #'+fields);					
	toConsole('div richiesto: #'+thanks);	
	
	//inizio validazione
	var error_found = 0;			
	
	if(error_found==0)
	{

		var options = { 
		
			beforeSubmit: function()
			{
				toConsole('invio in corso ...');
				jQuery(Field).fadeOut();
				jQuery(Var1).fadeOut();								
				jQuery(Load).fadeIn();				

			},
			resetForm: true,
			error: function()
			{
				toConsole('Errore di invio');
				jQuery(Load).fadeOut();
				jQuery(Thanks).html('<p>Attenzion! Errore di invio!</p>');
				return false;
			},
		    success: function() 
		    { 			    			
		    	toConsole('email inviata');   
				jQuery(Thanks).fadeIn();
				jQuery("div.latodx input.buttonClose").hide();									
				jQuery(Load).fadeOut().delay(3000,function(){

					jQuery(DivPadre).dialog('close').delay(500,function(){
						if(formName=='frm_guestbook'){
							toConsole(formName);
							HtmlContent(225,formName);	
						}
						if(formName=='frm_contatti'){
							toConsole(formName);
							HtmlContent(7,formName);	
						}
						
					});
				});
								
		    	
		    	return false; 	     	     
		    } 
		    
		}; 	
		
		jQuery(Form).ajaxForm(options); 
	    jQuery(Form).ajaxSubmit(options);
		    
	}	
	return false;

}



/*BOF randomizzazione*/

(function($){

	$.fn.shuffle = function() {
		return this.each(function(){
			var items = $(this).children();
			return (items.length) ? $(this).html($.shuffle(items)) : this;
		});
	}
	
	$.shuffle = function(arr) {
		for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x);
		return arr;
	}
})(jQuery);

/*EOF randomizzazione*/


function $j(argument)
{
	var result = jQuery(argument);
	if (result.length == 0) return null;
	else return result;
}
