 
// JavaScript Graphic Functions
// JavaScript Document
function abreFecha(id){
	if(get(id).style.display == 'none'){
		get(id).style.display = '';
	}else{
		get(id).style.display = 'none';
	}
} 
// JavaScript Document
function autoHideMenuEsquerdo(id, openedWidth, closedWidth){
	get(id).style.position = 'absolute';
	get(id).style.overflow = 'hidden';
	get(id).style.zindex = '999';
	setWidth(id,closedWidth);
	get(id).onmouseover = function(){
		resizeToRight(id,openedWidth);
	}
	document.body.onmouseout = function(){
		resizeToRight(id,closedWidth);
	}
} 
// JavaScript Document
function autoHideMenuTopo(id, openId, closeId, openedHeight, closedHeight){
	get(id).style.position = 'absolute';
	get(id).style.overflow = 'hidden';
	get(id).style.zindex = '999';
	setHeight(id,closedHeight);
	get(openId).onmouseover = function(){
		resizeToDown(id,openedHeight);
	}
	get(closeId).onmouseout = function(){
		resizeToDown(id,closedHeight);
	}
} 
// Determine browser and version.

function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.
  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";
  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
} 
// Determine browser and version.

var dragRObj = new Object();
	dragRObj.zIndex = 0;


function dragResizeStart(event, id, idImg, ajusteX, ajusteY) {
  if(isNaN(ajusteX)) ajusteX = 0;
  if(isNaN(ajusteY)) ajusteY = 0;
  dragRObj.ajusteX = ajusteX;
  dragRObj.ajusteY = ajusteY;

  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id){
    dragRObj.elNode = document.getElementById(id);
  // está é uma span que deve abrir imediatamente depois da div e fechar imediatamente antes
  // seu id deve ser span+idDoObjetoRedimensionavel
    dragRObj.divContent = document.getElementById('div'+id);
//	alert(dragRObj.divContent.offsetHeight);

	dragRObj.img = document.getElementById(idImg);
	
  }else {
    if (browser.isIE)
      dragRObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragRObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragRObj.elNode.nodeType == 3)
      dragRObj.elNode = dragRObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragRObj.cursorStartX = x;
  dragRObj.cursorStartY = y;
  dragRObj.elStartLeft  = parseInt(dragRObj.elNode.style.left, 10);
  dragRObj.elStartTop   = parseInt(dragRObj.elNode.style.top,  10);

  if (isNaN(dragRObj.elStartLeft)) dragRObj.elStartLeft = 0;
  if (isNaN(dragRObj.elStartTop))  dragRObj.elStartTop  = 0;

  // Update element's z-index.
if(dragObj.elNode != null)
  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragResizeGo);
    document.attachEvent("onmouseup",   dragResizeStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragResizeGo,   true);
    document.addEventListener("mouseup",   dragResizeStop, true);
    event.preventDefault();
  }
}

function dragResizeGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft  - dragRObj.ajusteX;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop - dragRObj.ajusteY;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX - dragRObj.ajusteX;
    y = event.clientY + window.scrollY - dragRObj.ajusteY;;
  }

  // Move drag element by the same amount the cursor has moved.

  dragRObj.elNode.style.width = (x - parseInt(dragRObj.elNode.style.left)) + "px";
  dragRObj.elNode.style.height  = (y - parseInt(dragRObj.elNode.style.top)) + "px";
  dragRObj.notDragX = false;
  if(parseInt(dragRObj.elNode.style.width)+parseInt(dragRObj.elNode.style.borderLeft)+parseInt(dragRObj.elNode.style.borderRight) <= dragRObj.divContent.offsetWidth){
	  dragRObj.elNode.style.width = dragRObj.divContent.offsetWidth + 'px';
  	  dragRObj.notDragX = true;
  }
  dragRObj.notDragY = false;
  if(parseInt(dragRObj.elNode.style.height) <= dragRObj.divContent.offsetHeight){
	  dragRObj.elNode.style.height = dragRObj.divContent.offsetHeight + 'px';
	  dragRObj.notDragY = true;
  }
  
  dragRObj.img.style.top = (parseInt(dragRObj.elNode.style.height)-dragRObj.img.offsetHeight)+'px';
  dragRObj.img.style.left = (parseInt(dragRObj.elNode.style.width)-dragRObj.img.offsetWidth)+'px';
  
  dragRObj.elNode.style.zIndex = dragObj.zIndex;
