function validaCadastroSpl() {
	var msg = "";
	
	if(document.forms[0].nome.value == "") {
		msg = msg + "* Campo nome vazio\n";	
	}
	
	if(document.forms[0].login.value == "") {
		msg = msg + "* Campo Apelido vazio\n";
	}

	if(document.forms[0].login.length > 10 || document.forms[0].login.length < 4) {
		msg = msg + "* Campo Apelido deve ter menos que 10 caracteres e no mínimo 4\n";
	}
	
	if(document.forms[0].login.value.match(/W/)) {
		msg = msg + "* Campo Apelido possui caracteres inválidos\n";
	}

	if((document.forms[0].email.value != "") && (document.forms[0].emailConf.value != "")) {
		if(isEmail(document.forms[0].email.value)) {
			if(document.forms[0].email.value != document.forms[0].emailConf.value != "") {
				msg = msg + "* Campo e-mails diferentes\n";		
			}
		} else {
			msg = msg + "* Campo e-mail inválido\n";	
		}
	} else {
		msg = msg + "* Campo e-mail vazio\n";
	}
	
	if(document.forms[0].senha.value != "") {
		if(document.forms[0].senha.value == document.forms[0].senhaConf.value) {
			var senhaCerta = document.forms[0].senha.value;
			if(senhaCerta.length < 6) {
				msg = msg + "* Sua senha tem que conter no mínimo 6(seis) dígitos\n";
			}
		} else {
			msg = msg + "* Campos senhas e confirmação de senha diferentes\n";		
		}
	} else {
		msg = msg + "* Campo senha vazio\n";
	}
	
	if(!validaCheck("sexo")) {
		msg = msg + "* Campo Sou vazio\n";
	}
	
	if(document.forms[0].dataNascDia.value == "") {
		msg = msg + "* Campo DIA da Data de Nascimento vazio\n";
	}
	
	if(document.forms[0].dataNascMes.value == "") {
		msg = msg + "* Campo MÊS da Data de Nascimento vazio\n";
	}
	
	if(document.forms[0].dataNascAno.value == "") {
		msg = msg + "* Campo ANO da Data de Nascimento vazio\n";
	}
	
	if(document.forms[0].pais.value == "") {
		msg = msg + "* Campo País vazio\n";
	}
	
	if(document.forms[0].estado.value == "") {
		msg = msg + "* Campo Estado vazio\n";
	}
	
	if(document.forms[0].cidade.value == "") {
		msg = msg + "* Campo Cidade vazio\n";
	}
	
	if(!validaCheck("sexoParceiro")) {
		msg = msg + "* Campo Procuro vazio\n";
	}
	
	if(document.forms[0].opcaoSex.value == "") {
		msg = msg + "* Campo Para relação vazio\n";
	}

	if( !validaCheck("tipoRel") ) {
		msg = msg + "* Campo Desejo relacionamento vazio\n";
	}
	
	if((document.forms[0].idadeEntreIni.value == "") || (document.forms[0].idadeEntreFim.value == "")){
		msg = msg + "* Campo Idade vazio\n";
	}
	
	if( ((document.forms[0].idadeEntreIni.value) * 1) > ((document.forms[0].idadeEntreFim.value) * 1) ){
		msg = msg + "* Idade Final menor que a inicial\n";
	}
	
	if(!document.forms[0].termos.checked) {
		msg = msg + "* É necessário marcar o Termo de Acordo de Utilização do Querovocê\n";
	}

	if(msg == "") {		
		if(verificaAge(document.frCadUsuario, "cad")) {document.forms[0].submit();}		
	} else {		
		alert(msg);	
	}
}

function confirmaMinhaConta() {
	
	var msg = "";
	
	if(document.forms[0].nome.value == "") msg = msg + "* Campo nome vazio\n";
	
	if(document.forms[0].pais.value == 0 || document.forms[0].pais.value == "") msg = msg + "* Campo País vazio\n";
	
	if(document.forms[0].estado.value == 0 || document.forms[0].estado.value == "") msg = msg + "* Campo Estado vazio\n";
	
	if(document.forms[0].cidade.value == "" || document.forms[0].cidade.value == 0) msg = msg + "* Campo Cidade vazio\n";
	
	if(document.forms[0].trocaSenha.value == 1)
		if (document.forms[0].senhaNova.value != document.forms[0].senhaRepete.value != "")
			msg = msg + "* As senhas não estão iguais\n";
		
	if(msg == "")
		document.forms[0].submit();
	else
		alert(msg);	
	
}

