function Nascondi (id) {
document.getElementById('blu'+id).style.display = "none";
document.getElementById('rossa'+id).style.display = "block";

}

function Mostra (id) {
document.getElementById('rossa'+id).style.display = "none";
document.getElementById('blu'+id).style.display = "block";
}

function loadProdotti(id){
  document.getElementById("content").style.cursor="wait";
  var evento=document.getElementById("idEvento").value;
  var bisogno=document.getElementById("idBisogno").value;
  return new Ajax.Request('/iaportal/ListaBisogniProdotti.do',{ method:"post", onSuccess:processRisultati, parameters:{idBisogno:bisogno,idEvento:evento,idSottoBisogno:id}});
}

var bisognoEvidenziato=null;
function evidenziaBisogno(id){
  if (document.getElementById( bisognoEvidenziato )) {
  	document.getElementById( bisognoEvidenziato ).style.fontWeight='normal';
  	document.getElementById( bisognoEvidenziato ).style.color='#666666';
  }
  if (document.getElementById( id )) {
  	 document.getElementById( id ).style.fontWeight='bold';
  	 bisognoEvidenziato = id;
  }
  return;
}

function processRisultati(xhr){
  document.getElementById("content").style.cursor="pointer";
  document.getElementById("risultati").innerHTML=xhr.responseText;
  scroller.init();
}

function scheda(id,query){
	if (query!=null){
	 if (query!='') query="&"+query;
	 }
	else {query='';} 
	top.document.location.href="/iaportal/SchedaProdotto.do?idProdotto="+id+query;
}

//We wrap all the code in an object so that it doesn't interfere with any other code

var scroller1 = {
  init:   function() {
    //collect the variables
    scroller1.docH = document.getElementById("content1").offsetHeight;
    scroller1.contH = document.getElementById("container1").offsetHeight;
    scroller1.scrollAreaH = document.getElementById("scrollArea1").offsetHeight;
      
    //calculate height of scroller and resize the scroller div
    //(however, we make sure that it isn't to small for long pages)
    scroller1.scrollH = 15;//(scroller1.contH * scroller1.scrollAreaH) / scroller.docH;
	
    //if(scroller.scrollH < 15) scroller.scrollH = 15;
    document.getElementById("scroller1").style.height = Math.round(scroller1.scrollH) + "px";
    
    //what is the effective scroll distance once the scoller's height has been taken into account
    scroller1.scrollDist = Math.round(scroller1.scrollAreaH-scroller1.scrollH);
    
    //make the scroller div draggable
    Drag.init(document.getElementById("scroller1"),null,0,0,-1,scroller1.scrollDist);
    
    //add ondrag function
    document.getElementById("scroller1").onDrag = function (x,y) {
      var scrollY = parseInt(document.getElementById("scroller1").style.top);
      var docY = 0 - (scrollY * (scroller1.docH - scroller1.contH) / scroller1.scrollDist);
      document.getElementById("content1").style.top = docY + "px";
    }
  }
}

var Old_scroller = {
  init:   function() {

    //collect the variables
    scroller.docH = document.getElementById("content").offsetHeight;
    scroller.contH = document.getElementById("container").offsetHeight;
    scroller.scrollAreaH = document.getElementById("scrollArea").offsetHeight;
      
    //calculate height of scroller and resize the scroller div
    //(however, we make sure that it isn't to small for long pages)
    scroller.scrollH = 15;//(scroller.contH * scroller.scrollAreaH) / scroller.docH;
	
    //if(scroller.scrollH < 15) scroller.scrollH = 15;
    document.getElementById("scroller").style.height = Math.round(scroller.scrollH) + "px";
    
    //what is the effective scroll distance once the scoller's height has been taken into account
    scroller.scrollDist = Math.round(scroller.scrollAreaH-scroller.scrollH);
    
    //make the scroller div draggable
    Drag.init(document.getElementById("scroller"),null,0,0,-1,scroller.scrollDist);
    
    //add ondrag function
    document.getElementById("scroller").onDrag = function (x,y) {
      var scrollY = parseInt(document.getElementById("scroller").style.top);
      var docY = 0 - (scrollY * (scroller.docH - scroller.contH) / scroller.scrollDist);
      document.getElementById("content").style.top = docY + "px";
    }

	if (document.getElementById("lista2")!=null)
	{
	scroller1.init();
	}
  }
}

// Gestione dello scroller verticale - vianello
var verticalScrollingEnd=false;
var timeoutVerticalScrolling;
var	prevScrollTop
var scroller = {
  init:   function()   {}
}
 
 function startVerticalScrolling(elemId, direction) {
	var obj = document.getElementById(elemId);
	obj.style.cursor='pointer'; 
	verticalScrollingEnd=false;
	loopVerticalScrolling( elemId, direction);
}	

 function loopVerticalScrolling(elemId, direction) {
	var obj = document.getElementById(elemId);
    var div = document.getElementById("container");	
	
    // direction = 1, scrolling verso il basso
	// direction = 0, scrolling verso l'alto
	// containerTable e' l'id del div che contiene l'albero
 
    var	prevScrollTop = div.scrollTop; 
  
	if (direction) {// scrolling verso il basso
		div.scrollTop = div.scrollTop+5;
	} else // scrolling verso l'alto
		div.scrollTop = div.scrollTop-5;
			
	if (div.scrollTop == prevScrollTop)  {
		if (direction)  // verso il basso 
			document.getElementById("verticalBottomScrollerImg").src= "/iaportal/img/blank_scroller.jpg";	
		else 
			document.getElementById("verticalTopScrollerImg").src= "/iaportal/img/blank_scroller.jpg";
	
		stopVerticalScrolling( obj ); // fermo tutto sono a fine corsa
	} else {
		if (direction)  {// verso il basso 
			var target = document.getElementById("verticalTopScrollerImg");
			if (target.src!= "/iaportal/img/up_scroll.jpg")
				target.src = "/iaportal/img/up_scroll.jpg";	
		} else {
			var target = document.getElementById("verticalBottomScrollerImg");
			if (target.src!= "/iaportal/img/down_scroll.jpg")
				target.src = "/iaportal/img/down_scroll.jpg";	
		}
	}
	
	if (!verticalScrollingEnd)
		timeoutVerticalScrolling = setTimeout("loopVerticalScrolling('"+elemId+"',"+direction+")", 100);
	else
		window.clearTimeout( timeoutVerticalScrolling );
 }
 
function stopVerticalScrolling( obj ) {
	// alert("???");
  obj.style.cursor='default'; 
  verticalScrollingEnd = true;
 }
	 
