// JavaScript Document
var p = " ";
$(function(){
	var d = window.setInterval(saudacao, 1000);
	$('#banner_coin').coinslider({ 
		width: 1000, // width of slider panel
		height: 218, // height of slider panel
		spw: 20, // squares per width
		sph: 5, // squares per height
		delay: 6000, // delay between images in ms
		navigation: false, // prev next and buttons
		links : false, // show images as links
		hoverPause: false // pause on hover
	});
	if($('#bg_banner').length){
		$('#bg_banner').fadeTo(100, 0.5,function(){ 
			$('#bg_banner').slideDown(300, function(){
				$('#banner_flutuante').slideDown(300);
			});
		});
	}
});

function abrPag(url){
	window.location.href = url;	
}

function fechaBanner(){
	$('#banner_flutuante').slideUp(300, function(){
		$('#bg_banner').slideUp(300);
	});	
}

function saudacao(){
	var hoje = new Date;
	var hora = hoje.getHours();
	if(hora >= 0 && hora < 13){
		var saudacao = "Bom dia";
	}else if(hora >= 13 && hora < 19){
		var saudacao = "Boa tarde";
	}else if(hora >= 19){
		var saudacao = "Boa noite";
	}
	if(hora > 12){
		hora = hora-12;
	}
	if(hora < 10){
		hora = "0"+hora;
	}
	var mes = hoje.getMonth();
	var meses = ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'];
	var dia = hoje.getDate();
	if(dia < 10){
		dia = "0"+dia;
	}
	var ano = hoje.getFullYear();
	var minuto = hoje.getMinutes();
	if(minuto < 10){
		minuto = "0"+minuto;
	}
	var semana = ['Domingo','Segunda-feira','Ter&ccedil;a-feira','Quarta-feira','Quinta-feira','Sexta-feira','S&aacute;bado'];
	var dsem = hoje.getDay();
	if(p == " "){
		p = ":";
	}else{
		p = " ";
	}
	var sauda = saudacao+"! "+semana[dsem]+", dia "+dia+"/"+meses[mes]+"/"+ano+" - "+hora+p+minuto;
	$('#relogio').html(sauda);
}

function confCont(){
	var nom = $('#nom').val();
	var ema = $('#ema').val();
	var tel = $('#tel').val();
	var cid = $('#cid').val();
	var est = $('#est').val();
	var ass = $('#ass').val();
	var txt = $('#txt').val();
	if(!nom || nom.length < 3){
		alert('Digite um nome válido!');
		return false;
	}else if(!ema || ema.length < 3 || ema.indexOf("@") < 0 || ema.indexOf(".") < 0){
		alert('Digite um email válido!');
		return false;
	}else if(!tel || ema.length < 13){
		alert('Digite um telefone válido!');
		return false;
	}else if(!cid || cid.length < 13){
		alert('Digite uma cidade válida!');
		return false;
	}else if(!est || est.length < 13){
		alert('Digite um estado válido!');
		return false;
	}else if(!ass){
		alert('Escolha um assunto!');
		return false;
	}else if(!txt || txt.length < 10){
		alert('Escreva sua mensagem com mais de 10 letras!');
		return false;
	}else{
		return true;
	}
}

function MudaVideo(src){
	var caminho = "http://www.aplicanet.com.br/~admpira/videos/";
	var vid = '<OBJECT id="MediaPlayer" type="application/x-oleobject" height="350" width="400" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">';
	vid += '<PARAM NAME="URL" VALUE="'+caminho+src+'">';
	vid += '<PARAM NAME="SendPlayStateChangeEvents" VALUE="True">';
	vid += '<PARAM NAME="AutoStart" VALUE="True">';
	vid += '<PARAM NAME="uiMode" VALUE="mini">';
	vid += '<PARAM NAME="PlayCount" VALUE="50">';
	vid += '<PARAM NAME="stretchToFit" VALUE="True">';
	vid += '<PARAM NAME="enableContextMenu" VALUE="False">';
	vid += '<embed type="application/x-mplayer2" ';
	vid += 'src="'+caminho+src+'" ';
	vid += 'name="player" ';
	vid += 'showcontrols="1" ';
	vid += 'showdisplay="0" ';
	vid += 'showstatusbar="1" ';
	vid += 'animationatstart="1" ';
	vid += 'transparentatstart="0" ';
	vid += 'allowchangedisplaysize="0" ';
	vid += 'autosize="1" ';
	vid += 'displaysize="0" ';
	vid += 'enablecontextmenu="0" ';
	vid += 'windowless="0" ';
	vid += 'width="400" ';
	vid += 'height="350" ';
	vid += 'enablefullscreencontrols="1"></embed>';
	vid += '</OBJECT>';
	$('#videoPlayer').html(vid);
}

function abrSetor(tipo){
	var valor = $('#'+tipo).val();
	if(valor){
		window.location.href = 'congrega.php?setor='+valor;
	}
}

function confNoivos(){
	var noi = $('#noivo').val();
	var noa = $('#noiva').val();
	var ema = $('#email').val();
	var fon = $('#fone').val();
	var dat = $('#data').val();
	var cur = $('#curso').val();
	if(!noi || noi.length < 3){
		alert('Digite um nome para o noivo válido!');
		$('#noivo').focus();
		return false;
	}else if(!noa || noa.length < 3){
		alert('Digite um nome para a noiva válido!');
		$('#noiva').focus();
		return false;
	}else if(!ema || ema.indexOf('@') < 0|| ema.indexOf('.') < 0){
		alert('Digite um email válido!');
		$('#email').focus();
		return false;
	}else if(!fon || fon.length < 14){
		alert('Digite um telefone válido!');
		$('#fone').focus();
		return false;
	}else if(!dat || dat.length < 10){
		alert('Digite a data para o casamento!');
		$('#data').focus();
		return false;
	}else if(!cur){
		alert('Escolha a melhor data para seu curso!');
		return false;
	}else{
		return true;
	}
}
