/* GUIFW v1.1 - Copyright 2011., Dean Martinis */

var guifw = new Object();


guifw.eid = function(i_name) {
	if (i_name != undefined && i_name != null && i_name != "") {
		var t_obj = document.getElementById(i_name);
		if (t_obj != undefined && t_obj != null) return t_obj;
	}
	return null;
}

guifw.defaultskinpath = function() {
	return "img/core/";
}

guifw.iefixneed = function() {
	var u_agent = navigator.userAgent;
	if ((u_agent.indexOf("MSIE") != -1) && (u_agent.indexOf("Opera") == -1)) return true;
	return false;
}

guifw.browsersize = function() {
	var i_screen = {clientHeight:0, clientWidth:0, scrollHeight:0, scrollWidth:0, scrollLeft:0, scrollTop:0};
	if (window.innerWidth && window.innerHeight) {
		i_screen.clientHeight = window.innerHeight;
		i_screen.clientWidth = window.innerWidth;
		i_screen.scrollLeft = window.pageXOffset;
		i_screen.scrollTop = window.pageYOffset;
	} else if (!(document.documentElement.clientWidth == 0) && !(document.documentElement.clientHeight == 0)) {
		i_screen.clientHeight = document.documentElement.clientHeight;
		i_screen.clientWidth = document.documentElement.clientWidth;
		i_screen.scrollLeft = document.documentElement.scrollLeft;
		i_screen.scrollTop = document.documentElement.scrollTop;
	} else {
		i_screen.clientHeight = document.body.clientHeight;
		i_screen.clientWidth = document.body.clientWidth;
		i_screen.scrollLeft = document.body.scrollLeft;
		i_screen.scrollTop = document.body.scrollTop;
	}
	if (!(document.documentElement.scrollWidth == 0) && !(document.documentElement.scrollHeight == 0)) {
		i_screen.scrollHeight = document.documentElement.scrollHeight;
		i_screen.scrollWidth = document.documentElement.scrollWidth;
	} else {
		i_screen.scrollHeight = document.body.scrollHeight;
		i_screen.scrollWidth = document.body.scrollWidth;
	}
	return i_screen;
}

guifw.events = {
	add:function(i_obj, i_event, i_func) {
		if (i_obj != undefined && i_event != undefined && i_func != undefined) {
			if (i_obj.addEventListener) {
				i_obj.addEventListener(String(i_event).toLowerCase(), i_func, false);
				return true;
			} else if (i_obj.attachEvent) {
				i_obj.attachEvent("on" + String(i_event).toLowerCase(), i_func);
				return true;
			}
		}
		return false;
	},
	remove:function(i_obj, i_event, i_func) {
		if (i_obj != undefined && i_event != undefined && i_func != undefined) {
			if (i_obj.removeEventListener) {
				i_obj.removeEventListener(String(i_event).toLowerCase(), i_func, false);
				return true;
			} else if (i_obj.detachEvent) {
				i_obj.detachEvent("on" + String(i_event).toLowerCase(), i_func);
				return true;
			}
		}
		return false;
	},
	create:function(i_obj, i_type, i_event) {
		if (i_obj != undefined && i_type != undefined && i_event != undefined) {
			if (document.all) {
				i_obj.fireEvent("on" + String(i_event).toLowerCase());
				return true;
			} else {
				var evt = document.createEvent(i_type);
				evt.initEvent(String(i_event).toLowerCase(), true, true);
				i_obj.dispatchEvent(evt);
				return true;
			}
		}
		return false;
	}
}

