function busca(){
	if(gE("inputbusca").value == "Buscar"){
		alert("Por favor, preencha o termo a ser buscado")
		gE("inputbusca").focus();
		return false;
	}
}

//******************************************************************
function Nova()
{
	if(gE('new_cat').style.display == 'none')
	{
		gE('new_cat').style.display = 'block';
	}
	else
	{
		gE('new_cat').style.display = 'none';
	}
}

function hora(){
	var hora = gE("horario").value;
	hora = hora.substring(0,2);
	if(hora > 24)
	{
		alert("Horário inválido!");
		return false;
	}
}
//*********************************
function fadeOut(id, time) {
	target = document.getElementById(id);
	alpha = 100;
	timer = (time*1000)/100;
	var i = setInterval(
			function() {
				if (alpha <= 50)
				{
					clearInterval(i);
					//target.style.display = "none";
				}
				setAlpha(target, alpha);
				alpha -= 2;
			}, 1);
}

function fadeIn(id, time) {
	target = document.getElementById(id);
	//target.style.display = "block";
	alpha = 50;
	timer = (time*1000)/100;
	var i = setInterval(
			function() {
				if (alpha >= 100)
					clearInterval(i);
				setAlpha(target, alpha);
				alpha += 2;
			}, 1);
}

function setAlpha(target, alpha) {
	target.style.filter = "alpha(opacity="+ alpha +")";
	target.style.opacity = alpha/100;
}

//*********************************************************
function projeto(){
		fadeOut("oprojeto_eventos1", 0.1);
		setTimeout("projeto1()",1000);
}
function projeto1(){
		fadeIn("oprojeto_eventos2", 0.1);
		setTimeout("projeto2()",2000);
}
function projeto2(){
		fadeOut("oprojeto_eventos2", 0.1);
		setTimeout("projeto3()",1000);
}
function projeto3(){
		fadeIn("oprojeto_eventos1", 0.1);
		setTimeout("projeto()",2000);
}

//*********************************************************
function tec(){
		fadeOut("tecnologiadeaz_blog1", 0.1);
		setTimeout("tec1()",1000);
}
function tec1(){
		fadeIn("tecnologiadeaz_blog2", 0.1);
		setTimeout("tec2()",2000);
}
function tec2(){
		fadeOut("tecnologiadeaz_blog2", 0.1);
		setTimeout("tec3()",1000);
}
function tec3(){
		fadeIn("tecnologiadeaz_blog1", 0.1);
		setTimeout("tec()",2000);
}

//*********************************************************

function txtBoxFormat(objeto, 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 = objeto.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++;
    }

    objeto.value = sCod;

    if (nTecla != 8) { // backspace
      if (sMask.charAt(i-1) == "9") { // apenas números...
        return ((nTecla > 47) && (nTecla < 58)); } 
      else { // qualquer caracter...
        return true;
      } 
    }
    else {
      return true;
    }
  }
//*********************************************************
function mail(id)
{
	if(gE(id).value != "")
	{
		if(!checkMail(gE(id).value))
		{
			alert("E-mail inválido!");
			document.getElementById(id).focus();
			return false;
		}
	}
	
	return true;
}

//*********************************************************
function checkMail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){
                    return true;
                }
    }else{
        return false;
        }
}
//*********************************************************

function getPosicaoElemento(elemID){
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop};
}

//*********************************************************

function toggle(obj) { 
			var el = document.getElementById(obj); 
			if ( el.style.display != "none" ) { 
			el.style.display = 'none'; 
			} 
			else { 
			el.style.display = 'block'; 
			} 
			} 