function abreAcordo() {

window.open("contrato.html","contrato","width=600,toolbar=no,menubar=no,resizable=no,scrollbars=yes");

}

function abreJan(pag,w,h,scrl,idUsu) {
	window.open(pag,"jan"+idUsu,"toolbar=no,menubar=no,width="+w+",height="+h+",resizable=no,scrollbars="+scrl);	
}

function abreJanelaW(pag,janela,w,y) {
	window.open(pag,janela,"toolbar=no,menubar=no,width="+w+",height="+y+",resizable=no,scrollbars=yes");	
}

function enviaConviteSpl() {
	var msg = "";
	
	if(document.forms[0].nome.value == "") {
		msg = msg + "* Campo nome vazio\n";	
	}
	
	if(document.forms[0].email.value != "") {
		if(!isEmail(document.forms[0].email.value)) {
			msg = msg + "* Campo e-mail inválido\n";
		}			
	} else {
		msg = msg + "* Campo e-mail vazio\n";
	}
	
	if(msg != "") {
		alert(msg);	
	} else {
		document.forms[0].submit();	
	}
}
function enviaConviteNormal() {
	var valor = document.forms[0].email.value;
	var erro = "";
	
	if(valor == "") {		
		erro = "* Campo de e-mails vazio;";		
	} else {		
		var arrConvite = valor.split(",");			
		
		var qb = "";		
		for(i=0;i<arrConvite.length;i++) {
			if(arrConvite[i] != "") {	
				var arrEmails = arrConvite[i].split("-");
				toNome = arrEmails[0];
				toEmail = trim(arrEmails[1]);
				
				if(!isEmail(toEmail)) {
					erro = erro + qb + "E-mail errado ("+ toEmail +")";	
					qb = "\n";
				}
			}		
		}
		
	}
	
	if(erro == "") {
		document.forms[0].submit();	
	} else {
		alert(erro);
	}
	
}

function isEmail(str) {
	return ( /^['_a-z0-9-]+(\.['_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,4}))$/.exec( str.toLowerCase() ) ? true : false );
}

function trim(str) {
	s = str.replace(/^(\s)*/, '');
	s = s.replace(/(\s)*$/, '');
	return s;
}


function desabilitaCampo() {
	document.getElementById("emailConf").setAttribute("autocomplete","off");
}

function validaCheck(nome) {
	var checa = document.forms[0][nome];
	ver = false;

	for(i=0;i<checa.length;i++) 
	{
		if(checa[i].checked) {
			ver = true;
		}
	}
	return ver;
}

function disableCtrlKeyCombination(e)
{
        //list all CTRL + key combinations you want to disable
        var forbiddenKeys = 'v';
        var key;
        var isCtrl;

        if(window.event) {
                key = window.event.keyCode;     //IE
                if(window.event.ctrlKey)
                        isCtrl = true;
                else
                        isCtrl = false;
        } else {
                key = e.which;     //firefox
                if(e.ctrlKey)
                        isCtrl = true;
                else
                        isCtrl = false;
        }

        //if ctrl is pressed check if other key is in forbidenKeys array
        if(isCtrl) {    //case-insensitive comparation
				if(forbiddenKeys.toLowerCase() == String.fromCharCode(key).toLowerCase()) {
					alert('Não é possível colar nada neste campo, é necessário que digite seu e-mail');
					return false;
				}
        }
        return true;
}

function cadPerfil(passo){
	document.forms[0].passo.value = passo;
	document.forms[0].submit();
}

function abreOpc(opc){

	if(opc == 0 || opc == "" ) {
		document.getElementById("opcaoFilho").className = "off";
	} else if(opc == 1) {
		document.getElementById("opcaoFilho").className = "on";
	}
		
}

function abreSenha(opc,id){

	if(opc == 0 || opc == "" ) {
		document.getElementById(id).className = "off";
	} else if(opc == 1) {
		document.getElementById(id).className = "on";
	}
		
}

function select_innerHTML(objeto,innerHTML){

    objeto.innerHTML = ""
    var selTemp = document.createElement("micoxselect")
    var opt;
    selTemp.id="micoxselect1"
    document.body.appendChild(selTemp)
    selTemp = document.getElementById("micoxselect1")
    selTemp.style.display="none"
    if(innerHTML.toLowerCase().indexOf("<option")<0){//se não é option eu converto
        innerHTML = "<option>" + innerHTML + "</option>"
    }
    innerHTML = innerHTML.replace(/<option/g,"<span").replace(/<\/option/g,"</span")
    selTemp.innerHTML = innerHTML
    for(var i=0;i<selTemp.childNodes.length;i++){
        if(selTemp.childNodes[i].tagName){
            opt = document.createElement("OPTION")
            for(var j=0;j<selTemp.childNodes[i].attributes.length;j++){
                opt.setAttributeNode(selTemp.childNodes[i].attributes[j].cloneNode(true))
            }
            opt.value = selTemp.childNodes[i].getAttribute("value")
            opt.text = selTemp.childNodes[i].innerHTML
            if(document.all){ //IEca
                objeto.add(opt)
            }else{
                objeto.appendChild(opt)
            }                    
        }    
    }
    document.body.removeChild(selTemp)
    selTemp = null
}

