//Autor: Bortolotti Giacomo
//http://www.bellajack.it
//Date: 29/11/09

$(document).ready(function() {

	$('#app').addClass('nascondi');
	$('#villette').addClass('nascondi');
	$('#vacanze').addClass('nascondi');
	$('#commerciali').addClass('nascondi');
	
	var start = false;
	var appartamenti = false;
	var villette = false;
	var vacanze = false;
	var commerciali = false;
	
	$('#appartamentiButton').click(
		
			function(){
				if(!start){
					$('#app').animate({
						
						height: 'show'
						
						
					}, 500);
					appartamenti = true;
					start = true;
				}
				
				if(villette){
					$('#villette').animate({
						
						height: 'hide'
						
						
					}, 500, function(){
						
						$('#app').animate({
						
							height: 'show'
							
							
						}, 500);
						
					});
					villette = false;
					appartamenti = true;
				}
				
				if(vacanze){
					$('#vacanze').animate({
						
						height: 'hide'
						
						
					}, 500, function(){
						
						$('#app').animate({
						
							height: 'show'
							
							
						}, 500);
						
					});
					vacanze = false;
					appartamenti = true;
				}
				
				if(commerciali){
					$('#commerciali').animate({
						
						height: 'hide'
						
						
					}, 500, function(){
						
						$('#app').animate({
						
							height: 'show'
							
							
						}, 500);
						
					});
					commerciali = false;
					appartamenti = true;
				}
				
			}
	);
	
	$('#villetteButton').click(
		
		function(){
				if(!start){
					$('#villette').animate({
						
						height: 'show'
						
						
					}, 500);
					villette = true;
					start = true;
				}
				
				if(appartamenti){
					$('#app').animate({
						
						height: 'hide'
						
						
					}, 500, function(){
						
						$('#villette').animate({
						
							height: 'show'
							
							
						}, 500);
						
					});
					appartamenti = false;
					villette = true;
				}
				
				if(vacanze){
					$('#vacanze').animate({
						
						height: 'hide'
						
						
					}, 500, function(){
						
						$('#villette').animate({
						
							height: 'show'
							
							
						}, 500);
						
					});
					vacanze = false;
					villette = true;
				}
				
				if(commerciali){
					$('#commerciali').animate({
						
						height: 'hide'
						
						
					}, 500, function(){
						
						$('#villette').animate({
						
							height: 'show'
							
							
						}, 500);
						
					});
					commerciali = false;
					villette = true;
				}
				
			}
		
	);
	
	$('#vacanzeButton').click(
		
		function(){
				if(!start){
					$('#vacanze').animate({
						
						height: 'show'
						
						
					}, 500);
					vacanze = true;
					start = true;
				}
				
				if(appartamenti){
					$('#app').animate({
						
						height: 'hide'
						
						
					}, 500, function(){
						
						$('#vacanze').animate({
						
							height: 'show'
							
							
						}, 500);
						
					});
					appartamenti = false;
					vacanze = true;
				}
				
				if(villette){
					$('#villette').animate({
						
						height: 'hide'
						
						
					}, 500, function(){
						
						$('#vacanze').animate({
						
							height: 'show'
							
							
						}, 500);
						
					});
					villette = false;
					vacanze = true;
				}
				
				if(commerciali){
					$('#commerciali').animate({
						
						height: 'hide'
						
						
					}, 500, function(){
						
						$('#vacanze').animate({
						
							height: 'show'
							
							
						}, 500);
						
					});
					commerciali = false;
					vacanze = true;
				}
				
			}
		
	);
	
	$('#commercialiButton').click(
		
		function(){
				if(!start){
					$('#commerciali').animate({
						
						height: 'show'
						
						
					}, 500);
					commerciali = true;
					start = true;
				}
				
				if(appartamenti){
					$('#app').animate({
						
						height: 'hide'
						
						
					}, 500, function(){
						
						$('#commerciali').animate({
						
							height: 'show'
							
							
						}, 500);
						
					});
					appartamenti = false;
					commerciali = true;
				}
				
				if(villette){
					$('#villette').animate({
						
						height: 'hide'
						
						
					}, 500, function(){
						
						$('#commerciali').animate({
						
							height: 'show'
							
							
						}, 500);
						
					});
					villette = false;
					commerciali = true;
				}
				
				if(vacanze){
					$('#vacanze').animate({
						
						height: 'hide'
						
						
					}, 500, function(){
						
						$('#commerciali').animate({
						
							height: 'show'
							
							
						}, 500);
						
					});
					vacanze = false;
					commerciali = true;
					
				}
				
			}
		
	);

});
