jQuery(document).ready(function() {
		
		//jQuery(document).pngFix();
		
		if(pagina_corsi == false)
		{
			leggiXML();
		}
		else
		{
			document.getElementById('scroll_news').innerHTML = "";
			jQuery('#newscontainer').css({"background-color":"#333"});
			jQuery('#cont_scroll_news').css({"background-color":"#333"});
		}
		if(mia_testata != '')
		{
			document.getElementById('scheda_testata').innerHTML ="<img src=\"testata_nuova_html/img/testate/"+mia_testata+"\" width=\"825\" height=\"280\" alt=\"testata\" />";
			jQuery("#scheda_testata").css("left","0px");
		}
  });

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

var attuale=1;
var scheda_aperta="";
var mio_slide;

function autoSlide()
{
	if((attuale == 4) || (attuale == 8))
	{
		scrollNews();	
	}
	
	if(attuale+1<=8)
	{
		slidaScheda((attuale+1));
	}
	else
	{
		slidaScheda(1);
	}
	
}

function apriScheda(scheda)
{
	window.clearInterval(mio_slide);
	if(scheda_aperta == "")
	{
		jQuery("#"+scheda).stop().animate({
		left: '0px'
	  });
		scheda_aperta = scheda;
	}
	else if(scheda !=scheda_aperta)
	{
		
		jQuery("#"+scheda).stop().animate({
		left: '0px'
	  });
		
		chiudiScheda();
		scheda_aperta = scheda;
	}
	document.getElementById(scheda+"_focus1").focus();
}

function chiudiScheda()
{
	jQuery("#"+scheda_aperta).stop().animate({
		left: '-825px'
	  });
	
	if(scheda_aperta == "corsi")
	{
		azzeraFormListini();
		jQuery("#corsi_contenitore").css("left","0px");
	}
	else if(scheda_aperta == "listini")
	{
		azzeraFormListini();
		jQuery("#listini_contenitore").css("left","0px");
	}
	else if(scheda_aperta == "prenota")
	{
		azzeraFormPrenota();
		jQuery("#prenota_contenitore").css("left","0px");
	}
	else if(scheda_aperta == "guida")
	{
		azzeraFormGuida();
	}
	scheda_aperta = "";
}

var stato_menu_news = 0;
function scrollNews()
{
	if(stato_menu_news == 0)
	{
		document.getElementById('scroll_news').innerHTML = "<a href=\"#nogo\" onclick=\"scrollNews()\"><img src=\"testata_nuova_html/img/su.png\" width=\"13\" height=\"12\" border=\"0\"/></a>";
		jQuery("#elenco_news").stop().animate({
			top: "-164px"
		  },
			{ 
				duration: 500, 
				specialEasing: {
					top: 'easeOutBack'
				}
		} );
		stato_menu_news = 1;
	}
	else
	{
		document.getElementById('scroll_news').innerHTML = "<a href=\"#nogo\" onclick=\"scrollNews()\"><img src=\"testata_nuova_html/img/giu.png\" width=\"13\" height=\"12\" border=\"0\" /></a>";
		jQuery("#elenco_news").stop().animate({
			top: "0px"
		  },
			{ 
				duration: 500, 
				specialEasing: {
					top: 'easeOutBack'
				}
			} );
		stato_menu_news = 0;
	}
}

function slida(pulsante)
{
	window.clearInterval(mio_slide);	
	slidaScheda(pulsante);
}

function slidaScheda(pulsante)
{
	if(jQuery("#scheda_testata").css("left") == '0px')
	{
		jQuery("#scheda_testata").stop().animate({
				top: '-280px'
				},
				{ 
					duration: 1000, 
					specialEasing: {
						left: 'easeOutQuad'
					}
				});
	}
	if(scheda_aperta != "")
	{
		chiudiScheda();
		jQuery("#scheda_news_"+attuale).css({'left':'825px'});
		jQuery("#scheda_news_"+pulsante).css({'left':'0px'});
	}
	else
	{
		if(attuale != pulsante )
		{
			jQuery("#scheda_news_"+attuale).stop().animate({
				left: '-825px'
				},
				{ 
					duration: 1000, 
					specialEasing: {
						left: 'easeInQuad'
					}
				});
			jQuery("#scheda_news_"+pulsante).css({'left':'825px'});
			jQuery("#scheda_news_"+pulsante).stop().animate({
				left: '0px'
				},
				{ 
					duration: 900, 
					specialEasing: {
						left: 'easeInQuad'
					}
				})
		}
	}
	
	if(attuale%2==0)
	{
		jQuery("#news_li_"+attuale).removeClass('news_title_li_hover').addClass('news_title_li_pari');
	}
	else
	{
		jQuery("#news_li_"+attuale).removeClass('news_title_li_hover').addClass('news_title_li');
	}
	
	if(pulsante%2==0)
	{
		jQuery("#news_li_"+pulsante).removeClass('news_title_li_pari').addClass('news_title_li_hover');
	}
	else
	{
		jQuery("#news_li_"+pulsante).removeClass('news_title_li').addClass('news_title_li_hover');
	}
	
	
	
	//jQuery("#news_li_"+pulsante).addClass("news_title_li_hover");
	
	//jQuery("#news_li_"+attuale).attr({class:"news_title_li"});
	
	attuale = pulsante;
}


