var texto_ = ""
var numimg_ = 2
day = new Date() 
seed = day.getTime()
//Caso incremente o número de banners, o numing_ aumenta e o último número da linha abaixo incrementado.
ran = parseInt(((seed - (parseInt(seed/1000,10) * 1000))/10)/100*numimg_ + 1,3)
if(ran == (1)){
	texto_=("<a href='http://clicklogger.rm.uol.com.br/?prd=16&grp=src:14;sze:1;creative:468x60_uolhost_parceiro_newwws&msr=Cliques%20de%20Origem:1&oper=7&redir=http://www.uolhost.com.br/' target='_blank'><img src='banner/uol.gif' border='0'></a>");
	link_=("http://clicklogger.rm.uol.com.br/?prd=16&grp=src:14;sze:1;creative:468x60_uolhost_parceiro_newwws&msr=Cliques%20de%20Origem:1&oper=7&redir=http://www.uolhost.com.br/");
	alt_="UOL";
}
if(ran == (2)){
	texto_ = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='468' height='60'><param name=movie value='banner/fullbanner_promocao.swf'><param name=quality value=high> <embed src='banner/fullbanner_promocao.swf' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='468' height='60'></embed> </object>"	
	link_=("http://encontrodewebdesign.com.br/encontro_13/conteudo.asp?sessao=2&subsessao=3");
	alt_="13 EWD";
}
//if(ran == (3)){
	//texto_=("<a href='http://www.plugin.com.br' target='_blank'><img src='banner/plugin_sql.gif' border='0'></a>");
//}
//if(ran == (4)){
	//texto_=("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='468' height='60'><param name=movie value='banner/banner_ewd13.swf'><param name=quality value=high><embed src='banner/banner_ewd13.swf' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='468' height='60'></embed></object>");
//}


