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);
}

var dontforce=false;
function SetFocusAtElement(aId)
{
	if (dontforce) return;
	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=/";
}
function S4() {return (((1+Math.random())*0x10000)|0).toString(16).substring(1);}
function GetNewGUID()
{
	try
	{
		var r = 0;
		for (var f = 0; f <= window.history.length; f++) r += Math.random(); // try for some extra randomness
	}
	catch (e) {};
	return (S4()+S4()+S4()+S4()+S4()+S4()+S4()+S4()).toUpperCase();
}
function ValidateAnonymousSession(key)
{
	try
	{
		var sesscookie = GetCookie(key);
		if (sesscookie == null || sesscookie == '')
		{
			SetCookie(key, GetNewGUID());
/*
			var scount = GetCookie(key+'_SessCount');
			var sc = 1;
			if (scount != null &&  scount != '')
				try { sc = parseInt(scount); if (isNaN(sc)) sc=1; else sc++; } catch (){};
			SetCookie(key+"_SessCount", sc.ToString(), 60*60*24*30);
*/
		}
	}
	catch (e) {};
}
function GetScreenRes()
{
	var ScreenRes = null;
	try
	{
		if (window.screen.width != null && window.screen.height != null && window.screen.width > 0 && window.screen.height > 0)
		{
			ScreenRes = window.screen.width + 'x' + window.screen.height;
			//var ordate = GetCookie('ppsr');
			//if (ordate == null || ScreenRes != ordate)
			//	SetCookie('ppsr', ScreenRes, 60*60*24*120);
			//else ScreenRes = null;
		}
	}
	catch (e) {};
	return (ScreenRes==null?"NO":ScreenRes);
}
/*
function attachLogo()
{
	var LogoGUID = GetCookie('AS_LogoGUID');
	if (LogoGUID != '' && LogoGUID != null)
	{
		var ww = document.getElementById('topbanner').offsetLeft + 770 - 180; 
		document.write('<img src=\"cms.aspx?srv=207&stp=1&guid=' + LogoGUID + '\" style=\"position:absolute;top:20px;left:' + ww + 'px;\" id=logotype'); 
		if (window.attachEvent) 	
		{
			window.attachEvent('onresize', drawlogo);
			window.attachEvent('onload', drawlogo);
		}
		else
		{
			addEventListener('resize', drawlogo, false);
			addEventListener('load', drawlogo, false);
		}
	}
}
function drawlogo()  
{
	var LogoGUID = GetCookie('AS_LogoGUID');
	if (LogoGUID != '' && LogoGUID != null)
	{
 		if (document.getElementById('logotype') != null) 
		{
	 		document.getElementById('logotype').style.left = document.getElementById('topbanner').offsetLeft + 770 - 180 + 'px';
 		}
		else
		{
			var o = document.createElement('img');
 			o.src='cms.aspx?srv=207&stp=1&guid=' + LogoGUID;
 			o.style.position='absolute';
 			o.style.top='20px';
 			o.style.left = document.getElementById('topbanner').offsetLeft + 770 - 180 + 'px';
 			o.id = 'logotype';
			document.body.appendChild(o);
 		}
 	}
} 
*/
// 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) {
	dontforce=true;
	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");
	}
}

