var menu_splash_page_top = false;

/********************FUNCTIONS SPLASH PAGE*************************/
function activateCheckbox(obj){
	var parent=$(obj).parent();
	var child_input=$(parent).children('.input-checkbox');
	var val_input=$(child_input).attr('status');
	
	var newval=((val_input=='0')?1:0);
	$('.input-checkbox').attr('status',0);
	$('.checkbox').removeClass('selected');
	$(child_input).attr('status',newval);
	if(newval==1){
		$(obj).addClass('selected');
	}else{
		$(obj).removeClass('selected');
	}
}

function closeSplashPage(){
	var check_yes = $('#yes').attr('status');
	if (check_yes == '1') {
	    f6_setCookieForAgeSelection(); //F6 MOD
	    var arr_dim = getDimWindow();
	    var h = parseInt(arr_dim[1]);
	    $('#splash-page').animate({ 'top': (-h) + 95 }, 1500, function () {
	        var pagina = $('div.country select option:selected').val();  //F6 MOD
	        document.location.href = pagina;  //F6 MOD
			/*menu_splash_page_top = true; 
			setTimeout("showMainMenu()",300);
			 var pagina = $('li.selected').attr('id');
			 var submenu_pagina = $('.submenu-'+pagina);
			 var link_pagina = $('li.selected').children('a');
			 if(submenu_pagina){
				
				setTimeout( function(){ semicloseWindowSubmenu(link_pagina);},1000);
			 }
			 $('#carouselle-home').css('display','block');*/
		});	
	}
}

function showMainMenu(){
	$('#splash-page').hide();
	$('#site').css('display','block');
	//$('#carouselle-home-int').css('visibility','visible');
}

function isIE(){
	return $.browser.msie;
}


/**************FUNCTIONS HOME******************/
var carouselle = "false";
var x ;
var autoTime = 7000;
function initializeCarouselleHome(){

	
	if(isIE()){
		var _w = $('.mask-car-center').width();
		$('#cont-masks').css('width',_w);
	}
	var pos_window = getDimWindow();
	var height = Math.abs(pos_window[1] - 95 - 420)/2;
	var position_top = 95 + height;
	$('#carouselle-home').css('top',position_top);
	$("#carouselle-home-int").jCarouselLite({
		vertical: true,
		start: 0,
		btnNext: "#btn-prev",
    	btnPrev: "#btn-next",
		speed: 1000,
		beforeStart: function(a) {
			carouselle = 'true';
			/*$('.mask-car-center a').unbind('mouseover',hoverCarouselle());
			$('.mask-car-center a').unbind('mouseout',outCarouselle());
			$('.box-carouselle').unbind('mouseover',function(){hoverCarouselleBox();});
			$('.box-carouselle').unbind('mouseout',function(){outCarouselleBox();});*/
			
			var selected = $('#carouselle-home-int .selected');
			var slide_selected = $(selected).parent().attr('class');
			var nro = slide_selected.split('-');
			var nro_slide = $('#carouselle-home-int').children('ul').children('li').length;
			nro_slide = Math.ceil(nro_slide/3);
			
			if(slide_pos == 'prev'){
				var slide_s = parseInt(nro[1]);
				var s = slide_s+1;
				var new_s;
				if(s > nro_slide){
					new_s =1;
				} else{new_s =s;}
				
		    }else{
				var slide_s = parseInt(nro[1]);
				var s = slide_s-1;
				var new_s;
				if(s < 1){
					new_s =nro_slide;
				} else{new_s =s;}
				
			}
			
			
		
			var nome = '.slide-'+new_s;
			var slide_succ = $(nome);
			
			$('#carouselle-home-int .box-carouselle').removeClass('selected');
			$(slide_succ).children('.box-carouselle').addClass('selected');
			
			//var el = a[2];
			//console.log(a[3]);
			var child = $(nome);
			
			var el = $(child[0]).find('.txt-carouselle-int').clone();
			
			var link_h = $(child[0]).children('.box-carouselle').attr('href');
			$('.mask-car-center a').attr('href',link_h);
			$('.mask-car-center .txt-carouselle').html(el);
			if(slide_sel == "true"){
				setTimeout(function(){
					$('.img_car').css('visibility','visible');			
				},250);
			}
		},
		afterEnd : function(a) {
			if(slide_sel == "true"){
				setTimeout(function(){
					$('.img_car').css('visibility','visible');			
					//hoverCarouselle();
				},1000);
			}
			carouselle = 'false';
			/*$('.mask-car-center a').bind('mouseover',function(){hoverCarouselle();});
			$('.mask-car-center a').bind('mouseout',function(){outCarouselle();});
			$('.box-carouselle').bind('mouseover',function(){hoverCarouselleBox(this);});
			$('.box-carouselle').bind('mouseout',function(){outCarouselleBox(this);});*/
		}
	});
	
	
	//simulate autoscroll by simulating "click" on next link
    x = setInterval("$('#btn-prev').trigger('click');", autoTime);
    //if stopAuto is clicked the autoscroll is suspended for autoTime
    //no matter how far along the timer already was





	$('.mask-car-center a').bind('mouseover',function(){hoverCarouselle();});
	$('.mask-car-center a').bind('mouseout',function(){outCarouselle();});
	$('.box-carouselle').bind('mouseover',function(){hoverCarouselleBox(this);});
	$('.box-carouselle').bind('mouseout',function(){outCarouselleBox(this);});
	
}





//var slide_pos ='prev';
var slide_sel = 'false';
function hoverCarouselle(){
	clearInterval(x);
	$('.mask-carouselle').addClass('selected');	
	var img_hover = $('.box-carouselle.selected').children('.image-carouselle').children('.img_car');
	$(img_hover).css('visibility','hidden');
	slide_sel = 'true';
	
	//clearInterval(autoScroll);	
}

function outCarouselle(){
	$('.mask-carouselle').removeClass('selected');	
	var img = $('#carouselle-home-int .selected').children('.image-carouselle').children('.img_car');
	$(img).css('visibility','visible');
	slide_sel = 'false';
	x = setInterval("$('#btn-prev').trigger('click');", autoTime);
	
}

function hoverCarouselleBox(obj){
	clearInterval(x);
	$('.mask-carouselle').addClass('selected');	
	var img = $('#carouselle-home-int .selected').children('.image-carouselle').children('.img_car');
	$(img).css('visibility','hidden');
	slide_sel = 'true';
	//clearInterval(autoScroll);	
}

function outCarouselleBox(obj){
	$('.mask-carouselle').removeClass('selected');	
	var img = $('#carouselle-home-int .selected').children('.image-carouselle').children('.img_car');
	$(img).css('visibility','visible');
	slide_sel = 'false';
	x = setInterval("$('#btn-prev').trigger('click');", autoTime);
	
	//autoScroll = setInterval("autoS()",7000);
}
/************FUNCTION ARCHIVE*******************/
function initializeArchive(){
	resizeBackgroundArchive('start',1);
	setPositionPreview();
	embedPlayerVideo();	
	changePreviewArchive();
}

var id_slideshow_calendar = 1;
function resizeBackgroundArchive(obj,id_slideshow){
	resize_calendar = 'true';
	var slideshow = '.slideshow-calendar-'+id_slideshow;
	var old_w_li = $(slideshow).find('li').width();
	var ps_ul = $(slideshow).find('ul').position();
	var old_pos_left_ul = ps_ul.left;
	var id_current_slide = Math.abs(Math.floor(old_pos_left_ul/old_w_li));
	
	$('#background').css('width','100%');
	$('#background').css('height','100%');	
	
	var arr_win = getDimWindow();
	var _w =  arr_win[0];
	var _h =  arr_win[1] - 84;
	var w_img = parseInt($('.photo-calendar').attr('_w'));
	var h_img = parseInt($('.photo-calendar').attr('_h'));
	
	var _w1 =  arr_win[0];
	var _h1 =  arr_win[1];
	if(arr_win[0] < 995 && arr_win[1] < 584){
		_w1 = 995;
		_h1 = 584;
	}
	var dimensions = getMinAreaResize(w_img ,h_img, _w1, _h1);

	
	var newH = dimensions[1];
	var newW = dimensions[0];
	var rapOrig = w_img / h_img;
	
	$(slideshow).find('ul').css('width', _w*$('.section').length);
	$(slideshow).find('ul').css('height', _h+84);
	$(slideshow).find('li').css('height', _h+84);
	$(slideshow).find('li').css('width', _w);
	$(slideshow).find('.section').css('width', _w);
	$(slideshow).find('section-calendar').css('width', _w);
	
	
	
	var width_photo = dimensions[0];
	var diff = (width_photo-_w);
	
	//resize vertical image
	try{
		var vertical_photos = $(slideshow).find('.vertical-photo-calendar');
		if($(vertical_photos).length > 0){
			$(vertical_photos).each(function(index) {
				//alert(index );
				var photo = vertical_photos[index];
				var width_txt = $(photo).parent().parent().find('.cont-txt-int').width();
				var w_img_v = parseInt($(photo).attr('_w'));
				var h_img_v = parseInt($(photo).attr('_h'));
				var w_max= _w1-96-width_txt;
				var h_max= _h1;
				$(photo).css('height',_h1);
				$(photo).css('width','auto');
				//var dimensions_vertical = getMinAreaResize(w_img_v ,h_img_v, w_max, h_max);
				//alert(dimensions_vertical[0]);
				//alert(dimensions_vertical[1]);
			});	
		}
	}catch(e){}
	//
	$(slideshow).find('.photo-calendar').each(function() {
    	$(this).css('height',Math.ceil(dimensions[1]));	
		$(this).css('width',Math.ceil(dimensions[0]));
  	});
	
	$('#site').css('visibility','visible');


	if(obj!='start'){
		try
		{
			var current_section = $(section_calendar);
			var sl= $(current_section).attr('id');
			var nro = sl.split('-');
			var id_section = parseInt(nro[1]);
			
			if(obj!= 'start'){
				if(id_section>0){
					$(slideshow).find('ul').css('left', -(_w*Math.abs(id_section-1)));	
				}else{
					$(slideshow).find('ul').css('left', 0);	
				}
			}
		}
		catch(e)
		{
			$(slideshow).find('ul').css('left', 0);	
		}
	}
	
	if(obj=='start'){

	}
	setTimeout(function(){resize_calendar="false";},100)

}

function changePreviewArchive(){
	var slideshow =$('.slideshow-calendar-'+id_slideshow_calendar);
	var div = $(slideshow).find('.info_archive');
	
	var archive_prev = $(div).attr('txt_archivio_prev');
	var archive_next = $(div).attr('txt_archivio_next');
	
	var img_prev = $(div).attr('img_archivio_prev');
	var img_next = $(div).attr('img_archivio_next');

	if(archive_prev!='' && img_prev!= ''){
		var img_top = $('#arrow-top-calendar').find('img');
		$(img_top).attr('src',img_prev);
		var txt_top = $('#arrow-top-calendar').find('.description');
		$(txt_top).html(archive_prev);
		$('#arrow-top-calendar .preview-slide').css('visibility','visible');
	}else{
		$('#arrow-top-calendar .preview-slide').css('visibility','hidden');
	}

	if(archive_next!='' && img_next!= ''){
		var img_bottom = $('#arrow-bottom-calendar').find('img');
		
		$(img_bottom).attr('src',img_next);
		var txt_bottom = $('#arrow-bottom-calendar').find('.description');

		$(txt_bottom).html(archive_next);
		$('#arrow-bottom-calendar .preview-slide').css('visibility','visible');
	}else{
		$('#arrow-bottom-calendar .preview-slide').css('visibility','hidden');
	}
}

function clickArrowTopCalendar(){
	var current_slideshow = $('.slideshow-calendar-'+id_slideshow_calendar);
	try{
		var prev_sl = $('.slideshow-calendar-'+(id_slideshow_calendar-1)).length;
	}catch(e){}
	if(prev_sl>0){
		//posiziona sl
		var new_slideshow = $('.slideshow-calendar-'+(id_slideshow_calendar-1));
		var arr_win = getDimWindow();
		var _h =  arr_win[1];
		$(new_slideshow).css('top',-_h);
		$(new_slideshow).css('display','block');
		$(new_slideshow).find('ul').css('left','0px');
		resizeBackgroundArchive('start',id_slideshow_calendar-1);
		id_slideshow_calendar-=1;
		changePreviewCal($(new_slideshow).find('#s-1'));
		loadVideo($(new_slideshow).find('#s-1'));
		changePreviewArchive();
		$(new_slideshow).animate({'top':0},400,function(){$(current_slideshow).css('display','none');});
		count_slide_archive=1;
	}
}

function clickArrowBottomCalendar(){
	var current_slideshow = $('.slideshow-calendar-'+id_slideshow_calendar);
	try{
		var next_sl = $('.slideshow-calendar-'+(id_slideshow_calendar+1)).length;
	}catch(e){}
	if(next_sl>0){
		//posiziona sl
		var new_slideshow = $('.slideshow-calendar-'+(id_slideshow_calendar+1));
		var arr_win = getDimWindow();
		var _h =  arr_win[1];
		$(new_slideshow).css('top',_h);
		$(new_slideshow).css('display','block');
		$(new_slideshow).find('ul').css('left','0px');
		resizeBackgroundArchive('start',id_slideshow_calendar+1);
		id_slideshow_calendar+=1;
		/*$('.slideshow-calendar').css('z-index',0);
		$(current_slideshow).css('z-index',1);
		$(new_slideshow).css('z-index',2);*/
		changePreviewCal($(new_slideshow).find('#s-1'));
		loadVideo($(new_slideshow).find('#s-1'));
		changePreviewArchive();
		$(new_slideshow).animate({'top':0},400,function(){$(current_slideshow).css('display','none');});
		count_slide_archive=1;
	}
}


