function popper(thisUrl,thisWidth,thisHeight,thisTop,thisLeft)
{
if (!thisLeft)
	var thisLeft=(screen.width-thisWidth)/2; // get center of screen minus popup width
if (!thisTop)
	var thisTop=(screen.height-thisHeight)/2; // get center of screen minus popup height

var optionString,mainWin;
optionString = ('width=' + thisWidth + ',height=' + thisHeight + ',top=' + thisTop + ',left=' + thisLeft + ',status=no,menubar=no,resizable=no,scrollbars=no');
mainWin = window.open(thisUrl,'editorHtmlWindow',optionString);
mainWin.focus();
}

function popperScroll(thisUrl,thisWidth,thisHeight,thisTop,thisLeft)
{
var optionString,mainWin;
optionString = ('width=' + thisWidth + ',height=' + thisHeight + ',top=' + thisTop + ',left=' + thisLeft + ',status=no,menubar=no,resizable=no,scrollbars=yes');
mainWin = window.open(thisUrl,'mainWindow',optionString);
mainWin.focus();
}


function dialogBox(thisUrl,thisWidth,thisHeight,thisTop,thisLeft)
{
var optionString,mainWin;
optionString = ('width=' + thisWidth + ',height=' + thisHeight + ',top=' + thisTop + ',left=' + thisLeft + ',status=no,menubar=no,resizable=no,scrollbars=yes');
mainWin = window.showModalDialog(thisUrl,'',optionString);

}



/**
 * Sets/unsets the pointer in browse mode
 *
 * @param   object   the table row
 * @param   object   the color to use for this row
 * @param   object   the background color
 *
 * @return  boolean  whether pointer is set or not
 */
function setPointer(theRow, thePointerColor, theNormalBgColor)
{
    var theCells = null;

    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    var currentColor = null;
    var newColor     = null;
    // Opera does not return valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined' && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].setAttribute('bgcolor', newColor, 0);
        } // end for
    }
    else {
        currentColor = theCells[0].style.backgroundColor;
        newColor     = (currentColor.toLowerCase() == thePointerColor.toLowerCase())
                     ? theNormalBgColor
                     : thePointerColor;
        for (var c = 0; c < rowCellsCnt; c++) {
            theCells[c].style.backgroundColor = newColor;
        }
    }

    return true;
} // end of the 'setPointer()' function

function disableButtons() {
  var num_elem, num_forms;

  num_forms = window.document.forms.length;
  for (var i=0; i <num_forms; i++) {
    num_elem = window.document.forms[i].elements.length;
    for (var j=0; j<num_elem; j++) {
    frm = window.document.forms[i];
      if (frm.elements[j].type == 'submit') {
         frm.elements[j].disabled='true';
      }
      if (frm.elements[j].type == 'button') {
         frm.elements[j].disabled='true';
      }
      if (frm.elements[j].type == 'reset') {
         frm.elements[j].disabled='true';
      }
    }
  }
}

//Gestão de checkboxes
var checkflag = "false";
function check (lista) {
  if (checkflag == "false") {
    for (i=0; i < lista.length; i++) {
      lista[i].checked = true;
    }
    checkflag = "true";
  } else {
    for (i=0; i < lista.length; i++) {
      lista[i].checked = false;
    }
    checkflag = "false";
  }
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_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 layerFormHome(width,height,e)
{

	var arr1 = width.split("px");
	var arr2 = height.split("px");
	
	formAbs = e;

	width = arr1[0];
	height = arr2[0];

	document.getElementById('layer_form').style.display='block';
	
	if (document.getElementById('layer_form').addEventListener){
		document.getElementById('layer_form').addEventListener('click', esconder, false); 
	} else if (document.getElementById('layer_form').attachEvent){
		document.getElementById('layer_form').attachEvent('onclick', esconder);
	}
	
	tamanhos = getPageSize();
	xcenter = (tamanhos[0]/2) - (width / 2);
	
	if (window.pageYOffset) {
		ycenter = window.pageYOffset + (tamanhos[3]/2) - (height / 2);
	} else {
		ycenter = document.documentElement.scrollTop + document.body.scrollTop + (tamanhos[3]/2) - (height / 2);
	}

	document.getElementById('layer_form').style.width = (tamanhos[0]-25)+'px';
	document.getElementById('layer_form').style.height = tamanhos[1]+'px';
	
	e.style.display='block';
	//Centrado em altura e largura
	/*e.style.top = ycenter+'px';
	e.style.left = xcenter+'px';*/
	//Alinhado à direita no topo
	e.style.top = '0px';
	e.style.right = '0px';
}

function esconder()
{
	document.getElementById('layer_form').style.display='none';
	formAbs.style.display='none';
}

function comon_cookurl_createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*2*60*60));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

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

function comon_cookurl_eraseCookie(name) {
	comon_cookurl_createCookie(name,"",-1);
}