parseInt(dragRObj.elNode.style.top)
  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragResizeStop(event) {

  // Stop capturing mousemove and mouseup events.
  if (browser.isIE) {
    document.detachEvent("onmousemove", dragResizeGo);
    document.detachEvent("onmouseup",   dragResizeStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragResizeGo,   true);
    document.removeEventListener("mouseup",   dragResizeStop, true);
  }
  
  dragStop(event);
  
} 
// JavaScript Document
function resizeHeightToDown(id, height){
	heightAtual = parseInt(get(id).style.height);
	difAtual = height - heightAtual;
	inc = parseInt(difAtual / 5);
	get(id).style.height = (heightAtual + inc) + 'px';
	if(difAtual > -5 && difAtual < 5 ){
		clearInterval(iids[id]);
		iidt[id] = false;
	}
} 
// JavaScript Document
function resizeHeightToUp(id, height){
	heightAtual = parseInt(get(id).style.height);
	topAtual = parseInt(get(id).style.top);
	difAtual = height - heightAtual;
	inc = parseInt(difAtual / 5);
	get(id).style.top = (topAtual - inc) + 'px';
	get(id).style.height = (heightAtual + inc) + 'px';
	if(difAtual > -5 && difAtual < 5 ){
		clearInterval(iids[id]);
		iidt[id] = false;
	}
} 
// JavaScript Document
function resizeToDown(id, height){
	if(!iidt[id]){
		iidt[id] = true;
		iids[id] = setInterval("resizeHeightToDown('"+id+"','"+height+"');",5);
	}
} 
// Javascript Document
function resizeToLeft(id, width){
	if(!iidt[id]){
		iidt[id] = true;
		iids[id] = setInterval("resizeWidthToLeft('"+id+"','"+width+"');",5);
	}
} 
// JavaScript Document
function resizeToRight(id, width){
	if(!iidt[id]){
		iidt[id] = true;
		iids[id] = setInterval("resizeWidthToRight('"+id+"','"+width+"');",5);
	}
} 
// Javascript Document
function resizeToUp(id, height){
	if(!iidt[id]){
		iidt[id] = true;
		iids[id] = setInterval("resizeHeightToUp('"+id+"','"+height+"');",5);
	}
} 
// JavaScript Document
function resizeWidthToLeft(id, width){
	widthAtual = parseInt(get(id).style.width);
	leftAtual = parseInt(get(id).style.left);
	difAtual = width - widthAtual;
	inc = parseInt(difAtual / 5);
	get(id).style.left = (leftAtual - inc) + 'px';
	get(id).style.width = (widthAtual + inc) + 'px';
	if(difAtual > -5 && difAtual < 5 ){
		clearInterval(iids[id]);
		iidt[id] = false;
	}
} 
// JavaScript Document
function resizeWidthToRight(id, width){
	widthAtual = parseInt(get(id).style.width);
	difAtual = width - widthAtual;
	inc = parseInt(difAtual / 5);
	get(id).style.width = (widthAtual + inc) + 'px';
	if(difAtual > -5 && difAtual < 5 ){
		clearInterval(iids[id]);
		iidt[id] = false;
	}
} 
// JavaScript Document
function setHeight(id,height){
	height = ''+height;
	if(height.charAt(height.length -1) == '%'){
		height = windowPercentHeight(height.substr(0,height.length -1));
	}
	get(id).style.height = height + 'px';
} 
// JavaScript Document
function setLeft(id,left){
	left = ''+left;
	if(left.charAt(left.length -1) == '%'){
		left = windowPercentWidth(left.substr(0,left.length -1));
	}
	get(id).style.left = left + 'px';
} 
// JavaScript Document
function setTop(id,top){
	top = ''+top;
	if(top.charAt(top.length -1) == '%'){
		top = windowPercentHeight(top.substr(0,top.length -1));
	}
	get(id).style.top = top + 'px';
} 
// JavaScript Document
function setWidth(id,width){
	width = ''+width;
	if(width.charAt(width.length -1) == '%'){
		width = windowPercentWidth(width.substr(0,width.length -1));
	}
	get(id).style.width = width + 'px';
} 
// Javascript Document

/* variaveis que serão usadas em mais de uma função */

var	iids = Array();
var iidt = Array(); 
// JavaScript Document
function windowHeight(){
	return windowSize('h');
} 
// JavaScript Document
function windowPercentHeight(percent){
	percent = parseInt(percent);
	return parseInt(windowHeight()/100*percent);
} 
// JavaScript Document
function windowPercentWidth(percent){
	percent = parseInt(percent);
	return parseInt(windowWidth()/100*percent);
} 
// JavaScript Document

/* Retorna a largura da janela se passado 'w' como parâmetro
	ou retorna a altura se passado qualquer outro valor
*/
function windowSize(xy) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  if(xy == 'w'){
	return myWidth;
  }else{
    return myHeight;
  }
} 
// JavaScript Document
function windowWidth(){
	return windowSize('w');
} 

