inicio=true;
function carregaImagensApoio(posicao,externo){
	if (((externo)&&(inicio))||((!externo)&&(!inicio))){
		imagens = new Array ('apoio_imip.png','apoio_oi.png','apoio_brala.png');
		links   = new Array ('http://www.imip.org.br/','http://oibluesbynight.com.br/blog/','http://www.brala.org.br/');
		if ((posicao+1)>imagens.length){
			posicao=0;
		}
		document.getElementById('apoioImagem').innerHTML ='<a href="'+links[posicao]+'" target="_blank"><img border="0" src="images/general/'+imagens[posicao]+'"/></a>';
		posicao++;
		$('#apoioImagem').fadeIn(1000);
		timerSaida = setTimeout('descarregaImagensApoio()',4000);
		funcao = "timerEntrada = setTimeout('carregaImagensApoio("+posicao+",false)',5000)";
		eval(funcao);
		inicio=false;
	}
}
function descarregaImagensApoio(){
	$('#apoioImagem').fadeOut(1000);
}

divPrincipalAtual = '';
function fechaDivs(){
	
	document.getElementById('logo').style.display="none";
	//document.getElementById('btnConcurso').style.display="none";
	document.getElementById('paginaBroomer').style.display="none";
	document.getElementById('paginaCampanha').style.display="none";
	document.getElementById('paginaLojas').style.display="none";
	document.getElementById('paginaColecao').style.display="none";
	document.getElementById('paginaFaleConosco').style.display="none";
	document.getElementById('paginaNovidades').style.display="none";
	document.getElementById('paginaNovidadesInt').style.display="none";
	document.getElementById('paginaDicas').style.display="none";

	$('#menu').removeClass('pageBroomer');
	$('#menu').removeClass('pageCampanha');	
	$('#menu').removeClass('pageLojas');
	$('#menu').removeClass('pageColecao');
	$('#menu').removeClass('pageFaleConosco');
	
	//fecha as divs das noticias
	if (document.getElementById('noticiasId').value !=0){
		ids = document.getElementById('noticiasId').value.split(",");
		for (i=1;i<ids.length;i++){
			document.getElementById('interna'+ids[i]).style.display="none";
		}
	}
}
function carregaHome(){
	alteraTxt(1);
	fechaDivs();
	document.getElementById('logo').style.display="block";
	document.getElementById('btnConcurso').style.display="block";
}
function transicao(divNovo){
	if (divPrincipalAtual == ''){
		$(divNovo).fadeIn(1000);
	}else{
		$(divPrincipalAtual).fadeOut(1000);
		$(divNovo).fadeIn(1000);
	}
	divPrincipalAtual=divNovo;
}
function carregaBroomer(){
	alteraTxt(1);
	fechaDivs();
	$('#menu').addClass('pageBroomer');
	document.getElementById('paginaBroomer').style.display="block";
	document.title = "Broomer Men's Wear | A Broomer";
}

function carregaCampanha(){
	alteraTxt(1);
	fechaDivs();
	$('#menu').addClass('pageCampanha');
	document.getElementById('paginaCampanha').style.display="block";
	document.title = "Broomer Men's Wear | Campanha";
}

function carregaLojas(){
	alteraTxt(2);
	fechaDivs();
	$('#menu').addClass('pageLojas');
	document.getElementById('paginaLojas').style.display="block";
	document.title = "Broomer Men's Wear | Lojas";
	$('.endLojas').hide();
	$('#linkRecife').click(function(){
		$('.endLojas').fadeOut(600);
		$('#contentRecife').fadeIn(600);
		return false;
	});
	$('#linkGuararapes').click(function(){
		$('.endLojas').fadeOut(600);
		$('#contentGuararapes').fadeIn(600);
		return false;
	});
	$('#linkMaceio').click(function(){
		$('.endLojas').fadeOut(600);
		$('#contentMaceio').fadeIn(600);
		return false;
	});
	$('#linkPetrolina').click(function(){
		$('.endLojas').fadeOut(600);
		$('#contentPetrolina').fadeIn(600);
		$('#contentPetrolina2').fadeIn(600);
		return false;
	});
	$('#linkJoaoPessoa').click(function(){
		$('.endLojas').fadeOut(600);
		$('#contentJoaoPessoa').fadeIn(600);
		return false;
	});
	$('#linkSaoLuis').click(function(){
		$('.endLojas').fadeOut(600);
		$('#contentSaoLuis').fadeIn(600);
		return false;
	});
	$('#linkSalgueiro').click(function(){
		$('.endLojas').fadeOut(600);
		$('#contentSalgueiro').fadeIn(600);
		return false;
	});
	$('#anime').show(); 
	$('#anime').cycle({  
		fx:     'uncover',  
		timeout: 0,  
		speed: 800,  
		next:   '.next',  
		prev:   '.previous',  
		pager: '.numbers'  
	});
}
function carregaColecao(){
	alteraTxt(1);
	fechaDivs();
	$('#menu').addClass('pageColecao');
	document.getElementById('paginaColecao').style.display="block";
	document.title = "Broomer Men's Wear | Coleção";
	
	$('#carousel').jcarousel();	
	$('#carousel li a').hover(function(){
		$(this).find('span.mascara').fadeOut(300);
	}, function(){
		$(this).find('span.mascara').fadeIn(300);
	});	
	
	$('#carousel li a').fancybox({
		'transitionIn'	: 'fade',
		'transitionOut'	: 'fade',
		'overlayColor' : '#000',
		'centerOnScroll' : true,
		'titlePosition': 'over'
	});
}