var count_slide_archive = 1;
var resize_calendar = 'false';

//<!-- TODO: Sostituire JPLAYER -->
function clickArrowRightArchive(){
	if(resize_calendar =="false"){
		if($('.jp-jplayer').length >0){
			$('.jp-jplayer').jPlayer( "destroy" );
		}
		var slideshow = $('.slideshow-calendar-'+id_slideshow_calendar);
		var position_ul = $(slideshow).find('ul').position();
		var left_pos_ul = position_ul.left;
		
		var dim_window = getDimWindow();
		width_window = dim_window[0];
		if(count_slide_archive < $(slideshow).find('.section').length){
			var sposta;
			if(count_slide_archive+1 > $(slideshow).find('.section').length){
					count_slide_archive = $(slideshow).find('.section').length;
					var iden = count_slide_archive;
					var sposta = width_window*(iden-1);
					$(slideshow).find('ul').find('ul').animate({'left': -sposta },1000);	
					section_calendar = $(slideshow).find('#s-'+(iden));
					changePreviewCal(section_calendar);
					loadVideo(section_calendar);
			}else{ 
				if(count_slide_archive+1 <= $(slideshow).find('.section').length){
					count_slide_archive+=1;
					iden = count_slide_archive;
					var sposta = width_window*(iden-1);				
					$(slideshow).find('ul').animate({'left': -sposta },1000,function(){ slide_left = 'false';  });
					section_calendar = $(slideshow).find('#s-'+(iden+1));
					changePreviewCal(section_calendar);
					loadVideo(section_calendar);
				}
			}
	  }
  }
}

function clickArrowLeftArchive() {
	if(resize_calendar =="false"){
		slide_right= 'true';
		var slideshow = $('.slideshow-calendar-'+id_slideshow_calendar);
		var position_ul = $('.slideshow-calendar-'+id_slideshow_calendar).find('ul').position();
		var left_pos_ul = position_ul.left;
		
		var dim_window = getDimWindow();
		width_window = dim_window[0];
		

		
		if(count_slide_archive-1 < 0){
			if(count_slide_archive-1>0){
				var iden = 0;
				var sposta = width_window*(iden-1);
				count_slide_archive =0;
				$('.slideshow-calendar-'+id_slideshow_calendar).find('ul').animate({'left': -sposta },1000,function(){ slide_right = 'false'; });
				section_calendar = $('.slideshow-calendar-'+id_slideshow_calendar).find('#s-'+(iden));
				changePreviewCal(section_calendar);
				loadVideo(section_calendar);

			}
		}else{ 
			if(count_slide_archive-1>0){
				count_slide_archive-=1;
				iden = count_slide_archive;
				var sposta = width_window*(iden-1);
				
				$('.slideshow-calendar-'+id_slideshow_calendar).find('ul').animate({'left': -sposta },1000,function(){ slide_right = 'false'; });
				section_calendar = $('.slideshow-calendar-'+id_slideshow_calendar).find('#s-'+(iden));
				changePreviewCal(section_calendar);
				loadVideo(section_calendar);
			}
		}
		
		
		slide_right= 'true';
	}
}


/************FUNCTION CALENDAR*******************/
//slideshow-calendar
var section_calendar ;
function initializeCalendar() {
    resizeBackgroundCalendar('resize');
	setPositionPreview();
	embedPlayerVideo();


	$(window).resize(function () {
	    resizeBackgroundCalendar('resize');
	    setPositionPreview();
	    //embedPlayerVideo();
	});

}
function arrowsVisibiliy(opacity) {
    if (count_slide > 1)
        $('#arrow-left-calendar .arrow').show().fadeTo('slow', opacity);
    else
        $('#arrow-left-calendar .arrow').hide();
    if (count_slide < $('.section').length)
        $('#arrow-right-calendar .arrow').show().fadeTo('slow', opacity);
    else
        $('#arrow-right-calendar .arrow').hide();

    $('#arrow-top-calendar .arrow').show().fadeTo('slow', opacity);
    $('#arrow-bottom-calendar .arrow').show().fadeTo('slow', opacity);
}

//<!-- TODO: Sostituire JPLAYER -->
function loadVideo(el){
	if($(el).children('.section').find('.section-video-out').length>0){
		var obj = $(el).find('.jp-jplayer');
		var preview = $(el).find('.inp_video').attr('preview_video');
		var src = $(el).find('.inp_video').attr('src_video');
	
		embedVideoGallery(obj,src,preview,700,390);
	}	
}

function resizeBackgroundCalendar(obj) {
	resize_calendar = 'true';
	var old_w_li = $('.slideshow-calendar li').width();
	var ps_ul = $('.slideshow-calendar ul').position();
	var old_pos_left_ul = ps_ul.left;
	var id_current_slide = Math.abs(Math.floor(old_pos_left_ul/old_w_li));
	
	$('#background').css('width','100%');
	$('#background').css('height','100%');	
	
	var arr_win = getDimWindow();
	var _w =  arr_win[0];
	var _h =  arr_win[1] - 84;
	var w_img = parseInt($('.photo-calendar').attr('_w'));
	var h_img = parseInt($('.photo-calendar').attr('_h'));
	
	var _w1 =  arr_win[0];
	var _h1 =  arr_win[1];
	if(arr_win[0] < 995 && arr_win[1] < 584){
		_w1 = 995;
		_h1 = 584;
	}
	var dimensions = getMinAreaResize(w_img ,h_img, _w1, _h1);

	
	var newH = dimensions[1];
	var newW = dimensions[0];
	var rapOrig = w_img / h_img;
	
	$('.slideshow-calendar ul').css('width', _w*$('.section').length);
	$('.slideshow-calendar ul').css('height', _h+84);
	$('.slideshow-calendar li').css('height', _h+84);
	$('.slideshow-calendar li').css('width', _w);
	$('.section').css('width', _w);
	$('.section-calendar').css('width', _w);
	
	
	
	var width_photo = dimensions[0];
	var diff = (width_photo-_w);
	
	
	
	$('.photo-calendar').each(function() {
    	$(this).css('height',Math.ceil(dimensions[1]));	
		$(this).css('width',Math.ceil(dimensions[0]));
  	});
	
	$('#site').css('visibility','visible');


	if(obj!='start'){
		try
		{
			var current_section = $(section_calendar);
			var sl= $(current_section).attr('id');
			var nro = sl.split('-');
			var id_section = parseInt(nro[1]);
			
			if(obj!= 'start'){
				if(id_section>0){
					$('.slideshow-calendar ul').css('left', -(_w*Math.abs(id_section-1)));	
				}else{
					$('.slideshow-calendar ul').css('left', 0);	
				}
			}
		}
		catch(e)
		{
			$('.slideshow-calendar ul').css('left', 0);	
		}
	}
	
	if(obj=='start'){

	}
	setTimeout(function(){resize_calendar="false";},100)

}

function setPositionPreview(){
	var dim_win = getDimWindow();
	var height_page = ((dim_win[1] < 584)? 584:dim_win[1]);
	var height_preview = $('.preview-slide').height()+8;
	var position_top = ((height_page-95) - height_preview)/2;
	$('.preview-slide').css('top',position_top+95);
	var position_top_arr = ((height_page-95) - 31)/2;
	$('.arrow').css('top',95+position_top_arr);
	
	//set arrows archive
	var dim_win = getDimWindow();
	var height_page = ((dim_win[1] < 584)? 584:dim_win[1]);
	var width_page = ((dim_win[0] < 995)? 995:dim_win[0]);
	
	var height_preview = $('.preview-slide').height()+8;
	var position_top = ((height_page-95) - height_preview)/2;
	$('.preview-slide').css('top',position_top+95);
	var position_top_arr = ((height_page-95) - 31)/2;
	$('.arrow').css('top',95+position_top_arr);
	
	var positionleft_arr = ((width_page) - 37)/2;
	//set arrows archive
	try{
		$('.arrow-archive').css('left',positionleft_arr);
		$('.arrow-archive').css('top','0px');
		$('.preview-slide-archive').css('top','41px');
		$('.preview-slide-archive').css('left',Math.floor((width_page-$('.preview-slide').width())/2));
		$('.preview-slide-archive-bottom').css('top',-(height_preview+7));
	}catch(e){}
}

function showPreview(obj){
	var preview = $(obj).parent().children('.preview-slide');
	$(preview).fadeIn();
}

function hidePreview(obj){
	var preview = $(obj).parent().children('.preview-slide');
	$(preview).fadeOut();
}

function showArrow(obj) {
    var id = $(obj).attr("id");
    if (id=="arrow-left-calendar" && count_slide > 1)
        $(obj).children('.arrow').fadeTo('slow',1);
    else if (id == "arrow-right-calendar" && count_slide < $('.section').length)
        $(obj).children('.arrow').fadeTo('slow', 1);
    else if (id == "arrow-bottom-calendar")
        $(obj).children('.arrow').fadeTo('slow', 1);
    else if (id == "arrow-top-calendar")
        $(obj).children('.arrow').fadeTo('slow', 1);
}

function hideArrow(obj) {
    var id = $(obj).attr("id");
    if (id == "arrow-left-calendar" && count_slide > 1)
        $(obj).children('.arrow').fadeTo('slow', 0.2);
    else if (id == "arrow-right-calendar" && count_slide < $('.section').length)
        $(obj).children('.arrow').fadeTo('slow', 0.2); 
    else if (id == "arrow-bottom-calendar")
        $(obj).children('.arrow').fadeTo('slow', 0.2); 
    else if (id == "arrow-top-calendar")
        $(obj).children('.arrow').fadeTo('slow', 0.2); 
}


var slide_left = 'false';
var slide_right = 'false';
var count_slide = 1;
var resize_calendar = 'false';

function clickArrowRightCalendar(){
	if(resize_calendar =="false"){
		if($('.jp-jplayer').length >0){
			$('.jp-jplayer').jPlayer( "pause" );
		}
		var position_ul = $('.slideshow-calendar ul').position();
		var left_pos_ul = position_ul.left;
		
		var dim_window = getDimWindow();
		width_window = dim_window[0];
		if(count_slide < $('.section').length){
			var sposta;
			if(count_slide+1 > $('.section').length){
					count_slide = $('.section').length;
					var iden = count_slide;
					var sposta = width_window*(iden-1);
					$('.slideshow-calendar ul').animate({'left': -sposta },1000);	
					section_calendar = $('#s-'+(iden));
					changePreviewCal(section_calendar);
					loadVideo(section_calendar);
			}else{ 
				if(count_slide+1 <= $('.section').length){
					count_slide+=1;
					iden = count_slide;
					var sposta = width_window*(iden-1);				
					$('.slideshow-calendar ul').animate({'left': -sposta },1000,function(){ slide_left = 'false';  });
					section_calendar = $('#s-'+(iden));
					changePreviewCal(section_calendar);
					loadVideo(section_calendar);
					$("#arrow-right-calendar").children('.arrow').hide();
				}
			}
            arrowsVisibiliy(0.2);
	}
  }
}

function clickArrowLeftCalendar() {
    if (resize_calendar == "false") {
        if ($('.jp-jplayer').length > 0) {
            $('.jp-jplayer').jPlayer("pause");
        }
			slide_right= 'true';
			var position_ul = $('.slideshow-calendar ul').position();
			var left_pos_ul = position_ul.left;
			
			var dim_window = getDimWindow();
			width_window = dim_window[0];
			
	
			
			if(count_slide-1 < 0){
			    if (count_slide - 1 > 0) {
						var iden = 0;
						var sposta = width_window*(iden-1);
						count_slide =0;
						$('.slideshow-calendar ul').animate({'left': -sposta },1000,function(){ slide_right = 'false'; });
						section_calendar = $('#s-'+(iden));
						changePreviewCal(section_calendar);
						loadVideo(section_calendar);

					}
			}else{
                if (count_slide - 1 > 0) {
					count_slide-=1;
					iden = count_slide;
					var sposta = width_window*(iden-1);

					$("#arrow-left-calendar").children('.arrow').hide();
					$('.slideshow-calendar ul').animate({'left': -sposta },1000,function(){ slide_right = 'false'; });
					section_calendar = $('#s-'+(iden));
					changePreviewCal(section_calendar);
					loadVideo(section_calendar);
				}
			}
            arrowsVisibiliy(0.2);
			
			slide_right= 'true';
	}
}

//FIX ALESSIO PER LOAD ASINCRONO IMMAGINI NEL CALENDARIO
function loadCalendarImageAtIndex(index) {
    var parent = $('.slideshow-calendar .ul_calendar #s-' + index);
    if (parent.length == 0)
        return;
    var imgTag = $(parent).find("img.photo-calendar");
    if (imgTag.attr("src") == "")
        return;
    var img_src = $(parent).find("div.preview").attr("img_current");
    $(parent).find(".photo-calendar").attr("src", img_src);
}