// JavaScript Mask Functions
// JavaScript Document
function dateMask(event,object){
	val = object.value.replace(/\D/,'');
	novoValor = '';
	for(i=0;i<=val.length;i++){
		if(!teclaPermitida(event))
			if(i==2 || i==4) 
				novoValor = novoValor + '/';
				
		if(val.charCodeAt(i) > 47 && val.charCodeAt(i) < 58)
			if(i < 9)
				novoValor = novoValor + val.charAt(i);	
	}
	if(!teclaPermitida(event))
		object.value = novoValor;
} 
// JavaScript Document

/* impede que o usuário digite qualquer coisa além de números*/
function digitMask (event){
	if(event.keyCode){ code = event.keyCode; } else { code = event.which; }
	if((code > 47 && code < 58) || teclaPermitida(event)){
		return true;
	}else{
		return false;
	}
} 
// JavaScript Document

/* impede que o usuário digite qualquer coisa além de um email */
function emailMask (event, object) {
	if(event.keyCode){ code = event.keyCode; } else { code = event.which; }
	var str = String.fromCharCode(code);
	if((str.match(/\W/) != null || !teclaNaoPermitida(event))  && code != 46 && code != 45 && code != 64 && !teclaPermitida(event)){
		return false;
	}else{
		if(code == 64 && object.value.match(/@+/) == '@')
			return false;
		else
			return true;
	}
} 
// JavaScript Document

/* impede que o usuário digite qualquer coisa além de um nome de arquivo */
function filenameMask(event){
	if(event.keyCode){ code = event.keyCode; } else { code = event.which; }
	var str = String.fromCharCode(code);
	var a = String.fromCharCode(231);
	if((str.match(/\W/) != null || !teclaNaoPermitida(event))  && code != 46 && code != 45 && !teclaPermitida(event)){
		return false;
	}else{
		return true;
	}
} 
// JavaScript Document
function hourMask(event,object){
	val = object.value.replace(/\D/,'');
	novoValor = '';
	for(i=0;i<=val.length;i++){
		if(!teclaPermitida(event))
			if(i==2) 
				novoValor = novoValor + ':';
				
		if(val.charCodeAt(i) > 47 && val.charCodeAt(i) < 58)
			if(i < 5)
				novoValor = novoValor + val.charAt(i);	
	}
	if(!teclaPermitida(event))
		object.value = novoValor;
} 
// JavaScript Document

/* impede que o usuário digite qualquer coisa além de números inteiros */
function intMask(event, object){
	if(event.keyCode){ code = event.keyCode; } else { code = event.which; }
	if(code == 45 || digitMask(event)){
		if(code == 45 && object.value != '')
			return false;
		else
			return true;
	}else{
		return false;
	}
	return true;
} 
// JavaScript Document

/* limita o número de caracteres ao valor informado em size */
function limitMask(event, object, size){
	if(	object.value.length >= size && !teclaPermitida(event)){
		return false;
	}else{
		return true;
	}
} 
// JavaScript Document

/* impede que o usuário digite qualquer coisa além de um path */
function pathMask(event,object){
	if(event.keyCode){ code = event.keyCode; } else { code = event.which; }
	if(filenameMask(event) ||  code == 47 || code == 92 || code == 58){
		if(code == 58 && object.value.match(/:/) != null)
			return false;
		else
			return true;
	}else{
		return false;
	}

} 
// JavaScript Document

/* impede que o usuário digite qualquer coisa além de números reais */
function realMask(event, object){
	if(event.keyCode){ code = event.keyCode; } else { code = event.which; }
	if(code == 44 || code == 45 || digitMask(event)){
		if(code == 45 && object.value.substr(0,1) == '-')
			return false;
		if(code == 44 && (object.value.match(/,+/) == ','))
			return false;
	}else{
		return false;
	}
	return true;
} 
// JavaScript Document

