function DeletaLista(){
    msg = confirm('Deseja excluir o(s) item(ns) selecionado(s)?');
    if (msg) {
        location.href="?action="+ arguments[0] +"&area="+ arguments[1] +"&iditem="+ arguments[2];
    }
    return false;
}

function DesejaContinuar(){
    msg = confirm('Tem certeza que tem autorização para usar o direito de imagem da foto? ');
    if (msg) {
        return true;
    }
    return false;
}

function centraliza(largura,altura){
	window.moveTo((window.screen.width-largura)/2,(window.screen.height-altura)/2);
}

function abreJanela(arquivo,nome,barra,largura,altura) {
	window.open(arquivo,nome,"resizable=no,toolbar=no,status=no,menubar=no,scrollbars="+barra+",width="+largura+",height="+altura);
}

function redimenciona(){
	var i=0;
	function resize() {
		if (navigator.appName == 'Netscape') i=40;
		if (document.images[0]) window.resizeTo(document.images[0].width +50, document.images[0].height+80-i);
		if (window.moveTo((window.screen.width-document.images[0].width)/2,(window.screen.height-document.images[0].height)/2));
	}
}

function montaSWF(arquivo,largura,altura,action) {
	var now = new Date();	
	var dia = now.getDay();
	var mes = now.getMonth();
	var ano = now.getFullYear();
	var hora = now.getHours();
	var mintuto = now.getMinutes();
	var segundo = now.getSeconds();
	var data = ano+""+mes+""+dia+""+hora;

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">');
	document.write('<param name="movie" value="swf/'+ arquivo +'.swf?ieSux='+ data +'" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="FlashVars" value="'+ action +'&clearCache='+ data +'" />');
	document.write('<embed FlashVars="'+ action +'&clearCache='+ data +'" wmode="transparent" menu="false" src="swf/'+ arquivo +'.swf?ieSux='+ data +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + largura + '" height="' + altura + '"></embed>');
	document.write('</object>');
}

startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		if (navRoot != null) {
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
					}
					node.onmouseout=function() {
						this.className=this.className.replace
						(" over", "");
					}
				}
			}
		}
	}
}

window.onload=startList;

function goTo(url) {
	window.location.href = url;
}

function tralha(i) {
    var objs = document.getElementById("objetos").getElementsByTagName("div");
    
    var n = 1;
    
    for(var j = 0; j < objs.length; j++) {
        if (document.getElementById("obj" + n)) {
            document.getElementById("obj" + n).style.display = 'none';
            n++;
        }
    }
    
    document.getElementById("obj" + i).style.display = '';
}

function setLength(img) {
    if (img.width > 85 && img.height <= 100)
        img.width = 85;
    if (img.width <= 85 && img.height > 100)
        img.height = 120;
        
    if (img.width > 85 && img.height > 100) {
        if (img.width > img.height)
            img.width = 85;
        else
            img.height = 100;
    }
}

function cloth(tipo) {
    document.getElementById("roupa_blusa").style.display = 'none';
    document.getElementById("roupa_calca").style.display = 'none';
    document.getElementById("roupa_saia").style.display = 'none';
    document.getElementById("roupa_sapato").style.display = 'none';
    document.getElementById("roupa_bolsa").style.display = 'none';
    document.getElementById("roupa_oculos").style.display = 'none';
    document.getElementById("roupa_acessorio").style.display = 'none';
    
    document.getElementById("roupa_" + tipo).style.display = '';
    return false;
}