function settaScrollNews()
{
	document.getElementById('scroll_news').innerHTML = "<a href=\"#nogo\" onclick=\"scrollNews()\"><img src=\"testata_nuova_html/img/giu.png\" width=\"13\" height=\"12\" border=\"0\"/></a>";
	//==============================
	//	S	C	R	O	L	L	1
	//==============================	
	if(jQuery("#testo1").height() > jQuery("#textbox1").height())
	{
				jQuery("#scroll1").draggable({ axis: 'y', containment: 'parent', opacity: 0.35,
							   drag: function(event, ui) 
									{
										var textTop = ((jQuery("#testo1").height() - jQuery("#textbox1").height()+20)* ui.position.top) / (jQuery("#scroll_area1").height() - jQuery("#scroll1").height() );
										window.clearInterval(mio_slide);
										// animazione slide
										jQuery("#testo1").stop().animate(
											{
											
											top: textTop * -1 + 'px'
											
											},
											{ 
												duration: 500, 
												specialEasing: {
													top: 'easeOutQuad'
												}
											} );
										// fine animazione slide
									}
		});
	}
	else
	{
		jQuery("#scroll1").css({'width':'0px', 'height':'0px'});
		jQuery("#scroll_area1").css({'width':'0px', 'height':'0px'});
	}
	
	// posizionamento assoluto del testo per evitare il taglio orizzontale

	// fine
	
	
	//==============================
	//	S	C	R	O	L	L	2
	//==============================
	if(jQuery("#testo2").height() > jQuery("#textbox2").height())
	{
		jQuery("#scroll2").draggable({ axis: 'y', containment: 'parent', opacity: 0.35,
							   drag: function(event, ui) 
									{
										var textTop = ((jQuery("#testo2").height() - jQuery("#textbox2").height()+20)* ui.position.top) / (jQuery("#scroll_area2").height() - jQuery("#scroll2").height() );
										window.clearInterval(mio_slide);
										jQuery("#testo2").stop().animate({
											top: textTop * -1 + 'px'
										  },
											{ 
												duration: 500, 
												specialEasing: {
													top: 'easeOutQuad'
												}
											} );
									}
		});
	}
	else
	{
		jQuery("#scroll2").css({'width':'0px', 'height':'0px'});
		jQuery("#scroll_area2").css({'width':'0px', 'height':'0px'});
	}
	
	//==============================
	//	S	C	R	O	L	L	3
	//==============================
	if(jQuery("#testo3").height() > jQuery("#textbox3").height())
	{
		jQuery("#scroll3").draggable({ axis: 'y', containment: 'parent', opacity: 0.35,
							   drag: function(event, ui) 
									{
										var textTop = ((jQuery("#testo3").height() - jQuery("#textbox3").height()+20)* ui.position.top) / (jQuery("#scroll_area3").height() - jQuery("#scroll3").height() );
										window.clearInterval(mio_slide);
										jQuery("#testo3").stop().animate({
											top: textTop * -1 + 'px'
										  },
											{ 
												duration: 500, 
												specialEasing: {
													top: 'easeOutQuad'
												}
											} );
									}
		});
	}
	else
	{
		jQuery("#scroll3").css({'width':'0px', 'height':'0px'});
		jQuery("#scroll_area3").css({'width':'0px', 'height':'0px'});
	}
	
	//==============================
	//	S	C	R	O	L	L	4
	//==============================
	if(jQuery("#testo4").height() > jQuery("#textbox4").height())
	{
		jQuery("#scroll4").draggable({ axis: 'y', containment: 'parent', opacity: 0.35,
							   drag: function(event, ui) 
									{
										var textTop = ((jQuery("#testo4").height() - jQuery("#textbox4").height()+20)* ui.position.top) / (jQuery("#scroll_area4").height() - jQuery("#scroll4").height() );
										window.clearInterval(mio_slide);
										jQuery("#testo4").stop().animate({
											top: textTop * -1 + 'px'
										  },
											{ 
												duration: 500, 
												specialEasing: {
													top: 'easeOutQuad'
												}
											} );
									}
		});
	}
	else
	{
		jQuery("#scroll4").css({'width':'0px', 'height':'0px'});
		jQuery("#scroll_area4").css({'width':'0px', 'height':'0px'});
	}
	
	//==============================
	//	S	C	R	O	L	L	5
	//==============================
	if(jQuery("#testo5").height() > jQuery("#textbox5").height())
	{
		jQuery("#scroll5").draggable({ axis: 'y', containment: 'parent', opacity: 0.35,
							   drag: function(event, ui) 
									{
										var textTop = ((jQuery("#testo5").height() - jQuery("#textbox5").height()+20)* ui.position.top) / (jQuery("#scroll_area5").height() - jQuery("#scroll5").height() );
										window.clearInterval(mio_slide);
										jQuery("#testo5").stop().animate({
											top: textTop * -1 + 'px'
										  },
											{ 
												duration: 500, 
												specialEasing: {
													top: 'easeOutQuad'
												}
											} );
									}
		});
	}
	else
	{
		jQuery("#scroll5").css({'width':'0px', 'height':'0px'});
		jQuery("#scroll_area5").css({'width':'0px', 'height':'0px'});
	}
	
	//==============================
	//	S	C	R	O	L	L	6
	//==============================
	if(jQuery("#testo6").height() > jQuery("#textbox6").height())
	{
		jQuery("#scroll6").draggable({ axis: 'y', containment: 'parent', opacity: 0.35,
							   drag: function(event, ui) 
									{
										var textTop = ((jQuery("#testo6").height() - jQuery("#textbox6").height()+20)* ui.position.top) / (jQuery("#scroll_area6").height() - jQuery("#scroll6").height() );
										window.clearInterval(mio_slide);
										jQuery("#testo6").stop().animate({
											top: textTop * -1 + 'px'
										  },
											{ 
												duration: 500, 
												specialEasing: {
													top: 'easeOutQuad'
												}
											} );
									}
		});
	}
	else
	{
		jQuery("#scroll6").css({'width':'0px', 'height':'0px'});
		jQuery("#scroll_area6").css({'width':'0px', 'height':'0px'});
	}
	
	//==============================
	//	S	C	R	O	L	L	7
	//==============================
	if(jQuery("#testo7").height() > jQuery("#textbox7").height())
	{
		jQuery("#scroll7").draggable({ axis: 'y', containment: 'parent', opacity: 0.35,
							   drag: function(event, ui) 
									{
										var textTop = ((jQuery("#testo7").height() - jQuery("#textbox7").height()+20)* ui.position.top) / (jQuery("#scroll_area7").height() - jQuery("#scroll7").height() );
										window.clearInterval(mio_slide);
										jQuery("#testo7").stop().animate({
											top: textTop * -1 + 'px'
										  },
											{ 
												duration: 500, 
												specialEasing: {
													top: 'easeOutQuad'
												}
											} );
									}
		});
	}
	else
	{
		jQuery("#scroll7").css({'width':'0px', 'height':'0px'});
		jQuery("#scroll_area7").css({'width':'0px', 'height':'0px'});
	}
	
	//==============================
	//	S	C	R	O	L	L	8
	//==============================
	if(jQuery("#testo8").height() > jQuery("#textbox8").height())
	{
		jQuery("#scroll8").draggable({ axis: 'y', containment: 'parent', opacity: 0.35,
							   drag: function(event, ui) 
									{
										var textTop = ((jQuery("#testo8").height() - jQuery("#textbox8").height()+20)* ui.position.top) / (jQuery("#scroll_area8").height() - jQuery("#scroll8").height() );
										window.clearInterval(mio_slide);
										jQuery("#testo8").stop().animate({
											top: textTop * -1 + 'px'
										  },
											{ 
												duration: 500, 
												specialEasing: {
													top: 'easeOutQuad'
												}
											} );
									}
		});
	}
	else
	{
		jQuery("#scroll8").css({'width':'0px', 'height':'0px'});
		jQuery("#scroll_area8").css({'width':'0px', 'height':'0px'});
	}
	
	if(mia_testata == '')
	{
		//-----attivo lo slide
		mio_slide = window.setInterval("autoSlide()", 5000);
	}
	else
	{
		jQuery("#news_li_1").removeClass('news_title_li_hover').addClass('news_title_li');
		jQuery("#scheda_news_1").css({'left':'825px'});
		attuale = 0;
	}
}



