// JavaScript Document
<!--
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_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_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];}
}
//-->


var spigaActiveZone = "##";

function swapZone(zone,deact)
{
	var linkId = "";
	var linkClass = "";
	var divId = "";
	
	switch(zone)
	{
		case "caf":
			linkId = "linkC";
			linkClass = (deact) ? "linkImgC" : "linkImgCHover";
			divId = "divC";
			break;
		case "gel":
			linkId = "linkG";
			linkClass = (deact) ? "linkImgG" : "linkImgGHover";
			divId = "divG";
			break;
		case "pas":
			linkId = "linkP";
			linkClass = (deact) ? "linkImgP" : "linkImgPHover";
			divId = "divP";
			break;
	}
	if(spigaActiveZone != zone)
	{
		var link = document.getElementById(linkId);
		link.className = linkClass;
		var div = document.getElementById(divId);
		div.style.display = (deact) ? "none" : "block";
	}
}

function activateZone(zone)
{
	if(spigaActiveZone != "##")
	{
		var temp = spigaActiveZone;
		spigaActiveZone = "##";
		swapZone(temp,true);
	}
	swapZone(zone,false);
	spigaActiveZone = zone;
}

function acceptPrivacy()
{
	alert("Per procedere bisogna accettare la normativa sulla privacy");
}

function noFilesForJobs()
{
	alert("Per procedere bisogna allegare il cv e il manoscritto");
}

function openCitySelector(comuneId, provinciaId, capId)
{
}

function openVideo(name)
{
	window.open("/fabbri/FilmViewer.aspx?video="+name,"","width=320,height=285,scrollbars=no,location=no,statusbar=no");
}


/*function openTv()
{
	window.open("/fabbri/filmati/plasmafabbri.html","","width=470,height=380,scrollbars=no,location=no,statusbar=no");
}*/

function openTv()
{
	window.open("/fabbri/filmati/tv.html","","width=530,height=493,scrollbars=no,location=no,statusbar=no");
}

function openFilm(filmNumber)
{
	window.open("/fabbri/filmati/tv"+filmNumber+".html","","width=530,height=493,scrollbars=no,location=no,statusbar=no");
}

/* funzioni pop up */
/*var pull = createPullDown(522,400);
pull.step(IMAGESTEP,"images/sigep-splash.jpg");
pull.show()*/
var now = new Date();
var startDad = new Date(2008,02,19);
var endDad = new Date(2008,02,20);
if(startDad <= now && endDad >= now)
{
	var dad = createPullDown(385,385,false);
	dad.step(IMAGESTEP,"images/fabbri08_papa.jpg");
	dad.show()
}
/*var startMom = new Date(2008,04,11);
var endMom = new Date(2008,04,12);
if(startMom <= now && endMom >= now)
{
	var mom = createPullDown(385,385);
	mom.step(IMAGESTEP,"images/MAMMA.jpg");
	mom.show()
}*/
var startEaster = new Date(2008,02,20);
var endEaster = new Date(2008,02,25);
if(startEaster <= now && endEaster >= now)
{
	var easter = createPullDown(385,385);
	easter.step(IMAGESTEP,"images/fabbri08_pasqua.jpg");
	easter.show()
}

var startBarF = new Date(2008,06,01);
var endBarF = new Date(2008,07,25);
if(startBarF <= now && endBarF >= now)
{
	var barfestival = createPullDown(400,318);
    barfestival.step(IMAGESTEP,"/fabbri/concorsi_fabbri/barfestival/barfestival2008.jpg");
    barfestival.step(REGOLAMENTOSTEP,"/fabbri/concorsi_fabbri/barfestival/barfestival2008.pdf");
    barfestival.show()
}

function openFebbraio()
{
	/*var febbraio = createPullDown(402,280);
    febbraio.step(IMAGESTEP,"images/febbraio-"+lang+".jpg");
    febbraio.show();*/
	
	var elem = document.getElementById("promo");
	if(elem)
	{
		elem.style.display = "block";
		setTimeout(hideFebbraio,4000);
	}
}