function selectCloth(tipo,id,ext) {
    switch(tipo) {
        case "imgBlusa":
            document.forms[0].hidBlusa.value = id;
            document.getElementById("imgBlusa").src = "Arquivos/Galeria/Roupa/" + id + "/" + id + "." + ext;
            break;
        case "imgCalca":
            document.forms[0].hidCalca.value = id;
            document.forms[0].hidSaia.value = 0;
            document.getElementById("imgCalca").src = "Arquivos/Galeria/Roupa/" + id + "/" + id + "." + ext;
            break;
        case "imgSaia":
            document.forms[0].hidCalca.value = 0;
            document.forms[0].hidSaia.value = id;
            document.getElementById("imgCalca").src = "Arquivos/Galeria/Roupa/" + id + "/" + id + "." + ext;
            break;
        case "imgSapato":
            document.forms[0].hidSapato.value = id;
            document.getElementById("imgSapato").src = "Arquivos/Galeria/Roupa/" + id + "/" + id + "." + ext;
            break;
        case "imgBolsa":
            document.forms[0].hidBolsa.value = id;
            document.getElementById("imgBolsa").src = "Arquivos/Galeria/Roupa/" + id + "/" + id + "." + ext;
            break;
        case "imgOculos":
            document.forms[0].hidOculos.value = id;
            document.getElementById("imgOculos").src = "Arquivos/Galeria/Roupa/" + id + "/" + id + "." + ext;
            break;
        case "imgAcessorio":
            document.forms[0].hidAcessorio.value = id;
            document.getElementById("imgAcessorio").src = "Arquivos/Galeria/Roupa/" + id + "/" + id + "." + ext;
            break;
    }
}

function comentar(id,area,tipo) {
    window.open('http://www.revistapaisefilhos.com.br/comentar.php?comment=' + id + '&tl=' + area + '&tipo=' + tipo,'Comentário','location=no,toolbar=no,status=yes,scrollbars=yes,resizable=no,width=370,height=550');
    return false;
}

function enviar(id,area,tipo) {
    window.open('http://www.revistapaisefilhos.com.br/enviar.php?page=' + id + '&tl=' + area + '&tipo=' + tipo,'Enviar','location=no,toolbar=no,status=yes,scrollbars=no,resizable=no,width=400,height=350');
    return false;
}

function enviar2(action,area,tipo) {
    window.open('http://www.revistapaisefilhos.com.br/enviar2.php?action=' + action + '&tl=' + area + '&tipo=' + tipo,'Enviar','locatin=no,toolbar=no,status=yes,scrollbars=no,resizable=no,width=400,height=350');
}

function favoritar(id,area) {
    var url = '?action=favorito&id=' + id + '&area=' + area;
    doRequest('server.php' + url, retornofavoritar);
    return false;
}

function compartilhar() {
    var div = document.getElementById("box_compartilhar");
    
    if (div.style.display == 'none')
        div.style.display = '';
    else
        div.style.display = 'none';
}

function retornofavoritar(f) {
    if (f == "ok")
        alert(unescape('P%E1gina adicionada ao Favoritos com sucesso.'));
    else
        alert(f);
        
    window.location.href = window.location.toString();
}

function comentarForm(id,area,tipo) {
    window.open('http://www.revistapaisefilhos.com.br/comentar.php?comment=' + id + '&tl=' + area + '&tipo=' + tipo + '#form','Comentário','location=no,toolbar=no,status=yes,scrollbars=yes,resizable=no,width=370,height=550');
    return false;
}

function gallery(galeria,id,imagem,desc) {	
	var d = document.getElementById("imgPrincipal");
	d.src = "Arquivos/Galeria/Imagens/" + galeria + "/" + id + "." + imagem;
    document.getElementById("pnlDescricao").innerHTML = desc.replace(/\n/i,'');
	return false;
}

function convite(i,n) {
    img = document.getElementById("imgPrincipal");
    input = document.forms[0].hidConvite;
    
    img.src = 'Arquivos/Galeria/Convite/' + i + '/' + i + '.' + n;
    input.value = i;
}

