var s;

function CarregarPagina(pagina, div, site, aux, AuxUrl){
	
	var pg = ""
	caminho = "http://www.cocvitoria.com.br/"	
	pg = caminho + 'funcs/pagina.asp?div='+ div +'&IdSite='+ site +'&aux='+ aux +'&pagina='+ escape(pagina) +"&AuxUrl="+ escape(AuxUrl)
	
	window.info.location.href = pg;
}


function redim(iframe)
{
	if(navigator.appName=="Microsoft Internet Explorer")
		var altura = parseInt(document.body.scrollHeight);
	else
		var altura = parseInt(document.body.offsetHeight);

	parent.document.getElementById(iframe).style.height = altura + 'px';
}

function ancora(obj){

	e = "#"+ obj;
	titulo('Sistema COC de Ensino');
}

function AbreDivMenu(IDMenu){
	if(document.getElementById('mm'+IDMenu).style.display=='none'){
		document.getElementById('mm'+IDMenu).style.display = 'block';
	}
	else{
		document.getElementById('mm'+IDMenu).style.display = 'block';
		document.getElementById('mm'+IDMenu).style.display = 'none';
	}
}

function ValidaEnqueteJornal(){
	
	var f    = document.forms['EnqueteSite']
	
	f.target = 'enquete';
	f.action = 'http://www.cocvitoria.com.br/funcs/enquete.asp'
	f.submit();	

}

function ValidaBuscaJornal(){

	var f = document.forms['busca'];

	if(f.busca.value == ''){
		alert('Digite uma palavra!');
		f.busca.focus();
		return;
	}
	
	if(f.busca.value.length < 5){
		alert('Digite uma palavra com no mnimo 5 letras!');
		f.busca.focus();
		return;
	}	

	f.action = '../funcs/buscaNew.asp'
	f.target = 'info';
	f.submit();
	f.busca.value = '';

}

function EnqueteResultado(IdSite, site){
	
	var f    = document.forms['EnqueteSite']

	
	f.target = 'enquete';
	f.action = 'http://www.cocvitoria.com.br/enquete/EnqueteResultado.asp?bt=1&IdSiteEnquete='+ IdSite +'&IdSite='+ site
	f.submit();	
}

// ---------- Muda Fundo
function mudaFundo(cor){
	document.body.style.backgroundColor = cor;
}


// ---------- Muda z-index do topo
function trazSubMenu(){
	document.getElementById('divSubMenu').style.zIndex = 5;
}

function voltaSubMenu(){
	document.getElementById('divSubMenu').style.zIndex = -1;
}

// ------------ Conta caracteres
function Conta(formulario){
	var form = document.forms[formulario];
	total = form.mensagem.value.length;
	form.mensagem.focus();
	if(total <= 3000){
		form.total.value = 'Máximo de 3000 caracteres. '+ total +' caracteres já digitados'
	}
	else{
		form.total.value = 'Máximo de 3000 caracteres. 3000 caracteres já digitados'
		form.mensagem.value = form.msg.value.substring(0,3000);
		alert('Excedido o número máximo de caracteres.');
		return;
	}
}

// ---------- Funo genrica para abrir div
function AbreDiv(obj){	
	var div;
	div = obj;
	
	if (document.getElementById(div).style.display == "none"){
		document.getElementById(div).style.display = "block";
		}
	else{
		document.getElementById(div).style.display = "none";
    	}		
}

function AbreDiv2(IDMenu){
	if(document.getElementById('SubMenuTopo_'+IDMenu).style.display=='none'){
		document.getElementById('SubMenuTopo_'+IDMenu).style.display = '';
		document.getElementById('SubMenu_'+IDMenu).style.display = '';
		document.getElementById('SubMenuRodape_'+IDMenu).style.display = '';
	}
	else{
		document.getElementById('SubMenuTopo_'+IDMenu).style.display = 'none';
		document.getElementById('SubMenu_'+IDMenu).style.display = 'none';
		document.getElementById('SubMenuRodape_'+IDMenu).style.display = 'none';
	}
}


function MudaCor(Menu,Cor,Muda){
	if(Muda==1){
		document.getElementById(Menu).style.backgroundColor = '#b6b6b6'
	}
	else{
		document.getElementById(Menu).style.backgroundColor = Cor
	}
}


// ---------- Funo genérica para limpar div
function LimpaDiv(obj){	
	var div;
	div = obj;
	document.getElementById(div).innerHTML = ' ';
}


// ---------- Funções Remote
function Mensagem(mode){
		if (!mode)
			document.getElementById('aguarde').style.display = "block";
		else
			document.getElementById('aguarde').style.display = "none";
}

