﻿// JavaScript Document

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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];}
}

var contando

function zeramenu01(){
	document.getElementById('menuKissFM').style.display='none';
	document.getElementById('menuProgramas').style.display='none';
}
function kill() {
	contando=setTimeout("zeramenu01()", 3000);	
}
function keepAlive() {
	clearTimeout(contando);	
}
function mostra(submenu){
	if(submenu == 'KissFM'){
		document.getElementById('menuKissFM').style.display='block';
		document.getElementById('menuProgramas').style.display='none';
	}
	if(submenu == 'Programas'){
		document.getElementById('menuKissFM').style.display='none';
		document.getElementById('menuProgramas').style.display='block';
	}
}

// **************************************************
// * CALENDARIO										*
// * Autor : Peter M Jordan - uranking@uranking.com *
// * página: www.uranking.com                       *
// **************************************************

// construindo o calendário
function popdate(obj,div,tam,ddd)
{
    if (ddd) 
    {
        day = ""
        mmonth = ""
        ano = ""
        c = 1
        char = ""
        for (s=0;s<parseInt(ddd.length);s++)
        {
            char = ddd.substr(s,1)
            if (char == "/") 
            {
                c++; 
                s++; 
                char = ddd.substr(s,1);
            }
            if (c==1) day    += char
            if (c==2) mmonth += char
            if (c==3) ano    += char
        }
        ddd = mmonth + "/" + day + "/" + ano
    }
  
    if(!ddd) {today = new Date()} else {today = new Date(ddd)}
    date_Form = eval (obj)
    if (date_Form.value == "") { date_Form = new Date()} else {date_Form = new Date(date_Form.value)}
  
    ano = today.getFullYear();
    mmonth = today.getMonth ();
    day = today.toString ().substr (8,2)
  
    umonth = new Array ("Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro")
    days_Feb = (!(ano % 4) ? 29 : 28)
    days = new Array (31, days_Feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)

    if ((mmonth < 0) || (mmonth > 11))  alert(mmonth)
    if ((mmonth - 1) == -1) {month_prior = 11; year_prior = ano - 1} else {month_prior = mmonth - 1; year_prior = ano}
    if ((mmonth + 1) == 12) {month_next  = 0;  year_next  = ano + 1} else {month_next  = mmonth + 1; year_next  = ano}
    txt  = "<table bgcolor='#efefff' style='border:solid #330099; border-width:2' cellspacing='0' cellpadding='3' border='0' width='"+tam+"' height='"+tam*1.1 +"' class='calendario'>"
    txt += "<tr bgcolor='#FFFFFF'><td colspan='7' align='center'><table border='0' cellpadding='0' width='100%' bgcolor='#FFFFFF' class='calendario'><tr>"
    txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+((mmonth+1).toString() +"/01/"+(ano-1).toString())+"') class='Cabecalho_Calendario' title='Ano Anterior'><<</a></td>"
    txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+( "01/" + (month_prior+1).toString() + "/" + year_prior.toString())+"') class='Cabecalho_Calendario' title='Mês Anterior'><</a></td>"
    txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+( "01/" + (month_next+1).toString()  + "/" + year_next.toString())+"') class='Cabecalho_Calendario' title='Próximo Mês'>></a></td>"
    txt += "<td width=20% align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+((mmonth+1).toString() +"/01/"+(ano+1).toString())+"') class='Cabecalho_Calendario' title='Próximo Ano'>>></a></td>"
    txt += "<td width=20% align=right><a href=javascript:force_close('"+div+"') class='Cabecalho_Calendario' title='Fechar Calendário'><b>X</b></a></td></tr></table></td></tr>"
    txt += "<tr><td colspan='7' align='right' bgcolor='#ccccff' class='mes'><a href=javascript:pop_year('"+obj+"','"+div+"','"+tam+"','" + (mmonth+1) + "') class='mes'>" + ano.toString() + "</a>"
    txt += " <a href=javascript:pop_month('"+obj+"','"+div+"','"+tam+"','" + ano + "') class='mes'>" + umonth[mmonth] + "</a> <div id='popd' style='position:absolute'></div></td></tr>"
    txt += "<tr bgcolor='#330099'><td width='14%' class='dia' align=center><b>Dom</b></td><td width='14%' class='dia' align=center><b>Seg</b></td><td width='14%' class='dia' align=center><b>Ter</b></td><td width='14%' class='dia' align=center><b>Qua</b></td><td width='14%' class='dia' align=center><b>Qui</b></td><td width='14%' class='dia' align=center><b>Sex<b></td><td width='14%' class='dia' align=center><b>Sab</b></td></tr>"
    today1 = new Date((mmonth+1).toString() +"/01/"+ano.toString());
    diainicio = today1.getDay () + 1;
    week = d = 1
    start = false;
    for (n=1;n<= 42;n++) 
    {
        if (week == 1)  txt += "<tr bgcolor='#efefff' align=center>"
        if (week==diainicio) {start = true}
        if (d > days[mmonth]) {start=false}
        if (start) 
        {
            dat = new Date((mmonth+1).toString() + "/" + d + "/" + ano.toString())
            day_dat   = dat.toString().substr(0,10)
            day_today  = date_Form.toString().substr(0,10)
            year_dat  = dat.getFullYear ()
            year_today = date_Form.getFullYear ()
            colorcell = ((day_dat == day_today) && (year_dat == year_today) ? " bgcolor='#FFCC00' " : "" )
            txt += "<td"+colorcell+" style=\"border: 1px solid #efefff\" align=center onMouseOut=\"this.style.border='1px solid #efefff'\" onMouseOver=\"this.style.border='1px solid #5787B7'\" onClick=\"javascript:block('"+  d + "/" + (mmonth+1).toString() + "/" + ano.toString() +"','"+ obj +"','" + div +"')\" class='data' style=\"cursor: pointer\">"+ d.toString() + "</td>"
            d ++ 
        } 
        else 
        { 
            txt += "<td class='data' align=center> </td>"
        }
        week ++
        if (week == 8) 
        { 
            week = 1; txt += "</tr>"} 
        }
        txt += "</table>"
        div2 = eval (div)
        div2.innerHTML = txt 
}
  
