var is=new function (){
	this.VER=navigator.appVersion
	this.AGENT=navigator.userAgent
	this.DOM=document.getElementById?1:0
	this.IE=(document.all && !this.DOM)?1:0;
	this.MAC=this.AGENT.indexOf("Mac")>-1
	this.NS6=document.getElementById&&!document.all?1:0
	this.NS4=(document.layers && !this.DOM)?1:0;
	this.OPERA=this.AGENT.indexOf('Opera')>-1
	return this
}
	
function getElement(id){
	if (is.DOM)	return document.getElementById(id)
	else
	if (is.IE) 	return eval("document.all."+id)
	else
	if (is.NS)	return eval("document."+id)
}

function showhide(id) {
	obj = getElement(id);
	viz =  obj.style.display;
    if (viz == 'block' ) {
    obj.style.display = "none";
    } else {
	obj.style.display = "block";
    }   
}

function bookmarksite(title,url){
if (window.sidebar)
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)
	window.external.AddFavorite(url, title);
}

// funções menu lateral
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	var ck = name+"="+value+expires+"; path=/";
	document.cookie = ck;
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i<ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return '60';
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}

function showhidemenu(id,artigo,url) {
obj = getElement('m'+id);
viz =  obj.style.display;
    if (viz == 'block' ) {
		obj.style.display = "none";
		nome='';
    } else {
		obj.style.display = "block";
		if(artigo==1)
			document.location.href=url;
		nome = id;
    } 
	createCookie('menux', nome, '200');  
}
// funções menu lateral

function Imprimir()
{
var a = window. open('','','scrollbars=yes,width=20,height=20');

a.document.open("text/html");
a.document.write('<html>\n<head>\n<link rel="stylesheet" href="/css/main.css" media="all" type="text/css" />\n<style>\n.noprint{display:none}\n<\/style>\n</head>\n<body style="padding-left:20px;background-image:none;background-color:#FFFFFF;">\n');
a.document.write('<table align="left" width="100%" border="0" cellpadding="0" cellspacing="0" style="height:114px;">\n<tr>\n<td>\n<img align="absmiddle" src="/images/logotipo_print.jpg" border="0" alt="" />\n');
a.document.write('<tr>\n<td>\n');
a.document.write(document.getElementById('tbl_print').innerHTML);
a.document.write('\n<\/td>\n<\/tr>\n');
a.document.write('<\/table>\n');
a.document.write('<\/body>\n<\/html>');
a.document.close();
a.print();
}

function modifyimage(loadarea, imagemx){
if (document.getElementById){
		var imgobj=document.getElementById(loadarea);
		if (document.all) {
			imgobj.style.filter="blendTrans(duration=0.7)";
			imgobj.filters.blendTrans(duration=5).Apply();
			imgobj.filters.blendTrans.Play();
			imgobj.src=imagemx;
		}else{
			imgobj.src=imagemx;
		}
	}
	return false;
}

/* AJAX */

var ajaxObjects = new Array();
var ajaxObjectsDelayProtect = new Array();


function showContent(divobj,index,url,fnc_completo)
{
	if (ajaxObjectsDelayProtect[url] == index){divobj.innerHTML = ajaxObjects[index].response;	}
	if (fnc_completo)eval(fnc_completo);
}

function showWaitMessage(divobj)
{
	divobj.innerHTML = '<p align="center">A carregar dados...<\/p>';
}

function getContent(url,divobj,opt,fnc_completo,params)
{
	var ajaxIndex = ajaxObjects.length;
	ajaxObjectsDelayProtect[url] = ajaxIndex;
	ajaxObjects[ajaxIndex] = new sack(url);
	ajaxObjects[ajaxIndex].requestFile = url;
	ajaxObjects[ajaxIndex].onCompletion = function() {showContent(divobj,ajaxIndex,url,fnc_completo)};
	ajaxObjects[ajaxIndex].onLoading = function() {showWaitMessage(divobj)};
	ajaxObjects[ajaxIndex].onError = function() {alert('Erro de ligação. Por favor tente novamente.')};
	ajaxObjects[ajaxIndex].onFail = function() {alert('Erro de ligação. Por favor tente novamente.')};
	ajaxObjects[ajaxIndex].runAJAX();
}


