//MENU DORP DOWN
var cssdropdown={
disappeardelay: 250, 

dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all,

getposOffset:function(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
},

showhide:function(obj, e, visible, hidden){
if (this.ie || this.firefox)
this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
},

iecompattest:function(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
},

clearbrowseredge:function(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=this.ie && !window.opera? this.iecompattest().scrollLeft+this.iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=this.ie && !window.opera? this.iecompattest().scrollTop : window.pageYOffset
var windowedge=this.ie && !window.opera? this.iecompattest().scrollTop+this.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){ //move up?
edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) //up no good either?
edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
},

dropit:function(obj, e, dropmenuID){
if (this.dropmenuobj!=null) //hide previous menu
this.dropmenuobj.style.visibility="hidden"
this.clearhidemenu()
if (this.ie||this.firefox){
obj.onmouseout=function(){cssdropdown.delayhidemenu()}
this.dropmenuobj=document.getElementById(dropmenuID)
this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()}
this.dropmenuobj.onmouseout=function(){cssdropdown.dynamichide(e)}
this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()}
this.showhide(this.dropmenuobj.style, e, "visible", "hidden")
this.dropmenuobj.x=this.getposOffset(obj, "left")
this.dropmenuobj.y=this.getposOffset(obj, "top")
this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
}
},

contains_firefox:function(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
},

dynamichide:function(e){
var evtobj=window.event? window.event : e
if (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))
this.delayhidemenu()
else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
this.delayhidemenu()
},

delayhidemenu:function(){
this.delayhide=setTimeout("cssdropdown.dropmenuobj.style.visibility='hidden'",this.disappeardelay)
},

clearhidemenu:function(){
if (this.delayhide!="undefined")
clearTimeout(this.delayhide)
}
}



//função que abre a tabela e fecha
function sub1_abre(tabela){
    tabela = document.getElementById(tabela);
    if(tabela.style.display=="none"){
        tabela.style.display="block";
    } else {
        tabela.style.display="none";
    }
}

// coloca a data nas páginas
now = new Date();
day = new Object();
month = new Object();
day[0] = "Domingo";
day[1] = "Segunda-feira";
day[2] = "Terça-feira";
day[3] = "Quarta-feira";
day[4] = "Quinta-feira";
day[5] = "Sexta-feira";
day[6] = "Sabado";
month[0] = "Janeiro";
month[1] = "Fevereiro";
month[2] = "Março";
month[3] = "Abril";
month[4] = "Maio";
month[5] = "Junho";
month[6] = "Julho";
month[7] = "Agosto";
month[8] = "Setembro";
month[9] = "Outubro";
month[10] = "Novembro";
month[11] = "Dezembro";
year = now.getYear();
if (year < 1000) year += 1900;


  
//funções de confirmação de exclução do banco de dados!
function del()
{
if (window.confirm('Tem certeza que deseja Excluir?'))
{
	return true;
} else {
    return false;
}
}


//funções de confirmação de alteração do banco de dados!
function up()
{
if (window.confirm('Alterar o registro?'))
{
	return true;
} else {
    return false;
}
}




// função que valida o upload de fotos
function validaFoto() {
var arquivo = document.upload.file1.value;
if (arquivo=="" || arquivo.indexOf('.jpg',0)==-1 && arquivo.indexOf('.gif',0)==-1 && arquivo.indexOf('.png',0)==-1 && arquivo.indexOf('.JPG',0)==-1 && arquivo.indexOf('.GIF',0)==-1 && arquivo.indexOf('.PNG',0)==-1 )
	{
		alert("Escolha um arquivo válido!");
		document.upload.file1.focus();
		return false
	}else {


	imagem     = new Image();
	imagem.src = document.upload.file1.value;
	largura    = imagem.width;
	altura     = imagem.height;
			if (largura != 400 || altura != 300){
				alert("Sua imagem está com as seguintes medidas:\n Largura:"+largura+"px.\n Altura:"+altura+"px.\n\n Envie imagens com as medidas abaixo:\n Largura:400px. \n Altura:300px.");
				return false;

			}
		
			
	}
}


