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=yes,scrollbars=no');
mainWin = window.open(thisUrl,'editorHtmlWindow',optionString);
mainWin.focus();
}

function popperScroll(thisUrl,thisWidth,thisHeight,thisTop,thisLeft,thisWindowName)
{

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
if(!thisWindowName)
{
	var thisWindowName = 'mainWindow';
}

var optionString,mainWin;
optionString = ('width=' + thisWidth + ',height=' + thisHeight + ',top=' + thisTop + ',left=' + thisLeft + ',status=no,menubar=no,resizable=yes,scrollbars=yes');
mainWin = window.open(thisUrl,thisWindowName,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)
{
	if (thePointerColor != ''){
		if (thePointerColor == 'transparent') thePointerColor = theNormalBgColor;
	  if (theRow.bgColor == '' || typeof(theRow.bgColor) == 'undefined') thePointerColor = theNormalBgColor;
  	theRow.bgColor = thePointerColor;
	}

  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];}}
}

//------------------ VALIDAçÂO DO FORM
function formtool_count_chars(textField, countField,maxlen,show_alert) {
    if(textField != null && textField.value != null) {
	    if (textField.value.length > maxlen){
            if(show_alert)
               alert('Este campo não pode exceder o limite de ' +  maxlen + ' caracteres.');
            textField.value = textField.value.substring(0, maxlen);
	    } else {
            countField.value = textField.value.length;
	    }
    }
}

// Para calcular a altura do browser
function findHeight() {
	getScrollHeight = 0;
	getScrollHeight = document.body.clientHeight;
	//DESCOMENTAR QD TUDO ESTIVER CORRIGIDO!!!!!
	//document.getElementById("msg_ml").style.height = getScrollHeight+"px";
}