function getContent2(url,divobj,opt,fnc_completo,params)
{
	var ajaxIndex = ajaxObjects.length;
	ajaxObjectsDelayProtect[url] = ajaxIndex;
	ajaxObjects[ajaxIndex] = new sack(url);
	ajaxObjects[ajaxIndex].requestFile = url;
	ajaxObjects[ajaxIndex].onCompletion = function() {showContent(divobj,ajaxIndex,url,fnc_completo)};
	ajaxObjects[ajaxIndex].onError = function() {alert('Erro de ligação. Por favor tente novamente.')};
	ajaxObjects[ajaxIndex].onFail = function() {alert('Erro de ligação. Por favor tente novamente.')};
	ajaxObjects[ajaxIndex].runAJAX();
}

function getContent_post(url,params)
{
	var ajaxIndex = ajaxObjects.length;
	ajaxObjectsDelayProtect[url] = ajaxIndex;
	ajaxObjects[ajaxIndex] = new sack(url);
	ajaxObjects[ajaxIndex].requestFile = url;
	ajaxObjects[ajaxIndex].encodeURIString = false;
	ajaxObjects[ajaxIndex].runAJAX(params);
} 
/* AJAX */
function apagar_file(nome, pasta){
	getContent('/conteudos/apagar_file.htm?nome='+nome+'&pasta='+pasta, getElement('lista_files'), 1, 'x=1','&x=1');
}
	
	
	
//
// LARGE POPUP: Full-Screen Pop-up Functions
//
var myScrollWidth;
var myScrollHeight;
function showLargePopup(elem) {
	var popFullscreen = document.getElementById('fullscreen');
	var popLarge = document.getElementById('largepopup');
	document.getElementById('start-call').className = 'show';
	getSize();
	popFullscreen.style.height = myScrollHeight + 'px';
	popFullscreen.style.display = 'block';
	popLarge.style.left = ((myWidth - popLarge.offsetWidth) / 2) + 'px';
	popLarge.style.top = (((myHeight - popLarge.offsetHeight) / 2) + myScroll) + 'px';
	popLarge.style.visibility = 'visible';
	//refreshTimer = setTimeout("setLocation('"+elem.getAttribute("href")+"')", 1500);
}

function setLocation(loc) {
	window.location = loc;
}

function hideLargePopup() {
	var popFullscreen = document.getElementById('fullscreen');
	var popLarge = document.getElementById('largepopup');
	popLarge.style.visibility = 'hidden';
	popFullscreen.style.display = 'none';
}
var dpopTimer = "";
function showDownloadPopup(e) {
	var popDownload = document.getElementById('dpop');
	var btnDownload = document.getElementById('download');
	if (moveanim.timer != null) {
		clearInterval(moveanim.timer);
		moveanim.timer = null;
	}
	position = findElementPos(btnDownload);
	popDownload.style.top = (position[1] - (popDownload.offsetHeight - 40)) +"px";
	popDownload.style.left = "5" + "px";
	if (dpopTimer != ""){
		clearTimeout(dpopTimer);
		dpopTimer = "";
	} else {
		setOpacity(0, 'dpop');
		popDownload.style.visibility = 'visible';
		moveStart(popDownload, parseInt(popDownload.style.left), parseInt(popDownload.style.left), parseInt(popDownload.style.top) + 10, parseInt(popDownload.style.top), 15);
		fadeElementSetup('dpop', 0, 100, 13);
	}
}

function hideDownloadPopup() {
	dpopTimer = setTimeout("actuallyHide()", 500);
}

function actuallyHide() {
	var popDownload = document.getElementById('dpop');
	if (dpopTimer != "")	{
		dpopTimer = "";
		moveStart(popDownload, parseInt(popDownload.style.left), parseInt(popDownload.style.left), parseInt(popDownload.style.top), parseInt(popDownload.style.top) - 10, 15);
		fadeElementSetup('dpop', 100, 0, 13, 1);
	}
}

// Utility: Get the size of the window, and set myWidth and myHeight
// Credit to quirksmode.org

function getSize() {
	// Window Size
	if (self.innerHeight) { // Everyone but IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myScroll = window.pageYOffset;
	} else if (document.documentElement && document.documentElement.clientHeight) { // IE6 Strict
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		myScroll = document.documentElement.scrollTop;
	} else if (document.body) { // Other IE, such as IE7
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
		myScroll = document.body.scrollTop;
	}

	// Page size w/offscreen areas

	if (window.innerHeight && window.scrollMaxY) {	
		myScrollWidth = document.body.scrollWidth;
		myScrollHeight = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) { // All but Explorer Mac
		myScrollWidth = document.body.scrollWidth;
		myScrollHeight = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		myScrollWidth = document.body.offsetWidth;
		myScrollHeight = document.body.offsetHeight;
	}
}
