function validaEmail(email)
{
	return (/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(email));
}

function flash(movie, flashvars, width, height, retorna)
{
	swfid = movie.split("/");
	swfid = swfid[swfid.length-1].replace(".swf", "");
	strSWF= '<object id="' + swfid + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + width + '" height="' + height + '">'+
			'<param name="movie" value="' + movie + '">'+
			'<param name="quality" value="high">'+
			'<param name="wmode" value="transparent">'+
			'<param name="FlashVars" value="' + flashvars + '">'+
			'<embed name="' + swfid + '" src="' + movie + '" width="' + width + '" height="' + height + '" flashvars="' + flashvars + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>'+
			'</object>';
	if(!retorna) this.document.write(strSWF);
	else return(strSWF);
}

function NumbersOnly(myfield, e, dec)
{
	var key;
	var keychar;

	if (window.event)
		key = window.event.keyCode;
	else if (e)
		key = e.which;
	else
		return true;
	
	keychar = String.fromCharCode(key);

	// control keys
	if ((key==null) || (key==0) || (key==8) || (key==9) || (key==27) )
		return true;

	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
		return true;

	// decimal point jump
	else if (dec && (keychar == "."))
	{
		myfield.form.elements[dec].focus();
		return false;
	}
	else
		return false;
}


function TrocaFoto(foto_id)
{
	img_url = "../foto.php?foto_id=" + foto_id + "&width=399&height=330";
		
	$("#foto_grande").fadeOut("slow", function()
			{
			  var img = new Image();
			  
			  $(img)
				.load(function () 
				{
				  $(this).hide();
				
				  $('#foto_grande').attr('src', img_url);
				  $('#foto_grande').fadeIn('slow');
				  
				})
				.attr('src', img_url);			
			}); 	
}

function AbreShadowbox(url, titulo, player, w, h)
{
    Shadowbox.open({
        content: url,
        player:  player,
        title:   titulo,
        width:   w, 
        height:  h
    });
}

function ShowCepPopup(){
	window.open('http://www.correios.com.br/servicos/cep/cep_default.cfm','ShowCep','location=no,resize=no, width=730,height=400,left=18,top=18,maximized=0,scrollbars=1');
}

function show(obj) 
{
	no = obj.options[obj.selectedIndex].value;
	count = obj.options.length;
	for(i=1;i<count;i++)
	{
		document.getElementById('Pergunta'+i).style.display = 'none';
	}
	if(no>0)
	{
		document.getElementById('Pergunta'+no).style.display = 'block';
	}
}

function slideDown(div)
{
	if($("#" + div).css("display")=="none") 
	{
		$("#" + div).slideDown("normal");
	} 
	else 
	{
		$("#" + div).slideUp("normal");
	}
}


$(document).ready(function() 
{
	// ajusta a altura do conteudo
	try
	{
		if($('#div_conteudo_coluna_02').height() < 520)
		{
			$('#div_conteudo_coluna_02').css("height", "520px");
		}
	}
	catch(e){}

	// configura o ajax do cadastro de mailing
	$('#cadastro_mailing').submit(function() 
	{ 
		$(this).ajaxSubmit({ success: function(responseText, statusText){ alert(responseText); } }); 

		return false; 
	});
	$('#mailing_nome').focus(function()
	{
		if($(this).val()=='nome') $(this).val('');
	})
	$('#mailing_nome').blur(function()
	{
		if($(this).val()=='') $(this).val('nome');
	})	
	$('#mailing_email').focus(function()
	{
		if($(this).val()=='e-mail') $(this).val('');
	})
	$('#mailing_email').blur(function()
	{
		if($(this).val()=='') $(this).val('e-mail');
	})
	
}); 