//FIX ALESSIO PER LOAD ASINCRONO IMMAGINI NEL CALENDARIO
function clickArrowRightCalendarAsyncImage() {
    loadCalendarImageAtIndex(count_slide + 1);
    clickArrowRightCalendar();
}


function changePreviewCal(slide){

	var div = $(slide).find('.preview');
	var mese_prev = $(div).attr('mese_prev');
	var mese_next = $(div).attr('mese_next');
	
	var img_prev = $(div).attr('img_prev');
	var img_next = $(div).attr('img_next');

	if(mese_prev!='' && img_prev!= ''){
		var img_left = $('#arrow-left-calendar').find('img');
		$(img_left).attr('src',img_prev);
		var txt_left = $('#arrow-left-calendar').find('.description');
		$(txt_left).html(mese_prev);
		$('#arrow-left-calendar .preview-slide').css('visibility','visible');
	}else{
		$('#arrow-left-calendar .preview-slide').css('visibility','hidden');
	}

	if(mese_next!='' && img_next!= ''){
		var img_right = $('#arrow-right-calendar').find('img');
		
		$(img_right).attr('src',img_next);
		var txt_right = $('#arrow-right-calendar').find('.description');

		$(txt_right).html(mese_next);
		$('#arrow-right-calendar .preview-slide').css('visibility','visible');
	}else{
		$('#arrow-right-calendar .preview-slide').css('visibility','hidden');
	}
}

function resizeUlSlideshow(){
	//dim finestra
	/*
	var dim_window = getDimWindow();
	width_window = dim_window[0];
	var nro_li = $('.slideshow-calendar').children('ul').children('li').length;

	$('.slideshow-calendar .section').css('width',width_window);
	$('.slideshow-calendar .section-calendar').css('width',width_window);

	var length_slideshow = width_window*nro_li;
	$('.slideshow-calendar').children('ul').css('width',length_slideshow);
	
	//slide che sto visualizzando
	var position_ul = $('.slideshow-calendar ul').position();
	var left_pos_ul = position_ul.left;
	var slide = count_slide;
	var pos_slide = ((slide == 0)? 0:-(slide*width_window));
	$('.slideshow-calendar').children('ul').css('left',-(slide*width_window));
	*/
}

function embedPlayerVideo(){
	var nro_video = $('.cont-video').length;	
	var videos = $('.cont-video');
	for (i = 0; i < nro_video; i++) {
	    var video = videos[i];
	    var v = $(video).find('.jp-jplayer');
	    var src_video = $(video).parent().parent().find('input').attr('src_video');
	    var preview = $(video).parent().parent().find('input').attr('preview_video');
	    var ancestor = $(v).attr('id');
	    var id_video = ancestor.split('_');
	    var an = '#jp_container_' + id_video[2];
	    embedVideoHistory($(v), src_video, "", preview, 700, 390, id_video[2]);
	}
}



function setPositionVideo(){
	var dim_window = getDimWindow();
	width_window = dim_window[0];
	height_window = dim_window[1] -95;
	height_video = $('.cont-video').height();
	var pos_top = Math.floor((height_window-height_video)/2)+95;
	$('.cont-video').css('margin-top',pos_top);
	
	//posiziona testo video
	
	$('#calendar .cont-txt-video .cont-txt-int').css('margin-top', pos_top-18);
	
	//centra scheda video
	var margin_sh_video = (width_window-888)/2;
	$('.section-video-out').css('margin-left',margin_sh_video);
}

var count_arrows_calendar = 0;
var sh_arrows;
function showHideArrows() {
	if(count_arrows_calendar < 6){
		if(count_arrows_calendar%2 == 0){
		        $('#arrow-left-calendar').addClass('selected');
                $('#arrow-right-calendar').addClass('selected');
			try{
				$('#arrow-top-calendar').addClass('selected');
				$('#arrow-bottom-calendar').addClass('selected');	
			}catch(e){}
        } else {
			$('#arrow-left-calendar').removeClass('selected');
			$('#arrow-right-calendar').removeClass('selected');
			try{
				$('#arrow-top-calendar').removeClass('selected');
				$('#arrow-bottom-calendar').removeClass('selected');
            } catch (e) {
            
            }
		}
		count_arrows_calendar +=1;
	}else{
    clearInterval(sh_arrows);
    arrowsVisibiliy(0.2);
    }
}

/**********FUNCTIONS HISTORY**************/
var resize_history = false;
var new_larg_arrows;
var iden_obj_open;
var box_info_open = 'off';
function positionElementsHistory(){
	clearInterval(interval_history);
	/*****position scroll*****/
	var dimWindow = getDimWindow();
	var heightWindow = dimWindow[1];
	
	/**********************/
	var cont = $('#h-'+iden_obj_open).find('.box-history-open-int');
	//var pos_cont =$(cont).position();
	//var pos_cont_top = pos_cont.top;
	
	space_scroll = ($(cont).height()-heightWindow)+105;
	
	if(Math.abs(positionBoxInfo) < 0 && positionBoxInfo > space_scroll){
		positionBoxInfo = space_scroll;
	}

	//alert('resize');
	$('.box-history-open-int').css('top','0px');	
		

	/********/
	var nro_li_vis =  $('#history li').length;
	var nro_li_hidden =  $('.pl_item').length;
	var nro_li = nro_li_vis-nro_li_hidden;
	var dim_window = getDimWindow();
	height_window = dim_window[1] ;
	width_window = dim_window[0];
	
	var pos_box_history = Math.floor(((height_window-95)-327)/2);
	$('.box-history').css('margin-top',pos_box_history);
	var width_ul = $('#history ul').children('li').length * 222;
	$('#history ul').css('min-width',width_ul);
	
	//guarda che ci siano sempre numeri dispari di oggetti
	var el = Math.floor(width_window/222);
	if(width_window < 995){
		el =4;	
	}else{
		var el = ((el%2==0)?el:el-1);
	}
	//position arrows
	var pos_top_arrow = Math.floor((height_window-$('.btn_prev_history').height()-95)/2);
	$('.btn_prev_history').css('top',pos_top_arrow +11);
	$('.btn_next_history').css('top',pos_top_arrow+11);
	
	
	var dim_cont = el*222;
	$('.cont-history-slidshow').css('width',dim_cont);
	var margin_left = Math.ceil((width_window-dim_cont)/2);
	$('.cont-history-slidshow').css('margin-left',margin_left );
	new_larg_arrows = margin_left;

	$('#history .hover').css('display', 'none');
	$('#history ul li').css('height',height_window);
	setTimeout(function(){
		//nascondi shadows
		if(event_trigger == true){
				//riposiziona box
				//guarda che c'� spazio per centrare il tutto
			var el = Math.floor(width_window/222);
			var dim_cont = el*222;
			
			if(width_window < 995){
				el =4;	
			}else{
				var el = ((el%2==0)?el:el-1);
			}
		
			dim_cont = el*222;
			//visualizza obj che si vedono	
			//vedi qnt ogg si vedono
			var el_show = Math.ceil((el-(nro_li-2))/2);

			pos_center = position_li_close-(222*el_show);
			//sposta el li
			$('.cont-history-slidshow ul').css('left',-pos_center+'px');
			//mi servono4 qdr per oggetto
			var scarto;
			if(el == 4){
				//visualizza loro qdr
				$('.cont-history-slidshow').css('width','888px');
				scarto = width_window-(Math.floor((width_window-888)/2)*2 + 888);
				var margin_left = Math.floor((width_window-888)/2)+scarto;
				new_larg_arrows = margin_left;
				$('.cont-history-slidshow').css('margin-left',margin_left);
				
			}else{
				//di al tuo slidshow di andare a quella slide
				$('.cont-history-slidshow').css('width',el*222);
				scarto = width_window-(Math.floor((width_window-(el*222))/2)*2 + (el*222));
				var margin_left = Math.floor((width_window-(el*222))/2)+scarto;
				$('.cont-history-slidshow').css('margin-left',margin_left);
			}
			new_larg_arrows = margin_left;
			
			if(parseInt(iden_obj_open) == nro_li){
				//vedi dov e li apert e in base a quello allarga
				var larg = el_show*222;
				$('#cont-arrow-right').width(new_larg_arrows+larg-scarto);
			}else{
				$('#cont-arrow-right').width(new_larg_arrows-scarto);
			}

			if(parseInt(iden_obj_open) == 1){
				//vedi dov e li apert e in base a quello allarga
				var larg = el_show*222;
				$('#cont-arrow-left').width(new_larg_arrows+larg);
			}else{
				$('#cont-arrow-left').width(new_larg_arrows);
			}
			
			
			//$('.btn_next_history').width(new_larg_arrows);
			//$('.btn_prev_history').width(new_larg_arrows);
		
			setTimeout(function(){
				if(isIE()){
				    $('#history .hover').css('display', 'block');	
				}else{
				    $('#history .hover').show('fast');
				}
			},200);
		}
	},300);

$('#history .shadow.hover').css('height', height_window);
	
	var cont = $('#h-'+iden_obj_open).find('.box-history-open-int');
	space_scroll = ($(cont)-height_window)+105;
	
	if(box_info_open == 'off'){
		initializeIntervalHistory();
	}
}


var nro_li_visible=0;
var interval_history;
var first_slide;
//		btnGo : ['.btn_more2','.btn_more3','.btn_more4','.btn_more5','.btn_more6','.btn_more7','.btn_more7'],
var pos_scroll_init = 0;
var scroll_right = 'on';
var pos_scroll;
var totalElement;
function initializeCarouselleHistory(){
	$('.pl_item').css('visibility','hidden');
	
	var size_window =  getDimWindow();
	var width_window = size_window[0];
	var nro_li = Math.ceil((width_window-110)/222);
	nro_li_visible = nro_li;
	
	var arrDots=new Array();
	
	for (i=0; i<= $('.btn_more_hidden').length; i++) { 
		arrDots[i]=".btn_more_hidden"+(i+1);
	}

	$(".cont-history-slidshow").jCarouselLite({
	    speed: 1000,
	    visible: nro_li_visible,
	    btnPrev: '.btn_prev_history_hidden',
	    btnNext: '.btn_next_history_hidden',
	    circular: true,
	    btnGo: arrDots,
	    beforeStart: function (a) {
	        if (slide_pos == 'prev') { }
	    },
	    afterEnd: function (a) {
	        first_slide = a[0];
	        $('.pl_item').css('vsiibility', 'hidden');
	    }
	});
	
	$('.pl_item').css('visibility','hidden');
	initializeIntervalHistory();

	
	$(".btn_prev_history").bind("click", function () {
		clearInterval(interval_history);
		//vai alla slide tot
		scroll_right = 'off';
		if(pos_scroll_init > 0){
			$('.btn_prev_history_hidden').trigger('click');
			pos_scroll_init-=1;
		}
	});

	$(".btn_next_history").bind("click", function () {
	    clearInterval(interval_history);
	    //vai alla slide tot
	    scroll_right = 'on';
	    if (pos_scroll_init <= totalElement) {
	        $('.btn_next_history_hidden').trigger('click');
	        pos_scroll_init += 1;
	    }

	});
	//$(".btn_next_history").bind("click", function () { $('.btn_next_history').css('display','block');});

	$("#cont-arrow-left").bind("mouseover", function () {$('.btn_prev_history').css('display','block');});
	$("#cont-arrow-right").bind("mouseover", function () { $('.btn_next_history').css('display','block');});
	$("#cont-arrow-left").bind("mouseout", function () {$('.btn_prev_history').css('display','block');});
	$("#cont-arrow-right").bind("mouseout", function () {$('.btn_next_history').css('display','block');});
	
	
	$('.pl_item .box-history-open').remove();

}

function initializeIntervalHistory() {
    totalElement =($('#history li').length - $('#history li.pl_item').length);
	var nro_li_vis =  $('#history li').length;
	var nro_li_hidden =  $('.pl_item').length;
	var nro_li =  nro_li_vis-nro_li_hidden;
	nro_slide = Math.ceil(nro_li/3);
	var w = getDimWindow();
	var width_window = w[0];
	var el = Math.floor(width_window/222);
	var dim_cont = el*222;
	if(width_window < 995){
		el =4;	
	}else{
		var el = ((el%2==0)?el:el-1);
	}
	pos_scroll = nro_li-el;
	if(pos_scroll>0){
		interval_history = setInterval( function(){
												//vai alla slide tot
												if(scroll_right == 'on'){
													if(pos_scroll_init < pos_scroll){														
														$('.btn_next_history_hidden').trigger('click');
														pos_scroll_init+=1;
													}else{
														scroll_right = 'off';
														$('.btn_prev_history_hidden').trigger('click');
														pos_scroll_init-=1;
													}
												}else{
													if(pos_scroll_init < 1){
														scroll_right = 'on';
														$('.btn_next_history_hidden').trigger('click');
														pos_scroll_init+=1;
													}else{
														$('.btn_prev_history_hidden').trigger('click');
														pos_scroll_init-=1;
													}
												}																		
											//var slide = $(".btn_more_hidden"+(first_slide+1));
										}, 5000);
	
	}
}

