function AdjustFloatElem()
{
var fp = document.getElementById('floatph');
var cw = fp.offsetWidth;
var bow = document.body.offsetWidth;
var ch = fp.offsetHeight;
var boh = document.body.offsetHeight;
if (cw > 0 && bow > 0 && ch > 0 && boh > 0)
{
	if (fp.style.left == '' || fp.style.left == '0')
		fp.style.left = Math.floor( Math.max( bow - cw, 0) / 2 );
	if (fp.style.top == '' || fp.style.top == '0')
		fp.style.top = Math.floor( Math.max( boh - ch, 0) / 2 );
}
else
	setTimeout('AdjustFloatElem()', 10);
}

function SetFocusAtElement(aId)
{
	try
	{
		var aId_Counter = eval('window.Counter_' + aId);
		if (aId_Counter == null)
			aId_Counter = 0;

  		var e = null;
		e = document.getElementById(aId);
		if (!(e == null || typeof e == "undefined" ))
			e.focus();
		if (aId_Counter < 20)
			window.setTimeout('SetFocusAtElement(\'' + aId + '\')', 100);
		aId_Counter++;
		eval('window.Counter_' + aId + '=' + aId_Counter);
	}
	catch (aa)
	{
		setTimeout('SetFocusAtElement(\'' + aId + '\')', 1000);
	}
}
// Retrieve the value of the cookie with the specified name.
function GetCookie(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}

function SetCookie(sName, value, expiredSecs)
{
	var exdate = new Date();
	exdate.setTime(exdate.getTime() + (expiredSecs * 1000));
	document.cookie = sName + "=" + escape(value)+ ((expiredSecs == null) ? "" : "; expires=" + exdate.toGMTString()) +  "; path=/";
}

// Script Flash
function FlashCallback(aArg)
{
 eval("fc_"+aArg+"();");
}

//******************************
// Rollover Imagens
//******************************


function MM_swapImgRestore() {
	var i,x,a=document.MM_sr;
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) {
	var p,i,x;
	if(!d) d=document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && document.getElementById) x=document.getElementById(n);
	return x;
}

function MM_swapImage() {
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null) {
		document.MM_sr[j++]=x;
		if(!x.oSrc) x.oSrc=x.src;
		x.src=a[i+2];
	}
}

//******************************
// Criar Janela
//******************************
function criarjanela(href,nome,params) {
	if (href!="#")
	{
		if (criarjanela.arguments.length>=2){
			if( (nome!=null) && (nome!="") ){
				var tmp=nome.split(" "); // aproveita so a primeira palavra
				if(tmp.length!=0)
					nm=tmp[0];
				else
					nm="";
			}
			else
				nm="";
		}
		else nm="";
		if (criarjanela.arguments.length==3) param=params;
		else param="toolbar=no,location=no,directories=no,status=no,menubar=0,scrollbars=0,copyhistory=yes,width=194,height=177";
		win=window.open(href,nm,param);
		/*
		try
		{
			if (win != null)
				window.focus();
		}
		catch (aaaa) {}
		*/
	}
}

function criarJanela(href,nome,params) {
	criarjanela(href,nome,params);
}

//******************************
// Combo Box 
//******************************

function gotoURL(combo) {
	var val=combo.value;
	if (combo.value!="#") {
		window.open(combo.value,"_blank","width=900,height=550,toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes");
	}
}
