var storie_pepsi = new Array('Le origini','Anni 30','Anni 40','Anni 50','Anni 60','Anni 70','Anni 80','Anni 90','Anni 2000','Oggi');
// JavaScript Document
/********************CUFON***************************/
function attivaCufon(idElemento){
	idElemento=(typeof(idElemento)=="undefined")?"":(idElemento+" ");
	Cufon.replace(idElemento+'.futura', { fontFamily: 'Futura', hover:'true' });
}
/*******************CUFON***************************/

/*******************JCAROUSELLE***************************/
function attivaCarouselleLite(){	
	/*$(".contScrollProducts").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
    });*/

	var posizionaTh=$("#contDots a.selected").attr("idDot");
    $(".boxPromo").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
		start:1,
		visible: 5,
		scroll: 1,
		btnGo: ["#dotSlide1","#dotSlide2","#dotSlide3","#dotSlide4","#dotSlide5","#dotSlide6","#dotSlide7","#dotSlide8","#dotSlide9","#dotSlide10","#dotSlide11"],
        beforeStart: function(a) {
        },
        afterEnd: function(a) {
       }
    });
	
	$(".next").bind("click",function(){
		var nDot=(($("#contDots a.selected").attr("idDot")=='Nan')?1:parseInt($("#contDots a.selected").attr("idDot")));							 
		var newDot= nDot+ 1;
		newDot=(newDot > 8)? 1 : newDot;
		$("#contDots a").removeClass("selected");
		$("#dotSlide"+newDot).addClass("selected");
	});
	
	$(".prev").bind("click",function(){
		var newDot=parseInt($("#contDots a.selected").attr("idDot")) - 1;
		newDot=(newDot < 1)? 8: newDot;
		$("#contDots a").removeClass("selected");
		$("#dotSlide"+newDot).addClass("selected");
	});
	
	$("#contDots a").bind("click",function(){
		var newDot=parseInt($(this).attr("iddot"));
		$("#contDots a").removeClass("selected");
		$("#dotSlide"+newDot).addClass("selected");

	});
}
/*******************JCAROUSELLE ***************************/

