/* FUNÇÃO PARA CRIAR LINK PROMOCIONAL ESCONDIDO
 * NESSA FUNÇÃO É CRIADO UM NOVO ELEMENTO HTML DENTRO DA DIV GERAL, PASNDO O MOUSE NESSE LINK 
 * ABRE-SE UM FLASH TRANSPARENTE COM UM LINK PARA CADASTRO E ENTREGA DE BRINDE
 */
$(document).ready(function() {
	var conteudo = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="250" HEIGHT="250"  ALIGN=""><PARAM NAME=movie VALUE="../imagens/hidden.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=transparent> <PARAM NAME=bgcolor VALUE=#000000> <EMBED src="../imagens/hidden.swf" quality=high wmode=transparent bgcolor=#000000  WIDTH="250" HEIGHT="250" NAME="hidden" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';       
	conteudo += '<div id="janela_promo" class="jqmNotice" style="position:absolute;height:251px;width:248px;top:0px;left:0px;">'+
    '<div class="jqmnTitle jqDrag">'+
      '<div>Parabéns</div>'+
      '<div class="jqmClose">&nbsp;</div>'+
    '</div>'+
	'<div class="jqmnContent">'+
	  '<form class="validate"  style="width:205px;margin-top:15px;" method="post">'+
	  '<p>Preenchao formulário abaixo para ganhar o seu brinde</>'+
		  '<div class="campo2">'+
		  		'<label for="de_nome">Nome:</label>&nbsp;&nbsp;'+
				'<input type="text" name="nome" size="23" id="nome"/>'+
		  '</div>'+
		  '<div class="campo2">'+
				'<label for="de_email">Email:</label>&nbsp;&nbsp;'+
				'<input type="text" name="email" size="23" id="email" />'+
		  '</div>'+
		  '<div class="campo2">'+
				'<label for="CPF">CPF:</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
				'<input type="text" name="CPF"  size="23" id="CPF"/>'+
		  '</div>'+
		  '<div class="campo2">'+
		  		'<div id="loading3">&nbsp;</div>'+
		  		'<div id="resposta3">&nbsp;</div>'+
				'<input id="submitPromo" type="button" class="bt_enviar2" value="Enviar" />'+
				
		  '</div>'+
	   '</form>'+
    '</div>'+
	'<div class="jqResize">&nbsp;</div>'+
	'</div>';
	
	$("#geral").append("<div id=hidden>"+conteudo+"</div>");	
	var top = Math.random() * 700 ;
	var left = Math.random() * 700;
	
	$('#hidden').css("left",left);
	$('#hidden').css("top",top);
	$('#hidden').css("z-index","10");
	
});

/** **********************FUNÇÃO PARA ENVIO DE DADOS PARA FORMULARIO DE PROMOÇÃO DE LINK ESCONDIDO***************/
$(document).ready(function() {
	$("#submitPromo").click(function() {
		$().ajaxStart(function() { 
			$('#loading3').show();
			$('#resposta3').html("Por favor aguarde...");
		 });
		$().ajaxStop(function() { 
			$('#loading3').hide(); 
		});
		var nome  = $("#nome").val();
		var email = $("#email").val();
		var CPF   = $("#CPF").val();
		if(nome == "")
		{
			$("#resposta3").html("Preencha corretamente o nome");
			return false;
		}
		if(!checkMail(email))
		{
			$("#resposta3").html("Email inválido");
			return false;
		}
		if(!validacpf(CPF))
		{
			$("#resposta3").html("CPF inválido");
			return false;
		}
		$.post('../includes/promo.php',
			{ nome: nome, email: email, CPF: CPF },
			function(data, textStatus) {
				$("#resposta3").html(data);	
			});
			return false;
		
		});
});	
/******************************************************************************/
