AC_FL_RunContent = 0;


var isIE  = (navigator.userAgent.indexOf("MSIE") != -1) ? true : false;
var isIE8 = (navigator.userAgent.indexOf("MSIE 8") != -1) ? true : false;
var isIE7 = (navigator.userAgent.indexOf("MSIE 7") != -1) ? true : false;
var isIE6 = (navigator.userAgent.indexOf("MSIE 6") != -1) ? true : false;
var isIE5 = (navigator.userAgent.indexOf("MSIE 5") != -1) ? true : false;
var isOPERA = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
var isFIREFOX = (navigator.userAgent.indexOf("Firefox") != -1) ? true : false;
var isCHROME = (navigator.userAgent.indexOf("Chrome") != -1) ? true : false;
var isSAFARI = false;
if(isCHROME==false) {
	var isSAFARI = (navigator.userAgent.indexOf("Safari") != -1) ? true : false;
}


document.write('<scr'+'ipt language="javascr'+'ipt" src="js/AC_RunActiveContent.js"></scr'+'ipt>');

var eventosAguardando = [];

function AdicionaEvento(node, event, handler){
	if (EncontrarEventos(node, event, handler) != null){
		return;
	}
	if (!node.addEventListener){
		node.attachEvent('on' + event, handler);
	}else{
		node.addEventListener(event, handler, false);
	}
	eventosAguardando.push({node: node, event: event, handler: handler});
}

function EncontrarEventos(node, event, handler){
	var i;
	for (i in eventosAguardando){
		if (eventosAguardando[i].node == node && eventosAguardando[i].event == event && eventosAguardando[i].handler == handler){
			return i;
		}
	}
	return null;
}


function P(val){
	document.write(val);	
}

function Area(url){
	window.location = 'index.php?p='+url;	
}

function cProjetos(url) {
	window.location = 'index.php'+url;
}

function Logout() {
	window.location = 'inc/logout.php';
}

function AlterarSenha() {
	window.location = 'index.php?p=16';
}

function BaixarArquivo(id){
	window.location = 'arquivo.php?id='+id;
}

function overIcon(iconItem) {
	iconItem.className='over';
}
function outIcon(iconItem) {
	iconItem.className='out';
}

function ResponderMSG(as) {
	parent.document.getElementById('assunto').value = 'RES: '+as;
	
	var iframeEl = parent.document.getElementById('leitura');
	if(iframeEl.contentDocument) { // DOM
    	z = iframeEl.contentDocument.body;
	} else if (iframeEl.contentWindow) { // IE win
    	z = iframeEl.contentWindow.document.body;
	}
	
	b = z.innerHTML;	
	a = '<br><br> -------------------------------------------------------------------- <br> <b>Mensagem original:</b> <br><br>';
	resp = a+b;
	
	var iframeEl = parent.document.getElementById('RHTMLHtml');
	if(iframeEl.contentDocument) { // DOM
    	z = iframeEl.contentDocument.body;
	} else if (iframeEl.contentWindow) { // IE win
    	z = iframeEl.contentWindow.document.body;
	}
	z.innerHTML = resp;
	
	parent.document.getElementById('assunto').focus();
}

function ExibirMSG(id) {
	url = 'inc/leitura.php?id='+id;
	parent.document.getElementById('leitura').src = url;
	if(parent.document.getElementById('leitura').style.height=='0px') {
		vel = 5;
		for (i = 0; i <= 100; i++) {
			setTimeout("Altura('leitura',"+(i*4)+")", (i * vel));
		}
	}
}

function FechaMSG() {
		vel = 5;
		for (i = 0; i <= 100; i++) {
			setTimeout("Altura('leitura',"+((100-i)*4)+")", (i * vel));
		}		
}

function AtualizaMSG() {
	url = parent.document.getElementById('mensagens').src;
	parent.document.getElementById('mensagens').src = url;
}

function Altura(obj,px) {
	parent.document.getElementById(obj).style.height = px+'px';
}


function isEmail(text){
   var    arroba = "@",
          ponto = ".",
         posponto = 0,
         posarroba = 0;
   
    if (text =="") return false;
   
    for (var indice = 0; indice < text.length; indice++){
       if (text.charAt(indice) == arroba) {
          posarroba = indice;
            break;
       }
    }
   
   for (var indice = posarroba; indice < text.length; indice++){
      if (text.charAt(indice) == ponto) {
         posponto = indice;
           break;
      }
   }
   if (posponto == 0 || posarroba == 0) return false;
   if (posponto == (posarroba + 1)) return false;
   if ((posponto + 1) == text.length) return false;
   return true;
}