function carregaFaleConosco(){
	alteraTxt(1);
	fechaDivs();
	$('#menu').addClass('pageFaleConosco');
	document.getElementById('paginaFaleConosco').style.display="block";
	document.title = "Broomer Men's Wear | Fale Conosco";
}
function carregaNovidades(){
	alteraTxt(1);
	fechaDivs();
	document.getElementById('paginaNovidades').style.display="block";
	document.title = "Broomer Men's Wear | Novidades";
	$('.listaNovidades').find('li:last').css('border','none');
	$('.listaNovidades').jScrollPane({showArrows:true});
}
function carregaNovidadesInt(notId){
	alteraTxt(1);
	fechaDivs();
	document.getElementById('paginaNovidadesInt').style.display="block";
	document.getElementById('interna'+notId).style.display="block";
	document.title = "Broomer Men's Wear | Novidades";
	$('.novidadesInt').jScrollPaneRemove();
	$('.novidadesInt').jScrollPane({showArrows:true});
}
function fichaDivsDica(){
	document.getElementById('dicaTipo').style.display="none";
	document.getElementById('dicaNosGravatas').style.display="none";
	document.getElementById('dicaVestir').style.display="none";
	document.getElementById('dicaViajando').style.display="none";
	document.getElementById('dicaTecidos').style.display="none";
}
function limpaMenu(){
	document.getElementById('aTipo').style.backgroundPosition= "15px 0";
	document.getElementById('aNosGravatas').style.backgroundPosition= "15px -34px";
	document.getElementById('aVestir').style.backgroundPosition= "15px -73px";
	document.getElementById('aViajando').style.backgroundPosition= "15px -109px";
	document.getElementById('aTecidos').style.backgroundPosition= "15px -145px";
}
function retiraHover(nome,posicao){
	if (nome!=document.getElementById('menuMarcado').value){
		document.getElementById(nome).style.backgroundPosition= posicao;
	}
}
function colocaHover(nome,posicao){
	if (nome!=document.getElementById('menuMarcado').value){
		document.getElementById(nome).style.backgroundPosition= posicao;
	}
}
function carregaDicas(dica,menu,posicao){
	alteraTxt(1);
	fechaDivs();
	fichaDivsDica();
	limpaMenu();
	document.getElementById('paginaDicas').style.display="block";
	document.getElementById(dica).style.display="block";
	document.title = "Broomer Men's Wear | Dicas";
	$('.dicasInt').jScrollPaneRemove();
	$('.dicasInt').jScrollPane({showArrows:true});
	document.getElementById('menuMarcado').value=menu;	
	document.getElementById(menu).style.backgroundPosition= posicao;
}
function alteraTxt(id){
	enviaRequisicao('ocultoFlash','altera_txt.php?id='+id,'');
}
function tiraEspaco(texto){
	while(texto.indexOf(" ") != -1){
	  texto = texto.replace(" ","");
	}
    return texto;
}
function validaNewsletter(){
	if(tiraEspaco(document.getElementById('emailNews').value) == ""){
		alert("Informe o e-mail.");
		document.getElementById('emailNews').focus();
		return ;	
	}else{	
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('emailNews').value))){ 
			alert("Email inválido.");
	        document.getElementById('emailNews').focus();
	   	    return;
	    }
	}	
	campos = "pagina=1&newsletter=1&email="+encodeURI(document.getElementById('emailNews').value);
	enviaRequisicao('formEmail','ler_pagina_remota.php?'+campos,'<div style="height:20px"><font color=white>Enviando...</font></div>');	
}

function submeterContato(){

	if(tiraEspaco(document.getElementById('nomeContato').value) != undefined){
        if(tiraEspaco(document.getElementById('nomeContato').value) == "" || tiraEspaco(document.getElementById('nomeContato').value)=="Nome"){
            alert("Informe o nome.");
            document.getElementById('nomeContato').focus();
            return;
        }
    }
	if(document.getElementById('emailContato').value != undefined){
        if(tiraEspaco(document.getElementById('emailContato').value) == ""||tiraEspaco(document.getElementById('emailContato').value)=="E-mail"){
            alert("Informe o e-mail.");
            document.getElementById('emailContato').focus();
            return;

        }else{
            if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('emailContato').value))){
                alert("Formato de email incorreto.");
                document.getElementById('emailContato').focus();
                return;
            }
        }
    }
    if(tiraEspaco(document.getElementById('assuntoContato').value) != undefined){
        if(tiraEspaco(document.getElementById('assuntoContato').value) == "" || tiraEspaco(document.getElementById('assuntoContato').value) =="Assunto"){
            alert("Informe a assunto.");
            document.getElementById('assuntoContato').focus();
            return;
        }
    }

	if(tiraEspaco(document.getElementById('mensagemContato').value) != undefined){
        if(tiraEspaco(document.getElementById('mensagemContato').value) == "" || tiraEspaco(document.getElementById('mensagemContato').value) == "Mensagem"){
            alert("Informe a mensagem.");
            document.getElementById('mensagemContato').focus();
            return;
        }
    }
	

	setarCamposContato();

	enviaRequisicao('enviaContato','enviarContato.php?'+campos,'<div style="margin:150px 130px;color:white"><img src="images/general/loading3.gif"/>Enviando...</div>');
    document.getElementById('nomeContato').value='';
	document.getElementById('emailContato').value='';
	document.getElementById('assuntoContato').value='';
	document.getElementById('mensagemContato').value='';

}

function setarCamposContato(){
	campos = "nome="+encodeURI(document.getElementById('nomeContato').value);
	campos += "&email="+encodeURI(document.getElementById('emailContato').value);
	campos += "&assunto="+encodeURI(document.getElementById('assuntoContato').value);
	campos +="&mensagem="+encodeURI(document.getElementById('mensagemContato').value);
}
