//ADV function (txt players)
function getSite() {
	return "corriere";
};

function traffic_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};
/*SOPPALCO TEMPOREALE*/
function loadTempoReale() {
	$('.tr-home-container .tr-header, .tr-home-container #tr-21, .tr-home-container #tr-105').html();
	var idCompetitions = new Array();
	var counterCompetitions = 0;
	$.ajax({ 
		url: "/Sport/2010/optasics/xml-temporeale/competitions.xml", 
		dataType: "xml",
		success: function(xml_cont){
			$('.tr-home-container .tr-header').html("");
			if ($(xml_cont).find('Comp[comp-id="21"]').attr('active') == "1") {
				idCompetitions[0] = "21";
				$('.tr-home-container .tr-header').append('<li class="tab0"><a href="#tr-21">Serie A</a></li>');
			}
			if ($(xml_cont).find('Comp[comp-id="105"]').attr('active') == "1") {
				 idCompetitions[1] = "105";
				 $('.tr-home-container .tr-header').append('<li class="tab1"><a href="#tr-105">Serie B</a></li>');
			}
			
			for(var i = 0; i < idCompetitions.length; i ++) {
				$.ajax({ 
					url: '/Sport/2010/optasics/xml-temporeale/matchdays_'+idCompetitions[i]+'.xml', 
					dataType: "xml",
					success: function(xml_cont){
						$("#tr-"+idCompetitions[counterCompetitions]).html("");
						dataHtml = "";
						linkHtml = $(xml_cont).find('link').text();
						$(xml_cont).find('result').each(function(){
							matchStatus = $(this).attr('match-status');
							teamCodeHome = $(this).find('home-team').find('team-code').text();
							teamCodeHomeIt = $(this).find('home-team').find('team-code-it').text();
							teamNameHome = $(this).find('home-team').find('team-name').text();
							scoreHome = $(this).find('home-team').find('score').text();
							teamCodeAway = $(this).find('away-team').find('team-code').text();
							teamCodeAwayIt = $(this).find('away-team').find('team-code-it').text();
							teamNameAway = $(this).find('away-team').find('team-name').text();
							scoreAway = $(this).find('away-team').find('score').text();
							
							dataHtml += '<li><a href="'+linkHtml+'">';
							dataHtml += '<img src="/images/static/common/temporeale/scudetti/'+teamCodeHome+'.gif" class="img-scudetto" alt="'+teamNameHome+'" title="'+teamNameHome+'" />';
							dataHtml += '<span>'+teamCodeHomeIt+'</span>';
							dataHtml += '<strong>'+scoreHome+'</strong>';
							dataHtml += '<img src="/images/static/common/temporeale/scudetti/'+teamCodeAway+'.gif" class="img-scudetto" alt="'+teamNameAway+'" title="'+teamNameAway+'" />';
							dataHtml += '<span>'+teamCodeAwayIt+'</span>';
							dataHtml += '<strong>'+scoreAway+'</strong>';
							dataHtml += '<em>'+matchStatus+'</em>';
							dataHtml += '</a></li>';	
						});
						
						$("#tr-"+idCompetitions[counterCompetitions]).append(dataHtml);
						$("#tr-"+idCompetitions[counterCompetitions]).find("li:last").addClass("last");
						counterCompetitions ++;
					}			
				});	
			}
			
			$(".tr-header").tabs();
			
		}
	});
}
/*FINE SOPPALCO TEMPOREALE*/
function cercaPagineGialle() {
	$('.search-pgialle').attr('method','post');
	var argomento = (document.searchpgialle.cosa.value);
	var actionForm = "http://paginegialle.corriere.it/pgol/4-"
	document.searchpgialle.action = actionForm + argomento;
}

function getBoxMulino() {
	$.ajax({
		type: "GET",
		url: "http://www.corriere.it/ilmulino/mulino.xml",
		dataType: "xml",
		cache: false,
		success: function(xml_cont) {
			var data = $(xml_cont).find('channel item:eq(0)')
			var title = data.find('title').text();
			var description = data.find('description').text();
			var pubDate = data.find('pubDate').text();
			pubDate = pubDate.substring(5,16);
			var monthNames = [["Jan", "gennaio"], ["Feb", "febbraio"], ["Mar", "marzo"], ["Apr", "aprile"], ["May", "maggio"], ["Jun", "giugno"], ["Jul", "luglio"], ["Aug", "agosto"], ["Sep", "settembre"], ["Oct", "ottobre"], ["Nov", "novembre"], ["Dec", "dicembre"]];
			$.each(monthNames, function(i, month) {
				if (pubDate.indexOf(month[0]) !== -1) {
					pubDate = pubDate.replace(month[0], month[1]);
					return false
				}
			})
			var category = data.find('category').text();
			var link = data.find("link").text();

			$("#box-ilmulino p.subtitle").html(category);
			$("#box-ilmulino h3.hour").html(pubDate);
			$("#box-ilmulino h4.section").html("<a target='_blank' href=\"" + link + "\">" + title + "<\/a>");
			$("#box-ilmulino p.desc-text").html("<a target='_blank' href=\"" + link + "\">" + description + "<\/a>");
			$("#box-ilmulino").css("display", "block");
		}
	 });
}

function getNewsNRC() {
		$.ajax({
			type: "GET",
			url: "/english/xml/nrc.xml",
			dataType: "xml",
			success: function(xml_cont) {
			  list_li_nrc="<li class='title'>nrc-handelsblad</li>";
			$(xml_cont).find('item').each(function(i){
			 if(i<5){
				list_li_nrc = list_li_nrc +'<li><a href="'+$(this).find("link").text()+'" target="_blank">'+$(this).find("title").text()+'</a></li>';
        }
      });
			 $('#news_nrc').html(list_li_nrc).show();
			}
		});
}