function visualizzaConcorso2010()
{
	var catalogoAmarena = createPullDown(351,482);
    catalogoAmarena.step(IMAGESTEP,"/fabbri/concorsi_fabbri/ConcorsoAmarena2010/concorso20101.jpg");
    catalogoAmarena.step(REGOLAMENTOSTEP,"/fabbri/concorsi_fabbri/ConcorsoAmarena2010/piano2010.pdf");
    catalogoAmarena.show()
}


function hideFebbraio()
{
	var elem = document.getElementById("promo");
	if(elem)
		elem.style.display = "none";
}

/* funzioni per news */
var newsDivs = new Array();
var activeIdx = -1;
var millis = 4000;
var __scrollOffset = new Array();
var activeNews = new Array();

function addNewsDiv(divId)
{
	newsDivs[newsDivs.length] = divId;
}

function setNewsBlock()
{
	if(newsDivs.length-1 == activeIdx)
		activeIdx = 0;
	else
		activeIdx++;
	if(activeNews.length > 1)
		activeNews[0] = activeNews[1];
	else
		activeNews[0] = document.getElementById("news"+newsDivs[activeIdx++]);
	activeNews[1] = document.getElementById("news"+newsDivs[activeIdx]);
	if(activeNews[0] && activeNews[1])
	{
		activeNews[0].style.display = "block";
		activeNews[0].style.top = "0px";
		__scrollOffset[0] = 0;
		__scrollOffset[1] = 110;
		activeNews[1].style.top = "110px";
		activeNews[1].style.display = "block";
	}
	setTimeout(scrollNews,millis);
}

function launchNews()
{
	//verifica se ci sono piu' di una news news
	if(newsDivs.length > 0 && newsDivs.length == 1)
	{
		//rende visibile la prima news
		var elem = document.getElementById("news"+newsDivs[0]);
		if(elem)
			elem.style.display = "block";
	}
	else if(newsDivs.length > 0 && newsDivs.length > 1)
	{
		setNewsBlock();
		
	}
}

function scrollNews()
{
	__scrollOffset[0] -= 2;
	__scrollOffset[1] -= 2;
	if(__scrollOffset[1] >=0)
	{
		activeNews[0].style.top = __scrollOffset[0] + "px";
		activeNews[1].style.top = __scrollOffset[1] + "px";
		setTimeout(scrollNews,10);
	}
	else
	{
		setTimeout(setNewsBlock,millis);
	}
}

var __DIRECTION = true;
var __ISMOVING = false;

function scrolLeft()
{
	__DIRECTION = false;
	__ISMOVING = true;
	scrollFolder();
}

function scrolRight()
{
	__DIRECTION = true;
	__ISMOVING = true;
	scrollFolder();
}

function stopMoving()
{
	__ISMOVING = false;
}

function scrollFolder()
{
	var elem = document.getElementById("containerMin");
	if(elem)
	{
		if(!elem.myLeft)
			elem.myLeft = 0;
		elem.myLeft += __DIRECTION ? -10: 10;
		if(__ISMOVING && elem.myLeft >= -elem.offsetWidth && elem.myLeft <= 0)
		{
			elem.style.marginLeft = elem.myLeft+"px";
			//alert(elem.style.marginLeft)
			setTimeout("scrollFolder()", 20);
		}
	}
}

// per video ricette

var __activeLink = null;
var __videoLink = null;
var __videoLinkSet = false;

function setVideoLink(linkId)
{
	if(__videoLink == null)
		__videoLink = linkId;
	else if(!__videoLinkSet)
	{
		__videoLinkSet = true;
		var elem = document.getElementById(__videoLink);
		if(elem)
			setLink(elem);
	}
}

function setLink(link)
{
	if(__activeLink != null)
		__activeLink.className = "linkVideoRicette";
	__activeLink = link;
	__activeLink.className = "linkVideoSelected";
}