
	/*
	
	PORTAL GPL
	-----------------------------------------------------------------------------------------------------------------
	@author: 		Guilherme Augusto Madaleno
	@description: 	Functions file
	@email:			zatec@ymail.com
	@site:			http://www.zatecus.com.br
	@version:		1.0
	
	*/
	
	/*
		Insere e-mails no banco de dados
		-----------------------------------------------------------------------------------------------------------------
	*/

	function addNewsletter ()
	{
		var email = $('#newsletter');
		if (email.val())
		{
			$.ajax
			({
				type		: "POST",
				url			: root + 'json=newsletter',
				data		: "email=" + email.val(),
				dataType	: "json",
				error		: function (XMLHttpRequest, textStatus, errorThrown)
				{
					alert('Erro ao cadastrar seu e-mail. Poderia por favor tentar novamente?');
				},
				success		: function(callBack)
				{
					switch (callBack)
					{
						default:
							alert('Ocorreu um erro ao cadastrar sua newsletter. Poderia tentar novamente?');
						break;
						
						case 'ok':
							alert('Newsletter inserida com sucesso. Obrigado!');
						break;
						
						case 'invalid_email':
							alert('Digite antes seu e-mail!');						
						break;
						
						case 'error_db':
							alert('Ocorreu um erro ao cadastrar sua newsletter. Poderia tentar novamente?');
						break;
						
						case 'email_exists':
							alert('Seu e-mail ja foi cadastrado anteriormente!');
						break;
						
						case 'email_not_valid':
							alert('E-mail invalido. Por favor, tente novamente');
						break;
						
						case 'no_email':
							alert('Ocorreu um erro ao cadastrar sua newsletter. Poderia tentar novamente?');
						break;
					}
					return false;
				}
			});	
		}
	}
	
	/*
		Envia formulário de contato
		-----------------------------------------------------------------------------------------------------------------
	*/
	
	function contactForm ()
	{
		var nome 		= $('#nome');
		var email 		= $('#email');
		var telefone 	= $('#telefone');
		var assunto 	= $('#assunto');
		var mensagem 	= $('#mensagem');
		if (!nome.val())
		{
			alert('Favor preencher seu nome!');
			nome.focus();	
			return false;
		}
		else if (!email.val())
		{
			alert('Favor preencher seu email!');
			email.focus();
			return false;
		}
		else if (!telefone.val())
		{
			alert('Favor preencher seu telefone!');
			telefone.focus();
			return false;
		}
		else if (!assunto.val())
		{
			alert('Favor preencher seu assunto!');
			assunto.focus();
			return false;
		}
		else if (!mensagem.val())
		{
			alert('Favor preencher sua mensagem!');
			mensagem.focus();
			return false;
		}
		else
		{
			document.contact.submit();
		}
	}
	
	/*
		Envia formulário para currículos
		-----------------------------------------------------------------------------------------------------------------
	*/
	
	function curriculumForm ()
	{
		var nome 			= $('#nome');
		var email 			= $('#email');
		var telefone 		= $('#telefone');
		var curriculo 		= $('#curriculo');
		var curriculoExt	= $('#curriculo').val().split('.').pop().toLowerCase();
		var sendButton		= $('#sendButton');
		
		if (!nome.val())
		{
			alert('Favor preencher seu nome!');
			nome.focus();	
			return false;
		}
		else if (!email.val())
		{
			alert('Favor preencher seu email!');
			email.focus();
			return false;
		}
		else if (!telefone.val())
		{
			alert('Favor preencher seu telefone!');
			telefone.focus();
			return false;
		}
		else if (!curriculo.val())
		{
			alert('Favor anexar seu curriculo!');
			curriculo.focus();
			return false;
		}
		else if (curriculoExt != 'doc' && curriculoExt != 'docx' && curriculoExt != 'pdf')
		{
			alert('O formato do currículo que você selecionou é inválido!');
			curriculo.focus();
			return false;
		}
		else
		{
			sendButton.html('Aguarde...');
			document.curriculum.submit();
		}
	}


	/*
		Abre um iframe para exibir conteúdo
		-----------------------------------------------------------------------------------------------------------------
	*/

	function iFrameOpen (src, width, height)
	{
		if (src)
		{
			if (!width) 	width = 640;
			if (!height) 	height = 480;
			$('#iFrameSrc').attr('width', width);
			$('#iFrameSrc').attr('height', height);
			$('#iFrameSrc').attr('src', src);
			$.blockUI
			({ 
				message: $('#iFrameHolder'), 
				css: 
				{
					width				: width + 'px',
					height				: height + 'px',
					marginLeft			: '-' + (width / 2) + 'px',
					marginTop			: '-' + (height / 2) + 'px',
					left				: '50%',
					top					: '50%',
					border				: '10px solid #c0c0c0',
					padding				: '0px'
				},
				overlayCSS				:
				{ 
					backgroundColor		: '#000000', 
					backgroundImage		: 'url(' + img + 'blockui.png)',
					backgroundPosition	: 'top center',
					backgroundRepeat	: 'no-repeat',
					opacity				: 0.9 
				}
			});	
		}
		else
		{
			alert('Erro: Fonte de iFrame indefinida!');	
		}
	}

	/*
		Abre um vídeo em janela
		-----------------------------------------------------------------------------------------------------------------
	*/

	function watchVideo (div)
	{
		var divHolder = "#" + div;
		if (div)
		{
			$.blockUI
			({ 
				message: $(divHolder), 
				css: 
				{
					width				: $(divHolder).width() + 'px',
					height				: $(divHolder).height() + 'px',
					marginLeft			: '-' + ($(divHolder).width() / 2) + 'px',
					marginTop			: '-' + ($(divHolder).height() / 2) + 'px',
					left				: '50%',
					top					: '50%',
					border				: '10px solid #c0c0c0',
					padding				: '0px'
				},
				overlayCSS				:
				{ 
					backgroundColor		: '#000000', 
					backgroundImage		: 'url(' + img + 'blockui.png)',
					backgroundPosition	: 'top center',
					backgroundRepeat	: 'no-repeat',
					opacity				: 0.9 
				}
			});			
		}
		else
		{
			alert('Ocorreu um erro ao abrir este v&iacute;deo. Tente mais tarde!');	
		}
	}
	

	/*
		Abre uma foto em janela
		-----------------------------------------------------------------------------------------------------------------
	*/

	function openPhoto (file)
	{
		if (file)
		{
			$('#fotoDivHTML').html('<a href="javascript:void(false)" onclick="$.unblockUI();"><img src="' + file + '" alt="" border="0" /></a>');
			$.blockUI
			({ 
				message: $('#fotoDiv'), 
				css: 
				{
					width				: $('#fotoDiv').width() + 'px',
					height				: $('#fotoDiv').height() + 'px',
					marginLeft			: '-' + ($('#fotoDiv').width() / 2) + 'px',
					marginTop			: '-' + ($('#fotoDiv').height() / 2) + 'px',
					left				: '50%',
					top					: '50%',
					border				: '10px solid #c0c0c0',
					padding				: '0px'
				},
				overlayCSS				:
				{ 
					backgroundColor		: '#000000', 
					backgroundImage		: 'url(' + img + 'blockui.png)',
					backgroundPosition	: 'top center',
					backgroundRepeat	: 'no-repeat',
					opacity				: 0.9 
				}
			});			
		}
		else
		{
			alert('Ocorreu um erro ao abrir esta foto. Tente mais tarde!');	
		}
	}
	