function getNewsPOLOTIKEN() {
		$.ajax({
			type: "GET",
			url: "/english/xml/politiken.xml",
			dataType: "xml",
			success: function(xml_cont) {
			  list_li_nrc="<li class='title'>politiken</li>";
			$(xml_cont).find('item').each(function(i){
			 if(i<5){
				list_li_nrc = list_li_nrc +'<li><a href="'+$(this).find("link").text()+'" target="_blank">'+$(this).find("title").text()+'</a></li>';
        }
      });
			 $('#news_politiken').html(list_li_nrc).show();
			}
		});
}
function getNewsSPIEGEL() {
		$.ajax({
			type: "GET",
			url: "/english/xml/spiegel.xml",
			dataType: "xml",
			success: function(xml_cont) {
			  list_li_nrc="<li class='title'>spiegelonline</li>";
			$(xml_cont).find('item').each(function(i){
			 if(i<5){
				list_li_nrc = list_li_nrc +'<li><a href="'+$(this).find("link").text()+'" target="_blank">'+$(this).find("title").text()+'</a></li>';
        }
      });
			 $('#news_spiegel').html(list_li_nrc).show();
			}
		});
}
//POPUP LOGIN
function checkPopUp(){
  $.cookie('advertising-login', 'true' , { path: '/', expires: 30 });
  $.modal.close();
  return false;
}
$(document).ready(function(){


//POPUP LOGIN
		if($('.popup_advertise').length > 0) {
			if($.cookie('advertising-login') == null || $.cookie('advertising-login')!= "true"){
				$('.popup_advertise').modal({overlayClose:true,
			                         	containerId : 'simplemodal-advertise',
                                onClose: function (dialog) {
                                    	dialog.data.fadeOut('slow', function () {
                                    		dialog.container.slideUp('slow', function () {
                                    			dialog.overlay.fadeOut('slow', function () {
                                    				$.modal.close();
                                    			});
                                    		});
                                    	});
                                    }});

			}
		}
//FINE POPUP LOGIN

  if($("#ppn_check_column").length > 0){
    $("#ppn_check_column").remove();
      if($("#col-dx").height() >= $("#col-sx").height()){
          $.get("/tools/includes/afc_google_dyn_articolo_std_sez.inc?varPPN=corriere_std_"+sezione_ppn_dyn, function(data){
              $("#col-sx").append(data);
           });
      }
      else {
          $.get("/tools/includes/afc_google_dyn_articolo_spc_sottosez.inc?varPPN=corriere_spc_"+sezione_ppn_dyn, function(data){
              $("#col-dx").append(data);
           });
      }
  }

	if ($("#col-dx .tablequote-matchlist").length > 0) {
		if (Math.random() > 0.5) {
			$('#col-dx .tablequote-matchlist tr.partita').each(function(){
				var marchio1 = $(this).next('tr');
				var marchio2 = marchio1.next('tr');
				marchio2.insertBefore(marchio1);
			});
		}
	}
	//SALUTE: ESAMI DEL SANGUE 
	$(".esami-spalla .list-compressed li").each(function(){
		if($(this).find("ul").length > 0) $(this).find("a:first").css("font-style","italic");
	});
	//FINE SALUTE: ESAMI DEL SANGUE
	//spazio sotto la minipushbar in home
	if ($(".mini-pushbar-home").text().length > 100) {
		$(".mini-pushbar-home").addClass("spacer_bottom")
	}

	// commenti article toolbar
	if($("#box-dilatua-scrivi").length > 0){
		text_tool = "";
		num_com = $("#box-dilatua-scrivi #num-commenti").html().toLowerCase().split("<br>");
		if( num_com[0]  == 0){
			// se � ancora commentabile
			if($("#box-dilatua-scrivi .scrivi-dx-dilatua").length > 0){
				text_tool = "<li class='commenti-tool'>&nbsp;<a href='#boxcommenta' title='commenti'>COMMENTA</a></li>";
			}
		} else {
			text_tool = "<li class='commenti-tool'>&nbsp;<a href='#commenti' title='commenti'><strong>"+num_com[0]+"</strong> COMMENTI</a></li>";
		}
		$(".article .toolbar").prepend(text_tool);

	}
	
	/*SOPPALCO TEMPOREALE*/
		if ($('.tr-home-container').length > 0) {
			$('.tr-home-container').show();
			loadTempoReale();
			setInterval("loadTempoReale()", 60000);
		}	
	/*FINE SOPPALCO TEMPOREALE*/

	/*fanbox3*/
	$(".fanbox3 a").hover(function() {
	  $(this).next("em").animate({opacity: "show"}, "slow");
	}, function() {
	  $(this).next("em").animate({opacity: "hide"}, "fast");
	});

	// box ilmulino cultura
	if($("#box-ilmulino").length > 0) {
		getBoxMulino()
	}

	// gazzetta english in terza colonna carico il box NRC Handelsblad (solo le prime 5 news)
	if($("#news_nrc").length > 0) {
		getNewsNRC()
	}

	if($("#news_politiken").length > 0) {
		getNewsPOLOTIKEN()
	}

	if($("#news_spiegel").length > 0) {
		getNewsSPIEGEL()
	}

	$(".input-sbianca").focus(function() {
		if($(this).val() != "") {
			$(this).val(""); //Svuoto il contenuto.
		}
	});

	//box infotraffic
	if($('#mycarousel_traffic').length > 0){
$.ajax({
	url: "http://xml.corriereobjects.it/traffico/xml/traffico.json",
	    async: true,
	    dataType: "script",
	    success: function(json) {
      list_li="";

			$.each(xml_wrap.traffico, function(i, item) {
				list_li = list_li +'<li><a href="http://viaggi.corriere.it/servizi/traffico/"><strong>'+item.auto+'</strong><br />'+item.testo+'</a></li>';
			});

			 $('#mycarousel_traffic').html(list_li);
			$('#mycarousel_traffic').jcarousel({
				auto: 3,
				scroll: 1,
				wrap: 'last',
				initCallback: traffic_initCallback
			});
  }
});

	/*	$.ajax({
				type: "GET",
			url: "/traffico/xml/traffico.xml",
			dataType: "xml",
			success: function(xml_cont) {
			  list_li="";
			$(xml_cont).find('evts evt').each(function(){
				list_li = list_li +'<li><a href="http://viaggi.corriere.it/servizi/traffico/"><strong>'+$(this).attr("auto")+'</strong><br />'+$(this).find('testo').text()+'</a></li>';
			});
			 $('#mycarousel_traffic').html(list_li);
			$('#mycarousel_traffic').jcarousel({
				auto: 3,
				scroll: 1,
				wrap: 'last',
				initCallback: traffic_initCallback
			});
			}
		});*/


	}

	/* disabilita link per risultati classifica 2009*/
	$("table.stab a").css("cursor","default");
	$("table.stab a").click(function() {
			return false;
		}
	);

	//rimpicciolisco la scritta league
	if($("#col-dx #tabellino-hp h3 .title").length > 0){
	  if($("#col-dx #tabellino-hp h3 .title").html().indexOf("league")>-1) {
	   $("#tabellino-hp h3 .title").html($("#tabellino-hp h3 .title").html().replace("league","<span class='sub-title'>league</span>"));
	   $("#tabellino-hp h3 div.title").attr("style","margin:0");
	  }
	}

	//focus motore di ricerca

//	$("#search_val").focus();


	if ($("#square-top").size() > 0) {
		 $("#square-top").addClass("spacer_bottom");
	}



	$("#menu > ul.nav_1st").prepend("<li class=\"first\" style=\"width: 1px; height: 16px\"><!-- elemento generato da libreria_animazioni.js --></li>");

	// eccezione per sport e scienze che dal menu di secondo livello passano al menu di primo livello
	if ($(".sottomenu_scienze").length > 0) {
		$("#menu_news").attr("id","menu_scienze")
	}

	if ($("#sottomenu_sport").length > 0) {
		$("#menu_news").attr("id","menu_sport")
	}


	// selezione automatica del menu
	var id = $(".nav_1st").attr("id")
	var sezione=id.substring(id.indexOf("_")+1);
	if (sezione == "scommesse-lotterie") {
		$("#menu .nav_1st #scommesse").addClass("current");
	}
	if ((sezione == "giochi")&&(sottosezione="default")) {
		$("#menu .nav_1st #giochi").removeClass("current");
		$("#menu .nav_1st #news").addClass("current");
	}
	else {
		$("#menu .nav_1st #"+sezione).addClass("current");
	}

	if ($(".nav_2nd").length > 0) {
		var subid = $(".nav_2nd").attr("id")
		var sottosezione=subid.substring(subid.indexOf("_")+1);
		$("#menu .nav_2nd #"+sottosezione).addClass("current");
		$('.nav_2nd li:last').css('background-image','none')
	}

	if ($("#menu_sport").length > 0) {
		// seleziona il menu dal body cms sport
		// se siamo in tempo reale il controllo è sulla variabile id_c
		if((s.d.URL).indexOf("/sport/speciali/2010/tempo-reale/results.shtml") > -1){
			if(s.getQueryParam("id_c") == "21"){
					$("#sottomenu_sport #seriea").addClass("current");
				}
			else if(s.getQueryParam("id_c") == "105"){
					$("#sottomenu_sport #serieb").addClass("current");
				}
			else {
					$("#sottomenu_sport #coppe").addClass("current");
				}
		}
		else if ($("body").attr("class") != null) {

			var sportid = ($("body").attr("class")).split(" ")[0];
			var sportsezione=sportid.substring(sportid.indexOf("-")+1);
			$("#sottomenu_sport #"+sportsezione).addClass("current");

			if ($("body").attr("id") == "basket" && $("body").attr("class").indexOf("serie_a2m")>-1){
				$("#sottomenu_sport #legadue").addClass("current");
			} else if ($("body").attr("id") == "basket"){
				$("#sottomenu_sport #basket").addClass("current");
			}

			if (($("body").attr("class")).indexOf("sub-pallavolo")>-1 && ($("body").attr("class")).indexOf("serie_a2m")>-1){
				$("#sottomenu_sport #pallavolo").removeClass("current");
				$("#sottomenu_sport #pallavolo2").addClass("current");
			}
		}

		if ($("#sezione-speciale").length > 0 && $("#sezione-speciale").text() == "coppe") {
			$("#sottomenu_sport #coppe").addClass("current");
		} else if ($("#sezione-speciale").length > 0 && $("#sezione-speciale").text() == "campionato") {
			$("#sottomenu_sport #seriea").addClass("current");
		}
	}

	var usn=$.cookie("rcsLogin");

	if(usn!=null){
		usn=usn.substring(0,usn.indexOf("|"));
		if(usn.indexOf("@")==-1){
			//cookie obsoleto lo cancello
			$.cookie("rcsLogin", null,{path: '/', domain  : 'corriere.it'});
		}else{
			usn=usn.substring(0,usn.indexOf("@"));
			$("#user-name").html(usn);
			// non utilizzare toggle per non spaginare.
			// imposto il diplay:inline direttamente..
			$("#headBoxLogin span.notlogged").css("display", "none");
			$("#headBoxLogin span.logged").css("display", "inline");
		}
	}

	/*
	if(usn!=null){

		usn=usn.substring(0,usn.indexOf("|"));

		$("#user-name").html(usn);

		// non utilizzare toggle per non spaginare.

		// imposto il diplay:inline direttamente..

		$("#headBoxLogin span.notlogged").css("display", "none");

		$("#headBoxLogin span.logged").css("display", "inline");

	}*/

	$("#headBoxLogin a.headLogin").click(function(){

		$("#formLoginRegistrati > input[name='contentPath']").val(document.location.href);

		$("#formLoginRegistrati").submit();

		return false;

	});

	$("#headBoxLogin a.headRegistrazione").click(function(){

		$("#formRegistrazione > input[name='contentPath']").val(document.location.href);

		$("#formRegistrazione").submit();

		return false;

	});

	$("#headBoxLogin a.headUsn").click(function(){

		$("#formModifica").submit();

		return false;

	});

	$("#headBoxLogin a.headLogout").click(function(){

		$("#formLogout").submit();

		return false;

	});

	if($("#bannerone").height()==0){

		// $("#bannerone").css("width","250px");

		$("#bannerone").css("display","none");

		// Head Loghi Disabilitato 20090430

		// $("#bigbox").css("width","750px");

		// $("#boxmiddle").css("borderColor","#ffffff");

		// $("#boxbottom").css("padding","5px 0 0 3px");

	}

	if($("div.square-bottom").length>0){
		//if($('div.square-bottom').children().size()<2){
    if($("div.square-bottom").height() < 10){

		$("#ad_home_hide").load("/includes2007/ssi/boxes/accordion_home_meth_2.html");
		$("#ad_home_hide").css({'margin-right':'0','width':'auto','background':'none'});
		$(".asc-lar-0,.asc-lar-1,.asc-lar-2,.asc-lar-3").css("padding-right","13px");
		$("#ascensore-dx-static_large").css("padding-left","0px");
		}
		else{
			$(".square-bottom").css("width","311px");
			$(".square-bottom").css("margin-right","10px");
			$(".asc-lar-0").css("padding-right","4px");
			$(".asc-lar-1").css("padding-right","4px");
			$(".asc-lar-2").css("padding-right","4px");
			$("#ascensore-dx-static_large").css("padding-left","0px");
		}
	}

	$('#ad_home_hide').show();
	lnk_rullo_notizie = $("#xml").attr('name');
	getNews();
	setInterval ( getNews, 30000 );
	getNewsEconomia();
	getNewsElezioni2009();
	getNewsvideochatCor();

	$('#sect_news1, #sect_news2, #sect_news3').removeClass('ui-tabs-hide');

	if (browser_user_ag == "iPad") {
		$('#pane2, #pane3, #pane4').jScrollPane({showArrows:true,scrollbarWidth:18,dragMaxHeight:15});
	} else {
		$('#pane2, #pane3, #pane4').jScrollPane({showArrows:false,scrollbarWidth:18,dragMaxHeight:15});
	}

	$('#commenta-notizia').jScrollPane({showArrows:false,scrollbarWidth:18,dragMaxHeight:15});

	$("#truschino > dd:first").slideDown("slow");

	$("#truschino > dt:first").attr("class","selected");

	$("#truschino > dt > a").mouseover(function(){

		if($(this).parent().attr("class")!="selected"){

			$("#truschino > dd:visible").slideUp("slow");

			$("#truschino > dt.selected").attr("class","");

			$(this).parent().next().slideDown("slow");

			$(this).parent().attr("class","selected");

			return false;

		}

	});

	$("#ascensore-sx > dd:first").slideDown("slow");

	$("#ascensore-sx > dt:first").attr("class","selected");

	$("#ascensore-sx > dt > a").hoverIntent({

		sensitivity:1,

		interval:120,

		over:function(){

			if($(this).parent().attr("class")!="selected"){

				$("#ascensore-sx > dd:visible").slideUp("slow");

				$("#ascensore-sx > dt.selected").attr("class","");

				$(this).parent().next().slideDown("slow");

				$(this).parent().attr("class","selected");

				return false;

			}

		},

		timeout:30,

		out:function(){}

	});

	$("#ascensore-dx > dd:first").slideDown("slow");

	$("#ascensore-dx > dt:first").attr("class","selected");

	$("#ascensore-dx > dt > a").hoverIntent({

		sensitivity:1,

		interval:120,

		over:function(){

			if($(this).parent().attr("class")!="selected"){

				$("#ascensore-dx > dd:visible").slideUp("slow");

				$("#ascensore-dx > dt.selected").attr("class","");

				$(this).parent().next().slideDown("slow");

				$(this).parent().attr("class","selected");

				return false;

			}

		},

		timeout:30,

		out:function(){}

	});

	$("#forum-blog-sx dt:nth("+parseInt(Math.random()*$("#forum-blog-sx dt").length)+")").addClass("default");

	$("#forum-blog-sx dt.default + dd").addClass("default");

	$("#forum-blog-dx dt:nth("+parseInt(Math.random()*$("#forum-blog-dx dt").length)+")").addClass("default");

	$("#forum-blog-dx dt.default + dd").addClass("default");

	$("#forum-blog-sx dt").mouseover(function(){

		mover=$(this).attr("id").substring(3);

	});

	if(eval($("#forum-blog-sx"))!=""){

		$("#forum-blog-sx > dd.default").slideDown("slow");

		$("#forum-blog-sx > dt.default").attr("class","selected");

		$("#forum-blog-sx > dt.selected").each(function(){

			def=$(this).attr("id").substring(3);

			$("#forum-blog-sx > dd.default").load("/includes2007/ssi/boxes/forum_e_blog/contents/"+def+".html");

		});

		$("#forum-blog-sx > dt > a").hoverIntent({

			sensitivity:1,

			interval:120,

			over:function(){

				if($(this).parent().attr("class")!="selected"){

					$("#forum-blog-sx > dd:visible").slideUp("slow");

					$("#forum-blog-sx > dt.selected").attr("class","");

					$(this).parent().next().slideDown("slow");

					$(this).parent().attr("class","selected");

					if($(this).parent().next().html()==""){

						$(this).parent().next().load("/includes2007/ssi/boxes/forum_e_blog/contents/"+mover+".html");

						return false;

					}

				}

			},

			timeout:30,

			out:function(){}

		});

	};

	$("#forum-blog-dx dt").mouseover(function(){

		mover=$(this).attr("id").substring(3);

	});

	if(eval($("#forum-blog-dx"))!=""){

		$("#forum-blog-dx > dd.default").slideDown("slow");

		$("#forum-blog-dx > dt.default").attr("class","selected");

		$("#forum-blog-dx > dt.selected").each(function(){

			def=$("dl#forum-blog-dx > dt.selected").attr("id").substring(3);

			$("#forum-blog-dx > dd.default").load("/includes2007/ssi/boxes/forum_e_blog/contents/"+def+".html");

		});

		$("#forum-blog-dx > dt > a").hoverIntent({

			sensitivity:1,

			interval:120,

			over:function(){

				if($(this).parent().attr("class")!="selected"){

					$("#forum-blog-dx > dd:visible").slideUp("slow");

					$("#forum-blog-dx > dt.selected").attr("class","");

					$(this).parent().next().slideDown("slow");

					$(this).parent().attr("class","selected");

					if($(this).parent().next().html()==""){

						$(this).parent().next().load("/includes2007/ssi/boxes/forum_e_blog/contents/"+mover+".html");

						return false;

					}

				}

			},

			timeout:30,

			out:function(){}

		});

	};



	/* Gestione randomica del box visualizzato BOX-TROVOLAVORO-CASA-AUTO */
	/* ATTENZIONE VIENE EREDITATO DA TUTTI I TABS! */
	var r = Math.ceil((3*Math.random())) - 1;
	$("#ui-tabs-list").children().each(function (i) {
		if ( $(this).parents("div").attr("id") != "player_tabs" ){
			if (i == r) {
				$(this).addClass("ui-tabs-selected");
			}
		}
	});
	/* fine - Gestione randomica del box visualizzato BOX-TROVOLAVORO-CASA-AUTO */

	$("#box-trovolavoro-casa-auto > ul").tabs();

	$("#box-trovolavoro-casa-auto-cor > ul").tabs();

	/* tolgo il random che viene dato a tutti i tabs e forzo l'apertura sul primo */
	$("#box-invio-fotovideo > ul").tabs();
	$("#box-invio-fotovideo #ui-tabs-list").children().removeClass("ui-tabs-selected");
	$("#box-invio-fotovideo #ui-tabs-list li:first").addClass("ui-tabs-selected");
	$("#box-invio-fotovideo #section-2").css("display","none");
	$("#box-invio-fotovideo #section-1").css("display","block");


	$("#box-shopping > ul").tabs();

	$("#box-home-video > ul").tabs();

	$("#agenda_v10 > ul").tabs();

	$("#box-viaggi > ul").tabs();

	//$("#box-viaggi-home-cor > ul").tabs({ event: 'mouseover' });  COMMENTATO FINO AL 06/08/2010
	
    //DOPO IL 6 AGOSTO 2010 MODIFICARE IN #box-viaggi-home-cor
	 /*$("#box-viaggi-home-cor-single >ul >li >a").bind("click", function(){
		location.href = $("#" + $(this).attr("href").split("#")[1] + " a:first").attr("href");
		return false;
	});*/

	$("#box-tempo > ul").tabs();

	$("#box-dizionari > ul").tabs();

	$("#trovocinema-tabs > ul").tabs();

	$("#player_tabs > ul").tabs();
	$("#tabs_container > ul").tabs();

	$("#info_box_tabs > ul").tabs();

	$("#box-dizionari-compact > ul").tabs();

	$("#box-news > ul").tabs();

	$("#allwebsites").change(function(){

		var loc=$(this).attr("value");

		if(loc!=null){

			document.location.href=loc;

		}

	});

	var offset=0;

	var paginazione=5;

	var totale=$("#corriere-tv-mid ul.corriere-tv-bottom li").length;

	$("#corriere-tv-mid ul.corriere-tv-bottom li").slice(offset,offset+paginazione).show();

	$("#corriere-tv-mid ul.corriere-tv-bottom li:visible:last").addClass("last");

	$('#mycarousel-next').bind('click',function(){

		offset=offset+paginazione;

		if(offset+paginazione>totale){offset=totale-paginazione;}

		$("#corriere-tv-mid ul.corriere-tv-bottom li:visible").hide().removeAttr("class");

		$("#corriere-tv-mid ul.corriere-tv-bottom li").slice(offset,offset+paginazione).show();

		$("#corriere-tv-mid ul.corriere-tv-bottom li:visible:last").addClass("last");

		return false;

	});

	$('#mycarousel-prev').bind('click',function(){

		offset=offset-paginazione;

		if(offset<0){offset=0;}

		$("#corriere-tv-mid ul.corriere-tv-bottom li:visible").hide().removeAttr("class");

		$("#corriere-tv-mid ul.corriere-tv-bottom li").slice(offset,offset+paginazione).show();

		$("#corriere-tv-mid ul.corriere-tv-bottom li:visible:last").addClass("last");

		return false;

	});

	function Aggiorna_frecce(){

		var li_restanti_big=0;

		try{

			li_restanti_big=totale_big-offset_big;

		}

		catch(r){

			li_restanti_big=offset_big;

		}

		if(offset_big==0){

			$("#mycarousel-prev_new").css({

				cursor:"default",

				opacity:"0.5",

				filter:"alpha(opacity=50)"

			});

			if(totale_big>6){

				$("#mycarousel-next_new").css({

				cursor:"pointer"});

			}

			else{

				$("#mycarousel-next_new").css({

					cursor:"default",

					opacity:"0.5",

					filter:"alpha(opacity=50)"

				});

			}

		}

		else{

			$("#mycarousel-prev_new").css({cursor:"pointer"});

			$("#mycarousel-prev_img").attr("src","http://images.corriere.it/images/precedente_att.gif");

			if(li_restanti_big>6){

				$("#mycarousel-next_new").css({cursor:"pointer"});

			$("#mycarousel-next_img").attr("src","http://images.corriere.it/images/successive_att.gif");}

			else{

				$("#mycarousel-next_new").css({cursor:"default"});

			$("#mycarousel-next_img").attr("src","http://images.corriere.it/images/successive_dis.gif");}

		}

	}

	if($("#corriere-tv-mid_new").length!=0){

		var offset_big=0;

		var paginazione_big=6;

		var totale_big=$("#corriere-tv-mid_new ul.corriere-tv-bottom_new li").length;

		Aggiorna_frecce();

		$("#corriere-tv-mid_new ul.corriere-tv-bottom_new li").slice(offset_big,offset_big+paginazione_big).show();

		$("#corriere-tv-mid_new ul.corriere-tv-bottom_new li:visible:last").addClass("last");

		$('#mycarousel-next_new').bind('click',function(){

			offset_big=offset_big+paginazione_big;

			if(offset_big+paginazione_big>totale_big){offset_big=totale_big-paginazione_big;}

			Aggiorna_frecce();

			$("#corriere-tv-mid_new ul.corriere-tv-bottom_new li:visible").hide().removeAttr("class");

			$("#corriere-tv-mid_new ul.corriere-tv-bottom_new li").slice(offset_big,offset_big+paginazione_big).show();

			$("#corriere-tv-mid_new ul.corriere-tv-bottom_new li:visible:last").addClass("last");

			return false;

		});

		$('#mycarousel-prev_new').bind('click',function(){

			offset_big=offset_big-paginazione_big;

			if(offset_big<0){offset_big=0;}

			Aggiorna_frecce();

			$("#corriere-tv-mid_new ul.corriere-tv-bottom_new li:visible").hide().removeAttr("class");

			$("#corriere-tv-mid_new ul.corriere-tv-bottom_new li").slice(offset_big,offset_big+paginazione_big).show();

			$("#corriere-tv-mid_new ul.corriere-tv-bottom_new li:visible:last").addClass("last");

			return false;

	});}

	function Aggiorna_frecce_small(){

		var li_restanti_sm=0;

		try{

			li_restanti_sm=totale_sm-offset_sm;

		}

		catch(r){

			li_restanti_sm=offset_sm;

		}

		if(offset_sm==0){

			$("#mycarousel-prev_new").css({cursor:"default",opacity:"0.50",filter:"alpha(opacity=50)"});

			if(totale_sm>4){

				$("#mycarousel-next_new").css({cursor:"pointer",opacity:"1",filter:"alpha(opacity=100)"});

			}

			else{

				$("#mycarousel-next_new").css({cursor:"default",opacity:"0.50",filter:"alpha(opacity=50)"});

			}

		}

		else{

			$("#mycarousel-prev_new").css({cursor:"pointer",opacity:"1",filter:"alpha(opacity=100)"});

			if(li_restanti_sm>4){

				$("#mycarousel-next_new").css({cursor:"pointer",opacity:"1",filter:"alpha(opacity=100)"});

			}

			else{

				$("#mycarousel-next_new").css({cursor:"default",opacity:"0.50",filter:"alpha(opacity=50)"});

			}

		}

	}

	if($("#corriere-tv-mid_small").length!=0){

		var offset_sm=0;

		var paginazione_sm=4;

		var totale_sm=$("#corriere-tv-mid_small ul.corriere-tv-bottom_new li").length;

		Aggiorna_frecce_small();

		$("#corriere-tv-mid_small ul.corriere-tv-bottom_new li").slice(offset_sm,offset_sm+paginazione_sm).show();

		$("#corriere-tv-mid_small ul.corriere-tv-bottom_new li:visible:last").addClass("last");

		$('#mycarousel-next_new').bind('click',function(){

			offset_sm=offset_sm+paginazione_sm;

			if(offset_sm+paginazione_sm>totale_sm){offset_sm=totale_sm-paginazione_sm;}

			Aggiorna_frecce_small();

			$("#corriere-tv-mid_small ul.corriere-tv-bottom_new li:visible").hide().removeAttr("class");

			$("#corriere-tv-mid_small ul.corriere-tv-bottom_new li").slice(offset_sm,offset_sm+paginazione_sm).show();

			$("#corriere-tv-mid_small ul.corriere-tv-bottom_new li:visible:last").addClass("last");

			return false;

		});

		$('#mycarousel-prev_new').bind('click',function(){

			offset_sm=offset_sm-paginazione_sm;

			if(offset_sm<0){offset_sm=0;}

			Aggiorna_frecce_small();

			$("#corriere-tv-mid_small ul.corriere-tv-bottom_new li:visible").hide().removeAttr("class");

			$("#corriere-tv-mid_small ul.corriere-tv-bottom_new li").slice(offset_sm,offset_sm+paginazione_sm).show();

			$("#corriere-tv-mid_small ul.corriere-tv-bottom_new li:visible:last").addClass("last");

			return false;

		});

	}

	if($("#corriere-motori-mid_small").length!=0){

		var offset_sm=0;

		var paginazione_sm=4;

		var totale_sm=$("#corriere-motori-mid_small ul.corriere-tv-bottom_new li").length;

		Aggiorna_frecce_small();

		$("#corriere-motori-mid_small ul.corriere-tv-bottom_new li").slice(offset_sm,offset_sm+paginazione_sm).show();

		$("#corriere-motori-mid_small ul.corriere-tv-bottom_new li:visible:last").addClass("last");

		$('#mycarousel-next_new').bind('click',function(){

			offset_sm=offset_sm+paginazione_sm;

			if(offset_sm+paginazione_sm>totale_sm){offset_sm=totale_sm-paginazione_sm;}

			Aggiorna_frecce_small();

			$("#corriere-motori-mid_small ul.corriere-tv-bottom_new li:visible").hide().removeAttr("class");

			$("#corriere-motori-mid_small ul.corriere-tv-bottom_new li").slice(offset_sm,offset_sm+paginazione_sm).show();

			$("#corriere-motori-mid_small ul.corriere-tv-bottom_new li:visible:last").addClass("last");

			return false;

		});

		$('#mycarousel-prev_new').bind('click',function(){

			offset_sm=offset_sm-paginazione_sm;

			if(offset_sm<0){offset_sm=0;}

			Aggiorna_frecce_small();

			$("#corriere-motori-mid_small ul.corriere-tv-bottom_new li:visible").hide().removeAttr("class");

			$("#corriere-motori-mid_small ul.corriere-tv-bottom_new li").slice(offset_sm,offset_sm+paginazione_sm).show();

			$("#corriere-motori-mid_small ul.corriere-tv-bottom_new li:visible:last").addClass("last");

			return false;

		});

	}

	function Aggiorna_frecce_auto(tipo_vaschetta,num_elementi,id_frecce_prev,id_frecce_next){

		var li_restanti_sm_v=0;

		var li_restanti_sm_f=0;

		try{

			li_restanti_sm_v=totale_sm_v-offset_sm_v;

			li_restanti_sm_f=totale_sm_f-offset_sm_f;

}

catch(r){

	li_restanti_sm_v=offset_sm_v;

	li_restanti_sm_f=offset_sm_f;

}

if(tipo_vaschetta==0){

	if(offset_sm_v==0){

		$(id_frecce_prev).css({cursor:"default",opacity:"0.50",filter:"alpha(opacity=50)"});

		if(totale_sm_v>num_elementi){

			$(id_frecce_next).css({cursor:"pointer",opacity:"1",filter:"alpha(opacity=100)"});

		}

		else{

			$(id_frecce_next).css({cursor:"default",opacity:"0.50",filter:"alpha(opacity=50)"});

		}

		}

		else{

			$(id_frecce_prev).css({cursor:"pointer",opacity:"1",filter:"alpha(opacity=100)"});

			if(li_restanti_sm_v>num_elementi){

				$(id_frecce_next).css({cursor:"pointer",opacity:"1",filter:"alpha(opacity=100)"});

			}

			else{

				$(id_frecce_next).css({cursor:"default",opacity:"0.50",filter:"alpha(opacity=50)"});

			}

		}

}

if(tipo_vaschetta==1){

	if(offset_sm_f==0){

		$(id_frecce_prev).css({cursor:"default",opacity:"0.50",filter:"alpha(opacity=50)"});

		if(totale_sm_f>num_elementi){

			$(id_frecce_next).css({cursor:"pointer",opacity:"1",filter:"alpha(opacity=100)"});

		}

		else{

			$(id_frecce_next).css({cursor:"default",opacity:"0.50",filter:"alpha(opacity=50)"});

		}

	}

	else{

		$(id_frecce_prev).css({cursor:"pointer",opacity:"1",filter:"alpha(opacity=100)"});

		if(li_restanti_sm_f>num_elementi){

			$(id_frecce_next).css({cursor:"pointer",opacity:"1",filter:"alpha(opacity=100)"});

		}

		else{

			$(id_frecce_next).css({cursor:"default",opacity:"0.50",filter:"alpha(opacity=50)"});

		}

	}

}

}

if($("#corriere-motori-slim-slv").length!=0){

	var id_button_prev_v="#mycarousel-prev_slv";

	var id_button_next_v="#mycarousel-next_slv";

	var offset_sm_v=0;

	var paginazione_sm_v=6;

	var totale_sm_v=$("#corriere-motori-slim-slv ul.corriere-tv-bottom_new li").length;

	Aggiorna_frecce_auto(0,paginazione_sm_v,id_button_prev_v,id_button_next_v);

	$("#corriere-motori-slim-slv ul.corriere-tv-bottom_new li").slice(offset_sm_v,offset_sm_v+paginazione_sm_v).show();

	$("#corriere-motori-slim-slv ul.corriere-tv-bottom_new li:visible:last").addClass("last");

	carica_title_video();

	$('#mycarousel-next_slv').bind('click',function(){

		offset_sm_v=offset_sm_v+paginazione_sm_v;

		if(offset_sm_v+paginazione_sm_v>totale_sm_v){offset_sm_v=totale_sm_v-paginazione_sm_v;}

		Aggiorna_frecce_auto(0,paginazione_sm_v,id_button_prev_v,id_button_next_v);

		$("#corriere-motori-slim-slv ul.corriere-tv-bottom_new li:visible").hide().removeAttr("class");

		$("#corriere-motori-slim-slv ul.corriere-tv-bottom_new li").slice(offset_sm_v,offset_sm_v+paginazione_sm_v).show();

		$("#corriere-motori-slim-slv ul.corriere-tv-bottom_new li:visible:last").addClass("last");

		carica_title_video();

		return false;

	});

	$('#mycarousel-prev_slv').bind('click',function(){

		offset_sm_v=offset_sm_v-paginazione_sm_v;

		if(offset_sm_v<0){offset_sm_v=0;}

		Aggiorna_frecce_auto(0,paginazione_sm_v,id_button_prev_v,id_button_next_v);

		$("#corriere-motori-slim-slv ul.corriere-tv-bottom_new li:visible").hide().removeAttr("class");

		$("#corriere-motori-slim-slv ul.corriere-tv-bottom_new li").slice(offset_sm_v,offset_sm_v+paginazione_sm_v).show();

		$("#corriere-motori-slim-slv ul.corriere-tv-bottom_new li:visible:last").addClass("last");

		carica_title_video();

		return false;

	});

}

function carica_title_foto(){

	var img_src_motori=$("#corriere-motori-slim-slf ul.corriere-tv-bottom_new li:visible img");

	for(var i_motori=0;i_motori<img_src_motori.length;i_motori++){

		var arg_motori=img_src_motori[i_motori];

		$(arg_motori).attr("src",$(arg_motori).attr("title"));

	}

}

function carica_title_video(){

	var img_src_motori=$("#corriere-motori-slim-slv ul.corriere-tv-bottom_new li:visible img");

	for(var i_motori=0;i_motori<img_src_motori.length;i_motori++){

		var arg_motori=img_src_motori[i_motori];

		$(arg_motori).attr("src",$(arg_motori).attr("title"));

	}

}

if($("#corriere-motori-slim-slf").length!=0){

	var id_button_prev_f="#mycarousel-prev_slf";

	var id_button_next_f="#mycarousel-next_slf";

	var offset_sm_f=0;

	var paginazione_sm_f=6;

	var totale_sm_f=$("#corriere-motori-slim-slf ul.corriere-tv-bottom_new li").length;

	Aggiorna_frecce_auto(1,paginazione_sm_f,id_button_prev_f,id_button_next_f);

	$("#corriere-motori-slim-slf ul.corriere-tv-bottom_new li").slice(offset_sm_f,offset_sm_f+paginazione_sm_f).show();

	$("#corriere-motori-slim-slf ul.corriere-tv-bottom_new li:visible:last").addClass("last");

	carica_title_foto();

	$('#mycarousel-next_slf').bind('click',function(){

		offset_sm_f=offset_sm_f+paginazione_sm_f;

		if(offset_sm_f+paginazione_sm_f>totale_sm_f){offset_sm_f=totale_sm_f-paginazione_sm_f;}

		Aggiorna_frecce_auto(1,paginazione_sm_f,id_button_prev_f,id_button_next_f);

		$("#corriere-motori-slim-slf ul.corriere-tv-bottom_new li:visible").hide().removeAttr("class");

		$("#corriere-motori-slim-slf ul.corriere-tv-bottom_new li").slice(offset_sm_f,offset_sm_f+paginazione_sm_f).show();

		$("#corriere-motori-slim-slf ul.corriere-tv-bottom_new li:visible:last").addClass("last");

		carica_title_foto();

		return false;

	});

	$('#mycarousel-prev_slf').bind('click',function(){

		offset_sm_f=offset_sm_f-paginazione_sm_f;

		if(offset_sm_f<0){offset_sm_f=0;}

		Aggiorna_frecce_auto(1,paginazione_sm_f,id_button_prev_f,id_button_next_f);

		$("#corriere-motori-slim-slf ul.corriere-tv-bottom_new li:visible").hide().removeAttr("class");

		$("#corriere-motori-slim-slf ul.corriere-tv-bottom_new li").slice(offset_sm_f,offset_sm_f+paginazione_sm_f).show();

		$("#corriere-motori-slim-slf ul.corriere-tv-bottom_new li:visible:last").addClass("last");

		carica_title_foto();

		return false;

	});

}

function Aggiorna_frecce_small(){

	var li_restanti_sm=0;

	try{

		li_restanti_sm=totale_sm-offset_sm;

	}

	catch(r){

		li_restanti_sm=offset_sm;

	}

	if(offset_sm==0){

		$("#mycarousel-prev_new").css({cursor:"default",opacity:"0.50",filter:"alpha(opacity=50)"});

		if(totale_sm>3){

			$("#mycarousel-next_new").css({cursor:"pointer",opacity:"1",filter:"alpha(opacity=100)"});

		}

		else{

			$("#mycarousel-next_new").css({cursor:"default",opacity:"0.50",filter:"alpha(opacity=50)"});

		}

	}

	else{

		$("#mycarousel-prev_new").css({cursor:"pointer",opacity:"1",filter:"alpha(opacity=100)"});

		if(li_restanti_sm>3){

			$("#mycarousel-next_new").css({cursor:"pointer",opacity:"1",filter:"alpha(opacity=100)"});

		}

		else{

			$("#mycarousel-next_new").css({cursor:"default",opacity:"0.50",filter:"alpha(opacity=50)"});

		}

	}

}

if($("#vaschetta-ibm").length!=0){

	var offset_sm=0;

	var paginazione_sm=3;

	var totale_sm=$("#vaschetta-ibm ul.vaschetta-ibm-bottom li").length;

	Aggiorna_frecce_small();

	$("#vaschetta-ibm ul.vaschetta-ibm-bottom li").slice(offset_sm,offset_sm+paginazione_sm).show();

	$("#vaschetta-ibm ul.vaschetta-ibm-bottom li:visible:last").addClass("last");

	$('#mycarousel-next_new').bind('click',function(){

		offset_sm=offset_sm+paginazione_sm;

		if(offset_sm+paginazione_sm>totale_sm){offset_sm=totale_sm-paginazione_sm;}

		Aggiorna_frecce_small();

		$("#vaschetta-ibm ul.vaschetta-ibm-bottom li:visible").hide().removeAttr("class");

		$("#vaschetta-ibm ul.vaschetta-ibm-bottom li").slice(offset_sm,offset_sm+paginazione_sm).show();

		$("#vaschetta-ibm ul.vaschetta-ibm-bottom li:visible:last").addClass("last");

		return false;

	});

	$('#mycarousel-prev_new').bind('click',function(){

		offset_sm=offset_sm-paginazione_sm;

		if(offset_sm<0){offset_sm=0;}

		Aggiorna_frecce_small();

		$("#vaschetta-ibm ul.vaschetta-ibm-bottom li:visible").hide().removeAttr("class");

		$("#vaschetta-ibm ul.vaschetta-ibm-bottom li").slice(offset_sm,offset_sm+paginazione_sm).show();

		$("#vaschetta-ibm ul.vaschetta-ibm-bottom li:visible:last").addClass("last");

		return false;

	});

}

var d=$("#media-daytop ul").attr("class");

$("#ctv-"+d).addClass("active");

$("#media-daytop ul li").click(function(){

	$("#media-daytop .go-ctv").addClass("hide");

	var sel=$(this).attr("id").substring(4);

	$("#media-daytop ul li").removeClass("active");

	$(this).addClass("active");

	$("#media-daytop .cap, #media-daytop .preview").addClass("hide");

	$("#"+sel+"top-caption, #daily-"+sel).removeClass("hide");

	if(sel=="video"){

		$("#media-daytop .go-ctv").removeClass("hide");

	}

	return false;

});


$("#smaller-text").click(function(){
	var size=parseInt($(".article p").css("font-size"))-2+"px";
	if(parseInt(size)>=10){
		$(".article p").css("font-size",size);
	}
	return false;
});

$("#bigger-text").click(function(){
	var size=parseInt($(".article p").css("font-size"))+2+"px";
	if(parseInt(size)<26){
		$(".article p").css("font-size",size);
	}
	return false;
});

$("#form-sondaggio > button[type='button']").click(function(){

	var url=$("#form-sondaggio").attr("action");

	var destinaz=url.indexOf('/appsSondaggi/pages/corriere/d_')+31;

	var id_sond=url.substring(destinaz,destinaz+4);

	location="http://www.corriere.it/appsSondaggi/votazioneDispatch.do?method=risultati&idSondaggio="+id_sond;

});


$("#searchtool").submit(function(){

	var search=$.trim($("#searchtool > #search_val").attr("value"));

	if(search.length==0){

		alert("Inserire un criterio di ricerca");

		return false;

	}

	return true;

});

try {
	$("#col-sx table[width='95%']").addClass("clear");
} catch (e) {}

$("#box-trovolavoro-casa-auto a.tab-casa").click(function(){

	initForm();

	viewField();

});

$("#box-trovolavoro-casa-auto-cor a.tab-casa").click(function(){

	initForm();

	viewField();

});

$('#col-sx div.article ul.toolbar li.macro-section').click(function(){

	if($("#col-sx div.article ul.toolbar li.macro-section a").attr('href')){

		window.location.href=$("#col-sx div.article ul.toolbar li.macro-section a").attr('href')

	}

});

if(($.browser.mozilla)||($.browser.opera)){

}else{

	$("ul.italiaoggi li:last").css({backgroundImage:"none"});

}

$("div#col-sx > a > img:first").addClass("pushbar-bare-img");

if(($.browser.msie)&&((navigator.userAgent.indexOf("MSIE 6.0")!=-1))){

	$("#main").removeClass("clearfix").addClass("clearfix");

}

var nuova_finestra=null;

function closeWin(){

	if(nuova_finestra!=null){

		if(!nuova_finestra.closed)

			nuova_finestra.close();

	}

}

function popUpWin(url,type,strWidth,strHeight){

	closeWin();

	type=type.toLowerCase();

	if(type=="full-screen"){

		strWidth=screen.availWidth;

		strHeight=screen.availHeight;

	}

	var tools="";

	if(type=="standard")tools="resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";

	if(type=="console"||type=="fullscreen")tools="resizable,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=0,top=0";

	nuova_finestra=window.open(url,'nuova_finestra',tools);

	nuova_finestra.focus();

}

$("a[rel*=popup]")

.click(function(){

	var t="standard";

	var w="780";

	var h="580";

	attribs=$(this).attr("rel").split(" ");

	if(attribs[1]!=null){t=attribs[1];}

	if(attribs[2]!=null){w=attribs[2];}

	if(attribs[3]!=null){h=attribs[3];}

	popUpWin($(this).attr("href"),t,w,h);

	return false;

})

.each(function(){

	if($(this).attr("rel").indexOf("noicon")==-1){

		$(this).addClass("new-window").attr("title",$(this).attr("title")+"  [Apre una nuova finestra]");

	}

});

$("#box-trovolavoro-casa-auto").css("display","block");

$("a[rel*=expand_li]")
	.each(function() {
		var destinazioneLink = $(this).attr("href");
		var target_var = $(this).attr("target");
		var cliccato=0;
		$(this).unbind("click").click(function() {
                                       cliccato=1;
			})
			.parents("li:eq(0)")
			.unbind("click")
			.click( function() {
				if(cliccato==0){
					if(target_var=="_blank") window.open(destinazioneLink,'sponsor');
					else window.location = destinazioneLink;
				}
				cliccato=0;
			})
			.hover(function () {
				$(this).css({ cursor: "pointer" });
			}, function () {
				$(this).css({ cursor: "default" });
		});
});


});
	var lnk_rullo_notizie ="";