//<!-- TODO: Sostituire JPLAYER -->
function embedVideoHistory(obj,src,src_ogv,preview,w,h,an){
/*console.log(an);
//console.log(src);
//console.log(preview);*/
		  $(obj).jPlayer({
			ready: function () {
			  $(this).jPlayer("setMedia", {
				m4v: src,
				poster: preview
			  });
			},
			swfPath: "/js/jQuery.jPlayer.2.1.0",
			supplied: "m4v",
            solution:'html,flash',
			size: {
				width: w,
				height: h,
				cssClass: "video"
			} ,
			cssSelector: {
				play: "#jp-video-play-"+an,
				pause: "#jp-pause-"+an,
				stop: ".jp-stop",
				seekBar: ".jp-seek-bar",
				playBar: ".jp-play-bar",
				mute: ".jp-mute",
				unmute: ".jp-unmute",
				volumeBar: ".jp-volume-bar",
				volumeBarValue: ".jp-volume-bar-value",
				volumeMax: ".jp-volume-max",
				currentTime: ".jp-current-time",
				duration: ".jp-duration",
				restoreScreen: ".jp-restore-screen",
				repeat: ".jp-repeat",
				repeatOff: ".jp-repeat-off",
				gui: ".jp-gui",
				noSolution: ".jp-no-solution"
			},
			cssSelectorAncestor : '#jp_container_'+an
			//warningAlerts : true
});
		  
		 //$(video).css('width',w);
		 //$(video).css('height',h);
}


//<!-- TODO: Sostituire JPLAYER -->
var position_ul_old;
var position_li_close;
var event_trigger = false;
var li_open;
var old_width_ul;

function showMoreFromParent(obj) {
    var child = $(obj).children("a");
    showMore(child);
}

function showMore(obj) {
	//embedVideoGallery($('#jp-jplayer0'),'http://www.jplayer.org/video/m4v/Big_Buck_Bunny_Trailer_480x270_h264aac.m4v','img/prov/history/big_1.jpg',287,222);
	//positionBoxInfo= 0;
	var nro_li_vis =  $('#history li').length;
	var nro_li_hidden =  $('.pl_item').length;
	var nro_li = nro_li_vis-nro_li_hidden;
	
	clearInterval(interval_history);
	box_info_open = 'on';
	
	var li = $(obj).parent().parent();	
	
	//load video
	//if($(li).children('.box-history-open').find('.video-history') > 0){
	$('.jp-jplayer').jPlayer( "destroy" );
	var box_info = $(li).find('.video-history');
	
	for (i=0; i< $(box_info).length; i++) {
		var video = box_info[i];
		var v =$(video).find('.jp-jplayer');
		var src_video = $(video).find('input').attr('src');
		var src_ogv = $(video).find('input').attr('src_ogv');
		var preview = $(video).find('input').attr('preview');
		var ancestor = $(v).attr('id');
		var id_video = ancestor.split('_');
		var an = '#jp_container_'+id_video[2];
		embedVideoHistory($(v),src_video,src_ogv,preview,287,222,id_video[2]);
	}
	//}
	//load video
	

	
	
	$(li).addClass('open');
	li_open = li;
	
	
	
	var id_li = $(li).attr('id');
	var id = id_li.split('-');
	var iden = id[1];
	iden_obj_open = iden;
	
	var w = getDimWindow();
	var width_w = w[0];
	var pos = Math.floor((width_w-888)/2);
	var slide = Math.floor(pos/222);
	width_window = width_w;
	
	
	
	//guarda che c'� spazio per centrare il tutto
	var el = Math.floor(width_w/222);
	var dim_cont = el*222;
	if(width_window < 995){
		el =4;	
	}else{
		var el = ((el%2==0)?el:el-1);
	}
	
	var pos_li_sel = $(li).position();
	pos_li_sel_left = (pos_li_sel.left);
	position_li_close = pos_li_sel_left;
	

		//visualizza obj che si vedono	
		//vedi qnt ogg si vedono
		var el_show = Math.ceil(el-4)/2;
		
		var scarto;
		//mi servono4 qdr per oggetto
		if(el == 4){
			//visualizza loro qdr
			$('.cont-history-slidshow').css('width','888px');
			scarto = width_window-(Math.floor((width_window-888)/2)*2 + 888);
			var margin_left = Math.floor((width_window-888)/2)+scarto;
			
			$('.cont-history-slidshow').css('margin-left',margin_left);
			
		}else{
			//di al tuo slidshow di andare a quella slide
			$('.cont-history-slidshow').css('width',el*222);
			scarto = width_window-(Math.floor((width_window-(el*222))/2)*2 + (el*222));
			var margin_left = Math.floor((width_window-(el*222))/2)+scarto;
			$('.cont-history-slidshow').css('margin-left',margin_left);
		}
		
		new_larg_arrows = margin_left;
		//id === el
		var id_obj = iden-el_show;
		
		
		//pos el sel se fosse il primo
		var pos_li_first = (222*(nro_li-2))+(222*iden);
		var pos_ul = $('.cont-history-slidshow ul').position();
		position_ul_old = (pos_ul.left);
		
		
		old_width_ul = $('.cont-history-slidshow ul').width();
		$('.cont-history-slidshow ul').css('width',$('.cont-history-slidshow ul').width()+2000);
		
		var pos_li_sel = $(li).position();
		pos_li_sel_left = (pos_li_sel.left);
		position_li_close = pos_li_sel_left;
		//sposta el li
		pos_center = pos_li_sel_left-(222*el_show);
		$('.cont-history-slidshow ul').animate({'left':-pos_center+'px'}, 1000,function(){
				var el_li = $('.shadow').parent();
				for (i=0; i<el_li.length; i++) {
					var li = el_li[i];
					if( !$(li).hasClass('open')){
						$(li).children('.shadow').css('z-index',4);
						$(li).children('.shadow').addClass('hover');
						$(li).children('.shadow').height(w[1]);
					}
				}
				$('#cont-arrow-left').addClass('hover');
				$('#cont-arrow-right').addClass('hover');
				
				$("#cont-arrow-left").unbind();
				$("#cont-arrow-right").unbind();
				$('.btn_prev_history').css('display','none');
				$('.btn_next_history').css('display','none');
							
				if(parseInt(iden) == nro_li){
					//vedi dov e li apert e in base a quello allarga
					var larg = el_show*222;
					$('#cont-arrow-right').width(new_larg_arrows+larg-scarto);
				}else{
					$('#cont-arrow-right').width(new_larg_arrows-scarto);
				}

				if(parseInt(iden) == 1){
					//vedi dov e li apert e in base a quello allarga
					var larg = el_show*222;
					$('#cont-arrow-left').width(new_larg_arrows+larg);
				}else{
					$('#cont-arrow-left').width(new_larg_arrows);
				}
			
		});		


	event_trigger = true;




	$(obj).parent().hide();
	var box_open = $(li).children('.box-history-open');
	$(box_open).fadeIn(500,function(){});
	$(li).css('width','888px');
	

	//var id_fisrt_slide = $(first_slide).attr('id');
	var id_li_selected = $(li).attr('id');
	if(isIE()){
		$('.box-history-open-int').css('height','100%');
	}

	
	scrollBox(obj);



}

function closeBoxHistoryOpen(obj){
	box_info_open = 'off';
	$('.jp-jplayer').jPlayer( "destroy" );
	$('.cont-history-slidshow ul').css('width',old_width_ul);
	
	var li = $(obj).parent().parent();
	
	$(li).removeClass('open');
	var id_li = $(li).attr('id');
	
	

	var box_open = $(li).children('.box-history-open');
	$(box_open).css('display','none');
	
	var box = $(li).children('.box-history');
	$(box).fadeIn();
	
	$(li).css('width','222px');
	$(li).css('height','100%');
	$('.cont-history-slidshow ul').animate({'left':position_ul_old+'px'}, 500);
	
	$('.shadow').css('z-index',1);
	$('.shadow').removeClass('hover');
	$('#cont-arrow-right').removeClass('hover');
	$('#cont-arrow-left').removeClass('hover');
	$('.shadow').css('height','0px');
	event_trigger = false;
	//positionElementsHistory(); FIX ALESSIO
	/*interval_history = setInterval(function(){
		$('.btn_next_history').trigger('click');	
	},5000);*/
	
	//initializeIntervalHistory();
	
	$(".btn_prev_history").bind("click", function () {clearInterval(interval_history);});
	$(".btn_next_history").bind("click", function () {clearInterval(interval_history);});
	
	$("#cont-arrow-left").bind("mouseover", function () {$('.btn_prev_history').css('display','block');});
	$("#cont-arrow-right").bind("mouseover", function () {$('.btn_next_history').css('display','block');});
	$("#cont-arrow-left").bind("mouseout", function () {$('.btn_prev_history').css('display','none');});
	$("#cont-arrow-right").bind("mouseout", function () {$('.btn_next_history').css('display','none');});
}



function scrollBottom(){
	
}

var scrollTop;
var scrollDown;
var positionBoxInfo =0;
var h_box;
var space_scroll = 0;
function scrollBox(obj){

	
	var dimWindow = getDimWindow();
	var heightWindow = dimWindow[1];
	
	
	
	var cont = $(obj).parent().parent().children('.box-history-open').children('.box-history-open-int');
	if(isIE()){
		//$(cont).find('.row').height();
		//console.log($(cont).find('.row').height());
		var max_h = Math.max($(cont).find('.row').height());	
		$(cont).css('height',max_h);
	}
	space_scroll = ($(cont).height()-heightWindow)+105;
	var info =$(cont).children('.cont-info');
	var value= 140;
	
	if($(cont).size()!=0){
		//$('#carouselle-home-int').height($(window).height()-$('#headerInt').height()-value);
		
		
		var h= $(info).height();
		if(h < heightWindow-value){
			//se non devo scrollare
			$(cont).css('top','0px');
			$('.cont-arrows').css('display','none');
		}else{
			$(cont).css('top','0px');
			$('.cont-arrows').css('display','block');
	    }
		

		animated = false;
		var arrow_top = $(obj).parent().parent().children('.box-history-open').children('.cont-arrows').children('.cont-arrows-int').children('.arrow-top');
		var arrow_bottom = $(obj).parent().parent().children('.box-history-open').children('.cont-arrows').children('.cont-arrows-int').children('.arrow-bottom');
		
		$(arrow_bottom).click(function(){
				var dimWindow = getDimWindow();
				var heightWindow = dimWindow[1];
				
				
				
				var cont = $(obj).parent().parent().children('.box-history-open').children('.box-history-open-int');
				space_scroll = ($(cont).height()-heightWindow)+105;					   
									   
									   
				positionBoxInfo +=100;
				if(positionBoxInfo > (space_scroll)){
					positionBoxInfo = space_scroll;
				}
				animated = true;
				$(cont).css('top',-positionBoxInfo+'px');
				//animate({'top':-positionBoxInfo+'px'}, 300);
			},200);
		
		$(arrow_top).mouseout(function(){
			clearInterval(scrollTop);
		});
		
		$(arrow_bottom).mouseout(function(){
			clearInterval(scrollBottom);
		});
		
		$(arrow_top).click(function(){
			
			positionBoxInfo -=100;
			//console.log('prima'+sp);
			if(positionBoxInfo < 0){
				positionBoxInfo = 0;
			}
			$(cont).css('top',-positionBoxInfo+'px');
			//animate({'top':-positionBoxInfo+'px'}, 300);
		},200);
				
	}	
}


function handle(delta) {

	var s = delta + ": ";
	
	
	
	if(iden_obj_open>0){
		var dimWindow = getDimWindow();
		var heightWindow = dimWindow[1];
		var cont = $('#h-'+iden_obj_open).find('.box-history-open-int');
		//console.log(cont);
		//space_scroll = Math.abs(($(cont).height()-heightWindow)+105);
		//console.log(space_scroll);
		//space_scroll = (heightWindow-140);
		if(space_scroll >0){
		    if (delta < 0) {
		        positionBoxInfo += 100;
		        if (positionBoxInfo > (space_scroll)) {
		            positionBoxInfo = space_scroll;
		        }
		        animated = true;
		        $(li_open).children('.box-history-open').children('.box-history-open-int').css('top', -positionBoxInfo + 'px');
		    }
		    else {
		        positionBoxInfo -= 100;
		        if (positionBoxInfo < 0) {
		            positionBoxInfo = 0;
		        }
		        $(li_open).children('.box-history-open').children('.box-history-open-int').css('top', -positionBoxInfo + 'px');
		    }
        } else {
            return;//FIX
			if (delta < 0){
				$('.arrow-bottom').trigger('click');
			}else{
				$('.arrow-top').trigger('click');
			}	
		}
	}
}
 
function wheel(event){	



	var delta = 0;
	if (!event) event = window.event;
	if (event.wheelDelta) {
		delta = event.wheelDelta/120; 
		if (window.opera) delta = -delta;
	}else if (event.detail) {
		delta = -event.detail/3;
	}

	if (delta)
		handle(delta);
}


/***************************FUNCTIONS LIMETED EDITION*******************************/
var positionTopLI=0;
var h_box =489;
var arrow_top_open = false;
var arrow_bottom_open = false;
var sp;

