//Código para evitar cópias
function click() {
if (event.button==2||event.button==3) {
 oncontextmenu='return false';
  }
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;");



// Funções Auxiliares
//funções de codificar e decodificar uma URL
function urlencode(plaintext){
	var SAFECHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.!~*'()";
	var HEX = "0123456789ABCDEF";
	var encoded = "";
	for(var i = 0; i < plaintext.length; i++ ){
		var ch = plaintext.charAt(i);
	    if(ch == " "){
		    encoded += "+";
		}
		else if(SAFECHARS.indexOf(ch) != -1){
		    encoded += ch;
		}
		else{
		    var charCode = ch.charCodeAt(0);
			if(charCode > 255){
			    alert( "Unicode Character '" + ch + "' cannot be encoded using standard URL encoding.\n" +
				        "(URL encoding only supports 8-bit characters.)\n" +
						"A space (+) will be substituted." );
				encoded += "+";
			}
			else{
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	}
	return encoded;
}

function urldecode(encoded){
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var plaintext = "";
   var i = 0;
   while(i < encoded.length){
       var ch = encoded.charAt(i);
	   if(ch == "+"){
	       plaintext += " ";
		   i++;
	   }
	   else if(ch == "%"){
			if(i < (encoded.length-2)
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ){
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			}
			else{
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		}
		else{
		   plaintext += ch;
		   i++;
		}
	}
   return plaintext;
}

// Funções NetHistória

function jumpMenu(targ,obj,restore){
	eval(targ+".location='"+obj.options[obj.selectedIndex].value+"'");
	if (restore) obj.selectedIndex=0;
}

function popup(url, width, height){
	window.open(url, 'novaxs', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height+',left = 200,top = 120');
}


function popup_imagem(imagem, desc, xx, yy){
	jan = window.open('blank.php', 'novaxs', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width='+xx+',height='+yy+',left = 0,top = 0');
	jan.document.write('<html><head><title>NetHistoria :: Imagem</title></head><body>');
	jan.document.write('<table border="0"><tr><td id="tdd" style="text-align: justify; font-family:Verdana; font-size:8pt;">');
	jan.document.write('<img id="image" src="../'+imagem+'" width="'+(xx-40)+'" height="'+(yy-150)+'"><br>');
	jan.document.write(urldecode(desc)+'<br><br><center><input type="button" value="Fechar" onClick="window.close()"></center></td></tr></table><script language="javascript">window.resizeTo(document.body.scrollWidth+28, document.all.tdd.offsetHeight+60); function click(){if (event.button==2||event.button==3){oncontextmenu=\'return false\';}}document.onmousedown=click; document.oncontextmenu = new Function("return false;");</script></body></html>');
}



function fale_valida_dados(form){
	ret=true;
	if(form.nome.value=="")
		ret=false;
	if(form.email.value=="")
		ret=false;
	if(form.cidade.value=="")
		ret=false;
	if(form.mensagem.value=="")
		ret=false;
	if(!ret)
		alert("Dado(s) inválido(s).\nPor favor, verifique.");

	return ret;
}

function boletim_valida_dados(form){
	msg=false;
	msg2=false;
	if(form.boletins_nome.value=="")
		msg=true;
	if(form.boletins_email.value=="" || !(form.boletins_email.value.indexOf("@")>0 && form.boletins_email.value.indexOf(".")>0))
		msg=true;
	if(form.boletins_ultimas.checked==false && form.boletins_geral.checked==false)
		msg2=true;
	if(msg){
		alert("O campo \"Seu nome\" e/ou o campo \"Seu e-mail\" não foi(ram) preenchido(s).");
		return false
	}else{
		if(msg2){
			alert("Selecione o(s) boletim(s) que você deseja receber.");
			return false;
		}else{
			return true;
		}
	}
}

function indique_valida_dados(form){
	msg=false;
	if(form.seu_nome.value=="")
		msg=true;
	if(form.seu_email.value=="" || !(form.seu_email.value.indexOf("@")>0 && form.seu_email.value.indexOf(".")>0))
		msg=true;
	if(form.amigo_nome.value=="")
		msg=true;
	if(form.amigo_email.value=="" || !(form.amigo_email.value.indexOf("@")>0 && form.amigo_email.value.indexOf(".")>0))
		msg=true;
	if(msg){
		alert("Dado(s) inválido(s).\nPor favor, verifique.");
		return false;
	}
	else{
		return true;
	}
}

function comente_valida_dados(form){
	msg=false;
	if(form.nome.value=="")
		msg=true;
	if(form.email.value=="" || !(form.email.value.indexOf("@")>0 && form.email.value.indexOf(".")>0))
		msg=true;
	if(form.mensagem.value=="")
		msg=true;
	if(msg){
		alert("Dado(s) inválido(s).\nPor favor, verifique.");
		return false;
	}
	else{
		return true;
	}
}

function fechar(){
	window.close();
	}
	
function voltarPopup(url) {  
	opener.location.href = url;
}
