var url;
var tempo = 150;
$(document).ready(function(){
	$('#botoes a').click(function(){
		if ($('#menu').is(':animated')) {
		} else {
		url = $(this).attr('href');
		switch ($('#menu').css('left')) {
			case '155px':
				$('#menu').animate({
					width:'1000px'
					//left:'0%',
					//marginLeft:'0px'
				},1000);
				$('#line').css({
					'border': 'none'
				});
				$('#b1').animate({
					top:'-=120px'			 
				},tempo,'linear',function(){
					$('#b1').animate({
						left:'+=840px'			 
					},tempo*5,'linear',function(){
						$('#b1').animate({
							top:'+=240px'			 
						},tempo*2,'linear',function(){
							$('#b1').animate({
								left:'-=120px'			 
							},tempo,'linear',function(){
								$('#b1').animate({
									top:'-=120px'			 
								},tempo,'linear')
							})
						})
					})
				})
				$('#b2').animate({
					top:'+=120px'			 
				},tempo,'linear',function(){
					$('#b2').animate({
						left:'-=120px'			 
					},tempo,'linear',function(){
						$('#b2').animate({
							top:'-=240px'			 
						},tempo*2,'linear',function(){
							$('#b2').animate({
								left:'+=840px'			 
							},tempo*5,'linear',function(){
								$('#b2').animate({
									top:'+=120px'			 
								},tempo,'linear')
							})
						})
					})
				})
				$('#b3').animate({
					top:'-=240px'			 
				},tempo*2,'linear',function(){
					$('#b3').animate({
						left:'+=840px'			 
					},tempo*5,'linear',function(){
						$('#b3').animate({
							top:'+=240px'			 
						},tempo*2,'linear',function(){
							$('#b3').animate({
								left:'-=120px'			 
							})
						})
					})
				})
				$('#b4').animate({
					left:'-=120px'		 
				},tempo,'linear',function(){
					$('#b4').animate({
						top:'-=240px'			 
					},tempo*2,'linear',function(){
						$('#b4').animate({
							left:'+=840px'			 
						},tempo*5,'linear',function(){
							$('#b4').animate({
								top:'+=240px'			 
							},tempo*2,'linear',function(){
								end();
							})
						})
					})
				})
				$('#menu img:first, #footer').fadeOut(200);
				break;
			case '830px':
				$('#menu').animate({
					width:'1000px',
					left:'155px'
				},1000);
				$('#line').css({
					'border': 'none'
				});
				setTimeout(function(){
					$('#b1').animate({
						left:'-=720px'				 
					},tempo*6,'linear')
					$('#b2').animate({
						top:'+=120px'				 
					},tempo,'linear',function(){
						$('#b2').animate({
							left:'-=120px'			 
						},tempo,'linear',function(){
							$('#b2').animate({
								top:'-=120px'			
							},tempo,'linear',function(){
								$('#b2').animate({
									left:'-=600px'			 
								},tempo*5,'linear')
							})
						})
					})
					$('#b3').animate({
						top:'-=120px'			 
					},tempo,'linear',function(){
						$('#b3').animate({
							left:'-=600px'				 
						},tempo*5,'linear',function(){
							$('#b3').animate({
								top:'+=120px'			 
							},tempo,'linear',function(){
								$('#b3').animate({
									left:'-=120px'			
								},tempo,'linear')
							})
						})
					})
					$('#b4').animate({
						left:'-=120px'			 
					},tempo,'linear',function(){
						$('#b4').animate({
							top:'-=120px'			 
						},tempo,'linear',function(){
							$('#b4').animate({
								left:'-=600px'				 
							},tempo*5,'linear',function(){
								$('#b4').animate({
									top:'+=120px'			 
								},tempo,'linear',function(){
									end();
								})
							})
						})
					})			
				},200)
				$('#menu img:first, #footer').fadeOut(200);
				break;
			default:
				$('#menu').animate({
					width:'1000px',
					left:'0%',
					marginLeft:'0px'
				},1000,function(){	
				});
				
				$('#b1').animate({
					top:'-=120px'			 
				},tempo,'linear',function(){
					$('#b1').animate({
						left:'+=480px'			 
					},tempo*4,'linear',function(){
						$('#b1').animate({
							top:'+=240px'			 
						},tempo*2,'linear',function(){
							$('#b1').animate({
								left:'-=120px'			 
							},tempo,'linear',function(){
								$('#b1').animate({
									top:'-=120px'			 
								},tempo,'linear')
							})
						})
					})
				})
				$('#b2').animate({
					top:'+=120px'			 
				},tempo,'linear',function(){
					$('#b2').animate({
						left:'-=120px'			 
					},tempo,'linear',function(){
						$('#b2').animate({
							top:'-=240px'			 
						},tempo*2,'linear',function(){
							$('#b2').animate({
								left:'+=480px'			 
							},tempo*4,'linear',function(){
								$('#b2').animate({
									top:'+=120px'			 
								},tempo,'linear')
							})
						})
					})
				})
				$('#b3').animate({
					top:'-=240px'			 
				},tempo*2,'linear',function(){
					$('#b3').animate({
						left:'+=480px'			 
					},tempo*4,'linear',function(){
						$('#b3').animate({
							top:'+=240px'			 
						},tempo*2,'linear',function(){
							$('#b3').animate({
								left:'-=120px'			 
							})
						})
					})
				})
				$('#b4').animate({
					left:'-=120px'		 
				},tempo,'linear',function(){
					$('#b4').animate({
						top:'-=240px'			 
					},tempo*2,'linear',function(){
						$('#b4').animate({
							left:'+=480px'			 
						},tempo*4,'linear',function(){
							$('#b4').animate({
								top:'+=240px'			 
							},tempo*2,'linear',function(){
								end();
							})
						})
					})
				})
				$('#menu img:first, #footer').fadeOut(1000);
		}
		}
		return false;
	})
	if (lado == 1) {
		$('#conteudo').css({
			left:'0px'			   
		})
		$('#menu_portfolio').css({
			left:'0px',
			right:'auto'
		})
		$('#content.portfolio').css({
			marginLeft:'220px'				
		})
		$('#conteudo.port').css({
			backgroundPosition:'bottom right'					
		})
		$('#line').css({
			'border-left': '2px #792D16 solid'
		});
		$('#menu').css({
			width:'1000px',
			left:'auto',
			right:'0px'
		}).animate({
			width:'310px'
		},1000,function(){
			$('#menu').css({
				right:'auto',
				left:'830px'
			})
			$('#menu img:first, #footer').fadeIn();
		});
			$('#menu img:first, #footer').hide();
		$('#logo').css({
			top:'480px',
			left: '20px'
		});
		$("#logo").attr("src","public/images/web/estrutura/terra_tag_left.png"
		);
		$('#footer').css({
			top:'550px',
			left: '20px'
		});
		$('#footer span').css({
			'font-size': '9px'
		});
		$('#botoes').css({
			left:'auto',
			right:'30px'
		})
	} else if (lado == 2) {
		$('#line').css({
			'border-right': '2px #792D16 solid'
		});
		$('#menu').css({
			width:'1000px',
			left:'155px',
			right:'0px'
		}).animate({
			width:'310px'
		},1000,function(){
			$('#menu img:first, #footer').fadeIn();
		});
		$('#menu img:first, #footer').hide();
		$('#logo').css({
			top:'480px',
			left: '-5px'
		});
		$("#logo").attr("src","public/images/web/estrutura/terra_tag_right.png"
		);
		$('#footer').css({
			top:'550px',
			left: '0'
		});
		$('#footer span').css({
			'font-size': '9px'
		});
		$('#botoes').css({
			left:'155px'
		})
	} 
})
function end(){
	window.location.href = url;
}