function positionElementsLI(){
	
	var dimWindow = getDimWindow();
	var heightWindow = dimWindow[1];
	

	//centra frecce
	var pos_arrows = Math.floor((heightWindow-195)/2);
	$('.cont-arrow-le .arrow-top').css('margin-top',pos_arrows+95);
	
	if(positionTopLI != 0){
		//riposiziona oggetto
		var pos = Math.abs(positionTopLI)/h_box;
		if((heightWindow-95) < 489){
			h_box = 489;	
		}else{
			h_box = (heightWindow-95);
			$('.box-lim-edition').css('height',h_box);
		}
		//riposiziona contenitore
		positionTopLI = h_box*pos;
		
		$('.cont-lim-edition').animate({'top':-positionTopLI+'px'}, 300);
	}else{
		//posiziona box
		//vedi qual � l atezza
		//il box deve essere alto come l altezza
		//altezza minima 489
		if((heightWindow-95) < 489){
			h_box = 489;	
		}else{
			h_box = (heightWindow-95);
			$('.box-lim-edition').css('height',h_box);
		}
		positionTopLI = 0;
	}
	
	//var _h=((isIE())?618:823);
	var div = $('.box-lim-edition').length;
	sp = (h_box*div)-heightWindow+95;
	
	
	

	
}

function clickBottle(){
	$(el_animated).queue("fx",[]);
	$(el_animated).stop();
	clearInterval(vibrazione_oggetto);
												
	var div = $('.box-lim-edition').length;										 
	if(arrow_top_open == false){
		arrow_top_open = true;
		//alert(positionTopLI);
		positionTopLI += h_box;
		if(positionTopLI > (sp)){
			positionTopLI = sp;
			//in che pos sono???
			
		}
	}
	$('.cont-lim-edition').animate({'top':-positionTopLI+'px'}, 300,function (){	
										
										arrow_top_open = false;
										//in che pos sono
										var nro_box = (positionTopLI/$('.box-lim-edition').height())+1;
										
	                                    if (nro_box == 1) {
	                                        if (!$('.cont-arrow-le .arrow-top').hasClass("noArrow"))
	                                            $('.cont-arrow-le .arrow-top').addClass("noArrow");
	                                    } else
	                                        $('.cont-arrow-le .arrow-top').removeClass("noArrow");

	                                    if (nro_box == $('.box-lim-edition').length) {
	                                        if (!$('.cont-arrow-le .arrow-bottom').hasClass("noArrow"))
	                                            $('.cont-arrow-le .arrow-bottom').addClass("noArrow");
	                                    } else
	                                        $('.cont-arrow-le .arrow-bottom').removeClass("noArrow");				   
										//$('.bottle').bind('click',function(){clickBottle()});
										//$('#box-'+(nro_box)).unbind('click');
																			
										//vai vibrare bott slide_succ
										var box = '#box-'+(nro_box+1);
										
										var bottle_box = $(box).children('.box-lt').children('.box-lim-edition-int').children('.bottle');
										if($(box).children('.box-lt').children('.box-lim-edition-int').hasClass('box-lim-edition-int-sx')){
											$(bottle_box).queue("fx",vibrate($(bottle_box),'right'));
										}else if($(box).children('.box-lt').children('.box-lim-edition-int').hasClass('box-lim-edition-int-dx')){
											$(bottle_box).queue("fx",vibrate($(bottle_box),'left'));
										}
									});
}

var el_animated;

function activateBoxBottles(){
	var nro_box = (positionTopLI/$('.box-lim-edition').height())+1;
	//vai vibrare bott slide_succ
	var box = '#box-'+(2);
	var bottle_box = $(box).children('.box-lt').children('.box-lim-edition-int').children('.bottle');
	if($(box).children('.box-lt').children('.box-lim-edition-int').hasClass('box-lim-edition-int-sx')){
		$(bottle_box).queue("fx",vibrate($(bottle_box),'right'));
	}else if($(box).children('.box-lt').children('.box-lim-edition-int').hasClass('box-lim-edition-int-dx')){
		$(bottle_box).queue("fx",vibrate($(bottle_box),'left'));
	}
	

	
	$('.link_bottle').bind('click',function(){
			//$('.bottle').bind('click',function(){clickBottle()});
			//$(this).unbind('click');
	    clickBottle();

	    var nro_box = (positionTopLI / $('.box-lim-edition').height()) + 1;
	    if (nro_box == 1) {
	        if (!$('.cont-arrow-le .arrow-top').hasClass("noArrow"))
	            $('.cont-arrow-le .arrow-top').addClass("noArrow");
	    } else
	        $('.cont-arrow-le .arrow-top').removeClass("noArrow");

	    if (nro_box == $('.box-lim-edition').length) {
	        if (!$('.cont-arrow-le .arrow-bottom').hasClass("noArrow"))
	            $('.cont-arrow-le .arrow-bottom').addClass("noArrow");
	    } else
	        $('.cont-arrow-le .arrow-bottom').removeClass("noArrow");				   
		}
	);
var nro_box = (positionTopLI / $('.box-lim-edition').height()) + 1;
if (nro_box == 1) {
    if (!$('.cont-arrow-le .arrow-top').hasClass("noArrow"))
        $('.cont-arrow-le .arrow-top').addClass("noArrow");
} else
    $('.cont-arrow-le .arrow-top').removeClass("noArrow");

if (nro_box == $('.box-lim-edition').length) {
    if (!$('.cont-arrow-le .arrow-bottom').hasClass("noArrow"))
        $('.cont-arrow-le .arrow-bottom').addClass("noArrow");
} else
    $('.cont-arrow-le .arrow-bottom').removeClass("noArrow");

	
	//attiva arrows
		$('.cont-arrow-le .arrow-bottom').click(function () {
		    $('.bottle').queue("fx", []);
		    $(el_animated).stop();
		    clearInterval(vibrazione_oggetto);
		    var div = $('.box-lim-edition').length;
		    //alert(h_box);
		    if (arrow_top_open == false) {
		        arrow_top_open = true;
		        positionTopLI += h_box;
		        if (positionTopLI > (sp)) {
		            positionTopLI = sp;
		            //in che pos sono???
		        }
		    }


		    var nro_box = (positionTopLI / $('.box-lim-edition').height()) + 1;
		    if (nro_box == 1) {
		        if (!$('.cont-arrow-le .arrow-top').hasClass("noArrow"))
		            $('.cont-arrow-le .arrow-top').addClass("noArrow");
		    } else
		        $('.cont-arrow-le .arrow-top').removeClass("noArrow");

		    if (nro_box == $('.box-lim-edition').length) {
		        if (!$('.cont-arrow-le .arrow-bottom').hasClass("noArrow"))
		            $('.cont-arrow-le .arrow-bottom').addClass("noArrow");
		    } else
		        $('.cont-arrow-le .arrow-bottom').removeClass("noArrow");


		    $('.cont-lim-edition').animate({ 'top': -positionTopLI + 'px' }, 300, function () {

		        arrow_top_open = false;
		        //in che pos sono
		        var nro_box = (positionTopLI / $('.box-lim-edition').height()) + 1;

		        //$('.bottle').bind('click',function(){clickBottle()});
		        //$('#box-'+(nro_box)).unbind('click');

		        //vai vibrare bott slide_succ
		        var box = '#box-' + (nro_box + 1);

		        var bottle_box = $(box).children('.box-lt').children('.box-lim-edition-int').children('.bottle');
		        if ($(box).children('.box-lt').children('.box-lim-edition-int').hasClass('box-lim-edition-int-sx')) {
		            $(bottle_box).queue("fx", vibrate($(bottle_box), 'right'));
		        } else if ($(box).children('.box-lt').children('.box-lim-edition-int').hasClass('box-lim-edition-int-dx')) {
		            $(bottle_box).queue("fx", vibrate($(bottle_box), 'left'));
		        }
		    });
		});


		$('.cont-arrow-le .arrow-top').click(function () {
		    $('.bottle').queue("fx", []);
		    clearInterval(vibrazione_oggetto);
		    $(el_animated).stop();
		    if (arrow_bottom_open == false) {
		        arrow_bottom_open = true;
		        positionTopLI -= h_box;
		        if (positionTopLI < 0) {
		            positionTopLI = 0;
		        }
		    }

		    var nro_box = (positionTopLI / $('.box-lim-edition').height()) + 1;
		    if (nro_box == 1) {
		        if (!$('.cont-arrow-le .arrow-top').hasClass("noArrow"))
		            $('.cont-arrow-le .arrow-top').addClass("noArrow");
		    } else
		        $('.cont-arrow-le .arrow-top').removeClass("noArrow");

		    if (nro_box == $('.box-lim-edition').length) {
		        if (!$('.cont-arrow-le .arrow-bottom').hasClass("noArrow"))
		            $('.cont-arrow-le .arrow-bottom').addClass("noArrow");
		    } else
		        $('.cont-arrow-le .arrow-bottom').removeClass("noArrow");

		    $('.cont-lim-edition').animate({ 'top': -positionTopLI + 'px' }, 300, function () { arrow_bottom_open = false; });

		    var nro_box = (positionTopLI / $('.box-lim-edition').height()) + 1;
		    //vai vibrare bott slide_succ
		    if (nro_box <= 1) {
		        nro_box = 3;
		    } else {
		        nro_box += 2;
		    }
		    //console.log('..................');
		    //$('.bottle').bind('click',function(){clickBottle()});
		    //var d =$('#box-'+(nro_box-2));
		    //$(d).unbind();
		    //console.log($(d));

		    var box = '#box-' + (nro_box - 1);
		    var bottle_box = $(box).children('.box-lt').children('.box-lim-edition-int').children('.bottle');
		    if ($(box).children('.box-lt').children('.box-lim-edition-int').hasClass('box-lim-edition-int-sx')) {
		        $(bottle_box).queue("fx", vibrate($(bottle_box), 'right'));
		    } else if ($(box).children('.box-lt').children('.box-lim-edition-int').hasClass('box-lim-edition-int-dx')) {
		        $(bottle_box).queue("fx", vibrate($(bottle_box), 'left'));
		    }
		});



	$('.box-lt').mouseenter(function () {

	    var dimWindow = getDimWindow();
	    var widthWindow = dimWindow[0];

	    var box_bk = $(this).parent().children('.box-bk').children('.box-bk-int');
	    $(this).parent().children('.box-bk').addClass('selected');
	    var src_background = $(this).parent().children('.box-bk').children('.box-bk-int').attr('background');

	    var color_background = $(this).parent().children('.box-bk').children('.box-bk-int').attr('color');
	    var url = color_background;
	    //$(this).parent().children('.box-bk').children('.box-bk-int').html('<img src="'+src_background+'" />');

	    var url2 = 'url(' + src_background + ') top center repeat';
	    //$(this).parent().children('.box-bk').css('background',url);
	    $(box_bk).css('background', url2);
	    var parentBox_bk = box_bk.parent();
	    var boxSelected = ($(this).parent().attr("id"));
	    setTimeout(function () {
	        var nro_box = (positionTopLI / $('.box-lim-edition').height()) + 1;
	        var box = 'box-' + (nro_box);
	        if (box_bk.parent().hasClass("selected") && boxSelected == box) {
	            $(box_bk).width(0);
	            if (nro_box % 2)
	                $(box_bk).css("float", "left");
                else
	                $(box_bk).css("float", "right");

                if (nro_box % 2)
                    $(box_bk).css("margin-left", "90px");
                else
                    $(box_bk).css("margin-right", "90px");

                $(box_bk).css("margin-top", "0px");

                $(box_bk).animate({ 'width': widthWindow, "margin-right": "0px", "margin-left": "0px" }, 700, function () { $(this).parent().children('.box-bk').css('background', url); });
	        }
	    }, 700);

	});

	$('.box-lt').mouseleave(function () {
	    //setTimeout(function(){
	    //$('.box-bk-int').css('display','none');	 

	    var box_bk = $(this).parent().children('.box-bk').children('.box-bk-int');
	    $('.box-bk').removeClass('selected');
	    $('.box-bk-int').animate({ 'width': 0 }, 200);
	    $('.box-bk-int').css('width', '995px');
	    //},300);
	});

/*
	$('.box-lim-edition-int').mouseout(function(){
		$('.box-bk').children('.box-bk-int').css('background','none');
		$('.box-bk').removeClass('selected');
		$(this).children('.box-bk-int').animate({'margin-top': '379px' }, 300);
		//console.log('out');
	});

	
	$('.box-lim-edition-int').mouseover(function(){
		//if(!$(this).hasClass('selected')){		
			$(this).addClass('selected');
			$('.box-bk').children('.box-bk-int').css('background','none');	
			
			var src_background = $(this).attr('background');
			var url = 'url('+src_background+') left center no-repeat';
			$(this).parent().parent().children('.box-bk').children('.box-bk-int').css('background',url);
			$(this).children('.box-bk-int').animate({'margin-top': '0px' }, 300);
		//}
		
	});*/
	
}

