var Plugins = new Array();
var processElements = false;
function compileApp( pDocument ) {
	if (! pDocument) 
		pDocument = document;
	initializeDebug( pDocument );
	initializeDate( pDocument );
	initializeCurrency( pDocument );
	for (var c = 0; c < Plugins.length; c++) 
		if (Plugins[c].initialize)
			Plugins[c].initialize(pDocument);
	if (processElements) {
		for (var f = 0; f < pDocument.forms.length; f++) {
			appCompileForm(pDocument.forms[f], f);
		}
	}
	for (var c = 0; c < Plugins.length; c++) 
		if (Plugins[c].terminate) 
			Plugins[c].terminate(pDocument);
	pDocument.jslibCompiled = true;
}
function appCompileForm ( form, index ) {
	form.jslibCompiled = false;
	if (form.getAttribute('OnBeforeCompile')) {
		var content = form.getAttribute('OnBeforeCompile');
		form.onBeforeCompile = function () { return(eval(content)) };
		form.onBeforeCompile();
	}
	for (var c = 0; c < Plugins.length; c++) {
		if (Plugins[c].startForm) 
			Plugins[c].startForm(form, index);
	}
	for (var e = 0; e < form.length; e++) {
		form.elements[e].jslibCompiled = false;
		for (var c = 0; c < Plugins.length; c++) 
			if (Plugins[c].processElement) 
				Plugins[c].processElement(form.elements[e], e);
		form.elements[e].jslibCompiled = true;
	}
	for (var c = 0; c < Plugins.length; c++) 
		if (Plugins[c].finishForm) 
			Plugins[c].finishForm(form, index);
	if (form.getAttribute('OnAfterCompile')) {
		var content = form.getAttribute('OnAfterCompile');
		form.onAfterCompile = function () { return(eval(content)) };
		form.onAfterCompile();
	}
	form.jslibCompiled = true;
}
function appAddCompile ( component ) {
    Plugins[Plugins.length] = component;
	processElements = processElements || (component.processElement ? true : false) || (component.startForm ? true : false) || (component.finishForm ? true : false);
}
function include( src, path ) {
	src = src.split('.');
	if ( src[ src.length - 1 ] == 'js') 
		src.length -= 1;
	path = path || libraryPATH || '';
	if ( path.substr( path.length - 1 ) != "/" )
		path += "/";
	document.write('<script language="Javascript1.2" src="' + path + src.join('/') + '.js"><\/script>');
}
var debugLogging = false;
var debugLogIdentation = 0;
var debugWinLog = null;
function initializeDebug( document ) {
	if (getProp(document.body, 'debug') == 'true') {
		makeLog();
	}
}
function makeLog(pDo) {
	debugLogging = ( (arguments.length == 0) || (pDo) );
}
function doLog(pText, pOffset) {
	if (! debugLogging) 
		return;
	pOffset = Number(pOffset);
	if ( (pOffset < 0) && ( debugLogIdentation > 0 ) )
		debugLogIdentation += pOffset;
	if (this.logIdentation > 0)
		pText = Replicate('.  ', debugLogIdentation) + pText;
	if ( (debugWinLog == null) || (! debugWinLog.opened) ) {
		debugWinLog = window.open("","debugWinLog","height=400,width=550,status=1,resizable=1,scrollbars=1");
		debugWinLog.document.write( '<pre>' );
	}
	debugWinLog.document.write( '('+ debugNow() +') '+ pText );
	if (pOffset > 0)
		debugLogIdentation += pOffset;
}
function debugNow() {
	var pDate = new Date();
	var Y = pDate.getYear();
	var M = pDate.getMonth();
	var D = pDate.getDay();
	var H = pDate.getHours();
	var N = pDate.getMinutes();
	var S = pDate.getSeconds();
	pDate = (Y+1900) + '-';
	pDate += (M < 10 ? '0' : '') + M + '-';
	pDate += (D < 10 ? '0' : '') + D + ' ';
	pDate += (H < 10 ? '0' : '') + H + ':';
	pDate += (N < 10 ? '0' : '') + N + ':';
	pDate += (S < 10 ? '0' : '') + S;
	return(pDate);
}
function showObject(pObject) {
	if ( (pObject == "") || (pObject == null) ) { pObject = this; }
	var getProperties = function ( pObject ) { 
		var vProps = ''; 
		vProps = '<html><body><table border="2" width="90%" cols="2">';
		vProps += '<tr align="left" bgcolor="lightgrey"><th>Property</th><th>Value</th></tr>';
		for (var propName in pObject) { 
			try {
				vProps +="<tr><td>"+ propName +"</td><td>"+ pObject[propName] +"&nbsp;</td></tr>";
			} catch(e) {
				vProps +="<tr><td colspan=\"2\">Error: "+ propName +" - "+ e +"&nbsp;</td></tr>";
			}
		} 
		vProps +="</table></body></html>";
		return vProps;
	} 
	var newWindow = window.open('','propWin','height=400,width=350,status=1,resizable=1,scrollbars=1');
	newWindow.document.write( getProperties( pObject ) );
	newWindow.document.close();
	newWindow.focus();
}
function assert(fact, details) {
	if (fact) {
		var msg = "Assert [failure] " + details;
		msg = msg + " in function: \n" + getStackTrace();
		alert(msg);
	}
}
function getFunctionName(aFunction) {
  var name = aFunction.toString().match(/function (\w*)/)[1];
  if ((name == null) || (name.length == 0))
	name = 'anonymous';
  return name;
}
function getStackTrace() {
  var result = '';
  if (typeof(arguments.caller) != 'undefined') { 
	for (var a = arguments.caller; a != null; a = a.caller) {
	  var func = getFunctionName(a.caller);
	  result += '> ' + func + '\n';
	  if (a.caller == a) {
		result += '*';
		break;
	  }
	}
  }
  else { 
	var testExcp;
	try
	{
	  foo.bar;
	}
	catch(testExcp)
	{
	  var stack = parseErrorStack(testExcp);
	  for (var i = 1; i < stack.length; i++)
	  {
		result += '> ' + stack[i][0] + '('+ stack[i][1] +') ' + stack[i][2] +':'+ stack[i][3] + '\n';
	  }
	}
  }
  return result;
}
function parseErrorStack(excp)
{
  var stack = [];
  var name;
  if (!excp || !excp.stack)
  {
	return stack;
  }
  var stacklist = excp.stack.split('\n');
  for (var i = 0; i < stacklist.length - 1; i++)
  {
	var framedata = stacklist[i];
	name = framedata.match(/^(\w*)\(([^\)]*)\)@(.+):(\d+)/);
	if (name.length) 
		name.shift();
	stack[stack.length] = name;
  }
  while (stack.length && (! stack[stack.length - 1].length) )
  {
	stack.length = stack.length - 1;
  }
  return stack;
}
function ChangeMacros(pText) {
  if (arguments.length) {
    for (var i = 1; i < arguments.length; i+=2) {
	    pText = pText.replace(new RegExp('%'+ arguments[i] +'%', 'g'), arguments[i+1]);
    }
  }
  return(pText);
}
function Replicate(pString, pCount){
	var vString = '';
	for (var i = 0; i < pCount; i++) vString += pString;
	return(vString);
}
function STrim(pString) {
	return(String(pString).replace(/^ +| +$/g, ''));
}
function hexToString(str) {
	return String.fromCharCode(parseInt(str,16));
}
function decodeUrl(url) {
	return url.replace(/[0-9A-F]{2}/g,hexToString);
}
function isMozilla() { return(isGecko()); }
function isGecko() {
    return(navigator.userAgent.indexOf('Gecko') != -1);
}
function isInternetExplorer() { return(isMSIE()); }
function isMSIE() {
	return( navigator.appName == "Microsoft Internet Explorer" );
}
function isMSIE5() {
    return( isMSIE() && (navigator.userAgent.indexOf('MSIE 5') != -1) );
}
function isMSIE5_0() {
    return( isMSIE() && (navigator.userAgent.indexOf('MSIE 5.0') != -1) );
}
function isMSIE501AtLeast() {
	return(isMSIEAtLeast(5.01));
}
function isMSIE55AtLeast() {
	return(isMSIEAtLeast(5.5));
}
function isMSIEAtLeast(version) {
	var Result = false;
	if (version) {
		var UA =  navigator.userAgent.match(new RegExp('MSIE ([^;]+)'));
		if ( (UA) && (typeof(UA) == 'object') && (UA.length) ) {
			UA = Number(UA[UA.length - 1]);
			if ( (! isNaN(UA)) && (UA >= version) && (navigator.userAgent.indexOf('Opera') == -1) ) {
				Result = true;
			}
		}
	}
	return(Result);
}
function isOpera() {
	return((navigator.appName.indexOf("Opera") != -1) ? true : false);
}
var formatDate = 'br';
function initializeDate( document ) {
	var vFormat = getProp(document.body, 'formatDate');
	if (vFormat) 
	    formatDate = vFormat;
}
function getExtensionDate(pDate, pFormat) {
	if (! (pFormat)) 
	    pFormat = formatDate;
	var Data = pDate.getDate();
	var Dia  = pDate.getDay();
	var Mes  = pDate.getMonth();
	var Ano  = pDate.getYear();
	Ano = (Ano < 30)  ? Ano + 2000 : Ano;
	Ano = (Ano < 100) ? Ano + 1900 : Ano;
	if (Data < 10) { Data = "0" + Data; }
	var nomeDia = new Array(7);
	nomeDia[0] = "Domingo";
	nomeDia[1] = "Segunda-feira";
	nomeDia[2] = "Terça-feira";
	nomeDia[3] = "Quarta-feira";
	nomeDia[4] = "Quinta-feira";
	nomeDia[5] = "Sexta-feira";
	nomeDia[6] = "Sábado";
	var nomeMes = new Array(12);
	nomeMes[0]  = "Janeiro";
	nomeMes[1]  = "Fevereiro";
	nomeMes[2]  = "Mar&ccedil;o";
	nomeMes[3]  = "Abril";
	nomeMes[4]  = "Maio";
	nomeMes[5]  = "Junho";
	nomeMes[6]  = "Julho";
	nomeMes[7]  = "Agosto";
	nomeMes[8]  = "Setembro";
	nomeMes[9]  = "Outubro";
	nomeMes[10] = "Novembro";
	nomeMes[11] = "Dezembro";
	return nomeDia[Dia] + ", " + Data + " de " + nomeMes[Mes] + " de " + Ano;
}
function getDate() {
	var vDate = new Date();
	var vYear = vDate.getYear();
	if ( (vYear > 40) && (vYear < 140) ) { vYear += 1900; }
	return(fullDate( vDate.getDate() +'/'+ (vDate.getMonth() + 1) +'/'+ vYear ));
}
function isDate(pDate, pFormat) {
	var monthDays = function (pM, pY) {
		if (pM == 4 || pM == 6 || pM == 9 || pM == 11) 
			return(30);
		if (pM == 2) {
			if ((pY % 4 == 0) && ( (pY % 100 != 0) || (pY % 400 == 0))) 
				return(29);
			else 
				return(28);
		}
		return(31);
	}
	if (! (pFormat)) 
	    pFormat = formatDate;
	else if (Number(pFormat)) 
		pFormat = (Number(pFormat) == 1) ? 'us' : 'br';
	var aDate = String(pDate).split( /[^0-9]/ );
	if (aDate.length < 3) 
		return(false);
	if (pFormat == 'us') {
		var aux = aDate[0];
		aDate[0] = aDate[1];
		aDate[1] = aux;
	}
	for (var i = 0; i < 3; i++) {
		aDate[i] = Number(aDate[i]);
	    if (isNaN(aDate[i]))
			return(false);
	}
	aDate[2] = (aDate[2] < 100) ? aDate[2] + 1900 : aDate[2];
	if (aDate[0] < 1 || aDate[0] > 31 || aDate[0] > monthDays(aDate[1], aDate[2])) 
		return(false);
	if (aDate[1] < 1 || aDate[1] > 12) 
		return(false);
	if (aDate[2] < 1) 
		return(false);
	return(true);
}
function fullDate(pDate, pChar) {
	if (! pDate)
		return('');
	var aDate = String(pDate).split( /[^0-9]/ );
	if (aDate.length < 3) 
		return(pDate);
	for (var i = 0; i < 3; i++) {
		aDate[i] = Number(aDate[i]);
	    if (isNaN(aDate[i])) 
			return(pDate);
		if (i < 2 && aDate[i] <= 9) 
			aDate[i] = '0' + aDate[i];
	}
	aDate[2] = (aDate[2] < 30)  ? aDate[2] + 2000 : aDate[2];
	aDate[2] = (aDate[2] < 100) ? aDate[2] + 1900 : aDate[2];
	pChar = (pChar) ? pChar : '/';
	return(aDate.join(pChar));
}
function maskDate(pDate, pChar) {
	pDate = String(pDate);
	if ( (pDate.match( /\D/ ) == null) && (pDate.length >= 5) ) 
		pDate = pDate.substr(0, 2) +'.'+ pDate.substr(2, 2) +'.'+ pDate.substr(4);
	return( fullDate( pDate, pChar ) );
}
function getTime() {
	var vDate = new Date();
	return(shortTime( vDate.getHours() +':'+ vDate.getMinutes() ));
}
function isTime(pTime) {
	var aTime = String(pTime).split( /[^0-9]/ );
	if (aTime.length < 2) {
		return(false);
	}
	if (aTime.length == 2) {
		aTime[2] = 0;
	}
	for (var i = 0; i < 3; i++) {
		aTime[i] = Number(aTime[i]);
		if (isNaN(aTime[i])) {
			return(false);
		}
	}
	if (aTime[0] < 0 || aTime[0] > 23) {
	    return(false);
	}
	if (aTime[1] < 0 || aTime[1] > 59) {
	    return(false);
	}
	if (aTime[2] < 0 || aTime[2] > 59) {
	    return(false);
	}
	return(true);
}
function shortTime(pTime, pChar) {
	var aTime = String(pTime).split( /[^0-9]/ );
	if (aTime.length < 2) {
		return(pTime);
	}
	for (var i = 0; i < aTime.length; i++) {
		aTime[i] = Number(aTime[i]);
		if (isNaN(aTime[i])) {
			return;
		}
		if (aTime[i] <= 9) {
			aTime[i] = '0' + aTime[i];
		}
	}
	return( aTime.join(pChar ? pChar : ':') );
}
function maskTime(pTime) {
	var aTime = String(pTime).split(/\D/);
	if (aTime.length == 1) {
		var vTime = String(aTime[0]);
		var nStart = Number(vTime.substr(0, 1));
		if ( ( vTime.length >= 4 ) || (nStart < 2) || ( (nStart == 2) && Number(vTime.substr(1, 1)) <= 4 ) ) {
			aTime[1] = vTime.substr(2, 4);
			aTime[0] = vTime.substr(0, 2);
		}
		else {
			aTime[1] = vTime.substr(1, 2);
			aTime[0] = vTime.substr(0, 1);
		}
	}
	for (var i = 0; i < 2; i++) {
		switch (String(aTime[i]).length) {
			case 0:
				aTime[i] = '00';
				break;
			case 1:
				aTime[i] = '0' + String(aTime[i]);
				break;
			default :
		}
	}
	return(aTime.join(':'));
}
var formatCurrency = 'br';
var decimalCurrency = 2;
var usSeparator = {};
	usSeparator['decimal'] = '.';
	usSeparator['other'] = ',';
	usSeparator['decimalReg'] = '\\.';
	usSeparator['otherReg'] = ',';
