$(document).ready(function(){
	document.getElementById('stileAttivo').href = "css/style.css";
	var viewportHeight;
	var viewportHeight_tmp;
	var logoclick=true;
	var sottomenu=false;
	var footer_full;
	var contenuto_height;
	
	// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportHeight_tmp = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportHeight_tmp = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportHeight_tmp = document.getElementsByTagName('body')[0].clientHeight
 }
 	
	
	if(viewportHeight_tmp < 650){
		viewportHeight = 700
		if(viewportHeight_tmp > 610){ $('#footer').css({'bottom' : -100}); }
		else{
			$('#footer').css({'bottom' : -150});
		}

		footer_full = viewportHeight;
	}
	else{
		viewportHeight = viewportHeight_tmp
		footer_full = viewportHeight-60;
		$('#footer').css({'bottom' : viewportHeight-(contenuto_height+220)});
	}
	contenuto_height = viewportHeight-220;
	
	//document.write('<p>Your viewport width is '+viewportHeight+'x'+viewportHeight_tmp+'</p>');
	
	$('#dovesiamo').hide();
	$('#contenuto').css({'height' : contenuto_height});
	$('.innerfade img').css({'height' : contenuto_height});
	$('#sfondo_azienda, #mappa').css({'height' : contenuto_height});
	$('#trasparente').css({'height' : contenuto_height});
		
	
	$('#img_sfondo').cycle({ fx: 'fade' });
	
	$('.home_link').livequery('click', function(){
		$('#footer_content').hide();
			$(this).fadeIn();
			$('#contenuto').animate({height : contenuto_height}, 1000);
			$('#categorie').load('prodotti.html #categorie', function(){$(this).fadeIn();});
			$('#footer, #logo_legno').animate({height : 220}, 1000);
			$('#img_sfondo').hide().load('home.html .sfondo', 
						  function(){ 
								$(this).fadeIn(1000);
								$('#img_sfondo').cycle({ fx: 'fade' });
							});		
			$('#testo_legno').fadeIn("slow", function(){
				$('#trasparente').animate({height : contenuto_height-10}, 1000);
			});
		
		return false;
	});
	
	$('#azienda').hover(function(){			  
		$('#dovesiamo').fadeIn("normal");		
	}, 
	function(){
		$('#dovesiamo').fadeOut("normal");
	});
	
	$('.azienda_link').livequery('click', function(){
		$('#footer_content').hide().load('azienda.html #txt_azienda', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : 190}, 1000);
			$('#categorie').load('prodotti.html #categorie', function(){$(this).fadeIn();});
			$('#contenuto').animate({height : contenuto_height + 30});
			$('#img_sfondo').hide().load('azienda.html #sfondo_home', function(){ $(this).fadeIn(1000); });			
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.dovesiamo_link').livequery('click', function(){
		$('#footer_content').hide().load('contatti.html #txt_contatti', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : 200}, 1000);
			$('#contenuto').animate({height : contenuto_height + 20});
			$('#img_sfondo').hide().load('mappa.html iframe', function(){ $(this).css({'height' : contenuto_height}).fadeIn(1000);});
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.qualita_link').livequery('click', function(){
		$('#footer_content').hide().load('qualita.html #txt_qualita', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : 250}, 1000);
			$('#categorie').load('prodotti.html #categorie', function(){$(this).fadeIn();});
			$('#contenuto').animate({height : contenuto_height-30});
			$('#img_sfondo').hide().load('qualita.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.prodotti_link').livequery('click', function(){
		$('#footer_content').hide().load('prodotti.html #prodotti_content', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			$('#categorie').load('prodotti.html #categorie', function(){$(this).fadeIn();});
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.country_link').livequery('click', function(event){
		$('#footer_content').hide().load('country.php #prodotti_dettaglio', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			$('#categorie').load('country.php #cat_country', function(){$(this).fadeIn();});
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.contract_link').livequery('click', function(event){
		$('#footer_content').hide().load('contract.php #prodotti_dettaglio', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			$('#categorie').load('contract.php #cat_contract', function(){$(this).fadeIn();});
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.cntr_giorno_link').livequery('click', function(event){
		$('#footer_content').hide().load('cntr_giorno.php #prodotti_dettaglio', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.cntr_notte_link').livequery('click', function(event){
		$('#footer_content').hide().load('cntr_notte.php #prodotti_dettaglio', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.cnt_giorno_link').livequery('click', function(event){
		$('#footer_content').hide().load('cnt_giorno.php #prodotti_dettaglio', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.cnt_notte_link').livequery('click', function(event){
		$('#footer_content').hide().load('cnt_notte.php #prodotti_dettaglio', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.gallery a').livequery( function(){
		$(this).fancybox({ 
			'titleShow' : true,
			'showNavArrow' : true							
		});
	});
	
	$('#catalogo_mnt a').livequery( function() {
		$(this).fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'width'		: 730,
			'height'		: 550,
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'opaque'
			}
		});
	});
	
	$('.cucine_link').livequery('click', function(event){
		$('#footer_content').hide().load('Cucine.php #prodotti_dettaglio', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.notte_link').livequery('click', function(event){
		$('#footer_content').hide().load('Notte.php #prodotti_dettaglio', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.sala_link').livequery('click', function(event){
		$('#footer_content').hide().load('sala.php #prodotti_dettaglio', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.stube_link').livequery('click', function(event){
		$('#footer_content').hide().load('Stube.php #prodotti_dettaglio', function(){	
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.elbsee_link').livequery('click', function(event){
		$('#footer_content').hide().load('Elbsee.php #prodotti_dettaglio', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.garmisch_link').livequery('click', function(event){
		$('#footer_content').hide().load('Garmisch.php #prodotti_dettaglio', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.klostersee_link').livequery('click', function(event){
		$('#footer_content').hide().load('Klostersee.php #prodotti_dettaglio', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.kreuzberg_link').livequery('click', function(event){
		$('#footer_content').hide().load('Kreuzberg.php #prodotti_dettaglio', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.zell_link').livequery('click', function(event){
		$('#footer_content').hide().load('Zell.php #prodotti_dettaglio', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.mountain_link').livequery('click', function(event){
		$('#footer_content').hide().load('mountain.php #prodotti_dettaglio', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			$('#categorie').load('mountain.php #cat_mountain', function(){$(this).fadeIn();});
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	$('.contatti_link').livequery('click', function(event){
		$('#footer_content').hide().load('contatti.html #txt_contatti', function(){
			$(this).fadeIn();
			$('#footer, #logo_legno').animate({height : footer_full}, 1000);
			$('#categorie').load('prodotti.html #categorie', function(){$(this).fadeIn();});
			//$('#img_sfondo').hide().load('prodotti.html #sfondo_home', function(){ $(this).fadeIn(1000); });
			$('#testo_legno').fadeOut("slow", function(){
				$('#trasparente').animate({height : 50}, 1000);
			});
		});
		return false;
	});
	
	
});