function sair() {
	if(confirm("Deseja sair do sistema?")){
		document.location.href='conf.php?acao=logof';
	}
}
function mostraEmpresa(){
	if(document.getElementById('perfil').value == "4"){
		document.getElementById('emp').style.display='block';
		document.getElementById('foto').style.display='none';
		document.getElementById('mini').style.display='none';
	}else{
		document.getElementById('emp').style.display='none';
	}
	
	if(document.getElementById('perfil').value == "2"){
		document.getElementById('emp').style.display='none';
		document.getElementById('foto').style.display='block';
		document.getElementById('mini').style.display='block';
	}else{
		document.getElementById('foto').style.display='none';
		document.getElementById('mini').style.display='none';
	}
}
function textoStatus(texto){
	window.status = texto;
}
function underLine(d){
	document.getElementById(d).style.text="underline";
}
function validaAlterSenha(){
	if(document.getElementById("senha").value == ""){
		alert("Senha é um campo obrigatório.\n\n\nNewwws.com.br")
		document.getElementById("senha").focus();
		return false;
	}
	
	if(document.getElementById("confsenha").value == ""){
		alert("Confirma senha é um campo obrigatório.\n\n\nNewwws.com.br")
		document.getElementById("confsenha").focus();
		return false;
	}
	
	if(document.getElementById("senha").value != document.getElementById("confsenha").value){
		alert("Campos preenchidos com valores diferentes.\n\n\nNewwws.com.br")
		document.getElementById("confsenha").focus();
		return false;
	}else{
		document.user.submit();
	}
}
function validaReceba()
{ 
	if(document.getElementById("nome").value == "")
	{
		alert("Nome é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById("nome").focus();
		return false;
	}
	document.getElementById("email").value = document.getElementById("email").value.toLowerCase(); 
	
	if (!(email(document.getElementById("email"))))
		return false
		
	document.receba.submit();
}
function validaLogin(){
	if (!(email(document.getElementById("email"))))
		return false
	
	if(document.getElementById("senha").value == "")
	{
		alert("Senha é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById("senha").focus();
		return false;
	}
	document.getElementById("email").value = document.getElementById("email").value.toLowerCase(); 
	document.login.submit();	
}
function validaEnvie(){
	if(document.getElementById("seunome").value == ""){
		alert("Seu nome é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById("seunome").focus();
		return false;
	}
		
	
	if (!(email(document.getElementById("seuemail"))))
		return false
	
	if(document.getElementById("nomeamigo").value == ""){
		alert("Nome do seu amigo é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById("nome").focus();
		return false;
	}
		
	if (!(email(document.getElementById("emailamigo"))))
		return false
		
	//document.envie.action="http://www.rrcdesign.com.br/conf.php?acao=c&table=envie&noticia_id="+document.getElementById("noticia_id").value;
	document.envie.action="enviar.php?acao=c&table=envie&noticia_id="+document.getElementById("noticia_id").value;
	document.envie.submit();
	
	
}
function validaComentario() {
	if(document.getElementById("nome").value == ""){
		alert("Nome é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById("nome").focus();
		return false;
	}
		
	
	if (!(email(document.getElementById("email"))))
		return false
		
	if(document.getElementById("comentario_conteudo").value == ""){
		alert("Comentário é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById("comentario_conteudo").focus();
		return false;
	}
	
	document.comentario.action="conf.php?acao=c&table=comentario";
//	alert(document.cad_noticia.action);
	document.comentario.submit();
	
}
function validaContato(){
	if(document.getElementById("nome").value == ""){
		alert("Nome é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById("nome").focus();
		return false;
	}
		
	
	if (!(email(document.getElementById("email"))))
		return false
		
	if(document.getElementById("setor").value == ""){
		alert("Setor é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById("setor").focus();
		return false;
	}
	
	if(document.getElementById("mensagem").value == ""){
		alert("Mensagem é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById("mensagem").focus();
		return false;
	}
	
	document.contato.action="conf.php?acao=c&table=contato";
//	alert(document.cad_noticia.action);
	document.contato.submit();

}
function validaNoticia(acao)  {
	var str = document.getElementById("noticia_titulo");
	if(str.value == "")
	{
		alert("Título é um campo obrigatório.\n\n\nNewwws.com.br");
		str.focus();
		return false;
	}else{
		if (str.value.length < 10 || str.value.length > 80)
			{
				alert("Favor verificar o preenchimento do campo Título.\n\nQuantidade de Caracteres:\n     Minimo: 10\n     Máximo: 80\n\n\nNewwws.com.br");			
				str.focus();
				return false;
			}
	}
	
	
//	if(document.all.EditorValue.value == ""){
//		alert("Notícia é um campo obrigatório.\n\n\nNewwws.com.br");
//		//alert(document.all.EditorValue.value);
//		document.all.EditorValue.focus();
//		return false;
//	}
	var act="";
	if(acao == "a"){
		act = "&noticia_id="+document.getElementById("noticia_id").value;
	}
	document.cad_noticia.action="conf.php?acao="+acao+"&table=noticia"+act;
//	alert(document.cad_noticia.action);
	document.cad_noticia.submit();
	
}
function validaImgNoticia(){
	if(document.getElementById("img").value == ""){
		alert("Campo de imagem é obrigatório.\n\n\nNewwws.com.br");
		document.getElementById("img").focus();
		return false;
	}
	
	return true;
}

function validaLink(acao){
	if(document.getElementById("cliente").value == ""){
		alert("Cliente é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById("cliente").focus();
		return false;
	}
	
	var str1 = document.getElementById("link_titulo");
	if(str1.value == "")
	{
		alert("Título é um campo obrigatório.\n\n\nNewwws.com.br");
		str1.focus();
		return false;
	}else{
		if (str1.value.length > 30)
			{
				alert("Favor verificar o preenchimento do campo Título.\n\nQuantidade de Caracteres:\nMáximo: 30\n\n\nNewwws.com.br");
				str1.focus();
				return false;
			}
	}
	
	if(document.getElementById("link_url").value == ""){
		alert("URL é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById("link_url").focus();
		return false;
	}else{
		/*if(document.getElementById("link_url").value.indexOf("http://")){
			
		}*/
	}
	
	var str2 = document.getElementById("link_chave");
	if(str2.value == ""){
		alert("Descrição é um campo obrigatório.\n\n\nNewwws.com.br");
		str2.focus();
		return false;
	}else{
		if (str2.value.length < 40 || str2.value.length > 55)
			{
				alert("Favor verificar o preenchimento do campo Descrição.\n\nQuantidade de Caracteres:\n     Minimo: 40\n     Máximo: 55\n\n\nNewwws.com.br");
				str2.focus();
				return false;
			}
	}
	
	if(document.getElementById("link_chave").value == ""){
		alert("Descrição é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById("link_chave").focus();
		return false;
	}
	var act="";
	if(acao == "a"){
		act = "&link_id="+document.getElementById("link_id").value;
	}
	document.cad_link.action="conf.php?acao="+acao+"&table=link"+act;
//	alert(document.cad_noticia.action);
	document.cad_link.submit();
	
}
function validaUser(acao){
	if(document.getElementById('perfil').value == ""){
		alert("Perfil é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById('perfil').focus();
		return false;
	}else{
		if(document.getElementById('perfil').value=="4"){
			if(document.getElementById('empresa_user').value == ""){
				alert("Empresa é um campo obrigatório.\n\n\nNewwws.com.br");
				document.getElementById('empresa_user').focus();
				return false;
			}
		}
	}
	
	if(document.getElementById('contato').value == ""){
		alert("Nome é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById('contato').focus();
		return false;
	}
	
	
	if (!(email(document.getElementById("email"))))
		return false
	
	if(document.getElementById('ddd1').value == ""){
		alert("DDD é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById('ddd1').focus();
		return false;
	}
	if(document.getElementById('telefone_user').value == ""){
		alert("Telefone é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById('telefone_user').focus();
		return false;
	}
	
	
	
	if(document.getElementById('celular_user').value != ""){
		if(document.getElementById('ddd2').value == ""){
			alert("DDD do celular é um campo obrigatório.\n\n\nNewwws.com.br");
			document.getElementById('ddd2').focus();
			return false;
		}
	}
	
	document.user.submit();
}

function validaBusca(){
	if(document.getElementById("parBusca").value == ""){
		alert("Busca é um campo obrigatório.\n\n\nNewwws.com.br");
		document.getElementById("parBusca").focus();
		return false;
	}
	return true;
}
function email(email){
	var valid = "y"; 
		
	if (email.value != "") 
	{ 
	if (email.value.length < 7 || email.value.indexOf("@.") != -1 || email.value.indexOf("-.") != -1 || email.value.indexOf("_.") != -1 || email.value.indexOf("..") != -1 || 
			email.value.indexOf("._") != -1 || email.value.indexOf(".-") != -1 || email.value.indexOf(".@") != -1 || email.value.indexOf("@-") != -1 || email.value.indexOf("@_") != -1 || 
			email.value.indexOf("@") != email.value.lastIndexOf("@") || email.value.indexOf("@") == -1 || email.value.indexOf(".") == -1 || 
			(email.value.length - (email.value.lastIndexOf(".") + 1)) < 2) 
		{ 
			valid = "n"; 
			alert("O email informado está incorreto.\n\n\nNewwws.com.br"); 
			email.focus();
			return false;
		} 
		else 
		{ 
			a = "abcdefghijklmnopqrstuvwxyz0123456789@-_."; 
			b = 0; 
			while (b < email.value.length) 
			{ 
				if (a.indexOf(email.value.charAt(b)) == -1) 
				{ 
					valid = "n"; 
					alert("O campo de e-mail não pode conter o caracter \"" + email.value.charAt(b) + "\"."); 
					email.focus(); 
					b = email.value.length;
					return false;
				} 
				b = b + 1; 
			} 
		} 
	}
	else{
		valid = "n"; 
		alert("E-mail é um campo obrigatório.\n\n\nNewwws.com.br"); 
		email.focus();
		return false;
	}
	
	if (valid == "y") 
	{ 
		var rx = /^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.[a-z][a-z]$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.aero$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.biz$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.coop$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.com$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.edu$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.gov$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.info$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.int$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.mil$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.museum$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.name$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.net$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.org$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9][a-z0-9\-\.]*[a-z0-9]\.pro$/i; 
		//var rx = /^[a-z0-9\._]*[a-z0-9_]@[a-z0-9]*[a-z0-9]\.[a-z][a-z]$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9]*[a-z0-9]\.aero$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9]*[a-z0-9]\.biz$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9]*[a-z0-9]\.coop$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9]*[a-z0-9]\.com$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9]*[a-z0-9]\.edu$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9]*[a-z0-9]\.gov$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9]*[a-z0-9]\.info$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9]*[a-z0-9]\.int$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9]*[a-z0-9]\.mil$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9]*[a-z0-9]\.museum$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9]*[a-z0-9]\.name$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9]*[a-z0-9]\.net$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9]*[a-z0-9]\.org$|^[a-z0-9\._]*[a-z0-9_]@[a-z0-9]*[a-z0-9]\.pro$/i; 
		
		if (rx.test(email.value) || (email.value=="bruno-rodrigues@uol.com.br")) 
		{ 
			rx = /^[a-z0-9_]/; 
			if(!(rx.test(email.value))) 
			{ 
				valid = "n"; 
				alert("O e-mail informado está incorreto.\n\n\nNewwws.com.br"); 
				email.focus(); 
				return false;
			} 
		} 
		else 
		{ 
			valid = "n"; 
			alert("O e-mail informado está incorreto.\n\n\nNewwws.com.br"); 
			email.focus(); 
			return false;
		} 
	} 
	if (valid == "y"){
		//
		return true;
	} 
}
var to=new Array()
function over(n){
	if(typeof(to[n])!="undefined")clearTimeout(to[n])
	document.getElementById("o"+n).style.display="block";
	if(n == 1){
	//	document.getElementById("o1").style.display="none"
		document.getElementById("o2").style.display="none";
		document.getElementById("o3").style.display="none";
		document.getElementById("o4").style.display="none";
	}
	
	if(n == 2){
		document.getElementById("o1").style.display="none";
	//	document.getElementById("o2").style.display="none";
		document.getElementById("o3").style.display="none";
		document.getElementById("o4").style.display="none";
	}
	
	if(n == 3){
		document.getElementById("o1").style.display="none";
		document.getElementById("o2").style.display="none";
	//	document.getElementById("o3").style.display="none";
		document.getElementById("o4").style.display="none";
	}
	
	if(n == 4){
		document.getElementById("o2").style.display="none";
		document.getElementById("o1").style.display="none";
		document.getElementById("o3").style.display="none";
	//	document.getElementById("o4").style.display="none";
	}
//	alert(document.getElementById("o"+n).style.display);
}
function out(n){
	to[n]=document.getElementById('o'+n).style.display="none";
}
function exclusao(table,id){
	if(confirm("Você realmente deseja excluir?")){
		document.location.href="conf.php?acao=e&table="+table+"&id="+id+"&totLinks=0";
	}
}
function excluirImgNoticia(noticia_id,noticia_img){
	if(confirm("Você realmente deseja excluir a imagem?")){
		document.location.href="conf.php?acao=e&table=img&noticia_id="+noticia_id+"&noticia_img="+noticia_img;
	}
}
function max(txarea,total,dig,res) 
{ 
//	total = 10; 
	var tam = txarea.value.length; 
	var str=""; 
	str=str+tam; 
	dig.innerHTML = str; 
	res.innerHTML = total - str; 

	if (tam > total){
		aux = txarea.value; 
		txarea.value = aux.substring(0,total); 
		dig.innerHTML = total 
		res.innerHTML = 0
	} 
} 
function mudarPor(id){
	for(i=1;i<=6;i++){
		document.getElementById('campo'+i).style.display="none";
		document.getElementById('sub'+i).style.display="none";
	}
	document.getElementById('campo'+id).style.display="inline";
	document.getElementById('sub'+id).style.display="inline";
	document.getElementById('campo'+id).focus();
}
function NewWindow(mypage, myname, w, h, scroll) 
{
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll;
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
function mudarStatusNot(noticia_id,noticia_status){
	var alt;
	if(noticia_status == "1"){
		alt = "exibir notícia para visitante";
	}else{
		alt = "não exibir notícia para visitante";
	}
	if(confirm("Realmente deseja "+alt+"?")){
		document.location.href = "conf.php?acao=a&table=noticia&noticia_id="+noticia_id+"&noticia_status="+noticia_status+"&campo=noticia_status";
	}
}
function txtBoxFormat(objForm, strField, sMask, evtKeyPress) {
var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
if(document.all) { // Internet Explorer
    nTecla = evtKeyPress.keyCode;
} else if(document.layers) { // Nestcape
    nTecla = evtKeyPress.which;
} else {
    nTecla = evtKeyPress.which;
    if (nTecla == 8) {
        return true;
    }
}
sValue = objForm[strField].value;
// Limpa todos os caracteres de formatação que
// já estiverem no campo.
sValue = sValue.toString().replace( "-", "" );
sValue = sValue.toString().replace( "-", "" );
sValue = sValue.toString().replace( ".", "" );
sValue = sValue.toString().replace( ".", "" );
sValue = sValue.toString().replace( "/", "" );
sValue = sValue.toString().replace( "/", "" );
sValue = sValue.toString().replace( "(", "" );
sValue = sValue.toString().replace( "(", "" );
sValue = sValue.toString().replace( ")", "" );
sValue = sValue.toString().replace( ")", "" );
sValue = sValue.toString().replace( " ", "" );
sValue = sValue.toString().replace( " ", "" );
sValue = sValue.toString().replace( ":", "" );
sValue = sValue.toString().replace( ":", "" );
fldLen = sValue.length;
mskLen = sMask.length;
i = 0;
nCount = 0;
sCod = "";
mskLen = fldLen;
while (i <= mskLen) {
bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ":") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))
if (bolMask) {
    sCod += sMask.charAt(i);
    mskLen++;
} else {
    sCod += sValue.charAt(nCount);
    nCount++;
}
i++;
}
objForm[strField].value = sCod;
if (nTecla != 8) { // backspace
    if (sMask.charAt(i-1) == "9") { // apenas números...
    return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9
else { // qualquer caracter...
    return true;
}
} else {
    return true;
}
}
//Fim da Função Máscaras Gerais
/***
* AUTO TAB - ao prencher o campo, automaticamente manda o foco para o próximo!
***/
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
    var keyCode = (isNN) ? e.which : e.keyCode;
    var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
    if(input.value.length >= len && !containsElement(filter,keyCode)) {
        input.value = input.value.slice(0, len);
        input.form[(getIndex(input)+1) % input.form.length].focus();
    }
function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
    if(arr[index] == ele)
        found = true;
    else
        index++;
        return found;
    }
function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
        if (input.form[i] == input)index = i;
        else i++;
        return index;
    }
    return true;
}
function focar(){
	document.testando.campoteste.focus();
}
function formatCurrency(campo) {
	var num = campo.value;
	
	num = num.toString().replace(/\$|/g,'');
	
	if(isNaN(num))
		num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+
	num.substring(num.length-(4*i+3));
	campo.value = (((sign)?'':'-') + num + '.' + cents);
	
}