//*********************************************************function esqueci() {
function esqueci() {
props=window.open('esqueci.asp', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=300, height=130, left = 390, top = 341.5');
}

//*********************************************************function esqueci() {
function popup(url) {
props=window.open(url, 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=300, height=130, left = 390, top = 341.5');
}

//*********************************************************
function galeria(id) {
props=window.open('galeria.asp?idMaquina=' + id, 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=800, height=750, left = 390, top = 341.5');
}

//*********************************************************
function galeria_videos(id) {
props=window.open('galeria_videos.asp?idMaquina=' + id, 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=800, height=750, left = 390, top = 341.5');
}
//*********************************************************
var el;
function gE(id)
{
	el = document.getElementById(id);
	return el;
}

//*********************************************************
var esquerda = "";
var cima = "";
function meio()
{
	esquerda = LeftPosition = (screen.width) ? (screen.width-100)/2 : 0;
	cima = TopPosition = (screen.height) ? (screen.height-50)/2 : 0;
	return esquerda;
	return cima;
}

//*********************************************************
function textCounter(field, countfield, maxlimit) 
		{
			if (gE(field).value.length > maxlimit) 
				gE(field).value = gE(field).value.substring(0, maxlimit);

			else 
				gE(countfield).value = 0 + gE(field).value.length;
		}
//*********************************************************
function excluir(id, url)
{
	if(confirm("Deseja realmente excluir?"))
	{
		a = url + id
		// alert(a)
		window.location = url + id
	}
}


function pagina(endereco){
	window.location = endereco + ".asp"
}

//*********************************************************

function verificaNews(){
	if(gE("inputnome").value == "Nome")
	{
		alert("Por favor, preencha o seu nome!");
		gE("inputnome").focus();
		return false;
	}
	if(gE("input").value == "E-mail")
	{
		alert("Por favor, preencha o seu e-mail!");
		gE("input").focus();
		return false;
	}
	 return mail('input');
}

//*********************************************************
function verifica()
{
	var checks = document.getElementsByTagName("input");
	
	for(j=0;j<checks.length;j++)
		{
			if(checks[j].getAttribute("obrig") == "sim")
			{
				if(checks[j].value == "")
				{
					alert("Por favor, preencha o campo " + checks[j].getAttribute("nome") + " !");
					checks[j].focus();
					return false;
				}
			}
		}
	

var checks1 = document.getElementsByTagName("input");
var marcado1 = "";
var radios = "";
	
	for(i=0;i<checks1.length;i++)
	{
		if(checks1[i].getAttribute("type") == "radio")
		{
			radios = "sim";
			if(checks1[i].checked == true)
			{
				marcado1 = "sim";
			}
		}
								  
	}
	
	if(marcado1 != "sim" && radios != "")
	{
		alert("Por favor, selecione o sexo!");
		return false;
	}

	var checks1 = document.getElementsByTagName("select");
	
	for(j=0;j<checks1.length;j++)
		{
			if(checks1[j].getAttribute("obrig") == "sim")
			{
				if(checks1[j].value == "")
				{
					alert("Por favor, preencha o campo " + checks1[j].getAttribute("nome") + " !");
					checks1[j].focus();
					return false;
				}
			}
		}	



var checks2 = document.getElementsByTagName("textarea");

for(j=0;j<checks2.length;j++)
    {
        if(checks2[j].getAttribute("obrig") == "sim")
        {
            if(checks2[j].value == "")
            {
                alert("Por favor, preencha o campo " + checks2[j].getAttribute("nome") + " !");
                checks2[j].focus();
                return false;
            }
        }


	}
	if(document.getElementById("email")){
		return mail('email');
	}
	return mail('email3');
}

//*********************************************************
function verifica1()
{
	var checks = document.getElementsByTagName("input");
	
	for(j=0;j<checks.length;j++)
		{
			if(checks[j].getAttribute("obrig") == "sim")
			{
				if(checks[j].value == "")
				{
					alert("Por favor, preencha o campo " + checks[j].getAttribute("nome") + " !");
					checks[j].focus();
					return false;
				}
			}
		}
	

var checks1 = document.getElementsByTagName("input");
var marcado1 = "";
var radios = "";
	
	for(i=0;i<checks1.length;i++)
	{
		if(checks1[i].getAttribute("type") == "radio")
		{
			radios = "sim";
			if(checks1[i].checked == true)
			{
				marcado1 = "sim";
			}
		}
								  
	}
	
	if(marcado1 != "sim" && radios != "")
	{
		alert("Por favor, selecione o sexo!");
		return false;
	}

	var checks1 = document.getElementsByTagName("select");
	
	for(j=0;j<checks1.length;j++)
		{
			if(checks1[j].getAttribute("obrig") == "sim")
			{
				if(checks1[j].value == "")
				{
					alert("Por favor, preencha o campo " + checks1[j].getAttribute("nome") + " !");
					checks1[j].focus();
					return false;
				}
			}
		}	



var checks2 = document.getElementsByTagName("textarea");

for(j=0;j<checks2.length;j++)
    {
        if(checks2[j].getAttribute("obrig") == "sim")
        {
            if(checks2[j].value == "")
            {
                alert("Por favor, preencha o campo " + checks2[j].getAttribute("nome") + " !");
                checks2[j].focus();
                return false;
            }
        }


	}

		if(!checkMail(gE('seu_email').value))
		{
			alert("Seu e-mail inválido!");
			document.getElementById('seu_email').focus();
			return false;
		}


		if(!checkMail(gE('email_amigo').value))
		{
			alert("E-mail do amigo inválido!");
			document.getElementById('email_amigo').focus();
			return false;
		}

	
}


//*********************************************************
var numero;
function numeros(obj)
{
var valor = document.getElementById(obj).value;
var char = valor.substr(valor.length-1);
var numeros = new Array();
numeros[0] = "1";
numeros[1] = "2";
numeros[2] = "3";
numeros[3] = "4";
numeros[4] = "5";
numeros[5] = "6";
numeros[6] = "7";
numeros[7] = "8";
numeros[8] = "9";
numeros[9] = "0";
numeros[11] = ".";
numeros[12] = "-";
numeros[13] = "/";

for (i=0;i<numeros.length;i++)
{
if(char == numeros[i])
{
numero = "sim";
break;
}
else
{
numero = "nao";
}
}

if (numero == "sim")
{
document.getElementById(obj).value = valor;
}
else
{
document.getElementById(obj).value = valor.substr(0,valor.length-1); 
}
}

//*********************************************************
function verifica_termos(){
		 
		 if (document.getElementById('letra').value == ""){
			alert("Por favor, preencha o campo letra!"); 
			return false;
		 }
		 
		  if (document.getElementById('titulo').value == ""){
			alert("Por favor, preencha o campo titulo!"); 
			return false;
		 }

}


//*********************************************************

function addFav(){
var url="http://www.tecnologiaparatodos.com.br/";
var title="Tecnologia para Todos";
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);}
}

//*********************************************************