function getNews(){

	if(lnk_rullo_notizie){
		$.ajax({
			type:"GET",
			url:"/notizie-ultima-ora/"+lnk_rullo_notizie,
			dataType:"xml",
			success:function(xml){
				var testo="";
				if($(xml).find('notizia').length > 0){
				$(xml).find('notizia').each(function(){
					var id_text=$(this).attr('id')
					var titolo_text=$(this).find('titolo').text()
					var data_text=$(this).find('data').text()
					var url_text=$(this).find('url').text()
					var section_text=$(this).find('categoria').text()
					var ora_text=$(this).find('ora').text()
					testo+='<li class="nota-flash">';
					testo+='<a href="http://www.corriere.it'+url_text+'"><span class="time-flash">'+ora_text+'</span>&nbsp;|&nbsp;';
					testo+='<span class="testo-flash">'+titolo_text+'</span>';
					testo+='</a>'
					testo+='</li>'
				});
				$('#pane1 > ul').remove();
				$('#pane1').append($('<ul></ul>').html(testo)).jScrollPane({showArrows:false,scrollbarWidth:18,dragMaxHeight:15});
				if(($.browser.msie)&&((navigator.userAgent.indexOf("Windows NT 5.0")!=-1)||(navigator.userAgent.indexOf("Windows NT 5.01")!=-1))){
					$("#main").removeClass("clearfix").addClass("clearfix");
				}
				}
				else {
          lnk_rullo_notizie = "news_hp_corsera.xml";
          getNews();
        }
			}
		});

	}
}