var vibrazione_oggetto;
var bottleVibreCountMax = 8;
var bottleVibreCount = 0;
var bottleLimitCount = 0;
var bottleLimitCountMax = 8;
function vibrate(obj,orientation) { // passi l'input + il valore da controllare
	el_animated = $(obj);
	var obj = $(obj);
	var pos;
	var dif = 10;
	//if(v != val) { // se il valore dell'input non è uguale a quello da controllare
	if(orientation == 'left'){
		pos = 89;
		var l='on';
		vibrazione_oggetto = setInterval(function () {
		    if (bottleVibreCount > bottleVibreCountMax) {

		        if (bottleLimitCount > bottleLimitCountMax) {
		            bottleLimitCount = 0;
		            bottleVibreCount = 0;
		        }
		        else {
		            bottleLimitCount++;
		        }
		        return;
		    }

		    if (l == 'on') {
		        pos = pos + dif;
		    } else {
		        pos = pos - dif;
		    }
		    obj.animate({ left: pos }, 60, function () { l = ((l == 'on') ? 'off' : 'on'); });
		    bottleVibreCount++;
		}, 100);
	}else{
		pos= 87;
		var l='on';

		vibrazione_oggetto = setInterval(function () {
		    if (bottleVibreCount > bottleVibreCountMax) {

		        if (bottleLimitCount > bottleLimitCountMax) {
		            bottleLimitCount = 0;
		            bottleVibreCount = 0;
		        }
		        else {
		            bottleLimitCount++;
		        }
		        return;
		    }

		    if (l == 'on') {
		        pos = pos + dif;
		    } else {
		        pos = pos - dif;
		    }
		    obj.animate({ right: pos }, 60, function () { l = ((l == 'on') ? 'off' : 'on'); });
		    bottleVibreCount++;
		}, 100);
	}
}

function scrollPageLE(){
   $('.link_bottle').click(function() {  
	try{
		var link_b = $(this).attr('box');
		var id = link_b.split('-');
		
		if(parseInt(id[1]) > 0){
			//posiziona  contenitore principale
			positionTopLI = parseInt(id[1]-1)*h_box;
			$('.cont-lim-edition').animate({'top':-positionTopLI+'px'}, 300);
		}
	}catch(e){}
   });
}

/***********FUNCTIONS COCKTAILS*************/
var cocktail_selected;
var obj_preparazione;
var obj_lat_coctails ;
var hover_li =false;
var hover_box_like = true;


function initCocktails() {
//WHY?????
//	if(isIE()){
//		$('.btn_li').css('display','none');
//	}
	var obj_active =$('#gallery .active');

	var zoomFunc = function(dimension) {
		return dimension * 1.5;
	}
	var shrinkFunc = function(dimension) {
		return dimension * 0.7;
	}

	$('#gallery').flowGallery({
	  easing: 'easeOutCubic',
	  imagePadding: 0,
	  thumbWidth: 280
	});

	var li = $('.gal').find('li');
	for (i=0; i<$(li).length; i++) { 
		var div =  $(li[i]).find('div');
		var txt =  $(li[i]).find('.txt');
		var width_txt = $(txt).width();
		$(txt).css('left',-Math.floor(width_txt/2)+2);
	}

	
	activateEventsGallery();
	
	var dimWindow = getDimWindow();
	var heightWindow = dimWindow[1];
	var widthWindow = dimWindow[0];
	var pos_gallery = Math.floor((heightWindow-462-95)/2);

	$('.cont-gallery-int').css('top',pos_gallery+95);
	$('.cont-gallery-int').css('height',heightWindow);

	$('.btn_prev').click(function(){
		try{
			var itemActive = $('#gallery .active');
			var prev_item_active = $(itemActive).prev();
			$(prev_item_active).trigger('click');
		}catch(e){}
	});
	
	$('.btn_next').click(function(){
		try{
			var itemActive = $('#gallery .active');
			var next_item_active = $(itemActive).next();
			$(next_item_active).trigger('click');
		}catch(e){}
});

	initBoxLetYouInspire();
}

function setStateBoxLetYouInspire() {
    var container = $("#cont-lasciati_ispirare");
    if (!container.find('.btn_filtra').hasClass('active')) {//NOT RESULT MODE
        if (!container.hasClass('open')) {//IS CLOSED
            container.find('.btn_filtra, .off').show(); // :-(  --> :-D
            container.addClass('open');
            container.animate({ 'bottom': '0px' });
            container.find('.btn .arrow, .btn').addClass('selected');
        }
        else {//IS OPEN
            container.removeClass('open');
            container.animate({ 'bottom': -container.height() + container.find('.btn').height() });
            container.find('.btn .arrow, .btn').removeClass('selected');
        }
    }
    else {//RESULT MODE
        container.find('.btn_li,.btn_filtra').hide();
        container.find('.btn_ris').show();
    }
}

function initBoxLetYouInspire() {

    /* OPEN BOX LET YOU INSPIRE */
    $("#cont-lasciati_ispirare .btn").click(function () {
        setStateBoxLetYouInspire();
    });

    /*ADD FILTER */
    $("#cont-lasciati_ispirare .btn_filtra").click(function () {
        var container = $(this).parent();
        //SET BOXSTATE AT RESULT MODE
        $(this).addClass('active');
        setStateBoxLetYouInspire();

        //GET FILTER TYPE AND VALUE
        var filterType = "";
        var filterValue = "";
        container.find(".btn_li .on .selected:first").each(function () {
            filterValue = $(this).attr("index");
            filterType = $(this).parent().parent().parent().attr("type").toLowerCase();
        });
        var cocktails = $('#gallery li');
        cocktails.show();
        //SHOW VISIBILITY
        var totalElement = cocktails.length;
        var cocktailsToHide = new Array();

        if (filterValue != "" && filterType != "") {
            //FIRST PASS, CHECK THE INDEX AND PUT IN ARRAY
            cocktails.each(function (index, elem) {
                var cockatailsValues = $(this).attr(filterType).split(',');
                if (cockatailsValues.length <= 0 || $.inArray(filterValue, cockatailsValues) == -1) {
                    cocktailsToHide.push(index);
                }
            });


            if (cocktailsToHide.length > 0) {
                cocktails.each(function (index, elem) {
                    var inArrayIndex = $.inArray(index, cocktailsToHide);
                    if (inArrayIndex > -1) {
                        $(this).hide('slow', function () {
                            $(this).remove();
                            if (inArrayIndex + 1 == cocktailsToHide.length) {
                                //alert('Last-' + $('#gallery li:visible:first').length);
                                $('#gallery li:visible:first').click();
                            }
                        });
                        totalElement--;
                    }
                });
            }
        }

        //SHOW RESULTS
        container.find('.btn_ris .risultati span').html(totalElement);
    });

    /*REMOVE FILTER */
    $("#cont-lasciati_ispirare .del_filtro").click(function () {
        location.href = location.href.replace('#','');
    });
    
    /* OPEN BOX FILTERITEMS */
    $("#cont-lasciati_ispirare .btn_li .label").click(function () {
        var container = $(this).parent();
        var isVisible = container.hasClass('on');

        $('.btn_li .on:visible').each(function () {
            $(this).parent().css('background', '#ECECEC');
            $(this).find(".cont-filter-4,.cont-filter-3,.cont-filter-6").hide();
            $(this).removeClass('on').addClass('off');
        });

        if (!isVisible) {//Old state is not Selected
            container.parent().css('background', '#FFF');
            container.find('.cont-filter-4,.cont-filter-3,.cont-filter-6').show();
            container.removeClass('off').addClass('on');
        }
    });

    /* SELECT FILTERITEM */
    $('.cont-filter-6 .filter-item div,.cont-filter-3 .filter-item div,.cont-filter-4 .filter-item div').click(function () {
        if ($(this).parent().hasClass('selected')) {
            $(this).parent().removeClass('selected');
        } else {
            $(this).parent().parent().find(".filter-item").removeClass('selected');
            $(this).parent().addClass('selected');
        }
    });

    /* IE7 FIX: ANIMATE FOR FIRST LOAD*/
    $("#cont-lasciati_ispirare").animate({ 'bottom': -$("#cont-lasciati_ispirare").height() + $("#cont-lasciati_ispirare").find('.btn').height() });

}
function activateEventsGallery() {
    activateEventsGallery_F6();
}


function gotoSchedaCocktail(){
	var active = $('#gallery').find('.active');
	var href = $(active).attr('href');
	location.href=href;
}

function getCurr(newCurrent,originalEvent){}

function hoverGalleryImg(obj){
	if($(obj).parent().hasClass('selected')){
		
		var pos = $(obj).parent().position();
		var left_pos_glass = pos.left;
		var width_glass = $(obj).width();
		var height_glass = $(obj).height();
		
		var l = Math.floor((width_glass - $('#cont-like').width())/2);
		var l_top = Math.floor((height_glass - $('#cont-like').height())/2);
		$('#cont-like').css('left',left_pos_glass+l);
		$('#cont-like').css('bottom','200px');
		if(isIE()){
			$('#cont-like').css('display','block');	
		}else{ $('#cont-like').show();}
	}	
}

function outGalleryImg(obj){
	if(isIE()){
		$('#cont-like').css('display','none');	
	}else{ $('#cont-like').hide();}
}

function initVideoPreparazioneCock() {
    $("#jquery_jplayer_1").jPlayer({
        ready: function () {
            //alert("http://localhost:3272" + $('.cont-video input').attr('src'));
            $(this).jPlayer("setMedia", {
                m4v:$('.cont-video input').attr('src'),
                poster:$('.cont-video input').attr('preview')
            });
        },
        swfPath: "/js/jQuery.jPlayer.2.1.0",
        solution:'html,flash',
        supplied: "m4v",
        size: {
            width: "325px",
            height: "228px",
            cssClass: "video"
        },
        cssSelector: {
            play: ".jp-video-play",
            pause: ".jp-pause",
            stop: ".jp-stop",
            seekBar: ".jp-seek-bar",
            playBar: ".jp-play-bar",
            mute: ".jp-mute",
            unmute: ".jp-unmute",
            volumeBar: ".jp-volume-bar",
            volumeBarValue: ".jp-volume-bar-value",
            volumeMax: ".jp-volume-max",
            currentTime: ".jp-current-time",
            duration: ".jp-duration",
            fullScreen: ".jp-full-screen",
            restoreScreen: ".jp-restore-screen",
            repeat: ".jp-repeat",
            repeatOff: ".jp-repeat-off",
            gui: ".jp-gui",
            noSolution: ".jp-no-solution"
        }
    });
}

function closeSchCocktail(){
	location.href= 'cocktails.html';
}

function setPosCocktail(){
	var h_gallery = $('.gallery').height();
	var dimWindow = getDimWindow();
	var heightWindow = dimWindow[1];
	
	var pos = Math.floor((heightWindow-h_gallery)/2);
	//$('.gallery').css('margin-top',pos);
	
	//prov
	var dimWindow = getDimWindow();
	var widthWindow = dimWindow[1];
	if(widthWindow <= 995){
		//$('.sl-cocktails').css('width','910px;');
	}
}


function resizeBkCocktails(){
	var dimWindow = getDimWindow();
	var heightWindow = dimWindow[1];
	var widthWindow = dimWindow[0];
	//var widthWindow = ((widthWindow < 995)?widthWindow : dimWindow[0]);
	var space_ck = Math.floor((widthWindow-350)/280);
	var visible_obj = ((space_ck%2==0)? (space_ck):space_ck-1);
	obj_lat_coctails = visible_obj/2;
	
	//position arrows
	var pos_top = Math.floor((dimWindow[1]-95-$('.btn_prev').height())/2);
	$('.btn_prev').css('margin-top',pos_top);
	$('.btn_next').css('margin-top',pos_top);
	
	var h_gallery = ((heightWindow < 584)? 584: heightWindow-95);
	//$('.cont-gallery').height(heightWindow-95);
	//$('.cont-gallery').width(widthWindow);
	
		//box-like
	/*if(id_coktail!= undefined){
		var cocktail = $('#cocktail-'+id_coktail);
		var pos_cocktail = $(cocktail).position();
		var pos_left_cocktail =  pos_cocktail.left;
		$('#box-like').css('left',pos_left_cocktail);
		var pos_top = Math.floor((dimWindow[1] - $('#cont-like').height())/2);
		var pos_left = Math.floor((350 - $('#cont-like').width())/2);
		$('#cont-like').css('top',pos_top+180);
		$('#cont-like').css('left',pos_left);
	}*/
	/*
	if(dimWindow[0] > 1384){
		//var le = $(left_coktail);
		//var rc = $(right_coktail);
		$(right_coktail).css('display','block');
		$(left_coktail).css('display','block');
	}else{
		$(right_coktail).css('display','none');
		$(left_coktail).css('display','none');
	}*/
	var dimWindow = getDimWindow();
	var heightWindow = dimWindow[1];
	var widthWindow = dimWindow[0];
	var pos_gallery = Math.floor((heightWindow-462-95)/2);
	//alert(pos_gallery);
	//$('.cont-gallery-int').css('top',462+pos_gallery);
	$('.cont-gallery-int').css('top',pos_gallery+95);
	$('.cont-gallery-int').css('height',heightWindow);
	//console.log(heightWindow-(pos_gallery+95));
}

function openTooltip(obj){
	var overlay =$(obj).parent().find('.overlay-tooltip');
	var tooltip =$(obj).parent().find('.tooltip');
	$(overlay).css('display','block');
	$(tooltip).css('display','block');
	$(obj).parent().css('z-index','99999');
}

