$(function() {
	if ($("#infoconseil_new_box_sx").height()!=null && $("#infoconseil_new_box_dx").height()!=null) {
		var d1 = $("#infoconseil_new_box_sx").height();
		var d2 = $("#infoconseil_new_box_dx").height();
		var d_sum = 10;
		if (Number(d1)>Number(d2))
		{
			d_sum += d1;
			//$("#infoconseil_new_box_dx").height(d1);
		}
		if (Number(d2)>Number(d1))
		{
			d_sum += d2;
			//$("#infoconseil_new_box_sx").height(d2);
		}
		$("#infoconseil_new_box_dx").height(d_sum);
		$("#infoconseil_new_box_sx").height(d_sum);
	}
	
	if ($("#info_conseil_ressegna_seduta").height()!=null && $("#info_conseil_precedenti_sedute").height()!=null) {
		var d1 = $("#info_conseil_ressegna_seduta").height();
		var d2 = $("#info_conseil_precedenti_sedute").height();
		var d_sum = 10;
		if (Number(d1)>Number(d2))
		{
			d_sum += d1;
			//$("#info_conseil_precedenti_sedute").height(d1);
		}
		if (Number(d2)>Number(d1))
		{
			d_sum += d2;
			//$("#info_conseil_ressegna_seduta").height(d2);
		}
		$("#info_conseil_precedenti_sedute").height(d_sum);
		$("#info_conseil_ressegna_seduta").height(d_sum);
	}
	
	
		if ($("#info_conseil_video_basso_sx").height()!=null && $("#infoconseil_new_box_dx").height()!=null) {
		var d1 = $("#info_conseil_video_basso_sx").height();
		var d2 = $("#infoconseil_new_box_dx").height();
		var d_sum = 10;
		if (Number(d1)>Number(d2))
		{
			d_sum += d1;
			//$("#infoconseil_new_box_dx").height(d1);
		}
		if (Number(d2)>Number(d1))
		{
			d_sum += d2;
			//$("#info_conseil_video_basso_sx").height(d2);
		}
		$("#infoconseil_new_box_dx").height(d_sum);
		$("#info_conseil_video_basso_sx").height(d_sum);
	}
	
	
	//@@GD configurazione oggetti Jquery
	if ($("#cont_txtblu").height()!=null && $("#rightcolumn02").height()!=null)
	{
		var d1 = $("#contentwrapperDown").height();
		$("#cont_txtblu").height(d1);
		var d2 = $("#rightcolumn02").height();
		if (Number(d1)>Number(d2))
		{
			$("#rightcolumn02").height(d1+5);
		}
		if (Number(d2)>Number(d1))
		{
			$("#cont_txtblu").height(d2-5);
		}
	}
	
	if ($("#cont_txt").height()!=null && $("#rightcolumn").height()!=null)
	{
		var d1 = $("#cont_txt").height();
		var d2 = $("#rightcolumn").height();
		if (Number(d1)>Number(d2))
		{
			$("#rightcolumn03").height(d1-140);
		}
		if (Number(d2)>Number(d1))
		{
			$("#cont_txt").height(d2-10);
		}
	}

	if (jQuery.browser.mozilla)
	{
		//workaround per firefox
		if (window.location.pathname.indexOf('default_i.asp')>0 || window.location.pathname.indexOf('default_f.asp')>0)
			$("#pre_menup").css('margin-top','13px');
		else
			$("#pre_menup").css('margin-top','1px');
	}

	/*
	if ($("#rightcolumn").height()!=null  && $("#contentwrapper").height()!=null)
	{
		//&& $("#riempitivomenualtosx").height()==0
		var d1 = $("#rightcolumn").height();
		var d2 = $("#contentwrapper").height();
		if (Number(d1)>Number(d2))
		{
			$("#riempitivomenualtosx").height(d1-d2);
		}
	}
	*/

	$("#btn_sommario").click(function(){
		if (!$("#div_sommario").is(":visible"))
		{
			$("#impostazioni").toggle();
			//$("#Player").toggle();
			TogglePlayer();
			
			$("#div_sommario").slideToggle("slow");
		}
		/*
		if ($("#Player").is(":visible"))
		{
			$("#impostazioni").toggle();
			$("#Player").toggle();
			
			$("#div_sommario").slideToggle("slow");
		}
		else
		{
			$("#div_sommario").slideToggle("slow",function(){
				$("#impostazioni").toggle();
				$("#Player").toggle();
				
			}
			);
		}
		if ($("#btn_sommario").html() == "Mostra sommario")
			{
				$("#btn_sommario").html("Nascondi sommario");
			}
		else
			{
				$("#btn_sommario").html("Mostra sommario");
			}
		*/

		return false;
	})

	$("#btn_video").click(function(){
		if ($('#Player_wrapper')!=null && $('#Player_wrapper').position()!=null)
		{
			if (0>$('#Player_wrapper').position().top)
			{
				$("#div_sommario").slideToggle("slow",function(){
					$("#impostazioni").toggle();
					//$("#Player").toggle();
					TogglePlayer();
				}
				);
			}		
		}
		else
		{
			if (!$("#Player").is(":visible"))
			{
				$("#div_sommario").slideToggle("slow",function(){
					$("#impostazioni").toggle();
					//$("#Player").toggle();
					TogglePlayer();
				}
				);
			}
		}
		/*
		else
		{
			$("#div_sommario").slideToggle("slow",function(){
				$("#impostazioni").toggle();
				$("#Player").toggle();
			}
			);
		}
		*/
		/*
		if ($("#btn_sommario").html() == "Mostra sommario")
			{
				$("#btn_sommario").html("Nascondi sommario");
			}
		else
			{
				$("#btn_sommario").html("Mostra sommario");
			}
		*/
		return false;
	})	
	
	try{
		createPlayer();
	}
	catch(e)
	{}

	if ($('#sd1'))
	{	
		//Posizione sul primo link del sommario
		if (document.getElementById('sd1')!=null)
		{
			var time = document.getElementById('sd1').getAttribute("onclick");
			time = time.replace("go_to(","").replace(")","");
			if (document.getElementById('Player').controls)
				setTimeout("document.getElementById('Player').controls.play();document.getElementById('Player').controls.currentPosition=" + time+";",1500);
			else
				setTimeout("if(thisMovie('Player')!=null&&thisMovie('Player').sendEvent!=null){thisMovie('Player').sendEvent('SEEK'," + time+");}",1500);
		}
	}
	
})