//news dichiarazione redditi
  function getNewsEconomia(){

	var lnk=$("#newseconomia").attr('name');
	if(lnk){
		$.ajax({
			type:"GET",
			url:"/economia/dichiarazione_redditi/"+lnk,
			dataType:"xml",
			success:function(xml){
				var testo="";

				$(xml).find('DOC').each(function(){

					var url_text=$(this).find('ALLEGATO').attr('href');
					var estensione=$(this).find('ALLEGATO').attr('tipofile');
					var section_text=$(this).find('categoria').text()
					var ora_text=$(this).find('ora').text()
					var titolo=$(this).find('TITOLO').text()
					var fonte=$(this).find('FONTE').text()
					var data=$(this).find('VISIBILE_DA').text()

					testo+='<li class="nota-flash">';
					testo+='<img src="/economia/dichiarazione_redditi/'+estensione+'.gif" /><a href="/Primo_Piano/Economia/ipsoa/2009/'+estensione+'/'+url_text+'" target="_blank"><span class="time-flash">'+data+'</span></a>&nbsp;|&nbsp;';
					testo+='<a href="/Primo_Piano/Economia/ipsoa/2009/'+estensione+'/'+url_text+'" target="_blank"><span class="luogo-flash">'+titolo+' |</span></a>';
					testo+='<span class="testo-flash">'+fonte+'</span>';
					testo+='</li>'

				});

				$('#pane1 > ul').remove();

				$('#pane1').append($('<ul></ul>').html(testo)).jScrollPane({showArrows:false,scrollbarWidth:18,dragMaxHeight:15});

				if(($.browser.msie)&&((navigator.userAgent.indexOf("Windows NT 5.0")!=-1)||(navigator.userAgent.indexOf("Windows NT 5.01")!=-1))){

					$("#main").removeClass("clearfix").addClass("clearfix");
				}
			}
		});
		var newsTimeout=setTimeout(getNewsEconomia,30000);
	}
}