function closeTooltip(){
	$('.tooltip').css('display','none');
	$('.overlay-tooltip').css('display','none');
	$('.method').css('z-index','2');
}

/****************FUNCTIONS GALLERY CAMPARI***********************/
var current_thumb = 5;
var scroll_sl_gallery = false;
var interval_description_thumb;
function initCarouselleGalleryCampary() {
    //cont-slider
    var arrDots = new Array();


    for (i = 0; i < $('.cont-slider li').length; i++) {

        /*if(parseInt(4+i) > $('.cont-slider li').length){
        value = 	
        }*/
        /*console.log(i+1);
        console.log(value);
        console.log('--------');*/
        arrDots[i] = $(".btn_thumb_hidden_" + (i + 1));
        //arrDots[i]= $(".thumb-"+(value));
    }
    $(".cont-slider").jCarouselLite({
        vertical: true,
        btnNext: ".arrow_top",
        btnPrev: ".arrow_bottom",
        btnGo: arrDots,
        speed: 900, //ALESSIO
        visible: 5,
        start: 0,
        afterEnd: function (a) {
            //AlessandroG, show arrows
            $('#slider a.arrow_top,#slider a.arrow_bottom').css('visibility', 'visible');
        }
    });

    var element_on = $('.cont-slider .thumb-5').parent();

    $('.arrow_top').click(function () {

        //AlessandroG, hide arrows
        $('#slider a.arrow_top,#slider a.arrow_bottom').css('visibility', 'hidden');

        var currentItem = $('li.thumb_selected');
        var next_el = (currentItem.length > 0) ? currentItem.next() : null;

        $('li').removeClass('thumb_selected');
        //if(scroll_sl_gallery == false){
        scroll_sl_gallery = true;
        var nro_thumbs = Math.ceil($('#gallery li').length / 3) + 1;

        current_thumb += 1;
        if (current_thumb > nro_thumbs) {
            current_thumb = 1;
        }

        if (currentItem.length == 0) {
            next_el = $('.thumb-' + current_thumb).parent();
            //alert('NEXT: falling back to old selector, ' + next_el.attr('id'));
        }
        //alert('NEXT: current item ' + currentItem.attr('id') + "; calculated next_el: " + next_el.attr('id'));

        element_on = next_el;
        $('.thumb').removeClass('on');

        $(next_el).children('.thumb').addClass('on');
        $(next_el).addClass('thumb_selected');
        showContThumbGallery(next_el);
        showGalleryText();
        /* if ($('#cont_description_thumb .description_thumb').length > 0 && $('#cont_description_thumb .author').html() != "")
        $('.description_thumb').show('fast', function () { scroll_sl_gallery = false; interval_description_thumb = setTimeout(function () { closeDescriptionGallery() }, 8000); });
        */
    });
    var timeoutGalleryText;
    function showGalleryText() {
        if ($('#cont_description_thumb .description_thumb').length > 0 && $('#cont_description_thumb .author').html() != "")
            $('.description_thumb,.description_thumb_bg').stop(true, true);
        $('.description_thumb').css("opacity", "1");
        $('.description_thumb_bg').css("opacity", "0.7");
        $('.description_thumb,.description_thumb_bg').show('fast', function () { scroll_sl_gallery = false; clearTimeout(timeoutGalleryText); timeoutGalleryText = setTimeout(function () { closeDescriptionGallery() }, 8000); });
    }
    function showGalleryTextPermanent() {
        if ($('#cont_description_thumb .description_thumb').length > 0 && $('#cont_description_thumb .author').html() != "") {
            $('.description_thumb,.description_thumb_bg').stop(true, true);
            $('.description_thumb').css("opacity", "1");
            $('.description_thumb_bg').css("opacity", "0.7");
            $('.description_thumb,.description_thumb_bg').show('fast');
        }
    }
    function hideGalleryTextPermanent() {
        if ($('#cont_description_thumb .description_thumb').length > 0 && $('#cont_description_thumb .author').html() != "") {
            $('.description_thumb,.description_thumb_bg').stop(true, true);
            $('.description_thumb,.description_thumb_bg').css("opacity", "0");
            $('.description_thumb,.description_thumb_bg').hide('fast');
        }

    }
    $('.arrow_bottom').click(function () {

        //AlessandroG, hide arrows
        $('#slider a.arrow_top,#slider a.arrow_bottom').css('visibility', 'hidden');

        var currentItem = $('li.thumb_selected');
        var next_el = (currentItem.length > 0) ? currentItem.prev() : null;

        $('li').removeClass('thumb_selected');
        scroll_sl_gallery = true;
        var nro_thumbs = Math.ceil($('#gallery li').length / 3) + 1;

        current_thumb -= 1;
        if (current_thumb < 1) {
            current_thumb = nro_thumbs;
        }

        if (currentItem.length == 0)
        {
            next_el = $('.thumb-' + current_thumb).parent();
            //alert('BOTTOM: falling back to old selector, ' + next_el.attr('id'));
        }
        //alert('BOTTOM: current item ' + currentItem.attr('id') + "; calculated next_el: " + next_el.attr('id'));
        
        element_on = next_el;
        $('.thumb').removeClass('on');

        $(next_el).children('.thumb').addClass('on');
        $(next_el).addClass('thumb_selected');
        var layer = $(next_el).children('.thumb').children('.layer_top_thumb');

        showContThumbGallery(next_el);

        showGalleryText(); 
        /*
        if ($('#cont_description_thumb .description_thumb').length > 0 && $('#cont_description_thumb .author').html() != "")
            $('.description_thumb').show('fast', function () { scroll_sl_gallery = false; interval_description_thumb = setTimeout(function () { closeDescriptionGallery() }, 8000); });
    */
    });

    //hover thumbs
    $('.cont-slider li').mouseenter(function () {
        if (!$(this).hasClass('thumb_selected')) {
            $(this).children('.thumb').addClass('on');
            var layer = $(this).children('.thumb').children('.layer_top_thumb');
        } else {
        showGalleryTextPermanent(); 
        /*
            if ($('#cont_description_thumb .description_thumb').length > 0 && $('#cont_description_thumb .author').html()!="")
                $('.description_thumb').show('fast', function () { });
                */
        }
    });

    //hover thumbs
    $('.cont-slider li').mouseleave(function () {
        if (!$(this).hasClass('thumb_selected')) {
            $(this).children('.thumb').removeClass('on');
            var layer = $(this).children('.thumb').children('.layer_top_thumb');
            //$(this).children('.thumb').trigger('click');
        } else {
            hideGalleryTextPermanent(); 
        /*
            interval_description_thumb = setTimeout(function () { interval_description_thumb = closeDescriptionGallery() }, 8000);
       */
        }
    });


    //hover thumbs
    $('.cont-slider .thumb').click(function () {

        if (!$(this).parent().hasClass('thumb_selected')) {
            try {
                var el = $(this).parent().prev().prev().prev().prev();
                if ($(el).length > 0) {
                    var attr = $(el).attr('id');
                    var id_el = attr.split('-');
                    var value = id_el[1];
                    var btn = $('.btn_thumb_hidden_' + value);
                    //$(btn[0]).trigger('click');
                    $('.btn_thumb_hidden_' + value).trigger('click');
                }
            } catch (e) { }

            var attr_obj = $(this).parent().attr('id');
            //alert(attr_obj);
            var id_obj = attr_obj.split('-');
            var value_o = id_obj[1];
            current_thumb = value_o;
            $('.thumb').removeClass('on');
            $('.thumb').parent().removeClass('thumb_selected');

            $('.thumb-' + value_o).addClass('on');
            $('.thumb-' + value_o).parent().addClass('thumb_selected');
            var layer = $('.thumb-' + value_o).children('.layer_top_thumb');

            showContThumbGallery($(this).parent());
            showGalleryText(); 
        /*
            if ($('#cont_description_thumb .description_thumb').length > 0 && $('#cont_description_thumb .description_thumb').attr("author") != undefined)
                $('.description_thumb').show('fast', function () { scroll_sl_gallery = false; });
                */
        }
    });

    $('.description_thumb').mouseenter(function () {
      //  clearInterval(interval_description_thumb);
    });

    $('.description_thumb').mouseleave(function () {
    
        //showGalleryText(); 
        /*
        interval_description_thumb = setTimeout(function () { interval_description_thumb = closeDescriptionGallery() }, 8000);
        */
    });

    $('.btn_more').click(function () {
    /*
        if (!$('.btn_more').hasClass('selected')) {
            $('.btn_more').addClass('selected');
            //entro
            clearInterval(interval_description_thumb);
            $('#cont_description_thumb .txt').css('display', 'none');
            $('#cont_description_thumb .txt_long').css('display', 'block');
        } else {
            $('.btn_more').removeClass('selected');
            $('#cont_description_thumb .txt').css('display', 'block');
            $('#cont_description_thumb .txt_long').css('display', 'none');
        }*/
    });

    //$('#cont_description_thumb .description_thumb').mouseenter
    resizeBackground('#full .image img');
}

function closeDescriptionGallery() {

    $('#cont_description_thumb .description_thumb,.description_thumb_bg').hide('fast');
}



function showContThumbGallery(li) {
    var dimWindow = getDimWindow();
    var heightWindow = dimWindow[1];

    //insert image fullscreen
    var isImage = $(li).children('.mat-bk').hasClass('image');
    var isVideo = $(li).children('.mat-bk').hasClass('video');
    $('#full-old').css("position", "absolute");
    $('#slider').css("z-index", "999");
    $('#full-old').css("z-index", "998");

    if (isImage) {
        //change txt label
        var txt_description = $(li).children('.description_thumb').clone();
        var author = $(li).children('.description_thumb').attr('author');
        var descr_author = $(li).children('.description_thumb').attr('intro');
        var descr_long_author = $(li).children('.description_thumb').attr('description');
        $('#cont_description_thumb .author').html(author);
        $('#cont_description_thumb .txt').html(descr_author);
        $('#cont_description_thumb .txt_long').html(descr_long_author);
        if ($('#cont_description_thumb .description_thumb').length > 0 && $('#cont_description_thumb .author').html()!="")
            $('#cont_description_thumb').css('display', 'block');
        else
            $('#cont_description_thumb').css('display', 'none');
            
        $('#full-old').show();
        $('#full .full-int').html(""); //ERASE ALL
        $('#full .full-int').html('<div class="image"></div>');
        $('#full .full-int').append($("#templateHidden .txt-intro").clone());
        var sf = $(li).children('.mat-bk').children('img').clone();
        $('#full .image').hide();
        $('#full .image').html(sf);
        resizeBackground(sf);

        $('#full .image').show();

        //showGalleryText(); 
        /*
        setTimeout(function () {
        $('#full-old').fadeOut(800, function () { $('#full-old').hide(); $('#full-old .video-fl').jPlayer("destroy"); });
        }, 200);
        */

        } else if (isVideo) {

        var txt_description = $(li).children('.description_thumb').clone();
        var author = $(li).children('.description_thumb').attr('author');
        var descr_author = $(li).children('.description_thumb').attr('intro');
        $('#cont_description_thumb .author').html(author);
        $('#cont_description_thumb .txt').html(descr_author);

        if ($(li).children('.description_thumb').hasClass('hidden')) {
        $('#cont_description_thumb').css('display', 'none');
        } else {
        if ($('#cont_description_thumb .description_thumb').length > 0 && $('#cont_description_thumb .author').html()!="")
        $('#cont_description_thumb').css('display', 'block');
        else
        $('#cont_description_thumb').css('display', 'none');
        }
      
        $('#full-old').html($('#full').children('.full-int').clone());
        $('#full .full-int').html('');
        $('#full .full-int').html($('.html_video .video-fl').clone());

        var descr_long_author = $(li).children('.description_thumb').attr('description');
        $('#cont_description_thumb .txt_long').html(descr_long_author);

        var src_video = $(li).children('.mat-bk').children('.lk_video').attr('src_video');
        var preview_video = $(li).children('.mat-bk').children('.lk_video').attr('previewVideo');

        
        embedVideoGallery($("#jquery_jplayer_1"), src_video, preview_video, 700, 390);

        //pos_video
        var pos_video = Math.floor((heightWindow - 455 - 95) / 2);
        $('#full .video-fl').css('top', pos_video + 141);
        $('#slider').css('top', pos_video + 95); //TODO FULLSIX INSERT

        //alert("ALESSIO");
        $('#full').show('slow');
        $('#full-old').hide('slow', function () { $('#full-old').html(''); $('#full .video-fl').jPlayer("destroy"); });

        if (detectIpad())
        $("#full .video-fl, #full-old .video-fl").css("left","290px");
        /*
        $('#full .image').html(sf);
        resizeBackground(sf);
        $('#full-old').html($('#full').children('.full-int').clone());
        $('#full').show('slow');
        $('#full-old').hide('slow',function(){$('#full-old').html('');});
        */
    }
    /*$('#image').hide('slow',function(){
		
    });*/
}

