var pulsanti= new Array();
var inc=20;
  function getStyleVal (source_id, IEStyleName, CSSStyleName) {
    var elem = document.getElementById(source_id);
    var target = "";
    if (elem.currentStyle) {
      target = elem.currentStyle[IEStyleName];
    } else 
if (window.getComputedStyle) {
      var compStyle = window.getComputedStyle(elem, "");
      target = compStyle.getPropertyValue(CSSStyleName);
   } else {
      target = "";
    }
    return target;
//document.getElementById(target_id).innerHTML = target;
  }

window.onload = function() {
  var urlPagina=window.location.href;
  var pathPagina=window.location.pathname;
  var re2=/(^\/)(.*)/;
  var found2=pathPagina.match(re2);
  var pathArray = window.location.pathname.split( '/' );
// alert('pathArray[0]='+pathArray[0]);
// alert('pathArray[1]='+pathArray[1]);


//  var re=/(http:\/\/2008.festivaleconomia.eu\/)([\w|-]*)(\/.*)?/;
//  var found = urlPagina.match(re);
//  switch (found2[2]) {
  switch (pathArray[1]) {
	case "relatori":
		accendiBollino("contentFestival.gif");
		break;
	case "festival":
		accendiBollino("contentFestival.gif");
		break;
	case "web-tv":
		accendiBollino("contentWebtv.gif");
		break;	
	case "sponsor":
		accendiBollino("contentSponsor.gif");
                break;
	case "multimedia":
		accendiBollino("contentMultimedia.gif");
                break;
	case "info":
		accendiBollino("contentInfo.gif");
                break;
	case "organizzazione":	
		accendiBollino("contentOrganizzazione.gif");
                break;
	case "press":
		accendiBollino("contentPress.gif");
                break;
	case "programma":
		accendiBollino("contentProgramma.gif");
                break;
	case "agenda":
		accendiBollino("contentAgenda.gif");
                break;
	case "fsb":
		accendiBollino("contentFsb.gif");
                break;
        case "user":
                accendiBollino("contentAgenda.gif");
                break;
  }	

//  accendiBollino(found[2]);

}

function redirectPage(mestesso,pagina,immagine){
  location.href="/"+pagina;
  accendiBollino(immagine);
/*
  var bollino=document.getElementById('side-tab'); 
  bollino.style.background="transparent url(/sites/all/themes/zen/festivaleco/images/"+immagine+") no-repeat";
  bollino.style.visibility="visible";
*/
}


function accendiBollino(immagine){
  var bollino=document.getElementById('side-tab');
  bollino.style.background="transparent url(/sites/all/themes/zen/festivaleco/images/"+immagine+") no-repeat";
  bollino.style.visibility="visible";
}

	function deScrollDiv(divName,maxScost){
	  for (x in pulsanti) {
//	  alert("elemento da descrollare="+pulsanti[x]);
	    var verso="+";
	    var elemento=document.getElementById(pulsanti[x]);
	    pulsanti.pop(divName);
	    intervalloA=setInterval("scrollIn('"+elemento.id+"','"+verso+"','"+maxScost+"')",1);	
	  }
//alert("chiama scrolldiv x"+divName);
//	setTimeout ("scrollDiv('"+divName+"','"+maxScost+"')", 10 );
	  scrollDiv(divName,maxScost);
	}

    	function scrollDiv(divName,maxScost) {
  	  var verso="-";
	  pulsanti.push(divName);
	  var bollino=document.getElementById('side-tab'); 
 	  bollino.style.background="transparent url(/sites/all/themes/zen/festivaleco/images/"+divName+".gif) no-repeat"
 	  bollino.style.visibility="visible"
	  var elemento = document.getElementById(divName);  
//	  alert("bottoni="+pulsanti); //	alert("elemento="+elemento.className+" divName="+elemento.id);  
// 	  intervallo=setInterval("nextFrame('"+elemento.id+"','"+verso+"')",10);
          intervalloB=setInterval("scrollOut('"+elemento.id+"','"+verso+"','"+maxScost+"')",10);
    	}

    	function scrollOut(divName,verso,maxScost) {
	  if (document.getElementById(divName).style.marginLeft){
	    var myScost=document.getElementById(divName).style.marginLeft
	  }
          else { 
	    var myScost = getStyleVal(divName, 'marginLeft', 'margin-left');
	  }
	     myScost=myScost.replace(/[a-z]/g,'');
	     maxScost=parseInt(maxScost);
	     myScost=parseInt(myScost)-inc;
	     var somma=maxScost+myScost;
	    if (somma>inc) {
 	      document.getElementById(divName).style.marginLeft=myScost+'px';
    	   } else {
			       myScost=myScost-somma;
	      document.getElementById(divName).style.marginLeft=myScost+'px';
    	      clearInterval(intervalloB);
    	   }
}
	function scrollIn(divName,verso,maxScost) {
          if (document.getElementById(divName).style.marginLeft){
            var myScost=document.getElementById(divName).style.marginLeft
          }
          else {
            var myScost = getStyleVal(divName, 'marginLeft', 'margin-left');
         }
           maxScost=parseInt(maxScost);
           myScost=myScost.replace(/[a-z]/g,'');
           myScost=parseInt(myScost)+inc;
     	   var somma=maxScost+myScost;
           if (myScost<=(0)) {
//        alert("div="+divName+" verso="+verso+" scost elem="+myScost+" max-scost="+maxScost);
             document.getElementById(divName).style.marginLeft=myScost+'px';
           } else {
	     myScost=0;
             document.getElementById(divName).style.marginLeft=myScost+'px';
             clearInterval(intervalloA);
	  }
    	}

