$(document).ready(
   function()
   {
		/* external link */		
		$("a[rel='blank']").click(function(){
			window.open($(this).attr('href'));
			return false;
		});

		$("dd").hide();
		$("dt a").click(function(){
			$(this).parent().next().slideToggle("slow");
			return false;
		});
		
		var path = window.location.toString().split('#');
		var pathAgenda = path[1];
		var path2 = location.pathname;
		path2=path2.substring(path2.indexOf("/"));

		if( (path2 == "/sole/") || (path2 == "/sole/index.php") || (path2 == "/sole/prodotto.php") || (path2 == "/sole/agenda.php") ){
			$(".header ul li a.sole").addClass("on");
		}
		if( (path2 == "/vento/") || (path2 == "/vento/index.php") || (path2 == "/vento/prodotto.php") || (path2 == "/vento/agenda.php") ){
			$(".header ul li a.vento").addClass("on");
		}
		if( (path2 == "/acqua/") || (path2 == "/acqua/index.php") || (path2 == "/acqua/prodotto.php") || (path2 == "/acqua/agenda.php") ){
			$(".header ul li a.acqua").addClass("on");
		}
		if( (path2 == "/chisiamo/") || (path2 == "/chisiamo/index.php") || (path2 == "/chisiamo/leasing.php") || (path2 == "/chisiamo/ambiente.php") || (path2 == "/contatti/") || (path2 == "/contatti/index.php") ){
			$(".header ul li a.chisiamo").addClass("on");
		}
		if( (path2 == "/scenario/") || (path2 == "/scenario/index.php") || (path2 == "/scenario/01.php")  || (path2 == "/scenario/02.php")  || (path2 == "/scenario/03.php")  || (path2 == "/scenario/04.php")  || (path2 == "/scenario/05.php")  || (path2 == "/scenario/06.php")  || (path2 == "/scenario/07.php")  || (path2 == "/scenario/08.php")  || (path2 == "/scenario/09.php") ){
			$(".header ul li a.scenario").addClass("on");
		}
		if( (path2 == "/agenda/") || (path2 == "/agenda/index.php") ){
			$(".header ul li a.agenda").addClass("on");
		}
		
		//var prePath = "/work.env/unicredit.energy.dev.it/htdocs";
		var prePath = "";
						
		if((path2 == prePath + "/acqua/video.php") || (path2 == prePath+"/sole/video.php") || (path2 == prePath+"/vento/video.php") || (path2 == prePath+"/interviews/")) {
			var hash = { mainWidth: 690, mainHeight: 535 }
			var videoOverlay = new jQSoverlay.build(hash);
		}
		
		$('img[rel="overlay_open"]').bind("click", function(e) {
			var videoPath = prePath + "/video/interview/" + this.id + ".m4v";
			var params = { menu:"false", allowFullScreen:"true" };
			var flashvars = { videoFile: videoPath,videoWidth: '640', videoHeight: '352' };
			var attributes = { id: 'videoplayer' };
			
			swfobject.embedSWF(prePath + '/swf/player.swf', 'videoplayer', '640', '400', '9.0.0', prePath + '/js/expressinstall.swf', flashvars, params, attributes);
			
			var $target = $(e.target).parent().parent();
			
			$('#overlay h4').html($('div.video_right h4', $target).html());
			$('#overlay h5').html($('div.video_right h5', $target).html());
			
			videoOverlay.reveal();
		});
		
		$('span[rel="overlay_close"]').bind("click", function() {
			videoOverlay.conceal();
		});
});
