$(document).ready(function() {
   
   $("ul#navmenu_lev2 li:last-child").addClass("last-child");
   
   // prettyPhoto
   $("a[rel^='prettyPhoto']").prettyPhoto();
   
   // taccone per overlay modali su IE
   $('body').append($('.jqmWindow'));
   
   // tutti i link a youtube si aprono in prettyBox
	//$("a[href^='http://www.youtube']:not([rel='directlink'])").attr("onclick","");
	$("a[href^='http://www.youtube']:not([rel='directlink'])").attr("target","");
   
	//$("a[href^='http://www.youtube']:not([rel='directlink'])").prettyPhoto();
   $("a[href^='http://www.youtube']:not([rel='directlink'])").click(function() {
     $.prettyPhoto.open($(this).attr('href'),$(this).children('img').attr('alt'),'');
     return false;
   });
   
   	
	/*
   $(".jcarousel").jcarousel({
         // configuration goes here
         auto: 1,
         scroll: 1,
         animation: 500
   });
   */
	
	/*
	$("p.highlight_text").removeClass("highlight_text");
	$("p.highlight_text").append('<span class="highlighted_text">xx'+$(this).html+'</span>');
	*/
	
	
	// datepicker
	$('.date-pick').datePicker({clickInput:true,startDate:'01/01/1900'});


});


var googleSearchInterval = 0;

window.onload = function() {
   adjustFooter();
   googleSearchInterval = setInterval("startGoogleSearch()", 100);
}

function startGoogleSearch() {
   if(!$("#cse").is("div") || googleSearchStr == undefined || googleSearchStr == "") {
      clearInterval(googleSearchInterval);
   }
   else {
      if($("#cse input.gsc-search-button")) {
         clearInterval(googleSearchInterval);
         $("#cse input.gsc-input").css("background-image","none");
         $("#cse input.gsc-input").val(googleSearchStr);
         $("#cse input.gsc-search-button").click();
      }
   } 
}

function adjustFooter () {
   
   if($("#main_content").is("div") || $("#left_navigation").is("div")) {
      
		var mainContentHeight = 0;
		var leftNavHeight     = 0;
		var sidebarHeight     = 0;
		var footerTopPos      = 0;
		
		if($("#main_content").is("div")) {
         mainContentHeight = $("#main_content").height() + 72 + mainContentTopOffset;
		}
		if($("#left_navigation").is("div")) {
         leftNavHeight = $("#left_navigation").height() + 72 + 341;
		}
		if($("#sidebar").is("div")) {
         sidebarHeight = $("#sidebar").height() + 72;
		}
		
		footerTopPos = Math.max(mainContentHeight,leftNavHeight,sidebarHeight);
		
		if (footerTopPos != 0) {
		   $("#footer").css("position","absolute");
         $("#footer").css("top",footerTopPos+"px");
		}

	}	
	
	$("#footer").show();
	
}

function homeBoxRollover(sezione) {
   $(".home_box_rollover").hide();
   $("#home_box_"+sezione+"_rollover").show();
}
function homeBoxRollout(sezione) {
   $("#home_box_"+sezione+"_rollover").hide();
}









































