function popUp(doc, height, width)
{
	var top = (screen.height - height - 30) / 2;
	var left = (screen.width - width) / 2;
	
	var janela = window.open(doc, height + width,"height=" + height + ",width=" + width + ",top=" + top + ",left=" + left + ",scrollbars=yes,resizable=yes");
	janela.moveTo(left, top);
	janela.focus();	
}

function popUpConteudo(doc)
{
	popUp(doc, 380, 600);
}

function popUpExplicacao(doc)
{
	popUp(doc, 500, 720);
}

function popUpAvisos(doc)
{
	popUp(doc, 280, 650);
}

function popUpSistemas(doc)
{
	popUp(doc, 550, 720);
}

function popUpParametros(doc)
{
	popUp(doc, 320, 720);
}


function obterParametro(name)
{
	var argsArray = location.search.substr(1).split('&');
	var pos;

	for(i = 0;i < argsArray.length; i++) {
		pos = argsArray[i].indexOf("=");
		if(argsArray[i].substr(0, pos) == name) {
			return argsArray[i].substr(pos+1);
		}
	}
	
	return "";
}

// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }

  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  if(foundObj)
  {
    if(foundObj.toString().indexOf("Flash") == -1) {
  	  if(foundObj.style == null)
  	    foundObj.style = foundObj;
    }
  }

  if(!foundObj)
  {
    if(theDoc.all)
      foundObj = theDoc.all[theObj];
    else
      foundObj = theDoc[theObj];
  }

  return foundObj;
}

function formatNumber(number)
{
	var str = number.toString();
	var str2;
	
	for(var i = 0; i < str.length; i++)
	{
		if(i < str.length % 3)
			str2 += str[i];
	}
	
	return str2;
}

function formatearNumero(num)
{
	var s = num.toString();
	var s2 = "";
	var integerPlaces = s.indexOf('.');
	if(integerPlaces == -1)
		integerPlaces = s.length;
	
	for(var i = 0; i < s.length; i++)
	{
		if(s.charAt(i) == '.')
			s2 += ',';
		else {
			if((i > 0) && ((integerPlaces - i) % 3 == 0))
				s2 += '.';
			s2 += s.charAt(i);
		}
	}
	
	return s2;
}
