function empty(v){
	if(v==null || v==0 || v=='' || v==""){ return true; }
	else{ return false; }
}
	
$(function(){
	
	$('.section').css({ 'height' : $(window).height() + 'px' });
	
	function pageload(hash){
		if(hash){
			
			$.browser.msie ? hash = encodeURIComponent(hash) : "";
			
			if(hash != 'home')
			{
				$('#top').show();
				$('#footer').show();
				
				$('#' + hash + ' > div.bloco').load("pages/" + hash + ".php");
			}
			else
			{
				$('#top').hide();
				$('#footer').hide();
			}
		}
		else
		{
			$("#load").empty();
			
			$('#top').hide();
			$('#footer').hide();
			
			window.location = '#home';
		}
	}
	
	if(!window.location.hash)
	{
		$("#load").empty();
		
		$('#top').hide();
		$('#footer').hide();
		
		window.location = '#home';
	}
	
	$.historyInit(pageload, "pages/home.php");
	
	$("a[rel='history']").click(function(event){
		var hash = this.href;
		var $anchor = $(this);
		
		//alert($anchor.attr('href'))
		
		$('html, body').stop().animate({
			scrollTop: $($anchor.attr('href')).offset().top
		}, 1500, 'easeInOutExpo');
		
		event.preventDefault();
		
		hash = hash.replace(/^.*#/, '');
		$.historyLoad(hash);
		
		//alert($anchor)
		
		return false;
	});
	
	
	
	/*
	$('.nav a').bind('click', function(event){
		var $anchor = $(this);
		
		$('html, body').stop().animate({
			scrollTop: $($anchor.attr('href')).offset().top
		}, 1500, 'easeInOutExpo');
		
		event.preventDefault();
	});
	*/
	
	
	
	
	/*
	$('.nav a').bind('click', function(event){
		var $anchor = $(this);
		
		$('html, body').stop().animate({
			scrollTop: $($anchor.attr('href')).offset().top
		}, 1500, 'easeInOutExpo');
		
		event.preventDefault();
	});
	
	if(navigator.appName == "Microsoft Internet Explorer"){
		$('#top, #footer').show();
	}
	
	$('.section').css({ 'height' : $(window).height() + 'px' });
	
	if(window.pageYOffset >= $(window).height())
	{
		$('#top, #footer').show();
	}
	
	$('#_bora_').empty().load('bora-bora.html');
	$('#port_bora').empty().load('bora-trabalhos.html');
	$('#clients_bora').empty().load('bora-clientes.html');
	$('#contato_bora').empty().load('bora-contato.html');
	
	$('.galera').click(function(evento){
		evento.preventDefault();
		
		$('.carregando').css('display', 'inline');
		
		$('#_bora_').load('bora-bora.html', function(){
			$('.carregando').css('display', 'none');
			$('#top, #footer').fadeIn('slow');
		});
	});
	
	$('.jobora').click(function(evento){
		evento.preventDefault();
		
		$('.carregando').css('display', 'inline');
		
		$('#port_bora').load('bora-trabalhos.html',function(){
			 $('.carregando').css('display', 'none');
			 $('#top, #footer').fadeIn('slow');
		});
	});
	
	$('.clients').click(function(evento){
		evento.preventDefault();
		
		$('.carregando').css('display', 'inline');
		
		$('#clients_bora').load('bora-clientes.html',function(){
			$('.carregando').css('display', 'none');
			$('#top, #footer').fadeIn('slow');
		});
	});
	
	$('.contact_bora').click(function(evento){
		evento.preventDefault();
		
		$('.carregando').css('display', 'inline');
		
		$('#contato_bora').load('bora-contato.html',function(){
			$('.carregando').css('display', 'none');
			$('#top, #footer').fadeIn('slow');
		});
	});
	*/
	$('div#news div a, div#footer ul li#msEmail a').click(function(){
		
		if($('div#news div form').is(':hidden'))
		{
			$('div#news div').animate({'right' : '0px'});
			$('div#news div form').fadeIn();
			$('div#footer ul li#msEmail a').css({'background-position' : '-60px -30px'});
		}
		else
		{
			$('div#news div').animate({'right' : '-410px'});
			$('div#news div form').fadeOut();
			$('div#footer ul li#msEmail a').css({'background-position' : '-60px 0px'});
		}
		
	});
	
});
