// JavaScript Document
//var isIE = (navigator.userAgent.indexOf("MSIE") != -1);
//var isFox = (navigator.userAgent.indexOf("Firefox") != -1);
var isFox = document.layers?true:false;
var isIE = document.all?true:false;

function SalvarBrowser()
{
	if(isIE) valor = 'IE'; else valor = 'Fox';
	WriteCookieMins('IDBROWSER',valor,120);
}

// ------------ Rotinas de Cookies -----------------
function getCookieVal(offset){var endstr=document.cookie.indexOf(";",offset); 
if(endstr==-1) endstr=document.cookie.length; return unescape(document.cookie.substring(offset,endstr));}

function GetCookie(name) {
	var arg=name+"="; var alen=arg.length; var clen=document.cookie.length; var i=0;
	while(i<clen){
		var j=i+alen; 
		if(document.cookie.substring(i,j)==arg) return getCookieVal(j);
		i=document.cookie.indexOf(" ",i)+1;
		if(i==0) break;
	}
	return null;
}

function SetCookie(name,value)
{	
	var argv=SetCookie.arguments; 
	var argc=SetCookie.arguments.length; 
	var expires=(argc>2)? argv[2]:null;
	var path=(argc>3)? argv[3]:null;
	var domain=(argc>4)? argv[4]:null;
	var secure=(argc>5)? argv[5]:false;
	document.cookie=name+"="+escape(value)+((expires==null)? "":("; expires="+expires.toGMTString()))+
		((path==null)? "":("; path="+path))+((domain==null)? "":("; domain="+domain))+((secure==true)? "; secure":"");
}

function WriteCookieMins(nome,valor,mins) 
{	
	var today = new Date();
	var expires = new Date();
	expires.setTime(today.getTime() + 60*mins*1000);	// minutos
	SetCookie(nome,valor,expires);
}

function WriteCookieDays(nome,valor,dias) 
{	
	var today = new Date();
	var expires = new Date();
	expires.setTime(today.getTime() + 60*60*24*dias*1000);	// dias
	SetCookie(nome,valor,expires);
}

function deleteCookie(name)
{
  var expdate = new Date();   
  expdate.setMonth(expdate.getMonth() - 1);
  SetCookie(name, "", expdate);
}

function CheckCookie(nome, valor)
{
	if(GetCoookie(nome)!=valor) return(false); else return(true);
}

function CookieSupport()
{
	x = false;
	WriteCookieMins('COOKIETEST','yes',1);
	if(GetCookie('COOKIETEST')=='yes') x=true;
	//deleteCookie('COOKIETEST');
	return(x);
}

/* ------- fim de cookies ----------- */

function ById(idx)
{	var x = document.getElementById(idx);
	return(x);
}

function replaceString(oldS,newS,fullS)
{
	for (var i=0; i<fullS.length; i++) 
	{      
		if (fullS.substring(i,i+oldS.length) == oldS)
		{	fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length);
		}
	}
	return fullS;
}

/* --- OVERLIB functions ---- */
function MyPiclib(img,title)
{
	var s = "<center><img src='"+img+"' border=0></center>";
	return overlib(s,CAPTION,'<center>'+title+'</center>',BELOW,RIGHT);
}

function MyTxtlib(s,title)
{
	return overlib(s,CAPTION,'<center>'+title+'</center>',BELOW,RIGHT);
}
/* ----- fim de overlib ------ */

function mysfloat(x,n,def)
{
	sx = x.toString();
	ponto = sx.indexOf(".");
	if(ponto>=0) ret = sx.substring(0,ponto) + "." + sx.substring(ponto+1,ponto+n+1);
	else ret = sx + def;
	return(ret);
}

function GetObj(id)
{
	var ie = false;
	if(document.all) { ie = true; }
	if (ie) return document.all[id];
	else return document.getElementById(id);
}

function ShowHide(id)
{
	var obj = document.getElementById(id);
	if(obj.style.display=='none') obj.style.display=''; else obj.style.display='none';
}

function Ampliar(im,w,h)
{
	nw = w;
	nh = h;
	x = window.open("","PicWindow","menubar=no,toolbar=no,scrollbars=no,resizable=yes,status=no,width="+nw+",height="+nh);
	x.document.write("<html><body style='margin:0 0 0 0'><center><img src='" + im + "' border=0></center></body></html>");
	//x.status = ":-)";
}