function mudaIdadeFim() {
	idadeIni = document.forms[0].idadeEntreIni.value;
	idadeFim = document.forms[0].idadeEntreFim.value;
	
	inner = "<option value=''>--</option>\n";
	
	selecionado = "";	
	for(i = idadeIni; i <= 100; i++) { 	
		if ( i == idadeFim ) { 		
			selecionado = "selected=\"selected\"";	
		}	
		inner += "<option value='" + i + "' " + selecionado +  ">" + i + "</option>\n";		
		selecionado = "";
	}	
	select_innerHTML(document.getElementById("idadeEntreFim"),inner);
}

function mudaPesoFim() {
	pesoIni = document.forms[0].pesoIni.value;
	pesoFim = document.forms[0].pesoFim.value;
	
	inner = "<option value=''>--</option>\n";
	
	selecionado = "";	
	for(i = pesoIni; i <= 150; i++) { 	
		if ( i == pesoFim ) { 		
			selecionado = "selected=\"selected\"";	
		}	
		inner += "<option value='" + i + "' " + selecionado +  ">" + i + "</option>\n";		
		selecionado = "";
	}	
	select_innerHTML(document.getElementById("pesoEntreFim"),inner);
}

function selTodosAssunto( valor ) {

	form = document.forms[0];

	for (i = 0; i < form.length; i++) {
	
		if ( form[i].value == valor)
			form[i].checked = true;
		
		
	}

	
}

function unselectAll() {

	form = document.forms[0];

	for (i = 0; i < form.length; i++) {
			form[i].checked = false;
	}

	
}


function goToIndex() {
	window.location = "index.php";
}
function goToRefer() {
	window.location = document.referrer;
}

function goTo(pag) {
window.location = pag;
}

function viewEmail(usu,email) {
	window.location = "view-email.php?uid="+usu+"&email="+email;
}

function respostaEmail(usu,email) {
	window.location = "form_email.php?perfil="+usu+"&email="+email;
}

function deletaEmail() {
	
	document.getElementById('voltar').checked = false;
	document.getElementById('seleciona').checked = false;
	document.getElementById('apagar').checked = false;
	
	var form = document.forms[0];
	var count = 0;
	
	for (i = 0; i < form.length; i++) {	
		if (form[i].checked) count++;
	}
		
	if (count < 1) alert("Nenhum e-mail selecionado.");
	else form.submit();

}

function deletaBusca() {
	

	document.getElementById("voltar").checked = false;
	document.getElementById("seleciona").checked = false;
	document.getElementById("apagar").checked = false;
	var form = document.forms[0];
	var count = 0;
	for (i = 0; i < form.length; i++)		
		if (form[i].checked) count++;
	if (count < 1) alert("Nenhuma busca selecionada.");
	else form.submit();


}

function validaEmail() {
	
	var msg = "";

	if( trim(document.forms[0].assunto.value) == "") {
		msg = msg + "* O campo assunto deve ser preenchido\n";	
	}
	
	if( trim(document.forms[0].mensagem.value) == "") {
		msg = msg + "* O campo mensagem deve ser preenchido\n";	
	}
	
	if(msg == "") {
		document.forms[0].submit();
	} else {
		alert(msg);	
	}
	
}

function habilitaPerso() {
	
	if (document.forms[0].salva.checked)
		document.forms[0].nomeBusca.disabled = false;
	else
		document.forms[0].nomeBusca.disabled = true;
	
}

function verificaSalva() {

	if (!document.forms[0].salva.checked)
		document.forms[0].submit();
	else if  (document.forms[0].salva.checked && document.forms[0].nomeBusca.value != "")
		document.forms[0].submit();
	else
		alert("* Preencha o nome da busca a ser salva.");
}

function abreFoto(foto, x, y) {
	window.open("view_foto.php?foto="+foto, "galeria", "width="+ x +",height="+ y +",menubar=no,location=no,resizable=no,scrollbars=yes,status=no");
}