function thisMovie(movieName) {
	if(navigator.appName.indexOf("Microsoft") != -1) 
	{
		return window[movieName];
	} else {
		return document[movieName];
	}
}

function go_to(time)
{
		$("#div_sommario").slideToggle("slow",function()
			{
				$("#impostazioni").toggle();
				//$("#Player").toggle();
				TogglePlayer();
				//$("#btn_sommario").html("Mostra sommario");
				if ($("#Player").is(":visible"))
				{
					var isiPad = navigator.userAgent.match(/iPad/i) != null;
					if (isiPad)
						setTimeout("document.getElementById('Player').currentTime="+time+";",1500);
					else
					{
						if (document.getElementById('Player').controls)
							setTimeout("document.getElementById('Player').controls.play();document.getElementById('Player').controls.currentPosition=" + time+";",1500);
						else
							setTimeout("if(thisMovie('Player')!=null&&thisMovie('Player').sendEvent!=null){thisMovie('Player').sendEvent('SEEK'," + time+");}",1500);
					}
				}
			}
		);
}

function TogglePlayer()
{
	// Correzione per player non funzionante dopo applicazione stile css display:none
	if ($('#Player_wrapper')!=null && $('#Player_wrapper').position()!=null)
	{
		if (0>$('#Player_wrapper').position().top)
			$('#Player_wrapper').css({top:0});
		else
			$('#Player_wrapper').css({top:-3000});
	}
	else
		$("#Player").toggle();
}