function verificaForm() {
	erro = false;
	nome = document.getElementById('nome').value;
	mail = document.getElementById('mail').value;
	fone = document.getElementById('fone').value;
	desc = document.getElementById('desc').value;
	
	if(nome==''){
		erro = true	
	}
	if(mail==''){
		erro = true	
	}
	if(fone==''){
		erro = true	
	}
	if(desc==''){
		erro = true	
	}

	if(erro==false) {
		if(isEmail(mail)) {
			document.form_cont.submit();
		}else{
			alert('O email é inválido.');	
		}
	}else{
		alert('Os campos devem ser preenchidos.');	
	}
}

function verificaAlterarSenha() {
	erro = false;
	atual = document.getElementById('atual').value;
	pwd = document.getElementById('pwd').value;
	cpwd = document.getElementById('cpwd').value;
	if(atual==''){
		erro = true	
	}
	if(pwd==''){
		erro = true	
	}
	if(cpwd==''){
		erro = true	
	}
	if(erro==false) {
		if(pwd==cpwd) {
			document.form_new_pwd.submit();
		}else{
			alert('A senha não corresponde com sua confirmação.');		
		}
	}else{
		alert('Os campos devem ser preenchidos.');	
	}
}

function verificaFormCad() {
	erro = false;
	nome = document.getElementById('nome').value;
	mail = document.getElementById('mail').value;
	cmail = document.getElementById('cmail').value;
	fone = document.getElementById('fone').value;
	celu = document.getElementById('cel').value;
	cida = document.getElementById('cid').value;
	
	if(nome==''){
		erro = true	
	}
	if(mail==''){
		erro = true	
	}
	if(cmail==''){
		erro = true	
	}
	if(fone==''){
		erro = true	
	}
	if(celu==''){
		erro = true	
	}
	if(cida==''){
		erro = true	
	}

	if(erro==false) {
		if(mail==cmail) {
			if(isEmail(mail)) {
				document.form_cad.submit();
			}else{
				alert('O email é inválido.');	
			}
		}else{
			alert('O email não corresponde a sua confirmação.');		
		}
	}else{
		alert('Os campos devem ser preenchidos.');	
	}
}


function verificaLogin() {
	erro = false;
	user = document.getElementById('user').value;
	pswd = document.getElementById('pswd').value;

	if(user==''){
		erro = true	
	}
	if(pswd==''){
		erro = true	
	}

	if(erro==false) {
		document.form_login.submit();
	}else{
		alert('Para entrar, insira seu nome e senha!');	
	}

}

function verificaLost() {
	email = document.getElementById('email').value;
	if(email=='') {
		alert('Digite seu E-mail!');
	}else{
		document.form_lost.submit();	
	}

}


function tecla(e) {
	var ikeycode;
	if(document.all) {
		ikeycode = e.keyCode;
	}else{
		ikeycode = e.which;
	}
	if (ikeycode == 13){
		if(document.form_login.user.value=="") {
			document.form_login.user.focus();
		} else {
			if(document.form_login.pswd.value=="") {
				document.form_login.pswd.focus();
			}else{
				document.form_login.submit();
			}
		}
	}
}

function teclaL(e) {
	var ikeycode;
	if(document.all) {
		ikeycode = e.keyCode;
	}else{
		ikeycode = e.which;
	}
	if (ikeycode == 13){
		if(document.form_lost.email.value=="") {
			document.form_lost.email.focus();
		} else {
			document.form_lost.submit();
		}
	}
}


function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}




