var isDOM 		= (typeof(document.getElementsByTagName) != 'undefined') ? 1 : 0;
var isIE4		= ((typeof(document.all) != 'undefined') && (parseInt(navigator.appVersion) >= 4)) ? 1 : 0;
var isNS4		= (typeof(document.layers) != 'undefined') ? 1 : 0;
var is_ie		= document.all? true: false;

function _ElemById(id)			{ return document.getElementById(id); }
function _ElemByIdDoc(id)		{ return document.getElementById(id).contentWindow.document; }


function imprimir()
	{
	self.print();
	}
	
function AdicionarFavoritos(l, n)		
	{
	if (window.external) { window.external.AddFavorite(l, n)};
	}
function definirHomePage(l, n)
	{
	if (document.all)
		document.write('<a href="javascript:history.go(0);" onClick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\''+l+'\');">'+n+'</a>');
		else if(document.getElementById)
			document.write('<a href="" onclick="alert(\'Por favor arraste o icon para cima do icon “Home” que se encontra no topo do seu browser.\');return false;" class="home">'+n+'</a>');
	}


function relogio()
	{
	var data = new Date();
	var h = data.getHours();
	var m = data.getMinutes();
	var s = data.getSeconds();
	if(h<10) h = '0' + h;
	if(m<10) m = '0' + m;
	if(s<10) s = '0' + s;
	var string = h + ":" + m + ":" + s;
	document.getElementById("relogio").innerHTML = string;
	setTimeout('relogio()',1000);
	}


function _preloadImages() 
	{
	var d=document; 
	if(d.images)
		{ 
		if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=_preloadImages.arguments; 
		for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0)
				{ 
				d.MM_p[j]=new Image; 
				d.MM_p[j++].src=a[i];
				}
		}
	}
function changeImages() 
	{
	if (document.images) 
		{
		for (var i=0; i<changeImages.arguments.length; i+=2) 
			{
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
			}
		}
	}

// - - - - - - - - - - 
// Boxes
// - - - - - - - - - - 
function Boxes_Confirm(perg)	{ return confirm(perg); }
function Boxes_Alert(text)		{ alert(text); }
	
function clipboard_def(text)	{ if( window.clipboardData && clipboardData.setData ) clipboardData.setData("Text", text); }
	
	
// - - - - - - - - - - - - - - - - - - - - 
// StyleShetts 
// - - - - - - - - - - - - - - - - - - - - 
function ActivarStyleSheet(title)
	{
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) 
		{
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) 
			{
			a.disabled = true;
			if(a.getAttribute("title") == title) a.disabled = false;
			}
		}
	CriarCookie("estilo", title, 365);
	}

function MudaClassObj(Obj, Class)
	{
	Obj.className = Class;
	}
	
// - - - - - - - - - - - - - - - - - - - - 
// Cookie 
// - - - - - - - - - - - - - - - - - - - - 
function CriarCookie(name, value, days) 
	{
	if (days) 
		{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = " expires="+date.toGMTString()+";";
		} else expires = "";
	document.cookie = name+"="+value+";"+expires+" path=/;";
	}

function LerCookie(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 null;
	}

// - - - - - - - - - - - - - - - - - - - - 
// PopUps 
// - - - - - - - - - - - - - - - - - - - - 
function _js_popup(Url, Width, Height, Style)
	{
	tstyle = 'scrollbars=no, resizable=no, TOP=50, LEFT=150, status=no, help=no"';
	if(Style.length==0) Style = tstyle;
	xstyle = 'WIDTH='+Width+', HEIGHT='+Height+', ';
	popupWindow = window.open(Url, '', xstyle+Style);
	if (popupWindow.opener == null) popupWindow.opener = self;
	popupWindow.focus();
	}


function include_runtime_javascript(script_filename, funcao) 
	{
    var html_doc = document.getElementsByTagName('head').item(0);
    var js = document.createElement('script');
    js.setAttribute('language', 'javascript');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', script_filename);
    html_doc.appendChild(js);

	js.onreadystatechange = function () { if (js.readyState == 'loaded') {eval(funcao);} }
	js.onload = function () { eval(funcao); }
	
	return false;
	}