function CalculaFesta()
{
   var Adul = new Number(document.getElementById('txtAdulto').value);
   var Cria = new Number(document.getElementById('txtCrianca').value);
   var Error = "";
   
   var Bolo = new Number(0);
   var Doces = new Number(0);
   var Salgados = new Number(0);
   var Refrigerante = new Number(0);
   
   if(Adul == 0) Error += "\r\n» Insira o numero de Adultos";
   if(Cria == 0) Error += "\r\n» Insira o numero de Crianças";
        
   if(Error.length == 0)
   {
        Bolo = (Adul+Cria)*0.1;
        Doces = (Adul*6)+(Cria*4);
        Salgados = (Adul*10)+(Cria*6);
        Refri = (Adul+Cria)*0.25;
        
        document.getElementById("txtBolo").value = Bolo;
        document.getElementById("txtDoces").value = Math.ceil(Doces);
        document.getElementById("txtSalgados").value = Math.ceil(Salgados);
        document.getElementById("txtRefrigerante").value = Math.ceil(Refri);
   }
   else
        alert("ATENÇÃO\r\nOcorreram alguns erros:\r\n"+ Error)
}

function paginar(i) {
    document.forms[0].hidPagina.value = i;
    document.forms[0].submit();
    return false;
}

function sendPromocao() {
    form = document.forms[0];
    if (!form.txtNome.value) {
        alert('O campo nome deve ser preenchido.');
        form.txtNome.focus();
        return false;
    }
    if (!form.txtEmail.value) {
        alert('O campo e-mail deve ser preenchido.');
        form.txtEmail.focus();
        return false;
    }
    if (!form.txtResposta.value) {
        alert('O campo resposta deve ser preenchido.');
        form.txtResposta.focus();
        return false;
    }
    
    form.submit();
    return false;
}

function votar(n) {
    key = false;
    
    f = document.forms[0].elements;
    for(var i = 0; i < f.length; i++) {
        if (f[i].name == "enquete" + n && f[i].checked) {
            key = true;
            break;
        }
    }
    
    if (!key) {
        alert('Necessário selecionar a opção antes de votar.');
        return false;
    }

    document.forms[0].hidEnquete.value = n;
    document.forms[0].submit();
    return false;
}

function IeXXX()
{
    var X = new Date();
    
    var hora = X.getHours();
    var Minu = X.getMinutes();
    var Segu = X.getSeconds();
    
    var dia = X.getDate();
    var mes = X.getMonth()+1;
    var ano = X.getFullYear();
    
    return  hora + Minu + Segu + dia + mes + ano
}

function Habilita()
{
    document.getElementById("butons").style.display = (arguments[0] ? "":"none");
}

function MostraDiv()
{
    document.getElementById(arguments[0]).style.display = (arguments[1] ? "":"none");   
}

var nome;

function roupagravida() {
    nome = prompt('Defina um nome para o conjunto.');
    
    if (nome == null)
        return false;
    
    if (!nome) {
        alert(unescape('%C9 necess%E1rio definir um nome para o conjunto.'));
        roupagravida();
        return false;
    }
    
    doRequest('server.php?action=consulta-roupa-gravida&nome=' + nome, validarroupagravida);
}

function validarroupagravida(f) {
    if (eval(f)) {
        var blusa = document.forms[0].hidBlusa.value;
        var bolsa = document.forms[0].hidBolsa.value;
        var sapato = document.forms[0].hidSapato.value;
        var oculos = document.forms[0].hidOculos.value;
        var acessorio = document.forms[0].hidAcessorio.value;
        var calca = document.forms[0].hidCalca.value;
        var saia = document.forms[0].hidSaia.value;
        
        var url = '?action=roupa-gravida&nome=' + nome + '&blusa=' + blusa + '&bolsa=' + bolsa + '&sapato=' + sapato + '&oculos=' + oculos + '&acessorio=' + acessorio + '&calca=' + calca + '&saia=' + saia;
        
        doRequest('server.php' + url, retornoroupagravida);
    }
    else {
        alert(unescape('O nome escolhido est%E1 sendo utilizado, favor escolher outro.'));
        roupagravida();
        return false;
    }
}

function retornoroupagravida(f) {
    if (f == "ok")
        alert('Conjunto armazenado com sucesso.');
    else
        alert(f);
}