// função que valida o upload de fotos
function validaFoto1() {
var arquivo = document.upload.file1.value;
if (arquivo=="" || arquivo.indexOf('.jpg',0)==-1 && arquivo.indexOf('.gif',0)==-1 && arquivo.indexOf('.png',0)==-1 && arquivo.indexOf('.JPG',0)==-1 && arquivo.indexOf('.GIF',0)==-1 && arquivo.indexOf('.PNG',0)==-1 )
	{
		alert("Escolha um arquivo válido!");
		document.upload.file1.focus();
		return false
	}else {


	imagem     = new Image();
	imagem.src = document.upload.file1.value;
	largura    = imagem.width;
	altura     = imagem.height;
			if (largura != 400 || altura != 334){
				alert("Sua imagem está com as seguintes medidas:\n Largura:"+largura+"px.\n Altura:"+altura+"px.\n\n Envie imagens com as medidas abaixo:\n Largura:400px. \n Altura:334px.");
				return false;

			}
		
			
	}
}



// função que valida o upload de fotos
function validaFoto2() {
var arquivo = document.upload.file1.value;
if (arquivo=="" || arquivo.indexOf('.jpg',0)==-1 && arquivo.indexOf('.gif',0)==-1 && arquivo.indexOf('.png',0)==-1 && arquivo.indexOf('.JPG',0)==-1 && arquivo.indexOf('.GIF',0)==-1 && arquivo.indexOf('.PNG',0)==-1 )
	{
		alert("Escolha um arquivo válido!");
		document.upload.file1.focus();
		return false
	}else {


	imagem     = new Image();
	imagem.src = document.upload.file1.value;
	largura    = imagem.width;
	altura     = imagem.height;
			if (largura != 300 || altura != 440){
				alert("Sua imagem está com as seguintes medidas:\n Largura:"+largura+"px.\n Altura:"+altura+"px.\n\n Envie imagens com as medidas abaixo:\n Largura:300px. \n Altura:440px.");
				return false;

			}
		
			
	}
}



// coloca a barrinha entre a data
function Mascara (formato, keypress, objeto){
	campo = eval (objeto);
	if (formato=='data'){
		separador = '/'; 
		conjunto1 = 2;
		conjunto2 = 5;
		if (campo.value.length == conjunto1){
			campo.value = campo.value + separador;
		}
		if (campo.value.length == conjunto2){
			campo.value = campo.value + separador;
		}
	}
}





// valida inclusao de dados
function ValidaForm() {
var form = document.incluir
	copyValue();
	if (form.titulo.value !== "" & form.descricao.value !== "descrição" & form.descricao.value !== "" & form.descricao.value !== "<P>&nbsp;</P>" & form.data.value !== "" & form.data.value !== "dd/mm/aaaa") {
		OnFormSubmit();
	} else {
		if (form.titulo.value == ""){
			window.alert("Preencha o Título");
			form.titulo.focus();
			return false
		}
		if (form.subtitulo.value == ""){
			window.alert("Preencha o Sub-título");
			form.subtitulo.focus();
			return false
		}
			if (form.data.value == "" || form.data.value == "dd/mm/aaaa"){
			window.alert("Preencha a data de entrada");
			form.data.focus();
			return false
		}
			if (form.dataSaida.value == "" || form.dataSaida.value == "dd/mm/aaaa"){
			window.alert("Preencha a data de saída");
			form.dataSaida.focus();
			return false
		}
		if (form.descricao.value == "descrição" || form.descricao.value == ""|| form.descricao.value == "<P>&nbsp;</P>"){
			window.alert("Preencha a Descrição");
			return false
		}		
	}
}


// valida inclusao de dados
function ValidaCursos() {
var form = document.incluir
	copyValue();
	if (form.titulo.value !== "" & form.descricao.value !== "descrição" & form.descricao.value !== "" & form.descricao.value !== "<P>&nbsp;</P>" & form.preco.value!=="" & form.preco.value!=="9.999,99" ) {
		OnFormSubmit();
	} else {
		if (form.titulo.value == ""){
			window.alert("Preencha o Título");
			form.titulo.focus();
			return false
		}
		if (form.subtitulo.value == ""){
			window.alert("Preencha o Sub-título");
			form.subtitulo.focus();
			return false
		}
		
		if (form.preco.value == "" || form.preco.value == "9.999,99"){
			window.alert("Preencha o Preço");
			form.preco.focus();
			return false
		}
		if (form.descricao.value == "descrição" || form.descricao.value == ""|| form.descricao.value == "<P>&nbsp;</P>"){
			window.alert("Preencha a Descrição");
			return false
		}		
	}
}