//news elezioni 2009
  function getNewsElezioni2009(){
	var lnk=$("#elezioni2009").attr('name');
	if(lnk){
		$.ajax({
			type:"GET",
				url:"http://videochat.corriere.it/new/notizie-ultima-ora/"+lnk,
			dataType:"xml",
			success:function(xml){
				var testo="";
				$(xml).find('notizia').each(function(){

								var url_text=$(this).find('url').text()
					var ora_text=$(this).find('ora').text()
					var titolo=$(this).find('titolo').text()
					var section_text=$(this).find('testo').text()

					//var ora=ora_text.substring(ora_text.indexOf('2009',0)+4,ora_text.length-9);
					var section_text=section_text.substring(0,150) +"...";

					testo+='<li class="nota-flash">';
					testo+='<span class="time-flash">'+ora_text+'</span>&nbsp;<a href="http://www.corriere.it'+url_text+'" target="_blank"><span class="luogo-flash">'+titolo+'</span></a>';
					testo+='<br/>'
					//testo+='<a href="'+url_text+'" target="_blank"><span class="testo-flash">'+section_text+'</span></a>';
					testo+='</li>'
				});
				$('#pane1 > ul').remove();
				$('#pane1').append($('<ul></ul>').html(testo)).jScrollPane({showArrows:false,scrollbarWidth:10,dragMaxHeight:15});
				if(($.browser.msie)&&((navigator.userAgent.indexOf("Windows NT 5.0")!=-1)||(navigator.userAgent.indexOf("Windows NT 5.01")!=-1))){
					$("#main").removeClass("clearfix").addClass("clearfix");
				}
			}
		});
		var newsTimeout=setTimeout(getNewsElezioni2009,30000);
	}

}