guifw.ajaxobject = function() {
	var lv_ajax_modul = null;
	if (String(window.location.protocol).indexOf("http") == -1) {
		if (window.XMLHttpRequest && !(window.ActiveXObject)) {
			lv_ajax_modul = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			try {
				lv_ajax_modul = new ActiveXObject("MSXML2.XMLHTTP");
			} catch (e) {
				try {
					lv_ajax_modul = new ActiveXObject("MICROSOFT.XMLHTTP");
				} catch (e) {
					lv_ajax_modul = null;
				}
			}
		} else {
			lv_ajax_modul = null;
		}
	} else {
		if (window.XMLHttpRequest) {
			lv_ajax_modul = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			try {
				lv_ajax_modul = new XMLHttpRequest();
			} catch(e) {
				try {
					lv_ajax_modul = new ActiveXObject("MSXML2.XMLHTTP");
				} catch (e) {
					try {
						lv_ajax_modul = new ActiveXObject("MICROSOFT.XMLHTTP");
					} catch (e) {
						lv_ajax_modul = null;
					}
				}
			}
		} else {
			lv_ajax_modul = null;
		}
	}
	this.ajaxid = lv_ajax_modul;
	this.error = false;
	if (lv_ajax_modul == null) this.error = true;

	this.get = function(i_url_path, fn_callback_method) {
		var lv_ajax_modul = this.ajaxid;
		if (lv_ajax_modul != undefined && lv_ajax_modul != null && typeof(lv_ajax_modul) == "object") {
			lv_ajax_modul.abort();
			lv_ajax_modul.open("GET", i_url_path, true);
			lv_ajax_modul.onreadystatechange = fn_callback_method;
			lv_ajax_modul.send(null);
			return true;
		} else {
			throw new Error("XMLHTTP Ajax not supported!");
			return false;
		}
	}

	this.post = function(i_url_path, i_url_parm, fn_callback_method) {
		var lv_ajax_modul = this.ajaxid;
		if (lv_ajax_modul != undefined && lv_ajax_modul != null && typeof(lv_ajax_modul) == "object") {
			lv_ajax_modul.abort();
			lv_ajax_modul.open("POST", i_url_path, true);
			lv_ajax_modul.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			lv_ajax_modul.onreadystatechange = fn_callback_method;
			lv_ajax_modul.send(i_url_parm);
			return true;
		} else {
			throw new Error("XMLHTTP Ajax not supported!");
			return false;
		}
	}

	this.abort = function() {
		var lv_ajax_modul = this.ajaxid;
		if (lv_ajax_modul != undefined && lv_ajax_modul != null && typeof(lv_ajax_modul) == "object") {
			lv_ajax_modul.abort();
			return true;
		} else {
			throw new Error("XMLHTTP Ajax not supported!");
			return false;
		}
	}

	this.readystate = function() {
		var lv_ajax_modul = this.ajaxid;
		if (lv_ajax_modul != undefined && lv_ajax_modul != null && typeof(lv_ajax_modul) == "object") {
			return lv_ajax_modul.readyState;
		} else {
			return -1;
		}
	}

	this.status = function() {
		var lv_ajax_modul = this.ajaxid;
		if (lv_ajax_modul != undefined && lv_ajax_modul != null && typeof(lv_ajax_modul) == "object") {
			return lv_ajax_modul.status;
		} else {
			return -1;
		}
	}

	this.responsetext = function() {
		var lv_ajax_modul = this.ajaxid;
		if (lv_ajax_modul != undefined && lv_ajax_modul != null && typeof(lv_ajax_modul) == "object") {
			return lv_ajax_modul.responseText;
		} else {
			return "";
		}
	}

	this.removescripts = function() {
		var lv_ajax_modul = this.ajaxid;
		var i_result = "";
		if (lv_ajax_modul != undefined && lv_ajax_modul.responseText != "") {
			i_result = lv_ajax_modul.responseText;
			i_result = i_result.replace(/&(lt|gt);/g, function(strMatch, p1){ return (p1 == "lt") ? "<" : ">"; });
			i_result = i_result.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, "");
		}
		return i_result;
	}

	this.runscripts = function() {
		var lv_ajax_modul = this.ajaxid;
		try {
			if (lv_ajax_modul != undefined && lv_ajax_modul.responseText != "") {
				var i_html = lv_ajax_modul.responseText;
				var i_script = "";
				i_html = i_html.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){ if (i_html !== null) i_script += arguments[1] + '\n'; return ""; });
				if (i_script) {
					if (window.execScript) {
						window.execScript(i_script);
					} else {
						window.setTimeout(i_script, 0);
					}
				}
			}
		} catch(e) {
			alert(e);
			return false;
		}
		return true;
	}
}