/* impede que o usuário digite um espaço em branco */
function spaceMask(event){
	if(event.keyCode){ code = event.keyCode; } else { code = event.which; }
	if(code == 32){
		return false;
	}else{
		return true;
	}
} 
// JavaScript Document
function teclaNaoPermitida(event){
	if(event.charCode){ code = event.charCode; } else { code = event.which; }
	if(	   code == 225
		|| code == 233
		|| code == 237
		|| code == 243
		|| code == 250
		|| code == 193
		|| code == 201
		|| code == 205
		|| code == 211
		|| code == 218
		|| code == 224
		|| code == 232
		|| code == 236
		|| code == 242
		|| code == 249
		|| code == 192
		|| code == 200
		|| code == 204
		|| code == 210
		|| code == 217
		|| code == 226
		|| code == 234
		|| code == 238
		|| code == 244
		|| code == 251
		|| code == 194
		|| code == 202
		|| code == 206
		|| code == 212
		|| code == 219
		|| code == 231
		|| code == 199
		|| code == 227
		|| code == 245
		|| code == 241
		|| code == 195
		|| code == 213
		|| code == 209
		|| code == 228
		|| code == 235
		|| code == 239
		|| code == 246
		|| code == 252
		|| code == 196
		|| code == 203
		|| code == 207
		|| code == 214
		|| code == 220) 
		return false;
	else
		return true;
} 
// JavaScript Document
/* teclas sempre permitidas */
function teclaPermitida(event){
	if(event.keyCode){ code = event.keyCode; } else { code = event.which; }
	return ( code == 8 || code == 9 || code == 13);
} 

// JavaScript Popup Functions             -->
// JavaScript Document
/*
 * Abre um popup
 */
function abrePopup(page,width,height) {
	features = 'width='+width+',height='+height+',scrollbars=yes,statusbar=no';
	win = window.open(page,'id',features);	
	win.window.focus();
} 
// JavaScript Document
/*
 * Abre um popup redimensionavbel
 */
function abreResizablePopup(page,width,height) {
	features = 'width='+width+',height='+height+',scrollbars=yes,statusbar=no,resizable=yes';
	win = window.open(page,'id',features);	
	win.window.focus();
} 

// JavaScript Util Functions
// Javascript document
function appendHtml(id, html){
	get(id).innerHTML = get(id).innerHTML + html;
} 
// JavaScript Document
/*
 * Iguala todos os checkboxes de nome name ou checkbox 'chkAll'
 */
function checkAll(form, name, checked){
	eval("a = document."+form+"."+name+";");
	for (cont=0; cont < a.length; cont++){
		a[cont].checked = checked;
	}
}

var _nv_checbox = 0;
function createCheckbox(name, value, label){
	document.write('<input id="'+name+_nv_checbox+'" name="'+name+'" type="checkbox" value="'+value+'"><label for="'+name+_nv_checbox+'">'+label+'</label>');
	_nv_checbox++;
}

var _nv_checkall = 0;
function createCheckall(form, name, label){
	document.write('<input id="chkAll'+_nv_checkall+'" name="chkAll'+_nv_checkall+'" type="checkbox" onClick="checkAll(\''+form+'\', \''+name+'\', this.checked)"><label for="chkAll'+_nv_checkall+'">'+label+'</label>');
	_nv_checkall++;
} 
//Javascript Document
function enterPressed(event){
	if(event.keyCode){ code = event.keyCode; } else { code = event.which; }
	if (code == 13) {
	    return true;
	} else {
	    return false;
	}    	
} 
// JavaScript Document
function get(id){
	return document.getElementById(id);
} 
// Javascript Document

function getURLVar(varName){
	url = String(document.location);
	varName = String(varName).toLowerCase();
	
	urlStrVars = url.substr(url.indexOf('?')+1);
	urlVars = urlStrVars.split('&');

	for(i=0;i<urlVars.length;i++){
		// variavel[0] -> nome da URL VAR
		// variavel[1] -> valor da URL VAR
		variavel = urlVars[i].split('=');
		if(variavel[0].toLowerCase() == varName){
			return variavel[1];
		}
	}
	
}

var contentsBottom = 0;
function guardaBottom(id){
	h = get(id).style.height;
	t = get(id).style.top;
	b = parseInt(h) + parseInt(t);
	if(contentsBottom < b){
		contentsBottom = b;
	}
}


//// 

var _largs = Array();
var _footerAlterado = false;

function zoomNaDiv(id,percent){
	if(!_largs[id]){
		_largs[id] = parseInt(get(id).style.width);
	}
	obj = get(id);
	obj.style.zoom = percent+'%';
	largAnterior = _largs[id];
	largAtual = largAnterior*percent/100;
	largNovaPercentAtual = 100*largAnterior/largAtual;
	obj.style.width = (largAnterior*largNovaPercentAtual/100)+'px';

	altAnterior = obj.offsetHeight;
	altAtual = altAnterior*percent/100;
	bottomAtual = altAtual+parseInt(obj.style.top);
	
	
	if((bottomAtual > contentsBottom) || _footerAlterado){
		contentsBottom = bottomAtual;
		_footerAlterado = true;
		ajusta();
	}

}

