var scrollSpeed=1600; // change this value to adjust scroll speed (duration of change in ms)

var pagina = window.location.href.toLowerCase();
if (pagina.indexOf('destaque') != -1){
var startX = '-4000px';
var startY = '-800px';
}
else {
var startX = '-2000px';
var startY = '-800px';
}


$(document).ready(function(){
	$('#link1').hide();$('#link2').hide();$('#link3').hide();$('#link4').hide();$('#link5').hide();$('#link6').hide();$('#link7').hide();
	
	$("#contato_botao").click(function(){
		var nome = $("#nome").val();
		var email = $("#email").val();
		var mensagem = $("#mensagem").val();
		validar(nome, email, mensagem);
	}); 
	

						   
	$('#pane-container').stop().animate({'right':startX, 'top':startY},scrollSpeed, function(){
																								  
	/********************************************
	 * Animações do menu
	 */
	
			$("#link1").animate({
    		 width: ['toggle', 'easeInCubic'],
  			}, 500, function(){
			
				$("#link2").animate({
				 width: ['toggle', 'easeInCubic'],
				}, 500, function(){
				
					$("#link3").animate({
					 width: ['toggle', 'easeInCubic'],
					}, 500, function(){
					
						$("#link4").animate({
						 width: ['toggle', 'easeInCubic'],
						}, 500, function(){
						
							$("#link5").animate({
							 width: ['toggle', 'easeInCubic'],
							}, 500, function(){
							
								$("#link6").animate({
								 width: ['toggle', 'easeInCubic'],
								}, 500, function(){
								
									$("#link7").animate({
									 width: ['toggle', 'easeInCubic'],
									}, 500, function(){
										$("#navegador").show();
										});
								});
							});
						});
					});
				});
			});
			
	});
	
	
	
	/* Javascript Styling */
	
	$('body').css({ 'overflow':'hidden'});
	$('.pane').css({'float':'left'});
	$('.auxiliary-pane').css({'display':'block'});
	$('.row').css({'float':'right', 'width':'6000px'});
	
	
	/* Navigation Animations */

	$("#bug").click(function(event){
		navegar(event, '-2000', '-800');
	});

	$("ul#menu li#link1").click(function(event){
		navegar(event, '-2000', '-800');
	});
	
	$("ul#menu li#link2").click(function(event){
		navegar(event, '-1000', '0');
	});
	
	$("ul#menu li#link3, #aproveite_nossos_servicos").click(function(event){							 
		navegar(event, '-3000', '-1600');
	});
	
	$("ul#menu li#link4").click(function(event){
		navegar(event, '-4000', '-800');
	});
	
	$("ul#menu li#link5").click(function(event){
		navegar(event, '-3000', '0');
		
	});
	
	$("ul#menu li#link6, #link_twitter").click(function(event){
		navegar(event, '0', '-800');
	});
	
	$("ul#menu li#link7, #nos_contate").click(function(event){
		navegar(event, '-1000', '-1600');
		
		
		
		
		
	});
	
	/* Links do navegador */
	
	$("#tela_1a").click(function(event){
		navegar(event, '-4000', '0');
	});
	
	$("#tela_1b").click(function(event){
		navegar(event, '-3000', '0');
	});		
	
	$("#tela_1c").click(function(event){
		navegar(event, '-2000', '0');
	});
	
	$("#tela_1d").click(function(event){
		navegar(event, '-1000', '0');
	});
	
	$("#tela_1e").click(function(event){
		navegar(event, '0', '0');
	});
	
	$("#tela_2a").click(function(event){
		navegar(event, '-4000', '-800');
	});
	
	$("#tela_2b").click(function(event){
		navegar(event, '-3000', '-800');
	});
	
	$("#tela_2c").click(function(event){
		navegar(event, '-2000', '-800');
	});
	
	$("#tela_2d").click(function(event){
		navegar(event, '-1000', '-800');
	});
	
	$("#tela_2e").click(function(event){
		navegar(event, '0', '-800');
	});
	
	$("#tela_3a").click(function(event){
		navegar(event, '-3000', '-1600');
	});
	
	$("#tela_3b").click(function(event){
		navegar(event, '-2000', '-1600');
	});
	
	$("#tela_3c").click(function(event){
		navegar(event, '-1000', '-1600');
	});
	
	function navegar(event, x, y){
		$('#pane-container').stop().animate({'right': x + 'px', 'top': y + 'px'},scrollSpeed);
		xa = (((parseInt(x) +4000) /10) /4);
		ya = Math.abs(y) / 32;
		$('#tela_atual').stop().animate({'left': xa + 'px', 'top': ya + 'px'},scrollSpeed);
		event.preventDefault();
	}
});

function validar(nome, email, mensagem){
    
    if (nome == "" || nome == "Nome") {
        alert ("Por favor digite seu nome.");
        return false;
                    }
					
	if (mensagem == "" || mensagem == "Nome") {
        alert ("Por favor digite sua mensagem.");
        return false;
                    }
                    
    if (email == "" || email == "E-mail") {
        alert ("Por favor digite seu email.");
        return false;
                     }
    
    if (email.length >0) {
     i=email.indexOf("@")
     j=email.indexOf(".",i)
     k=email.indexOf(",")
     kk=email.indexOf(" ")
     jj=email.lastIndexOf(".")+1
     len=email.length

        if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)) {
            var valores = $("input, textarea").serialize();
            $("#enviando, #botao_enviar").slideToggle();
            $.post("contato.php", valores, function(data){
                alert(data);
                $("#enviando, #botao_enviar").slideToggle();
                
            });
        }
        else {
            alert("Por favor confira seu email.\n" +
            email + " não é um email válido.");
            return false;
            }
    }
};
