/*
xGUI class for xGUI.php
ver 0.2
chglog
0.2
- waitText receiving
*/
if (typeof xGUI != 'object' || typeof document.xGUI=='undefined'){
xGUI = new Object();
/*
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
*/
/**
prototype.js parts
*/
function $() {
	if(typeof(arguments[i])=="object") return arguments[i];
	var results = [], element;
 	for (var i = 0; i < arguments.length; i++) {
	element = arguments[i];
    if (typeof element == 'string')
		element = document.getElementById(element);
		results.push(element);
	}
	return results.length < 2 ? results[0] : results;
}
function $f(element) {
	return document.getElementsByName(element);
}

/*******/

xGUI.Call = function(callback, args){
	if(typeof(callback) =='function'){
		callback(args);
	}else if(typeof(callback) =='object' && callback instanceof Array){
		if(callback[2]==undefined) callback[0][callback[1]](args);
		else callback[0][callback[1]](callback[2]);
	}else if(typeof(callback) =='string'){
		xGUI.globalEvalScript(callback);
	}else{
		throw({Message:'Invalid callback!', CallbackType:typeof(callback), Callback:callback, 'args':args});
	}
}

xGUI.clone = function (source, isDeep){
	if(source.toSource) var back= eval(source.toSource());
	else var back= source;
	for(i in source){
		if(isDeep){
			back[i] = xGUI.clone(source[i], isDeep);
		}else{
			back[i] = source[i];	
		}
	}
	return back;
}

xGUI.extend = function(destination, source) {
  for (property in source) {
    destination[property] = source[property];
  }
  return destination;
}

xGUI.Nothing = function(){}

if(typeof xGUI.debugMode == "undefined") xGUI.debugMode = true;

xGUI.swfObjectLoaded=false;

if( (typeof xGUI.dir == 'undefined')){
	if(typeof xGUIdir == 'undefined'){
		xGUIdir = xGUI.dir = 'xGUI';
	}else{
		xGUI.dir = xGUIdir;
	}
}


xGUI.url = function(url){
	xGUI.waitwindow.open();
	location.href = url;
}
xGUI.redir = function(url){
	location.replace(url);
}

/**
url = 'http://username:password@hostname/path?arg=value#anchor';

Array
(
    [scheme] => http
    [host] => hostname
    [user] => username
    [pass] => password
    [path] => /path
    [query] => arg=value
    [fragment] => anchor
)
*/

/*
xGUI.URL = function(){
	
}
xGUI.URL.prototype.scheme = null;
xGUI.URL.prototype.host = null;
xGUI.URL.prototype.user = null;
xGUI.URL.prototype.pass = null;
xGUI.URL.prototype.path = null;
xGUI.URL.prototype.query = null;
xGUI.URL.prototype.fragment = null;

xGUI.URL.parseUrl = function(url){
	var p = "";
	// protocol, domain, user, pass
	p += "(?:([a-zA-Z]{2,10})\:\/\/(?:(\w+)(?:\:(\w*)|)@|)([a-zA-Z0-9\.-]+|)(?:\:([0-9]+)|)|)";
	// path
	p += "([^?]+|\/?)";
	// query
	p += "(\?[a-zA-Z0-9\!:+=&%@!\-\/]+|\??)";
	// fragment
	p += "(?:#([a-z0-9_])+|(?:))";
	var re = /(?:([a-zA-Z]{2,10})\:\/\/(?:(\w+)(?:\:(\w*)|)@|)([a-zA-Z0-9\.-]+|)(?:\:([0-9]+)|)|)([^?]+|\/?)(\?[a-zA-Z0-9\!:+=&%@!\-\/]+|\??)(?:#([a-z0-9_])+|(?:))/;
	var result = 111;
	result = re.match(url);
	xGUI.firedebug(result);
	xGUI.debug(result);
	alert(result);
	return result;
}


/* Common functions */

xGUI.GetX = function (obj)
{
	var x = 0;

	do
	{
		x += obj.offsetLeft;
		obj = obj.offsetParent;
	}
	while (obj);
	return x;
}
xGUI.GetY = function (obj)
{
	var y = 0;
	do
	{
		y += obj.offsetTop;
		obj = obj.offsetParent;
	}
	while (obj);
	return y;
}


xGUI.ignoreErrors = function() {
	return true;
}



xGUI.LoadScript = function (url)
{
	var e = document.createElement("script");
	e.src = url;
	e.type="text/javascript";
	return document.getElementsByTagName("head")[0].appendChild(e);
}

xGUI.syncLoadJavascript = function(jsurl, onceOnly){
	if(onceOnly){
		for(var i=0; i<xGUI.syncLoadJavascript_LoadList.length; i++){
			if(xGUI.syncLoadJavascript_LoadList[i]==jsurl) return;
		}
	}
	xGUI.syncLoadJavascript_LoadList.push(jsurl);
	xGUI.console('load script '+jsurl);
	var r = new xGUI.ajax.Request({realSync:true, url:jsurl,method:'get',async:true});
	r.onComplete = 'xGUI.console("script loaded"); xGUI.globalEvalScript(this.getResponseText()+";xGUI.console(\'script evaluated\')");';
	r.send();
}

xGUI.globalEvalScript = function(__data){
	__data= __data.replace(/^\s+|\s+$/g,"");
	if(!__data)return;
	try{
	//return eval(__data);
	if ( window.execScript ){
		window.execScript( __data );
	//}else if(xGUI.DOM.isSafari()){
	//	with(window){with(document){
	//		window.setTimeout( __data, 0 );
	//	}}
	}else{
		return eval.call( window, __data );
	}
	return;
	}catch(e){
		xGUI.debug(e);
		throw e;
	}
}

xGUI.loadPackage =function(p){
	xGUI.syncLoadJavascript(xGUI.dir+'/xGUI.'+p+'.js', true);
}

xGUI.syncLoadJavascript_LoadList = new Array();


xGUI.getSWFObject=function(){
	if(!xGUI.swfObjectLoaded){
		xGUI.syncLoadJavascript(xGUIdir+'/swfobject.js', true);
	}
}

xGUI.LoadOverlib = function(){
	xGUI.syncLoadJavascript(xGUI.dir+"/overlib/overlib.js", true); 
	xGUI.syncLoadJavascript(xGUI.dir+"/overlib/template.js", true);
}


xGUI.addEventListener = function(ev, f){
	xGUI.DOM.addEventListener(document,ev,f);
}


/*
Debug
*/

xGUI.console = function(e){
	if (typeof(window.console)=='object'){
		if(arguments.length > 1){
			for(var i = 0; i<arguments.length; i++){
				xGUI.console(arguments[i]);
			}
		}else{
			window.console.log(e);
		}
	}
}
xGUI.fbdbg = xGUI.console;
xGUI.firedebug = xGUI.console;

xGUI.vardump = function(obj){
	var tmp="\n";
	for(i in obj){
		tmp+=i+": \n"+obj[i]+"\n";
	}
	return tmp;	
}

xGUI.debug = function(_obj){
	var obj;
	if(!xGUI.debugMode) return;
	var field="innerHTML";
	var to = typeof(_obj);
	if(_obj && to=="object"){
		if(1||_obj.Code){
			if(_obj instanceof Array){
				var tmp="\n";
				for(var i=0; i<_obj.length ; i++){
					tmp+=i+": "+_obj[i]+"\n";
				}
				obj = tmp;
			}else{
				var tmp="\n";
				for(var i in _obj){
					tmp+=i+": \n"+_obj[i]+"\n";
				}
				obj = tmp;
			}
		}else if(_obj.toSource){
			obj = _obj.toSource();
		}
	}else{
		obj = _obj;
	}
	obj = new String(obj);
	obj = obj.split("\&").join('&amp;');
	obj = obj.split("\<").join('&lt;');
	obj = obj.split("\>").join('&gt;');
//	obj = obj.split("\n").join("\n<br />");
//	obj = obj.split("\t").join(' &nbsp;&nbsp;&nbsp;&nbsp; ');
	obj = "<pre>"+obj+"</pre>";
	if(!xGUI.debug.enabled) return;
	b = xGUI.debug.createBox();
	obj = "#" + ++xGUI.debug.row + ": "+ (obj) +"<br />\n\r";
	if(xGUI.debug.direction){
		b[field] += obj;
	}else{
		b[field] = obj+b[field];
	}
}
xGUI.debug.enabled=true;
xGUI.debug.pos = 2 // 1-topleft, 2-topright, 3-bottomright, 4-bottomleft
xGUI.debug.size = new Array(450,250);
xGUI.debug.direction = 0;
xGUI.debug.row = 0;
xGUI.debug.createBox = function(){
	if(e=document.getElementById("xGUIdebugBox")){
		e.style.display="";
		document.getElementById("xGUIdebugBox_X").style.display="";
		return e;
	}
	var e = document.createElement("div");
	e.id = "xGUIdebugBox";
	e.style.fontSize="12px";
	e.style.backgroundColor = "#fefefe";
	e.style.border = "1px solid black";
	if(xGUI.DOM.isIE()){
		e.style.position= "absolute";
	}else{
		e.style.position= "fixed";
	}
	e.style.width = xGUI.debug.size[0]+"px";
	e.style.height = xGUI.debug.size[1]+"px";
	e.style.overflow = "auto";
	e.style.margin="5px";
	e.style.padding="2px";
	if(xGUI.debug.pos<3) e.style.top = "0px";
	else e.style.bottom = "0px";
	if(xGUI.debug.pos == 1 || xGUI.debug.pos==4) e.style.left = "0px";
	else e.style.right = "0px";
	document.getElementsByTagName("body")[0].appendChild(e);

	var ex = document.createElement("div");
	document.getElementsByTagName("body")[0].appendChild(ex);
	ex.innerHTML = "x";
	ex.id="xGUIdebugBox_X"
	ex.style.backgroundColor="#fff";
	ex.style.border="1px solid #000";
	ex.style.position="fixed";
	ex.style.padding="1px";
	ex.style.lineHeight="10px";
	ex.style.fontSize="10px";
	ex.style.textAlign="center";
	ex.style.height=ex.style.width="10px";
	ex.style.top=(xGUI.GetY(e))+"px";
	ex.style.left=(xGUI.GetX(e)-15)+"px";
	ex.onmouseover = function(){
		document.getElementById("xGUIdebugBox").style.display="none";
		document.getElementById("xGUIdebugBox_X").style.display="none";
	}
	return e;
}

/*
Debug EOF
*/

xGUI.flashLine = function(msg, type){
	if(!type) type = 1;
	var c, e;
	if(!(c=$("xGUIflashLineContainer"))){
		c=document.createElement("div");
		document.getElementsByTagName("body")[0].appendChild(c);
		c.id = "xGUIflashLineContainer";
//		c.style.marginTop=new String(document.body.scrollTop)+"px";
//		c.flashKeepTop = xGUI.flashLine.keepTop;
//		xGUI.DOM.addEventListener(window, 'scroll', "$('"+c.id+"').flashKeepTop()");
	}
	e=document.createElement("div")
	e.id = "xGUIflashLine"+String(xGUI.flashLine.counter++);
	switch(type){
		case 2: e.className="xGUI_flashLine_success"; break;
		case 3: e.className="xGUI_flashLine_warning"; break;
		case 1: default: e.className="xGUI_flashLine_info"; break;
	}
	e.innerHTML = msg;
	e.flashOp = xGUI.flashLine.startOp;
	e.flashHideRate = xGUI.flashLine.hideRate;
	e.flashHide = xGUI.flashLine.hide;
	c.appendChild(e);
	setTimeout("$('"+e.id+"').flashHide()", xGUI.flashLine.hideFrequence);
}

xGUI.flashLine.startOp = 200;
xGUI.flashLine.hideFrequence = 70;
xGUI.flashLine.hideRate = 5;
xGUI.flashLine.counter = 0;

xGUI.flashLine.hide=function(){
	this.flashOp-=xGUI.flashLine.hideRate;
	if(this.flashOp<1){
		this.parentNode.removeChild(this);
	}else{
		xGUI.FX.setOpacity(this, this.flashOp);
		setTimeout("$('"+this.id+"').flashHide()", xGUI.flashLine.hideFrequence);
	}
}
xGUI.flashLine.keepTop = function(){	
//	this.style.marginTop=new String(document.body.scrollTop)+"px";
}
/**
xGUI.FX
*/
xGUI.FX = new Object();
xGUI.FX.setOpacity=function(e, percent){
	percent = Math.round(percent);
	if(percent<0)percent = 0;
	if(percent>100)percent = 100;
	e = $(e);
	e.style.MozOpacity = percent/100;
	e.style.opacity = percent/100;
//	e.filters.alpha.opacity = percent;
//	e.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+String(percent)+")"
	e.style.filter = "alpha(opacity="+String(percent)+")"
}
xGUI.FX.ClassMorph = function(srcClass, targetClass){}

xGUI.FX.BlinkClass = function(e, targetClass, opts){
	if(!e) return false;
	if(!opts) opts = {};
	if(!opts.count) opts.count = 3;
	if(!opts.rate) opts.rate = 8;
	this.options=opts;
	this.originalClass = e.className;
	this.targetClass = targetClass;
	this.element=e;
	new xGUI.FX.EffectProcessor(this);
}
xGUI.FX.BlinkClass.prototype.options = null;
xGUI.FX.BlinkClass.prototype.state = 0;
xGUI.FX.BlinkClass.prototype.element = null;
xGUI.FX.BlinkClass.prototype.originalClass = "";
xGUI.FX.BlinkClass.prototype.targetClass = "";
xGUI.FX.BlinkClass.prototype.Process = function(){
	if(this.state%2){
		this.element.className = this.originalClass;
	}else{
		if( (this.state/2) >= this.options.count) return 0;
		this.element.className = this.targetClass;
	}
	this.state++;
	return 1000/this.options.rate;
}


xGUI.FX.runningEffects = new Array(),

xGUI.FX.EffectProcessor = function(FX){
	this.FX = FX;
	this.ident = xGUI.FX.runningEffects.length;
	xGUI.FX.runningEffects[this.ident] = this;
	this.Resume();
}
xGUI.FX.EffectProcessor.prototype.FX=null;
xGUI.FX.EffectProcessor.prototype.ident=0;
xGUI.FX.EffectProcessor.prototype.Resume = function(){
	var delay;
	if(delay = this.FX.Process()){
		setTimeout("xGUI.FX.runningEffects["+this.ident+"].Resume()", Math.round(delay));
	}else{
		this.FX = null;
		xGUI.FX.runningEffects[this.ident] = null;
	}
};


xGUI.setDisplay = function (idn,disp){
	$(idn).style.display=(disp?'':'none');
}


/*
WaitWindow
*/
xGUI.waitwindow = new Object();
xGUI.waitwindow.image = new Image();
xGUI.waitwindow.image.src = xGUI.dir+'/wait.gif';
xGUI.waitwindow.IsOpen = false;
xGUI.waitwindow.open = function(){
	xGUI.waitwindow.display();
	xGUI.DOM.addEventListener(window,'unload',xGUI.waitwindow.close);
}

xGUI.waitwindow.addWin = function(){
	if(! (e = document.getElementById('xGUI_wwdiv'))){
		e = document.createElement('div');
		e.id = "xGUI_wwdiv";
		if(typeof(xGUI.waitwindow.waitText) == 'undefined'){
			if(typeof(waitText) == 'undefined'){
				xGUI.waitwindow.waitText = "Please wait...";
			}else{
				xGUI.waitwindow.waitText = waitText;
			}
		}
		e.innerHTML = '<table border="0" cellspacing="0" cellpadding="0" id="xGUI_ww" onClick="return false;"><tr><td id="xGUI_loaderContainerH"><div id="xGUI_w"><img src="'+xGUI.waitwindow.image.src+'" alt=""/></div></td></tr></table>';
		e.style.display = 'none';
		document.body.insertBefore(e,document.getElementsByTagName("body")[0].childNodes[0]);
	}
	return e;
}
xGUI.waitwindow.display = function(){
	e = xGUI.waitwindow.addWin();
	xGUI.waitwindow.IsOpen = true;
	e.style.display = '';
	//document.body.disabled = true;
}
xGUI.waitwindow.close = function(){
	if(xGUI.waitwindow.IsOpen == false) return false;
	e = document.getElementById('xGUI_wwdiv');
	e.style.display = 'none';
	document.body.disabled = false;
	document.onmousemove = null;
	//xGUI.waitwindow.IsOpen = false;
}

xGUI.waitwindow.mousemoved = function(ev){
	ev           = ev || window.event;
	if(ev.pageX || ev.pageY){
		var pos = {x:ev.pageX, y:ev.pageY};
	}else{
		var pos = {
			x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
			y:ev.clientY + document.body.scrollTop  - document.body.clientTop
		};
	}
	//	xGUI.debug('x: '+pos.x+', y:'+pos.y);
	e = document.getElementById("xGUI_w");
	//	e.style.top = pos.y+10;
	//	e.style.left = pos.x+10;
}
/*
End of Waitwindow
*/

/*
Event manager
*/

xGUI.EventDispatcher = function(){}
xGUI.EventDispatcher.prototype.listenerGroups = null;
xGUI.EventDispatcher.prototype.dispatchEvent = function (event, args){
	var listo = this.getListByEvent(event);
	if(listo!=null){
		listo.dispatch(args);
	}
}
xGUI.EventDispatcher.prototype.addEventListener = function (event, func){
	if(!this.listenerGroups) this.listenerGroups = new Array();
	var listo = this.getListByEvent(event);
	if(listo==null){
		var listo = new xGUI.EventDispatcher.EventListenerGroup(event);
		this.listenerGroups.push(listo);
	}
	return listo.addListener(func);
}
xGUI.EventDispatcher.prototype.removeEventListener = function (event, func){
	var listo =this.getListByEvent(event);
	if(listo!=null){
		listo.removeListener(func);
	}
}

xGUI.EventDispatcher.prototype.getListByEvent = function(event){
	if(!this.listenerGroups) this.listenerGroups = new Array();
	for(var i=0; i<this.listenerGroups.length; i++){
		if(this.listenerGroups[i].event == event) return this.listenerGroups[i];
	}
	return null;
}


xGUI.EventDispatcher.EventListenerGroup = function(event, func){
	this.event = event;
	this.Listeners = new Array();
	if(func) this.addListener(func);
}
xGUI.EventDispatcher.EventListenerGroup.prototype.event = null;
xGUI.EventDispatcher.EventListenerGroup.prototype.Listeners = null;
xGUI.EventDispatcher.EventListenerGroup.prototype.addListener = function(listener){
	if(typeof(listener)=="string"){
		var listenerStr = listener;
		listener = function(args){eval(listenerStr);}
	}
	var listenerRef = new xGUI.EventDispatcher.EventListenerReference(this, listener);
	this.Listeners.push(listenerRef);
	return listenerRef;
		
}
xGUI.EventDispatcher.EventListenerGroup.prototype.removeListener = function(listener){
	for(var iii=0; iii<this.Listeners.length; iii++){
		if(this.Listeners[iii].callback==listener) this.Listeners.splice(iii,1);
	}
}
xGUI.EventDispatcher.EventListenerGroup.prototype.removeListenerByReference = function(listenerRef){
	for(var iii=0; iii<this.Listeners.length; iii++){
		if(this.Listeners[iii].id==listenerRef.id) this.Listeners.splice(iii,1);
	}
}
xGUI.EventDispatcher.EventListenerGroup.prototype.dispatch = function(args){
	for(var iii=0; iii<this.Listeners.length; iii++){
		this.Listeners[iii].trigger(args);
	}
}


xGUI.EventDispatcher.EventListenerReference = function(g,c){
	this.group = g;
	this.callback = c;
	this.id = ++xGUI.EventDispatcher.EventListenerReference.Counter;
}
xGUI.EventDispatcher.EventListenerReference.Counter = 0;
xGUI.EventDispatcher.EventListenerReference.prototype.enabled = true;
xGUI.EventDispatcher.EventListenerReference.prototype.id = null;
xGUI.EventDispatcher.EventListenerReference.prototype.callback = null;
xGUI.EventDispatcher.EventListenerReference.prototype.trigger = function(args){
	if(this.enabled){
		xGUI.Call(this.callback, args);
	}
}
xGUI.EventDispatcher.EventListenerReference.prototype.Enable = function(){this.enabled=true;}
xGUI.EventDispatcher.EventListenerReference.prototype.Disable = function(){this.enabled=false;}
xGUI.EventDispatcher.EventListenerReference.prototype.Remove = function(){
	this.group.removeListenerByReference(this);
}





xGUI.eventManager = new xGUI.EventDispatcher();
xGUI.eventManager.listenerGroups = new Array();

/* eventListenerGroup */
xGUI.eventManager.eventListenerGroup = function(event, firstListener){
	this.event = event;
	this.Listeners = new Array();
	if(firstListener) this.Listeners[0] = firstListener;
}
xGUI.eventManager.eventListenerGroup.prototype.addListener = function(listener){
	if(typeof(listener)=="string"){
		var listenerStr = listener;
		listener = function(args){eval(listenerStr);}
	}
	this.Listeners.push(listener);
		
}
xGUI.eventManager.eventListenerGroup.prototype.removeListener = function(listener){
	for(var iii=0; iii<this.Listeners.length; iii++){
		if(this.Listeners[iii]==listener) this.Listeners.splice(iii,1);
	}
}
xGUI.eventManager.eventListenerGroup.prototype.dispatch = function(args){
	for(var iii=0; iii<this.Listeners.length; iii++){
		this.Listeners[iii](args);
	}
}
/**/



/*
Event manager EOF
*/

xGUI.Mouse = {}

xGUI.DOM = function(){}
xGUI.Browser = {inited:false}
xGUI.Browser.init = function(){
	if(!xGUI.Browser.inited){
		var b = navigator.userAgent.toLowerCase();
		xGUI.Browser.isSafari= /webkit/.test(b),
		xGUI.Browser.iOpera= /opera/.test(b),
		xGUI.Browser.isIE= /msie/.test(b) && !/opera/.test(b),
		xGUI.Browser.isMozilla= /mozilla/.test(b) && !/(compatible|webkit)/.test(b)
	}
}
xGUI.DOM.isIE = function(){ 
	xGUI.Browser.init();
	return xGUI.Browser.isIE;
}
xGUI.DOM.isSafari = function(){ 
	xGUI.Browser.init();
	return xGUI.Browser.isSafari;
}

xGUI.DOM.addEventListener = function(object, event, listener, iterate, debug){
	if(typeof iterate == 'undefined') array = true;
	listener = xGUI.DOM.formatListener(listener);
	if(
		iterate 
		&& typeof(object) == 'object' 
		&& typeof(object.length) == 'number' 
		&& typeof(object[0]) != 'undefined' 
		&& typeof(object.options)=="undefined"
	){
		//xGUI.console('xGUI.DOM.addEventListener: '+object.length+' long object array');
		for(var i = 0; i < object.length; i++){
			xGUI.DOM.addEventListener(object[i], event, listener);
		}
		//xGUI.DOM.addEventListener(object, event, listener, false);
	}else{
		if(iterate && typeof(event) == 'object' && event instanceof Array){
			for(var i = 0; i < event.length; i++){
				xGUI.DOM.addEventListener(object, event[i], listener);
			}
		}else{
			var id = xGUI.DOM.addEventListener.ListenedObjects.length;
			xGUI.DOM.addEventListener.ListenedObjects.push(object);
			var bridgeFunc = function(e){
				xGUI.DOM.eventListenerHub(e, id);
			}
			if(typeof object.xGUI_eventDispatcher=='undefined'){
				object.xGUI_eventDispatcher = new xGUI.EventDispatcher();
			}
			if(null===object.xGUI_eventDispatcher.getListByEvent(event)){
				if(object.addEventListener){
					object.addEventListener(event, bridgeFunc, false);
				}else if(object.attachEvent){
					object.attachEvent('on'+event, bridgeFunc);
				}else{
					object['on'+event]=bridgeFunc;
				}
			}
			return object.xGUI_eventDispatcher.addEventListener(event, listener);
		}
	}
}

xGUI.DOM.addEventListener.ListenedObjects = new Array();

xGUI.DOM.formatListener=function(listener){
	if(typeof(listener)=="string"){
		var listenerStr = listener;
		listener = function(event){eval(listenerStr);}
	}
	return listener;
}

xGUI.DOM.Event = function(){
	
}
xGUI.DOM.Event.prototype = {
	Type : null,
	Source : null,
	browserEvent : null,
	ListenedSource : null,
	PointerPos : null,
	PointerAbsPos : null
}

xGUI.DOM.eventListenerHub = function(e, listenedId){
	//xGUI.debug(listenedId);
	var eo;
	var ev = new xGUI.DOM.Event();
	if(xGUI.DOM.isIE()){
		eo = window.event;
		ev.Source = eo.srcElement
		if(!ev.Source && (eo.type=='load' || eo.type=='unload' || eo.type=="resize")) ev.Source = window;
	}else{
		eo = e;
		ev.Source = eo.currentTarget
	}
//	if(typeof ev.Source.xGUI_eventDispatcher =='undefined'){
//		xGUI.debug('nyet');
//		return;
//	}else{
//		xGUI.debug('ok: '+eo.type);
//	}
	ev.ListenedSource = xGUI.DOM.addEventListener.ListenedObjects[listenedId];
	ev.browserEvent = eo;
	ev.Type = eo.type;
	ev.PointerPos = {x:eo.clientX, y:eo.clientY};
	
	ev.PointerAbsPos = {x:eo.clientX + xGUI.DOM.Window.getScrollPos().x, y: eo.clientY + xGUI.DOM.Window.getScrollPos().y};
	ev.ListenedSource.xGUI_eventDispatcher.dispatchEvent(ev.Type, ev);
};


xGUI.DOM.show = function(obj, d){
	if(!d) d = "";
	$(obj).style.display=d;
}
xGUI.DOM.hide = function(obj){
	$(obj).style.display="none";
}

xGUI.DOM.visible = function(obj){
	if(!obj.xGUI_DOM_VisibilitySettings) return xGUI.debug("Element Was not invisibalized yet!");
	obj.style.visibility = obj.xGUI_DOM_VisibilitySettings.visibility
	obj.style.width = obj.xGUI_DOM_VisibilitySettings.width
	obj.style.height = obj.xGUI_DOM_VisibilitySettings.height
	if(xGUI.DOM.isIE()){
		obj.style.position = obj.xGUI_DOM_VisibilitySettings.position
	}

	obj.xGUI_DOM_VisibilitySettings = null;
}
xGUI.DOM.invisible = function(obj){
	if(obj.xGUI_DOM_VisibilitySettings) return;
	// saving related states
	obj.xGUI_DOM_VisibilitySettings = {
		visibility: obj.style.visibility,
		position: obj.style.position,
		overflow: obj.style.overflow,
		width: obj.style.width,
		height: obj.style.height,
		clip: obj.style.clip
	}
	obj.style.visibility = "hidden";
	obj.style.width = "0px"
	obj.style.height = "0px";
	if(xGUI.DOM.isIE()){
		obj.style.position = "absolute";
	}
	
}

xGUI.DOM.removeAllChildren=function(obj){
	for(var i=0;i<obj.childNodes.length;i++)obj.removeChild(obj.childNodes[i]);
}

xGUI.DOM.setPosition = function(e, pos){
	e.style.left=String(pos.x)+'px';
	e.style.top=String(pos.y)+'px';
}
xGUI.DOM.getPosition = function(e){
	return {x:xGUI.GetX(e), y:xGUI.GetY(e)};
}
xGUI.DOM.getSize = function(e){
	return {w:e.clientWidth, h:e.clientHeight};
}




//

xGUI.DOM.Window = new Object();
xGUI.DOM.Window.Loaded = false;

xGUI.DOM.Window.IsLoaded = function(){
	return xGUI.DOM.Window.Loaded;
}
xGUI.DOM.Window.setStatusBar = function(str){
	window.status = str;
}
xGUI.DOM.Window._onLoadHandler = function(){
	xGUI.DOM.Window.Loaded=true;
}

xGUI.DOM.Window.CallWhenLoaded =function(func){
	if(xGUI.DOM.Window.IsLoaded()){
		xGUI.Call(func);
	}else{
		xGUI.DOM.addEventListener(window, 'load', func);
	}
}
xGUI.DOM.Window.getScrollPos=function(){
	var re = {x:document.body.scrollLeft, y:document.body.scrollTop};
		if(!re.x){
			re.x = document.body.parentNode.scrollLeft;
		}
		if(!re.y){
			re.y = document.body.parentNode.scrollTop;
		}
	return re;
}
xGUI.DOM.Window.getVisibleSize=function(){
	if(xGUI.DOM.isIE()){
		return {w:document.body.parentNode.offsetWidth, h:document.body.parentNode.offsetHeight};
	}else{
		return {w:window.innerWidth, h:window.innerHeight};
	}
}


xGUI.DOM.Keyboard = new Object();
xGUI.DOM.Keyboard.isCtrl = false; 
xGUI.DOM.Keyboard.isShift = false; 
xGUI.DOM.Keyboard.isAlt = false; 
xGUI.DOM.Keyboard.mainDown = function(e){
	c = e.keyCode || e.which;
	switch(c){
		case 16: xGUI.DOM.Keyboard.isShift = true; break;
		case 17: xGUI.DOM.Keyboard.isCtrl = true; break;
		case 18: xGUI.DOM.Keyboard.isAlt = true; break;
		default:
			xGUI.eventManager.dispatchEvent(xGUI.DOM.Keyboard.geteventname('down', c, {Alt:e.altKey,Ctrl:e.ctrlKey,Shift:e.shiftKey}), e);
	}
	
}
xGUI.DOM.Keyboard.mainUp = function(e){
	c = e.keyCode || e.which;
	switch(c){
		case 16: xGUI.DOM.Keyboard.isShift = false; break;
		case 17: xGUI.DOM.Keyboard.isCtrl = false; break;
		case 18: xGUI.DOM.Keyboard.isAlt = false; break;
		default:
			xGUI.eventManager.dispatchEvent(xGUI.DOM.Keyboard.geteventname('up', c, {Alt:e.altKey,Ctrl:e.ctrlKey,Shift:e.shiftKey}), e);
	}
}

xGUI.DOM.Keyboard.onKeyUp = function(keycode, f, prefix){
	xGUI.DOM.Keyboard.onKey('up', keycode, f, prefix);
}

xGUI.DOM.Keyboard.onKeyDown = function(keycode, f, prefix){
	xGUI.DOM.Keyboard.onKey('down', keycode, f, prefix);
}

xGUI.DOM.Keyboard.onKey = function(event, keycode, f, prefix){
	if(typeof(keycode)=="string") keycode = keycode.charCodeAt();
	prefix = prefix || {Alt:false, Ctrl:false, Shift:false};
	var eventname = "key" + event + keycode + (prefix.Alt?'Alt':'')+ (prefix.Ctrl?'Ctrl':'')+ (prefix.Shift?'Shift':'');
	xGUI.eventManager.addEventListener(xGUI.DOM.Keyboard.geteventname(event, keycode, prefix), f);
}
xGUI.DOM.Keyboard.geteventname = function(event,keycode,prefix){
	return eventname = "key" + event + keycode + (prefix.Alt?'Alt':'')+ (prefix.Ctrl?'Ctrl':'')+ (prefix.Shift?'Shift':'');	
}

xGUI.DOM.setOverflowClipping = function(element) {
	element._overflow = element.style.overflow || 'visible';
	if(element._overflow!='hidden') element.style.overflow = 'hidden';
}

xGUI.DOM.unsetOverflowClipping = function(element) {
	if(element._overflow!='hidden') element.style.overflow = element._overflow;
	element._overflow = null;
}


xGUI.DOM.addEventListener(document, 'keyup', xGUI.DOM.Keyboard.mainUp)
xGUI.DOM.addEventListener(document, 'keydown', xGUI.DOM.Keyboard.mainDown)
xGUI.DOM.addEventListener(window, 'load', xGUI.DOM.Window._onLoadHandler);

/*
Ajax
*/
xGUI.ajax = new Object();

xGUI.ajax.Event = function(appid, event, args, target, async){
	if(typeof async == "string") async = (async=="true"||async=="1")?true:false;
	if(typeof target != "string") target = "server";
	this.appid = appid;
	this.event = event;
	this.args = args;
	this.target = target;
	this.async = async;
}
xGUI.ajax.Event.prototype.appid = null;
xGUI.ajax.Event.prototype.event = null;
xGUI.ajax.Event.prototype.args = new Object();
xGUI.ajax.Event.prototype.target = null;
xGUI.ajax.Event.prototype.async = null;
xGUI.ajax.Event.prototype.isSent = false;
xGUI.ajax.Event.prototype.isSet = false;
xGUI.ajax.Event.prototype.onSend = false;
xGUI.ajax.Event.prototype.set = function (){if(this.isSet)return false; xGUI.ajax.EventQueue.push(this);this.isSet=true; return true;}
xGUI.ajax.Event.prototype.setSent = function (){this.isSent=true; if(this.onSend)this.onSend(this);}
xGUI.ajax.Event.prototype.send = function(){if(!this.isSet)this.set(); return xGUI.ajax.dispatchEvents();}


xGUI.ajax.method = "GET";
xGUI.ajax.commandURL = "xGuax.php?null=null";
xGUI.ajax.httpRequest = null;
xGUI.ajax.container = new Object();
xGUI.ajax.EventQueue = new Array();
xGUI.ajax.textAreasListeningSubmit = new Array();
xGUI.ajax.setEvent = function(appid, event, args, target, async){
	(new xGUI.ajax.Event(appid, event, args, target, async)).set();
}


xGUI.ajax.setLoadingView = function(id){
	var e = $(id);
	e.innerHTML = '<img src="'+xGUI.dir+'loadcircle.gif" align="center" style="margin:auto;" />';
}

xGUI.ajax.dispatchEvents = function(options){
	if(typeof options != "object") options = {};
	var toServerEvents = 0;
	options.Data = new Array();
	options.Data.push("<xml>");
	var async = true;
	var event;
	var i=0;
	while(event = xGUI.ajax.EventQueue.shift()){
		if(event.isSent) continue;
		async = async && event.async;
		if(event.target=="server"){
			options.Data.push("<event"+i+">");
			options.Data.push("<appid>"+encodeURIComponent(event.appid)+"</appid>")	
			options.Data.push("<event>"+encodeURIComponent(event.event)+"</event>")
			options.Data.push("<args>");
			for(var j in event.args){
				if(event.args[j] instanceof Array){
					
				}
				options.Data.push(xGUI.ajax.serializeData(j, event.args[j]));
			}
			options.Data.push("</args>\n</event"+i+">");
			toServerEvents++;
		}else{
			event.args.appid = event.appid;
			event.args.event = event.event;
			xGUI.eventManager.dispatchEvent(/*event.appid, */event.event, event.args);
		}
		event.setSent();
		event = null;
		i++;
	}
	options.Data.push("</xml>");
//	return xGUI.console(options.Data.join("\n"));
	options.Data = ["xGuaxData=",encodeURIComponent(options.Data.join(''))].join('');
	if(options.Data.length>480){
		var method="POST";
	}else{
		var method="GET";
	}
//	xGUI.ajax.EventQueue = new Array();
	if(!toServerEvents) return;
	
	if(typeof(options.async) 		== "undefined") 	options.async = async;
	if(typeof(options.commandURL) 	== "undefined") 	options.commandURL = xGUI.ajax.commandURL;
	if(typeof(options.method)	 	== "undefined") 	options.method = method;
	options.xGuaxResponse = true;
	var request = new xGUI.ajax.Request(options);
	request.send();
	return request;
}

xGUI.ajax.serializeData = function(name, val, attributes){
	var content = new Array();
	if(attributes==undefined)attributes = {};
	if(typeof val == 'object' && val!==null){
		if(val instanceof Array){
			attributes.dataType="array";
			for(var i=0; i<val.length; i++){
				content.push(xGUI.ajax.serializeData('element'+i, val[i], {index:i}));
			}
		}else{
			attributes.dataType="object";
			for(i in val){
				content.push(xGUI.ajax.serializeData(i, val[i]));
			}
		}
	}else{
		content.push(encodeURIComponent(val));
	}
	content.unshift(">");
	for(i in attributes){
		content.unshift([" ",i,"=\"",attributes[i],"\""].join(''));
	}
	content.unshift("<"+name);
	content.push("</"+name+">");
	return content.join('');
}


/**
 * xGUI.ajax.Request class
 */

xGUI.ajax.Request = function(options){
	xGUI.ajax.Request.List.push(this);
	this.id = xGUI.ajax.Request.List.length-1;
	for(i in options) this[i] = options[i];

	try{
		this.httpRequest = new ActiveXObject('Msxml2.XMLHTTP');
	}catch(e){}
	if(!this.httpRequest)try{
		this.httpRequest = new ActiveXObject('Microsoft.XMLHTTP');
	}catch(e){}
	if(!this.httpRequest)try{
		this.httpRequest = new XMLHttpRequest();
	}catch(e){}
	
}
xGUI.ajax.Request.List = new Array();
xGUI.ajax.Request.Error = function(details){
	for(i in details) this[i] = details[i];
}
xGUI.ajax.Request.RunningCounter = 0;
xGUI.ajax.Request.asyncRunningCounter = 0;
xGUI.ajax.Request.syncRunningCounter = 0;
xGUI.ajax.Request.prototype.id=0;
xGUI.ajax.Request.prototype.realSync=false;
xGUI.ajax.Request.prototype.Running=false;
xGUI.ajax.Request.prototype.httpRequest=null;
xGUI.ajax.Request.prototype.url = '';
xGUI.ajax.Request.prototype.commandURL = xGUI.ajax.commandURL;
xGUI.ajax.Request.prototype.xGuaxResponse = false;
xGUI.ajax.Request.prototype.method='post';
xGUI.ajax.Request.prototype.onReadyStateChange = null;
xGUI.ajax.Request.prototype.onComplete = xGUI.fbdbg;
xGUI.ajax.Request.prototype.onError = xGUI.debugMode ? xGUI.debug : xGUI.fbdbg;
xGUI.ajax.Request.prototype.Data = '';
xGUI.ajax.Request.prototype.Timeout = 30;
xGUI.ajax.Request.prototype.TimeoutVariable;

xGUI.ajax.Request.Error.prototype.Code = null;
xGUI.ajax.Request.Error.prototype.Message = null;
xGUI.ajax.Request.Error.prototype.Time = null;
xGUI.ajax.Request.Error.prototype.Status = null;
xGUI.ajax.Request.Error.prototype.readyState = null;
xGUI.ajax.Request.Error.INVALID_RESPONSE = 1;
xGUI.ajax.Request.Error.TIMEOUT = 2;
xGUI.ajax.Request.Error.REQUEST_ERROR = 3;
xGUI.ajax.Request.Error.SERVER_ERROR = 4;
xGUI.ajax.Request.Error.UNKNOWN = 5;
xGUI.ajax.Request.Error.prototype.toString = function(){var re = "";for(i in this) if(i!="toString") re+=i+": "+this[i]+"\n";return re;}



xGUI.ajax.Request.prototype.isRunning = function (){return this.Running;}

xGUI.ajax.Request.prototype.Close = function (){
	
	this.Running = false;
	this.clearTimeout();	
	xGUI.ajax.Request.RunningCounter--;
	if(!this.async){
		xGUI.ajax.Request.syncRunningCounter--;
	}else{
		xGUI.ajax.Request.asyncRunningCounter--;
		document.body.style.cursor="auto"
	}
	if(xGUI.ajax.Request.asyncRunningCounter<1) xGUI.waitwindow.close();
	if(this.httpRequest){
		this.httpRequest.onreadystatechange = xGUI.Nothing;
		//this.httpRequest.abort();
		this.httpRequest = null;
	}
}

xGUI.ajax.Request.prototype.Cancel = function(){
	if(this.Running){
		xGUI.console("Cancelling request...");
		//this.httpRequest.abort();
		this.Close();
	}else{
		xGUI.console("Request was already closed.");
	}
}

xGUI.ajax.Request.prototype.clearTimeout = function(){
	clearTimeout(this.TimeoutVariable);
}

xGUI.ajax.Request.prototype.Complete = function (){
	this.clearTimeout();
	if(typeof this.onComplete == "function") this.onComplete(this);
	else if(typeof this.onComplete == "string") eval(this.onComplete);
	this.Close();
}

xGUI.ajax.Request.prototype.Error = function (Error, Close){
	Error.Time = (new Date).getTime();
	try{
		Error.Status = this.httpRequest.status;
		Error.readyState = this.httpRequest.readyState;
	}catch(e){}
	
	if(Close){
		xGUI.ajax.Request.prototype.onComplete = null;
		this.Close();
	}
	if(typeof this.onError == "function") this.onError(Error);
	else if(typeof this.onError== "string") eval(this.onError);
}

xGUI.ajax.Request.prototype.send = function (data){
	if(typeof data != "undefined") this.Data = data;
	if(this.Data.length > 480){
		this.method="POST";
	}
	xGUI.ajax.Request.RunningCounter++;
	if(!this.async){
		xGUI.ajax.Request.syncRunningCounter++;
		xGUI.waitwindow.open();
	}else{
		xGUI.ajax.Request.asyncRunningCounter++;
		document.body.style.cursor="wait"
	}
	this.Running = true;
	var e="xGUI.ajax.Request.List["+this.id+"].handleEvent()";
	this.httpRequest.onreadystatechange = function () {eval(e)};
	
	var url = this.commandURL;
	if(this.url.length) url = this.url;
	
	if(url.indexOf('?')==-1) url +='?';
	if(this.method.toUpperCase()=="POST"){
		this.httpRequest.open("POST", url+"&__="+Math.ceil(Math.random()*999999999)+Math.ceil(Math.random()*999999999), !this.realSync);
	}else{
		this.httpRequest.open("GET", url+"&"+this.Data, !this.realSync);
	}
	this.httpRequest.setRequestHeader('Referer', location.href);
	if(this.method.toUpperCase()=="POST") this.httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	this.httpRequest.setRequestHeader("Connection", "close");

	this.TimeoutVariable = setTimeout("xGUI.ajax.Request.List["+this.id+"].TimedOut()", this.Timeout*1000);
	if(this.method.toUpperCase()=="POST"){
		this.httpRequest.send(this.Data);
	}else{
		this.httpRequest.send(null);
	}
	if(this.realSync && this.Running) this.handleEvent();
}

xGUI.ajax.Request.prototype.TimedOut = function(){
	this.Error(new xGUI.ajax.Request.Error({Code:xGUI.ajax.Request.Error.TIMEOUT, Message:"Request has timed out ("+String(this.Timeout)+" seconds)!"}), true);
}

xGUI.ajax.Request.prototype.statusError = function(s){
	var e = new xGUI.ajax.Request.Error({Message: new String(s)+": " + this.httpRequest.responseText});
	if(s>=400 && s<500){
		e.Code = xGUI.ajax.Request.Error.REQUEST_ERROR;
	}else if(s>=500 && s<600){
		e.Code = xGUI.ajax.Request.Error.SERVER_ERROR;
	}
	this.Error(e, true);
}

xGUI.ajax.Request.prototype.getResponseText = function(){
	return this.httpRequest.responseText;
}
	

xGUI.ajax.Request.prototype.handleEvent = function(){
//	try{xGUI.debug([this.httpRequest.readyState,this.httpRequest.status, this.isRunning()]);}catch(e){}
	if(!this.isRunning()) return;
	switch(this.httpRequest.readyState){
		case 2:
			try{
				if(this.httpRequest.status!=200){
//					xGUI.debug("Error! Status:"+this.httpRequest.status);
					this.statusError(this.httpRequest.status)
				}
			}catch(e){}
		break;
		case 4:
			try{
				if(this.httpRequest.status==200){
					try{
						if(this.xGuaxResponse){
							if(!this.httpRequest.responseXML || !this.httpRequest.responseXML.childNodes[0] || !this.httpRequest.responseXML.childNodes[0].childNodes){
								return this.Error(new xGUI.ajax.Request.Error({Code:xGUI.ajax.Request.Error.INVALID_RESPONSE, Message:this.httpRequest.responseText}), true);
							}else{
								response = this.httpRequest.responseXML.childNodes[0];
								for(var i=0;i<response.childNodes.length;i++){
									argsxml = response.childNodes[i].getElementsByTagName("args")[0];
									if(null==argsxml) return alert("this.Error: Invalid response ("+i+")");
									args = new Object();
									for(var j=0;j<argsxml.childNodes.length; j++){
										args[argsxml.childNodes[j].nodeName] = ""
										if(argsxml.childNodes[j].childNodes.length){
											for(var k=0; k<argsxml.childNodes[j].childNodes.length; k++) args[argsxml.childNodes[j].nodeName] += argsxml.childNodes[j].childNodes[k].nodeValue;
										}
									}
									args.appid = response.childNodes[i].getElementsByTagName("appid")[0].firstChild.nodeValue;
									args.event = response.childNodes[i].getElementsByTagName("event")[0].firstChild.nodeValue;
									try{
										xGUI.eventManager.dispatchEvent(args.event, args);
									}catch(e){
										xGUI.fbdbg(e)
										xGUI.debug(e);
										this.Error(new xGUI.ajax.Request.Error({Code:xGUI.ajax.Request.Error.UNKNOWN, Message:'Error while dispatching event received from the server!', Event:args.event, Exception:e}), false);
									}
								}
							}
						}
						this.Complete();
					
					}catch(e){
						xGUI.fbdbg(e)
						xGUI.debug(e);
						this.Error(new xGUI.ajax.Request.Error({Code:xGUI.ajax.Request.Error.UNKNOWN, Message:'Error while parsing response. '+e.message, Exception:e}), true);
						throw e;
					}
				}else{
					this.httpRequest.abort();
					this.statusError(this.httpRequest.status)
				}
			}catch(e){}
		break;
	}
}

xGUI.ajax.extractScripts = function(txt) {
	var matchAll = new RegExp('<script[^>]*>([\\S\\s]*?)<\/script>', 'img');
	var matchOne = new RegExp('<script[^>]*>([\\S\\s]*?)<\/script>', 'im');
	var matchSrc = new RegExp('(?:<script.*src="(.*)".*?>)([\\S\\s]*?)(?:<\/script>)', 'im');
	var matches = txt.match(matchAll) || [];
	for(var i=0;i<matches.length;i++){
		var tmp = matches[i];
		matches[i] = (matches[i].match(matchOne) || ['', ''])[1];
		if(!matches[i].length){
			var srcm = tmp.match(matchSrc);
			if(srcm[1]) xGUI.LoadScript(srcm[1]);
		}
	}
	return matches;
	return (txt.match(matchAll) || []).map(function(scriptTag) {
		return (scriptTag.match(matchOne) || ['', ''])[1];
	});
}


xGUI.ajax.evalScripts = function(___html) {
	var ____scripts = xGUI.ajax.extractScripts(___html);
	var ____errors = new Array();
	for(var _____iiiiii=0;_____iiiiii<____scripts.length;_____iiiiii++){
		try{
			//eval(____scripts[_____iiiiii]); 
			xGUI.globalEvalScript(____scripts[_____iiiiii]);
		}catch(___c){
//			c.message = 'Error while evaluating script: '+c.message+"\nin script:\n"+scripts[i];
			xGUI.fbdbg(___c);
			____errors.push(new xGUI.ajax.Request.Error({Code:xGUI.ajax.Request.Error.UNKNOWN, Message:'Error while evaluating script: '+___c.message, Exception:___c, Script:____scripts}));
		}
	}
	if(____errors.length){
		throw(____errors);
	}
}



xGUI.ajax.container = new Object();
xGUI.ajax.container.use = function(appid, containerid, args){
	ident = appid+'.'+containerid;
	e = document.getElementById(ident);
	if(!e){
		document.write(xGUI.ajax.container.generateHtml(appid, containerid, args));
	}
//	alert(xGUI.ajax.container.generateHtml(appid, containerid, args));
}
xGUI.ajax.container.generateHtml = function(appid, containerid, args){
	return '<div id="'+appid+'.'+containerid+'" class="xGuax'+(args["float"]?'FloatingContainer':'Container')+'"'+(args.display?'':' style="display:none;"')+'>'+args.content+'</div>';
}
xGUI.ajax.container.build = function (args){
	var html = xGUI.ajax.container.generateHtml(args.appid, args.id, args);
	if(typeof args.div == "undefined") args.div = "";
	if(!args.div.length){
		var e = document.createElement("div");
		e.innerHTML = html;
		document.getElementsByTagName("body")[0].appendChild(e);
		new xGUI.DOM.Panel(e);
	}else if(args.div=="_inline"){
		document.write(html);
	}else{
		if(di = $(args.div)){
			new xGUI.DOM.Panel(di);
			di.innerHTML = html;
		}else{
			document.write(html);
		}
	}
}

xGUI.ajax.RerouteLinks = {};

xGUI.ajax.RerouteLinks.ReroutedElements = new Array();

xGUI.ajax.RerouteLinks.apply = function(id, opt){
	xGUI.firedebug("Rerouting "+id+"...");
	var e = $(id);
	for(i in xGUI.ajax.RerouteLinks.DefaultsOptions){
		if(typeof(opt[i])=="undefined"){
			opt[i]=xGUI.ajax.RerouteLinks.DefaultsOptions[i];
		}
	}
	
	// getting url to detect external urls
	var loc = new String(location);
	var domain = loc.substr(loc.indexOf('://')+3);
	domain = domain.substr(0, domain.indexOf('/'));
	
	e.AjaxReroute = xGUI.ajax.RerouteLinks.Rerouter;
	e.event = opt.event;
	e.appid = opt.appid;
	
	var Anchors = e.getElementsByTagName("a");
	var Forms = e.getElementsByTagName("form");
	
	for(var i = 0;i<Anchors.length; i++){
		var h = Anchors[i].href;
		var external = false;
		var javascriptOrInpageAnchor = false;
		if(!opt.rerouteExternalUrls){
			var perprepos = 0;
			if( (perprepos=h.indexOf('://')) !== -1){
				var hdomain = h.substr(perprepos+3);
				hdomain = hdomain.substr(0, hdomain.indexOf('/'));
				external = (hdomain!=domain);
				if(external)xGUI.firedebug('Reroute domain check: we are on '+ domain + ' and moving to '+hdomain);
			}
		}
		if(h.indexOf("javascript:")===0 || !h.length/*&& h.indexOf("location")===-1*/){
			javascriptOrInpageAnchor = true;
		}
		if(h.indexOf("#")===0){
			javascriptOrInpageAnchor = true;
		}

		if(!external && !javascriptOrInpageAnchor ){
			var eid = xGUI.ajax.RerouteLinks.ReroutedElements.length;
			xGUI.ajax.RerouteLinks.ReroutedElements[eid] = Anchors[i]
			xGUI.DOM.addEventListener(Anchors[i], 'mouseover', "xGUI.DOM.Window.setStatusBar('"+h+"')");
			xGUI.DOM.addEventListener(Anchors[i], 'mouseout', "xGUI.DOM.Window.setStatusBar('')");
			xGUI.DOM.addEventListener(Anchors[i], 'click', "$('"+id+"').AjaxReroute(xGUI.ajax.RerouteLinks.ReroutedElements["+eid+"])");
			Anchors[i]._href = h;
			Anchors[i].href = "javascript:;";
			xGUI.firedebug('Rerouting href: '+h)
		}
	}
	
//	$onsubmit='return xGUI.ajax.onSubmitForm("'.$e->appid.'","'.$gui->getFullFormID().'", "'.$gui->taskvar.'", '.(ifset($options['async'], ifset($options['onchange'], false, false), false )?'true':'false').')';
	
	for(var i = 0;i<Forms.length; i++){
		if(Forms[i].enctype!="multipart/form-data" || !xGUI.ajax.RerouteLinks.hasFileElement(Forms[i])){
			var eid = xGUI.ajax.RerouteLinks.ReroutedElements.length;
			// if no id
			if(!Forms[i].id) Forms[i].id='ReroutedForme'+eid;
			xGUI.ajax.RerouteLinks.ReroutedElements[eid] = Forms[i]
			Forms[i]._ReroutedElementsID;
			Forms[i]._ReroutedAppId=opt.appid;
			Forms[i]._RerouteScript = "xGUI.console('submitting'); xGUI.ajax.onSubmitForm(this._ReroutedAppId,this.id, 'action', false);";
//			Forms[i].onsubmit = "eval(this._RerouteScript) ; return false;"
//			Forms[i].onSubmit = "eval(this._RerouteScript) ; return false;"
			Forms[i].onsubmit = Forms[i].submit = function(){
				eval(this._RerouteScript)
				return false;
			}
			xGUI.firedebug('Rerouting form: '+Forms[i].id)
		}
	}
}

xGUI.ajax.RerouteLinks.hasFileElement = function (form){
	var ls = form.getElementsByTagName('input');
	for(var i=0; i< ls.length; i++){
		if(ls[i].type=="file")return true;
	}
	return false;
}

xGUI.ajax.RerouteLinks.DefaultsOptions = {event:"Link", rerouteExternalUrls:0};

xGUI.ajax.RerouteLinks.Rerouter = function(e){
	// "this" points to the rerouted container which received the event details in this case 
//	for(i in e) xGUI.debug(i+": "+e[i]);
	switch(e.tagName.toLowerCase()){
		case "a":
			(new xGUI.ajax.Event(this.appid, this.event, {url:e._href}, "server")).send();
		break;
	}
}


xGUI.ajax.CollectElementInputs = function(eid, appid){
	var e = document.getElementById(eid);
	if(!e){
		e = document.getElementById(appid+'.'+eid);
		if(!e) return;
	}
	var i=0;
	var vs= new Array();
	var is = e.getElementsByTagName("input");
	var ss = e.getElementsByTagName("select");
	var ts = e.getElementsByTagName("textarea");
	for(var i=0; i<is.length; i++){
		switch(is[i].type){
			case 'radio':
			case 'checkbox':
				if(!is[i].checked) continue;
			case 'text':
			case 'password':
			default:
				vs.push(encodeURIComponent(is[i].name)+"="+encodeURIComponent(is[i].value));
			case 'hidden':
				if(typeof FCKeditorAPI != 'undefined' && !(typeof FCKeditorAPI.GetInstance(is[i].name)=='undefined')){
					vs.push(encodeURIComponent(is[i].name)+"="+encodeURIComponent(FCKeditorAPI.GetInstance(is[i].name).GetXHTML()));
				}else{
					vs.push(encodeURIComponent(is[i].name)+"="+encodeURIComponent(is[i].value));
				}
			break;
		}
		//xGUI.debug([is[i].name, is[i].tagName, is[i].value]);
		
	}
	for(var i=0; i<ts.length; i++){
		vs.push(encodeURIComponent(ts[i].name)+"="+encodeURIComponent(ts[i].value));
	}
	
	for(var i=0; i<ss.length; i++){
		var iname = encodeURIComponent(ss[i].name);
		if(ss[i].multiple){
			for(var j=0; j<ss[i].options.length; j++){
				if(ss[i].options[j].selected) {
					vs.push(iname+"="+encodeURIComponent(ss[i].options[j].value));
				}
			}
		}else{
			vs.push(iname+"="+encodeURIComponent(ss[i].value));
		}
	}
	return "#serialized#"+vs.join('&');
}

xGUI.ajax.getInputValue = function (e){
	
}
xGUI.ajax.formOnChangeSubmit = function (formID){
	var e = $(formID);
	var f = e.submit;
	var l = new Array();
	
	l[0] = e.getElementsByTagName("input");
	l[1] = e.getElementsByTagName("select");
	l[2] = e.getElementsByTagName("textarea");
	for(var j=0;j<3;j++) for(var i=0; i<l[j].length; i++){
			if(j==2){
				xGUI.DOM.addEventListener(l[j][i], 'blur',  f);
			}else{
				if(document.all && j==0 && l[j][i].type=="checkbox"){
					xGUI.DOM.addEventListener(l[j][i], 'click',  "this.checked=!this.checked; $('"+formID+"').submit()");
				}else{
					xGUI.DOM.addEventListener(l[j][i], 'change',  f);
				}
			}
			xGUI.ajax.textAreasListeningSubmit.push({name:l[j][i].name, call:f});
		}	
}
xGUI.ajax.fromOnChangeSubmit_FCKeditorEvent = function(e){
	if(e.HasFocus){
		e.previousContent = e.GetXHTML();
	}else if(e.previousContent != e.GetXHTML()){
		e.ajaxOnChangeCall();
	}
}

function FCKeditor_OnComplete( editor )
{
//	for(i in editor) xGUI.debug(i+":"+editor[i]);
	if(xGUI.ajax.commandURL.indexOf('/')==-1){
		xGUI.ajax.commandURL = location.href.substr(0, location.href.lastIndexOf('/')+1) + xGUI.ajax.commandURL;
		
	}
	var e = xGUI.ajax.textAreasListeningSubmit;
	var call = xGUI.ajax.fromOnChangeSubmit_FCKeditorEvent;
	for(var i=0; i<e.length; i++){
		if(e[i].name==editor.Name){
			editor.Config.StartupFocus = false;
			editor.ajaxOnChangeCall = e[i].call;
			editor.previousContent = editor.GetXHTML();
			editor.Events.AttachEvent( 'OnBlur', call ) ;
			editor.Events.AttachEvent( 'OnFocus', call ) ;
		}
	}
}
xGUI.ajax.onSubmitForm = function(appid, formID, taskVar, async){
	f = $(formID);
	if(!f) return false;
	var action;
	if(typeof(f.action)=='string'){
		action = f.action;
	}else{
		action = f.attributes.getNamedItem('action').nodeValue;
	}
	if(typeof action =='object'){
		throw('Form action is came out to be an object!');
	}
	var event = new xGUI.ajax.Event(appid, 'submit', {"__args":xGUI.ajax.CollectElementInputs(formID, appid),"formAction":action}, "server", async);
	event.send();
	return false;
}
xGUI.ajax.KeepAlive = function(){
	setTimeout("xGUI.ajax.KeepAlivePing()", 300000);
}
xGUI.ajax.KeepAlivePing = function(){
	var e = new xGUI.ajax.Event('any', 'ping', {}, "server", true);
	e.send();
	xGUI.ajax.KeepAlive();
}

xGUI.ajax.container.eventHandler = function(args){
	ident = args.appid+'.'+args.id;
	e = document.getElementById(ident);
	
	if(e){
		switch(args.event){
			case "container.update":
			case "container.replace":
				if(typeof(e.xGUI_DOM_Panel) !="undefined"){
					e.xGUI_DOM_Panel.setContent(args.content);
					e.xGUI_DOM_Panel.Reposition();
				}else{
					e.innerHTML=args.content;
					xGUI.ajax.evalScripts(args.content);
				}
			//setTimeout("xGUI.ajax.evalScripts(window.x)", 100);
//			e.innerHTML="";
//			sub = document.createElement('div');
//			sub.innerHTML = args.content;
//			e.appendChild(sub);
			break;
			case "container.append":
			e.innerHTML += args.content;
			break;
			case "container.show":
				if(typeof(e.xGUI_DOM_Panel) !="undefined"){
					e.xGUI_DOM_Panel.Show();
				}else{
					e.style.display="";
				}
			break;
			case "container.hide":
				if(typeof(e.xGUI_DOM_Panel) !="undefined"){
					e.xGUI_DOM_Panel.Close();
				}else{
					e.style.display="none";
				}			
			break;
			case "container.build":
				args.div = ident;
				xGUI.ajax.container.build(args);
				if(args.display) e.style.display="";
				else e.style.display="none";
			break;
			default:
			throw Exception("Invalid event");
			break;
		}
	}else{
		switch(args.event){
			case "container.build":
				xGUI.ajax.container.build(args);
			break;
		}
	}
}
xGUI.ajax.divEventHandler = function (args){
	e = $(args.id);
	if(e){
		switch(args.event){
			case "div.update":
			case "div.replace":
			if(args.parent=="1"){
				e.parentNode.innerHTML = args.content;
			}else{
				e.innerHTML=args.content;
			}
			break;
			case "div.append":
			e.innerHTML += args.content;
			break;
			case "div.show":
			e.style.display="";
			break;
			case "div.hide":
			e.style.display="none";
			break;
			default:
			throw Exception("Invalid event");
			break;
		}
	}else{
		xGUI.debug({Message:"DIV "+args.id+" not found"});
	}
}
xGUI.ajax.coreEvents = new Object();
xGUI.ajax.coreEvents.alert = function (args){
	alert(args.msg);
}
xGUI.ajax.coreEvents.debug = function (args){
	xGUI.debug(args.msg);
}
xGUI.ajax.coreEvents.flashLine = function (args){
	xGUI.flashLine(args.msg);
}
xGUI.ajax.coreEvents.eval = function (args){
	eval(args.code);
}



/* core event listeners */
xGUI.eventManager.addEventListener('alert',xGUI.ajax.coreEvents.alert);
xGUI.eventManager.addEventListener('debug',xGUI.ajax.coreEvents.debug);
xGUI.eventManager.addEventListener('flashLine',xGUI.ajax.coreEvents.flashLine);
xGUI.eventManager.addEventListener('eval',xGUI.ajax.coreEvents.eval);
xGUI.eventManager.addEventListener('container.update', xGUI.ajax.container.eventHandler);
xGUI.eventManager.addEventListener('container.replace', xGUI.ajax.container.eventHandler);
xGUI.eventManager.addEventListener('container.append', xGUI.ajax.container.eventHandler);
xGUI.eventManager.addEventListener('container.show', xGUI.ajax.container.eventHandler);
xGUI.eventManager.addEventListener('container.hide', xGUI.ajax.container.eventHandler);
xGUI.eventManager.addEventListener('container.build', xGUI.ajax.container.eventHandler);
xGUI.eventManager.addEventListener('div.update', xGUI.ajax.divEventHandler);
xGUI.eventManager.addEventListener('div.replace', xGUI.ajax.divEventHandler);
xGUI.eventManager.addEventListener('div.append', xGUI.ajax.divEventHandler);
xGUI.eventManager.addEventListener('div.show', xGUI.ajax.divEventHandler);
xGUI.eventManager.addEventListener('div.hide', xGUI.ajax.divEventHandler);


xGUI.ajax.iFrameSubmit = function(Form, onComplete){
	this.id = xGUI.ajax.iFrameSubmit.List.length;
	xGUI.ajax.iFrameSubmit.List.push(this);
	this.Form = $(Form);
	if(onComplete!=undefined){
		this.addEventListener('onComplete', onComplete);
	}
	xGUI.DOM.Window.CallWhenLoaded([this,'setup']);
}
xGUI.ajax.iFrameSubmit.List = new Array();
xGUI.ajax.iFrameSubmit.prototype = xGUI.extend(new xGUI.EventDispatcher(),
{
	id : null,
	Form : null,
	iFrame : null,
	aimed : false,
	setup : function(){
		var name = 'xGUI_ajax_iFrameSubmit'+String(this.id);
		var d = document.createElement('div');
		d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+name+'" name="'+name+'"></iframe>';
		document.body.appendChild(d);
		this.iFrame = $(name);
		/*
		this.iFrame = document.createElement('iframe');
		this.iFrame.style.display='none';
		this.iFrame.src="about:blank";
		this.iFrame.name = this.iFrame.id='xGUI_ajax_iFrameSubmit'+String(this.id);
		document.body.appendChild(this.iFrame);
		*/
		xGUI.DOM.addEventListener(this.Form, 'submit', [this, 'formSubmit']);
		xGUI.DOM.addEventListener(this.iFrame, 'load', [this, 'completed']);
		this.Form.setAttribute('target', this.iFrame.name);
		
	},
	formSubmit : function(){
		this.log('iframe submit...');
		this.aimed = true;
		this.dispatchEvent('onSubmit', this);
	},
	completed : function(){
		if(!this.aimed) return;
		this.log('iframe submittal completed');
		this.dispatchEvent('onComplete', this);
	},
	getResultBody : function(){
		if (this.iFrame.contentDocument) {
			d = this.iFrame.contentDocument;
		} else if (this.iFrame.contentWindow) {
			d = this.iFrame.contentWindow.document;
		} else {
			d = window.frames[this.iFrame.id].document;
		}
		return d.body;
	},
	log : function(d){
		xGUI.console(d);
	}
}
);

/*
Ajax EOF
*/


/*
SelectSeach
*/
xGUI.selectSearch = function(q, eIdOrName){
	e = document.getElementById(eIdOrName);
	if(!e) e = document.getElementsByName(eIdOrName)[0];
	if(!e) return;
	txt = q.value.toLowerCase();
	for(i=0; i<e.options.length; i++){
		if(e.options[i].text.toLowerCase().indexOf(txt) != -1){
			e.value = e.options[i].value;
			e.onchange();
			return;
		}
	}
}

xGUI.dateField = new xGUI.EventDispatcher();

xGUI.dateField.addDateListener = function(name, event, listener){
	if(typeof name =='object') name = name.name;
	xGUI.dateField.addEventListener(name+event, listener);
}

xGUI.dateField.loadJSCalendar = function(){
	xGUI.syncLoadJavascript(xGUI.dir+"/jscalendar/calendar.js", true);
	xGUI.syncLoadJavascript(xGUI.dir+"/jscalendar/lang/calendar-hu.js", true);
	xGUI.syncLoadJavascript(xGUI.dir+"/jscalendar/calendar-setup.js", true);
}
xGUI.dateField.formats = new Object();
xGUI.dateField.setByPart=function (e){
	xGUI.dateField.loadJSCalendar();
	var id=e.name.substr(2);
	var d = new Date();
	var p;
	if(p=$f('Y_'+id)[0]) d.setFullYear(parseInt(p.value));
	if(p=$f('m_'+id)[0]){
		var val = p.value;
		if(val.substr(0,1)=="0") val = val.substr(1);
		d.setMonth(parseInt(val)-1);
		xGUI.dateField.setDays(p);
	}
	if(p=$f('d_'+id)[0]){
		var val = p.value;
		if(val.substr(0,1)=="0") val = val.substr(1);
		d.setDate(parseInt(val));
	}
	if(p=$f('H_'+id)[0]){
		var val = p.value;
		if(val.substr(0,1)=="0") val = val.substr(1);
		d.setHours(parseInt(val));
	}
	if(p=$f('M_'+id)[0]){
		var val = p.value;
		if(val.substr(0,1)=="0") val = val.substr(1);
		d.setMinutes(parseInt(val));
	}
	var formatName = id.split('[').join('_').split(']').join('_');
	var HtmlE = $f(id)[0];
	var oldVal = HtmlE.value;
	HtmlE.value = d.print(xGUI.dateField.formats[formatName]);
	if(oldVal!=HtmlE.value){
		xGUI.dateField.changed ( HtmlE);
	}
}

xGUI.dateField.changed = function (e){
	xGUI.dateField.dispatchEvent('change', e);
	xGUI.dateField.dispatchEvent(e.name+'change', e);
	
}
xGUI.dateField.setDays = function(e){
	if(typeof (e) =='undefined') return;
	var id=e.name.substr(2);
	var dayList = $f('d_'+id)[0];
	var yearList = $f('Y_'+id)[0];
	var isLeapYear = false;
	if(!(dayList) || dayList.tagName != 'SELECT'){
		return;
	}
	if(yearList){
		isLeapYear = !(yearList.value % 4);
	}
	var monthlengths = [31,isLeapYear?29:28,31,30,31,30,31,31,30,31,30,31];
	var monthlength = monthlengths[e.value-1];
	for(var i=0; i<dayList.childNodes.length; i++){
		dayList.childNodes[i].style.display = (parseInt(dayList.childNodes[i].value) <= monthlength ? "" : "none");
		dayList.childNodes[i].disabled = dayList.childNodes[i].value > monthlength;
	}
	if(dayList.value>monthlength) dayList.value = monthlength;
}


xGUI.map = function(i){
	if(typeof(xGUI.Local.maps[i]) == "undefined") return i;
	else return xGUI.Local.maps[i][( xGUI.Local.maps[i].length - 1 )];
}
xGUI.Local = new Object();
xGUI.lang = "en";
if(typeof(xGUI.loadLang)=="undefined"){
	xGUI.loadLang = false;
}
xGUI.Local.maps = new Object();
xGUI.Local.set=function(list){
	for(i in list){
		if(typeof(xGUI.Local.maps[i]) == "undefined") xGUI.Local.maps[i] = new Array();
		xGUI.Local.maps[i][xGUI.Local.maps[i].length]=list[i];
	}
}
xGUI.Local.load=function(l){
	xGUI.LoadScript(xGUI.dir+'/map/'+l);
}

if(typeof xGUIlang != 'undefined' && xGUIlang!=xGUI.lang){
	xGUI.lang = xGUIlang
}
xGUI.Local.loadDefault = function(){
	xGUI.Local.load(xGUI.lang);
}
if(xGUI.loadLang){
	xGUI.DOM.addEventListener(window, 'load', xGUI.Local.loadDefault);
}

xGUI.FileUploader = function(uploader){
	this.identifier = uploader;
	this.CompleteEvent = new xGUI.eventManager.eventListenerGroup()
	this.ErrorEvent = new xGUI.eventManager.eventListenerGroup()
}
xGUI.FileUploader.prototype.identifier = null;
xGUI.FileUploader.prototype.CompleteEvent = null;
xGUI.FileUploader.prototype.ErrorEvent = null;

xGUI.commonJSLoaded = true;


xGUI.FileUploader.Uploaders = {};
xGUI.FileUploader.CleanId = function(uploader){
	(new Array('[',']', '.')).map(function(e){uploader=uploader.split(e).join(e);});
	return uploader;
}
xGUI.FileUploader.RegisterUploader = function(uploader){
	var safeuploader = xGUI.FileUploader.CleanId(uploader);
	xGUI.FileUploader.Uploaders[safeuploader] = new xGUI.FileUploader(uploader);
	return xGUI.FileUploader.Uploaders[safeuploader];
}
xGUI.FileUploader.IsUploaderRegistered = function(uploader){
	return typeof(xGUI.FileUploader.Uploaders[xGUI.FileUploader.CleanId(uploader)]) != "undefined";
}
xGUI.FileUploader.onComplete = function(uploader){
	if(!xGUI.FileUploader.IsUploaderRegistered(uploader)) return;
	xGUI.FileUploader.Uploaders[xGUI.FileUploader.CleanId(uploader)].CompleteEvent.dispatch();
}
xGUI.FileUploader.onError = function(uploader){
	if(!xGUI.FileUploader.IsUploaderRegistered(uploader)) return;
	xGUI.FileUploader.Uploaders[xGUI.FileUploader.CleanId(uploader)].ErrorEvent.dispatch();
}



xGUI.itemList = function(id, args){
	this.id=id
	if(typeof(args)!="object") args = {};
		for(i in args) this[i] = args[i];
}
xGUI.itemList.prototype.id=null;

xGUI.itemList.getItemList = function(){}

xGUI.itemList.getSelected = function(listid){
	var l = $f(listid+"selected");
	if(!l) l = $f(listid+"selected[]");
	if(!l) return null;
	for(var i=0;i<l.length;i++){
		if(l[i].checked) return l[i].value;
	}
	return null;
}
xGUI.itemList.SubRowEvents = new Object();
xGUI.itemList.SubRowStates = new Object();
xGUI.itemList.showhideSubRow = function (prefix, subrow, id, closeOthers){
	pp=prefix+"subrow"+subrow+'_';
//	if(!xGUI.itemList.SubRowStates[prefix]) xGUI.itemList.SubRowStates[prefix] = new Object();
//	if(!xGUI.itemList.SubRowStates[prefix][subrow]) xGUI.itemList.SubRowStates[prefix][subrow] = new Object();
	
	if(!xGUI.itemList.SubRowStates[prefix][subrow][id]) xGUI.itemList.SubRowStates[prefix][subrow][id] = false;
	var state = xGUI.itemList.SubRowStates[prefix][subrow][id];

	if(closeOthers && !xGUI.itemList.SubRowStates[prefix][subrow][id]) for(i in xGUI.itemList.SubRowStates[prefix][subrow]) if(xGUI.itemList.SubRowStates[prefix][subrow][i]) xGUI.itemList.showhideSubRow(prefix, subrow, i);
	
	if(!xGUI.itemList.SubRowStates[prefix][subrow][id] && xGUI.itemList.SubRowEvents['init'+prefix]) xGUI.itemList.SubRowEvents['init'+prefix](id);
	xGUI.setDisplay(pp+id, xx=xGUI.itemList.SubRowStates[prefix][subrow][id] = !xGUI.itemList.SubRowStates[prefix][subrow][id]);
	if(!xGUI.itemList.SubRowStates[prefix][subrow][id] && xGUI.itemList.SubRowEvents['close'+prefix]) xGUI.itemList.SubRowEvents['close'+prefix](id);
}
xGUI.itemList.check = function (vp, id){
	if( (typeof(xGUI.itemList["recordSelect_"+vp])=="undefined") || !xGUI.itemList["recordSelect_"+vp]){
		var chkdid = "record_"+vp+"_"+id;
		xGUIrowrecord=$(chkdid);
		if(xGUIrowrecord.type=="checkbox" && xGUI.DOM.Keyboard.isShift){
			var t1, t2;
			var clickUsed = false;
			var chkUsed = false;
			var starti=null, endi, fi=null, li, ci;
			var pre = ("record_"+vp);
			var prelen = pre.length;
			var el = $(vp+"itemList").getElementsByTagName('input');
			endi = el.length
			for(var i = 0; i<el.length;i++) if(el[i].id.substr(0,prelen)!=pre) el.splice(i);
			for(var i = 0; i<el.length;i++){
				if(el[i].checked){
					if(fi===null) fi=i;
					li = i;
				}
				if(el[i].id==chkdid) ci = i;
			}
			if(fi===null)fi=0;
			if(ci<fi){
				starti = ci;
				endi = li+1;
			}else if(ci==fi){
				starti = endi = ci;
			}else{
				starti = fi;
				endi = ci+1;
			}
			for(i = 0;i<starti;i++)el[i].checked=false;
			for(i = starti;i<endi;i++)el[i].checked=true;
			for(i = endi;i<el.length;i++)el[i].checked=false;
		}else{
			xGUIrowrecord.checked = !xGUIrowrecord.checked;
		}
	}else{
		xGUI.itemList["recordSelect_"+vp]=false;
	}
}




document.xGUI = xGUI;

}