function validaDelete() {
		
	confirmacao = confirm("Tem certeza que quer deletar estes contatos?");
		
	if(confirmacao) document.frmDelContatos.submit();
}

function verificaVideo() {
	file = document.forms[0].video.value;
	arrFile = file.split(".");
	extensao = arrFile[ arrFile.length - 1 ].toLowerCase();
	if ( extensao.match("avi|mpg|mpeg|wmv") )
		document.forms[0].submit();
	else
		alert("Selecione um vídeo válido.");
}

function validaDenuncia() {
	msg = "";
	count = 0;
	
	for (i=0;i<document.frmDenuncia.denuncia.length;i++){
       if (document.frmDenuncia.denuncia[i].checked)
         count++;
    } 
	
	if ( count == 0) msg = msg +  "* Selecione o tipo de denúncia.\n";
	if (document.frmDenuncia.msg.value == "") msg = msg + "* Digite o ocorrido.";

	if (msg == "")
		document.frmDenuncia.submit();
	else
		alert(msg);

}

function limparDenuncia() {
	for (i=0;i<document.frmDenuncia.denuncia.length;i++)
      document.frmDenuncia.denuncia[i].checked = false; 
	document.frmDenuncia.msg.value = "";
}

function validaAnuncio() {

	msg = "";
	if (document.frmAnuncio.nome.value == "") msg = msg +  "* Informe seu nome.\n";
	if (document.frmAnuncio.empresa.value == "") msg = msg +  "* Informe o nome de sua empresa.\n";
	if (document.frmAnuncio.email.value == "") msg = msg +  "* Informe um e-mail.\n";
		else if (!isEmail(document.frmAnuncio.email.value)) msg = msg +  "* Informe um e-mail válido.\n";
	if (document.frmAnuncio.comentario.value == "") msg = msg +  "* Faça um comentário.\n";
	if (msg == "")
		document.frmAnuncio.submit();
	else
		alert(msg);
}

function validaFaleConosco() {

	msg = "";
	if (document.frmAnuncio.nome.value == "") msg = msg +  "* Informe seu nome.\n";
	if (document.frmAnuncio.email.value == "") msg = msg +  "* Informe um e-mail.\n";
		else if (!isEmail(document.frmAnuncio.email.value)) msg = msg +  "* Informe um e-mail válido.\n";
	if (document.frmAnuncio.comentario.value == "") msg = msg +  "* Faça um comentário.\n";
	if (msg == "")
		document.frmAnuncio.submit();
	else
		alert(msg);
}


function verificaWMP() {

	var fHasWMP = navigator.mimeTypes 
              && navigator.mimeTypes["application/x-mplayer2"]
              && navigator.mimeTypes["application/x-mplayer2"].enabledPlugin;
	if( fHasWMP )
		return true;
	else 
		return false;
	
}

function submitDissertativo() {
	
	var form = document.forms[0];

	for (i = 0; i < form.length; i++) {
		if (form[i].disabled) form[i].value = "";
	}
	
	form.submit();
	
}

		$(document).ready(function() {
			$(".lsNavegacao .submenu").hover(function() {
				$("ul", this).slideDown("fast");
			}, function() {
				$("ul",this).slideUp("fast");
			});

			  $('a[href*=#]:not([href=#])').click(function() {
				if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
				&& location.hostname == this.hostname) {
				  var $target = $(this.hash);
				  $target = $target.length && $target 
				  || $('[name=' + this.hash.slice(1) +']');
				  if ($target.length) {
					var targetOffset = $target.offset().top;
					$('html,body')
					.animate({scrollTop: targetOffset}, 1000);
				   return false;
				  }
				}
			  });

			  //$("input[@type*=checkbox]").css("width","15px !important");
		});



/*
 * jQuery ifixpng plugin
 * (previously known as pngfix)
 * Version 2.0  (04/11/2007)
 * @requires jQuery v1.1.3 or above
 *
 * Examples at: http://jquery.khurshid.com
 * Copyright (c) 2007 Kush M.
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
 
 /**
  *
  * @example
  *
  * optional if location of pixel.gif if different to default which is images/pixel.gif
  * $.ifixpng('media/pixel.gif');
  *
  * $('img[@src$=.png], #panel').ifixpng();
  *
  * @apply hack to all png images and #panel which icluded png img in its css
  *
  * @name ifixpng
  * @type jQuery
  * @cat Plugins/Image
  * @return jQuery
  * @author jQuery Community
  */
 