// ---------- Funções genrica para abrir janelas
function AbreJanela(arq,alt,lag,res,barra){
	if(barra=='')
		barra = 0;
	if(navigator.appName=="Microsoft Internet Explorer")
		window.open(arq,'Condi','fullscreen=0,channelmode=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+ barra +',resizable=' + res + ',width=' + lag + ',height=' + alt + ',top=100,left=100');
	else
		window.open(arq,'Condi','location=0,fullscreen=0,menubar=0,toolbar=0,status=0,screenX=100,screenY=100,scrollbars='+ barra +',resizable=1,width=' + lag + ',height=' + alt);
}


function ValidaAno(iAno){
	if (!isNaN(iAno)) 	{
		if (inRange(iAno, 01, 1900-AnoAtual()+10)) 
			return true;
		if (inRange(iAno, 1901, AnoAtual()+10)) 
			return true;
	} else  {
		return false;
	}
}

function inRange(iNum, iMin, iMax) {
	if (!isNaN(iNum)) {	
		if (iNum>=iMin && iNum <= iMax) 
			return true;
		else
			return false;
	} else 
		return false;
}

function AnoAtual() {
   d = new Date();
   return d.getYear();
}

function validaFaleConosco2(){
					
		var form = document.forms['FaleConosco']
					
		if (form.nome.value == '' || form.nome.value.length < 5){
			alert('Preencha corretamente o campo nome.');
			form.nome.focus();
			return;
		}
		if (form.email.value == '' || form.email.value.indexOf(".") < 2 || form.email.value.indexOf("@") < 2){
			alert('Preencha corretamente o campo e-mail.');
			form.email.focus();
			return;
		}
		if (form.assunto.value == ''){
			alert('Preencha corretamente o campo assunto.');
			form.assunto.focus();
			return;
		}
		if (form.mensagem.value == ''){
			alert('Preencha corretamente o campo mensagem.');
			form.mensagem.focus();
			return;
		}
					
		form.target = 'auxiliar';
		form.action = 'http://www.cocvitoria.com.br/faleconosco/enviar.asp';
		form.submit();
								
		alert('Mensagem enviada com sucesso!');
		form.reset();
}

// ---------- Funo flutuante da DIV Aguarde
function DivFlutuante()
{
	var startX = resultado,
	startY = 305;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	function ml(id)
	{
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x;this.style.top=y;};
		el.x = startX;
		if (verticalpos=="fromtop")
		el.y = startY;
		else{
		el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		el.y -= startY;
		}
		return el;
	}
	window.stayTopLeft=function()
	{
		if (verticalpos=="fromtop"){
		var pY = ns ? pageYOffset : document.body.scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		else{
		var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 10);
	}
	ftlObj = ml("aguarde");
	stayTopLeft();
}

/////////////// Jornal COC On-Line

function AbreMidia(Midia, Tipo){
	if (Tipo == 1){
		window.open('http://www.jornal.coc.com.br/fotos/'+ Midia,'wind','toolbar=no,width=628,height=504,scrollbars=yes,resizable=no');
		return
	}
	if (Tipo == 2){
		window.location.href = 'http://www.jornal.coc.com.br/Fotos/' + Midia;
		return
	}
}

function AbreGaleria(Id, Nome){
	
	window.open('http://www.cocvitoria.com.br/galeria.asp?Id='+ Id +'&Nome='+ Nome,'wind','toolbar=no,width=645,height=553,scrollbars=yes,resizable=no');
	
}

function abre_scroll(arq,alt,lag,res){
	if(navigator.appName=="Microsoft Internet Explorer")
		window.open(arq,'Condi','fullscreen=0,channelmode=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=' + res + ',width=' + lag + ',height=' + alt + ',top=100,left=100');
	else 
		window.open(arq,'Condi','location=0,fullscreen=0,menubar=0,toolbar=0,status=0, scrollbars=1, screenX=100,screenY=100,resizable=' + res + ',width=' + lag + ',height=' + alt);
}

function abre_scroll1(arq,alt,lag,res){
	if(navigator.appName=="Microsoft Internet Explorer")
		window.open(arq,'Condi','fullscreen=0,channelmode=0,toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=' + res + ',width=' + lag + ',height=' + alt + ',top=100,left=100');
	else 
		window.open(arq,'Condi','location=0,fullscreen=0,menubar=0,toolbar=1,status=0, scrollbars=1, screenX=100,screenY=100,resizable=' + res + ',width=' + lag + ',height=' + alt);
}

/* Inicio funo hint  ****************************************************************************************/

// Aqui voc vai detectar os navegadores


 //  IF = 1 -> Esconde Texto
 //  IF = 2 -> Move o Texto
function Hint(objNome, action, Esquerda, Topo){ 
 	if (bIsIE) {
  		objHint = document.getElementById(objNome);
 	}
	 if (bIsNav) {
  		objHint = document.getElementById(objNome);
  		event = objHint;
 	}
 
 	switch (action){
  		case 1: //Esconde
   			objHint.style.visibility = "hidden";
   		break;
  		case 2: //Move
		   objHint.style.visibility = "visible";
		   objHint.style.left = xmouse - Esquerda;
		   objHint.style.top = ymouse + Topo;
   		break;
 	}		 
}


function RedMenu(){
	document.getElementById("RedMenu").style.height = 1000
	document.getElementById("RedMenu").style.display = 'block'
	document.getElementById("RedMenu").style.display = 'none'
}

function StatusDiv(obj,pStatus){	
	
	var div;
	
	div = obj;
	
	Status = pStatus;
	
	if(Status == 0) {
		document.getElementById(div).style.display = "none";
		document.getElementById('txtDetalhe').style.display = "block";
		document.getElementById('DVCont').style.display = "block";
		document.getElementById('btEnviar').style.display = "block";
		}
	else{
		document.getElementById(div).style.display = "block";
		document.getElementById('txtDetalhe').style.display = "none";
		document.getElementById('DVCont').style.display = "none";
		document.getElementById('btEnviar').style.display = "none";
    	}

}

function LimpaForm(obj){
	
	s = setInterval('ResetarForm("'+ obj +'")', 50)	
	
}