/*******************JCAROUSELLE PRODOTTO******************/
function attivaCarouselleLiteProdotto(){	
	type_pepsi = new Array('#regular','#light','#twist','#boom','#up','#slam');
	titles_pepsi = new Array('Pepsi Regular','Pepsi Light','Pepsi Twist','Pepsi Boom','Seven Up','Slam');
	var id_p1=parseInt($('.contSchProdotto').attr("nro_p"));
	$(".contProdotti").jCarouselLite({
		btnNext: ".next",
		btnPrev: ".prev",
		mouseWheel: false,
		visible: 5,
		start:id_p1,
		afterEnd: function(a) {
			rolloverProduct();
       	}
	});
	$(".prev").bind("click",function(){
		var id_p=$('.contSchProdotto').attr("nro_p");
		var new_p=id_p-1;
		var nro=((new_p<0)?5:new_p);
		var el=document.getElementById(nro);
		var image=$(el).attr("image");
		var title=$(el).attr("title");
		var name=$(el).attr("name");
		var descr=$(el).attr("descr");
		var info=$(el).attr("info");
		var formati=$(el).attr("formati");
		var bcolor=$(el).attr("color");
		$(".contSchProdotto").css("background",bcolor);
		$(".contSchSx img").attr("src",image);
		$("#titleProduct").html(title);
		$(".productName").html(name);
		Cufon.replace('.productName', { fontFamily: 'Futura', hover:'true' });
		$(".info_product .txt").html(descr);
		$("#txt_info_nutrizionali").html(info);
		$(".txt_formati").html(formati);
		
		//.contSchProdotto
		
		$(".contSchProdotto").attr("nro_p",nro);
		if(title.length>37){
			$('.info_product_sx').css('height','205px');
			$('.info_product_dx').css('height','205px');
		}else{
			$('.info_product_sx').css('height','238px');
			$('.info_product_dx').css('height','238px');
		}
		//
		document.title="PEPSI - Prodotti - " + titles_pepsi[nro];
	});
	
	$(".next").bind("click",function(){
		var id_p=$('.contSchProdotto').attr("nro_p");
		var new_p=parseInt(id_p)+1;
		var nro=((new_p>5)?0:new_p);
		var el=document.getElementById(nro);
		
		var image=$(el).attr("image");
		var title=$(el).attr("title");
		var name=$(el).attr("name");
		var descr=$(el).attr("descr");
		var info=$(el).attr("info");
		var formati=$(el).attr("formati");
		var bcolor=$(el).attr("color");
		$(".contSchProdotto").css("background",bcolor);
		
		$(".contSchSx img").attr("src",image);
		$("#titleProduct").html(title);
		$(".productName").html(name);
		Cufon.replace('.productName', { fontFamily: 'Futura', hover:'true' });
		$(".info_product .txt").html(descr);
		$("#txt_info_nutrizionali").html(info);
		$(".txt_formati").html(formati);
		
		$(".contSchProdotto").attr("nro_p",nro);
		if(title.length>37){
			$('.info_product_sx').css('height','205px');
			$('.info_product_dx').css('height','205px');
		}else{
			$('.info_product_sx').css('height','238px');
			$('.info_product_dx').css('height','238px');
		}
		document.title="PEPSI - Prodotti - " + titles_pepsi[nro];
	});
	
	
	$('.contProdotti').css('position','absolute');
	$('.contProdotti').css('left','72px');

}
function rolloverProduct(){
	titles_pepsi = new Array('Pepsi Regular','Pepsi Light','Pepsi Twist','Pepsi Boom','Seven Up','Slam');
	//$(".product").unbind();
	$(".product").bind("mouseover", function(){
		var obj=$(this);
		//if(!$($('.descr_rollover',this)).is(":visible")){
			$($('.descr_rollover',this)).slideDown(800);
			$($('.btnTop_ro',this)).show({ direction: "right" });
		//}
		return(false);
	});	
	
	$(".product").bind("mouseleave", function(){
		//if($($('.descr_rollover',this)).is(":visible")){
			$($('.descr_rollover',this)).slideUp(800);
			$($('.btnTop_ro',this)).hide({ direction: "left" });
		//}
		return(false);
	});	
	
	$(".product").bind("click", function(){
		var obj=$(this);

		var iden= parseInt($(obj).attr("id"));
		var image=$(obj).attr("image");
		var title=$(obj).attr("title");
		var name=$(obj).attr("name");
		var descr=$(obj).attr("descr");
		var info=$(obj).attr("info");
		var formati=$(obj).attr("formati");
		var bcolor=$(obj).attr("color");
		$(".contSchProdotto").css("background",bcolor);
		$(".contSchStoria").css("background",bcolor);
		if(bcolor=="#003867"){
			$(".year_prev").css("color","#00345f");
			$(".year_next").css("color","#00345f");
		}else{
			$(".year_prev").css("color","#9a47b4");
			$(".year_next").css("color","#9a47b4");
		}
		//year_prev
		
		$(".contSchSx img").attr("src",image);
		$("#titleProduct").html(title);
		$(".productName").html(name);
		Cufon.replace('.productName', { fontFamily: 'Futura', hover:'true' });
		$(".info_product .txt").html(descr);
		$("#txt_info_nutrizionali").html(info);
		$(".txt_formati").html(formati);
		
		if(title.length>37){
			$('.info_product_sx').css('height','205px');
			$('.info_product_dx').css('height','205px');
		}else{
			$('.info_product_sx').css('height','238px');
			$('.info_product_dx').css('height','238px');
		}
		document.title="PEPSI - Prodotti - " + titles_pepsi[iden];
		return(false);
	});	
	
	//document.title="PEPSI - Prodotti - " + titles_pepsi[nro];
	
}
/*******************JCAROUSELLE PRODOTTO******************/
/*---------------rool over location---------------------*/
function rolloverLocation(){
	$(".location").bind("mouseover", function(){
		var obj=$(this);
		//if(!$($('.descr_rollover',this)).is(":visible")){
			$($('.descr_rollover',this)).slideDown(800);
			$($('.btnTop_ro',this)).show({ direction: "right" });
		//}
		return(false);
	});	
	
	$(".location").bind("mouseleave", function(){
		//if($($('.descr_rollover',this)).is(":visible")){
			$($('.descr_rollover',this)).slideUp(800);
			$($('.btnTop_ro',this)).hide({ direction: "left" });
		//}
		return(false);
	});	
}
/*---------------rool over location---------------------*/
/*********************SCROLL HOME***********************************/

