// JavaScript Document

<!--

// -----------------------------------------------------------------

// SWAP DE IMAGENS

// -----------------------------------------------------------------



function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}



function MM_swapImgRestore() { //v3.0

  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;

}



function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_swapImage() { //v3.0

  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)

   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}

}



// -----------------------------------------------------------------

// Hotfix para permitir transparencia de PNG no IE6

// -----------------------------------------------------------------

$(document).ready(function(){ $(document).pngFix(); }); 



// -----------------------------------------------------------------

// Função para troca de conteúdo de campo por ação Blur ou Focus

// -----------------------------------------------------------------



function CampoChecaInOut(acao,campo,valorpadrao)

	{

	a = document.getElementById(campo);

	if (acao == "1" && a.value == valorpadrao) { a.value = "" } // para onFocus

	if (acao == "0" && a.value == "") { a.value = valorpadrao } // para onBlur

	}



// -----------------------------------------------------------------

// Função para conteudo cin blackout

// -----------------------------------------------------------------



function blackout(id)

	{

	showHide('blackout');

	showHide(id);

	}



// -----------------------------------------------------------------

// Função para mostrar/esconder elemento

// -----------------------------------------------------------------



function showHide(id)
	{
	var obj = document.getElementById(id);
	if(obj.style.display == "") { obj.style.display = "none"; }
	else { obj.style.display = ""; }
	}

function showVisible(id)
	{
	var obj = document.getElementById(id);
	if(obj.style.visibility == "visible") { obj.style.visibility = "hidden"; }
	else { obj.style.visibility = "visible"; }
	}

function mostra_(id)
	{
	obj = document.getElementById(id);
	obj.style.display="block";
	}

function esconde_(id)
	{
	obj = document.getElementById(id);
	obj.style.display="none";
	}	


// -----------------------------------------------------------------

// Função para Slides

// -----------------------------------------------------------------



$(function(){

	$('#slider1').bxSlider({

		prev_image: '_img/slider_seta_esq.png',

		next_image: '_img/slider_seta_dir.png',

		wrapper_class: 'slider1_wrap',

		pager_class: 'slider1_pager',
		
		/*pager_text_before: 'RECENTES',*/ //não funciona
				
		margin: 0,

		auto: true,

		auto_controls: true,

		pager: true, 

		pause: 5000,

		stop_text: '', 

		start_text: ''	


	});

});




$(function(){

	$('#slider2').bxSlider({

		prev_image: '_img/slider_seta_esq.png',

		next_image: '_img/slider_seta_dir.png',

		wrapper_class: 'slider2_wrap',

		pager_class: 'slider2_pager',

		/*pager_text_before: ' Páginas ', */  //Nao funciona

		margin: 0,

		auto: true,

		auto_controls: true,

		pager: true, 

		pause: 5000,

		stop_text: '', 

		start_text: ''

	});

});



// -----------------------------------------------------------------

// Função para mostrar/esconder ordenar

// -----------------------------------------------------------------



function AbreOrdenar(acao)

	{

	obj = document.getElementById("ordenar");

	if (acao == "1") { obj.style.display = ""; } 

	if (acao == "0") { obj.style.display = "none"; } 

	}


// -----------------------------------------------------------------
// Função para Enviar indicação 
// -----------------------------------------------------------------

function indicacao(valor)
	{
	nome   = document.getElementById("nome").value;
	tit    = document.getElementById("titulo").value;		
	remet  = document.getElementById("remetente").value;			
	
	dest_1 = document.getElementById("destino_1").value;	
	dest_2 = document.getElementById("destino_2").value;	
	dest_3 = document.getElementById("destino_3").value;
	obs    = document.getElementById("obs").value;
	url    = document.getElementById("indique_url").value;
	proj   = document.getElementById("nome_projeto").value;	


	//VERIFICA OS CAMPOS PARA ENVIO DA INDICAÇÃO
	var inc_erro=0;
	var ereg =/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
	
	
	if(nome.length <= 2)
		{
		inc_erro = 1;
		alert("preencha o campo 'NOME'");
		document.getElementById("nome").style.backgroundColor="#EFEFEF"; 
		}
	else if(tit.length <= 2)
		{
		inc_erro = 1;
		alert("preencha o campo 'TITULO'");
		document.getElementById("titulo").style.backgroundColor="#EFEFEF"; 
		}			
	else if(ereg.test(remet)==false )
		{
		inc_erro = 1;
		alert("preencha o campo 'EMAIL' corretamente");
		document.getElementById("remetente").style.backgroundColor="#EFEFEF";  
		}
	else if(ereg.test(dest_1)==false )
		{
		inc_erro = 1; 
		alert("preencha o campo 'EMAIL(1) corretamente'");
		document.getElementById("destino_1").style.backgroundColor="#EFEFEF";  
		}

	if(inc_erro != 1)
		{	
					   
			if (window.XMLHttpRequest)
				{
				xmlhttp=new XMLHttpRequest(); //IE7+, Firefox, Chrome, Opera, Safari
				}
			else
				{
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); //IE6, IE5
				}
			xmlhttp.onreadystatechange=function()
			{
		  
			if (xmlhttp.readyState==4 && xmlhttp.status==200)
				{
				resp = document.getElementById("resp_form").innerHTML=xmlhttp.responseText;				
				alert(resp); // recupera o valor printado do arquivo indique.php e exibem no alert								
				document.getElementById("resp_form").style.display="none";
				}
			}
		
		dados = "nome="+nome+"&remetente="+remet+"&titulo="+tit+"&destino_1="+dest_1+"&destino_2="+dest_2+"&destino_3="+dest_3+"&obs="+obs+"&nome_projeto="+proj+"&url="+url
		
			xmlhttp.open("POST", "indique.php", true);
			xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");	
			xmlhttp.send(dados);   
			
			document.form_indicacao.reset();
			
			document.getElementById("nome").style.backgroundColor="#FFFFFF"; 
			document.getElementById("titulo").style.backgroundColor="#FFFFFF"; 			
			document.getElementById("destino_1").style.backgroundColor="#FFFFFF"; 
			document.getElementById("remetente").style.backgroundColor="#FFFFFF ";   
						
		}
	}

// -----------------------------------------------------------------
// CONTROLE DO POPUP
// -----------------------------------------------------------------

	$(document).ready(function() {	

  		//CARREGA A DIV DO POPUP E MOSTRA NA TELA
		$('#popup').fadeIn('slow', function() {	});		
		
	
		// EFEITO DE SCROLL DA DIV COM RELAÇÃO A TELA	
		var y_fixo = $("#popup").offset().top;
		$(window).scroll(function () {
			$("#popup").animate({
				top: y_fixo+$(document).scrollTop()+"px"
				},{duration:500,queue:false}
			);
		});

		//FECHA A DIV DO POPUP
		$('#close_pop').click(function() {
  			$('#popup').fadeOut('slow', function() {  });
		});
	});
	
	
	
	
	
	//document.getElementById('slider2_pager').innerHTML = " zzz ";