function ExibirFotos(i) {
	larea = document.getElementById('LIGHTBOX_FOTOS');
	lframe = document.getElementById('LIGHTBOX_FOTOS_FRAME');
	lclose = document.getElementById('LIGHTBOX_FOTOS_CLOSE');
	lframe.src='swf/galeria.php?id='+i;
	
	var arrayPageSize = getPageSize();
	larea.style.width=arrayPageSize[0]+'px';
	larea.style.height=arrayPageSize[1]+'px';
	
	if(isIE6) {
		sc = getScrollXY();
		scm = sc[1];
	}else{
		if(isIE5) {
			sc = getScrollXY();
			scm = sc[1];
		}else{
			scm = '';	
		}
	}
	
	lframe.style.left = '50%';
	lframe.style.top = '50%';
	lframe.style.marginLeft = '-332px';
	lframe.style.marginTop = (-250)+scm+'px';
	
	lclose.style.left = '50%';
	lclose.style.top = '50%';
	
	
	lclose.style.marginLeft = (332-12)+'px';
	lclose.style.marginTop = (-(250+13))+scm+'px';
	
	
	Opacidade('LIGHTBOX_FOTOS',0);
	Largura('LIGHTBOX_FOTOS_FRAME',0);
	Esquerda('LIGHTBOX_FOTOS_FRAME', 0);
	Exibe('LIGHTBOX_FOTOS',1);
	Exibe('LIGHTBOX_FOTOS_FRAME',1);
	
	
	vel = 5;
	for (i = 0; i <= 40; i++) {
		setTimeout("Opacidade('LIGHTBOX_FOTOS'," + (i*2) + ")", i * vel);
	}
	delay = 200;
	vel = 2;
	for (i = 0; i <= 166; i++) {
		setTimeout("Largura('LIGHTBOX_FOTOS_FRAME'," + (i*4) + ")", (i * vel)+delay);
		setTimeout("Esquerda('LIGHTBOX_FOTOS_FRAME', -" + (i*2) + ")",(i * vel)+delay);
	}
	setTimeout("Largura('LIGHTBOX_FOTOS_FRAME',665)",(333 * vel)+delay);
	setTimeout("Esquerda('LIGHTBOX_FOTOS_FRAME', -332)",(333 * vel)+delay);
	delay = 866;
	setTimeout("Exibe('LIGHTBOX_FOTOS_CLOSE',1)", delay);
	
}



function OcultarFotos() {
	larea = document.getElementById('LIGHTBOX_FOTOS');
	lframe = document.getElementById('LIGHTBOX_FOTOS_FRAME');
	lclose = document.getElementById('LIGHTBOX_FOTOS_CLOSE');
	Exibe('LIGHTBOX_FOTOS_CLOSE',0);
	Exibe('LIGHTBOX_FOTOS_FRAME',0);
	vel = 5;
	for (i = 0; i <= 40; i++) {
		setTimeout("Opacidade('LIGHTBOX_FOTOS'," + ((40 - i)*2) + ")", (i * vel));
	}
	setTimeout("Exibe('LIGHTBOX_FOTOS',0)",(40*5)+delay);
}









function getPageSize(){
	
	
var xScroll, yScroll;
	
if (window.innerHeight && window.scrollMaxY) { 
	//xScroll = window.innerWidth + window.scrollMaxX;
	xScroll = document.body.scrollWidth;
	yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
	xScroll = document.body.scrollWidth;
	yScroll = document.body.scrollHeight;
} else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight){ // Explorer 6 strict mode
	xScroll = document.documentElement.scrollWidth;
	yScroll = document.documentElement.scrollHeight;
} else { // Explorer Mac...would also work in Mozilla and Safari
	xScroll = document.body.offsetWidth;
	yScroll = document.body.offsetHeight;
}

	
	var windowWidth, windowHeight;
	

	
var windowWidth, windowHeight;
if (self.innerHeight) { // all except Explorer
	if(document.documentElement.clientWidth){
		windowWidth = document.documentElement.clientWidth; 
		windowHeight = document.documentElement.clientHeight; 
	}else{
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
	windowWidth = document.documentElement.clientWidth;
	windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
	windowWidth = document.body.clientWidth;
	windowHeight = document.body.clientHeight;
} 



	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}


	if(xScroll < windowWidth){	
		pageWidth = windowWidth;	
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}


















/* Metodo para atribuir Opacidade em vários navegadores */
function Opacidade(objDIV,nivel) {
	var elFX = document.getElementById(objDIV).style;
	elFX.opacity = nivel / 100;
	elFX.MozOpacity = nivel / 100;
	elFX.KhtmlOpacity = nivel / 100;
	if(isIE) {
		elFX.filter = "alpha(opacity=" + nivel + ");";
	}
}    

/* Metodo para Ocultar/Exibir a área do objeto */
function Exibe(objDIV, valor) {
	var elFX = document.getElementById(objDIV).style;
	if(valor==1) {
		elFX.display = 'block';
	}
	if(valor==0) {
		elFX.display = 'none';
	}
}



/* Metodo Para atribuir a área do objeto */
function Largura(objDIV, valor) {
	var elFX = document.getElementById(objDIV).style;
	elFX.overflow = 'hidden';
	elFX.whiteSpace = 'nowrap';
	elFX.width = valor + 'px';
}

function Esquerda(objDIV, valor) {
	var elFX = document.getElementById(objDIV).style;
	elFX.marginLeft = valor + 'px';
}