/*********************SCROLL HOME***********************************/

/*********************ROLL OVER*****************************/
function showRollOver(){
	$(".boxHome").unbind();
	$(".boxHome").bind("mouseover", function(){
		var obj=$(this);
		//if(!$($('.descr_rollover',this)).is(":visible")){
			$($('.descr_rollover',this)).slideDown(800);
			$($('.btnTop_ro',this)).show({ direction: "right" });
		//}
		return(false);
	});	
	
	$(".boxHome").bind("mouseleave", function(){
		//if($($('.descr_rollover',this)).is(":visible")){
			$($('.descr_rollover',this)).slideUp(800);
			$($('.btnTop_ro',this)).hide({ direction: "left" });
		//}
		return(false);
	});	
	
	//
	
}
/*********************ROLL OVER****************************/
/*--------------SCROLL STORIA----------------------*/
function scrollStoria(){	
	
	var posizionaTh=$("#contDots a.selected").attr("idDot");
    $(".contStorie").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
		start:5,
		visible: 5,
		scroll: 1,
		circular: false,
		btnGo: [".p1",".p2",".p3",".p4",".p5",".p6",".p3",".p4",".p5",".p6"],
        afterEnd: function(a) {
			rolloverStoria();
       }
    });
	
	
	var anni_scroll=new Array('','30','40','50','60','70','80','90','00','11');
	
	$(".next").bind("click",function(){
		$(".disabled").css("opacity",1);
		var id_s=$('.contSchStoria').attr("nro_s");
		var new_s=parseInt(id_s)+1;
		var nro=((new_s>9)?9:new_s);
		var el=document.getElementById(nro);
		
		var image=$(el).attr("image");
		var title=$(el).attr("title");
		var year=$(el).attr("year");
		var descr1=$(el).attr("descr1");
		var descr2=$(el).attr("descr2");
		
		var bcolor=$(el).attr("color");
		$(".contSchStoria").css("background",bcolor);
		if(bcolor=="#003867"){
			$(".year_prev").css("color","#00345f");
			$(".year_next").css("color","#00345f");
		}else{
			$(".year_prev").css("color","#9a47b4");
			$(".year_next").css("color","#9a47b4");
		}
		
		$(".contSchStoria img").attr("src",image);
		$("#year").html(year);
		Cufon.replace('.productName', { fontFamily: 'Futura', hover:'true' });		
		
		$(".contSchStoria").attr("nro_s",nro);		
		
		$(".year_next").html(anni_scroll[nro+1]);
		$(".year_prev").html(anni_scroll[nro-1]);
		/**/
		var nDot=(($("#contDots a.selected").attr("idDot")=='Nan')?1:parseInt($("#contDots a.selected").attr("idDot")));							 
		var newDot= nDot+ 1;
		newDot=(newDot > 10)? 10 : newDot;
		$("#contDots a").removeClass("selected");
		$("#dotSlide"+newDot).addClass("selected");
		
		/*if(nro==0 || nro==1 || nro==3|| nro==8 || nro==9){
			showTesto(true,descr1,descr2);
		}else{
			showTesto(false,descr1,descr2);
		}
		*/
		$("#col_sx_storia").html('<div id="boxScrollStoria">'+descr1+'</div>');
		if(nro==0){
			$("#boxScrollStoria").jScrollPane({showArrows:false});
		}
		document.title="PEPSI - Prodotti - " + storie_pepsi[nro];
	});
	
	$(".prev").bind("click",function(){
		$(".disabled").css("opacity",1);
		var id_s=$('.contSchStoria').attr("nro_s");
		var new_s=id_s-1;
		var nro=((new_s<0)?0:new_s);
		if(new_s>=0){
			var el=document.getElementById(nro);
			var image=$(el).attr("image");
			var title=$(el).attr("title");		
			var year=$(el).attr("year");
			var descr1=$(el).attr("descr1");
			var descr2=$(el).attr("descr2");
			var bcolor=$(el).attr("color");
			$(".contSchStoria").css("background",bcolor);	
	
			if(bcolor=="#003867"){
				$(".year_prev").css("color","#00345f");
				$(".year_next").css("color","#00345f");
			}else{
				$(".year_prev").css("color","#9a47b4");
				$(".year_next").css("color","#9a47b4");
			}
			$(".contSchStoria img").attr("src",image);
			$("#year").html(year);
			Cufon.replace('.productName', { fontFamily: 'Futura', hover:'true' });
			
			$("#col_sx_storia").html(descr1);
			$("#col_dx_storia").html(descr2);
	
			
			$(".contSchStoria").attr("nro_s",nro);
			
			$(".year_next").html(anni_scroll[nro+1]);
			$(".year_prev").html(anni_scroll[nro-1]);
			
			/*******/
			var newDot=parseInt($("#contDots a.selected").attr("idDot")) - 1;
			newDot=(newDot < 1)? 1: newDot;
			$("#contDots a").removeClass("selected");
			$("#dotSlide"+newDot).addClass("selected");
			
			/*if(nro==0 || nro==1 || nro==3|| nro==8 || nro==9){
				showTesto(true,descr1,descr2);
			}else{
				showTesto(false,descr1,descr2);
			}*/
			$("#col_sx_storia").html('<div id="boxScrollStoria">'+descr1+'</div>');
			if(nro==0){
				$("#boxScrollStoria").jScrollPane({showArrows:false});
			}
			document.title="PEPSI - Prodotti - " + storie_pepsi[nro];
		}
	});
	
	$("#contDots a").bind("click",function(){
		var newDot=parseInt($(this).attr("iddot"));
		$("#contDots a").removeClass("selected");
		$("#dotSlide"+newDot).addClass("selected");
		/*change contenuti*/
		var id_this=parseInt($($(this)).attr("iddot")-1);	
		var id_s=$('.contSchStoria').attr("nro_s");
		var nro=id_this;
		var el=document.getElementById(id_this);
		var image=$(el).attr("image");
		var title=$(el).attr("title");		
		var year=$(el).attr("year");
		var descr1=$(el).attr("descr1");
		var descr2=$(el).attr("descr2");
		var bcolor=$(el).attr("color");
		$(".contSchStoria").css("background",bcolor);	
		if(bcolor=="#003867"){
			$(".year_prev").css("color","#00345f");
			$(".year_next").css("color","#00345f");
		}else{
			$(".year_prev").css("color","#9a47b4");
			$(".year_next").css("color","#9a47b4");
		}

		$(".contSchStoria img").attr("src",image);
		$("#year").html(year);
		Cufon.replace('.productName', { fontFamily: 'Futura', hover:'true' });
		
		$("#col_sx_storia").html(descr1);
		$("#col_dx_storia").html(descr2);

		
		$(".contSchStoria").attr("nro_s",nro);
		var n=parseInt(id_this+1);
		$(".year_next").html(anni_scroll[id_this+1]);
		$(".year_prev").html(anni_scroll[id_this-1]);

		//dot
		var newDot=parseInt($("#contDots a.selected").attr("idDot"));
		newDot=id_this+1;
		$("#contDots a").removeClass("selected");
		$("#dotSlide"+newDot).addClass("selected");
		
		/*if(nro==0 || nro==1 || nro==3|| nro==8 || nro==9){
			showTesto(true,descr1,descr2);
		}else{
			showTesto(false,descr1,descr2);
		}*/
		$("#col_sx_storia").html('<div id="boxScrollStoria">'+descr1+'</div>');
		if(true || nro==0){
			// $("#col_sx_storia").addClass("col_sx_origini");
			//setTimeout(function(){
				$("#boxScrollStoria").jScrollPane({showArrows:false});
			//},500);
		}
		
		/*jQuery.scrollTo( '#10' );*/ 
		/**/
		document.title="PEPSI - Prodotti - " + storie_pepsi[nro];
	});
	
	$('.contStorie').css('position','absolute');
	$('.contStorie').css('left','77px');
	
	
}


