			var video = $('#bxVideo').find('.img');
			var ico = $('#bxVideo').find('.ico');
			var txt = $('#bxVideo').find('.ico p');
			var lk = $('#bxVideo').find('.bt');
			var img = $('.panel').find('.bg').find('.img');	
			
			
		//funzione chiusura overlayer
		MyChiudi = function() {
			$('.overlay').css( 'display','none');
			$('.o_box').css( 'display','none');
			$('.o_video').empty( );
		}
		
		//funzione posizionamento overlayer
		MyPosition = function() {
			var hW = $(window).width();
			var hH_window = $(window).height();
			
			var margineTop =  (hH_window - 430 )/2
			var margineLeft =  (hW - 656 )/2 

			$('.o_box').css('top', margineTop + 'px');
			$('.o_box').css('left', margineLeft + 'px');
		}

	
$(document).ready(function(){					   
	var instance_shr_box_overlay = new jSharingBoxClass();
	var domain = "http://mail.virgilio.it";
    var detailPageSlider ={"panel2":domain+"/video-tutorial-gestione-allegati.html","panel3": domain+"/video-tutorial-giga-allegati.html","panel4":domain+"/video-tutorial-social-network.html"}        
	$('#slider3')
	.anythingSlider({
		width               : 896,
		height              : 546,
		autoPlay		    : true,
		autoPlayLocked      : true,
		pauseOnHover        : true,
		navigationFormatter : function(i, panel){
			return ['Filtri Mail', 'Gestione Allegati', 'Giga Allegati', 'Social Network'][i - 1];
		}
	})//Mail Collector

		/*animazione all'apertura*/
			var hashes = window.location.href.slice(window.location.href.indexOf('-') + 1);
			var apertura = '.panel' + hashes;
			
			$('.bg').find('.img').css('display', 'none');
			
			if(hashes != '2' & hashes != '3' & hashes != '4'){
				setTimeout(function(){	
					$('.panel1').find('.bg').find('.img').fadeIn(500);
				}, 1100);
				
				setTimeout(function(){
				video.css('background','url(/imgs/img_panel1.jpg) no-repeat');
				ico.css('background','url(/imgs/ico_panel1.gif) no-repeat');
				txt.css('background','url(/imgs/txt_panel1.gif) no-repeat');	
							
				}, 500);
			
				video.fadeOut(500);
				ico.fadeOut(500);
				txt.fadeOut(500);
				
				setTimeout(function(){	
					$('#bxVideo').find('.bt').css('display', 'none');
					ico.fadeIn(400);
					txt.fadeIn(600);
					video.fadeIn(800);
					}, 600);	
				
					
			}else{

				setTimeout(function(){	
					$('.panel'+ hashes ).find('.bg').find('.img').fadeIn(500);
				}, 1100);
				
				setTimeout(function(){
				video.css('background','url(/imgs/img_'+ apertura + '.jpg) no-repeat');
				ico.css('background','url(/imgs/ico_' + apertura + '.gif) no-repeat');
				txt.css('background','url(/imgs/txt_' + apertura + '.gif) no-repeat');	
							
				}, 500);
			
				video.fadeOut(500);
				ico.fadeOut(500);
				txt.fadeOut(500);
				//new
				if( hashes != '1'){
					lk.fadeOut(500);
				}
				setTimeout(function(){	
					ico.fadeIn(400);
					txt.fadeIn(600);
					video.fadeIn(800);
					//new	
					if( hashes != '1'){
						lk.fadeIn(900);
					}
					}, 600);
						
			}
		
			$('.o_chiudi').live('click', function() {
				MyChiudi();
			});
		
		/*overlay*/
		$('#bxVideo .bt').click(function() {	
										 
			var vName = $('#bxVideo .bt').attr('title');	
			var hH = $("body").height();			
			var hLay = hH + 24;
			
			instance_shr_box_overlay.jSharingbox({
            show_cond : new Array( 'facebook', 'twitter','googleplus','fb-like'),
            currentObjId:"shr_box_overlay",
			pageurl: detailPageSlider[vName]
        });		
			
	
			$('.overlay').css('height', hLay);
			$('.overlay').css('display', "block");
			$('.o_box').css('display', "block");
			video = '<video width="642" height="362" controls autoplay><source src="swf/'+ vName +'.mp4"  type="video/mp4" /><source src="swf/'+ vName +'.ogv" type="video/ogg"><object width="642" height="362" type="application/x-shockwave-flash" data="swf/'+ vName +'.swf"><param name="movie" value="swf/'+ vName +'.swf" /><param name="flashvars" value="autostart=true&amp;controlbar=over&amp;image=swf/poster.jpg&amp;file=swf/'+ vName +'.mp4" /><img src="swf/poster.jpg" width="642" height="362" alt="" title="No video playback capabilities, please download the video below" /></object></video>';
			
			$('.o_video').append(video);
			MyPosition();
		});
			
		$(document).keydown( function( e ) {
			if( e.which == 27) {  // escape, close box
				MyChiudi();
			}
		}); 	
		
		$(window).resize(function() {
								  
			MyPosition();					  

		});
		
		$('.o_chiudi').click(function() {
			jSharingBox.context4LogBI =instance_shr_box_hp_top.getContext();
			MyChiudi();

		});
});