var brSeparator = {};
	brSeparator['decimal'] = ',';
	brSeparator['other'] = '.';
	brSeparator['decimalReg'] = ',';
	brSeparator['otherReg'] = '\\.';
function initializeCurrency( document ) {
	var vFormat = getProp(document.body, 'formatCurrency');
	if (vFormat) 
	    formatCurrency = vFormat;
	var vDecimal = getProp(document.body, 'decimalCurrency');
	if (! isNaN(Number(vDecimal))) 
	    decimalCurrency = vDecimal;
}
function getDecimalPoint(pLang) {
	if (! (pLang)) 
	    pLang = formatCurrency;
	else if (Number(pLang)) 
		pLang = (Number(pLang) == 1) ? 'us' : 'br';
	if (pLang == 'us')
	    return(usSeparator['decimal']);
	else 
	    return(brSeparator['decimal']);
}
function getDecimalPointRegExp(pLang) {
	if (! (pLang)) 
	    pLang = formatCurrency;
	else if (Number(pLang)) 
		pLang = (Number(pLang) == 1) ? 'us' : 'br';
	if (pLang == 'us')
	    return(usSeparator['decimalReg']);
	else 
	    return(brSeparator['decimalReg']);
}
function getCurrency(pCurrency, pLang) {
	if (! (pLang)) 
	    pLang = formatCurrency;
	else if (Number(pLang)) 
		pLang = (Number(pLang) == 1) ? 'us' : 'br';
	var Separator;
	if (pLang == 'us')
	    Separator = usSeparator;
	else 
	    Separator = brSeparator;
	var vReg = new RegExp(Separator['otherReg'], 'g');
	pCurrency = String(pCurrency).replace(vReg, '');
	var aCurrency = pCurrency.split(Separator['decimalReg']);
	vReg = new RegExp(Separator['decimalReg'], 'g');
	pCurrency = pCurrency.replace(vReg, '.');
	return(pCurrency);
}
function isCurrency(pCurrency, pLang) {
	return(! isNaN( getCurrency(pCurrency, pLang) ));
}
function fullCurrency(pCurrency, pDecimal, pLang, pSimple) {
	var vCurrency = getCurrency(pCurrency, pLang);
	var aCurrency = vCurrency.split(/\./);
	for (var i = 0; i < 2; i++) {
	    if ( (! aCurrency[i]) || ( isNaN(Number(aCurrency[i])) ) )
	        aCurrency[i] = '0';
	}
	if (! pDecimal) 
		pDecimal = decimalCurrency;
	if ( (aCurrency[1] != '') && (aCurrency[1].length > pDecimal) )
	   aCurrency[1] = aCurrency[1].substr(0, pDecimal);
	else if (aCurrency[1].length < pDecimal) 
	   aCurrency[1] += Replicate('0', pDecimal - aCurrency[1].length);
	var vGroups = aCurrency[0].length / 3;
	if (vGroups != parseInt(vGroups))
		vGroups = parseInt(vGroups) + 1;
	var vCurrency = '';
	if (pSimple) {
	    vCurrency = aCurrency[0];
	}
	else {
		for (var i = aCurrency[0].length - 3; i > 0; i -= 3) {
			vCurrency = '.' + aCurrency[0].substr(i, 3) + vCurrency;
		}
		vRest = aCurrency[0].length % 3;
		vCurrency = aCurrency[0].substr(0, vRest == 0 ? 3 : vRest) + vCurrency;
		vCurrency = vCurrency.replace(/^\./, '');
	}
	if (aCurrency[1] != '') {
		var Separator;
		if (pLang == 'us')
			Separator = usSeparator;
		else 
			Separator = brSeparator;
		vCurrency += Separator['decimal'] + aCurrency[1];
	}
	return(vCurrency);
}
function simpleCurrency(pCurrency, pDecimal, pLang) {
	return( fullCurrency(pCurrency, pDecimal, pLang, true) );
}
function getNodeValue(node) {
	var html = '';
	if (node && node.firstChild) {
		var nodechild = node.firstChild;
		while (nodechild) {
			html += nodechild.nodeValue;
			nodechild = nodechild.nextSibling;
		}
	}
	return html;
}
function getProp(node, prop) {
	var value = '';
	if ( (node) && (node.getAttribute) ) {
		value = node.getAttribute(prop);
		if ( (typeof(value) == 'undefined') || (value == null) ) value = ''
	}
	return(value);
}
function setProp(node, prop, value) {
	if ( (node) && (node.setAttribute) ) {
		node.setAttribute(prop, (typeof(value) != 'undefined' ? value : '') );
		return(1);
	}
	return(0);
}
function getStyle(id, propName) {
	var nodes = processNodes(id);
	var value;
	if (nodes.length) {
		var prop = nodes[0];
		if (prop.style) { prop = prop.style; }
		value = prop[propName];
	}
	return value;
}
function setStyle(id, propName, value) {
	var nodes = processNodes(id);
	for (var counter = 0; counter < nodes.length; counter++) {
		var prop = nodes[counter];
		if (prop) {
			if (prop.style) { prop = prop.style; }
			prop[propName] = value;
		}
	}
}
function getStyleSheetRule(pRule) {
	var vRules = getStyleSheetRules( { 'single' : pRule } );
	return( vRules ? vRules['single'] : vRules );
}
function getStyleSheetRules(pRules) {
	var ruleItems = {};
	if ( (document.styleSheets) && (document.styleSheets.length) ) {
		var ruleFound = {}, vSingle = false, vBreak;
		if (typeof(pRules) == 'object') {
			for (var j = 0; j < document.styleSheets.length; j++) {
				var docRules = (isGecko() ? document.styleSheets[j].cssRules : document.styleSheets[j].rules);
				if ( (docRules) && (docRules.length) ) {
					for (i = 0; i < docRules.length; i++) {
						vBreak = true;
						for (var rName in pRules) {
							var ruleItem = pRules[rName].toLowerCase();
							if ( (docRules[i]) && (docRules[i].selectorText) && (docRules[i].selectorText.toLowerCase() == ruleItem) ) {
								ruleItems[rName] = docRules[i];
								ruleFound[rName] = true;
							}
							else if (! ruleFound[rName]) {
								vBreak = false;
							}
						}
						if (vBreak) 
							break;
					}
				}
				if (vBreak) 
					break;
			}
		}
	}
	return(ruleItems);
}
function selectItem(List, Text) {
	if (STrim(Text) != '') {
		Text = Text.toLowerCase();
		for (var i = 0 ; i < List.options.length ; i++) {
			if (String(List.options[i].text).toLowerCase() == Text) {
				List.selectedIndex = i;
				return(i);
			}
		}
	}
	return(-1);
}
function setItemComboByValue(combo, value) { selectItemByValue(combo, value); }
function selectItemByValue(List, Value) {
		for (var i = 0 ; i < List.options.length ; i++) {
			if (List.options[i].value == Value) {
				List.selectedIndex = i;
				return(i);
			}
		}
	return(-1);
}
function findObject(name, doc) {
	if (! doc)
		doc = document;
	if (typeof(name) == 'object')
		return(name);
	var vPos;
	if ( name.indexOf && ( vPos = name.indexOf('?') ) > 0 && parent.frames.length ) {
	    doc = parent.frames[ name.substring(vPos + 1) ].document;
		name = name.substring(0, vPos);
	}
	var vObj;
	if ( !( vObj = doc[name] ) && doc.all ) 
		vObj = doc.all[name];
	if ( (! vObj) && doc.getElementById) 
		vObj = doc.getElementById(name);
	for (var i = 0; (!vObj) && (doc.forms && i < doc.forms.length); i++) 
		vObj = doc.forms[i][name];
	for (var i = 0; (!vObj) && doc.layers && (i < doc.layers.length); i++) 
		vObj = findObject( name, doc.layers[i].document );
	return( vObj );
}
function setEvent(obj, evt, fn) {
	if (obj.addEventListener) 
		obj.addEventListener(evt, fn, false);
	else 
		obj['on' + evt] = fn;
}
function setValue(object, value) {
	object = findObject(object);
	if (object) 
		if (isMozilla()) { object.textContent = value; }
			else { object.innerText = value; }
}
function getValue(object, name) {
	object = findObject( name ? name : object);
	if (object) 
		return( isGecko() ? object.textContent : object.innerText );
	else
		return('');
}
function getLastChild(node) {
	if (node.lastChild) {
		node = node.lastChild;
		while (node && (node.nodeName == '#text')) {
			node = node.previousSibling;
		}
		return node;
	}
}
function getFirstChild(node) {
	if (node && node.firstChild) {
		node = node.firstChild;
		while (node && (node.nodeName == '#text')) {
			node = node.nextSibling;
		}
		return node;
	}
}
function getNextSibling(node) {
	if (node.nextSibling) {
		node = node.nextSibling;
		while (node && (node.nodeName == '#text')) {
			node = node.nextSibling;
		}
		return node;
	}
}
function getClassName(node) {
	return getProp(node, (isMSIE() ? 'className' : 'class'));
}
function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}
function myXMLHttpRequest() {
	var req;
    if (window.XMLHttpRequest) {
	    try {
			req = new XMLHttpRequest();
		} catch(e) {
			req = null;
		}
	} 
	else if(window.ActiveXObject) {
		try {
	        req = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch(e) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				req = null;
			}
		}
    }
	return req;
}
function getAnchorPosition(anchorname) {
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
	}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
	}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
	}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
		}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
		}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
	}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
	}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
}
function getAnchorWindowPosition(anchorname) {
	var coordinates=getAnchorPosition(anchorname);
	var x=0;
	var y=0;
	if (document.getElementById) {
		if (isNaN(window.screenX)) {
			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
			y=coordinates.y-document.body.scrollTop+window.screenTop;
		}
		else {
			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
	}
	else if (document.all) {
		x=coordinates.x-document.body.scrollLeft+window.screenLeft;
		y=coordinates.y-document.body.scrollTop+window.screenTop;
	}
	else if (document.layers) {
		x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
	}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
}
function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
}	
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
}
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
}
function autoChange(event) {
	var vResult = true;
	var Content = getProp(this, 'autoChange');
	var Items = String(Content).split(/\s*;\s*/g);
	for (var i = 0; i < Items.length; i++) {
	    var Change = String(Items[i]).match(/^\s*([^:]+)\s*:\s*([^=]+)\s*=\s*([^\s]+)\s*/);
		var element = this;
		if (String(this.tagName).toUpperCase() == 'SELECT') {
			element = this.options[this.selectedIndex];
		}
		changeProp(this.form.elements[Change[1]], Change[2], getProp(element, Change[3])); 
		if ( (Change[2] == 'value') && (this.form.elements[Change[1]]) )
			this.form.elements[Change[1]].value = getProp(element, Change[3]);
	}
	if ( (vResult) && (this.autoChange_onchange) ) {
	    if (this.autoChange_onchange() == false) {
		    vResult = false;
	    }
	}
	return(vResult);
}
function appAutoChange()
{
}
appAutoChange.prototype.getName = function()
{
	return('autoChange');
}
appAutoChange.prototype.processElement = function(element, index)
{
	var Content = getProp(element, 'autoChange');
	if ( (Content) && (STrim(Content) != '') ) {
		if (String(element.tagName).toUpperCase() == 'SELECT') {
			if (element.onchange != autoChange) {
				if (element.onchange) 
					element.autoChange_onchange = element.onchange;
				element.onchange = autoChange;
			}
		}
		else {
			if (getProp(element, 'autoChangeOnClick') == 'true') {
				if (element.onclick != autoChange) {
					if (element.onclick) 
						element.autoChange_onchange = element.onclick;
					element.onclick = autoChange;
				}
			}
		}
	}
}
var pluginAutoChange = new appAutoChange();
if (appAddCompile) {
	appAddCompile( pluginAutoChange );
}
function compileAutoChange( document ) {
	for (var f = 0; f < document.forms.length; f++) {
		compileFormAutoChange(document.forms[f], f);
	}
}
function compileFormAutoChange(form, index) {
	for (var e = 0; e < form.length; e++) {
		pluginAutoChange.processElement(form.elements[e], e);
	}
}
function newOption(event) {
	var vResult = true;
	var Tag = String(getProp(this, 'newOption'));
	if ( (this.selectedIndex > -1) && (this.options[this.selectedIndex].value == Tag) ) {
		var Msg = String(getProp(this, 'newOptionMsg'));
		var Text = window.prompt(Msg, '');
		if ((STrim(Text) == '') || (Text == null)) {
			this.selectedIndex = 0;
		}
		else {
			if (selectItem(this, Text) == -1) {
				var valuePrefix = String(getProp(this, 'newOptionPrefix'));
				var newOption = new Option(Text, valuePrefix+Text, false, true);
				this.options[this.length] = newOption;
				return(this.length - 1);
			}
		}
	}
	if ( (vResult) && (this.newOption_onchange) ) {
	    if (this.newOption_onchange() == false) {
		    vResult = false;
	    }
	}
	return(vResult);
}
function appNewOption()
{
}
appNewOption.prototype.getName = function()
{
	return('newOption');
}
appNewOption.prototype.processElement = function(element, index)
{
	var Content = getProp(element, 'newOption');
	if ( (Content) && (STrim(Content) != '') ) {
		if (String(element.tagName).toUpperCase() == 'SELECT') {
			if (element.onchange != newOption) {
				if (element.onchange) 
					element.newOption_onchange = element.onchange;
				element.onchange = newOption;
			}
		}
	}
}
var pluginNewOption = new appNewOption();
if (appAddCompile) {
	appAddCompile( pluginNewOption );
}
function compileNewOption( document ) {
	for (var f = 0; f < document.forms.length; f++) {
		compileFormNewOption(document.forms[f], f);
	}
}
function compileFormNewOption(form, index) {
	for (var e = 0; e < form.length; e++) {
		pluginNewOption.processElement(form.elements[e], e);
	}
}
function processNodes(id) {
	var nodes;
	switch (typeof(id)) {
	    case 'string' :
	        nodes = [ id ];
	        break;
	    case 'object' :
			nodes = id;
	        break;
	    default :
			nodes = new Array();
			break;
	}
	for (var i = 0; i < nodes.length; i++)
		if (typeof(nodes[i]) == 'string') 
			nodes[i] = findObject( nodes[i] );
	return( nodes );
}
function changeProp(node, prop, value) {
	setProp(node, prop, value);
	if (node.mask_refresh) 
		node.mask_refresh( 'nofocus' );
}
function inputRefresh( pNoSelect ) {
	this.onfocus( pNoSelect );
	this.onblur();
}
function setMask(control, mask) {
	var text = '';
	if (! String(control.value).match(/^ *$/) ) {
		if (! mask) 
			mask = getProp(control, 'mask'); 
		switch (String(mask).toLowerCase()) {
		    case 'currency':
				text = fullCurrency(control.value, getProp(control, 'decimalCurrency'));
		        break;
			case 'date':
				text = maskDate(control.value);
		        break;
		    case 'time':
				text = maskTime(control.value);
		        break;
			case 'domain':
				text = control.value.toLowerCase().replace(/[^a-z0-9\-]/ig, '');
				break;
		    default:
				if ( (STrim(mask) != '') && ( typeof(mask) != 'undefined') ) {
					var digits = String(control.value).split(new RegExp(''));
					var maskformat = mask.split(new RegExp(''));
					var pos = 0;
					for (var i = 0; i < maskformat.length; i++) {
						if (maskformat[i] == 'd') {
							if (pos < digits.length)
								text += digits[pos];
							pos++;
						}
						else 
							text += maskformat[i];
					}
					if (pos < digits.length) 
						for (var i = pos; i < digits.length; i++) 
							text += digits[i];
				}
		}
	}
	return( text );
}
function removeMask(control, mask) {
	var text = String(control.value);
	if (! text.match(/^ *$/) ) {
		if (! mask) 
			mask = getProp(control, 'mask'); 
		if ( (STrim(mask) != '') && (typeof(mask) != 'undefined') && (String( getProp(control, 'type') ).toLowerCase() == 'text') ) {
			switch (String(mask).toLowerCase()) {
				case 'currency':
					text = simpleCurrency(text, getProp(control, 'decimalCurrency'));
					break;
				case 'date':
					text = text.replace(/[^\d\/]/g, '');
					break;
				case 'time':
					text = text.replace(/[^\d:]/g, '');
					break;
				case 'domain':
					text = text.toLowerCase().replace(/[^a-z0-9\-]/g, '');
					break;
				default:
					text = removeCharacter(control, null, text);
					break;
			}
		}
	}
	return( text );
}
function removeCharacter(control, character, text) {
	if ( (typeof(text) != 'string') || (STrim(text) == '') ) {
		text = String(control.value);
	}
	if (! text.match(/^ *$/) ) {
		if (! character) 
			character = getProp(control, 'character'); 
		if ( (STrim(character) != '') && (typeof(character) != 'undefined') && ((String( getProp(control, 'type') ).toLowerCase() == 'text') || (String( getProp(control, 'type') ).toLowerCase() == ''))) {
			switch (String( character ).toLowerCase()) {
				case 'numeric' :
					text = text.replace(/\D/g, "");
					break;
				case 'currency' :
					text = text.replace(/[^0-9,\.]/g, '');
					break;
				case 'email':
					text = text.replace(/[^_\.0-9a-z\-@]/ig, '').toLowerCase();
					break;
				default :
			}
		}
	}
	return( text );
}
function inputKeyPress(event) {
	var vResult = true;
	var key = 0;
	try {
		if (self.event) 
			key = self.event.keyCode;
		else if ( (self.parent) && (self.parent.event) )
			key = self.parent.event.keyCode;
		else if ( (event) && (event.which) )
			key = event.which; 
	} catch (e) {}
	if ( (key != 13) && (key != 8) && (key != 0) ) {
		var keychar = String.fromCharCode(key);
		switch ( String( getProp(this, 'character') ).toLowerCase() ) {
			case 'numeric':
				vResult = ( keychar.match(/\d/) != null );
				break;
			case 'currency':
				if (keychar == getDecimalPoint())
					vResult = ( this.value.search( new RegExp( getDecimalPointRegExp(), 'g' ) ) == -1 );
				else 
					vResult = ( keychar.match(/[\d,\.]/) != null );
				break;
			case 'date':
				vResult = ( keychar.match(/[\d\/]/) != null );
				break;
			case 'time':
				vResult = ( keychar.match(/[\d:]/) != null );
				break;
			case 'domain':
				vResult = ( keychar.match(/[a-z0-9\-]/i) != null );
				break;
			case 'email':
				vResult = ( keychar.match(/[_\.0-9a-z\-@]/i) != null );
				break;
			default:
				break;
		}
	}
	if (vResult) {
		if ( (getProp(this, 'mask')) && (key == 13) )
			this.onblur();
	}
	if ( (vResult) && (this.mask_onkeypress) ) {
	    if (this.mask_onkeypress(event) == false) {
		    vResult = false;
	    }
	}
	return(vResult);
}
function textOnFocus(pNoSelect) {
	this.value = removeMask(this);
	if (typeof(pNoSelect) != 'string')
		this.select();
	if (this.mask_onfocus) 
	    return(this.mask_onfocus());
}
function textOffFocus() {
	this.value = removeCharacter(this);
	if ( (this.value) && (getProp(this, 'character') == 'domain') )
		this.value = this.value.toLowerCase();
	if (getProp(this, 'mask')) 
		this.value = setMask(this);
	if (isMSIE5()) {
		var maxLength = getProp(this, 'maxlen');
		if (maxLength > 0)
			this.value = String(this.value).substr(0, maxLength);
	}
	if (this.mask_onblur) 
	    return(this.mask_onblur());
}
function appMask()
{
}
appMask.prototype.getName = function()
{
	return('Mask');
}
appMask.prototype.processElement = function(element, index)
{
	var mask = getProp(element, 'mask');
	var character = getProp(element, 'character');
	if ( (character) || (mask) ) {
		if (element.onkeypress != inputKeyPress) {
			if (element.onkeypress) 
				element.mask_onkeypress = element.onkeypress;
			element.onkeypress = inputKeyPress;
		}
		if (element.onblur != textOffFocus) {
			if (element.onblur) 
				element.mask_onblur = element.onblur;
			element.onblur = textOffFocus;
		}
		if (element.onfocus != textOnFocus) {
			if (element.onfocus) 
				element.mask_onfocus = element.onfocus;
			element.onfocus = textOnFocus;
			element.mask_refresh = inputRefresh;
		}
	}
	var selected = getProp(element, 'selected');
	if (selected) {
		setItemComboByValue(element, selected);
		if (element.onchange)
			element.onchange();
	}
	if (element.mask_refresh)
		element.mask_refresh( 'nofocus' );
}
var Mask = new appMask();
if (appAddCompile) {
	appAddCompile( Mask );
}
function compileMask( document ) {
	for (var f = 0; f < document.forms.length; f++) {
		compileFormMask( document.forms[f], f );
	}
}
function compileFormMask(form, index) {
	for (var e = 0; e < form.length; e++) {
		Mask.processElement(form.elements[e], e);
	}
}
function validateForm() {
	var form = this;
	var vSubmit = true;
	controls = new Array();
	wrongControls = new Array();
	for ( var counter = 0; counter < form.length; counter++ ) {
		var value = getProp(form.elements[counter], 'validate');
		if (value)
			controls[controls.length] = {
				'type'    : value,
				'control' : form.elements[counter]
			};
	}
	var Message = getProp(form, 'validateMsg');
	for (var i = 0; i < controls.length; i++) {
		var vType = String( controls[i]['type'] ).toLowerCase();
		var vControl = controls[i]['control'];
		var vEvalCustom = false;
		var vResult = true;
		if (getProp(vControl, 'validateEmpty') == 'true') {
			if (String(vControl.tagName).toUpperCase() == 'SELECT') {
				vResult = (vControl.selectedIndex > 0);
			}
			else {
				vResult = (STrim(vControl.value) != '');
			}
		}
		if ( (vResult) && (vType == 'custom') ) {
			var vCustom = getProp(vControl, 'validateCustom');
			if (vCustom) {
				vEvalCustom = true;
				vControl.onValidateCustom = function () { return(eval(vCustom)) };
				vResult = vControl.onValidateCustom();
			}
		}
		if ( (vResult) && (! String(vControl.value).match(/^ *$/) ) ) {
			switch (vType) {
				case 'number':
					vResult = (! isNaN(Number(vControl.value)));
					if ( (vResult) && (getProp(vControl, 'validatePositive') == 'true') ) {
					    vResult = (Number(vControl.value) >= 0);
					}
					break;
				case 'currency':
					vResult = isCurrency(vControl.value);
					if ( (vResult) && (getProp(vControl, 'validatePositive') == 'true') ) {
					    vResult = (getCurrency(vControl.value) >= 0);
					}
					break;
				case 'date':
					if (isDate(vControl.value))
						vControl.value = fullDate(vControl.value)
					else 
						vResult = false;
					break;
				case 'time':
					vResult = isTime(vControl.value);
					break;
				case 'email':
					vResult = isEmail(vControl.value);
					break;
				case 'cpf':
					vResult = isCPF(vControl.value);
					break;
				case 'cnpj':
					vResult = isCNPJ(vControl.value);
					break;
				case 'domain':
					vResult = ( (typeof(vControl.value) == 'string') && (vControl.value.match(/^[a-z0-9_]*$/)) );
					break;
				case 'match':
					var field = form.elements[getProp(vControl, 'validateMatch')];
					if (field) {
						vResult = (field.value == vControl.value);
					} else {
						vResult = false;
					}
					break;
				default :
					vResult = true;
			}
		}
		if (! vResult) { 
			vSubmit = false;
			if (Message) {
			    wrongControls[wrongControls.length] = [vControl, vEvalCustom];
			}
			else {
				vControl.focus();
				alert(getProp(vControl, 'validateMsg'));
				break;
			}
		}
	}
	if (wrongControls.length > 0) {
		var msgControls = '';
		for (var i = 0; i < wrongControls.length; i++) {
			var msg = '';
			if (wrongControls[i][1]) 
				msg = eval('"' + getProp(wrongControls[i][0], 'controlCustomName') + '"');
			if ( (msg == '') || (msg == null) )
				msg = eval('"' + getProp(wrongControls[i][0], 'controlName') + '"');
		    msgControls += ', ' + msg;
		}
		msgControls = msgControls.replace(/^, /, '');
		Message = ChangeMacros( Message, 'jslib_validate_controls', msgControls );
		Message = ChangeMacros( Message, 'controls', msgControls );
		window.alert(Message);
		try {
			if (wrongControls[0][0].focus) wrongControls[0][0].focus();
			if (wrongControls[0][0].select) wrongControls[0][0].select();
		}
		catch(e) {
		}
	}
	window.vformSubmit = vSubmit;
	return(vSubmit);
}
function isEmail(pEmail) {
	pEmail = pEmail.toLowerCase();
	if (pEmail.search(/^[_\.0-9a-z-]+@([0-9a-z-]+\.)+[a-z]+$/) > -1) {
		return(1);
	}
	if (pEmail.search(/^[_\.0-9a-z-]+@[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/) > -1) {
		return(1);
	}
	return(0);
}
function isCPF(pCPF) {
	pCPF = pCPF.replace(/\D/g, '');
	var CPF = pCPF.substr(0, 9);
	if (CPF.length != 9 || CPF.match(/^0{9}|1{9}|2{9}|3{9}|4{9}|5{9}|6{9}|7{9}|8{9}|9{9}$/)) {
		return false;
	}
	var Sum = 0;
	for (var i = 0; i < 9; i ++)
		Sum += parseInt(CPF.charAt(i)) * (10 - i);
	var Rest = 11 - (Sum % 11);
	if (Rest > 9) { CPF += 0; }
		else { CPF += Rest; }
	Sum = 0;
	for (var i = 0; i < 10; i ++)
		Sum += parseInt(CPF.charAt(i)) * (11 - i);
	Rest = 11 - (Sum % 11);
	if (Rest > 9) { CPF += 0; }
		else { CPF += Rest; }
	return(pCPF == CPF)
} 
function isCNPJ(pCNPJ) {
	pCNPJ = pCNPJ.replace(/\D/g, '');
	var CNPJ = pCNPJ.substr(0, 12);
	if (CNPJ.length != 12 || CNPJ.match(/^0{12}|1{12}|2{12}|3{12}|4{12}|5{12}|6{12}|7{12}|8{12}|9{12}$/)) {
		return false;
	}
	var Sum = 0;
	for (var i = 0; i < 12; i ++) 
		Sum += parseInt(CNPJ.charAt(i)) * ( i < 4 ? (5 - i) : (13 - i) );
	var Rest = 11 - (Sum % 11);
	if (Rest > 9) { CNPJ += 0; }
		else { CNPJ += Rest; }
	var Sum = 0;
	for (var i = 0; i < 13; i ++) 
		Sum += parseInt(CNPJ.charAt(i)) * ( i < 5 ? (6 - i) : (14 - i) );
	var Rest = 11 - (Sum % 11);
	if (Rest > 9) { CNPJ += 0; }
		else { CNPJ += Rest; }
	return(pCNPJ == CNPJ)
} 
function appValidate()
{
}
appValidate.prototype.getName = function()
{
	return('Validate');
}
appValidate.prototype.startForm = function(form, index)
{
	if (getProp(form, 'validate') == 'true') {
		onEventManager.addEvent(form, 'submit', validateForm, 'first');
	}
}
var Validate = new appValidate();
if (appAddCompile) {
	appAddCompile( Validate );
}
function compileValidate( document ) {
	for (var f = 0; f < document.forms.length; f++) {
		compileFormValidate(document.forms[f], f);
	}
}
function compileFormValidate(form, index) {
	Validate.startForm(form, index);
}
function appModified() {
}
appModified.prototype.getName = function() {
	return('Modified');
}
appModified.prototype.startForm = function(form, index) {
	if ((getProp(form, 'validate') == 'true') || 
		(getProp(form, 'validate') == 'numeric') || 
		(getProp(form, 'validate') == 'email') || 
		(getProp(form, 'validate') == 'date') || 
		(getProp(form, 'validate') == 'custom') || 
		(getProp(form, 'validate') == 'time') || 
		(getProp(form, 'validate') == 'number') || 
		(getProp(form, 'validate') == 'currency') || 
		(getProp(form, 'validate') == 'domain') || 
		(getProp(form, 'validate') == 'match') || 
		(getProp(form, 'validate') == 'cpf')) {
		form.modified = false;
		if (getProp(form,'checkUnload') == 'true') {
			onEventManager.addEvent(form, 'submit', function() { window.onbeforeunload = null } , 'first');
		}
	}
}
appModified.prototype.processElement = function(element,index) {
	element.modified = false;
	if (getProp(element,'cancelForm')) {
		onEventManager.addEvent(element, 'click', cancelForm , 'first');
		onEventManager.addEvent(element.form, 'submit', function () { element.disabled=true } , 'last');
	}
	onEventManager.addEvent(element, 'change', setModified , 'last');
}
function setModified() { 
	this.modified = true;
	this.form.modified=true; 
	var form = this.form;
	if (getProp(form,'checkUnload') == 'true') {
		window.onbeforeunload = function() { return modifiedFormMessage(form,'unload'); }
	}
}
function cancelForm() {
	var form = this.form;
	if (modifiedForm(form)) {
		if (getProp(form,'checkUnload') == 'true') {
			window.onbeforeunload = null;
		}
		var onCancel = getProp(form,'onCancel');
		if (onCancel) {
			eval(onCancel);
		}
	}
}
function modifiedForm(form) {
	var Message = modifiedFormMessage(form,'cancel');
	if (Message == '') {
		return true;
	} else {
		return window.confirm(Message);
	}
}
function modifiedFormMessage(form,msgPrefix) {
	var controls = new Array();
	for ( var counter = 0; counter < form.length; counter++ ) {
		var value = getProp(form.elements[counter], 'validate');
		if (value) {
			if (form.elements[counter].modified) {
				controls[controls.length] = form.elements[counter];
			}
		}
	}
	if (controls.length > 0) {
		var Message = getProp(form,msgPrefix+'Msg');
		var msgControls = '';
		for (var i = 0; i < controls.length; i++) {
			var msg = '';
			if ( (msg == '') || (msg == null) )
				msg = eval('"' + getProp(controls[i],'controlName') + '"');
			msgControls += ', ' + msg;
		}
		msgControls = msgControls.replace(/^, /, '');
		Message = ChangeMacros( Message, 'jslib_modified_controls', msgControls );
		Message = ChangeMacros( Message, 'controls', msgControls );
		return Message;
	} else {
		return '';
	}
}
var Modified = new appModified();
if (appAddCompile) {
	appAddCompile( Modified );
}
function appFocus()
{
	this.startForm(null, -1);
}
appFocus.prototype.getName = function()
{
	return('Focus');
}
appFocus.prototype.startForm = function(form, index)
{
	this.elementFocus = null;
	this.defaultFocus = null;
	this.focus = false;
}
appFocus.prototype.finishForm = function(form, index)
{
	if ( (this.defaultFocus) && (! this.elementFocus) ) 
	    this.elementFocus = this.defaultFocus;
	if ( (this.elementFocus) && (this.elementFocus.focus) ) {
		try {
			this.elementFocus.focus();
		} 
		catch(e) {}
	}
}
appFocus.prototype.processElement = function(element, index)
{
	if ( (element.focus) && ( (this.focus) || (! this.elementFocus) ) ) {
		var ctrlFocusEmpty = getProp(element, 'focusEmpty');
		if ( (typeof(ctrlFocusEmpty) == 'string') && ( (ctrlFocusEmpty.toLowerCase() == 'false') || (ctrlFocusEmpty == '0') ) )
			ctrlFocusEmpty = '';
		var ctrlFocus = getProp(element, 'setFocus');
		if (typeof(ctrlFocus) != 'string') 
			ctrlFocus = getProp(element, 'focus');
		if (typeof(ctrlFocus) == 'string') {
			if ( (ctrlFocus.toLowerCase() == 'false') || (ctrlFocus == '0') )
				ctrlFocus = '';
		}
		else {
			ctrlFocus = '';
		}
		if (ctrlFocusEmpty) {
			var isEmpty = true;
			if (String(element.tagName).toUpperCase() == 'SELECT') {
				isEmpty = (element.selectedIndex <= 0);
			}
			else {
				isEmpty = (STrim(element.value) == '');
			}
			if (isEmpty) {
				this.elementFocus = element;
				this.focus = false;
			}
			if (! this.defaultFocus) 
			    this.defaultFocus = element;
		}
		else if ( (! this.elementFocus) && (ctrlFocus) ) {
			this.elementFocus = element;
			this.focus = true;
			if (! this.defaultFocus) 
			    this.defaultFocus = element;
		}
	}
}
var Focus = new appFocus();
if (appAddCompile) {
	appAddCompile( Focus );
}
function compileFocus( document ) {
	for (var f = 0; f < document.forms.length; f++) {
		compileFormFocus(document.forms[f], f);
	}
}
function compileFormFocus(form, index) {
	Focus.startForm(form, index);
	for (var e = 0; e < form.length; e++) {
		Focus.processElement(form.elements[e], e);
	}
	Focus.finishForm(form, index);
}
function radioSelect (form, field, value) {
	if (form && field && value) {
		var elements = form.elements[field];
		if (elements && elements.length) {
			for (var index = 0; index < elements.length; index++) {
				if (elements[index].value == value) {
					elements[index].checked = true;
					break;
				}
			}
		} else if (elements) {
			if (elements.value == value) {
				elements.checked = true;
			}
		}
	}
}
function radioSelectForm (form) {
	var values = getProp(form, 'radioselect');
	if (values) {
		var fields = values.split(";");
		for (var index = 0; index < fields.length; index++) {
			var field = fields[index].split("=");
			radioSelect(form, field[0], field[1]);
		}
	}
}
function appRadioSelect()
{
}
appRadioSelect.prototype.getName = function() {
	return('RadioSelect');
}
appRadioSelect.prototype.startForm = function(form, index) {
	if (getProp(form, 'radioselect')) {
		radioSelectForm(form);
	}
}
var RadioSelect = new appRadioSelect();
if (appAddCompile) {
	appAddCompile( RadioSelect );
}
function jslibEventItem(pControl, pEvent) {
	this.control = pControl;
	this.eventName = pEvent;
	this.iEvents = {'first' : [], 'middle' : [], 'last' : []};
}
jslibEventItem.prototype.moments = [ 'first', 'middle', 'last' ];
jslibEventItem.prototype.runEvent = function(pEvent) {
	try {
		if (self.event) 
			pEvent = self.event;
		else if ( (self.parent) && (self.parent.event) )
			pEvent = self.parent.event;
	} catch (e) {}
	var result = true;
	for (var j = 0; j < this.moments.length; j++) {
		moment = this.moments[j];
		for (var i = 0; i < this.iEvents[moment].length; i++) {
			this.control.onRunEvent = this.iEvents[moment][i];
			if (this.control.onRunEvent(pEvent) == false) {
				result = false;
			}
		}
		if (! result) { break; }
	}
	return result;
}
jslibEventItem.prototype.addFunction = function(pFunction, pMoment) {
	if (! pMoment) { pMoment = "middle" }
	if (this.iEvents[pMoment]) {
		this.iEvents[pMoment].push(pFunction);
	}
}
function jslibEventManager() {
}
jslibEventManager.prototype.getName = function() {
	return('jslibEventManager');
}
jslibEventManager.prototype.addEvent = function(pControl, pEvent, pFunction, pPosition) {
	if (! pControl.jslibOnEvent) 
		pControl.jslibOnEvent = {};
	if (! pControl.jslibOnEvent[pEvent]) {
		var itemEvent = new jslibEventItem(pControl, pEvent)
		pControl.jslibOnEvent[pEvent] = itemEvent;
			if (pControl['on' + pEvent]) {
				itemEvent.addFunction(pControl['on' + pEvent]);
			}
			pControl['on' + pEvent] = function(ppEvent) { return(itemEvent.runEvent(ppEvent)) };
	}
	var itemEvent = pControl.jslibOnEvent[pEvent];
	itemEvent.addFunction(pFunction, pPosition);
}
var onEventManager = new jslibEventManager();
function jslibLocation(pWindow) {
	if (!pWindow) {
		pWindow = window;
	}
	this.parentWindow = pWindow;
	var url = pWindow.location.href;
	this.params = {};
	this.href = '';
	this.encoded = false;
	var pos = url.indexOf('?');
	if (pos > -1) {
		var params = url.substr(pos + 1);
		this.href = url.substr(0, pos);
		var arrayParams = params.split('&');
		for (var i = 0; i < arrayParams.length; i++) {
			var value = arrayParams[i];
			var values = value.split('=');
			this.setParam(unescape(values[0]), unescape(values[1]));
		}
		if (this.params['C'] == 'A') {
			this.encoded = true;
			var params = decodeUrl(this.params['V']);
			this.params = {};
			var arrayParams = params.split('&');
			for (var i = 0; i < arrayParams.length; i++) {
				var value = arrayParams[i];
				var values = value.split('=');
				this.setParam(unescape(values[0]), unescape(values[1]));
			}
		}
	}
	else {
		this.href = url;
	}
}
jslibLocation.prototype.setParam = function(pName, pValue) {
	this.params[pName] = pValue;
}
jslibLocation.prototype.redirect = function (url) {
	this.parentWindow.location.href = url;
}
jslibLocation.prototype.getUrl = function (pParams) {
	if (! pParams) { pParams = this.params; }
	var newParams = '';
	for (var key in pParams) {
		if (newParams) { newParams += '&'}
		newParams += escape(key) + '=' + escape(pParams[key]);
	}
	if (newParams) {
		return (this.href + '?' + newParams)
	}
	else {
		return (this.href)
	}
}
jslibLocation.prototype.reload = function () {
	var newParams = '';
	for (var key in this.params) {
		if (newParams) { newParams += '&'}
		newParams += escape(key);
		newParams += '=';
		newParams += escape(this.params[key]);
	}
	if (newParams) {
		this.redirect(this.href + '?' + newParams);
	}
	else {
		this.parentWindow.location.reload();
	}
}
var locationUrl = new jslibLocation(window);
function copyHtml( source, to ) {
	to.innerHTML = source.innerHTML;
}
function compileForm( form ) {
	if (processElements) {
		for (var c = 0; c < Plugins.length; c++) 
			if (Plugins[c].startForm) 
				Plugins[c].startForm(form, form);
		for (var e = 0; e < form.elements.length; e++) {
			for (var c = 0; c < Plugins.length; c++) {
				if (getProp(form.elements[e], 'onclick')) {
					form.elements[e].onclick = function (e) {
						eval(getProp(form.elements[e], 'onclick'));
					}
				}
				if (Plugins[c].processElement) 
					Plugins[c].processElement(form.elements[e], e);
			}
		}
		for (var c = 0; c < Plugins.length; c++) 
			if (Plugins[c].finishForm) 
				Plugins[c].finishForm(form, form);
	}
}
var stCol = 0;
var stParent = null;
var stItems = new Array();
var stMax = 0;
var stDesc = false;
var stNum = false;
var stLastCol = null;
function getCol(i) {
	var value = '';
	if (stItems[i]) {
		var tds = stItems[i].getElementsByTagName('TD');
		if ( (tds.length) && (tds[stCol]) )
			value = getValue(tds[stCol]);
	}
	if (stNum) {
		value = Number(String(value).replace(new RegExp('\\D', 'g'), ''));
		if (isNaN(value)) 
			value = 0;
	}
	return(value);
}
function compare(val1, val2) {
	return ( (stDesc) ? val1 > val2 : val1 < val2 );
}
function exchange(i, j) {
	if (i == j+1) {
		stParent.insertBefore(stItems[i], stItems[j]);
	}
	else if (j == i+1) {
		stParent.insertBefore(stItems[j], stItems[i]);
	}
	else {
		var node = stParent.replaceChild(stItems[i], stItems[j]);
		if (typeof(stItems[i]) == 'undefined') 
			stParent.appendChild(node);
		else 
			stParent.insertBefore(node, stItems[i]);
	}
}
function quickSort(lb, ub) {
	if (ub <= lb+1) 
		return;
	if ((ub - lb) == 2) {
		if (compare(getCol(ub-1), getCol(lb))) 
			exchange(ub-1, lb);
		return;
	}
	var i = lb + 1;
	var j = ub - 1;
	getCol(lb);
	if (compare(getCol(lb), getCol(i))) 
		exchange(i, lb);
	if (compare(getCol(j), getCol(lb))) 
		exchange(lb, j);
	if (compare(getCol(lb), getCol(i))) 
		exchange(i, lb);
	pivot = getCol(lb);
	while (true) {
		j--;
		while (compare(pivot, getCol(j))) 
			j--;
		i++;
		while (compare(getCol(i), pivot)) 
			i++;
		if (j <= i) 
			break;
		exchange(i, j);
	}
	exchange(lb, j);
	if ((j-lb) < (ub-j)) {
		quickSort(lb, j);
		quickSort(j+1, ub);
	}
	else {
		quickSort(j+1, ub);
		quickSort(lb, j);
	}
}
function sortTable() {
	stParent = this.stTable;
	if ( (stParent) && (stParent.nodeName != 'TBODY') )
		stParent = stParent.getElementsByTagName('TBODY')[0];
	col = this;
	if ( (typeof(col) == 'object') && (col.parentNode) ) {
		if (col.nodeName.toLowerCase() != 'td') {
			while (col = col.parentNode) {
				if (col.nodeName.toLowerCase() == 'td') 
					break;
			}
		}
		if (typeof(col) == 'object') {
			stNum = col.stNum;
			var colsTitle = col.parentNode.getElementsByTagName('TD');
			var colCount = 0;
			for (var i = 0; i < colsTitle.length; i++) {
				if (col == colsTitle[i]) 
					break
				colCount++;
			}
			col = colCount;
		}
	}
	stCol = Number(col);
	if ( (stParent) && (stParent.nodeName == 'TBODY') && (! isNaN(stCol)) ) {
		stDesc = (stCol == stLastCol) ? (! stDesc) : false;
		stLastCol = stCol;
		var stOffsetTop = getProp(this.stTable, 'stOffsetTop');
		if (stOffsetTop == '') 
			stOffsetTop = 1;
		var stOffsetBottom = Number(getProp(this.stTable, 'stOffsetBottom'));
		if (isNaN(stOffsetBottom)) 
			stOffsetBottom = 0;
		stItems = stParent.getElementsByTagName('tr');
		stMax = stItems.length - stOffsetBottom;
		quickSort(stOffsetTop, stMax, stDesc);
	}
}
function appSortTable()
{
}
appSortTable.prototype.getName = function()
{
	return('sortTable');
}
appSortTable.prototype.initialize = function(pDocument)
{
	var elms = pDocument.getElementsByTagName('TABLE');
	for (var i = 0; i < elms.length; i++) {
		if (getProp(elms[i], 'sortTable')) {
			this.compileTable(elms[i]);
		}
	}
}
appSortTable.prototype.compileTable = function(table) {
	table = findObject(table);
	var trs = table.getElementsByTagName('TR');
	if ( (trs) && (trs.length) ) {
		var trTitle = trs[0];
		var elms = trTitle.getElementsByTagName('TD');
		for (var i = 0; i < elms.length; i++) {
			if (getProp(elms[i], 'stSort')) {
				elms[i].stTable = table;
				elms[i].stNum = getProp(elms[i], 'stNum');
				elms[i].onclick = sortTable;
				if (elms[i].style) {
					elms[i].style.cursor = isGecko() ? 'pointer' : 'hand';
				}
			}
		}
	}
}
var vSortTable = new appSortTable();
if (appAddCompile) {
	appAddCompile( vSortTable );
}
function compileSortTable( document ) {
	vSortTable.initialize(document);
}
function jslibElement(pNode) {
	this.node = document.getElementById(pNode);
}
jslibElement.prototype.getId = function() {
	return this.node.getAttribute('id');
};
jslibElement.prototype.setStyle = function(style, value) {
	setStyle([this.getId()], style, value);
};
jslibElement.prototype.getStyle = function(style) {
	return getStyle(this.getId(), style);
};
jslibElement.prototype.changeDisplay = function(value) {
	if (value) {
		this.setStyle('display', value);
	}
	else {
		if (this.getStyle('display') == 'none') {
			this.setStyle('display', 'block');
		}
		else {
			this.setStyle('display', 'none');
		}
	}
};
function jslibElements() {
	this.elements = {};
}
jslibElements.prototype.getName = function() {
	return('jslibElements');
}
jslibElements.prototype.addElement = function(pElement) {
	this.elements[pElement.getId()] = pElement;
	this[pElement.getId()] = pElement;
}
var jsElements = new jslibElements();
function disableOnSubmit() {
	var form = this;
	var vSubmit = true;
	if (form.disableonsubmit_onsubmit) {
		if (form.disableonsubmit_onsubmit() == false) {
		    vSubmit = false;
		}
	}
	if (vSubmit) {
		if (document.app && document.app[form.id] && document.app[form.id].isAjax()) {
		} else {
			if (form.onsubmit == disableOnSubmit) {
				form.onsubmit = cancelSubmit;
			}
			else {
				window.setTimeout(function() {
					form.onsubmit = cancelSubmit;
				}, 5);
			}
		}
		if (form.disableOnSubmit_element) {
			var disableMsg = getProp(form, 'disableMsg');
			if (disableMsg != '') 
				setProp(form.disableOnSubmit_element,'oldvalue',form.disableOnSubmit_element.value);
			    form.disableOnSubmit_element.value = disableMsg;
			var disableClass = getProp(form, 'disableClass');
			if (disableClass != '') 
			    form.disableOnSubmit_element.className = disableClass;
		}
	}
	return(vSubmit);
}
function cancelSubmit() {
    return(false);
}
function disableOnSubmit_ButtonClick() {
	this.form.disableOnSubmit_element = this;
	if (this.disableonsubmit_onclick) 
	    return(this.disableonsubmit_onclick());
}
function appDisableOnSubmit()
{
}
appDisableOnSubmit.prototype.getName = function()
{
	return('disableOnSubmit');
}
appDisableOnSubmit.prototype.startForm = function(form, index)
{
	if (getProp(form, 'disableOnSubmit') == 'true') {
		this.currentForm = form;
		onEventManager.addEvent(form, 'submit',disableOnSubmit ,'last');
	}
	else {
		this.currentForm = null;
	}
}
appDisableOnSubmit.prototype.processElement = function(element, index)
{
	if (this.currentForm) {
		if (getProp(element, 'disableOnSubmit') == 'true') {
			onEventManager.addEvent(element, 'click', disableOnSubmit_ButtonClick,'last');
		}
	}
}
var DisableOnSubmit = new appDisableOnSubmit();
if (appAddCompile) {
	appAddCompile( DisableOnSubmit );
}
function compileDisableOnSubmit( document ) {
	for (var f = 0; f < document.forms.length; f++) {
		compileFormDisableOnSubmit(document.forms[f], f);
	}
}
function compileFormDisableOnSubmit(form, index) {
	DisableOnSubmit.startForm(form, index);
	for (var e = 0; e < form.length; e++) {
		DisableOnSubmit.processElement(form.elements[e], e);
	}
}