//Manipulador de Eventos: addEvent e removeEvent cross-browser
addEvent = function(o, e, f, s){
    var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a, c, d;
    r[r.length] = [f, s || o], o[e] = function(e){
        try{
            (e = e || event).preventDefault || (e.preventDefault = function(){e.returnValue = false;});
            e.stopPropagation || (e.stopPropagation = function(){e.cancelBubble = true;});
            e.target || (e.target = e.srcElement || null);
            e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0;
        }catch(f){}
        for(d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false));
        return e = null, !!d;
    }
};
removeEvent = function(o, e, f, s){
    for(var i = (e = o["_on" + e] || []).length; i;)
        if(e[--i] && e[i][0] == f && (s || o) == e[i][1])
            return delete e[i];
    return false;
};
//Fim do Manipulador de Eventos
// Insere Mascaras em campos de formulários
function maskInput(f, m) {
    function mask(e){
        var patterns = {"1": /[A-Z]/i, "2": /[0-9]/, "4": /[a-z]/i, "8": /./ },
            rules = { "a": 3, "A": 7, "9": 2, "C":5, "c": 1, "*": 8};
        function accept(c, rule){
            for(var i = 1, r = rules[rule] || 0; i <= r; i<<=1)
                if(r & i && patterns[i].test(c))
                    break;
                return i <= r || c == rule;
        }
        var k, mC, r, c = String.fromCharCode(k = e.key), l = f.value.length;
        (!k || k == 8 ? 1 : (r = /^(.)\^(.*)$/.exec(m)) && (r[0] = r[2].indexOf(c) + 1) + 1 ?
            r[1] == "O" ? r[0] : r[1] == "E" ? !r[0] : accept(c, r[1]) || r[0]
            : (l = (f.value += m.substr(l, (r = /[A|9|C|\*]/i.exec(m.substr(l))) ?
            r.index : l)).length) < m.length && accept(c, m.charAt(l))) || e.preventDefault();
    }
    for(var i in !/^(.)\^(.*)$/.test(m) && (f.maxLength = m.length), {keypress: 0, keyup: 1})
        addEvent(f, i, mask);
}
// Valida formulários
function testeForm(){
	mensagem = " ";
	if(f.nome.value=="" || f.nome.value.length<4)
		mensagem += "Corrija o campo Nome \n\r";
	if(f.email.value.length<10)
		mensagem += "Corrija o campo E-mail \n\r";
	if(f.telefone.value.length!=14)
		mensagem += "Corrija o campo Telefone \n\r";
	if(f.mensagem.value.length<20)
		mensagem += "Corrija o campo Mensagem \n\r";
	if(mensagem==" "){
		alert("Mensagem enviada com sucesso!");
		return true;
	}else{
		alert(mensagem);
		return false;
	}
}
// Fecha Banner Destaque
function fechaBanner(){
	document.getElementById("imagem").style.display = "none";
	document.getElementById("shadow").style.display = "none";
}

function hoje(){
	hoje = new Date()
	dia = hoje.getDate()
	dias = hoje.getDay()
	mes = hoje.getMonth()
	ano = hoje.getYear()
	if (dia < 10)
	{
	   dia = "0" + dia
	}

	function CriaArray (n)
	{
	   this.length = n
	}

	if (navigator.appName == 'Netscape')
	{
		if (ano >= 100)
		{
				x = ano - 100
				novoano = "200" + x
		}

	}
	else if (navigator.appName == 'Microsoft Internet Explorer')
	{
		if (ano >= 100)
		{
				novoano = ano
			}
	}

	NomeDia = new CriaArray(7)
	NomeDia[0] = "Domingo"
	NomeDia[1] = "Segunda-Feira"
	NomeDia[2] = "Terça-Feira"
	NomeDia[3] = "Quarta-Feira"
	NomeDia[4] = "Quinta-Feira"
	NomeDia[5] = "Sexta-Feira"
	NomeDia[6] = "Sábado"

	NomeMes = new CriaArray(12)
	NomeMes[0]  = "Janeiro"
	NomeMes[1]  = "Fevereiro"
	NomeMes[2]  = "Março"
	NomeMes[3]  = "Abril"
	NomeMes[4]  = "Maio"
	NomeMes[5]  = "Junho"
	NomeMes[6]  = "Julho"
	NomeMes[7]  = "Agosto"
	NomeMes[8]  = "Setembro"
	NomeMes[9]  = "Outubro"
	NomeMes[10] = "Novembro"
	NomeMes[11] = "Dezembro"
	
	dataAtual = NomeDia[dias] + ", " + dia + " de " + NomeMes[mes] + " de " + novoano;
	return dataAtual;
}

function StartImage(URL){
	w = 500+5*2+5+20;
	h = 400+5*2+80;
	imgwindow = window.open(URL,"imgwindow"," scrollbar=no, toolbar=no, fullscreen=no, resizable=yes,width="+w+",height="+h);
	imgwindow.focus();
}