var win = null;
function newwin(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',status=yes';
win = window.open(mypage,myname,settings);
}

function chgimg(imgName, imgPath) {
imgObj = 'document.'+imgName
eval(imgObj).src = imgPath
}

var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;

function hidelayer(lay) {

if (ie4) {document.all[lay].style.visibility = "hidden";}
if (ns4) {document.layers[lay].visibility = "hide";}
if (ns6) {document.getElementById([lay]).style.display = "none";}

}

function showlayer(lay) {
hidelayer('layer_bemestar');
hidelayer('layer_nutricao');
hidelayer('layer_lazer');
hidelayer('layer_seucorpo');

if (ie4) {document.all[lay].style.visibility = "visible";}
if (ns4) {document.layers[lay].visibility = "show";}
if (ns6) {document.getElementById([lay]).style.display = "block";}
}

function valida_depoimento(){ 

	if(document.frm.txb_name.value==''){
		alert('Preencha o campo Nome');
		document.frm.txb_name.focus();
		return false;
	}
	
	if(isNaN(document.frm.txb_idade.value) || document.frm.txb_idade.value==''){
		alert('O campo idade deve ser um valor numérico');
		document.frm.txb_idade.focus();
		return false;
	}
	
	if (document.frm.txb_email.value == "") {
		alert("Informe seu e-mail.");
		frm.txb_email.focus();
		frm.txb_email.select();
		return false;
	} else {
			prim = document.frm.txb_email.value.indexOf("@")
		if(prim < 2) {
			alert("O e-mail informado parece não estar correto.");
			frm.txb_email.focus();
			frm.txb_email.select();
			return false;
		}
		if(frm.txb_email.value.indexOf("@",prim + 1) != -1) {
			alert("O e-mail informado parece não estar correto.");
			frm.txb_email.focus();
			frm.txb_email.select();
			return false;
		}
		if(frm.txb_email.value.indexOf(".") < 1) {
			alert("O e-mail informado parece não estar correto.");
			frm.txb_email.focus();
			frm.txb_email.select();
			return false;
		}
		if(frm.txb_email.value.indexOf(" ") != -1) {
			alert("O e-mail informado parece não estar correto.");
			frm.txb_email.focus();
			frm.txb_email.select();
			return false;
		}			
		if(frm.txb_email.value.indexOf(".@") > 0) {
			alert("O e-mail informado parece não estar correto.");
			frm.txb_email.focus();
			frm.txb_email.select();
			return false;
		}
		if(frm.txb_email.value.indexOf("@.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			frm.txb_email.focus();
			frm.txb_email.select();
			return false;
		}
		
		if(frm.txb_email.value.indexOf("/") > 0) {
			alert("O e-mail informado parece não estar correto.");
			frm.txb_email.focus();
			frm.txb_email.select();
			return false;
		}
		if(frm.txb_email.value.indexOf("[") > 0) {
			alert("O e-mail informado parece não estar correto.");
			frm.txb_email.focus();
			frm.txb_email.select();
			return false;
		}
		if(frm.txb_email.value.indexOf("]") > 0) {
			alert("O e-mail informado parece não estar correto.");
			frm.txb_email.focus();
			frm.txb_email.select();
			return false;
		}
		if(frm.txb_email.value.indexOf("(") > 0) {
			alert("O e-mail informado parece não estar correto.");
			frm.txb_email.focus();
			frm.txb_email.select();
			return false;
		}
		if(frm.txb_email.value.indexOf(")") > 0) {
			alert("O e-mail informado parece não estar correto.");
			frm.txb_email.focus();
			frm.txb_email.select();
			return false;
		}
		if(frm.txb_email.value.indexOf("..") > 0) {
			alert("O e-mail informado parece não estar correto.");
			frm.txb_email.focus();
			frm.txb_email.select();
			return false;
		}
	}
	if(document.frm.txb_profissao.value==''){
		alert('Informe a sua profissão.');
		document.frm.txb_profissao.focus();
		return false;
	}else if(isNaN(document.frm.txb_anos.value) || document.frm.txb_anos.value==''){
		alert('Informe a Idade com que teve cancer');
		document.frm.txb_anos.focus();
		return false;
	}else	if(document.frm.txb_depoimento.value==''){
		alert('Preencha o campo Depoimento');
		document.frm.txb_depoimento.focus();
		return false;
	}else	if(document.frm.aceito.checked==false){
		alert('Você deve autorizar a publicação do seu depoimento');
		return false;
	}
	
	return true;	
}

function valida_manager(){
	if(document.frm.titulo.value==''){
		alert('Preencha o campo Título');
		return;
	}
	if(document.frm.materia.value==''){
		alert('Preencha o campo Chamada');
		return;
	}
	if(document.frm.texto.value==''){
		alert('Preencha o campo Texto');
		return;
	}
	document.frm.submit();
}




function pf_wopen (file, w, h, scr)
{    
    var F = file
    var W = w
    var H = h
    var S = scr
    var desktop = window.open( ""+F+"", '' , "width="+W+",height="+H+",toolbar=no,location=no,status=no,menubar=no,scrollbars="+S+",resizable=yes" );   
}

function pf_wopenLink (destino,file, w, h, scr)
{    
 
    var F = file
    var W = 300
    var H = 250
    var S = scr
    var desktop = window.open( ""+F+"?action="+destino, '' , "width="+W+",height="+H+",toolbar=no,location=no,status=no,menubar=no,scrollbars="+S+",resizable=yes" );   
}