// valida inclusao de dados
function ValidaHorarios() {
var form = document.incluir
		if (form.data.value == "" || form.data.value == "dd/mm/aaaa"){
			window.alert("Preencha a data de início");
			form.data.focus();
			return false
		}
		if (form.datafim.value == "" || form.datafim.value == "dd/mm/aaaa"){
			window.alert("Preencha a data de término");
			form.datafim.focus();
			return false
		}
		
		if (form.hora.value == "" || form.hora.value == "00h00"){
			window.alert("Preencha a Horário de início");
			form.hora.focus();
			return false
		}
		if (form.hora.value.length < 5 ){
			window.alert("Preencha o horário de início corretamente. Número de caracteres inválido");
			form.hora.focus();
			return false
		}
		if (form.horafim.value == "" || form.horafim.value == "00h00"){
			window.alert("Preencha a Horário de término");
			form.horafim.focus();
			return false
		}
		if (form.horafim.value.length < 5 ){
			window.alert("Preencha o horário de término corretamente. Número de caracteres inválido");
			form.horafim.focus();
			return false
		}
}













//editor html
var eb = document.all;
	eb._editor = window.frames['EditorHTML'];

function initToolBar(ed) {
	var eb = document.all;
	if (ed!=null) {
		eb._editor = window.frames['EditorHTML'];
	}
}
function doFormat(what) {
	var eb = document.all;
	eb._editor.execCommand(what, arguments[1]);
}
function swapMode() {
	var eb = document.all._editor;
 	eb.swapModes();
}
function create() {
	var eb = document.all;
	eb._editor.newDocument();
}
function newFile(){
	create();
}
function makeUrl(){
	sUrl = document.all.what.value + document.all.url.value;
	doFormat('CreateLink',sUrl);
}
function SwapView_OnClick(){
  if(document.all.btnSwapView.value == "Ver Html"){
		var sMes = "Ver Editor";
	} else {
		var sMes = "Ver Html"
  }
	document.all.btnSwapView.value = sMes;
	swapMode();
}
function OnFormSubmit(){
	copyValue();

  }
function validaTexto() {
	eb._editor.validaTexto()
}		
function copyValue() {
	var theHtml = "" + document.frames("EditorHTML").document.frames("textEdit").document.body.innerHTML + "";
	document.all.descricao.value = theHtml;
}














function validaRevenda() {
var form = document.incluir
	copyValue();
	if (form.nome.value !== "" & form.empresa.value !== "" & form.email.value !== "" & form.telefone.value !== "" & form.telefone.value !== "99 9999-9999" & form.endereco.value !== "" & form.cidade.value !== "" & form.estado.value !== "" & form.descricao.value !== "descrição" & form.descricao.value !== "" & form.descricao.value !== "<P>&nbsp;</P>") {
		OnFormSubmit();
	} else {
		if (form.nome.value == ""){
			window.alert("Preencha o Nome");
			form.nome.focus();
			return false
		}
		if (form.empresa.value == ""){
			window.alert("Preencha a Empresa");
			form.empresa.focus();
			return false
		}
		if (form.email.value == ""){
			window.alert("Preencha o Email");
			form.email.focus();
			return false
		}
		if (form.email.value.indexOf('@',0)==-1 || form.email.value.indexOf('.',0)==-1)
		{
		alert("E-mail inválido!")
		form.email.focus()
		return false
		}
		if (form.telefone.value == "" || form.telefone.value == "99 9999-9999"){
			window.alert("Preencha o Telefone");
			form.telefone.focus();
			return false
		}
		if (form.telefone.value.length < 12 ){
			window.alert("Preencha o Telefone corretamente. Número de caracteres inválido");
			form.telefone.focus();
			return false
		}
		if (form.endereco.value == ""){
			window.alert("Preencha o Endereço");
			form.endereco.focus();
			return false
		}
		if (form.cidade.value == "" ){
			window.alert("Preencha a Cidade");
			form.cidade.focus();
			return false
		}
		if (form.estado.value == "" ){
			window.alert("Escolha o Estado");
			form.estado.focus();
			return false
		}
			if (form.descricao.value == "descrição" || form.descricao.value == ""|| form.descricao.value == "<P>&nbsp;</P>"){
			window.alert("Preencha a Experiência");
			return false
		}
		
	}
	
}




