// JavaScript Document
var actual;
var homepage=false;
var printmode=false;


/************************************************************\
*
\************************************************************/
function  anima(chi , come){
    $(chi).animate({ height: come[0]+"px", marginTop:  come[1]+"px" }, 500 );
}
/************************************************************\
*
\************************************************************/
function stato(){
    var now= $(this).parent();

    $("#navigazione div").each(function(index) {
										
		if( $(this).css('marginTop') !="0px"  &&  $(this).css('marginTop')!="auto"  ){
            anima ( $(this),[47,0]);
            }else{
            if($(now).html()==$(this).html() ){
                anima ( $(this),[303,-255]);
            }
        }
    }
    )
}
/************************************************************\
*
\************************************************************/
function RGB2Color(r,g,b)
{
    return '#' + byte2Hex(r) + byte2Hex(g) + byte2Hex(b);
}
/************************************************************\
*
\************************************************************/
function byte2Hex(n)
{
    var nybHexString = "0123456789ABCDEF";
    return String(nybHexString.substr((n >> 4) & 0x0F,1)) + nybHexString.substr(n & 0x0F,1);
}
/************************************************************\
*
\************************************************************/
function makeColorGradient(frequency1, frequency2, frequency3,phase1, phase2, phase3, center, width, len)
{
    if (len == undefined)      len = 50;
    if (center == undefined)   center = 128;
    if (width == undefined)    width = 127;
    for (var i = 0; i < $("#legal a").size(); ++i)
    {
        var red =  Math.sin(frequency1*i + phase1) * width + center;
        var grn = Math.sin(frequency2*i + phase2) * width + center;
        var blu = Math.sin(frequency3*i + phase3) * width + center;
   
        $($("#legal a")[i]).css("border-bottom" , "10px solid "+ RGB2Color(red,grn,blu) );
        $($("#legal a")[i]).bind({
            mouseenter: function(){
                $(this).css("border-bottom" , "10px solid #CCC");
            }  ,
            mouseleave: function(event){
                $(this).css("border-bottom" , "10px solid "+ event.data.col)    ;
            }
            },{
        col: RGB2Color(red,grn,blu) }
        )
    }
}



$(document).ready(function() {
						   
						   
		if(!printmode){				   
						   
    $("#navigazione div.tabber").each(function(index) {
        $(this).css("margin-left", 9* (index+1)+($(this).width()*index)  +"px");
	
		
		
		
    });


	if(!homepage){
		$("#content-adv").show();
	    $("#navigazione div img.push").bind({ click:stato   })
		$("#navigazione div img.push").css("cursor", "pointer");
		
				//  $("#content-adv-home").show();

		$ ("#banner-adv").append($(".dx_").html());
          
	   $(".dx_").empty()
	   
	   $ ("#banner-adv").css("overflow","hidden");
	   
	      //$find(tempoBan).enabled=faltrue; 
		
	}else{
		 $("#navigazione div.tabber").css({ height: "303px" })
		  $("#navigazione").css("height","303px");
		  $("#navigazione").css("background-image","url(./assets/imgs/bg_menu_home.png)");
		  $("#content").hide();

	
		  $("#content-adv-home").show();
		
		
		
	}

	
	
	$('.scroll-pane').jScrollPane({scrollbarWidth:8});
		}
	
	
	
	
    makeColorGradient(.4,.4,.5,11,50,0);
})

