﻿var total_intro = 3; //Aqui coloca-se o numero de introduções existentes
var total_sol = 5; //Aqui coloca-se o numero de soluções existentes - editado por Carol 14.07.2011
var total_cli = 0; //Aqui coloca-se o numero de clientes existentes {NÃO MUDE O VALOR DESSA VARIÁVEL}
var total_depo = 0; //Aqui coloca-se o numero de depoimentos existentes {NÃO MUDE O VALOR DESSA VARIÁVEL}

var cli_atual = 1; //Indice de cliente atual
var depo_atual = 1; //Indice de depoimento atual

var lightArray = new Array(3); //inicia a array de lightBox
var total_light = 0; //total de imagens no portifolio

////////////////////////////////////////////////////////////////////////////FUNÇÕES DA PARTE DE INTRODUÇAO
function someIntro(){ //FUNÇÃO PARA SUMIR TODAS AS INTRODUÇÕES
		var i = 0;
		for(i=1;i<=total_intro;i++){
			$("#intro_txt_"+i).css({display:"none"});
			}
		}
function apareceIntro(num){ //FUNÇÃO PARA APARECER UMA INTRODUÇÃO
	someIntro();
	$("#intro_txt_"+num).css({display:""});
	}
function iniciaIntro(){ //Função de iniciação
	var i = 0;
	var local = 0;
	apareceIntro(1);
	for(i=1;i<=total_intro;i++){
		$("#a_intro"+i).click(function(){
									   local = this.id.substr(this.id.length-1)
									   apareceIntro(local);
									   });
		}
	}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////FUNÇÕES DA PARTE DE SOLUÇÕES
function someSol(){ //FUNÇÃO PARA SUMIR TODAS AS SOLUÇÕES
	var i = 0;
	for(i=1;i<=total_sol;i++){
		$("#sol_cont_txt"+i).css({display:"none"});
		}
	}
function mudaSol(num){//Aqui muda a classe do fundo de Soluções
	someSol();
	$("#sol_cont_txt"+num).css({display:""});
	num = (num-1)*217
	$("#solMenu").css({float:"left", width:"217px", height:"258px", background:"url(images/menu_comp.jpg) no-repeat", backgroundPosition: "-"+num+"px 0px"});
	}
function iniciaSol(){ //Função de iniciação
	var i = 0;
	var local = 0;
	mudaSol(1);
	for(i=1;i<=total_sol;i++){
		$("#a_sol"+i).click(function(){
									 local = this.id.substr(this.id.length-1);
									 mudaSol(local);
									 })
		}
	}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////FUNÇÕES DA PARTE DE CLIENTES
function someCli(){ //Função para sumir todos os grupos de clienes
		$(".cliCont").css({display:"none"});
	}
function mudaCli(num){ //Função para aparecer um grupo de clientes
	someCli();
	$(".cliCont:eq("+(num)+")").css({display:""});
	}
function maisCli(){ //Função para mudar o grupo de clientes clicando no botão de mais
	cli_atual++;
	if(cli_atual>total_cli) cli_atual = 0;
	mudaCli(cli_atual);
	}
function menosCli(){ // Função para mudar o grupo de clientes clicando no botão de menos
	cli_atual--;
	if(cli_atual < 0) cli_atual = total_cli;
	mudaCli(cli_atual)
	}
function iniciaCli(){ //Função de iniciação
	total_cli = $(".cliCont").length-1
	cli_atual = 0;
	mudaCli(cli_atual);
	$("#a_maisCli").click(function(){
								   maisCli();
								   })
	$("#a_menosCli").click(function(){
									menosCli();
									})
	}
//////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////////Funções de Depoimentos
function someDepo(){ //Função para sumir todos os depoimentos
	$(".depo_cont").css({display:"none"});
	}
function mudaDepo(num){ // Função para selecionar apenas um depoimento
	someDepo();
	$(".depo_cont:eq("+(num-1)+")").css({display:""});
	}
function maisDepo(){ // Funão para mudar o depoimento quando clicar no botão de mais
	depo_atual++;
	if(depo_atual>(total_depo-1)) depo_atual = 1;
	mudaDepo(depo_atual);
	}	
function menosDepo(){ //função para mudar o depoimento quando clicar no botão de menos
	depo_atual--;
	if(depo_atual < 1) depo_atual = total_depo-1;
	mudaDepo(depo_atual);
	}
function iniciaDepo(){ //Função de iniciação
	total_depo = $(".depo_cont").length;
	mudaDepo(1);
	$("#a_maisDepo").click(function(){
									maisDepo();
									})
	$("#a_menosDepo").click(function(){
									 menosDepo();
									 })
	}
//////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////Funções de iniciação do site
function iniciaSite(){
	var i = 0;
	
	lightArray[0] = 0
	lightArray[1] = 1
	lightArray[2] = 2
	lightArray[3] = 3	
	
	$(".a_topo").click(function(){
								scroll(0,0);
								});
	
	total_light = $(".lProd").length;
	$(".lProd").css({display:"none"});
	
	mostraA();
	
	$("#pf_esq").click(function(){
								poeMenos();
								});
	$("#pf_dir").click(function(){
								poeMais();
								})
	$("#btn_envia").click(function(){
								   enviaEmail();
								   });
	
	}