function embedVideoGallery(obj, src, preview, w, h, an) {

    $(obj).jPlayer({
        ready: function () {
            $(this).jPlayer("setMedia", {
                m4v: src,
                poster: preview
            });
        },
        swfPath: "/js/jQuery.jPlayer.2.1.0",
        supplied: "m4v",
        solution: 'html,flash',
        size: {
            width: w,
            height: h,
            cssClass: "video"
        },
        cssSelector: {
            play: ".jp-video-play",
            pause: ".jp-pause",
            stop: ".jp-stop",
            seekBar: ".jp-seek-bar",
            playBar: ".jp-play-bar",
            mute: ".jp-mute",
            unmute: ".jp-unmute",
            volumeBar: ".jp-volume-bar",
            volumeBarValue: ".jp-volume-bar-value",
            volumeMax: ".jp-volume-max",
            currentTime: ".jp-current-time",
            duration: ".jp-duration",
            fullScreen: ".jp-full-screen",
            restoreScreen: ".jp-restore-screen",
            repeat: ".jp-repeat",
            repeatOff: ".jp-repeat-off",
            gui: ".jp-gui",
            noSolution: ".jp-no-solution"
        }
    });

    //$(video).css('width',w);
    //$(video).css('height',h);
}


function positionElementsGalleryC() {
    var dimWindow = getDimWindow();
    var heightWindow = dimWindow[1];
    var widthWindow = dimWindow[0];
    var pos_slider = Math.floor((heightWindow - $('#slider').height() - 95) / 2);
    //$('#slider').css('top',pos_slider+95);

    var pos_tit_top_intro = Math.floor((heightWindow - $('.txt-intro').height() - 95) / 2);
    var pos_tit_right_intro = Math.floor((widthWindow - $('.txt-intro').width() - 234) / 2);
    $('.txt-intro').css('top', pos_tit_top_intro + 95);
    $('.txt-intro').css('right', pos_tit_right_intro);

    //pos_video
    var pos_video = Math.floor((heightWindow - 455 - 95) / 2);
    $('#full .video-fl').css('top', pos_video + 141);
    $('#slider').css('top', pos_video + 95); //TODO FULLSIX INSERT
    //alert("ALESSIO");
    //resize img
    resizeBackground('#full .image img');
}
/************RED BARS*************/
function initializeRedBars(){
	initializeMap();
	
   //set pp preparati all'aperitivo
   $('.cont-ap').css('min-height',$('.cont-aperitivo-int').height()-56);
   $('.cont-ap-int').css('min-height',$('.cont-aperitivo-int').height()-56);
   //position pp

   $('.cont-aperitivo').css('bottom',-$('.cont-aperitivo').height()+32);
}

function ppPreparaAperitivo(){
	$('.cont-aperitivo-int a').removeClass('selected');
	$('.cont-ap').css('min-height',$('.connect-social').height());
    $('.cont-ap-int').css('min-height',$('.connect-social').height());
	
	$('.f_aperitivo').css('display','none');
	$('.connect-social').css('display','block');
	$('.cont-aperitivo').css('bottom','0px');
	$('.cont-aperitivo .btn_close').css('display','block');
	$('.cont-ap-int').css('padding-right','28px');
}

function insertLocationAperitivo(){
	$('.cont-aperitivo-int a').removeClass('selected');
	$('.cont-aperitivo-int .location').addClass('selected');
	$('.cont-ap').css('min-height',$('.insert-location').height());
    $('.cont-ap-int').css('min-height',$('.insert-location').height());
	
	$('.f_aperitivo').css('display','none');
	$('.insert-location').css('display','block');
	$('.cont-aperitivo').css('bottom','0px');
	$('.cont-aperitivo .btn_close').css('display','block');
	$('.cont-ap-int').css('padding-right','23px');
}

function searchLocationAperitivo(){
	$('.cont-aperitivo-int a').removeClass('selected');
	$('.cont-aperitivo-int .search').addClass('selected');
	$('.cont-ap').css('min-height',$('.search-bar').height());
    $('.cont-ap-int').css('min-height',$('.search-bar').height());
	
	$('.f_aperitivo').css('display','none');
	$('.search-bar').css('display','block');
	$('.cont-aperitivo').css('bottom','0px');
	$('.cont-aperitivo .btn_close').css('display','block');

}

function closePP(){
	$('.cont-aperitivo-int a').removeClass('selected');
	$('.cont-aperitivo').css('bottom',-$('.cont-aperitivo').height()+32);
	$('.cont-aperitivo .btn_close').css('display','none');
}


var  infoBox;
function insertMarkerCampariOfficial(address, map,zoom){
	var address = address;
    geocoder.geocode( { 'address': 'via Einaudi, Conegliano'}, function(results, status) {
	var marker;
	
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var marker_image = new google.maps.MarkerImage('/img/google_map/marker_campari_official.png');
		marker = new google.maps.Marker({
			position: results[0].geometry.location,
			map: map,
			title:address,
			icon: marker_image
		}); 
		
		google.maps.event.addListener(marker, "click", function(e) {
			  var boxText = document.createElement("div");
			  boxText.style.cssText = "";
			  boxText.innerHTML = setInnerHtmlInfoWindow('Bar del corso','10',address);
			  
			  var myOptions = {
				 content: boxText,
				 closeBoxURL:'',
				 boxClass : "infoBoxOfficial",
				 boxStyle: { 
				   background: "url('img/google_map/info_window.png') no-repeat",
				   width: "407px",
				   height: "274px"
				 }
            };
            f6_clearInfoBox();

			  infoBox = new InfoBox(myOptions);
		 	  infoBox.open(map, marker);
			  
			  map.setZoom(25);
			  map.setMapTypeId(google.maps.MapTypeId.SATELLITE);
			  
		  	  //
			  $('.cont-aperitivo').css('display','none');
			  $('.filtra_risultati').css('display','none');
			  $('.cont-back-to-map').css('display','block');
			  
		  });
      } else {
        //alert("Geocode was not successful for the following reason: " + status);
        alert('We cannot find this place, please refine your search');
      }	  
    });
}

var html_info_window;
function setInnerHtmlInfoWindow(nome_locale, persone, indirizzo)
{
	return "<div class='cont_info_window'><div class='label_locale'>NOME DEL LOCALE</div><div class='nome_locale'>"+nome_locale+"</div><div class='label_locale'> "+persone+"HANNO SEGNALATO QUESTO BAR</div><div class='indirizzo'><span class='label'>INDIRIZZO</span><span class='ind'>"+indirizzo+"</span></div></div>";
}

function insertMarkerCampariUser(address, map){
	var address = address;
    geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var marker_image = new google.maps.MarkerImage('/img/google_map/marker_campari_user.png');
		var marker = new google.maps.Marker({
			position: results[0].geometry.location,
			map: map,
			title:address,
			icon: marker_image
		}); 	
		
		google.maps.event.addListener(marker, "click", function(e) {
			  var boxText = document.createElement("div");
			  boxText.style.cssText = "";
			  boxText.innerHTML = setInnerHtmlInfoWindow('Bar del corso','10',address);
			 
			  var myOptions = {
				 content: boxText,
				 closeBoxURL:'',
				 boxClass : "infoBoxUser",
				 boxStyle: { 
				   background: "url('img/google_map/info_window_user.png') no-repeat",
				   width: "407px",
				   height: "274px"
				 }
            };
            f6_clearInfoBox();
			  infoBox = new InfoBox(myOptions);
			  infoBox.open(map, marker);
			  
			  map.setZoom(25);
			  map.setMapTypeId(google.maps.MapTypeId.SATELLITE);
			  

			  $('.cont-aperitivo').css('display','none');
			  $('.filtra_risultati').css('display','none');
			  $('.cont-back-to-map').css('display','block');
			  
		  });
      } else {
    //alert("Geocode was not successful for the following reason: " + status);

    alert('We cannot find this place, please refine your search');
      }
    });

}

var geocoder;
var map; //F6 MOD
var f6_backToMap_zoom = 6;
var f6_freeze_zoom_calculation = false;

function initializeMap(){
	geocoder = new google.maps.Geocoder();
    latlng = new google.maps.LatLng(43.309191,12.612305);
    var myOptions = {
      zoom: 6,
      center: latlng,
	  sensor: 'true',
      mapTypeId: google.maps.MapTypeId.ROADMAP,
	  mapTypeControl: false,
		panControl: true,
		panControlOptions: {
			position: google.maps.ControlPosition.TOP_RIGHT
		},
		zoomControl: true,
		zoomControlOptions: {
			style: google.maps.ZoomControlStyle.LARGE,
			position: google.maps.ControlPosition.TOP_RIGHT
		},
		scaleControl: true,
		scaleControlOptions: {
			position: google.maps.ControlPosition.TOP_RIGHT
		}
    };

    //F6 MOD
    map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
		
	//insertMarkerCampariOfficial('via Einaudi, Conegliano',map);
	//insertMarkerCampariUser('Via Aurelia, Roma',map);

    $('.cont-back-to-map a').click(function (e) {
        e.preventDefault();
        map.setZoom(f6_backToMap_zoom);
        map.setMapTypeId(google.maps.MapTypeId.ROADMAP);

        f6_clearInfoBox();

        $('.cont-aperitivo').css('display', 'block');
        $('.filtra_risultati').css('display', 'block');
        $('.cont-back-to-map').css('display', 'none');

        //Permit again map zoom calculation
        f6_freeze_zoom_calculation = false;
    });
	

}

function openPPInsertAperitivo(){
	
}

/***********CONTACT***************/
var focus_txtarea=0;
function initializeMapContact(lat , lon){
	geocoder = new google.maps.Geocoder();
    latlng = new google.maps.LatLng(lat,lon);//45.538948,9.23471);
    var myOptions = {
      zoom: 16,
      center: latlng,
	  sensor: 'true',
      mapTypeId: google.maps.MapTypeId.ROADMAP,
	  mapTypeControl: false,
		panControl: false,
		panControlOptions: {
			position: google.maps.ControlPosition.TOP_RIGHT
		},
		zoomControl: false,
		zoomControlOptions: {
			style: google.maps.ZoomControlStyle.LARGE,
			position: google.maps.ControlPosition.TOP_RIGHT
		},
		scaleControl: false,
		scaleControlOptions: {
			position: google.maps.ControlPosition.TOP_RIGHT
		}
    };
	initializeBackgroundSite();
    var map = new google.maps.Map(document.getElementById("map_contact"),
        myOptions);
		
	var marker_image = new google.maps.MarkerImage('/img/google_map/marker_campari_official.png');
	marker = new google.maps.Marker({
		position: new google.maps.LatLng(lat,lon),//45.538948,9.23471),
		map: map,
		icon: marker_image
	}); 
	//onfocus
	$('#contact input').focus(function(){
		$('#contact input').removeClass('focus');
		$('.select-replacement').removeClass('sel');
		$('#contact textarea').removeClass('focus');
		$(this).addClass('focus');			
		//$('.input_fc_hidden').bind('focus',fcSelect);				   
	});
	
	$('.textarea_fc').focus(function(){	
		//if(focus_txtarea==0){
			//$('.input_fc_hidden').bind('focus',fcSelect);
			$('#contact input').removeClass('focus');
			$('.select-replacement').removeClass('sel');
			$('#contact .textarea_fc').addClass('focus');
		/*}else{
			$('#contact input').removeClass('focus');
			$('.select-replacement').removeClass('sel');
			$('#contact .textarea_fc').addClass('focus');
			focus_txtarea=0;
		}*/
	});
	
	
	$('.input_fc_hidden').bind('focus',function(){	

		fcSelect();
		
	});
	
	/*$('#contact textarea').focus(function(){
		$('#contact input').removeClass('focus');
		$('#contact textarea').removeClass('focus');
		$(this).addClass('focus');									   
	});*/
	//
	if(isIE()){
		var w_options = $('#contact .options').width();
		var h_options = ($('#contact .options .option').length+1)*26+6;
		$('#contact .bottom-shadow').css('width',w_options);
		//$('.top-shadow').css('height','200px');
	}
}

function fcSelect(){
	
	//$('.input_fc_hidden').remove();
	

	$('#contact input').removeClass('focus');
	$('.select-replacement').addClass('sel');	
}

/**********SITE MAP*************/
function setSiteMap(){
	$('.btn_location').click(function(){
		if($(this).hasClass('open') ){
			$(this).removeClass('open');
			$(this).parent().find('.list-country').css('display','none');
			resizeBackground('#img_bg');
		}else{
			$(this).addClass('open');
			$(this).parent().find('.list-country').css('display','block');
			resizeBackground('#img_bg');
		}
		var arr = getDimWindow();
		 if(arr[0] > 995){
			 //$('.menu-header-int-dx').css('visibility','hidden');
			 var wid = Math.abs(($('#site').width()-995)/2);
			 var lar_tot = Math.floor(wid)+ Math.floor(wid) + 995;
			 if(lar_tot == $('#site').width()){
				 $('.menu-header-int-sx').css('width',Math.floor(wid));
				 $('.menu-header-int-dx').css('width', Math.floor(wid) - 1);
			 }else{
				 var diff = $('#site').width()-lar_tot;
				$('.menu-header-int-sx').css('width',Math.floor(wid));
				$('.menu-header-int-dx').css('width', Math.floor(wid) + diff - 1);
			 }
setTimeout(function () { $('.menu-header').css('visibility', 'visible'); }, 100);
		 }else{
			 $('.menu-header-int-sx').css('width','0px');
			 $('.menu-header-int-dx').css('width','0px');
		 }
		
	});
}



function silenzia()  {return true}



