var chart1;
$(document).ready(function(){


/* ORA E DATA */
/*****************************************************************/
$("#clock").clock({"langSet":"it"});

/*****************************************************************/

/* POSIZIONO IL BOX CENTRALE */
/*****************************************************************/
$('.contenitore').centreInWindow(); 
/*****************************************************************/



/* SCROLLPANE */
/*****************************************************************/
	$('.scroll-pane').jScrollPane();
/*****************************************************************/



/* SCROLLTO */
/*****************************************************************/
	$('div.item_content a, a#tohome, a#to1, a#to2, a#to5').bind('click',function(event){
		var $anchor = $(this);
		$('html, body').stop().animate({ scrollLeft: $($anchor.attr('href')).offset().left }, 500);
		return false; }); 
		
/*****************************************************************/


/* VEGAS - IMMAGINI DI SFONDO A TUTTO SCHERMO */
/*****************************************************************/
$.vegas('slideshow', {
  backgrounds:[
    { src:'http://www.publy.it/wp-content/uploads/2011/07/iStock_000012675886Small.jpg' /*, fade:5000 */},
    { src:'http://www.publy.it/wp-content/uploads/2011/07/iStock_000005168460Small.jpg' /*, fade:4000 */},
    { src:'http://www.publy.it/wp-content/uploads/2011/07/pe0065795.jpg', valign:'20%', align:'right' /*, fade:3000 */ },
    { src:'http://www.publy.it/wp-content/uploads/2011/07/iStock_000016944942Small.jpg', valign:'20%', align:'right' /*, fade:2000*/ }   ]})
	('overlay', {   src:'http://www.publy.it/wp-content/themes/publyV2/js/overlays/01.png' });
/*****************************************************************/




function nascondiTutto() {
$('.firstbox').animate({top: '0'}, 500, 'linear');
$('.whiteBox').animate({top: '0'}, 500, 'linear');
$('.black').animate({top: '0'}, 500, 'linear');
$('.underDiv,.underDiv2,.underDiv3,.underDiv4,.underDiv5,.navigationArrow,.divU,.divU1,.divU2,.divU3,.divU4,.upDown,.undDiv,.undDiv2,.undDiv3,.undDiv4,.undDiv5,.navigationArrow_1').hide();
}


/* FRECCE DI SCORRIMENTO AVANTI ED  INDIETRO  */
/*****************************************************************/
var globalArrow_position = $('.contenitore').css('top').replace(/[^\d\.]/g, '');
var position = (globalArrow_position - 40) + "px";
$('div.globalArrow').css({'top' : position});
var cont = $('.section').css('width');


$('a.right').click(function() {
nascondiTutto();
$.scrollTo( "+="+cont, 800 );

		return false; 
		
 });


$('a.left').click(function() {
nascondiTutto();
$.scrollTo( "-="+cont, 800 );
		return false;
		
 });
/*****************************************************************/



/* OPEN CLOSE DIV */
/*****************************************************************/
        $(".slidingDiv").hide();
        $(".show_hide").show();

	$('.show_hide').click(function(){
	$(".slidingDiv").slideToggle();
	});
/*****************************************************************/


/*  INIZIALIZZO I DIV VERTICALI DEL PRIMO BOX */
/*****************************************************************/
$('.undDiv,.undDiv2,.undDiv3,.undDiv4,.undDiv5,.navigationArrow_1').hide(); 
$('div#section1 > * > * > *,#section1, a#tohome').click(function() {
$('.black').animate({top: '0'}, 500, 'linear');
$('.whitebox').animate({top: '0'}, 500, 'linear');
$('.divU,.divU1,.divU2,.divU3,.divU4,.upDown').hide(); 
$('.underDiv,.underDiv2,.underDiv3,.underDiv4,.underDiv5, .navigationArrow').hide();
$('.undDiv,.undDiv2,.undDiv3,.undDiv4,.undDiv5,.navigationArrow_1').slideDown();
$('.navigationArrow_1').show('slow');
});
/*****************************************************************/

/*  GESTIONE EVENTI PULSANTE PRIMO BOX */
/*****************************************************************/
if ( ($('.firstbox').css('top') == 'auto') || ($('.firstbox').css('top') == '0px') ) { $('div.navigationArrow_1 a.up').css('opacity', '0.7'); } 

$('div.navigationArrow_1 a.down').click(function() {
if ($('.firstbox').css('top') == '-600px') {
$('div.navigationArrow_1 a.down').css('opacity', '0.7');
} else {
$('div.navigationArrow_1 a.down').css('opacity', '1');
$('div.navigationArrow_1 a.up').css('opacity', '1');
$('.firstbox').animate({top: '-=300px'}, 500, 'linear'); return false; }
});
$('div.navigationArrow_1 a.up').click(function() {
if ( ($('.firstbox').css('top') == 'auto') || ($('.firstbox').css('top') == '0px') ) {
// non fare nulla
} else {
$('div.navigationArrow_1 a.down').css('opacity', '1');
$('div.navigationArrow_1 a.up').css('opacity', '1');
$('.firstbox').animate({top: '+=300px'}, 500, 'linear'); 
return false;
}
});
$('div.navigationArrow_1 a.close').click(function() {
$('.firstbox').animate({top: '0'}, 500, 'linear');
$('.undDiv,.undDiv2,.undDiv3,.undDiv4,.undDiv5,.navigationArrow_1').hide('slow');
return false;
});
/*****************************************************************/






/*  INIZIALIZZO I DIV VERTICALI DEL SECONDO BOX */
/*****************************************************************/
$('.underDiv,.underDiv2,.underDiv3,.underDiv4,.underDiv5,.navigationArrow').hide(); 
$('div#section2 > * > * > *, #section2, a#to1').click(function() {
$('.whiteBox').animate({top: '0'}, 500, 'linear');
$('.firstbox').animate({top: '0'}, 500, 'linear');
$('.divU,.divU1,.divU2,.divU3,.divU4,.upDown').hide(); 
$('.undDiv,.undDiv2,.undDiv3,.undDiv4,.undDiv5,.navigationArrow_1').hide('slow');
$('.underDiv,.underDiv2,.underDiv3,.underDiv4,.underDiv5').slideDown();
$('.navigationArrow').show('slow'); return false;
});
/*****************************************************************/

/*  GESTIONE EVENTI PULSANTE SECONDO BOX */
/*****************************************************************/
if ( ($('.black').css('top') == 'auto') || ($('.black').css('top') == '0px') ) { $('div.navigationArrow a.up').css('opacity', '0.7'); } 

$('div.navigationArrow a.down').click(function() {
if ($('.black').css('top') == '-1500px') {
$('div.navigationArrow a.down').css('opacity', '0.7');
} else {
$('div.navigationArrow a.down').css('opacity', '1');
$('div.navigationArrow a.up').css('opacity', '1');
$('.black').animate({top: '-=300px'}, 500, 'linear'); return false; }
});
$('div.navigationArrow a.up').click(function() {
if ( ($('.black').css('top') == 'auto') || ($('.black').css('top') == '0px') ) {
// non fare nulla
} else {
$('div.navigationArrow a.down').css('opacity', '1');
$('div.navigationArrow a.up').css('opacity', '1');
$('.black').animate({top: '+=300px'}, 500, 'linear'); 
return false;
}
});
$('div.navigationArrow a.close').click(function() {
$('.black').animate({top: '0'}, 500, 'linear'); 
$('.underDiv,.underDiv2,.underDiv3,.underDiv4,.underDiv5,.navigationArrow').hide();
return false;
});
/*****************************************************************/




/*  INIZIALIZZO I DIV VERTICALI DEL TERZO BOX */
/*****************************************************************/
$('.divU,.divU1,.divU2,.divU3,.divU4,.upDown').hide(); 
$('div#section3 > * > * > *,#section3, a#to2').click(function() {
$('.black').animate({top: '0'}, 500, 'linear');
$('.firstbox').animate({top: '0'}, 500, 'linear');
$('.undDiv,.undDiv2,.undDiv3,.undDiv4,.undDiv5,.navigationArrow_1').hide();
$('.underDiv,.underDiv2,.underDiv3,.underDiv4,.underDiv5,.navigationArrow').hide(); 
$('.divU,.divU1,.divU2,.divU3,.divU4,.upDown').slideDown();
$('.upDown').show('slow');
return false;
});
/*****************************************************************/

/*  GESTIONE EVENTI PULSANTE TERZO BOX */
/*****************************************************************/
if ( ($('.whiteBox').css('top') == 'auto') || ($('.whiteBox').css('top') == '0px') ) { $('div.upDown a.up').css('opacity', '0.7'); } 
/* SLIDING ELEMENTI */
$('div.upDown a.down').click(function() {
if ($('.whiteBox').css('top') == '-1500px') {
$('div.upDown a.down').css('opacity', '0.7');
} else {
$('div.upDown a.down').css('opacity', '1');
$('div.upDown a.up').css('opacity', '1');
$('.whiteBox').animate({top: '-=300px'}, 500, 'linear'); return false; }
});
$('div.upDown a.up').click(function() {
if ( ($('.whiteBox').css('top') == 'auto') || ($('.whiteBox').css('top') == '0px') ) {
// non fare nulla
} else {
$('div.upDown a.down').css('opacity', '1');
$('div.upDown a.up').css('opacity', '1');
$('.whiteBox').animate({top: '+=300px'}, 500, 'linear'); return false; }
});
$('div.upDown a.close').click(function() {
$('.whiteBox').animate({top: '0'}, 500, 'linear');
$('.divU,.divU1,.divU2,.divU3,.divU4,.upDown').hide('slow');
return false;
});
/*****************************************************************/



/* EFFETTI LETTERING */
/*****************************************************************/		
$('#ex1,#ex2,#ex3,#ex4,#ex5,#ex6,#ex7,.linea1,.linea2').hoverwords({ delay:50 });
/*****************************************************************/



/* RIDIMENSIONE DEL TESTO PER LE DIFFERENTI RISOLUZIONI */
/*****************************************************************/

if (($('.firstbox').width() >=  342 ) && ( $('.firstbox').width() < 427  ) ){
$('.b1').addClass('s1024');
} else {
  if (($('.firstbox').width() >=  427  ) && ( $('.firstbox').width() <  480 ) ) {
	$('#section1 div.b1').addClass('s1280');
	} else {
	  	if (( $('.firstbox').width() >=  480 ) && ( $('.firstbox').width() < 561 ) ){
		$('.b1').addClass('s1440');
		} else { 
			if( $('.firstbox').width() >=  561 )
				{
				$('.b1').addClass('s1680');
				}
				else { $('.b1').addClass('s1024'); }
			}
		}
	}	
/*****************************************************************/


/* FUNZIONE PER GRAFICI */
/*****************************************************************/
 chart = new Highcharts.Chart({
      chart: {
         renderTo: 'chart1',
         defaultSeriesType: 'line',
         marginRight: 130,
         marginBottom: 25
      },
      title: {
         text: 'Crescita Mensile',
         x: -20 //center
      },
      subtitle: {
         text: 'Serie storiche da Aprile 2010 a Luglio 2011',
         x: -20
      },
      xAxis: {
         categories: ['A', 'M', 'G', 'L', 'A', 'S', 
            'O', 'N', 'D', 'G', 'F', 'M', 'A','M', 'G','L' ]
      },
      yAxis: {
         title: {
            text: 'Valore in milioni'
         },
         plotLines: [{
            value: 0,
            width: 1,
            color: '#808080'
         }]
      },
      tooltip: {
         formatter: function() {
                   return '<b>'+ this.series.name +'</b><br/>'+
               this.x +': '+ this.y;
         }
      },
      legend: {
         layout: 'vertical',
         align: 'right',
         verticalAlign: 'top',
         x: -10,
         y: 100,
         borderWidth: 0
      },
      series: [{
	 name: 'Utenti unici',
         data: [1.5, 1.8, 2.0, 2.2, 2.2, 2.6, 2.5, 2.87, 3.635, 4.247, 5.001, 6.4, 7.050, 7.90, 8.30, 9.20]
      }, {
         name: 'Pagine Viste',
         data: [2.7, 2.95, 3.1, 3.3, 3.3, 5.5, 5.3, 6.56, 7.881, 8.920, 11.10, 13.0, 16.0, 17.54, 20.5, 22.1]
      }, {
         name: 'Impression',
         data: [7.0, 7.4, 7.7,7.9, 8.0, 10.5, 10.3, 11.5, 12.5, 13.6, 16.0, 21.0, 26.0, 33.5, 39.981, 46.192]
      }]
   });
/*****************************************************************/




});