function mcNews(id){

	document.location.href="http://www.corriere.it"+id;

}

function mcPiuVisti(pathURL){

	document.location.href=""+pathURL;

}

function mcPiuCommentati(pathURL){

	document.location.href=""+pathURL;

}

function allNews(id){

	document.location.href="/notizie-ultima-ora/index.shtml";

}


//news videochat corriere
  function getNewsvideochatCor(){
	var lnk=$("#videochatCor").attr('name');
	if(lnk){
		$.ajax({
			type:"GET",
			url:"/notizie-ultima-ora/"+lnk,
			dataType:"xml",
			success:function(xml){
				var testo="";
				$(xml).find('notizia').each(function(){

					var url_text=$(this).find('url').text()
					var ora_text=$(this).find('ora').text()
					var titolo=$(this).find('titolo').text()
					var section_text=$(this).find('testo').text()

					//var ora=ora_text.substring(ora_text.indexOf('2009',0)+4,ora_text.length-9);
					var section_text=section_text.substring(0,150) +"...";

					testo+='<li class="nota-flash">';
					testo+='<span class="time-flash">'+ora_text+'</span>&nbsp;<a href="http://www.corriere.it'+url_text+'" target="_blank"><span class="luogo-flash">'+titolo+'</span></a>';
					testo+='<br/>'
					//testo+='<a href="'+url_text+'" target="_blank"><span class="testo-flash">'+section_text+'</span></a>';
					testo+='</li>'
				});
				$('#pane1 > ul').remove();
				$('#pane1').append($('<ul></ul>').html(testo)).jScrollPane({showArrows:false,scrollbarWidth:10,dragMaxHeight:15});
				if(($.browser.msie)&&((navigator.userAgent.indexOf("Windows NT 5.0")!=-1)||(navigator.userAgent.indexOf("Windows NT 5.01")!=-1))){
					$("#main").removeClass("clearfix").addClass("clearfix");
				}
			}
		});
		var newsTimeout=setTimeout(getNewsvideochatCor,30000);
	}

}

function mcNews(id){

	document.location.href="http://www.corriere.it"+id;

}

function mcPiuVisti(pathURL){

	document.location.href=""+pathURL;

}

function mcPiuCommentati(pathURL){

	document.location.href=""+pathURL;

}

function allNews(id){

	document.location.href="/notizie-ultima-ora/index.shtml";

}




search="rcsLogin=";

function verificaPWD(){

	if(document.invioPasswordForm.femail.value==""){

		alert("Inserire l'indirizzo email");

		return false;

	}

	return true;

}

function submitPWD(){

	if(verificaPWD())

		document.invioPasswordForm.submit();

}

function goSubmit(){

	document.utenteAnagFormBean.submit();

}

function popupPassword(url){

	window.open(url,"","toolbar=no,width=380,height=240,top=50,left=50,directories=no,status=no,statusbar=no,resizable=1,menubar=no,scrollbars=no");

}

function Popup2(url){

	window.open(url,"","toolbar=no,width=380,height=240,top=50,left=50,directories=no,status=no,statusbar=no,resizable=1,menubar=no,scrollbars=no");

}

function modifica(){

	document.modifica.submit();

}

function logout(){

	document.logout.submit();

}

function verifica(){

	document.login.url.value=document.location.href;

	if(document.login.username.value==""||document.login.password.value==""){

		alert("Impostare Username e Password");

		return false;

	}

	return true;

}

function logon(urlKo){

	document.login.username.value=document.loginFormBean.username.value;

	document.login.password.value=document.loginFormBean.password.value;

	document.login.urlKo.value=urlKo

	document.login.submit();

}

function submitNickname(){

	document.utenteFormBean.submit();

}

function iscrizione(){

	document.iscrizione.url.value=document.location.href;

	document.iscrizione.submit();

}

function getLoginValue(){

	var value="notFound";

	if(document.cookie.length>0){

		offset=document.cookie.indexOf(search);

		if(offset!=-1)

		{

			offset+=search.length;

			end=document.cookie.indexOf(";",offset);

			if(end==-1)

				end=document.cookie.length;

			value=document.cookie.substring(offset,end);

			if(value.indexOf("|")>-1)

				value=value.substring(0,value.indexOf("|"));

		}

	}

	return value;

}

function getIsLoginValid(){

	var value=getLoginValue();

	if(value=="notValid")

		return false;

	else

		return true;

}

function getIsCookieValid(){

	var value=""+getLoginValue();

	if(value=="notFound"||value=="undefined"||value=="notValid"){

		return false;

	}else{

		return true;

	}

}

function verifica(){

	if(document.login.username.value==""||document.login.password.value==""){

		alert("Impostare Username e Password");

		return false;

	}

	return true;

}

function formLogin(url,operation){

	document.write('<form name="login" method="post" action="http://www.corriere.it/corcommunity/accesso/VerificaLogIn.do" onsubmit="return verifica();">');

	document.write('<input type="hidden" name="contentPath" value="'+url+'">');

	document.write('<input type="hidden" name="urlKo" value="">');

	document.write('<input type="hidden" name="username">');

	document.write('<input type="hidden" name="password">');

	document.write('</form>');

}

function formLogout(){

	document.write('<form name="logout" method="post" action="http://www.corriere.it/corcommunity/accesso/LogOut.do" onsubmit="return verifica();">');

	document.write('<input type="hidden" name="contentPath" value="">');

	document.write('</form>');

}

function formModifica(){

	document.write('<form name="modifica" method="post" action="http://www.corriere.it/corcommunity/accesso/ModificaRegistrazione.do">');

	document.write('</form>');

}

function galleria(path,n_galleria){

	pathcompleta="/speciali/"+path+"/galleria/sopra.html?"+n_galleria;

	path_sin="/speciali/popup/foto.html";

	path_des="/speciali/popup/vuoto.html";

	newWin=open("","","menubar=no,location=no,toolbar=yes,status=no,scrollbars=yes,resizable=no,width=680,height=480");

	newWin.document.write('<html><head><title>Galleria di immagini</title>');

	newWin.document.write('</head>');

	newWin.document.write('<frameset rows="45,*" border="0" frameborder="NO" framespacing="0">');

	newWin.document.write('<frame src="'+pathcompleta+'" name="sopra" scrolling="NO" marginheight="5" marginwidth="5">');

	newWin.document.write('<frameset cols="120,*" border="0" frameborder="NO" framespacing="0">');

	newWin.document.write('<frame src="'+path_sin+'" name="sin">');

	newWin.document.write('<frame src="'+path_des+'" name="des">');

	newWin.document.write('</frameset></frameset>');

	newWin.document.write('<noframes><body>Per visualizzare questa pagina &egrave; necessario un browser che supporti i frames</body></noframes>');

	newWin.document.write('</html>');

}