(function($) {

	/**
	 * helper variables and function
	 */
	$.ifixpng = function(customPixel) {
		$.ifixpng.pixel = customPixel;
	};
	
	$.ifixpng.getPixel = function() {
		return $.ifixpng.pixel || 'imagens/pixel.gif';
	};
	
	var hack = {
		ltie7  : $.browser.msie && $.browser.version < 7,
		filter : function(src) {
			return "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='"+src+"')";
		}
	};
	
	/**
	 * Applies ie png hack to selected dom elements
	 *
	 * $('img[@src$=.png]').ifixpng();
	 * @desc apply hack to all images with png extensions
	 *
	 * $('#panel, img[@src$=.png]').ifixpng();
	 * @desc apply hack to element #panel and all images with png extensions
	 *
	 * @name ifixpng
	 */
	 
	$.fn.ifixpng = hack.ltie7 ? function() {
    	return this.each(function() {
			var $$ = $(this);
			var base = $('base').attr('href'); // need to use this in case you are using rewriting urls
			if ($$.is('img') || $$.is('input')) { // hack image tags present in dom
				if ($$.attr('src')) {
					if ($$.attr('src').match(/.*\.png([?].*)?$/i)) { // make sure it is png image
						// use source tag value if set 
						var source = (base && $$.attr('src').substring(0,1)!='/') ? base + $$.attr('src') : $$.attr('src');
						// apply filter
						$$.css({filter:hack.filter(source), width:$$.width(), height:$$.height()})
						  .attr({src:$.ifixpng.getPixel()})
						  .positionFix();
					}
				}
			} else { // hack png css properties present inside css
				var image = $$.css('backgroundImage');
				if (image.match(/^url\(["']?(.*\.png([?].*)?)["']?\)$/i)) {
					image = RegExp.$1;
					$$.css({backgroundImage:'none', filter:hack.filter(image)})
					  .children().children().positionFix();
				}
			}
		});
	} : function() { return this; };
	
	/**
	 * Removes any png hack that may have been applied previously
	 *
	 * $('img[@src$=.png]').iunfixpng();
	 * @desc revert hack on all images with png extensions
	 *
	 * $('#panel, img[@src$=.png]').iunfixpng();
	 * @desc revert hack on element #panel and all images with png extensions
	 *
	 * @name iunfixpng
	 */
	 
	$.fn.iunfixpng = hack.ltie7 ? function() {
    	return this.each(function() {
			var $$ = $(this);
			var src = $$.css('filter');
			if (src.match(/src=["']?(.*\.png([?].*)?)["']?/i)) { // get img source from filter
				src = RegExp.$1;
				if ($$.is('img') || $$.is('input')) {
					$$.attr({src:src}).css({filter:''});
				} else {
					$$.css({filter:'', background:'url('+src+')'});
				}
			}
		});
	} : function() { return this; };
	
	/**
	 * positions selected item relatively
	 */
	 
	$.fn.positionFix = function() {
		return this.each(function() {
			var $$ = $(this);
			var position = $$.css('position');
			if (position != 'absolute' && position != 'relative') {
				$$.css({position:'relative'});
			}
		});
	};

})(jQuery);

function desabilita(id, valor) {
	
	document.getElementById(id).disabled = valor;

}

function limitaCampo(campo, limite) {
	
	var txt = campo;
	
	var texto = txt.value;
	
	var qntDigitada = texto.length;
	
	if(qntDigitada > limite) texto = texto.substr(0, limite);
	
	txt.value = texto;
	
} // fim da função

function atualizaMsgComentario(campo, limite, id) {
	
	var qntDigitada = campo.value.length;
	
	document.getElementById(id).innerHTML = (qntDigitada == 0) ? limite : (limite - qntDigitada);
	
} //


function verificaAge(form, qual){
	
var msg18 = qual == "cad" ? "Você ainda não tem 18 anos.\nAguarde mais um pouco para se cadastrar em nosso site" : "Idade não permitida. Menor de 18 anos";

var data = new Date();
	
	if(!document.all) var ano = (data.getYear() + 1900);
	else var ano = data.getYear();
	
	var anoUser = form.dataNascAno.value;
	
	if((ano - anoUser) < 19){
		
		var mes = data.getMonth();
		var mesUser = form.dataNascMes.value;
		
		if((mes+1) < mesUser){
			alert(msg18);
				return false;
			
		}else if((mes+1) == mesUser){
			var dia = data.getDate();
			var diaUser = form.dataNascDia.value;
			if((dia) < diaUser){
				
				alert(msg18);
				return false;
			}
		}
	}
	
	return true;
	
	
	}