$(document).ready(function() {
timerID = setTimeout(function(){$("#panel").animate({
		height: $(window).height()-90
//		height: $(window).height()/2+120
		}, 1000, function(){
	var p = $("#panel:first");
	var offset = p.offset();
	var altura_iframa = parseInt($(window).height())- parseInt(offset.top)- 140;
	$('#progra').height(altura_iframa);
			});},600);	//tempo di apertura iniziale
	$("#ificha").hide();
	$("#iprograma").show();
	var activo = 0;
	
	

   $("#show_button").hide();
	$("#show_button").click(function(){
		 activo = 1;
		$("div#panel").animate({
			height: $(window).height()-90
		},1000);
		//$("div.panel_button").toggle();
		$("#hide_button").show();
		$("#show_button").hide();
	
	});
	
   $("#hide_button").click(function(){
		activo = 0;
		$("div#panel").animate({
			height: "94px"
		}, 1000);
		$("#hide_button").hide();
		$("#show_button").show();
   });
   
   $("#imgficha").click(function(){
		activo = 0;
		$("div#panel").animate({
			height: $(window).height()/2+120
		}, 1000, function(){
		$(window).resize();
		});
		$("#ificha").show();
		$("#iprograma").hide();		
   });
   
   $("#imgprograma1").click(function(){
		activo = 1;
		$("div#panel").animate({
			height: $(window).height()-90
		}, 1000, function(){
		$(window).resize();
		});
		$("#ificha").hide();
		$("#iprograma").show();
		$("#hide_button").show();
		$("#show_button").hide();

   });
   
	/*$("#imgficha").click(function(){
	  $('#ificha').fadeIn('slow', function() {
		$("div#panel").animate({
			height: $(window).height()/2
		}, 'slow', function(){
		$("#iprograma").fadeOut('slow');
		});
		});
	 
	});*/
	
	/*$("#imgprograma1").click(function(){
	$('#iprograma').fadeIn('slow', function(){									  
		$("div#panel").animate({
			height: $(window).height()-140
		}, 'slow', function() {
		$("#ificha").fadeOut('slow');
		});
		});	 
	});*/
   /*});
	$("#imgprograma1").click(function(){
		
	 $('#ificha').fadeOut(1000, function()
	{
		$("div#panel").animate({
			height: $(window).height()-140
		}, 1000, function()
	{
	$("#iprograma").fadeIn('slow');
	});
	});*/

	//$("#iprograma").slideDown("slow");
	//$("#ificha").fadeOut("slow");
	//$("#iprograma").fadeIn("slow");
	
	//$("#iprograma").show();
	//$("#ificha").hide();
$(function()
{
	$(window).resize(function()
	{
    	var elem = $(this);
		/*if($(window).height()-180 > 640)
		{
			$('#progra').height(600);
			$('#ficha').height(400);
		}
		else
		{
		$('#progra').height($(window).height()-280);
		$('#ficha').height($(window).height());
		}*/
		
//alert($("#panel").outerHeight(true))

		
		if(activo == 1)
		{
			$("div#panel").height($(window).height()-90);
		}
var p = $("#panel:first");
var offset = p.offset();
var altura_iframa = parseInt($(window).height())- parseInt(offset.top)- 140;
//$("#txt_").text(altura_iframa);
//$("#txt_2").text(offset.top  + " , height:" + $(window).height())

$('#progra').height(altura_iframa);
$('#ficha').height(altura_iframa);
  	});
	$(window).resize();
});

	
});