function apriInviaPost(miourl){

	var miourl_s=miourl.split("&");

	var loc="";

	for(i in miourl_s)

		loc+=miourl_s[i]+"!*";

	loc=loc.substr(0,loc.length-2)

	tit=document.title

	prop="menubar=no,status=no,titlebar=no,toolbar=no,width=450,height=450,scrollbars=yes"

	window.open("http://www.corriere.it/cf/tellafriend/form.cfm?rr="+loc+"&tit="+tit,"InviaPagina",prop);

}

function apriInviaPagina(){

	var miourl=window.location.href;

	var miourl_s=miourl.split("&");

	var loc="";

	for(i in miourl_s)

		loc+=miourl_s[i]+"!*";

	loc=loc.substr(0,loc.length-2)

	tit=document.title

	prop="menubar=no,status=no,titlebar=no,toolbar=no,width=450,height=500,scrollbars=no"

	window.open("http://www.corriere.it/cf/tellafriend/form.cfm?rr="+loc+"&tit="+tit,"InviaPagina",prop);

}

function apriPermalinkPagina(){

	var ref=window.location.href;

	prop="menubar=no,status=no,titlebar=no,toolbar=no,width=450,height=450,scrollbars=yes"

	window.open("http://www.corriere.it/tools/includes/permalink.shtml?rr2="+ref,"PermalinkPagina",prop);

}

function galleriaN(str,str2){

	var larghezza=screen.availWidth;

	if(larghezza>=1024){

		window.open('http://www.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=670,status=no');

	}else{

		window.open('http://www.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=540,status=no');

	}

}

<!-- INIZIO COOKIE VIDEO PLAYER AKAMAI

function getCookieP(key)
{
	return key.toString();
}
function getCookie(key)
{
    var cookieValue = null;

    if (key)
    {
        var cookieSearch = key + "=";

        if (document.cookie)
        {
            var cookieArray = document.cookie.split(";");
            for (var i = 0; i < cookieArray.length; i++)
            {
                var cookieString = cookieArray[i];

                // skip past leading spaces
                while (cookieString.charAt(0) == ' ')
                {
                    cookieString = cookieString.substr(1);
                }

                // extract the actual value
                if (cookieString.indexOf(cookieSearch) == 0)
                {
                    cookieValue = cookieString.substr(cookieSearch.length);
                }
            }
        }
    }

    return cookieValue;
}