function validaContato() {
var form = document.incluir

		if (form.nome.value == ""){
			window.alert("Preencha o Nome");
			form.nome.focus();
			return false
		}
		if (form.email.value == ""){
			window.alert("Preencha o Email");
			form.email.focus();
			return false
		}
		if (form.email.value.indexOf('@',0)==-1 || form.email.value.indexOf('.',0)==-1)
		{
		alert("E-mail inválido!")
		form.email.focus()
		return false
		}
}



//funcao que coloca o traço no tel
function telCel (formato, keypress, objeto){
	campo = eval (objeto);
	if (formato=='telefone'){
		traco = '-'; 
		espaco = ' ';
		conjunto1 = 2;
		conjunto2 = 7;
		if (campo.value.length == conjunto1){
			campo.value = campo.value + espaco;
		}
		if (campo.value.length == conjunto2){
			campo.value = campo.value + traco;
		}
	}
}	

//funcao que coloca o traço no tel
function cepTraco(formato, keypress, objeto){
	campo = eval (objeto);
	if (formato=='cep'){
		traco = '-'; 
		conjunto1 = 5;
		if (campo.value.length == conjunto1){
			campo.value = campo.value + traco;
		}
	}
}


function validaCadastro() {
var form = document.cadastro
		if (form.nome.value == ""){
			window.alert("Preencha o Nome");
			form.nome.focus();
			return false
		}
		if (form.email.value == ""){
			window.alert("Preencha o Email");
			form.email.focus();
			return false
		}
		if (form.email.value.indexOf('@',0)==-1 || form.email.value.indexOf('.',0)==-1)
		{
		alert("E-mail inválido!")
		form.email.focus()
		return false
		}
		if (form.cpf.value == ""){
			window.alert("Preencha o CPF");
			form.cpf.focus();
			return false
		}
		if (form.endereco.value == ""){
			window.alert("Preencha o Endereço");
			form.endereco.focus();
			return false
		}
		if (form.numero.value == ""){
			window.alert("Preencha o Número");
			form.numero.focus();
			return false
		}
		if (form.cep.value == "" || form.cep.value == "99999-999"){
			window.alert("Preencha o Cep");
			form.cep.focus();
			return false
		}
		if (form.cep.value.length < 9 ){
			window.alert("Preencha o Cep corretamente. Número de caracteres inválido");
			form.cep.focus();
			return false
		}
		if (form.bairro.value == ""){
			window.alert("Preencha o Bairro");
			form.bairro.focus();
			return false
		}
		if (form.cidade.value == "" ){
			window.alert("Preencha a Cidade");
			form.cidade.focus();
			return false
		}
		if (form.telefone.value == "" || form.telefone.value == "99 9999-9999"){
			window.alert("Preencha o Telefone");
			form.telefone.focus();
			return false
		}
		if (form.telefone.value.length < 12 ){
			window.alert("Preencha o Telefone corretamente. Número de caracteres inválido");
			form.telefone.focus();
			return false
		}
		if (form.estado.value == "" ){
			window.alert("Escolha o Estado");
			form.estado.focus();
			return false
		}
	}

	
//coloca dois pontos entre a hora
function MascaraHora (formato, keypress, objeto){
	campo = eval (objeto);
	if (formato=='hora'){
		separador = 'h'; 
		conjunto1 = 2;
		if (campo.value.length == conjunto1){
			campo.value = campo.value + separador;
		}
		
	}
}