function showTesto(b,descr1,descr2){
	//if(b==false){
		$('#col_sx_storia').css('width','204px');
		$("#col_sx_storia").html(descr1);
		$("#col_dx_storia").html(descr2);
	/*}else{
		$('#boxScrollStoria').css('width','440px');
		$("#boxScrollStoria").html(descr1);
		var testo='';

		$("#col_dx_storia").html(testo);
	}	*/
}

function rolloverStoria(){
	var anni_scroll=new Array('','30','40','50','60','70','80','90','00','11');
	
	$('.product').unbind('mouseover');
	$(".product").bind("mouseover", function(){
		var obj=$(this);
		//if(!$($('.descr_rollover',this)).is(":visible")){
			console.log("over");
			$($('.descr_rollover',this)).slideDown(800);
			$($('.btnTop_ro',this)).show({ direction: "right" });
		//}
		return(false);
	});	
	
	$('.product').unbind('mouseleave');
	$(".product").bind("mouseleave", function(){
		//if($($('.descr_rollover',this)).is(":visible")){
			console.log("out");
			$($('.descr_rollover',this)).slideUp(800);
			$($('.btnTop_ro',this)).hide({ direction: "left" });
		//}
		return(false);
	});	
	
	$(".product").bind("click", function(){
		var id_this=parseInt($($(this)).attr("id"));		
		var id_s=$('.contSchStoria').attr("nro_s");
		var nro=id_this;
		var el=document.getElementById(id_this);
		var image=$(el).attr("image");
		var title=$(el).attr("title");		
		var year=$(el).attr("year");
		var descr1=$(el).attr("descr1");
		var descr2=$(el).attr("descr2");
		var bcolor=$(el).attr("color");
		$(".contSchStoria").css("background",bcolor);	
		if(bcolor=="#003867"){
			$(".year_prev").css("color","#00345f");
			$(".year_next").css("color","#00345f");
		}else{
			$(".year_prev").css("color","#9a47b4");
			$(".year_next").css("color","#9a47b4");
		}

		$(".contSchStoria img").attr("src",image);
		$("#year").html(year);
		Cufon.replace('.productName', { fontFamily: 'Futura', hover:'true' });
		
		$("#col_sx_storia").html(descr1);
		$("#col_dx_storia").html(descr2);

		
		$(".contSchStoria").attr("nro_s",nro);
		var n=parseInt(id_this+1);
		$(".year_next").html(anni_scroll[id_this+1]);
		$(".year_prev").html(anni_scroll[id_this-1]);

		//dot
		var newDot=parseInt($("#contDots a.selected").attr("idDot"));
		newDot=id_this+1;
		$("#contDots a").removeClass("selected");
		$("#dotSlide"+newDot).addClass("selected");
		
		/*if(nro==0 || nro==1 || nro==3|| nro==8 || nro==9){
			showTesto(true,descr1,descr2);
		}else{
			showTesto(false,descr1,descr2);
		}*/
		$("#col_sx_storia").html('<div id="boxScrollStoria">'+descr1+'</div>');
		if(nro==0){
			$("#boxScrollStoria").jScrollPane({showArrows:false});
		}
		document.title="PEPSI - Prodotti - " + storie_pepsi[id_this];
		
		return(false);
	});	
	
}
/*--------------SCROLL STORIA----------------------*/
$(document).ready(function(){
	attivaCufon("");
	$('#boxConcorso a').css('display','block');
	$('#h_menu ul').css('display','block');
	$('.descr_rollover').slideToggle(0);
	$('.btnTop_ro').slideToggle(0);	
	//attivaCarouselleLite();
	//rolloverProduct();
	showRollOver();
	return true;
});
/*---------------------SCROLLBAR--------------------------*/
function customizeScrollbar(){	
	$("#boxPrivacy").jScrollPane({showArrows:true});
}

/* --------------------FUNCTION EXISTS--------------------*/
function function_exists(function_name) {
    if (typeof function_name == 'string') {
        return (typeof this.window[function_name] == 'function');
    } else {
        return (function_name instanceof Function);
    }
}