function busca() {                                                                                                                                                                                                                   
     window.location.href = '/busca/' + document.forms[0].txtBusca.value.replace(/ /gi,"+");                                                
}

var ie =(((navigator.userAgent.indexOf("MSIE")>-1)||(navigator.userAgent.indexOf("Mozilla/5.0")>-1))&&navigator.userAgent.indexOf("Opera")==-1?true:false);
var ns =(navigator.userAgent.indexOf("Netscape")>-1&&navigator.userAgent.indexOf("Opera")==-1?true:false);
function buscar(input, evento) {
    var tecla = (evento.keyCode ? evento.keyCode: evento.which ? evento.which : evento.charCode);
    if ((tecla == 8)||(tecla == 46)||(tecla == 39)||(tecla == 37)||(tecla == 36)||(tecla == 35)||(tecla == 9)) {
        return true;
    }
    if (tecla == 13) {        
        window.location.href = 'busca/' + retirarAcentos(input.value.replace(/ /gi,"+"));
        evento.returnValue = false;
        return false;
    }
    return true;
}

function retirarAcentos(campo, evento) {
   var texto = campo.value;
   var acento = 'áàãâäéèêëíìîïóòõôöúùûüçÁÀÃÂÄÉÈÊËÍÌÎÏÓÒÕÖÔÚÙÛÜÇ';
   var semacento = 'aaaaaeeeeiiiiooooouuuucAAAAAEEEEIIIIOOOOOUUUUC';
   var nova='';                                                        
       
   var tecla = (evento.keyCode ? evento.keyCode: evento.which ? evento.which : evento.charCode);
    if (tecla == 13) {               
        location.href = 'busca/' + campo.value.replace(/ /gi,"+");
        evento.returnValue = false;
        return false;
    }  
   
   for (i = 0; i < texto.length; i++) {
         if (acento.search(texto.substr(i, 1)) >= 0) {
              nova += semacento.substr(acento.search(texto.substr(i, 1)), 1);
      }
         else {
             nova += texto.substr(i, 1);
         }
   }               
   campo.value = nova;
}
   
function FormataMaisEnviadas() {
        var oDiv = document.getElementById("comentadas");
        var oDiv2 = document.getElementById("enviadas");
        var oDiv3 = document.getElementById("lidas");
        
        oDiv.style.display = "none";
      //  oDiv2.style.removeProperty("display");  
		oDiv2.style.display = "block";
        oDiv3.style.display = "none";
    }
    
function FormataMaisComentadas() {
        var oDiv = document.getElementById("comentadas");
        var oDiv2 = document.getElementById("enviadas");
        var oDiv3 = document.getElementById("lidas");
        
		oDiv.style.display = "block"; 
      //  oDiv.style.removeProperty("display"); 
        oDiv2.style.display = "none";                  
        oDiv3.style.display = "none";               
    }
    
function FormataMaisLidas() {
        var oDiv = document.getElementById("comentadas");
        var oDiv2 = document.getElementById("enviadas");
        var oDiv3 = document.getElementById("lidas");
        
        oDiv.style.display = "none";
        oDiv2.style.display = "none";                  
        oDiv3.style.display = "block";            
        //oDiv3.style.removeProperty("display");            
    }

function login() {
    var url = window.location.toString();
    alert('É necessario fazer o login para guardar esse item.');
    window.location.href = '?action=login&ret=' + url;
    return false;
}



function addFav() {
        var url = "http://www.revistapaisefilhos.com.br/";
        var title = "Revista Pais & Filhos";
        if (window.sidebar) window.sidebar.addPanel(title, url, "");
        else if (window.opera && window.print) {
            var mbm = document.createElement('a');
            mbm.setAttribute('rel', 'sidebar');
            mbm.setAttribute('href', url);
            mbm.setAttribute('title', title);
            mbm.click();
        }
        else if (document.all) { window.external.AddFavorite(url, title); }
    }




