function AppLayer() {
	this.ready = false;
	this.parts = {};
	this.elements = {};
	this.waitStack = [];
	this.requestStack = [];
	this.requestModal = false;
	this.requestShowError = true;
	this.setEvent('load',function () {});
	this.setEvent('error',function () {});
	this.setEvent('update',function () {});
	this.setEvent('request',function () {});
	this.setEvent('response',function () {});
	onEventManager.addEvent(window,'load',function() {
		document.app.ready = true;
		document.app.flushWaitStack();
		document.app.onload();
	},'last',false);
	onEventManager.addEvent(window,'unload',unloadApp,'first',false);
	return;
}
AppLayer.prototype.clear = function() {
	if (this['requestInterval']) {
		clearInterval(this['requestInterval']);
		this['requestInterval'] = null;
	}
	for (var i = 0; i < this.requestStack.length; i++) {
		this.requestStack[i] = null;
	}
	for (var id in this.elements) {
		var element = this.elements[id];
		var nodes = element.getNodes();
		for (var node in nodes) {
			node['e'] = null;
		}
		element['core'] = null;
	}
	for (var id in this.parts) {
		var part = this.parts[id];
		part['core'] = null;
	}
	return;
}
AppLayer.prototype.setEvent = function(event,func,order) {
	onEventManager.addEvent(this,event,func,order);
}
AppLayer.prototype.scrollTop = function() {
	return (isMSIE()) ? document.body.scrollTop : window.pageYOffset;
}
AppLayer.prototype.scrollLeft = function() {
	return (isMSIE()) ? document.body.scrollLeft : window.pageXOffset;
}
AppLayer.prototype.setElement = function(props) {
	if (typeof(props) == 'object') {
		var id = props['ID'];
		if (this.elements[id]) {
			this.elements[id].props = props;
			this.elements[id].setup();
		} else {
			var element;
			if (props['T']) {
				eval('element = new T'+props['T']+'(this,props);');
			} else {
				eval('element = new T'+props['Type']+'(this,props);');
			}
			this.elements[id] = element;
			this.elements[element.getNodeID()] = element;
		}
		if (!this[id]) {
			this[id] = this.elements[id];
		}
	}
}
AppLayer.prototype.getElement = function(id) {
	return this.elements[id];
}
AppLayer.prototype.setPart = function (props) {
	if (typeof(props) == 'object') {
		var id = props['ID'];
		if (this.parts[id]) {
			this.parts[id].props = props;
		} else {
			this.parts[id] = new TPart(this,props);
		}
		if (!this[id]) {
			this[id] = this.parts[id];
		}
	}
}
AppLayer.prototype.getPart = function (id) {
	return this.parts[id];
}
AppLayer.prototype.setParam = function(key,value) {
	locationUrl.setParam(key,value);
}
AppLayer.prototype.clearParam = function(params) {
	if (typeof(params) == 'object') {
		for (var key in params) {
			this.setParam(key,null);
		}
	} else if (params != '') {
		this.setParam(params,null);
	}
}
AppLayer.prototype.popup = function(params) {
	var URL, L, T, W, H, isHTML, s, wname;
	if (typeof(params) == 'object') {
		URL = (params['html'] && (params['html'].length > 0)) ? params['html'] : params['url'];
		isHTML = (params['html'] && (params['html'].length > 0)) ? true : false;
		wname = params['name'];
		L = params['left'];
		T = params['top'];
		W = params['width'];
		H = params['height'];
		s = params['scroll'];
	} else {
		URL = params;
		isHTML = true;
	}
	var sW = screen.availWidth ? screen.availWidth : screen.width;
	var sH = screen.availHeight ? screen.availHeight : screen.height;
	if (parseInt(W) > 0) {} else { W = parseInt(sW * 0.8) }
	if (parseInt(H) > 0) {} else { H = parseInt(sH * 0.8) }
	if (W > sW) W = sW;
	if (H > sH) H = sH;
	if (parseInt(L) > 0) {} else { L = parseInt((sW - W) / 2.0) };
	if (parseInt(H) > 0) {} else { T = parseInt((sH - H) / 2.0) };
	var HTML = '';
	if (isHTML) {
		HTML = URL;
		URL = '';
	}
	var win = window.open(URL, wname, 'top=' + T + ',left=' + L + ',scrollbars='+s+',dialog=no,minimizable=no,modal=no,width=' + W + ',height=' + H + ',resizable=yes');
	try {
		win.resizeTo(W, H);
		win.moveTo(L, T);
	} catch(e) { }
	if (HTML) {
		win.document.write(HTML);
		win.document.close();
	}
	win.focus();
	return(win);
}
AppLayer.prototype.fmFile = function(param) {
	fmcb = function(fileName,fullPath,imageType,fileSize,fileModified,imageWidth,imageHeight,fm_Image) { fmCallback(param,fileName,fullPath,imageType,fileSize,fileModified,imageWidth,imageHeight,fm_Image); return true; };
	return this.popup({
		'url' : '/fmanager/?fm_Repository=default&',
		'scroll' : 'no',
		'name' : 'fmPopup'
	});
}
AppLayer.prototype.fmImage = function(param) {
	fmcb = function(fileName,fullPath,imageType,fileSize,fileModified,imageWidth,imageHeight,fm_Image) { fmCallback(param,fileName,fullPath,imageType,fileSize,fileModified,imageWidth,imageHeight,fm_Image); return true; };
	return this.popup({
		'url' : '/fmanager/?fm_Repository=default&fm_Image=true&',
		'scroll' : 'no',
		'name' : 'fmPopup'
	});
}
AppLayer.prototype.setCookie = function(name,value,expire) {
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expire)
	document.cookie=name+ "=" +escape(value)+
	((expire==null) ? "" : ";expires="+exdate.toGMTString())
}
AppLayer.prototype.getCookie = function(name) {
	if (document.cookie.length > 0 )  {
		var c_start = document.cookie.indexOf(name + "=")
		if (c_start != -1) {
			c_start = c_start + name.length + 1
			var c_end = document.cookie.indexOf(";",c_start);
			if (c_end == -1) {
				c_end = document.cookie.length;
			}
			return unescape(document.cookie.substring(c_start,c_end))
		}
	}
	return "";
}
AppLayer.prototype.cookieEnabled = function() {
	var name = 'cx'+Math.floor(Math.random() * 99999);
	this.setCookie(name,'abc');
	if (this.getCookie(name) == 'abc') {
		document.cookie = name+"="+";expires=Thu, 01-Jan-1970 00:00:01 GMT";
		return true;
	} else {
		return false;
	}
}
AppLayer.prototype.download = function(url) {
	var name = Math.floor(Math.random() * 99999);
	var div = document.createElement("DIV");
	div.innerHTML = '<iframe style="position: absolute; top: -1000; left: -1000; width: 1px; height: 1px;" frameborder="0" src="'+url+'" id="'+name+'" name="'+name+'"></iframe>';
	this.appendTag(div);
	return;
}
AppLayer.prototype.update = function(params,modal) {
	this.onupdate();
	var copy = {};
	for (var key in locationUrl.params) {
		if (locationUrl.params[key] != null) {
			if ((key != '_url') || (key != '_method')) {
				copy[key] = locationUrl.params[key];
			}
		}
	}
	if (typeof(params) == 'object') {
		for (var key in params) {
			copy[key] = params[key];
			if ((key != '_url') || (key != '_method')) {
				this.setParam(key,params[key]);
			}
		}
	}
	this.request(copy,modal);
	return;
}
AppLayer.prototype.request = function(params,modal) {
	if (this.ready) {
		var httpRequest = myXMLHttpRequest();
		if (httpRequest) {
			this.requestStack.push({
				'request'	: httpRequest,
				'params'	: params,
				'modal'		: ((modal) ? true : false)
			});
			this.onrequest();
			if (!defined(modal)) {
				modal = this.requestModal;
			}
			if (modal) {
				this.showModal('wait');
			}
			sendHttpRequest(httpRequest,params);
			if (!this['requestInterval']) {
				this['requestInterval'] = setInterval("document.app.response()",50);
			}
		}
	} else {
		this.waitStack.push(params);
	}
	return;
}
AppLayer.prototype.response = function () {
	var tempStack = [];
	var readyStack = [];
	for (var i = 0; i < this.requestStack.length; i++) {
		var request = this.requestStack[i]['request'];
		var params = this.requestStack[i]['params'];
		var modal = this.requestStack[i]['params'];
		if (request.readyState == 4) {
			readyStack.push({
				'request'	: request,
				'params'	: params,
				'modal'		: modal
			});
		} else {
			tempStack.push({
				'request'	: request,
				'params'	: params,
				'modal'		: modal
			});
		}
		this.requestStack[i] = null;
	}
	this.requestStack = tempStack;
	if (this.requestStack.length <= 0) {
		clearInterval(this['requestInterval']);
		this['requestInterval'] = null;
	}
	for (var i = 0; i < readyStack.length; i++) {
		var request = readyStack[i]['request'];
		var params = readyStack[i]['params'];
		var modal = readyStack[i]['params'];
		this.onresponse();
		if (modal) {
			this.hideModal();
		}
		this.process(request,params);
		readyStack[i] = null;
	}
	return;
}
AppLayer.prototype.flushWaitStack = function() {
	for (var i = 0; i < this.waitStack.length; i++) {
		this.request(this.waitStack[i]);
		this.waitStack[i] = null;
	}
}
AppLayer.prototype.addHtml = function (html) {
	var span = document.createElement('SPAN');
	document.body.insertBefore(span,document.body.firstChild);
	return changeTagHtml(span,html);
}
AppLayer.prototype.appendTag = function(tag,container) {
	if (!container) {
		container = document.getElementById('apptagcontainer');
	}
	if (container) {
		container.appendChild(tag);
	} else {
		document.body.appendChild(tag);
	}
	return;
}
AppLayer.prototype.appendHtml = function (html) {
	var span = document.createElement('SPAN');
	this.appendTag(span);
	return changeTagHtml(span,html);
}
AppLayer.prototype.showModal = function (cursor,keep,ffheight) {
	var div = document.getElementById('AppLayerModalDiv');
	if (!div) {
		div = document.createElement('DIV');
		div.id = 'AppLayerModalDiv';
		div.style.top = 0;
		div.style.left = 0;
		div.style.right = 0;
		div.style.bottom = 0;
		div.style.width = '100%';
		div.style.height = document.body.clientHeight;
		div.style.zIndex = -10;
		div.style.filter = 'alpha(opacity=50)';
		div.style.opacity = '0.6';
		div.style.position = 'absolute';
		div.style.mozOpacity = '0.5';
		div.style.backgroundColor = '#EFEFEF';
		this.appendTag(div,document.getElementById('appmodalcontainer'));
	}
	if (div.style.zIndex < 0) {
		disableAllTags(document,'showModal');
		var selects = document.getElementsByTagName('select');
		for (var i = 0; i < selects.length; i++) {
			if (selects[i].style.visibility != 'hidden') {
				selects[i].style.visibility = 'hidden';
				selects[i]['modal_hidden'] = true;
			}
		}
		div.style.zIndex = 10;
		div.style.width = '100%';
		div.style.cursor = cursor;
		if (isFirefox()) {
			if (parseInt(ffheight) > 0) {
				div.style.height = parseInt(document.body.scrollHeight) - parseInt(ffheight);
				if (parseInt(div.style.height) < parseInt(document.documentElement.scrollHeight)) {
					div.style.height = parseInt(document.documentElement.scrollHeight);
				}
			} else {
				div.style.height = document.body.scrollHeight;
			}
		} else {
			div.style.top = this.scrollTop();
			div.style.height = document.body.clientHeight;
			document.body.style.overflow = 'hidden';
		}
	}
	if (keep) { div['keep'] = keep; }
	return;
}
AppLayer.prototype.hideModal = function (force) {
	var div = document.getElementById('AppLayerModalDiv');
	if (div) {
		if (!div['keep'] || force) {
			div.style.zIndex = -10;
			div.style.width = 0;
			div.style.cursor = 'default';
			var selects = document.getElementsByTagName('select');
			for (var i = 0; i < selects.length; i++) {
				if (selects[i].style.visibility == 'hidden') {
					if (selects[i]['modal_hidden']) {
						selects[i].style.visibility = 'visible';
						selects[i]['modal_hidden'] = false;
					}
				}
			}
			enableAllTags(document,'showModal');
			div['keep'] = false;
			document.body.style.overflow = 'auto';
		}
	}
	return;
}
AppLayer.prototype.process = function (request,params) {
	var xml;
	if (request.responseXML && request.responseXML.documentElement) {
		xml = request.responseXML.documentElement;
	} else if (request.responseText) {
		xml = newXmlDoc(request.responseText);
	}
	if (xml) {
		if (xml.nodeName == 'Response') {
			if (xml.getAttribute('Status') == 'OK') {
				this.processXML(xml);
			} else if ((xml.getAttribute('Retry') == '1') && (typeof(params) == 'object')) {
				this.request(params);
			} else {
				if (xml.getAttribute("Description") != '') {
					this.onerror(xml.getAttribute("Reason"));
					if (this.requestShowError) {
						alert(xml.getAttribute("Description"));
					}
				} else {
					this.onerror();
					if (this.requestShowError) {
						alert('Error: '+xml2text(xml));
					}
				}
			}
		} else {
			if (String(request.responseText).search(/\w/) > -1) {
				this.onerror();
				if (this.requestShowError) {
					alert('Error: '+request.responseText);
				}
			}
		}
	} else {
		if (String(request.responseText).search(/\w/) > -1) {
			this.onerror();
			if (this.requestShowError) {
				alert('Error: '+request.responseText);
			}
		}
	}
}
AppLayer.prototype.processXML = function(xml) {
	if (xml.nodeName == 'Response') {
		if (xml.getAttribute("Status") == 'OK') {
			this.processResponse(xml);
		} else {
			if (xml.getAttribute("Description") != '') {
				alert('Error: '+xml.getAttribute("Description"));
			} else {
				alert('Error: '+xml2text(xml));
			}
		}
	} else {
		alert('Error: '+xml2text(xml));
	}
}
AppLayer.prototype.processResponse = function (xml) {
	for (var i = 0; i < xml.childNodes.length; i++) {
		var node = xml.childNodes[i];
		var name = node.nodeName;
		if (name != '#text') {
			if (this['process'+name]) {
				eval('this.process'+name+'(node);');
			}
		}
	}
}
AppLayer.prototype.processAlert = function (node) {
	alert(makeStringValue(getNodeValue(node)));
}
AppLayer.prototype.processScript = function (node) {
	eval('try { ' + getNodeValue(node) + ' } catch(e) { if (appDebugger && appDebugger.enabled) { alert(e.toString()) } } ');
}
AppLayer.prototype.processPopup = function (node) {
	var params;
	if (node.attributes.length > 0) {
		params = {};
		for (var i = 0; i < node.attributes.length; i++) {
			var name = node.attributes[i].nodeName;
			var value = node.attributes[i].nodeValue;
			params[name] = value;
		}
	} else {
		params = getNodeValue(node);
	}
	this.popup(params);
}
AppLayer.prototype.processAnchor = function (node) {
	document.location.hash = getNodeValue(node);
}
AppLayer.prototype.processScrollTo = function (node) {
	var pos = String(getNodeValue(node)).split(',');
	window.scrollTo(pos[0],pos[1]);
}
AppLayer.prototype.processDownload = function (node) {
	this.download(getNodeValue(node));
}
AppLayer.prototype.processRefresh = function (node) {
	document.location.reload();
}
AppLayer.prototype.processRedirect = function (node) {
	locationUrl.redirect(getNodeValue(node));
}
AppLayer.prototype.processGetParent = function (node) {
	if (window.parent && window.parent.document && window.parent.document.app) {
		window.parent.document.app.processResponse(node);
	}
}
AppLayer.prototype.processGetPart = function (node) {
	var id = node.getAttribute('ID');
	if (id) {
		var part = this.getPart(id);
		if (part) {
			part.processResponse(node);
		}
	}
}
AppLayer.prototype.processGetElement = function (node) {
	var id = node.getAttribute('ID');
	if (this.elements[id]) {
		this.elements[id].processResponse(node);
	}
}
AppLayer.prototype.processSetParam = function(node) {
	if (node.attributes.length > 0) {
		for (var i = 0; i < node.attributes.length; i++) {
			var name = node.attributes[i].nodeName;
			var value = node.attributes[i].nodeValue;
			if ((name != '_url') && (name != '_method')) {
				this.setParam(name,value);
			}
		}
	}
}
AppLayer.prototype.processClearParam = function(node) {
	if (node.attributes.length > 0) {
		for (var i = 0; i < node.attributes.length; i++) {
			var name = node.attributes[i].nodeName;
			if ((name != '_url') && (name != '_method')) {
				this.clearParam(name);
			}
		}
	} else {
		this.clearParam(getNodeValue(node));
	}
}
AppLayer.prototype.processAddHtml = function (node) {
	this.addHtml(getNodeValue(node));
}
AppLayer.prototype.processAppendHtml = function (node) {
	this.appendHtml(getNodeValue(node));
}
AppLayer.prototype.processSetTitle = function (node) {
	document.title = getNodeValue(node);
}
document['app'] = new AppLayer();
function TElement(core,props) {
	this['core'] = core;
	if (typeof(props) == 'object') {
		this['props'] = props;
		this.setup();
	}
}
TElement.prototype.setup = function(node) {
	if (!node) { node = this.getNode(); }
	if (node) {
		node['e'] = this;
		if (defined(this.props['Width'])) {
			this.setStyle('width',this.props['Width'],node);
		}
		if (defined(this.props['Height'])) {
			this.setStyle('height',this.props['Height'],node);
		}
	}
}
TElement.prototype.setEvent = function(event,func,order) {
	onEventManager.addEvent(this,event,func,order);
}
TElement.prototype.getID = function () {
	return this.props['ID'];
}
TElement.prototype.getPart = function (partID) {
	var elementID = this.getID();
	return this.core.getPart(elementID+partID);
}
TElement.prototype.getNode = function (index) {
	if (index > 0) {
		var nodes = this.getNodes();
		return nodes[index];
	} else {
		return document.getElementById(this.getID());
	}
}
TElement.prototype.getNodes = function () {
	var nodes = new Array();
	var node = this.getNode();
	if (node) {
		var tags = document.getElementsByTagName(node.tagName);
		for (var i = 0; i < tags.length; i++) {
			if (tags[i].id == node.id) {
				nodes.push(tags[i]);
			}
		}
	}
	return nodes;
}
TElement.prototype.getNodeID = function () {
	if (this.props['N']) {
		return this.props['N'];
	} else {
		return this.props['NodeID'];
	}
}
TElement.prototype.callEvent = function (event,params,modal) {
	if (!defined(modal)) {
		modal = this.eventModal;
	}
	this.core.setParam('act','callElementEvent');
	this.core.setParam('_',this.props['ID']);
	this.core.setParam('_ev_',event);
	this.core.setParam('_id_',this.getNodeID());
	this.core.update(params,modal);
}
TElement.prototype.showModal = function(params) {
	var width,height,cursor,top,left;
	if (typeof(params) == 'object') {
		top = params['top'];
		left = params['left'];
		width = params['width'];
		height = params['height'];
		cursor = params['cursor'];
	}
	if (!defined(width)) { width = this.props['Width'];	}
	if (!defined(height)) { height = this.props['Height']; }
	if (!defined(top)) { top = (((document.body.clientHeight - height - 20) / 2) + this.core.scrollTop()); }
	if (!defined(left)) { left = (((document.body.clientWidth - width) / 2) + this.core.scrollLeft()); }
	this.core.showModal(cursor,true,height);
	var node = this.getNode();
	var selects = node.getElementsByTagName('select');
	for (var i = 0; i < selects.length; i++) {
		if (selects[i].style.visibility == 'hidden') {
			selects[i].style.visibility = 'visible';
			selects[i]['modal_hidden'] = false;
		}
	}
	enableAllTags(node,'showModal');
	this.setStyle({
		'top'		: top,
		'left'		: left,
		'zIndex'	: 20,
		'position'	: 'absolute'
	});
	var formNodes = node.getElementsByTagName('form');
	for (var f = 0; f < formNodes.length; f++) {
		compileFormFocus(formNodes[f],f);
	}
	return;
}
TElement.prototype.hideModal = function() {
	this.setStyle({
		'top'		: -1000,
		'left'		: 0,
		'zIndex'	: -20,
		'position'	: 'absolute'
	});
	this.core.hideModal(true);
	return;
}
TElement.prototype.remove = function () {
	var element = this.getNode();
	element.parentNode.removeChild(element);
}
TElement.prototype.addHtml = function (html,element) {
	if (!element) {
		element = this.getNode();
	}
	var span = document.createElement('span');
	if (element) {
		element.appendChild(span);
		return changeTagHtml(span,html);
	}
}
TElement.prototype.newHtml = function (html) {
	var cid;
	if (this['C']) {
		cid = this['C'];
	} else {
		cid = this['Container'];
	}
	if (cid) {
		var container = this.core.getElement(cid);
		if (container) {
			container.addHtml(html);
		} else {
			cid = null;
			this.core.addHtml(html);
		}
	} else {
		this.core.addHtml(html);
	}
}
TElement.prototype.getHtml = function () {
	var tag = this.getNode();
	if (tag.outerHTML) {
		return tag.outerHTML;
	} else {
		var r = tag.ownerDocument.createRange();
		r.setStartBefore(tag);
		var df = r.createContextualFragment(html);
		return xml2text(df);
	}
}
TElement.prototype.setHtml = function (html) {
	var nodes = this.getNodes();
	for (var i = 0; i < nodes.length; i++) {
		var element = nodes[i];
		element['e'] = null;
		var tag = getTagFromHtml(html,element);
		if (tag) {
			if (isMSIE()) {
				html = tag.outerHTML;
				destroyTag(tag);
				changeTagHtml(element,html);
			} else {
				element.parentNode.replaceChild(tag,element);
			}
		} else {
			changeTagHtml(element,html);
		}
		element = this.getNode(i);
		this.setup(element);
		if (isMSIE() || isChrome()) {
			var scriptNodes = element.getElementsByTagName('script');
			for (var f = 0; f < scriptNodes.length; f++) {
				eval(scriptNodes[f].innerHTML);
			}
		}
		var formNodes = element.getElementsByTagName('form');
		for (var f = 0; f < formNodes.length; f++) {
			var formid = getProp(formNodes[f],'id');
			if (formid) {
				var form = document.app.getElement(formid);
				if (form) {
					form.setup(formNodes[f]);
				}
			}
			appCompileForm(formNodes[f],f);
		}
	}
}
TElement.prototype.appendHtml = TElement.prototype.addHtml;
TElement.prototype.setStyle = function(name,value,node) {
	if (typeof(name) == 'object') {
		for (var key in name) {
			this.setStyle(key,name[key],node);
		}
	} else {
		if (!node) { node = this.getNode(); }
		if (node) {
			node.style[name] = value;
		}
	}
	return;
}
TElement.prototype.getStyle = function(name,node) {
	if (!node) { node = this.getNode(); }
	if (node) {
		return node.style[name];
	}
	return;
}
TElement.prototype.processResponse = function(xml) {
	for (var i = 0; i < xml.childNodes.length; i++) {
		var node = xml.childNodes[i];
		var name = node.nodeName;
		if (name != '#text') {
			if (this['process'+name]) {
				this['process'+name](node);
			}
		}
	}
}
TElement.prototype.processAlert = function (node) {
	alert(makeStringValue(getNodeValue(node)));
}
TElement.prototype.processScript = function (node) {
	eval('with (this) { '+getNodeValue(node)+' }');
}
TElement.prototype.processRemove = function (node) {
	this.remove();
}
TElement.prototype.processAddHtml = function (node) {
	this.addHtml(getNodeValue(node));
}
TElement.prototype.processAppendHtml = TElement.prototype.processAddHtml;
TElement.prototype.processSetHtml = function (node) {
	this.setHtml(getNodeValue(node));
}
TElement.prototype.processGetPart = function (node) {
	var id = node.getAttribute('ID');
	var part = this.getPart(id);
	if (part) {
		part.processResponse(node);
	}
}
TElement.prototype.processSetStyle = function (node) {
	for (var i = 0; i < node.attributes.length; i++) {
		var name = node.attributes[i].nodeName;
		var value = node.attributes[i].nodeValue;
		this.setStyle(name,value);
	}
}
function loadTagUp(params) {
	var div,opener,attach,showType,eventType,onShow,onHide,onOpen;
	if (typeof(params) == 'object') {
		div = params['target'];
		attach = params['attach'];
		opener = params['opener'];
		showType = params['mode'];
		eventType = params['event'];
		onShow = params['onshow'];
		onHide = params['onhide'];
		onOpen = params['onopen'];
	}
	if (typeof(div) != 'object') {
		div = document.getElementById(div);
	}
	if (typeof(opener) != 'object') {
		opener = document.getElementById(opener);
	}
	if (typeof(attach) != 'object') {
		attach = document.getElementById(attach);
	}
	if (div && opener) {
		if (typeof(onOpen) == 'function') {
			opener['_onopen_'] = onOpen;
		}
		if ((showType == 'float') || (showType == 'popup')) {
			div.style['top'] = -1000;
		} else if (showType == 'block') {
			div.style['display'] = 'none';
		}
		div.xShow = function(event) {
			clearTimeout(div['hideTimeout']);
			if (window.event) {
				event = window.event;
			}
			if ((showType == 'float') || (showType == 'popup')) {
				var top, left;
				if (event) {
					if (attach) {
						var pos = getTagPos(attach);
						top = pos.y + parseInt(attach.offsetHeight);
						left = pos.x;
					} else {
						top = (event.clientY) ? event.clientY : event.screenY;
						left = (event.clientX) ? event.clientX : event.screenX;
						top += document.app.scrollTop();
						left += document.app.scrollLeft();
					}
					var width = parseInt(div.offsetWidth);
					if ((left + width) > document.body.clientWidth) {
						left = document.body.clientWidth - width - 10;
						div.style.width = width;
					}
				}
				if (showType == 'popup') {
					var dh = parseInt(div.offsetHeight);
					var bh = parseInt(document.body.offsetHeight);
					var st = document.app.scrollTop();
					var sh = (bh - top + st - 10);
					if (dh >= sh) {
						div.style.height = sh;
					}
				}
				div.style['top'] = top;
				div.style['left'] = left;
				div.style['position'] = 'absolute';
			} else if (showType == 'block') {
				div.style['display'] = 'block';
			}
			if (typeof(onShow) == 'function') {
				onShow(event);
			}
		};
		div.xHide = function(timeout) {
			div['hideTimeout'] = setTimeout(function() {
				if ((showType == 'float') || (showType == 'popup')) {
					div.style['top'] = -1000;
				} else if (showType == 'block') {
					div.style['display'] = 'none';
				}
				if (typeof(onHide) == 'function') {
					onHide();
				}
			},timeout);
		};
		if (eventType == 'over') {
			if (typeof(opener.onmouseover) == 'function') {
				opener['old_onmouseover'] = opener.onmouseover;
			}
			opener['onmouseover'] = function(event) {
				div.xShow(event);
				if (typeof(this['_onopen_']) == 'function') { this['_onopen_'](event); }
				if (typeof(this['old_onmouseover']) == 'function') { this['old_onmouseover'](event); }
			}
		} else if (eventType == 'click') {
			if (typeof(opener.onclick) == 'function') {
				opener['old_onclick'] = opener.onclick;
			}
			opener['onclick'] = function(event) {
				div.xShow(event);
				if (typeof(this['_onopen_']) == 'function') { this['_onopen_'](event); }
				if (typeof(this['old_onclick']) == 'function') { this['old_onclick'](event); }
			}
		}
		if (typeof(opener.onmouseout) == 'function') {
			opener['old_onmouseout'] = opener.onmouseout;
		}
		opener['onmouseout'] = function(event) {
			div.xHide(250)
			if (typeof(this['old_onmouseout']) == 'function') { this['old_onmouseout'](event); }
		};
		div['onmouseout'] = function() { div.xHide(250) };
		div['onmouseover'] = function() { clearTimeout(this['hideTimeout']); };
		div.xHide(0);
	}
}
var fmcb = null;
function FMGetCallBackFunc() { return(fmcb); }
function FMGetCallBackFunction() { return(fmcb); }
function x(c) { eval(decodeUrl(c)); }
function fmCallback(param,fileName,fullPath,imageType,fileSize,fileModified,imageWidth,imageHeight,fm_Image) {
	if (typeof(param) == 'function') {
		param(fileName,fullPath,imageType,fileSize,fileModified,imageWidth,imageHeight,fm_Image);
	} else {
		if (typeof(param) != 'object') {
			param = document.getElementById(param);
		}
		if (typeof(param) == 'object') {
			var tag = lc(param.tagName);
			if (tag == 'img') {
				tag.src = fullPath+fileName;
			} else if (tag == 'input') {
				tag.value = fullPath+fileName;
			}
		}
	}
	return true;
}
function makeStringValue(string) {
	string = string.replace(/\'/g,'\\\'');
	string = string.replace(/\n/g,'\\n');
	string = string.replace(/\t/g,'\\t');
	eval("string = String('"+string+"')");
	return string;
}
function makeQueryString(params) {
	var parts = new Array();
	if (typeof(params) == 'object') {
		for (var key in params) {
			if ((key != '') && (key != '_url') && (key != '_method') && (key != '')) {
				if (typeof(params[key]) != 'object') {
					params[key] = new Array(String(params[key]));
				}
				for (var i = 0; i < params[key].length; i++) {
					parts.push(cxEscape(key)+'='+cxEscape(params[key][i]));
				}
			}
		}
	}
	return String(parts.join('&'));
}
function sendHttpRequest(httpRequest,params) {
	if (httpRequest) {
		var url = (params['_url']) ? String(params['_url']) : '';
		var method = lc(params['_method']);
		var query = makeQueryString(params);
		if (method.indexOf('post') > -1) {
			httpRequest.open('POST',url,true);
			httpRequest.setRequestHeader("Request-Ajax", "1");
			httpRequest.setRequestHeader('Content-type','application/x-www-form-urlencoded');
			httpRequest.setRequestHeader('Content-length',query.length);
			httpRequest.setRequestHeader('Connection','close');
			httpRequest.send(query);
		} else {
			if (url.indexOf('?') == -1) { url += '?'; }
			httpRequest.open('GET',url+query,true);
			httpRequest.setRequestHeader("Request-Ajax", "1");
			httpRequest.send(null);
		}
	}
}
function getTagPos(e){
	var left = 0;
	var top  = 0;
	while (e.offsetParent){
		left += e.offsetLeft;
		top  += e.offsetTop;
		e     = e.offsetParent;
	}
	left += e.offsetLeft;
	top  += e.offsetTop;
	return {x:left, y:top};
}
function enableAllTags(parent,key) {
	enableTags(parent,'a',key);
	enableTags(parent,'img',key);
	enableTags(parent,'input',key);
	enableTags(parent,'select',key);
	enableTags(parent,'textarea',key);
}
function disableAllTags(parent,key) {
	disableTags(parent,'a',key);
	disableTags(parent,'img',key);
	disableTags(parent,'input',key);
	disableTags(parent,'select',key);
	disableTags(parent,'textarea',key);
}
function enableTags(parent,name,key) {
	if (parent && name) {
		var tags = parent.getElementsByTagName(name);
		for (var i = 0; i < tags.length; i++) {
			var tag = tags[i];
			if (tag['_disabled_control_'] == key) {
				tag.disabled = false;
				if (typeof(tag['_disabled_onclick_']) == 'function') {
					tag['onclick'] = tag['_disabled_onclick_'];
				} else {
					tag['onclick'] = function() { return(true); }
				}
				tag['_disabled_control_'] = '';
			}
		}
	}
	return;
}
function disableTags(parent,name,key) {
	if (parent && name) {
		var tags = parent.getElementsByTagName(name);
		for (var i = 0; i < tags.length; i++) {
			var tag = tags[i];
			if (getProp(tag,'disabled') == '') {
				if (!defined(tag['_disabled_control_'])) {
					tag.disabled = true;
					if (typeof(tag['onclick']) == 'function') {
						tag['_disabled_onclick_'] = tag['onclick'];
					}
					tag['onclick'] = function() { return(false); }
					tag['_disabled_control_'] = key;
				}
			}
		}
	}
	return;
}
function getTagFromHtml(html,node) {
	var span = document.createElement('SPAN');
	span.innerHTML = html;
	var tag;
	var tags = span.getElementsByTagName(node.tagName);
	for (var i = 0; i < tags.length; i++) {
		if (tags[i].id == node.id) {
			tag = tags[i];
			break;
		}
	}
	destroyTag(span);
	return tag;
}
function changeTagHtml(tag,html) {
	destroyTag(tag);
	if (tag.outerHTML) {
		tag.outerHTML = html;
		return tag;
	} else {
		var r = tag.ownerDocument.createRange();
		r.setStartBefore(tag);
		var df = r.createContextualFragment(html);
		tag.parentNode.replaceChild(df,tag);
		return df;
	}
}
function destroyTag(tag) {
	var as = tag.getElementsByTagName('a');
	for (var i = 0; i < as.length; i++) {
		var obj = as[i];
		obj['form'] = null;
	}
		var objects = tag.getElementsByTagName('object');
		for (var i = 0; i < objects.length; i++) {
			var obj = objects[i];
			for (var prop in obj) {
				if (typeof(obj[prop]) == 'function') {
					obj[prop] = null;
				}
			}
		}
	return;
}
function newXmlDoc(xml) {
	var doc;
	if (window.ActiveXObject) {
		doc = new ActiveXObject("Microsoft.XMLDOM");
		doc.async="false";
		doc.loadXML(xml);
	} else {
		var parser = new DOMParser();
		doc = parser.parseFromString(xml,"text/xml");
	}
	return doc.documentElement;
}
function xml2text(xml) {
	if (xml) {
		if (isFirefox()) {
			return (new XMLSerializer()).serializeToString(xml);
		} else if (xml.xml) {
			return xml.xml;
		}
	}
}
function defined(v) {
	if (String(''+v+'') == 'undefined') {
		return false;
	} else if (String(''+v+'').length > 0) {
		return true;
	} else {
		return false;
	}
}
function lc(string) {
	return String(string).toLowerCase();
}
function getFlashObject(id) {
	if (isFirefox()) {
		var embeds = document.getElementsByTagName('embed');
		var obj;
		for (var i = 0; i < embeds.length; i++) {
			if (embeds[i].name == id) {
				obj = embeds[i];
				break;
			}
		}
		return obj;
	} else {
		return document.getElementById(id);
	}
}
function fixFlashObject(id) {
	var flashObject = getFlashObject(id);
	if (flashObject.form) {
		window[id] = flashObject;
	}
}
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
function ControlVersion() {
	var version;
	var axo;
	var e;
	try {
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}
	if (!version) {
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			version = "WIN 6,0,21,0";
			axo.AllowScriptAccess = "always";
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}
	if (!version) {
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}
	if (!version) {
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}
	if (!version) {
		try {
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	return version;
}
function GetSwfVer(){
	var flashVer = -1;
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}
	return flashVer;
}
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			tempArray         = versionStr.split(" "); 	
			tempString        = tempArray[1];			
			versionArray      = tempString.split(",");	
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}
function supportFlex() {
	return DetectFlashVer(9, 0, 0);
}
function unloadApp() {
	document.app.clear();
		var objects = document.getElementsByTagName('object');
		for (var i = 0; i < objects.length; i++) {
			var obj = objects[i];
			for (var prop in obj) {
				if (typeof(obj[prop]) == 'function') {
					obj[prop] = null;
				}
			}
		}
	var as = document.getElementsByTagName('a');
	for (var i = 0; i < as.length; i++) {
		var obj = as[i];
		obj['form'] = null;
	}
	document['app'] = null;
	return true;
}
function TWindow(core,props) {
	this.base = TElement;
	this.base(core,props);
};
TWindow.prototype = new TElement;
TWindow.prototype.hideModal = function() {
	TElement.prototype.hideModal.call(this,true);
	this.getNode().parentNode.style['height'] = '0px';
}
function TPart(core,props) {
	this['core'] = core;
	if (typeof(props) == 'object') {
		this['props'] = props;
	}
}
TPart.prototype.remove = TElement.prototype.remove;
TPart.prototype.getNode = TElement.prototype.getNode;
TPart.prototype.getNodes = TElement.prototype.getNodes;
TPart.prototype.setHtml = TElement.prototype.setHtml;
TPart.prototype.addHtml = TElement.prototype.addHtml;
TPart.prototype.appendHtml = TElement.prototype.appendHtml;
TPart.prototype.setStyle = TElement.prototype.setStyle;
TPart.prototype.processResponse = TElement.prototype.processResponse;
TPart.prototype.processAlert = TElement.prototype.processAlert;
TPart.prototype.processScript = TElement.prototype.processScript;
TPart.prototype.processRemove = TElement.prototype.processRemove;
TPart.prototype.processSetHtml = TElement.prototype.processSetHtml;
TPart.prototype.processAddHtml = TElement.prototype.processAddHtml;
TPart.prototype.processAppendHtml = TElement.prototype.processAppendHtml;
TPart.prototype.processSetStyle = TElement.prototype.processSetStyle;
TPart.prototype.setup = function() {
}
TPart.prototype.getID = function () {
	return this.props['ID'];
}
TPart.prototype.getNodeID = function () {
	if (this.props['N']) {
		return this.props['N'];
	} else {
		return this.props['NodeID'];
	}
}
TPart.prototype.getElement = function() {
	if (this.props['E']) {
		return this.core.getElement(this.props['E']);
	} else {
		return this.core.getElement(this.props['ElementID']);
	}
}
TPart.prototype.getNode = function () {
	return document.getElementById(this.getID());
}
function TForm(core,props) {
	this.base = TElement;
	this.base(core,props);
	this.setEvent('error',function() {});
};
TForm.prototype = new TElement;
TForm.prototype.getForm = TElement.prototype.getNode;
TForm.prototype.getUrl = function () {
	var url = getProp(this.getNode(),'action');
	if (url == '') {
		url = '';
	}
	return url;
}
TForm.prototype.getMethod = function () {
	var method = getProp(this.getNode(),'method');
	var values = method.split('.');
	if (values.length > 0) {
		return values[0];
	} else {
		return method;
	}
}
TForm.prototype.getParams = function () {
	var form = this.getNode();
	var sbutton = form.submitedButton;
	var params = {};
	for (var i = 0; i < form.elements.length; i++) {
		var element = form.elements[i];
		var ename = element.name;
		var etype = element.type;
		var evalue = element.value;
		if ((lc(element.tagName) == 'object') || (lc(element.tagName) == 'embed')) {
			continue;
		} else {
			if (ename) {
				if (element.disabled) {
					continue;
				}
				if (etype == 'submit') {
					if (sbutton && (ename == sbutton.name)) {
						if (typeof(params[ename]) != 'object') { params[ename] = new Array(); }
						params[ename].push(evalue);
					}
				} else if (etype == 'checkbox') {
					if (element.checked) {
						if (typeof(params[ename]) != 'object') { params[ename] = new Array(); }
						params[ename].push(evalue);
					}
				} else if (etype == 'radio') {
					if (element.selected || element.checked) {
						if (typeof(params[ename]) != 'object') { params[ename] = new Array(); }
						params[ename].push(evalue);
					}
				} else if (etype == 'select-multiple') {
					for (var idx = 0; idx < element.options.length; idx++) {
						if (element.options[idx].selected){
							if (typeof(params[ename]) != 'object') { params[ename] = new Array(); }
							params[ename].push(element.options[idx].value);
						}
					}
				} else {
					if (typeof(params[ename]) != 'object') { params[ename] = new Array(); }
					params[ename].push(evalue);
				}
			}
		}
	}
	params['_url'] = this.getUrl();
	params['_method'] = this.getMethod();
	return params;
}
TForm.prototype.isAjax = function () {
	var method = this.getMethod();
	if (method.indexOf('ajax') > -1) {
		return true;
	} else {
		return false;
	}
}
TForm.prototype.isUpload = function () {
	var form = this.getNode();
	var upload = false;
	for (var i = 0; i < form.elements.length; i++) {
		if (form.elements[i].type) {
			if (lc(form.elements[i].type) == 'file') {
				upload = true;
				break;
			}
		}
	}
	return upload;
}
TForm.prototype.isUpdate = function () {
	var method = getProp(this.getNode(),'method');
	var values = method.split('.');
	if (values.length > 1) {
		if (values[1] == 'update') {
			return true;
		} else {
			return false;
		}
	} else {
		return false;
	}
}
TForm.prototype.cancelAjax = function(params) {
	var form = this.getNode();
	this.setDisabled(true);
	this.callEvent('Cancel',params);
}
TForm.prototype.submitAjax = function () {
	this.clearParams();
	var params = this.getParams();
	this.setDisabled(true);
	if (this.isUpdate()) {
		this.core.update(params);
	} else {
		this.core.request(params);
	}
	return false;
}
TForm.prototype.submitIframe = function() {
	var form = this.getNode();
	var name = this.getID()+Math.floor(Math.random() * 99999);
	var div = document.createElement("DIV");
	div.innerHTML = '<iframe style="display: none;" src="'+form.action+'" id="'+name+'" name="'+name+'" onload="document.app[\''+this.getID()+'\'].responseUpload(\''+name+'\')"></iframe>';
	this.core.appendTag(div);
	this.oldtarget = form.target;
	this.oldmethod = form.method;
	setProp(form,'target',name); form.target = name;
	setProp(form,'method','POST'); form.method = 'POST';
	setTimeout(function() { form.e.setDisabled(true); document.app.onrequest(); },100);
	return true;
}
TForm.prototype.responseUpload = function(id) {
	var form = this.getNode();
	setProp(form,'target',this.oldtarget); form.target = this.oldtarget;
	setProp(form,'method',this.oldmethod); form.method = this.oldmethod;
	this.core.onresponse();
	var iframe = document.getElementById(id);
	if (iframe && iframe.contentWindow && iframe.contentWindow.document) {
		var idoc = iframe.contentWindow.document;
		if (idoc['status'] != 'ok') {
			this.iframeError = idoc['status'];
			this.onerror();
			this.iframeError = null;
		}
	}
	return;
}
TForm.prototype.setAct = function (newact) {
	var form = this.getNode();
	for (var i = 0; i < form.elements.length; i++) {
		if (lc(form.elements[i].name) == 'act') {
			form.elements[i].value = newact;
		}
	}
}
TForm.prototype.setFocus = function (name) {
	var form = this.getNode();
	if (form.elements[name] && form.elements[name].type) {
		form.elements[name].focus();
	}
}
TForm.prototype.setValue = function (name,value) {
	var form = this.getNode();
	if (form.elements[name]) {
		if (!defined(form.elements[name].type) && (form.elements[name].length > 0)) {
			for (var i = 0; i < form.elements[name].length; i++) {
				var list = form.elements[name];
				var etype = list[i].type;
				var evalue = list[i].value;
				if (String(etype).search(/radio|check/) > -1) {
					if (evalue == value) {
						list[i].checked = true;
					}
					if (list[i].onchange) {
						list[i].onchange();
					}
				} else if (String(etype).search(/select/) > -1) {
					list[i].value = value;
					setProp(list[i],'selected',value);
					if (list[i].onchange) {
						list[i].onchange();
					}
				} else if (defined(etype)) {
					list[i].value = value;
					if (list[i].onchange) {
						list[i].onchange();
					}
				}
			}
		} else {
			if (form.elements[name].type.search(/checkbox/) > -1) {
				form.elements[name].checked = (form.elements[name].value == value) ? true : false;
			} else if (form.elements[name].type.search(/select/) > -1) {
				setProp(form.elements[name],'selected',value);
				form.elements[name].value = value;
			} else if (form.elements[name].type.search(/radio/) > -1) {
				radioSelect(form,name,value);
			} else {
				form.elements[name].value = value;
			}
			if (form.elements[name].onchange) {
				form.elements[name].onchange();
			}
		}
	}
}
TForm.prototype.setSubmit = function (newsubmit) {
	this.setValue('_'+this.getID()+'Submit',newsubmit);
}
TForm.prototype.setDisabled = function (value) {
	var key = this.getID();
	var form = this.getNode();
	if (value) {
		disableAllTags(form,key);
	} else {
		enableAllTags(form,key);
	}
	return;
}
TForm.prototype.setDisabledElement = function (name,value) {
	var form = this.getNode();
	if (form.elements[name]) {
		form.elements[name].disabled = value;
	}
	return;
}
TForm.prototype.reset = function() {
	var form = this.getForm();
	if (form) {
		form.reset();
		for (var i = 0; i < form.elements.length; i++) {
			if (form.elements[i].type) {
				if (form.elements[i].type.search(/select/i) > -1) {
					var selected = getProp(form.elements[i],'selected');
					if (selected) {
						setItemComboByValue(form.elements[i],selected);
					}
				} else if (form.elements[i].type.search(/submit/i) > -1) {
					var oldvalue = getProp(form.elements[i],'oldvalue');
					if (oldvalue) {
						form.elements[i].value = oldvalue;
					}
				}
			}
		}
	}
}
TForm.prototype.compile = function(onlyNew) {
	var form = this.getForm();
	if (form) {
		if (onlyNew) {
			for (var e = 0; e < form.elements.length; e++) {
				if (String(form.elements[e].tagName).toLowerCase() != 'object') {
					if (!form.elements[e].jslibCompiled) {
						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;
					}
				}
			}
		} else {
			appCompileForm(form,form.app_index);
		}
	}
}
TForm.prototype.checkAll = function (name,checked) {
	var form = this.getNode();
	if (form && form.elements[name]) {
		var element = form.elements[name];
		if (element.length) {
			for (var i = 0; i < element.length; i++) {
				if (element[i].type == 'checkbox') {
					if (element[i].disabled == false) {
						element[i].checked = checked;
					}
				}
			}
		} else {
			if (element.type == 'checkbox') {
				element.checked = checked;
			}
		}
	}
}
TForm.prototype.clearParams = function() {
	var form = this.getNode();
	for (var i = 0; i < form.elements.length; i++) {
		this.core.clearParam(form.elements[i].name);
	}
}
TForm.prototype.confirmChecked = function(name,msg) {
	var form = this.getNode();
	var ok = false;
	if (form.elements[name]) {
		if (form.elements[name].length) {
			for (var i = 0; i < form.elements[name].length; i++) {
				if (form.elements[name][i].checked) {
					ok = true;
					break;
				}
			}
		} else {
			if (form.elements[name].checked) {
				ok = true;
			}
		}
	}
	if (ok) {
		return true;
	} else {
		alert(msg);
		return false;
	}
}
TForm.prototype.processReset = function(node) {
	this.reset();
	return;
}
TForm.prototype.processEnable = function(node) {
	this.setDisabled(false);
	return;
}
TForm.prototype.processEnableElement = function(node) {
	var name = getNodeValue(node);
	this.setDisabledElement(name,false);
	return;
}
TForm.prototype.processCompile = function(node) {
	var onlyNew = (getNodeValue(node) == 'true') ? true : false;
	this.compile(onlyNew);
	return;
}
TForm.prototype.processClearParams = function(node) {
	this.clearParams();
	return;
}
TForm.prototype.processSetAct = function(node) {
	this.setAct(getNodeValue(node));
	return;
}
TForm.prototype.processSetValue = function(node) {
	for (var i = 0; i < node.attributes.length; i++) {
		var name = node.attributes[i].nodeName;
		var value = node.attributes[i].nodeValue;
		this.setValue(name,value);
	}
	return;
}
TForm.prototype.processSetFocus = function(node) {
	this.setFocus(getNodeValue(node));
	return;
}
function appFormAJAX() {}
appFormAJAX.prototype.getName = function() { return('FormAJAX'); }
appFormAJAX.prototype.startForm = function(form, index) {
	form['app_index'] = index;
	if (form.e) {
		if (getProp(form,'retainFocus') == 'true') {
			var tags = form.getElementsByTagName('a');
			for (var i = 0; i < tags.length; i++) {
				tags[i]['form'] = form;
				onEventManager.addEvent(tags[i], 'blur', function (pEvent) {
					this.form['retainFocusTimeout'] = setTimeout(function() { this.focus() },100);
				},'last',false);
				onEventManager.addEvent(tags[i], 'focus', function (pEvent) {
					clearTimeout(this.form['retainFocusTimeout']);
				},'last',false);
			}
		}
		onEventManager.addEvent(form, 'submit', function (pEvent) {
			if (this.e) {
				if (this.e.isAjax() && this.e.isUpload()) {
					return this.e.submitIframe();
				} else if (this.e.isAjax()) {
					return this.e.submitAjax();
				} else {
					return true;
				}
			} else {
				return true;
			}
		},'last');
	}
}
appFormAJAX.prototype.processElement = function(element, index) {
	if (element.form && element.form.e && (lc(element.tagName) != 'object')) {
		if (getProp(element.form,'retainFocus') == 'true') {
			if ((defined(element.type))) {
				onEventManager.addEvent(element, 'blur', function (pEvent) {
					this.form['retainFocusTimeout'] = setTimeout(function() { this.focus() },100);
				},'last',false);
				onEventManager.addEvent(element, 'focus', function (pEvent) {
					clearTimeout(this.form['retainFocusTimeout']);
				},'last',false);
			}
		}
		if ((element.type == 'checkbox')) {
			if (getProp(element,'checkAll')) {
				onEventManager.addEvent(element, 'click', function (pEvent) {
					this.form.e.checkAll(getProp(this,'checkAll'),this.checked);
				},'last',false);
			}
		}
		if ((element.type == 'submit') || (element.type == 'button') || (element.type == 'image')) {
			if (getProp(element,'confirmChecked')) {
				onEventManager.addEvent(element, 'click', function (pEvent) {
					return this.form.e.confirmChecked(
						getProp(this,'confirmChecked'),
						makeStringValue(getProp(this,'confirmCheckedMsg'))
					);
				},'first',true);
			}
			if (getProp(element,'confirmClick')) {
				onEventManager.addEvent(element, 'click', function (pEvent) {
					return confirm(makeStringValue(getProp(this,'confirmClick')));
				},'middle',true);
			}
			if (getProp(element,'changeAct')) {
				onEventManager.addEvent(element, 'click', function (pEvent) {
					this.form.e.setAct(getProp(this,'changeAct'));
				},'last',false);
			}
			if (getProp(element,'changeSubmit')) {
				onEventManager.addEvent(element, 'click', function (pEvent) {
					this.form.e.setSubmit(getProp(this,'changeSubmit'));
				},'last',false);
			}
			if (getProp(element,'disableOnClick')) {
				onEventManager.addEvent(element, 'click', function (pEvent) {
					this.disabled = true;
				},'last',false);
			}
			if (element.form.e.isAjax()) {
				if ((element.type == 'submit') || (element.type == 'image')) {
					onEventManager.addEvent(element, 'click', function (pEvent) {
						this.form.submitedButton = this;
					},'last',false);
				}
			}
		}
	}
}
var FormAJAX = new appFormAJAX();
if (appAddCompile) {
	appAddCompile( FormAJAX );
}
function TTableList(core,props) {
	this.base = TElement;
	this.base(core,props);
};
TTableList.prototype = new TElement;
function TTableData(core,props) {
	this.base = TElement;
	this.base(core,props);
};
TTableData.prototype = new TElement;
TTableData.prototype.processCalendar = function(node) {
	var place = document.getElementById('tdvdatecalendar');
	if (place) {
		changeTagHtml(place,getNodeValue(node));
	} else {
		this.processAddHtml(node);
	}
	return;
}
TTableData.prototype.processImageUploaded = function(node) {
	var name = node.getAttribute('name');
	var image = node.getAttribute('image');
	var thumb = node.getAttribute('thumb');
	tdvUploadImageSaved(name,image,thumb);
	tdvUploadImageClose(document.getElementById('tdvUploadImageForm'));
	return;
}
var msgCalendarSupportFlex = '';
var tdvDateCalendarType;
var tdvDateCalendarInput;
var tdvDateCalendarTimer;
function tdvDateTimeFocus(element,name) {
	if (name && element && element.form && element.form.elements) {
		if (element.form.elements[name]) {
			if (element.form.elements[name].onfocus) {
				return(element.form.elements[name].onfocus());
			}
		}
	}
	return true;
}
function tdvDateSetupFocus(name) {
	var hidden = document.getElementById(name);
	if (hidden) {
		hidden.focus = function() { try { hidden.form.elements[name+'_1'].focus(); } catch(e) {} }
	}
}
function tdvDateChange(name,event,caller) {
	if (window.event) {
		event = window.event;
	}
	var input = document.getElementById(name);
	if (input) {
		var fd1 = document.getElementById(name+'_1');
		var fd2 = document.getElementById(name+'_2');
		var fd3 = document.getElementById(name+'_3');
		if (fd1 && fd2 && fd3) {
			if ((fd1.value != '') || (fd2.value != '') || (fd3.value != '')) {
				input.value = fd1.value+'/'+fd2.value+'/'+fd3.value;
				if (caller == 'onchange') {
					if (input.onchange) {
						input.onchange();
					}
				}
			} else {
				input.value = '';
			}
		} else {
			input.value = '';
		}
		var calendar = getFlashObject('tdvDateCalendarObject');
		if (calendar && tdvDateCalendarInput) {
			if (tdvDateCalendarInput.id == input.name) {
				calendar.setType(tdvDateCalendarType);
				calendar.setSelectedDate(tdvDateCalendarInput.value);
			}
		}
	}
	return;
}
function tdvDateUpdate(input) {
	if (input) {
		var name = input.name;
		var fd1 = document.getElementById(name+'_1');
		var fd2 = document.getElementById(name+'_2');
		var fd3 = document.getElementById(name+'_3');
		if (fd1 && fd2 && fd3) {
			var values = String(input.value).split("/");
			fd1.value = (values[0]) ? values[0] : "";
			fd2.value = (values[1]) ? values[1] : "";
			fd3.value = (values[2]) ? values[2] : "";
		}
	}
}
function tdvTimeChange(name,event,caller) {
	if (window.event) {
		event = window.event;
	}
	var input = document.getElementById(name);
	var fd1 = document.getElementById(name+'_1');
	var fd2 = document.getElementById(name+'_2');
	if (fd1 && fd2 && input) {
		if ((fd1.value != '') || (fd2.value != '')) {
			var values = new Array();
			values.push(fd1.value);
			values.push(fd2.value);
			values.push("00");
			input.value = values.join(":");
			if (caller == 'onchange') {
				if (input.onchange) {
					input.onchange();
				}
			}
		} else {
			input.value = '';
		}
	} else if (input) {
		input.value = '';
	}
	return true;
}
function tdvTimeUpdate(input) {
	if (input) {
		var name = input.name;
		var fd1 = document.getElementById(name+'_1');
		var fd2 = document.getElementById(name+'_2');
		if (fd1 && fd2 && input) {
			var values = String(input.value).split(":");
			fd1.value = (values[0]) ? values[0] : "";
			fd2.value = (values[1]) ? values[1] : "";
		}
	}
	return true;
}
function tdvDateCalendarPos(top,left) {
	var div = document.getElementById('tdvDateCalendarContainer');
	if (div) {
		div.style.position = 'absolute';
		div.style.top = top;
		div.style.left = left;
		div.style.width = 200;
		div.style.height = 180;
	}
	if (tdvDateCalendarInput) {
		tdvDateCalendarImgLoaded(tdvDateCalendarInput.name);
	}
	return;
}
function tdvDateCalendarOut(name) {
	if (tdvDateCalendarTimer) {
		clearTimeout(tdvDateCalendarTimer);
	}
	tdvDateCalendarTimer = setTimeout(tdvDateCalendarHide,'750');
}
function tdvDateCalendarOver(name) {
	if (tdvDateCalendarTimer) {
		if (name && tdvDateCalendarInput && (tdvDateCalendarInput.id != name)) {
		} else {
			clearTimeout(tdvDateCalendarTimer);
		}
	}
}
function tdvDateCalendarHide() {
	var div = document.getElementById('tdvDateCalendarContainer');
	if (div) {
		div.style.top = -1000;
		tdvDateCalendarTimer = null;
	}
}
function tdvDateCalendarLoaded() {
	if (tdvDateCalendarType && tdvDateCalendarInput) {
		tdvDateCalendarImgClick(tdvDateCalendarInput.name);
		var calendar = getFlashObject('tdvDateCalendarObject');
		__flash_savedUnloadHandler = null;
		if (calendar) {
			calendar.setType(tdvDateCalendarType);
			calendar.setSelectedDate(tdvDateCalendarInput.value);
		}
	}
	return;
}
function tdvDateCalendarChange(date) {
	if (tdvDateCalendarInput) {
		tdvDateCalendarInput.value = date;
		if (tdvDateCalendarInput.onchange) {
			tdvDateCalendarInput.onchange();
		}
		tdvDateUpdate(tdvDateCalendarInput);
		tdvDateCalendarHide();
	}
}
function tdvDateCalendarImgClick(name,id,event) {
	if (supportFlex()) {
		if (tdvDateCalendarTimer) {
			clearTimeout(tdvDateCalendarTimer);
		}
		var container = document.getElementById('tdvDateCalendarContainer');
		var top = 0;
		var left = 0;
		if (window.event) {
			event = window.event;
		}
		if (event) {
			top = (event.clientY) ? event.clientY : event.screenY;
			left = (event.clientX) ? event.clientX : event.screenX;
			top += document.app.scrollTop();
			left += document.app.scrollLeft();
			var cwidth = 205;
			if ((left + cwidth) > document.body.clientWidth) {
				left = document.body.clientWidth - cwidth;
			}
			var cheight = 180;
			if ((top + cheight) > document.body.scrollHeight) {
				top = document.body.scrollHeight - cheight;
			}
			if (tdvDateCalendarInput && (tdvDateCalendarInput.name == name)) {
				if (container) {
					if (parseInt(container.style.top) > 0) {
						top = -1000;
					}
				}
			}
		}
		tdvDateCalendarType = 'date';
		tdvDateCalendarInput = document.getElementById(name);
		if (container) {
			if (id) {
				tdvDateCalendarPos(top,left);
				var calendar = getFlashObject('tdvDateCalendarObject');
				if (calendar) {
					if (calendar.setType) {
						calendar.setType(tdvDateCalendarType);
					}
					if (tdvDateCalendarInput) {
						if (calendar.setSelectedDate) {
							calendar.setSelectedDate(tdvDateCalendarInput.value);
						}
					}
				}
			}
		} else {
			if (id) {
				var element = document.app.getElement(id);
				if (element) {
					var img = document.getElementById(name+'CalendarImg');
					if (img) {
						var loadingimg = getProp(img,'loadingimg');
						if (String(img.src).search(loadingimg) == -1) {
							img.src = loadingimg;
							element.callEvent('Calendar',{
								'tdvDateCalendarContainer_top' : top,
								'tdvDateCalendarContainer_left' : left
							},false);
						}
					}
				}
			}
		}
	} else {
		alert(msgCalendarSupportFlex);
	}
	return;
}
function tdvDateCalendarImgLoaded(name) {
	var img = document.getElementById(name+'CalendarImg');
	if (img) {
		var loadingimg = getProp(img,'loadingimg');
		if (String(img.src).search(loadingimg) > -1) {
			var calendarimg = getProp(img,'calendarimg');
			img.src = calendarimg;
		}
	}
	return;
}
function tdvFMImageClick(name) {
	document.app.fmImage(function(fileName,fullPath,imageType,fileSize,fileModified,imageWidth,imageHeight,fm_Image) { tdvFMImageSelected(name,fileName,fullPath,imageType,fileSize,fileModified,imageWidth,imageHeight,fm_Image); });
}
function tdvFMImageSelected(name,fileName,fullPath,imageType,fileSize,fileModified,imageWidth,imageHeight,fm_Image) {
	var img = document.getElementById(name+'Img');
	if (img) {
		var url = String(fullPath+fileName);
		url = url.replace(/::/i,'thumb::');
		img.src = url;
	}
	var hidden = document.getElementById(name);
	if (hidden) {
		hidden.value = fullPath+fileName;
	}
}
function tdvUploadImageClick(name,id,event,formAct) {
	if (window.event) {
		event = window.event;
	}
	if (id) {
		var element = document.app.getElement(id);
		if (element) {
			var container = document.getElementById('tdvUploadImageContainer');
			if (container) {
				if (parseInt(container.style.top) < 0) {
					tdvUploadImageFormPos(300,125,{
						'_'	: element.getID(),
						'_id_' : element.getNodeID(),
						'tdvUploadImageName' : name
					});
				}
			} else {
				element.callEvent('UploadImageLoad',{
					'tdvUploadImageName' : name
				});
			}
		}
	}
}
function tdvUploadImageFormPos(W,H,params) {
	var container = document.getElementById('tdvUploadImageContainer');
	if (container) {
		var selects = document.getElementsByTagName('select');
		for (var i = 0; i < selects.length; i++) {
			if (selects[i].style.visibility != 'hidden') {
				selects[i].style.visibility = 'hidden';
				selects[i]['tdvuploadimg_hidden'] = true;
			}
		}
		try {
			document.getElementById('tdvUploadImageForm').style.display = 'block';
			document.getElementById('tdvUploadImageSending').style.display = 'none';
		} catch (e) {}
		var T = ((document.body.clientHeight - H) / 2) + document.app.scrollTop();
		var L = ((document.body.clientWidth - W) / 2) + document.app.scrollLeft();
		container.style.top = T;
		container.style.left = L;
		container.style.width = W;
		container.style.height = H;
		container.style.zIndex = 30;
		document.app.showModal();
		enableAllTags(container,'showModal');
		if (typeof(params) == 'object') {
			var form = document.getElementById('tdvUploadImageForm');
			if (form) {
				for (var i = 0; i < form.elements.length; i++) {
					var element = form.elements[i];
					if ((defined(element.type))) {
						onEventManager.addEvent(element, 'blur', function (pEvent) {
							this.form['retainFocusTimeout'] = setTimeout(function() { form.elements['tdvUploadImageFile'].focus(); },100);
						},'last',false);
						onEventManager.addEvent(element, 'focus', function (pEvent) {
							clearTimeout(this.form['retainFocusTimeout']);
						},'last',false);
					}
				}
				for (var key in params) {
					if (form.elements[key]) {
						form.elements[key].value = params[key];
					}
				}
				if (form.elements['tdvUploadImageName']) {
					var id = form.elements['tdvUploadImageName'].value;
					var hidden = document.getElementById(id);
					if (hidden) {
						if (hidden.form) {
							disableAllTags(hidden.form,'tdvuploadimg');
						}
					}
				}
				if (form.elements['tdvUploadImageFile']) {
					form.elements['tdvUploadImageFile'].focus();
				}
			}
		}
	}
}
function tdvUploadImageSaved(name,url,thumb) {
	var img = document.getElementById(name+'Img');
	if (img) {
		if (thumb != '') {
			img.src = thumb;
		} else {
			img.src = url;
		}
	}
	var hidden = document.getElementById(name);
	if (hidden) {
		if (hidden.form) {
			enableAllTags(hidden.form,'tdvuploadimg');
		}
		hidden.value = url;
	}
	return;
}
function tdvUploadImageFormValidate(form,msg) {
	for (var i = 0; i < form.elements.length; i++) {
		if (form.elements[i].type == 'file') {
			var file = form.elements[i].value;
			if (file.search(/\.png$|\.gif$|\.jpg$|\.jpeg$/i) == -1) {
				alert(msg);
				return false;
			}
		}
	}
	setTimeout(function() {
		try {
			document.getElementById('tdvUploadImageForm').style.display = 'none';
			document.getElementById('tdvUploadImageSending').style.display = 'block';
		} catch (e) {}
	},100);
	for (var i = 0; i < form.elements.length; i++) {
		var element = form.elements[i];
		if ((defined(element.type))) {
			element.onblur = null;
			element.onfocus = null;
		}
	}
	return true;
}
function tdvUploadImageResponse(iframe,msgLength) {
	if (iframe && iframe.contentWindow && iframe.contentWindow.document) {
		var idoc = iframe.contentWindow.document;
		if (idoc['status'] == 'length') {
			alert(msgLength);
			document.getElementById('tdvUploadImageForm').style.display = 'block';
			document.getElementById('tdvUploadImageSending').style.display = 'none';
		}
	}
}
function tdvUploadImageClose(form) {
	var container = document.getElementById('tdvUploadImageContainer');
	if (container) {
		var selects = document.getElementsByTagName('select');
		for (var i = 0; i < selects.length; i++) {
			if (selects[i].style.visibility == 'hidden') {
				if (selects[i]['tdvuploadimg_hidden']) {
					selects[i].style.visibility = 'visible';
					selects[i]['tdvuploadimg_hidden'] = false;
				}
			}
		}
		if (form && form.elements['tdvUploadImageName']) {
			var id = form.elements['tdvUploadImageName'].value;
			var hidden = document.getElementById(id);
			if (hidden) {
				if (hidden.form) {
					enableAllTags(hidden.form,'tdvuploadimg');
				}
			}
		}
		for (var i = 0; i < form.elements.length; i++) {
			var element = form.elements[i];
			if ((defined(element.type))) {
				element.onblur = null;
				element.onfocus = null;
			}
		}
		try {
			document.getElementById('tdvUploadImageForm').reset();
		} catch (e) {}
		container.style['top'] = -1000;
		container.style['position'] = 'absolute';
		document.app.hideModal();
	}
}
function TPage(core,props) {
	this.base = TElement;
	this.base(core,props);
};
TPage.prototype = new TElement;
function TShape(core,props) {
	this.base = TElement;
	this.base(core,props);
};
TShape.prototype = new TElement;
function TStep(core,props) {
	this.base = TElement;
	this.base(core,props);
};
TStep.prototype = new TElement;
TStep.prototype.clearParams = function () {
	this.core.clearParam(this.getID()+'_index');
	this.core.clearParam(this.getID()+'_limit');
	return;
}
TStep.prototype.processClearParams = function(node) {
	this.clearParams();
	return;
}