// função para exibir a janela com os meses
function pop_month(obj, div, tam, ano)
{
  txt  = "<table bgcolor='#CCCCFF' border='0' width=80 class='calendario'>"
  for (n = 0; n < 12; n++) { txt += "<tr><td align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+("01/" + (n+1).toString() + "/" + ano.toString())+"')>" + umonth[n] +"</a></td></tr>" }
  txt += "</table>"
  popd.innerHTML = txt
}

// função para exibir a janela com os anos
function pop_year(obj, div, tam, umonth)
{
  txt  = "<table bgcolor='#CCCCFF' border='0' width=160 class='calendario'>"
  l = 1
  for (n=1991; n<2012; n++)
  {  if (l == 1) txt += "<tr>"
     txt += "<td align=center><a href=javascript:popdate('"+obj+"','"+div+"','"+tam+"','"+(umonth.toString () +"/01/" + n) +"')>" + n + "</a></td>"
     l++
     if (l == 4) 
        {txt += "</tr>"; l = 1 } 
  }
  txt += "</tr></table>"
  popd.innerHTML = txt 
}

// função para fechar o calendário
function force_close(div) 
    { 
	div2 = eval (div); div2.innerHTML = '';
	document.getElementById('hora').style.visibility='visible'
	}
    
// função para fechar o calendário e setar a data no campo de data associado
function block(data, obj, div)
{ 
    force_close (div)
    obj2 = eval(obj)
    obj2.value = data 
}

// FUNÇÃO CEP DO CADASTRO
function pegaCep () {
	if (document.getElementById('cep').value) {	document.getElementById('numero').focus(); }
	else { document.getElementById('cep').focus(); }
	ajax = ajaxInit();
	document.getElementById('caption_cep').innerHTML = "aguarde, pesquisando cep...";
	if (ajax) {
		ajax.open("POST", "busca-cep.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("cep="+ document.getElementById('cep').value + "-" + document.getElementById('cep2').value);
		ajax.onreadystatechange = function() {
			if (ajax.readyState == 4) {
				if (ajax.status == 200) {
					texto = ajax.responseText;
					texto = texto.replace(/\+/g," ");
					texto = unescape(texto);
					str = texto.split(';');
					document.forms.cadastro.endereco.value = texto;
					if (str[0]) { document.forms.cadastro.endereco.value = str[0]; }
					else { document.forms.cadastro.endereco.value = ''; }
					if (str[1]) { document.forms.cadastro.bairro.value = str[1]; }
					if (str[2]) { document.forms.cadastro.cidade.value = str[2]; }
					if (str[3]) { document.forms.cadastro.uf.value = str[3]; }
					document.getElementById('caption_cep').innerHTML = '';
				}
				else {
					alert(ajax.statusText);
				}
			}
		}
	}
}
// CADASTRO
function cadastra_completo () {
	ajax = ajaxInit();
	if (ajax) {
		ajax.open("POST", "cadastra-completo.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		dados = "nome="+ document.getElementById('nome').value;
		dados += "&cep="+ document.getElementById('cep').value;
		dados += "&cep2="+ document.getElementById('cep2').value;
		dados += "&endereco="+ escape(document.getElementById('endereco').value);
		dados += "&numero="+ document.getElementById('numero').value;
		dados += "&complemento="+ escape(document.getElementById('complemento').value);
		dados += "&bairro="+ escape(document.getElementById('bairro').value);
		dados += "&cidade="+ escape(document.getElementById('cidade').value);
		dados += "&uf="+ escape(document.getElementById('uf').value);
		dados += "&ddd="+ document.getElementById('ddd').value;
		dados += "&telefone="+ document.getElementById('telefone').value;
		dados += "&rg="+ document.getElementById('rg').value;
		dados += "&diaNasc="+ document.getElementById('diaNasc').value;
		dados += "&mesNasc="+ document.getElementById('mesNasc').value;
		dados += "&anoNasc="+ document.getElementById('anoNasc').value;
		if (document.getElementById('sms_1').checked && document.getElementById('sms_2').value && document.getElementById('sms_3').value) { dados += "&sms_1=1"; } else { dados += "&sms=0"; }
		dados += "&sms_2="+ document.getElementById('sms_2').value;
		dados += "&sms_3="+ document.getElementById('sms_3').value;
		if (document.getElementById('newsletter')) {
			dados += "&newsletter="+ document.getElementById('newsletter').value;
		}
		if (document.getElementById('email_cadastro')) {
			dados += "&email="+ document.getElementById('email_cadastro').value;
		}
		if (document.getElementById('senha_cadastro')) {
			dados += "&senha="+ document.getElementById('senha_cadastro').value;
		}
		if (document.getElementById('sexo').checked) { sexo = "M"; } else { sexo = "F"; }
		dados += "&sexo=" + sexo;
		dados += "&estadocivil=" + escape($("#estadocivil").val());
		dados += "&formacao=" + escape($("#formacao").val());
		dados += "&ondeouco="+ escape($("#cadastro_ondeouco").val());
		dados += "&qualidade="+ escape($("#cadastro_qualidade").val());
		dados += "&comoconheceu="+ escape($("#cadastro_comoconheceu").val());
		ajax.send(dados);
		document.getElementById('btn_cadastro').innerHTML = '<div style="text-align:center;margin-left:-100px"><br><img src="/images/loading01.gif"><br>Aguarde, processando cadastro...</div>';
		ajax.onreadystatechange = function() {
			if (ajax.readyState == 4) {
				if (ajax.status == 200) {
					texto = ajax.responseText;
					texto = texto.replace(/\+/g," ");
					texto = unescape(texto);
					if (texto == "ok") { location.href='/cadastro/cadastro-completo.php'; }
					else if (texto == "cadastrado") { location.href='/cadastro/obrigado.php'; }
					else { show_error_msg (texto, '#cadastro_warning', 'error'); document.getElementById('btn_cadastro').innerHTML = '<input type="submit" id="login_btn" class="botao" value="Concluir meu cadastro" onclick="javascript:void(cadastra_completo())" />'; }
				}
				else {
					show_error_msg (ajax.statusText, '#cadastro_warning', 'error');
				}
			}
		}
	}
	return false;
}

// INICIA AJAX
function ajaxInit() {
	var req;
	try {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(e) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(ex) {
			try {
				req = new XMLHttpRequest();
			}
			catch(exc) {
				alert("Esse browser não tem recursos para uso do Ajax");
				req = null;
			}
		}
	}
	return req;
}

// VALIDA SOMENTE NÚMEROS
function onlyNumbers(type, evt) {
	var key_code = evt.keyCode  ? evt.keyCode  :
				   evt.charCode ? evt.charCode :
				   evt.which    ? evt.which    : void 0;
	if (key_code == 8  ||  key_code == 9  ||  key_code == 13  ||  key_code == 27)
	{
		return true;
	}
	else if ((key_code >= 35)  &&  (key_code <= 40))
	{
		return true
	}
	if (type == "rg") {
		if ((key_code != 120 && key_code != 88) && (key_code < 48 || key_code > 57)) return false;
		else return true;
	}
	else {
		if ((key_code >= 48)  &&  (key_code <= 57)) return true;
		else return false;
	}
}

// VALIDA FORMULÁRIO
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' precisa ser um e-mail válido.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' precisa conter um número.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- Preencha todos os campos obrigatórios.\n'; }
    } if (errors) alert('Não foi possível enviar o formulário:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

// VERIFICA REGULAMENTO PROMOÇÃO
function checkRegulamento () {
	if (document.getElementById('formPromoRegulamento').checked) {
		return true;
	}
	else {
		alert ("Para participar da promoção você deve concordar com o regulamento");
		return false;
	}
}
function valida_promocao (){
	var nome_form=arguments[0];
	for(var i=0;i<arguments.length;i++){
		if (arguments[i] == "regulamento") {
			if (!document.getElementById('formPromoRegulamento').checked) {
				alert ("Para participar da promoção você deve concordar com o regulamento");
				return false;
			}
		}
		if(document.getElementById(arguments[i]).value == ""){
			alert("Por favor, preencha o formulário corretamente.");
			document.getElementById(arguments[i]).focus();
			return false;
		}
	}
	return true;
}

function validaSenha () {
	if (document[arguments[0]][arguments[1]].value != "") {
		if (document[arguments[0]][arguments[1]].value != document[arguments[0]][arguments[2]].value) {
			alert("A confirmação de sua senha está incorreta");
			document[arguments[0]][arguments[1]].focus();
			return false;
		}
	}
}

function validar_contato () {
	if (document.forms.form2.depto.options[document.forms.form2.depto.selectedIndex].value && document.forms.form2.nome.value && document.forms.form2.email.value) { return true; }
	else { alert("Preencha o formulário corretamente"); return false; }
}

function validar(){
	for(var i=0;i<arguments.length;i++){
		if(document.getElementById(arguments[i]).value == ""){
			alert("Por favor, preencha o formulário corretamente.");
			document.getElementById(arguments[i]).focus();
			return false;
		}
	}
	return true;
}

// GALERIA DE FOTOS
var galeria_imagens = new Array();
function galeria_voltar (dir) {
	if (galeria_i > 0) {
		galeria_i--;
		galeria_abre_foto(galeria_i, dir);
	}
	galeria_atualiza_btn();
}
function galeria_proxima (dir) {
	if (galeria_i < (galeria_imagens.length - 1)) {
		galeria_i++;
		galeria_abre_foto(galeria_i, dir);
	}
	galeria_atualiza_btn();
}
function galeria_abre_foto (z, dir) {
	galeria_i = z;
	document.getElementById('foto_grande').src='/media/galeria/images/'+dir+'/'+galeria_imagens[galeria_i];
	var loader = new ImageLoader('/media/galeria/images/'+dir+'/'+galeria_imagens[galeria_i]);
	document.getElementById('galeria_loading').style.display='block';
	loader.loadEvent = function(url, image) {
		galeria_atualiza_btn();
		document.getElementById('galeria_loading').style.display='none';
	}
	loader.load();
}
function galeria_atualiza_btn () {
	if (galeria_i == 0) {
		document.getElementById('botao_anterior').src = '/images/bot_galeria01_off.jpg';
	}
	else { document.getElementById('botao_anterior').src = '/images/bot_galeria01.jpg'; }
	if (galeria_i == (galeria_imagens.length - 1)) {
		document.getElementById('botao_proxima').src = '/images/bot_galeria02_off.jpg';
	}
	else {
		document.getElementById('botao_proxima').src = '/images/bot_galeria02.jpg';
	}
	document.getElementById('permalink').value = permalinks+'/?foto='+galeria_i;
}
function galeria_envia_foto (dir) {
	location.href='enviar.php?foto='+galeria_imagens[galeria_i];
}

// VOTAÇÃO ARTISTAS
function artistas_avalia (n, x) {
	for (i = 1; i <= 5; i++) {
		var estrela = document.getElementById('estrela'+i);
		if (i > n) {
			estrela.setAttribute('class','estrela_off');
			estrela.setAttribute('className','estrela_off');
		}
		else {
			estrela.setAttribute('class','estrela_on');
			estrela.setAttribute('className','estrela_on');
		}
	}
	artistas_avaliacao = n;
}

function artistas_avalia_clear () {
	artistas_avalia(artistas_avaliacao_default);
}

function artistas_vota (id_artista) {
	ajax = ajaxInit();
	if (ajax) {
		ajax.open("POST", "votar.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("id="+id_artista+"&nota="+ artistas_avaliacao);
		ajax.onreadystatechange = function() {
			if (ajax.readyState == 4) {
				if (ajax.status == 200) {
					texto = ajax.responseText;
					texto = texto.replace(/\+/g," ");
					document.getElementById('avalia_stars').innerHTML = texto;
				}
				else {
					alert(ajax.statusText);
				}
			}
		}
	}
}

function max_text(txarea, total, status) {
	tam = txarea.value.length;
	str="";
	str=str+tam;
	document.getElementById(status).innerHTML = total - str;

	if (tam > total){
		aux = txarea.value;
		txarea.value = aux.substring(0,total);
		document.getElementById(status).innerHTML = 0
	}
}

function showResults () {
	ajax = ajaxInit();
	if (ajax) {
		ajax.open("POST", "/enquete/resultados.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("enqueteId="+document.forms.enquete.enqueteId.value);
		ajax.onreadystatechange = function() {
			if (ajax.readyState == 4) {
				if (ajax.status == 200) {
					texto = ajax.responseText;
					texto = texto.replace(/\+/g," ");
					texto = unescape(texto);
					document.getElementById('enquete_opcoes').innerHTML = texto;
				}
				else {
					alert(ajax.statusText);
				}
			}
		}
	}
}
function votaEnquete (opcao) {
	ajax = ajaxInit();
	if (ajax) {
		ajax.open("POST", "/enquete/votar.php", true);
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax.send("opcao="+opcao+"&enqueteId="+document.forms.enquete.enqueteId.value);
		ajax.onreadystatechange = function() {
			if (ajax.readyState == 4) {
				if (ajax.status == 200) {
					texto = ajax.responseText;
					texto = texto.replace(/\+/g," ");
					texto = unescape(texto);
					document.getElementById('enquete_opcoes').innerHTML = texto;
				}
				else {
					alert(ajax.statusText);
				}
			}
		}
	}
}

function validaEnquete () {
	var checkado = 0;
	for (i = 0; i < document.forms.enquete.opcaoEnquete.length; i++) {
		if (document.forms.enquete.opcaoEnquete[i].checked) {
			checkado = 1;
			opcao = document.forms.enquete.opcaoEnquete[i].value;
			break;
		}
	}
	if (checkado) { votaEnquete(opcao); }
	else { alert('Selecione uma opção.'); }
}

function ajaxInit() {
	var req;
	try {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(ex) {
			try {
				req = new XMLHttpRequest();
			} catch(exc) {
				alert("Esse browser não tem recursos para uso do Ajax");
				req = null;
			}
		}
	}
	return req;
}

$(document).ready(function(){ 
	$(document).pngFix();
	$("#login, #senha").defaultvalue("Seu email aqui", "senha");
	$('#combo_paginacao').change(function(){
		location.href = $(this).attr('uri')+"x="+$('#combo_paginacao').val();
	});
	$('.contato_form01').formValidation({
		alias			: 'name',
		required	: 'required',
		err_list	:	false,
		telefone: /^[0-9]{2,} [0-9]{8,}$/gi
	});
	$('#mycarousel').jcarousel({
        scroll: 1,
		easing: 'BounceEaseOut',
		auto: 10,
        animation: 450,
		wrap: 'both',
        initCallback: mycarousel_initCallback
    });
	$('#comentario_msg').keyup(function(){
 		limitChars('comentario_msg', 255, 'comentario_restantes');
 	});
	$('#cadastro').formValidation({
		alias			: 'name',
		required	: 'required',
		err_list	:	false,
		rg : /[0-9]+[0-9xy]+$/gi,
		telefone: /^[0-9]{2,} [0-9]{8,}$/gi,
		callback	: 'cadastra_completo'
	});
});
function limitChars(textid, limit, infodiv)
{
	var text = $('#'+textid).val();
	var textlength = text.length;
	if(textlength <= limit)
	{
		$('#' + infodiv).html((limit - textlength)+" ");
		return true;
	}
	else { $('#'+textid).val(text.substr(0,limit)); return false; }
}
jQuery.easing['BounceEaseOut'] = function(p, t, b, c, d) {
	if ((t/=d) < (1/2.75)) {
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)) {
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)) {
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
};
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
	
	jQuery('#mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};
function show_error_msg (msg, id, type) {
	$(id).html(msg);
	$(id).addClass(type);
	$(id).fadeIn("slow").click(function() { $(id).fadeOut("slow"); });
}