///////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////Funções de iniciaçao do lightbox
function iniciaLight(){
	var light_altura = window.screen.height;
	var light_tamanho = window.screen.width;
	var endereco = "";
	var light = "";
	
	light = light + '<div id="lightbox" style="background-image:url(images/pontolapontoca.gif); position:fixed; width:'+light_tamanho+'px; height:'+light_altura+'px; padding-left:50%; display:none;">';
	light = light + '	<div id="dlight" style="background-color:#000000; width:800px; height:550px; margin-left:-350px; margin-top:50px; position:absolute; border:1px solid #ff9933;">';
	light = light + '		<div id="dragL" style="height:30px; cursor:move; background-color:#272727; text-align:right; padding:2px; background-image:url(images/topo_janela.gif); padding-left:760px;">';
	light = light + '			<div style="width:35px; height:30px; text-align:right; right:0px; cursor:pointer;" onclick="fechaLight();">&nbsp;</div>';
	light = light + '		</div>';
	light = light + '		<iframe id="ilight" frameborder="0" style="margin:20px; width:760px; height:460px; overflow:auto;"></iframe>';
	light = light + '	</div>';
	light = light + '</div>';
	
	$("body").prepend(light);
	
	$("#dlight").draggable({ghosting:	true,
				opacity:	0.5,
				fx:			300,
				distance: 20,
				helper: 'clone',
				revert: true});

	}
function fechaLight(){
	$("#lightbox").css({display:"none"});
	$("#ilight").attr("src","about:blank");
	}
//////////////////////////////////////////////////////////////////////////////////////////////

function iniciaAlerta(){
	var light_altura = window.screen.height;
	var light_tamanho = window.screen.width;
	var endereco = "";
	var light = "";
	
	light = light + '<div id="lescrita" style="background-image:url(images/pontolapontoca.gif); position:fixed; display:none; width:'+light_tamanho+'px; height:'+light_altura+'px; padding-left:50%; display:none;">';
	light = light + '<div id="sescrita" style="border:1px solid #ff9933; height:150px; width:350px; background-color:#EEEEEE; position:absolute; margin-top:250px; margin-left:-175px;">';
	light = light + '	<div id="descrita" style="height:22px; background-color:#272727; border-bottom:#ff9933; padding:2px; color:#ff9933; font-family:Arial; font-weight:bold;">Interamplitude</div>';
	light = light + '	<div id="aescrita" style="height:60px; margin-left:20px; padding-top:20px; color:#272727;"></div>';
	light = light + '	<div style="text-align:center;"><input type="button" value="Ok" onclick="fechaAlerta();" style="width:50px;"></div>';
	light = light + '</div>';
	light = light + '</div>';
	
	$("body").prepend(light);
	
	
	$("#sescrita").draggable({ghosting:	true,
				handle: '#descrita',
				opacity:	0.5,
				fx:			300,
				distance: 20,
				helper: 'clone',
				revert: true});
	}
function fechaAlerta(){
	$("#lescrita").css({display:"none"});
	$("#aescrita").html("");
	}
function alerta(valor){
	$("#lescrita").css({display:""});
	$("#aescrita").html(valor);
	}

//////////////////////////////////////////////////Funções para o portifolio

function veriMais(num){
	num = num + 1
	if(num==total_light) return 0;
	return num;
	}
function veriMenos(num){
	num = num - 1;
	if(num<0) return total_light-1;
	return num;
	}
function mostraA(){
	var i = 0;
	for(i=0;i<4;i++){
		$(".pf_mostra_site:eq("+i+")").html($(".lProd:eq("+lightArray[i]+")").html());
		}
		$(".abreLight").click(function(){
							   endereco = this.rel;
							   $("#lightbox").css({display:""});
							   $("#ilight").attr("src",endereco);
							   });

	}
function poeMais(){
	lightArray[0] = veriMais(lightArray[0]);
	lightArray[1] = veriMais(lightArray[1]);
	lightArray[2] = veriMais(lightArray[2]);
	lightArray[3] = veriMais(lightArray[3]);	
	mostraA();
	}
	
function poeMenos(){
	lightArray[0] = veriMenos(lightArray[0]);
	lightArray[1] = veriMenos(lightArray[1]);
	lightArray[2] = veriMenos(lightArray[2]);
	lightArray[3] = veriMenos(lightArray[3]);	
	mostraA();
	}

///////////////////////////////////////////////////////////////////////////



function enviaEmail()
{
var xmlhttp;
var nome = $("#cto_form_nome").val();
var email = $("#cto_form_email").val();
var ddd = $("#cto_form_ddd").val();
var tel = $("#cto_form_tel").val();
var msg = $("#cto_form_msg").val();
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {
  
  //alerta("Seu e-mail foi enviado com sucesso! Obrigado");
  alerta(xmlhttp.responseText)
  $("#cto_form_nome").val("");
  $("#cto_form_email").val("");
  $("#cto_form_ddd").val("");
  $("#cto_form_tel").val("");
  $("#cto_form_msg").val("");
  }
}
//alert(cep)
xmlhttp.open("GET","http://www.interamplitude.com.br/envia.asp?nome="+nome+"&email="+email+"&ddd="+ddd+"&tel="+tel+"&msg="+msg+"",true);
xmlhttp.send(null);
}


$(document).ready(function() { //TUDO QUE DEVERÁ SER INICIADO JUNTO A PÁGINA
	iniciaAlerta(); //inicial alerta
	iniciaIntro(); //Iniciar a parte de introdução
	iniciaSol(); //aparecer a primeira Solução
	iniciaCli(); //aparecer o primeiro cliente
	iniciaDepo(); //aparecer o primeiro depoimento
	iniciaSite(); //iniciar Site
	iniciaLight(); //inicial Lightbox
	
	
});
