// JavaScript Document
var agora;
function abre(id_mov,id_fixo,a) {

		var movimento = setTimeout("abre('"+ id_mov +"','"+ id_fixo +"')");
		var speed = 10;
		var divContainer = document.getElementById(id_mov).style;
		var limite = document.getElementById(id_fixo).clientWidth;
		avancaDIV = parseInt(divContainer.right)+speed+"px";
		if(a == 0)
		{
		 teste = parseInt(divContainer.right) + 520;
		}
		a++;
		if(parseInt(divContainer.right) >= parseInt(limite)) {
			clearTimeout(movimento);
			return;
		}
		
		if(parseInt(divContainer.right) == parseInt(teste)) {
			clearTimeout(movimento);
			return;
		}
		
		divContainer.right = avancaDIV;
}

function voltar(id_mov,a) {
	
		var movimento = setTimeout("voltar('"+ id_mov +"')");
		var speed = -10;
		var divContainer = document.getElementById(id_mov).style;
		avancaDIV = parseInt(divContainer.right)+speed+"px";
		if(a == 0)
		{
		 teste = parseInt(divContainer.right) - 520;
		 teste = teste + "px";
		}
		
		a++;
		
		if(parseInt(divContainer.right) <= 0) {
			clearTimeout(movimento);
			return;
		}
		
		if(divContainer.right == teste) {
			clearTimeout(movimento);
			return;
		}
		divContainer.right = avancaDIV;
}

function abre2(id_mov,id_fixo,a) {

		var movimento = setTimeout("abre2('"+ id_mov +"','"+ id_fixo +"')");
		var speed = 10;
		var divContainer = document.getElementById(id_mov).style;
		var limite = document.getElementById(id_fixo).clientWidth;
		limite = ((limite <= 220) ? 0 : limite);
		avancaDIV = parseInt(divContainer.right)+speed+"px";
		if(a == 0)
		{
		 teste = parseInt(divContainer.right) + 220;
		}
		a++;
		if(parseInt(divContainer.right) >= parseInt(limite)) {
			clearTimeout(movimento);
			return;
		}
		
		if(parseInt(divContainer.right) == parseInt(teste)) {
			clearTimeout(movimento);
			return;
		}
		
		divContainer.right = avancaDIV;
}

function voltar2(id_mov,a) {
	
		var movimento = setTimeout("voltar2('"+ id_mov +"')");
		var speed = -10;
		var divContainer = document.getElementById(id_mov).style;
		avancaDIV = parseInt(divContainer.right)+speed+"px";
		if(a == 0)
		{
		 teste = parseInt(divContainer.right) - 220;
		 teste = teste + "px";
		}
		
		a++;
		
		if(parseInt(divContainer.right) <= 0) {
			clearTimeout(movimento);
			return;
		}
		
		if(divContainer.right==teste) {
			clearTimeout(movimento);
			return;
		}
		divContainer.right = avancaDIV;
}

var n;
 
function mudarAuto()
{
	n = 1;
	setInterval("aranha()", 4000);
}

function aranha()
{
	n++;
	if(n > 3)
	{
	   n = 1; 	
	}
	trocaimg('fixa2',n,1);
}
function trocaimg(id_mov,img,b)
{
	var posicao = document.getElementById(id_mov).style;
	if(img == 1)
	{
		document.getElementById('link2').href = "javascript:void%200";
		document.getElementById('link3').href = "javascript:void%200";
		
		var movimento = setTimeout("trocaimg('"+ id_mov +"','"+ img +"')");
		var posicao = document.getElementById(id_mov).style;
		if(parseInt(posicao.right) == 0)
		{
			document.getElementById('link2').href = "javascript:trocaimg(\'fixa2\',2,1);";
			document.getElementById('link3').href = "javascript:trocaimg(\'fixa2\',3,1);";
			clearTimeout(movimento);
			return;
		}
		else
		{
			var speed = -30;
			avancaDIV = parseInt(posicao.right)+speed+"px";
			posicao.right = avancaDIV;
		}
	}
	if(img == 2)
	{
		document.getElementById('link1').href = "javascript:void%200";
		document.getElementById('link3').href = "javascript:void%200";
		var movimento = setTimeout("trocaimg('"+ id_mov +"','"+ img +"')");
		var posicao = document.getElementById(id_mov).style;
		if(parseInt(posicao.right) == 600)
		{
			document.getElementById('link1').href = "javascript:trocaimg(\'fixa2\',1,1);";
			document.getElementById('link3').href = "javascript:trocaimg(\'fixa2\',3,1);";
			clearTimeout(movimento);
			return;
		}
		if(parseInt(posicao.right) < 600)
		{
			var speed = 30;
			avancaDIV = parseInt(posicao.right)+speed+"px";
			posicao.right = avancaDIV;
		}
		if(parseInt(posicao.right) > 600)
		{
			var speed = -30;
			avancaDIV = parseInt(posicao.right)+speed+"px";
			posicao.right = avancaDIV;
		}
		return;
	}
	if(img == 3)
	{
		document.getElementById('link2').href = "javascript:void%200";
		document.getElementById('link1').href = "javascript:void%200";
		
		var movimento = setTimeout("trocaimg('"+ id_mov +"','"+ img +"')");
		var posicao = document.getElementById(id_mov).style;
		
		if(parseInt(posicao.right) == 1200)
		{
			document.getElementById('link2').href = "javascript:trocaimg(\'fixa2\',2,1);";
			document.getElementById('link1').href = "javascript:trocaimg(\'fixa2\',1,1);";
			clearTimeout(movimento);
			return;
		}
		if(parseInt(posicao.right) < 1200)
		{
			var speed = 30;
			avancaDIV = parseInt(posicao.right)+speed+"px";
			posicao.right = avancaDIV;
		}		
	}
}


function validaForm(){
							
	if (document.getElementById('nome').value == ""){	alert("Preencha seu nome!");	document.getElementById('nome').focus();	return false;	}                       
	if (document.getElementById('email').value == ""){	alert("Preencha seu email!");	document.getElementById('email').focus();	return false;	}		
	
	parte1 = document.getElementById('email').value.indexOf("@");
	parte2 = document.getElementById('email').value.indexOf(".");
	parte3 = document.getElementById('email').value.length;
									
	if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) {
		alert("Preencha com um email válido!");
		document.getElementById('email').focus();
		return false;
	}	
	
	if (document.getElementById('ddd').value == ""){	alert("Preencha seu DDD!");	document.getElementById('ddd').focus();	return false;	}
	if (document.getElementById('telefone').value == ""){	alert("Preencha seu telefone!");	document.getElementById('telefone').focus();	return false;	}
	
	
	
	
											
	return true;
}