function setCookieP(key, val)
{
    if (key)
    {
        var date = new Date();

            // expires in 2 hours
            date.setTime(date.getTime() + 2*(60*60*1000));
            document.cookie = key + "=" + val + "; expires=" + date.toGMTString();


    }
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

// FINE COOKIE VIDEO PLAYER AKAMAI

function init() {



if (!document.getElementById) return

var imgOriginSrc;

var imgTemp = new Array();

var imgarr = document.getElementsByTagName('img');

for (var i = 0; i < imgarr.length; i++) {

if (imgarr[i].getAttribute('hsrc')) {

imgTemp[i] = new Image();

imgTemp[i].src = imgarr[i].getAttribute('hsrc');

imgarr[i].onmouseover = function() {

imgOriginSrc = this.getAttribute('src');

this.setAttribute('src',this.getAttribute('hsrc'))

}

imgarr[i].onmouseout = function() {

this.setAttribute('src',imgOriginSrc)

}

}

}

}

// onload=init;



function addLoadEvent(func) {

      var oldonload = window.onload;

      if (typeof window.onload != 'function') {

	      window.onload = func;

      } else {

		  window.onload = function() {

			  oldonload();

			  func();

		  }

	  }

}



addLoadEvent(init);





function Calendario(xlink){

	window.open('/Speciali/Politica/Calendario/Calendario.shtml?/Speciali/Politica/Calendario/'+xlink+'index.shtml','pp','width=750,height=520');void(0);

}

function pr99(rif){

	var largh=295;

	var hpos=screen.width-largh-20;

	var vpos=0;

	if(rif==undefined)rif='';

	mywindow=window.open('http://www.rtsi.ch/iraq/miniplayer.cfm?rif='+rif,'miniplayer','resizable=no,width=295,height=550,left='+hpos+',top=8,screenX=0,screenY=0');

}

function openlink(xlink){

	window.open("/openxlink.shtml?"+xlink,"xpage");

}

function openlink2(xlink){

	window.open("http://www.corriere.it/openxlink.shtml?"+xlink,"xpage");

}

function pr1(filename){window.open(filename,'Test1','menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,resizable=no,width=730,height=540')

}

function pr2(filename){window.open(filename,'','menubar=yes,location=no,toolbar=no,status=no,scrollbars=yes,resizable=no,width=450,height=480')}

function pr3(filename){window.open(filename,'','menubar=yes,location=yes,toolbar=no,status=no,scrollbars=yes,resizable=no,width=400,height=420')}

function pr5(nomefile,larghezza,altezza){

	parametri="menubar=no,location=no,toolbar=no,status=no,scrollbars=no,resizable=no,width="

	parametri=parametri+larghezza+",height="+altezza

	newWin=open('','',parametri)

	newWin.location.href=nomefile

}

function pr6(nomefile,larghezza,altezza){

	var pathToRemove="/Corriere della Sera";

	var lenPathToRemove=pathToRemove.length;

	if(nomefile.indexOf(pathToRemove)>-1)nomefile=nomefile.substring(lenPathToRemove);

	if(nomefile.indexOf(".xml")>-1)nomefile=nomefile.substring(0,nomefile.indexOf(".xml"))+".shtml";

	parametri="menubar=no,location=no,toolbar=no,status=no,scrollbars=yes,resizable=no,width="

	parametri=parametri+larghezza+",height="+altezza

	newWin=open('','',parametri)

	newWin.location.href=nomefile

}

function pr7(nomefile,larghezza,altezza){

	var pathToRemove="/Corriere della Sera";

	var lenPathToRemove=pathToRemove.length;

	if(nomefile.indexOf(pathToRemove)>-1)nomefile=nomefile.substring(lenPathToRemove);

	if(nomefile.indexOf(".xml")>-1)nomefile=nomefile.substring(0,nomefile.indexOf(".xml"))+".shtml";

	parametri="menubar=no,location=no,toolbar=no,status=no,scrollbars=no,resizable=no,width="

	parametri=parametri+larghezza+",height="+altezza

	newWin=open('','',parametri)

	newWin.location.href=nomefile

}

/*

function pr4(nomefile,larghezza,altezza){

	var pathToRemove="/Corriere della Sera";

	var lenPathToRemove=pathToRemove.length;

	if(nomefile.indexOf(pathToRemove)>-1)nomefile=nomefile.substring(lenPathToRemove);

	if(nomefile.indexOf(".xml")>-1)nomefile=nomefile.substring(0,nomefile.indexOf(".xml"))+".shtml";

	parametri="menubar=no,location=yes,toolbar=yes,status=no,scrollbars=yes,resizable=yes,width="

	parametri=parametri+larghezza+",height="+altezza

	newWin=open('','',parametri)

	newWin.location.href=nomefile

}*/

/*FUNZIONE POP UP UNIVERSALE*/

function pr4(nomefile,larghezza,altezza) {

if (nomefile.indexOf("/Corriere della Sera") > -1)

{

	pathToRemove = "/Corriere della Sera";

    urlPrefix = "http://www.corriere.it";

}



if (nomefile.indexOf("/Corriere della Sera") == -1)

{

	pathToRemove = "";

    urlPrefix = "";

}

if (nomefile.indexOf("/Roma/") > -1)

{


	 pathToRemove = "/Roma";

    urlPrefix = "http://roma.corriere.it";

}

if (nomefile.indexOf("/ViviMilano") > -1)

{

	pathToRemove = "/ViviMilano";

	urlPrefix = "";

}



var lenPathToRemove = pathToRemove.length;

if (nomefile.indexOf(pathToRemove) > -1) nomefile = nomefile.substring(lenPathToRemove);

if (nomefile.indexOf(".xml") > -1)  nomefile = nomefile.substring(0, nomefile.indexOf(".xml")) + ".shtml";

                parametri="menubar=no,location=yes,toolbar=yes,status=no,scrollbars=yes,resizable=yes,width="

                parametri=parametri+larghezza+",height="+altezza

                newWin=open('','',parametri)

                newWin.location.href=urlPrefix+nomefile

}



function gall(str){

	finestra=window.open('http://www.corriere.it/gallery/'+str+'/?1','gallery','width=870,height=650,status=no');

	if(window.focus){

		finestra.focus()

	}

}

function galleriaN(str,str2){

	var larghezza=screen.availWidth;

	if(larghezza>=1024){

		if(str=="Campania") {

			window.open('http://corrieredelmezzogiorno.corriere.it/campania/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=670,status=no');

		}

		else {

		window.open('http://www.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=670,status=no');

		}

	}

	else {

		if(str=="Campania") {

			window.open('http://corrieredelmezzogiorno.corriere.it/campania/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=540,status=no');

		} else {

			window.open('http://www.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=540,status=no');

	}

	}

}



function galleriaVN(str,str2){

	var larghezza=screen.availWidth;

	if(larghezza>=1024){

		if(str=="Milano") {

			window.open('http://milano.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=670,status=no');

		}

		else {

			window.open('http://corrierefiorentino.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=670,status=no');

		}

	}else{

		if(str=="Milano") {

			window.open('http://milano.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=540,status=no');

		}

		else {

			window.open('http://corrierefiorentino.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=540,status=no');

		}



	}

}

function galleriaRM(str,str2){

	var larghezza=screen.availWidth;

	if(larghezza>=1024){

			window.open('http://roma.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=670,status=no');

	}

	else{

			window.open('http://roma.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=540,status=no');

	}

}

function galleriaME(str,str2){

	var larghezza=screen.availWidth;

	if(larghezza>=1024){

			window.open('http://corrieredelmezzogiorno.corriere.it/campania/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=670,status=no');

	}

	else{

			window.open('http://corrieredelmezzogiorno.corriere.it/campania/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=540,status=no');

	}

}

function galleriaFI(str,str2){

	var larghezza=screen.availWidth;

	if(larghezza>=1024){

			window.open('http://corrierefiorentino.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=670,status=no');

	}

	else{

			window.open('http://corrierefiorentino.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=540,status=no');

	}

}

function galleriaBO(str,str2){

	var larghezza=screen.availWidth;

	if(larghezza>=1024){

			window.open('http://corrieredibologna.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=670,status=no');

	}

	else{

			window.open('http://corrieredibologna.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=540,status=no');

	}

}

function galleriaVE(str,str2){

	var larghezza=screen.availWidth;

	if(larghezza>=1024){

			window.open('http://corrieredelveneto.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=670,status=no');

	}

	else{

			window.open('http://corrieredelveneto.corriere.it/gallery/'+str+'/vuoto.shtml?'+str2+'','gallery','width=740,height=540,status=no');

	}

}

function getParameter_uuid(whichOne){

	var r="";

	if(whichOne!=null){

		var tp=new Array();

		tp=whichOne.split('=');

		r=unescape(tp[1].replace(/\+/g," "));

	}

	return r;

}

function getParameter_url(whichOne){

	var pairs=location.search.substring(1).split('&');

	var r="";

	var tp=new Array();

	for(var i=0;i<pairs.length;i++){

		tp=pairs[i].split('=');

		if(whichOne==tp[0])

			r=unescape(tp[1].replace(/\+/g," "));

	}

	return r;

}

function flash(id,src,w,h,flashVersion,flashVars){

	document.write(

	getFlashObject(

	id,

	src,

	w,

	h,

	flashVersion,

	flashVars

	)

	);

}

function getFlashObject(id,src,w,h,flashVersion,flashVars){

	var flash=

	'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+

	'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+flashVersion+'" '+

	'width="'+w+'" '+

	'height="'+h+'">'+

	'<param name="allowScriptAccess" value="sameDomain" />'+

	'<param name="allowFullScreen" value="true" />'+

	'<param name="movie" value="'+src+'" />'+

	'<param name="quality" value="high" />'+

	'<param name="bgcolor" value="#ffffff" />'+

	'<param name="salign" value="t" />'+

	'<param name="FlashVars" value="'+flashVars+'" />'+

	'<embed src="'+src+'" '+

	'quality="high" '+

	'bgcolor="#ffffff" '+

	'width="'+w+'" '+

	'height="'+h+'" '+

	'name="'+id+'" '+

	'align="middle" '+

	'salign="t" '+

	'allowScriptAccess="sameDomain" '+

	'allowFullScreen="true" '+

	'type="application/x-shockwave-flash" '+

	'pluginspage="http://www.macromedia.com/go/getflashplayer"'+

	'FlashVars="'+flashVars+'"/>'+

	'</object>';

	return flash;

}

function carica_flash_motori(uuid){

	var flashVars="sezione=motori_piu_visti";

	var chiaveFlash=new Date();

	if(uuid!=null)flashVars+="&uuid="+uuid;

	flashVars+='&testata=COL';

	flashVars+='&cssPath='+escape('http://www.corriere.it/motori/');

	flashVars+='&numRisultati=5';

	flashVars+='&chiaveFlash='+chiaveFlash.getTime();

	flashVars+='&screenW='+screen.availWidth;

	flashVars+='&screenH='+screen.availHeight;

	$("#mc-player-motori")[0].innerHTML=getFlashObject("mc-player-motori-flv","playerMotori.swf","620px","328px","9",flashVars);

}

function carica_href_video_mc(){

	var video_motori_mc=$("#corriere-motori-slim-slv ul.corriere-tv-bottom_new a");

	for(var i_motori_mc=0;i_motori_mc<video_motori_mc.length;i_motori_mc++){

		var arg_motori_mc=video_motori_mc[i_motori_mc];

		var href_mc_uuid=getParameter_uuid($(arg_motori_mc).attr("href"));

		var new_j_href_mc="javascript:carica_flash_motori('"+href_mc_uuid+"')";

		$(arg_motori_mc).attr("href",new_j_href_mc);

	}

}



$(document).ready(function(){

	if($("#mc-player-motori").length>0){

		carica_href_video_mc();

		var uuid="";

		uuid=getParameter_url("uuid");

		carica_flash_motori(uuid);

	}





});



// Slide Down per Accordion Elezioni 2008



$(document).ready(function(){



$("#accordion-vaschetta-bottom a").click(function () {

  if ($("#accordion-floating-cont:first").is(":hidden")) {

	$("#accordion-floating-cont").slideDown("normal");

	$("#accordion-vaschetta-bottom").addClass("vaschetta-open");

	return false;

  } else {

	$("#accordion-floating-cont").hide();

	$("#accordion-vaschetta-bottom").removeClass("vaschetta-open");

	return false;

  }

});

});

function mycarousel_initCallback(){
  jQuery('.carosello-article').css("opacity","1");
  jQuery('.carosello-article').css("filter","alpha(opacity=100)");
}
$(document).ready(function(){
  jQuery('.article-carousel').jcarousel({
          initCallback:   mycarousel_initCallback
      });

// GALLERIA ARTICOLO
			$('.gallery_slide_new').cycle({ fx: 'scrollLeft' });
			$('.gallery_slide_new img').each(function (i) {
				//alert($(this).height());
				if ($(this).height() < $('.gallery_slide_new').height()) {
					var margin_top = ($('.gallery_slide_new').height() - $(this).height()) / 2;
					$(this).css('margin-top', margin_top);
				}
			});
});
// COMBO FOOTER: NASCONDE IL BUTTON SUBMIT

$(document).ready(function(){

$("#allwebsites_vai").css('display','none');

$("#footer .websites").css('right','40px');







});



//allineo le immagini della galleria del cncorso viaggi

$("#diario-video-pagina .box-img-140 img").each(function(){

 var top = (140 - $(this).height() ) / 2;

    $(this).css('margin-top', top);

})



// LINK ARCHIVIO PER MESE DI CONSULTAZIONE

$(function() {

	var mesi = ["gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno", "luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre"];

	$(".linkNotizie").click(function () {

		var url = $(this).attr("href");

		var pclass = $(this).attr("class");

		var numPage = pclass.substring(12);

		var now = new Date();

		var idxMese = now.getMonth();

		var anno = now.getFullYear();

		/*if (now.getDate() < 2) {

			if (idxMese > 0) {

				idxMese--;

			} else {

				idxMese = 11;

				anno--;

			}

		}*/

		url = url + mesi[idxMese] + "_" + anno + "_" + numPage + ".html";

		document.location.href = url;

		return false;

	});

});



// PAGINAZIONE SETTIMANALE PER CLASSIFICHE CULTURA

$(function(){

	var prefix = "http://www.corriere.it/cultura/libri/classifiche_";

	$("#cultura_prec").bind("click", function () {

		var now = (new Date()).parseData($(this).attr("href").substring(1), -7);

		document.location.href = prefix + now.getDateString() + ".shtml";

		return false;

	});

	$("#cultura_succ").bind("click", function () {

		var now = (new Date()).parseData($(this).attr("href").substring(1), +7);

		document.location.href = prefix + now.getDateString() + ".shtml";

		return false;

	});



	if ($("#cultura_succ").attr("href") != undefined) {

		if ((new Date()).parseData($("#cultura_succ").attr("href").substring(1), +7) > new Date()) {

			$("#cultura_succ").hide();

		};

	}



	if ($("#cultura_prec").attr("href") != undefined) {

		if ((new Date()).parseData($("#cultura_prec").attr("href").substring(1), -7) < (new Date()).parseData("20080704", 0)) {

			$("#cultura_prec").hide();

		};

	}

});

//CAROUSEL GIOCHI ONLINE

(function($){
  $.fn.shufflegiochi = function() {
    return this.each(function(){
      var items = $(this).children();
      return (items.length)
        ? $(this).html($.shufflegiochi(items))
        : this;
    });
  }

  $.shufflegiochi = 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);




/*carosello giochi online*/
$(document).ready(function() {
$('#giochi_carousel ul').shufflegiochi();
    $('#carousel').jcarousel({
		size:9,
		scroll:3
    });
});




// BOX 8100 PAGINE INTERNE
if ($('#box8100').length > 0 ) {

	var elencoLocal = new Array("milano","roma","bologna","firenze","napoli","caserta","salerno","bari","lecce","venezia","padova","verona","treviso","vicenza","belluno","rovigo");
	var elencoLocalMonoCitta = new Array("milano","roma","bologna","firenze");

	$.getJSON("/informazione_locale/json/comuni.json", function(data){
		$(".loc").autocomplete(data.comuni, {
			autoFill:false,
			minChars:1,
			delay: 20,
			formatItem: function(row) {
				return row.name;
			},
			formatMatch: function(row) {
				return row.name;
			}
		}).result(function(event, data, formatted) {
			newLoc = data.value;
		});
	});

	function goTo(pagina) {
		// se � uno delle 16 citt� dei local va sempre in homepage
		//if ($.inArray(newLoc,elencoLocal) > -1) {
		//	pagina = "";
		//}
		// se � uno dei 4 local monocitt� devo aggiungere la citt� davanti
		if ($.inArray(newLoc,elencoLocalMonoCitta) > -1) {
			citta = "/"+newLoc;
		} else {
			citta = "";
		}
		var pathExtra = "";
		if (pagina == "aria") {
			pathExtra = citta + "/qualita-aria/giorno-1.shtml?id=1"
		} else if (pagina == "politici") {
			pathExtra = citta + "/rappresentanti.shtml#comune"
		} else if (pagina == "farmacie") {
			pathExtra = citta + "/farmacie.shtml"
		}

		if(typeof( window["newLoc"]) != "undefined") {
			tmp = window.location = "http://" + newLoc + ".corriere.it" + pathExtra;
		} else {
			return false;
		}
	};

	$("#gotoloc").click(function(){
		var pagina = $("#box8100 input[name=pagina]").val();
		goTo(pagina);
		return false;
	});

	$(".loc").keypress(function(e){
		if(e.which == 13){
			var pagina = $("#box8100 input[name=pagina]").val();
			goTo(pagina);
			return false;
		}
	});

	// sbianca text input
	$('.example-input').example(function() {
		return $(this).attr('title');
	});

}