guifw.modalwindow = function() {
	var lv_mwin = {id:null, fid:null, items:null, timer:null, active:false}
	var lv_ajax = {id:null, conid:null, timer:null, wname:null}
	var lv_fade = {alphacurrent:0, alphamax:50, speed:10, timer:null, inout:1};
	var fn_iefix_need = function() {
		var u_agent = navigator.userAgent;
		var b_ver = 0;
		if ((u_agent.indexOf("MSIE") != -1) && (u_agent.indexOf("Opera") == -1)) {
			b_ver = parseFloat(u_agent.substring(u_agent.indexOf("MSIE")+5));
			if (b_ver < 7) return true;
		}
		return false;
	}
	var fn_auto_resize = function() {
		if (lv_mwin.id != null && lv_mwin.active) {
			if (lv_mwin.fid != undefined && lv_mwin.fid != null) {
				var u_screen = guifw.browsersize();
				var t_height = Math.max(u_screen.clientHeight, u_screen.scrollHeight);
				var t_width = Math.max(u_screen.clientWidth, u_screen.scrollWidth);
				lv_mwin.id.style.height = t_height + "px";
				lv_mwin.id.style.width = t_width + "px";
				lv_mwin.fid.style.height = t_height + "px";
				lv_mwin.fid.style.width = t_width + "px";
			}
			setTimeout(fn_auto_refresh, 100);
		}
	}
	var fn_auto_refresh = function() {
		if (lv_mwin.active && lv_mwin.items.length > 0) {
			var t_obj = null;
			var t_height = 0;
			var t_width = 0;
			var u_screen = guifw.browsersize();
			for (var w_inx = 0; w_inx < lv_mwin.items.length; w_inx++) {
				t_obj = lv_mwin.items[w_inx];
				t_obj.style.overflow = "hidden";
				t_obj.style.margin = "0px";
				t_obj.style.height = "1px";
				t_obj.style.width = "1px";
				t_obj.style.left = "0px";
				t_obj.style.top = "0px";
				if (t_obj.guifwdata.resize == "off") {
					t_height = t_obj.guifwdata.height;
					t_width = t_obj.guifwdata.width;
				} else {
					if (t_obj.guifwdata.resize == "auto" || t_obj.guifwdata.resize == "height") {
						t_height = t_obj.scrollHeight;
						if (t_height == undefined || t_height == null || t_height < 1) t_height = t_obj.guifwdata.height;
					} else {
						t_height = t_obj.guifwdata.height;
					}
					if (t_obj.guifwdata.resize == "auto" || t_obj.guifwdata.resize == "width") {
						t_width = t_obj.scrollWidth;
						if (t_width == undefined || t_width == null || t_width < 1) t_width = t_obj.guifwdata.width; 
					} else {
						t_width = t_obj.guifwdata.width;
					}
					if (t_height > (u_screen.clientHeight - 20) && t_obj.guifwdata.oversize != "auto" && t_obj.guifwdata.oversize != "height") {
						t_height = u_screen.clientHeight - 20;
						if (t_obj.guifwdata.height > 0 && t_obj.guifwdata.height > t_height) t_height = t_obj.guifwdata.height;
					}
					if (t_width > (u_screen.clientWidth - 20) && t_obj.guifwdata.oversize != "auto" && t_obj.guifwdata.oversize != "width") {
						t_width = u_screen.clientWidth - 20;
						if (t_obj.guifwdata.width > 0 && t_obj.guifwdata.width > t_width) t_width = t_obj.guifwdata.width;
					}
				}
				t_obj.style.height = Number(t_height) + "px";
				t_obj.style.width = Number(t_width) + "px";
				if (t_obj.guifwdata.top == -1) {
					if (u_screen.clientHeight > t_height) {
						t_obj.style.top = Number(Math.floor((u_screen.clientHeight - t_height) / 2) + u_screen.scrollTop) + "px";
					} else {
						t_obj.style.top = "8px";
					}
				}
				if (t_obj.guifwdata.left == -1) {
					if (u_screen.clientWidth > t_width) {
						t_obj.style.left = Number(Math.floor((u_screen.clientWidth - t_width) / 2) + u_screen.scrollLeft) + "px";
					} else {
						t_obj.style.left = "0px";
					}
				}
				t_obj.style.visibility = "visible";
				if (typeof(t_obj.guifwdata.resizeaction) == "function") t_obj.guifwdata.resizeaction(t_obj);
			}
		}
	}
	var fn_fade_inout = function() {
		var t_speed = lv_fade.speed;
		if ((lv_fade.alphacurrent != lv_fade.alphamax && lv_fade.inout == 1) || (lv_fade.alphacurrent != 0 && lv_fade.inout == -1)) {
			if ((lv_fade.alphamax - lv_fade.alphacurrent) < lv_fade.speed && lv_fade.inout == 1) {
				t_speed = lv_fade.alphamax - lv_fade.alphacurrent;
			} else if (lv_fade.alphacurrent < lv_fade.speed && lv_fade.inout == -1) {
				t_speed = lv_fade.alphacurrent;
			}
			lv_fade.alphacurrent = lv_fade.alphacurrent + (t_speed * lv_fade.inout);
			if (guifw.iefixneed()) {
				lv_mwin.id.style.filter = "alpha(opacity=" + lv_fade.alphacurrent + ")";
			} else {
				lv_mwin.id.style.opacity = lv_fade.alphacurrent * .01;
			}
		} else {
			if (lv_fade.timer) {
				clearInterval(lv_fade.timer);
				lv_fade.timer = null;
			}
			if (lv_fade.inout == -1) {
				document.body.removeChild(lv_mwin.id);
				lv_mwin.id = null;
				lv_mwin.fid = null;
				lv_mwin.active = false;
			}
		}
	}
	var fn_ajax_callback = function() {
		if (lv_ajax.id.readystate() == 4 && (lv_ajax.id.status() == 200 || window.location.href.indexOf("http") == -1)) {
			var t_obj = lv_ajax.conid;
			if (lv_ajax.timer) {
				clearTimeout(lv_ajax.timer);
				lv_ajax.timer = null;
			}
			if (t_obj != undefined && t_obj != null) {
				t_obj.style.visibility = "hidden";
				t_obj.style.left = "0px";
				t_obj.style.top = "0px";
				t_obj.innerHTML = lv_ajax.id.removescripts();
				lv_ajax.id.runscripts();
			}
		}
	}
	var fn_ajax_timeout = function() {
		if (lv_mwin.active && lv_ajax.timer) {
			clearTimeout(lv_ajax.timer);
			lv_ajax.id.abort();
			lv_ajax.conid.innerHTML = "";
			this.removeItem(lv_ajax.wname);
			if (lv_mwin.items.length == 0) this.timeout(100);
		}
	}
	var fn_valid_wname = function(i_name) {
		if (i_name != undefined) {
			i_name = i_name.replace(/\W/g, "");
			i_name = i_name.substr(0, 20);
			i_name = i_name.toLowerCase();
			return i_name;
		} else {
			return null;
		}
	}
	var fn_get_item_id = function(i_name) {
		i_name = fn_valid_wname(i_name);
		if (i_name == null) return null;
		var t_obj = null;
		for (var w_inx = 0; w_inx < lv_mwin.items.length; w_inx++) {
			if (lv_mwin.items[w_inx].guifwdata.name == i_name) {
				t_obj = lv_mwin.items[w_inx];
				break;
			}
		}
		return t_obj;
	}
	return {
		active:function() {
			if (lv_mwin.id != undefined && lv_mwin.id != null && lv_mwin.active) {
				return true;
			} else {
				return false;
			}
		},
		open:function(i_parm) {
			if (lv_mwin.id == null && !lv_mwin.active) {
				var t_data = {color:"", image:"", alpha:50};
				if (i_parm != undefined) {
					if (i_parm.color != undefined) t_data.color = i_parm.color;
					if (i_parm.image != undefined) t_data.image = i_parm.image;
					if (i_parm.alpha != undefined && !isNaN(parseInt(i_parm.alpha))) t_data.alpha = parseInt(i_parm.alpha);
					var t_iefix = fn_iefix_need();
					var t_obj = document.createElement("div");
					t_obj.setAttribute("id", "guifw_modalwindow_background");
					t_obj.style.overflow = "hidden";
					t_obj.style.cursor = "not-allowed";
					t_obj.style.left = "0px";
					t_obj.style.top = "0px";
					if (t_iefix) {
						t_obj.style.position = "absolute";
						t_obj.style.height = "1px";
						t_obj.style.width = "1px";
					} else {
						t_obj.style.position = "fixed";
						t_obj.style.height = "100%";
						t_obj.style.width = "100%";
					}
					if (t_data.image != "") t_obj.style.background = "url(" + t_data.image + ") repeat 0px 0px";
					if (t_data.color != "") t_obj.style.backgroundColor = t_data.color;
					if (guifw.iefixneed()) {
						t_obj.style.filter = "alpha(opacity=0)";
					} else {
						t_obj.style.opacity = 0;
					}
					t_obj.style.zIndex = 10000;
					document.body.appendChild(t_obj);
					lv_mwin.id = t_obj;
					if (t_iefix) {
						var t_frm = document.createElement("iframe");
						t_frm.setAttribute("frameBorder", "0");
						t_frm.setAttribute("scrolling", "no");
						t_frm.style.filter = "mask()";
						t_obj.appendChild(t_frm);
						lv_mwin.fid = t_frm;
					}
					lv_fade.alphamax = t_data.alpha;
					lv_ajax.id = new guifw.ajaxobject();
					lv_mwin.items = new Array();
					lv_mwin.active = true;
					fn_auto_resize();
					guifw.events.add(window, "resize", fn_auto_resize);
					guifw.events.add(window, "scroll", fn_auto_resize);
					lv_fade.inout = 1;
					lv_fade.timer = setInterval(fn_fade_inout, 10);
				}
			}
		},
		close:function() {
			if (lv_mwin.id != null && lv_mwin.active) {
				guifw.events.remove(window, "scroll", fn_auto_resize);
				guifw.events.remove(window, "resize", fn_auto_resize);
				if (lv_ajax.timer) clearTimeout(lv_ajax.timer);
				for (var w_inx = 0; w_inx < lv_mwin.items.length; w_inx++) {
					var t_obj = lv_mwin.items[w_inx];
					while (t_obj.hasChildNodes()) {
						t_obj.removeChild(t_obj.lastChild);
					}
					document.body.removeChild(t_obj);
				}
				lv_mwin.id.style.cursor = "default";
				lv_ajax.id = null;
				lv_mwin.items = new Array();
				if (lv_fade.timer) clearInterval(lv_fade.timer);
				lv_fade.inout = -1;
				lv_fade.timer = setInterval(fn_fade_inout, 10);
			}
		},
		timeout:function(i_timer) {
			if (lv_mwin.id != null && lv_mwin.active) {
				if (i_timer != undefined && !isNaN(parseInt(i_timer))) {
					if (lv_mwin.timer) clearTimeout(lv_mwin.timer);
					lv_mwin.timer = setTimeout(this.close, i_timer);
				}
			}
		},
		cleartimeout:function() {
			if (lv_mwin.id != null && lv_mwin.active && lv_mwin.timer) {
				clearTimeout(lv_mwin.timer);
				lv_mwin.timer = null;
			}
		},
		addItem:function(i_name, i_parm) {
			if (!lv_mwin.active || i_name == undefined) return false;
			var t_data = {top:-1, left:-1, width:0, height:0, resize:"auto", oversize:"off", resizeaction:null, background:"none"};
			if (i_parm != undefined) {
				if (i_parm.top != undefined && !isNaN(parseInt(i_parm.top))) t_data.top = parseInt(i_parm.top);
				if (i_parm.left != undefined && !isNaN(parseInt(i_parm.left))) t_data.left = parseInt(i_parm.left);
				if (i_parm.width != undefined && !isNaN(parseInt(i_parm.width))) t_data.width = parseInt(i_parm.width);
				if (i_parm.height != undefined && !isNaN(parseInt(i_parm.height))) t_data.height = parseInt(i_parm.height);
				if (i_parm.resize != undefined) t_data.resize = String(i_parm.resize).toLowerCase();
				if (i_parm.oversize != undefined) t_data.oversize = String(i_parm.oversize).toLowerCase();
				if (i_parm.resizeaction != undefined && typeof(i_parm.resizeaction) == "function") t_data.resizeaction = i_parm.resizeaction;
				if (i_parm.background != undefined) t_data.background = String(i_parm.background);
			}
			i_name = fn_valid_wname(i_name);
			if (i_name == null) return false;
			for (var w_inx = 0; w_inx < lv_mwin.items.length; w_inx++) {
				if (lv_mwin.items[w_inx].guifwdata.name == i_name) return false;
			}
			w_inx = (lv_mwin.items.length + 1);
			if (w_inx < 1 || w_inx > 99) return false;
			var t_obj = document.createElement("div");
			t_obj.setAttribute("id", "guifw_modalwindow_" + i_name.toLowerCase());
			t_obj.style.position = "absolute";
			t_obj.style.overflow = "hidden";
			t_obj.style.margin = "10px";
			t_obj.style.height = "1px";
			t_obj.style.width = "1px";
			if (t_data.top == -1) {
				t_obj.style.top = "0px";
			} else {
				t_obj.style.top = Number(t_data.top) + "px";
			}
			if (t_data.left == -1) {
				t_obj.style.left = "0px";
			} else {
				t_obj.style.left = Number(t_data.left) + "px";
				}
			t_obj.style.background = t_data.background;
			t_obj.style.visibility = "hidden";
			t_obj.style.zIndex = 10000 + w_inx;
			t_obj.guifwdata = {name:i_name, top:t_data.top, left:t_data.left, width:t_data.width, height:t_data.height, resize:t_data.resize, visible:true};
			document.body.appendChild(t_obj);
			lv_mwin.items.push(t_obj);
			this.refreshItem(i_name);
			return true;
		},
		refreshItem:function(i_name) {
			if (lv_mwin.active && lv_mwin.items.length > 0 && i_name != undefined) {
				i_name = fn_valid_wname(i_name);
				if (i_name == null) return false;
				var t_obj = null;
				for (var w_inx = 0; w_inx < lv_mwin.items.length; w_inx++) {
					if (lv_mwin.items[w_inx].guifwdata.name == i_name) {
						t_obj = lv_mwin.items[w_inx];
						break;
					}
				}
				if (t_obj == undefined || t_obj == null) return false;
				t_obj.style.zIndex = 10001 + w_inx;
				fn_auto_refresh();
				return true;
			}
			return false;
		},
		resizeItem:function(i_name, i_parm) {
			if (lv_mwin.active && lv_mwin.items.length > 0 && i_name != undefined && i_parm != undefined) {
				var t_obj = fn_get_item_id(i_name);
				if (t_obj == undefined || t_obj == null) return false;
				if (i_parm.height != undefined && !isNaN(parseInt(i_parm.height))) t_obj.guifwdata.height = parseInt(i_parm.height);
				if (i_parm.width != undefined && !isNaN(parseInt(i_parm.width))) t_obj.guifwdata.width = parseInt(i_parm.width);
				if (i_parm.resize != undefined && i_parm.resize != "") t_obj.guifwdata.resize = String(i_parm.resize).toLowerCase();
				if (i_parm.oversize != undefined && i_parm.oversize != "") t_obj.guifwdata.oversize = String(i_parm.oversize).toLowerCase();
				if (i_parm.resizeaction != undefined && typeof(i_parm.resizeaction) == "function") t_obj.guifwdata.resizeaction = i_parm.resizeaction;
				if (i_parm.delay != undefined) {
					var t_delay = parseInt(i_parm.delay, 10);
					if (isNaN(t_delay)) t_delay = 100;
					setTimeout(fn_auto_refresh, t_delay);
				} else {
					fn_auto_refresh();
				}
				return true;
			}
			return false;
		},
		removeItem:function(i_name, i_close) {
			if (lv_mwin.active && lv_mwin.items.length > 0 && i_name != undefined) {
				i_name = fn_valid_wname(i_name);
				if (i_name == null) return false;
				var t_mwin_last_item = "";
				for (var w_inx = 0; w_inx < lv_mwin.items.length; w_inx++) {
					if (lv_mwin.items[w_inx].guifwdata.name == i_name) {
						var t_obj = lv_mwin.items[w_inx];
						lv_mwin.items.splice(w_inx, 1);
						while (t_obj.hasChildNodes()) {
							t_obj.removeChild(t_obj.lastChild);
						}
						document.body.removeChild(t_obj);
						if (i_close == 1 || lv_mwin.items.length == 0) {
							this.close();
						} else {
							this.showItems(0);
							if (t_mwin_last_item != "") this.activeItem(t_mwin_last_item, 1);
						}
						return true;
					}
					t_mwin_last_item = lv_mwin.items[w_inx].guifwdata.name;
				}
			}
			return false;
		},
		removeAll:function() {
			if (lv_mwin.active && lv_mwin.items.length > 0) {
				if (lv_ajax.timer) clearTimeout(lv_ajax.timer);
				for (var w_inx = 0; w_inx < lv_mwin.items.length; w_inx++) {
					var t_obj = lv_mwin.items[w_inx];
					while (t_obj.hasChildNodes()) {
						t_obj.removeChild(t_obj.lastChild);
					}
					document.body.removeChild(t_obj);
				}
				lv_mwin.items = new Array();
				return true;
			}
			return false;
		},
		activeItem:function(i_name, i_status) {
			if (lv_mwin.active && lv_mwin.items.length > 0 && i_name != undefined && i_status != undefined) {
				i_name = fn_valid_wname(i_name);
				if (i_name == null) return false;
				for (var w_inx = 0; w_inx < lv_mwin.items.length; w_inx++) {
					if (lv_mwin.items[w_inx].guifwdata.name == i_name) {
						if (parseInt(i_status) == 1) {
							if (guifw.iefixneed()) {
								lv_mwin.items[w_inx].style.filter = "none";
							} else {
								lv_mwin.items[w_inx].style.opacity = "none";
							}
							lv_mwin.items[w_inx].style.zIndex = 10001 + w_inx;
							lv_mwin.items[w_inx].guifwdata.visible = true;
						} else {
							if (guifw.iefixneed()) {
								lv_mwin.items[w_inx].style.filter = "alpha(opacity=75)";
							} else {
								lv_mwin.items[w_inx].style.opacity = 0.75;
							}
							lv_mwin.items[w_inx].style.zIndex = 9999;
							lv_mwin.items[w_inx].guifwdata.visible = false;
						}
						return true;
					}
				}
			}
			return false;
		},
		showItems:function(i_status) {
			if (lv_mwin.active && lv_mwin.items.length > 0 && i_status != undefined) {
				for (var w_inx = 0; w_inx < lv_mwin.items.length; w_inx++) {
					if (parseInt(i_status) == 1) {
						if (guifw.iefixneed()) {
							lv_mwin.items[w_inx].style.filter = "none";
						} else {
							lv_mwin.items[w_inx].style.opacity = "none";
						}
						lv_mwin.items[w_inx].style.zIndex = 10001 + w_inx;
						lv_mwin.items[w_inx].guifwdata.visible = true;
					} else {
						if (guifw.iefixneed()) {
							lv_mwin.items[w_inx].style.filter = "alpha(opacity=75)";
						} else {
							lv_mwin.items[w_inx].style.opacity = 0.75;
						}
						lv_mwin.items[w_inx].style.zIndex = 9999;
						lv_mwin.items[w_inx].guifwdata.visible = false;
					}
				}
				return true;
			}
			return false;
		},
		itemsCount:function() {
			if (lv_mwin.active && lv_mwin.items.length > 0) {
				return lv_mwin.items.length;
			} else {
				return 0;
			}
		},
		itemExist:function(i_name) {
			if (lv_mwin.active && lv_mwin.items.length > 0 && i_name != undefined) {
				var t_obj = fn_get_item_id(i_name);
				if (t_obj != undefined && t_obj != null) return true;
			}
			return false;
		},
		getItemId:function(i_name) {
			if (lv_mwin.active && lv_mwin.items.length > 0 && i_name != undefined) {
				var t_obj = fn_get_item_id(i_name);
				if (t_obj != undefined && t_obj != null) return t_obj;
			}
			return null;
		},
		getItemName:function(i_name) {
			if (lv_mwin.active && lv_mwin.items.length > 0 && i_name != undefined) {
				var t_obj = fn_get_item_id(i_name);
				if (t_obj != undefined && t_obj != null) return "guifw_modalwindow_" + t_obj.guifwdata.name;
			}
			return null;
		},
		setItemContent:function(i_name, i_parm) {
			if (lv_mwin.active && lv_mwin.items.length > 0 && i_name != undefined && i_parm != undefined) {
				var t_obj = fn_get_item_id(i_name);
				if (t_obj == undefined || t_obj == null) return false;
				if (lv_ajax.timer) clearTimeout(lv_ajax.timer);
				lv_ajax.timer = null;
				if (i_parm.html != undefined) {
					t_obj.innerHTML = i_parm.html;
					this.refreshItem(i_name);
				} else if (i_parm.urlpath != undefined) {
					var t_timer = 5000;
					var t_date = new Date();
					var t_urlpath = i_parm.urlpath;
					var t_urlparm = "";
					if (t_urlpath.indexOf("?") == -1) {
						t_urlpath += "?";
					} else {
						t_urlpath += "&";
					}
					t_urlpath += "rndseed=" + t_date.getTime();
					if (i_parm.urlparm != undefined) t_urlparm = i_parm.urlparm;
					if (i_parm.timeout != undefined) t_timer = parseInt(i_parm.timeout);
					if (isNaN(t_timer)) t_timer = 5000;
					lv_ajax.conid = t_obj;
					lv_ajax.wname = t_obj.guifwdata.name;
					lv_ajax.timer = setTimeout(fn_ajax_timeout, t_timer);
					lv_ajax.id.post(t_urlpath, t_urlparm, fn_ajax_callback);
				}
				return true;
			}
			return false;
		},
		setItemBackground:function(i_name, i_parm) {
			if (lv_mwin.active && lv_mwin.items.length > 0 && i_name != undefined && i_parm != undefined) {
				var t_obj = fn_get_item_id(i_name);
				if (t_obj == undefined || t_obj == null) return false;
				if (i_parm.image != undefined) {
					if (i_parm.image == "") {
						t_obj.style.background = "none";
					} else {
						t_obj.style.background = "url(" + i_parm.image + ") center center no-repeat";
					}
				} else if (i_parm.color != undefined) {
					t_obj.style.backgroundColor = i_parm.color;
				} else {
					return false;
				}
				return true;
			}
			return false;
		}
	}
}();