function reposicionaToolbox(idconteudo, idtoolbox) {
    if (get(idtoolbox) != null) {
        get(idtoolbox).style.top = parseInt(get(idconteudo).style.top)-22;
        get(idtoolbox).style.left=get(idconteudo).style.left;
    }
} 
function savePosition(page,id){
	l = parseInt(get(id).style.left);
	t = parseInt(get(id).style.top);
	w = parseInt(get(id).style.width);
	h = parseInt(get(id).style.height);
	z = get(id).style.zIndex;
	bg = get(id).style.backgroundColor;

	border = get(id).style.border;
	borderL = get(id).style.borderLeft;
	borderT = get(id).style.borderTop;
	borderR = get(id).style.borderRight;
	borderB = get(id).style.borderBottom;

	if(l < 0) l = 0;
	if(l < 0) t = 0;
	if(l < 0) w = 0;
	if(l < 0) h = 0;
	style = "z-index: "+z+"; ";
	style += "left: "+l+"px; ";
	style += "top: "+t+"px; ";
	style += "width: "+w+"px; ";
	style += "height: "+h+"px; ";
	style += "background-color: "+bg+"; ";
	style += "border: "+border+"; ";
	style += "border-left: "+borderL+"; ";
	style += "border-top: "+borderT+"; ";
	style += "border-right: "+borderR+"; ";
	style += "border-bottom: "+borderB+"; ";
	style = style.replace(/[#]/,'$$');
	style = style.replace(/[#]/,'$$');
	style = style.replace(/[#]/,'$$');
	style = style.replace(/[#]/,'$$');
	style = style.replace(/[#]/,'$$');
	style = style.replace(/[#]/,'$$');
//	alert(style);
//	get(id).innerHTML = get(id).innerHTML+'<br>'+page+'<br>'+style;
	get('iframeoculto_layouteronline').src = page+'&divStyle='+style;
} 
// mredkj.com
function NumberFormat(num, inputDecimal)
{
this.VERSION = 'Number Format v1.5.4';
this.COMMA = ',';
this.PERIOD = '.';
this.DASH = '-'; 
this.LEFT_PAREN = '('; 
this.RIGHT_PAREN = ')'; 
this.LEFT_OUTSIDE = 0; 
this.LEFT_INSIDE = 1;  
this.RIGHT_INSIDE = 2;  
this.RIGHT_OUTSIDE = 3;  
this.LEFT_DASH = 0; 
this.RIGHT_DASH = 1; 
this.PARENTHESIS = 2; 
this.NO_ROUNDING = -1 
this.num;
this.numOriginal;
this.hasSeparators = false;  
this.separatorValue;  
this.inputDecimalValue; 
this.decimalValue;  
this.negativeFormat; 
this.negativeRed; 
this.hasCurrency;  
this.currencyPosition;  
this.currencyValue;  
this.places;
this.roundToPlaces; 
this.truncate; 
this.setNumber = setNumberNF;
this.toUnformatted = toUnformattedNF;
this.setInputDecimal = setInputDecimalNF; 
this.setSeparators = setSeparatorsNF; 
this.setCommas = setCommasNF;
this.setNegativeFormat = setNegativeFormatNF; 
this.setNegativeRed = setNegativeRedNF; 
this.setCurrency = setCurrencyNF;
this.setCurrencyPrefix = setCurrencyPrefixNF;
this.setCurrencyValue = setCurrencyValueNF; 
this.setCurrencyPosition = setCurrencyPositionNF; 
this.setPlaces = setPlacesNF;
this.toFormatted = toFormattedNF;
this.toPercentage = toPercentageNF;
this.getOriginal = getOriginalNF;
this.moveDecimalRight = moveDecimalRightNF;
this.moveDecimalLeft = moveDecimalLeftNF;
this.getRounded = getRoundedNF;
this.preserveZeros = preserveZerosNF;
this.justNumber = justNumberNF;
this.expandExponential = expandExponentialNF;
this.getZeros = getZerosNF;
this.moveDecimalAsString = moveDecimalAsStringNF;
this.moveDecimal = moveDecimalNF;
this.addSeparators = addSeparatorsNF;
if (inputDecimal == null) {
this.setNumber(num, this.PERIOD);
} else {
this.setNumber(num, inputDecimal); 
}
this.setCommas(true);
this.setNegativeFormat(this.LEFT_DASH); 
this.setNegativeRed(false); 
this.setCurrency(false); 
this.setCurrencyPrefix('$');
this.setPlaces(2);
}
function setInputDecimalNF(val)
{
this.inputDecimalValue = val;
}
function setNumberNF(num, inputDecimal)
{
if (inputDecimal != null) {
this.setInputDecimal(inputDecimal); 
}
this.numOriginal = num;
this.num = this.justNumber(num);
}
function toUnformattedNF()
{
return (this.num);
}
function getOriginalNF()
{
return (this.numOriginal);
}
function setNegativeFormatNF(format)
{
this.negativeFormat = format;
}
function setNegativeRedNF(isRed)
{
this.negativeRed = isRed;
}
function setSeparatorsNF(isC, separator, decimal)
{
this.hasSeparators = isC;
if (separator == null) separator = this.COMMA;
if (decimal == null) decimal = this.PERIOD;
if (separator == decimal) {
this.decimalValue = (decimal == this.PERIOD) ? this.COMMA : this.PERIOD;
} else {
this.decimalValue = decimal;
}
this.separatorValue = separator;
}
function setCommasNF(isC)
{
this.setSeparators(isC, this.COMMA, this.PERIOD);
}
function setCurrencyNF(isC)
{
this.hasCurrency = isC;
}
function setCurrencyValueNF(val)
{
this.currencyValue = val;
}
function setCurrencyPrefixNF(cp)
{
this.setCurrencyValue(cp);
this.setCurrencyPosition(this.LEFT_OUTSIDE);
}
function setCurrencyPositionNF(cp)
{
this.currencyPosition = cp
}
function setPlacesNF(p, tr)
{
this.roundToPlaces = !(p == this.NO_ROUNDING); 
this.truncate = (tr != null && tr); 
this.places = (p < 0) ? 0 : p; 
}
function addSeparatorsNF(nStr, inD, outD, sep)
{
nStr += '';
var dpos = nStr.indexOf(inD);
var nStrEnd = '';
if (dpos != -1) {
nStrEnd = outD + nStr.substring(dpos + 1, nStr.length);
nStr = nStr.substring(0, dpos);
}
var rgx = /(\d+)(\d{3})/;
while (rgx.test(nStr)) {
nStr = nStr.replace(rgx, '$1' + sep + '$2');
}
return nStr + nStrEnd;
}
function toFormattedNF()
{	
var pos;
var nNum = this.num; 
var nStr;            
var splitString = new Array(2);   
if (this.roundToPlaces) {
nNum = this.getRounded(nNum);
nStr = this.preserveZeros(Math.abs(nNum)); 
} else {
nStr = this.expandExponential(Math.abs(nNum)); 
}
if (this.hasSeparators) {
nStr = this.addSeparators(nStr, this.PERIOD, this.decimalValue, this.separatorValue);
} else {
nStr = nStr.replace(new RegExp('\\' + this.PERIOD), this.decimalValue); 
}
var c0 = '';
var n0 = '';
var c1 = '';
var n1 = '';
var n2 = '';
var c2 = '';
var n3 = '';
var c3 = '';
var negSignL = (this.negativeFormat == this.PARENTHESIS) ? this.LEFT_PAREN : this.DASH;
var negSignR = (this.negativeFormat == this.PARENTHESIS) ? this.RIGHT_PAREN : this.DASH;
if (this.currencyPosition == this.LEFT_OUTSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
}
if (this.hasCurrency) c0 = this.currencyValue;
} else if (this.currencyPosition == this.LEFT_INSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
}
if (this.hasCurrency) c1 = this.currencyValue;
}
else if (this.currencyPosition == this.RIGHT_INSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n0 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n3 = negSignR;
}
if (this.hasCurrency) c2 = this.currencyValue;
}
else if (this.currencyPosition == this.RIGHT_OUTSIDE) {
if (nNum < 0) {
if (this.negativeFormat == this.LEFT_DASH || this.negativeFormat == this.PARENTHESIS) n1 = negSignL;
if (this.negativeFormat == this.RIGHT_DASH || this.negativeFormat == this.PARENTHESIS) n2 = negSignR;
}
if (this.hasCurrency) c3 = this.currencyValue;
}
nStr = c0 + n0 + c1 + n1 + nStr + n2 + c2 + n3 + c3;
if (this.negativeRed && nNum < 0) {
nStr = '<font color="red">' + nStr + '</font>';
}
return (nStr);
}
function toPercentageNF()
{
nNum = this.num * 100;
nNum = this.getRounded(nNum);
return nNum + '%';
}
function getZerosNF(places)
{
var extraZ = '';
var i;
for (i=0; i<places; i++) {
extraZ += '0';
}
return extraZ;
}
function expandExponentialNF(origVal)
{
if (isNaN(origVal)) return origVal;
var newVal = parseFloat(origVal) + ''; 
var eLoc = newVal.toLowerCase().indexOf('e');
if (eLoc != -1) {
var plusLoc = newVal.toLowerCase().indexOf('+');
var negLoc = newVal.toLowerCase().indexOf('-', eLoc); 
var justNumber = newVal.substring(0, eLoc);
if (negLoc != -1) {
var places = newVal.substring(negLoc + 1, newVal.length);
justNumber = this.moveDecimalAsString(justNumber, true, parseInt(places));
} else {
if (plusLoc == -1) plusLoc = eLoc;
var places = newVal.substring(plusLoc + 1, newVal.length);
justNumber = this.moveDecimalAsString(justNumber, false, parseInt(places));
}
newVal = justNumber;
}
return newVal;
} 
function moveDecimalRightNF(val, places)
{
var newVal = '';
if (places == null) {
newVal = this.moveDecimal(val, false);
} else {
newVal = this.moveDecimal(val, false, places);
}
return newVal;
}
function moveDecimalLeftNF(val, places)
{
var newVal = '';
if (places == null) {
newVal = this.moveDecimal(val, true);
} else {
newVal = this.moveDecimal(val, true, places);
}
return newVal;
}
function moveDecimalAsStringNF(val, left, places)
{
var spaces = (arguments.length < 3) ? this.places : places;
if (spaces <= 0) return val; 
var newVal = val + '';
var extraZ = this.getZeros(spaces);
var re1 = new RegExp('([0-9.]+)');
if (left) {
newVal = newVal.replace(re1, extraZ + '$1');
var re2 = new RegExp('(-?)([0-9]*)([0-9]{' + spaces + '})(\\.?)');		
newVal = newVal.replace(re2, '$1$2.$3');
} else {
var reArray = re1.exec(newVal); 
if (reArray != null) {
newVal = newVal.substring(0,reArray.index) + reArray[1] + extraZ + newVal.substring(reArray.index + reArray[0].length); 
}
var re2 = new RegExp('(-?)([0-9]*)(\\.?)([0-9]{' + spaces + '})');
newVal = newVal.replace(re2, '$1$2$4.');
}
newVal = newVal.replace(/\.$/, ''); 
return newVal;
}
function moveDecimalNF(val, left, places)
{
var newVal = '';
if (places == null) {
newVal = this.moveDecimalAsString(val, left);
} else {
newVal = this.moveDecimalAsString(val, left, places);
}
return parseFloat(newVal);
}
function getRoundedNF(val)
{
val = this.moveDecimalRight(val);
if (this.truncate) {
val = val >= 0 ? Math.floor(val) : Math.ceil(val); 
} else {
val = Math.round(val);
}
val = this.moveDecimalLeft(val);
return val;
}
function preserveZerosNF(val)
{
var i;
val = this.expandExponential(val);
if (this.places <= 0) return val; 
var decimalPos = val.indexOf('.');
if (decimalPos == -1) {
val += '.';
for (i=0; i<this.places; i++) {
val += '0';
}
} else {
var actualDecimals = (val.length - 1) - decimalPos;
var difference = this.places - actualDecimals;
for (i=0; i<difference; i++) {
val += '0';
}
}
return val;
}
function justNumberNF(val)
{
newVal = val + '';
var isPercentage = false;
if (newVal.indexOf('%') != -1) {
newVal = newVal.replace(/\%/g, '');
isPercentage = true; 
}
var re = new RegExp('[^\\' + this.inputDecimalValue + '\\d\\-\\+\\(\\)eE]', 'g');	
newVal = newVal.replace(re, '');
var tempRe = new RegExp('[' + this.inputDecimalValue + ']', 'g');
var treArray = tempRe.exec(newVal); 
if (treArray != null) {
var tempRight = newVal.substring(treArray.index + treArray[0].length); 
newVal = newVal.substring(0,treArray.index) + this.PERIOD + tempRight.replace(tempRe, ''); 
}
if (newVal.charAt(newVal.length - 1) == this.DASH ) {
newVal = newVal.substring(0, newVal.length - 1);
newVal = '-' + newVal;
}
else if (newVal.charAt(0) == this.LEFT_PAREN
&& newVal.charAt(newVal.length - 1) == this.RIGHT_PAREN) {
newVal = newVal.substring(1, newVal.length - 1);
newVal = '-' + newVal;
}
newVal = parseFloat(newVal);
if (!isFinite(newVal)) {
newVal = 0;
}
if (isPercentage) {
newVal = this.moveDecimalLeft(newVal, 2);
}
return newVal;
}

// JavaScript Document
function setHtml(id, html){
	get(id).innerHTML = html;
} 

// JavaScript Validation Functions
// JavaScript Document
/*
 * verifica se o campo indicado pelo ID contém apenas números
 */
function digitCheck (fieldID, nomeCampo) {
	var field = document.getElementById(fieldID).value;
	var pat=/^\d+$/;
	var matchArray=field.match(pat);
	if (matchArray==null && field != '') {
		alert("O campo "+nomeCampo+" deve conter apenas dígitos");
		return false;
	}
	return true;
} 
// JavaScript Document
/*
 * Verifica se o email contido campo indicado pelo ID ? v?lido
 *    This script and many more are available free online at
 *    The JavaScript Source!! http://javascript.internet.com
 */
function emailCheck (fieldID) {
	var emailStr = document.getElementById(fieldID).value;
	
	// The following variable tells the rest of the function whether or not
	// to verify that the address ends in a two-letter country or well-known
	// TLD.  1 means check it, 0 means don't.
	var checkTLD=1;
	
	// The following is the list of known TLDs that an e-mail address must end with. 
	var knownDomsPat=/^(br|com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	
	// The following pattern is used to check if the entered e-mail address
	// fits the user@domain format.  It also is used to separate the username
	// from the domain.
	var emailPat=/^(.+)@(.+)$/;
	
	// The following string represents the pattern for matching all special
	// characters.  We don't want to allow special characters in the address. 
	// These characters include ( ) < > @ , ; : \ " . [ ] 
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	
	// The following string represents the range of characters allowed in a 
	// username or domainname.  It really states which chars aren't allowed.
	var validChars="\[^\\s" + specialChars + "\]";
	
	// The following pattern applies if the "user" is a quoted string (in
	// which case, there are no rules about which characters are allowed
	// and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
	//is a legal e-mail address.
	var quotedUser="(\"[^\"]*\")";
	
	// The following pattern applies for domains that are IP addresses,
	//rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
	//e-mail address. NOTE: The square brackets are required. 
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	
	// The following string represents an atom (basically a series of non-special characters.) 
	var atom=validChars + '+';
	
	// The following string represents one word in the typical username.
	// For example, in john.doe@somewhere.com, john and doe are words.
	// Basically, a word is either an atom or quoted string. 
	var word="(" + atom + "|" + quotedUser + ")";
	
	// The following pattern describes the structure of the user
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	
	// The following pattern describes the structure of a normal symbolic
	// domain, as opposed to ipDomainPat, shown above. 	
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	
	// Finally, let's start trying to figure out if the supplied address is valid. 
	
	// Begin with the coarse pattern to simply break up user@domain into
	// different pieces that are easy to analyze. 
	
	var matchArray=emailStr.match(emailPat);	
	if (matchArray==null) {	
		//  Too many/few @'s or something; basically, this address doesn't
		// even fit the general mould of a valid e-mail address. 		
		alert("O e-mail não é válido (verifique  @ e .)");
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	
	// Start by checking that only basic ASCII characters are in the strings (0-127).	
	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			alert("O username contém caracteres inválidos.");
			return false;
		}
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			alert("O domínio contém caracteres inválidos.");
			return false;
	   }
	}
	
	// See if "user" is valid 	
	if (user.match(userPat)==null) {	
		// user is not valid		
		alert("O  username do e-mail não é válido.");
		return false;
	}
	
	// if the e-mail address is at an IP address (as opposed to a symbolic
	// host name) make sure the IP address is valid. 	
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {	
		// this is an IP address		
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				alert("O endereço IP do e-mail é inválido!");
				return false;
			}
		}
		return true;
	}
	
	// Domain is symbolic name.  Check if it's valid.	 
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			alert("O domínio do e-mail não é válido.");
			return false;
		}
	}
	
	// domain name seems valid, but now make sure that it ends in a
	// known top-level domain (like com, edu, gov) or a two-letter word,
	// representing country (uk, nl), and that there's a hostname preceding 
	// the domain or country. 
	if (checkTLD && domArr[domArr.length-1].length!=2 && 
		domArr[domArr.length-1].search(knownDomsPat)==-1) {
		alert("O endereço deve terminar com um domínio conhecido ou abreviatura de duas letras do país.");
		return false;
	}
	
	// Make sure there's a host name preceding the domain.	
	if (len<2) {
	alert("O Host está faltando no e-mail!");
	return false;
	}
	
	// If we've gotten this far, everything's valid!
	return true;
} 
// JavaScript Document
/*
 * verifica se o campo indicado pelo ID está vazio
 */
function emptyCheck (fieldID, nomeCampo) {
	var field = document.getElementById(fieldID).value;
	var pat=/^.+$/;
	var matchArray=field.match(pat);
	if (matchArray==null) {
		alert("O campo "+nomeCampo+" deve ser preenchido.");
		return false;
	}
	return true;
} 
// JavaScript Document
/*
 *  verifica se o campo indicado pelo ID tem no máximo 'size' caracteres
 */
function limitCheck(fieldID, size, nomeCampo){
	if(document.getElementById(fieldID).value.length > size){
		alert("O campo "+nomeCampo+" deve ter no máximo "+size+" caracteres.");
		return false;
	}else{
		return true;
	}
} 

