if(!com) var com = {};
if(!com.LeadTran) com.LeadTran = {};

com.LeadTran.IE = (window.navigator.userAgent.indexOf("MSIE") > 0) ? true : false;

if (com.LeadTran.IE == false)
{
	HTMLElement.prototype.__defineGetter__("innerText",function () { return(this.textContent); });   
	HTMLElement.prototype.__defineSetter__("innerText",function (txt) { this.textContent = txt; });
}

com.LeadTran.Utils = {
	DocumentReadyListener: {
		count: 0,
		functions: {},
		execute: function()
		{
			try
			{
				if (this.count > 0)
				{
					for(var key in this.functions)
					{
						try
						{
							if ((this.functions[key] != null) && (typeof this.functions[key] == "function"))
							{
								this.functions[key].call(this);
							}
						}catch(evc){}
					}
				}
			}catch(e){}
		}
	},
	DisableSelection: function(target)
	{
		try
		{
			if (target != null)
			{
				if (typeof target.onselectstart != "undefined")
				{
					target.onselectstart = function(){ return false; }
				}
				else if (typeof target.style.MozUserSelect!="undefined") 
				{
					target.style.MozUserSelect = "none"
				}	
				else
				{
					target.onmousedown = function(){ return false; }
				}
			}
		}catch(e){}	
	},
	GetStyle: function(element, style)
	{
		try
		{
			if ((element != null) && (style != null) && (style != ""))
			{
				if (element.currentStyle)
				{
					var value = eval("element.currentStyle." + style);
					if (value != null)
					{
						return value;
					}
					else
					{
						return element.currentStyle[style];
					}
				}
				else if (window.getComputedStyle)
				{
					return document.defaultView.getComputedStyle(element, null).getPropertyValue(style);
				}
			}
		}catch(e){}
		
		return "";
	},
	HasClass: function(element, classname)
	{
		try
		{
			if ((element != null) && (classname != null) && (classname != ""))
			{
				return preg_match('(\\s|^)' + classname + '(\\s|$)', element.className);
			}
		}catch(e){}
		
		return false;
	},
	AddClass: function (element, classname)
	{
		try
		{
			if ((element != null) && (classname != null) && (classname != "") && (this.HasClass(element, classname) == false))
			{
				element.className += (element.className != "" ? " " : "") + classname;
			}
		}catch(e){}
	},
	RemoveClass: function(element, classname)
	{
		try
		{
			if ((element != null) && (classname != null) && (classname != "") && (this.HasClass(element, classname) == true))
			{
				element.className = preg_replace('(\\s|^)' + classname + '(\\s|$)', ' ', element.className);
			}
		}catch(e){}
	},
	DocumentReady: function(onready)
	{
		try
		{
			if ((onready != null) && (typeof onready == "function"))
			{
				this.DocumentReadyListener.functions[this.DocumentReadyListener.count] = onready;
				this.DocumentReadyListener.count++;
			}
		}catch(e){}
	},
	InitializeDocumentReady: function()
	{
		try
		{
			if (document.addEventListener)
			{
			   document.addEventListener("DOMContentLoaded", function()
			   {
			   		try
					{
						com.LeadTran.Utils.DocumentReadyListener.execute();
					}catch(ev){}
			   }, false);
			}
			else
			{
				document.attachEvent("onreadystatechange", function()
				{
					try
					{
						if ((document.readyState == "complete") || (document.readyState == "loaded"))
						{
							com.LeadTran.Utils.DocumentReadyListener.execute();
						}
					}catch(ev){}
				});
			}
		}catch(e){}
	},
	RemoveElement: function(element)
	{
		try
		{
			if ((element != null) && (element.parentNode != null))
			{
				element.parentNode.removeChild(element);
			}
		}catch(e){}
	},
	AddElement: function(element, elementparent)
	{
		try
		{
			if ((element != null) && (elementparent != null))
			{
				elementparent.appendChild(element);
			}
		}catch(e){}
	},
	GetElementBounds: function(element)
	{
		var bounds = {
			width: 0,
			height: 0,
			top: 0,
			left: 0
		};
		
		try
		{
			if (element != null)
			{
				var paddingleft = $(element).css("padding-left").replace(/[\D]+/,"");
				paddingleft = (paddingleft != "") ? parseInt(paddingleft) : 0;
				
				var paddingright = $(element).css("padding-right").replace(/[\D]+/,"");
				paddingright = (paddingright != "") ? parseInt(paddingright) : 0;
				
				bounds.width = $(element).width() + paddingleft + paddingright;
				bounds.height = $(element).height();
				bounds.top = $(element).offset().top;
				bounds.left = $(element).offset().left;
			}
		}catch(e){}
		
		return bounds;
	},
	GetTextSize: function(text, fontsize, fontfamily, fontweight)
	{
		var size = {
			width: 0,
			height: 0
		};
		
		try
		{
			if ((text != null) && (text != ""))
			{
				var otextsize = document.createElement("span");
				otextsize.innerText = text;
				$(otextsize).attr("style", ((fontsize != null) && (fontsize != "") && (isNaN(fontsize) == false)? "font-size:" + fontsize + "px;": "") + ((fontfamily != null) && (fontfamily != "") ? "font-family:" + fontfamily + ";": "") + ((fontweight != null) && (fontweight != "") ? "font-weight:" + fontweight + ";": "") +"position:absolute; z-index:-1;");
				$(otextsize).css({
					top: "-10000px",
					left: "-10000px"
				});
				$("body").append(otextsize);
				
				var textbounds = com.LeadTran.Utils.GetElementBounds(otextsize);
				
				$(otextsize).remove();
				
				size.width = textbounds.width;
				size.height = textbounds.height;
			}
		}catch(e){}
		
		return size;
	},
	GetOS: function()
	{
		var OS = "unknown";
		
		try
		{
			if (navigator.appVersion.indexOf("Win")!=-1)
			{
				OS = "windows";
			}
			else if (navigator.appVersion.indexOf("Mac")!=-1)
			{
				OS = "mac";
			}
			else if (navigator.appVersion.indexOf("Linux")!=-1)
			{
				OS = "linux";
			}
			else if (navigator.appVersion.indexOf("X11")!=-1)
			{
				OS = "unix";
			}
		}catch(e){}
		
		return OS;
	},
	GetAttribute: function(element, attributename)
	{
		try
		{
			if ((element != null) && (attributename != null) && (attributename != ""))
			{
				var value = element.getAttribute(attributename);
				if (value != null)
				{
					return value;
				}
			}
		}catch(e){}
		
		return "";
	},
	IsEmailValid: function(email)
	{
		try
		{
			if ((email != null) && (email != ""))
			{
				return preg_match(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/, email);
			}
		}catch(e){}
		
		return false;
	},
	IsVisibleElement: function(control)
	{
		try
		{
			if (control != null)
			{
				return com.LeadTran.Utils.GetStyle(control, "display") == "none" ? false : true;
			}
		}catch(e){}
		
		return false;
	},
	getFileExtension: function(filename)
	{
		try
		{
			if ((filename != null) && (str_trim(filename) != ""))
			{
				filename = str_trim(filename);
				
				var pos = filename.lastIndexOf("."); 
	 			if( pos != -1 )
				{
					pos += 1;
					
					if (pos <= filename.length)
					{
						return filename.substr(pos, filename.length).toLowerCase();
					}
				} 
			}	
		}catch(e){}
		
		return "";
	},
	getScreenSize: function()
	{
		var bounds = {
			width: 0,
			height: 0
		};
		
		try
		{
			if ("width" in screen)
			{
				bounds.width = screen.width;
				bounds.height = screen.height;
			}
		}catch(e){}
		
		return bounds;
	},
	GetTextHeight: function(text, fontsize, fontfamily, fontweight, elementWidth)
	{
		try
		{
			if ((text != null) && (text != ""))
			{
				var otextsize = document.createElement("span");
				otextsize.innerText = text;
				$(otextsize).attr("style", ((fontsize != null) && (fontsize != "") && (isNaN(fontsize) == false)? "font-size:" + fontsize + "px;": "") + ((fontfamily != null) && (fontfamily != "") ? "font-family:" + fontfamily + ";": "") + ((fontweight != null) && (fontweight != "") ? "font-weight:" + fontweight + ";": "") + "position:absolute; z-index:-1;" + ((elementWidth != null) && (elementWidth != "") && (isNaN(elementWidth) == false)? "width:" + elementWidth + "px;": ""));
				$(otextsize).css({
					top: "-10000px",
					left: "-10000px"
				});
				$("body").append(otextsize);
				
				var textbounds = com.LeadTran.Utils.GetElementBounds(otextsize);
				
				$(otextsize).remove();
				
				return textbounds.height;
			}
		}catch(e){}
		
		return 0;
	},
 	BrowserDetect: {
		init: function () {
			this.browser = "";
			this.version = "";
			
			try{
				this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
				this.version = this.searchVersion(navigator.userAgent)
					|| this.searchVersion(navigator.appVersion)
					|| "an unknown version";
				this.OS = this.searchString(this.dataOS) || "an unknown OS";
			}catch(error){}
		},
		searchString: function (data) {
			try{
				for (var i=0;i<data.length;i++)	{
					var dataString = data[i].string;
					var dataProp = data[i].prop;
					this.versionSearchString = data[i].versionSearch || data[i].identity;
					if (dataString) {
						if (dataString.indexOf(data[i].subString) != -1)
							return data[i].identity;
					}
					else if (dataProp)
						return data[i].identity;
				}
			}catch(error){}
			
			return "";
		},
		searchVersion: function (dataString) {
			try{
				var index = dataString.indexOf(this.versionSearchString);
				if (index == -1) return;
				return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
			}catch(error){}
			
			return "";
		},
		dataBrowser: [
			{
				string: navigator.userAgent,
				subString: "Chrome",
				identity: "Chrome"
			},
			{ 	string: navigator.userAgent,
				subString: "OmniWeb",
				versionSearch: "OmniWeb/",
				identity: "OmniWeb"
			},
			{
				string: navigator.vendor,
				subString: "Apple",
				identity: "Safari",
				versionSearch: "Version"
			},
			{
				prop: window.opera,
				identity: "Opera"
			},
			{
				string: navigator.vendor,
				subString: "iCab",
				identity: "iCab"
			},
			{
				string: navigator.vendor,
				subString: "KDE",
				identity: "Konqueror"
			},
			{
				string: navigator.userAgent,
				subString: "Firefox",
				identity: "Firefox"
			},
			{
				string: navigator.vendor,
				subString: "Camino",
				identity: "Camino"
			},
			{		// for newer Netscapes (6+)
				string: navigator.userAgent,
				subString: "Netscape",
				identity: "Netscape"
			},
			{
				string: navigator.userAgent,
				subString: "MSIE",
				identity: "Explorer",
				versionSearch: "MSIE"
			},
			{
				string: navigator.userAgent,
				subString: "Gecko",
				identity: "Mozilla",
				versionSearch: "rv"
			},
			{ 		// for older Netscapes (4-)
				string: navigator.userAgent,
				subString: "Mozilla",
				identity: "Netscape",
				versionSearch: "Mozilla"
			}
		],
		dataOS : [
			{
				string: navigator.platform,
				subString: "Win",
				identity: "Windows"
			},
			{
				string: navigator.platform,
				subString: "Mac",
				identity: "Mac"
			},
			{
				   string: navigator.userAgent,
				   subString: "iPhone",
				   identity: "iPhone/iPod"
			},
			{
				string: navigator.platform,
				subString: "Linux",
				identity: "Linux"
			}
		]
	},
	CSS:
	{
		SetElementValue: function(cssclass, element, value)
		{
			try
			{
				var cssrules = "";
				
				for (var i = 0; i < document.styleSheets.length; i++)
				{
					if (document.styleSheets[i]["rules"] != null)
					{
						cssrules = "rules";
					}
					else if (document.styleSheets[i]["cssRules"])
					{
						cssrules = "cssRules";
					}
					
					if (cssrules != "")
					{
						for (var j = 0; j < document.styleSheets[i][cssrules].length; j++)
						{
							if (document.styleSheets[i][cssrules][j].selectorText == cssclass)
							{
								if (document.styleSheets[i][cssrules][j].style[element] != null)
								{
									document.styleSheets[i][cssrules][j].style[element] = value;
									
									return true;
								}
							}
						}
					}	
				}
			}catch(e){}	
			
			return false;
		}
	},
	GetWindowSize: function()
	{
		var size = {
			width: 0,
			height: 0
		};
		
		try
		{
			if (typeof(window.innerWidth) == 'number')
			{
				size.width = window.innerWidth;
				size.height = window.innerHeight;
			}
			else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
			{
				size.width = document.documentElement.clientWidth;
				size.height = document.documentElement.clientHeight;
			}
			else if (document.body && (document.body.clientWidth || document.body.clientHeight))
			{
				size.width = document.body.clientWidth;
				size.height = document.body.clientHeight;
			}
		}catch (e){}
		
		return size;
	},
	Select: {
		SelectByValue: function(element, value)
		{
			try
			{
				if ((element != null) && ("options" in element) && (element.options != null) && (element.options.length > 0) && (value != null)  && (str_trim(value) != ""))
				{
					for (var i = 0; i < element.options.length; i++)
					{
						try
						{
							if ((element.options[i] != null) && ("value" in element.options[i]) && (element.options[i].value == value))
							{
								element.selectedIndex = i;
								break;
							}
						}catch(eit){}
					}
				}
			}catch(e){}
			
			return false;
		},
		AddOption: function(element, text, value, selected)
		{
			try
			{
				if ((element != null) && ("options" in element) && (element.options != null) && (text != null) && (typeof text == "string") && (value != null))
				{
					var added = false;
					
					try
					{
						element.add(new Option(text, "" + value), null);
						added = true;
						
						if ((selected != null) && (typeof selected == "boolean"))
						{
							element.options[element.length - 1].selected = selected;
						}
						
						return element.options[element.length - 1];
					}
					catch(eit)
					{
						if (added == false)
						{
							element.add(new Option(text, "" + value));
							added = true;
						}
						
						if ((selected != null) && (typeof selected == "boolean"))
						{
							element.options[element.length - 1].selected = selected;
						}
						
						if (added == true) return element.options[element.length - 1];
					}
				}
			}catch(e){}
			
			return null;
		},
		SelectByAnyValue: function(element, value)
		{
			try
			{
				if ((element != null) && ("options" in element) && (element.options != null) && (element.options.length > 0) && (value != null))
				{
					for (var i = 0; i < element.options.length; i++)
					{
						try
						{
							if ((element.options[i] != null) && ("value" in element.options[i]) && (element.options[i].value == value))
							{
								element.selectedIndex = i;
								break;
							}
						}catch(eit){}
					}
				}
			}catch(e){}
			
			return false;
		},
		RemoveAllOptions: function(element)
		{
			try
			{
				if ((element != null) && ("options" in element) && (element.options != null) && (element.options.length > 0))
				{
					element.innerHTML = "";
				}
			}catch(e){}
		}
	},
	RemoveProperty: function(element, value)
	{
		try
		{
			if ((element != null) && (typeof element == "object") && (value != null) && (value in element))
			{
				delete element[value];
			}
		}catch(e){}
	},
	GetDocumentSize: function()
	{
		var size = {
			width: 0,
			height: 0
		};
		
		try
		{
			/*if (typeof window.innerWidth != 'undefined')
			{
				size.width = window.innerWidth,
				size.height = window.innerHeight
			}
			else if (document.documentElement && document.documentElement.clientWidth && document.documentElement.clientWidth != 0)
			{
				size.width = document.documentElement.clientWidth,
				size.height = document.documentElement.clientHeight
			}
			else
			{
				size.width = document.getElementsByTagName('body')[0].clientWidth,
				size.height = document.getElementsByTagName('body')[0].clientHeight
			}*/
			
			size.width = $(document).width() - 1;
			size.height = $(document).height() - 1;
		}catch(e){}
		
		return size;
	},
	StopEvent: function(ev)
	{
		try
		{
			ev = (("event" in window) && (window.event)) ? event : ev;
			
			if (ev.cancelBubble != null)  ev.cancelBubble = true;
			if (ev.stopPropagation) ev.stopPropagation();
			if (ev.preventDefault) ev.preventDefault();
			if (window.event) ev.returnValue = false;
			if (ev.cancel != null) ev.cancel = true;
		}catch(e){}	
	},
	Bounds: function(left, top, width, height)
	{
		this.top = ((top != null) && (isNaN(top) == false)) ? top : 0;
		this.left = ((left != null) && (isNaN(left) == false)) ? left : 0;
		this.width = ((width != null) && (isNaN(width) == false)) ? width : 0;
		this.height = ((height != null) && (isNaN(height) == false)) ? height : 0;
	},
	Location: function(left, top)
	{
		this.top = ((top != null) && (isNaN(top) == false)) ? top : 0;
		this.left = ((left != null) && (isNaN(left) == false)) ? left : 0;
	},
	Size: function(width, height)
	{
		this.width = ((width != null) && (isNaN(width) == false)) ? width : 0;
		this.height = ((height != null) && (isNaN(height) == false)) ? height : 0;
	},
	trim: function(string)
	{
	    try
	    {
	        if ((string != null) && (string != ""))
	        {
	            return string.replace(/^\s*|\s*$/g, "");
	        }
	    }catch(e){}
	    
	    return "";
	},
	preg_match: function(pattern, subject)
	{
	    try 
	    {
			if ((pattern) && (pattern != "") && (subject) && (subject != ""))
			{
				var regexp = new RegExp(pattern);
	
		        if (subject.match(regexp))
		        {
		            return true;
		        }
			}     
	    }catch(e){} 
	
	    return false;      
	},
	preg_replace: function(pattern, replacement, subject)
	{
	    try 
	    {
			if ((pattern) && (pattern != "") && (replacement) && (replacement != "") && (subject) && (subject != ""))
			{
				var regexp = new RegExp(pattern);
				
				return subject.replace(regexp, replacement);
			}     
	    }catch(e){} 
	
	    return "";      
	},
	str_startwith: function(content, str)
	{
	    try
	   	{
	   		if ((content != null) && (content != "") && (str != null) && (str != ""))
	   		{
	   			return !content.indexOf(str);
			}
		}catch(e){}
		
		return false;
	},
	str_remove_spaces: function(str)
	{
		try
		{
			if ((str != null) && (str != ""))
			{
				return str.replace(/\s/g, "");
			}
		}catch(e){}
		
		return str;
	},
	isdefined: function(varname)
	{
		try
		{
			if ((varname != null) && (varname != ""))
			{
				return (varname in window);
			}
		}catch(e){}
		
		return false;
	},
	str_remove_nl: function(string)
	{
	    try
	    {
	        if ((string != null) && (string != ""))
	        {
	            return string.replace(/[\n\r\t]/g, "");
	        }
	    }catch(e){}
	    
	    return "";
	},
	isfunction: function(value)
	{
		return ((value != null) && (typeof value == "function"));
	},
	isnumber: function(value)
	{
		return ((value != null) && (isNaN(value) == false));
	},
	iselement: function(value)
	{
		return ((value != null) && ("tagName" in value) && (value.tagName != null) && (value.tagName != ""));
	},
	isobject: function(value)
	{
		return ((value != null) && (typeof value == "object"));
	},
	isstring: function(value)
	{
		return ((value != null) && (typeof value == "string"));
	},
	isboolean: function(value)
	{
		return ((value != null) && (typeof value == "boolean"));
	},
	isdocument: function(value)
	{
		return ((value != null) && (value == document));
	},
	iswindow: function(value)
	{
		return ((value != null) && (value == window));
	},
	isscreen: function(value)
	{
		return ((value != null) && (value == screen));
	},
	isevent: function(value)
	{
		return (com.LeadTran.Utils.isobject(value) && ((("UIEvent" in window) && (value instanceof UIEvent)) || (("Event" in window) && (value instanceof Event)) || ("bubbles" in value)));
	},
	isdate: function(value)
	{
		return (value instanceof Date);
	},
	empty_number: function(value)
	{
		return (!this.isnumber(value));
	},
	empty_string: function(value)
	{
		if (this.isstring(value))
		{
			return (value == "");
		}
		
		return true;
	}
}

com.LeadTran.OS = com.LeadTran.Utils.GetOS();
com.LeadTran.Utils.InitializeDocumentReady();
com.LeadTran.Utils.BrowserDetect.init();

com.LeadTran.ErrorMessage = function(control)
{
	var element = control;
	var message = null;
	var self = this;
	var closing = false;
	
	var settingBoundsArgs = function()
	{
		this.cancel = false;
		this.bounds = {
			width: 0,
			height: 0,
			top: 0,
			left: 0
		};
	}
	this.onsettingbounds = null;
	this.maxWidth = 0;
	
	this.position = "left";
	this.closeonclick = true;
	this.text = "";
	this.visible = false;
	
	var PopupErrorContent = null;
	var Arrow = null;
	var window_onresize = null;
	
	this.show = function(text)
	{
		try
		{
			if (element != null)
			{
				if (message == null)
				{
					if (createMessage(text) == true)
					{
						operationMessage(true, false);
					}
				}
				else
				{
					updateMessage(text);
					
					if (this.visible == false)
					{
						operationMessage(true, false);
					}
					else if (closing == true)
					{
						operationMessage(true, false);
					}
				}
			}
		}catch(e){}
	}
	
	this.hide = function()
	{
		try
		{
			operationMessage(false, false);
		}catch(e){}
	}
	
	this.hidefast = function()
	{
		try
		{
			operationMessage(false, true);
		}catch(e){}
	}
	
	function getPosition(position)
	{
		try
		{
			if ((position != null) && ((position == "left") || (position == "right")))
			{
				return position;
			}
		}catch(e){}
		
		return "left";
	}
	
	function operationMessage(show, fast)
	{
		try
		{
			if (message != null)
			{
				if (show == true)
				{
					self.visible = true;
					
					if (closing == true)
					{
						$(message).stop();
						closing = false;
					}
					
					var updatingPosition = false;
					
					window_onresize = (("onresize" in window) && (window.onresize != null)) ? window.onresize : null;
					window.onresize = function()
					{
						try
						{
							if (window_onresize != null)
							{
								window_onresize.call(this);
							}
						}catch(e){}
						
						try
						{
							if (updatingPosition == false)
							{
								updatingPosition = true;
								updatePosition();
								updatingPosition = false;
							}
						}catch(e){}
					}
					
					$(message).css({
						opacity:0,
						display:"block"
					});
					
					$(message).animate({"opacity":0.87},function(){});
				}
				else
				{
					
					if (fast == true)
					{
						closing = true;
						
						$(message).stop();
						$(message).css({
							display:"none"
						});
						
						window.onresize = window_onresize;
						window_onresize = null;
						
						com.LeadTran.Utils.RemoveElement(message);
						message = null;
						
						self.visible = false;
						closing = false;
					}
					else
					{
						closing = true;
						
						$(message).fadeTo("slow",0,function(){
							$(message).css({
								display:"none"
							});
							
							window.onresize = window_onresize;
							window_onresize = null;
							
							com.LeadTran.Utils.RemoveElement(message);
							message = null;
							
							self.visible = false;
							closing = false;
						});	
					}
				}
			}
		}catch(e){}
	}
	
	function createMessage(text)
	{
		try
		{
			self.position = getPosition(self.position);
			
			if ((message == null) && (element != null) && (self.position != ""))
			{
				text = ((text != null) && (text != "")) ? text : "";
				
				var divPopupError = document.createElement('div');
				divPopupError.onclick = function()
				{
					if (self.closeonclick == true) self.hide();
				};
				
				com.LeadTran.Utils.DisableSelection(divPopupError);
				
				PopupErrorContent = document.createElement('div');
				$(divPopupError).addClass("popupError");
				
				if ((isNaN(self.maxWidth) == false) && (self.maxWidth > 50))
				{
					$(PopupErrorContent).css({
						maxWidth: self.maxWidth + "px"
					});
				}
				
				switch(self.position)
				{
					case "left":
						$(PopupErrorContent).addClass("popupErrorContent popupErrorLeft");
						break;
						
					case "right":
						$(PopupErrorContent).addClass("popupErrorContent popupErrorRight");
						break;
				}
				
				var sizeText = com.LeadTran.Utils.GetTextSize(text, 14, "arial", "bold");
				$(PopupErrorContent).css({width: sizeText.width + "px"})
				
				$("body").append(divPopupError);
				$(divPopupError).append(PopupErrorContent);
				
				Arrow = document.createElement('div');
				$(divPopupError).append(Arrow);
				
				switch(self.position)
				{
					case "left":
						$(Arrow).addClass("popupErrorArrow");
						$(Arrow).html('<div class="line10"><!-- --></div><div class="line9"><!-- --></div><div class="line8"><!-- --></div><div class="line7"><!-- --></div><div class="line6"><!-- --></div><div class="line5"><!-- --></div><div class="line4"><!-- --></div><div class="line3"><!-- --></div><div class="line2"><!-- --></div><div class="line1"><!-- --></div>');
						break;
						
					case "right":
						$(Arrow).addClass("popupErrorArrow");
						$(Arrow).html('<div class="line1"><!-- --></div><div class="line2"><!-- --></div><div class="line3"><!-- --></div><div class="line4"><!-- --></div><div class="line5"><!-- --></div><div class="line6"><!-- --></div><div class="line7"><!-- --></div><div class="line8"><!-- --></div><div class="line9"><!-- --></div><div class="line10"><!-- --></div>');
						break;
				}
					
				if ((Arrow) && (Arrow.childNodes))
				{
					var rowHeight =  $(Arrow).height();
					for (var i = 0; i < Arrow.childNodes.length; i++)
					{
						var oNode = Arrow.childNodes[i];
						if (oNode)
						{
							$(oNode).css({"margin-top":((rowHeight-oNode.offsetHeight)/2)});
						}
					}
				}	
				
				PopupErrorContent.innerText = text;
				
				var popupBounds = com.LeadTran.Utils.GetElementBounds(divPopupError);
				var popupContentBounds = com.LeadTran.Utils.GetElementBounds(PopupErrorContent);
				var elementBounds = getElementBounds();
				
				var top = elementBounds.top + parseInt(elementBounds.height / 2);
				var left = elementBounds.left;
				var rowWidth = $(Arrow).width();
				
				switch(self.position)
				{
					case "left":
						left -= popupContentBounds.width + 15;
						top -= parseInt(popupBounds.height / 2);
						$(Arrow).css({left:(popupContentBounds.width + 2)});
						break;
						
					case "right":
						left +=  elementBounds.width + 15;
						top -= parseInt(popupBounds.height / 2);
						$(Arrow).css({left:0});
						break;
				}
				
				$(divPopupError).css({
					width: (popupContentBounds.width + rowWidth + 2) + "px",
					left:left,
					top:top,
					opacity:0,
					display:"none"
				})
				
				self.text = text;
				message = divPopupError;
				
				return true;
			}
		}catch(e){}
		
		return false;
	}
	
	function updateMessage(text)
	{
		try
		{
			if ((message != null) && (PopupErrorContent != null) && (element != null) && (Arrow != null))
			{
				text = ((text != null) && (text != "")) ? text : "";
				if ((text != "") && (text != self.text))
				{
					if (closing == true)
					{
						if (message != null)
						{
							$(message).stop();
						}
						closing = false;
					}
					
					if ((isNaN(self.maxWidth) == false) && (self.maxWidth > 50))
					{
						$(PopupErrorContent).css({
							maxWidth: self.maxWidth + "px"
						});
					}
					
					PopupErrorContent.innerText = text;
					
					var sizeText = com.LeadTran.Utils.GetTextSize(text, 14, "arial", "bold");
					$(PopupErrorContent).css({width: sizeText.width + "px"})
					
					$(message).css({width: (sizeText.width + 32) + "px"})
					
					updatePosition();
					
					self.text = text;
				}
			}
		}catch(e){}
	}
	
	function updatePosition()
	{
		try
		{
			if ((message != null) && (PopupErrorContent != null) && (element != null) && (Arrow != null))
			{
				var popupBounds = com.LeadTran.Utils.GetElementBounds(message);
				var popupContentBounds = com.LeadTran.Utils.GetElementBounds(PopupErrorContent);
				var elementBounds = getElementBounds();
				
				var top = elementBounds.top + parseInt(elementBounds.height / 2);
				var left = elementBounds.left;
				var rowWidth = $(Arrow).width();
				
				switch(self.position)
				{
					case "left":
						left -= popupContentBounds.width + 15;
						top -= parseInt(popupBounds.height / 2);
						$(Arrow).css({left:(popupBounds.width - rowWidth)});
						break;
						
					case "right":
						left +=  elementBounds.width + 15;
						top -= parseInt(popupBounds.height / 2);
						$(Arrow).css({left:0});
						break;
				}
				
				$(message).css({
					left:left,
					top:top
				})
			}
		}catch(e){}
	}
	
	function getElementBounds()
	{
		try
		{
			if ((self.onsettingbounds != null) && (typeof self.onsettingbounds == "function") && (element != null))
			{
				var args = new settingBoundsArgs();
				
				self.onsettingbounds.call(this, element, args);
				
				if ((args != null) && (args.cancel == false))
				{
					return args.bounds;
				}
			}
		}catch(e){}
		
		return com.LeadTran.Utils.GetElementBounds(element);
	}
}

function str_trim(string)
{
    try
    {
        if ((string != null) && (string != ""))
        {
            return string.replace(/^\s*|\s*$/g, "");
        }
    }catch(e){}
    
    return "";
}

function preg_match(pattern, subject)
{
    try 
    {
		if ((pattern) && (pattern != "") && (subject) && (subject != ""))
		{
			var regexp = new RegExp(pattern);

	        if (subject.match(regexp))
	        {
	            return true;
	        }
		}     
    }catch(e){} 

    return false;      
}

function preg_replace(pattern, replacement, subject)
{
    try 
    {
		if ((pattern) && (pattern != "") && (replacement) && (replacement != "") && (subject) && (subject != ""))
		{
			var regexp = new RegExp(pattern);
			
			return subject.replace(regexp, replacement);
		}     
    }catch(e){} 

    return "";      
}

function str_startwith(content, str)
{
    try
   	{
   		if ((content != null) && (content != "") && (str != null) && (str != ""))
   		{
   			return !content.indexOf(str);
		}
	}catch(e){}
	
	return false;
}

function str_remove_spaces(str)
{
	try
	{
		if ((str != null) && (str != ""))
		{
			return str.replace(/\s/g, "");
		}
	}catch(e){}
	
	return str;
}

function isdefined(varname)
{
	try
	{
		if ((varname != null) && (varname != ""))
		{
			return (varname in window);
		}
	}catch(e){}
	
	return false;
}

function str_remove_nl(string)
{
    try
    {
        if ((string != null) && (string != ""))
        {
            return string.replace(/[\n\r\t]/g, "");
        }
    }catch(e){}
    
    return "";
}

com.LeadTran.SelectChannel = function(control)
{
	var parent = null;
	var button = null;
	var input = null;
	var panel = null;
	var tagspan = null;
	var defaults = null;
	var isvisible = false;
	 
	this.text =	"";
	this.onchange = null;
	this.onclick = null;
	this.value = "";
	
	var lastItem = null;
	var self = this;
	var objectSelect = false;
	var resizing = false;
	var waiting = null;
	var waiting_display = "";
	var disabled_select = false;
	var tagspan_color = "";
	var lastKey = null;	
	var lastElement = null;

	function Constructor()
	{
		try 
		{	
			if ((control != undefined) &&  ($(control).parent().children().length >= 3) && ($(control).parent().parent().children().length >= 3))
			{
				defaults = new Array();
				input = control;
				parent = $(input).parent().parent();
				button = $(parent).children().get(2);
				
				input = $(input).parent().children().get(0);
				tagspan = $(input).parent().children().get(1);
				panel = $(input).parent().children().get(2);

				if (($(parent).parent() != null) && ($(parent).parent().children() != null) && ($(parent).parent().children().length >= 2))
				{
					waiting = $(parent).parent().children().get(2);
					if (waiting != null)
					{
						$(waiting).css({display:"none"});
					}
				}

				com.LeadTran.Utils.DisableSelection(parent);
				com.LeadTran.Utils.DisableSelection(tagspan);


				var index = 0;
				$(panel).children().each(function(i,item)
				{
					com.LeadTran.Utils.DisableSelection(item);
					if($(item).attr("default") != undefined){
						defaults.push(item);
					}
					if($(item).attr("selected") != undefined){ index = i; }
					
					item.onclick = function()
					{
						try{clickItem(this);}catch(ev){}
					};
				});

				self.setIndex(index);
				self.hide();

				if(defaults.length > 0){
					div = $('<div class="sg_sel_items" value="" >---------------------</div>');
					self.addElementByIndex(div,0)
					$.each(defaults, function(index, value) { 
		  				self.addElementByIndex(value,0);
					});
				}
				
				var zindex = 9999 - $(parent).position().top;
				$(panel).css({"overflow-x":"hidden","overflow-y":"auto","position":"absolute","z-index":zindex});
				
				$(parent).get(0).onclick = function(){clickSelect(this);};
				$(document).click(function(e){clickDocument(e);});
				$(window).resize(function(){resize()});
				
				$(panel).get(0).onmouseover = function(){try{objectSelect = true;}catch(ev){}};
				$(parent).get(0).onmouseover = function(){try{objectSelect = true;}catch(ev){}};
				$(panel).get(0).onmouseout = function(){try{objectSelect = false;}catch(ev){}};
				$(parent).get(0).onmouseout = function(){try{objectSelect = false;}catch(ev){}};


				$(document).keypress(function(e){try{keypress(panel, String.fromCharCode(e.which));}catch(error){}});

			}
		}catch(error){}
	}
	this.removeElementByIndex = function(index)
	{
		try{
			 if (index >= 0 && this.size() > index){
				item = getElement[index];
				$(item).remove();
				return true;
			}
		}catch(error){} 
		return false;
	}
	this.addElementByIndex = function(Element,index)
	{
		try{
			
			if(this.size() > index && Element != null){
				
				ref = this.getElement(index);
				
				$(Element).insertBefore(ref);
				return true;
			}
		}catch(error){} 
		return false;
	}
	this.getElement = function(index){
		try{
			return $(panel).children().get(index);
		}catch(error){} 
		return null;
	}
	this.size = function(){
		try{
			return $(panel).children().length;
		}catch(error){} 
		return 0;
	}
	this.setIndex = function(index){
		try 
		{
			if($(panel).children().length > index){
				change($(panel).children().get(index));
			}
		}catch(error){} 
	}
	
	this.show = function(){
		try 
		{
			if ((panel != null) && (disabled_select == false))
			{
				var ScrollTop = $(window).scrollTop();
				var posDoc = $(parent).position();
				var posScreen = Object();
				posScreen.top = posDoc.top-ScrollTop;	
				posScreen.left = posDoc.left;

				var bottomDS = $(window).height()+ScrollTop;

				var HeigthScreen = $(window).height()
				var HeigthPanel = $(panel).height();
				var ParentWidth = $(parent).innerWidth();
				var ParentHeight = $(parent).height();

				var maxHeight = 100;
				var sizeBottom = 10;				

				var maxTopHeight = 200;
				
				var minHeight = maxTopHeight<HeigthPanel?maxTopHeight:HeigthPanel;

				var Top = "";

				var Height="";

				if((HeigthScreen - ParentHeight - posScreen.top) < maxHeight){
					Top = posDoc.top-minHeight-1;
					Height = minHeight+"px";

					maxHeight = (bottomDS - Top - sizeBottom);
				}else{
					Top = posDoc.top+ParentHeight;
					Height = "auto";
					maxHeight = (bottomDS - Top - sizeBottom);
				}
				

				$(panel).css({'top': Top+'px','left': posDoc.left+'px','max-height': maxHeight+'px','height': Height,'width':ParentWidth+'px',"overflow-y":"auto",'display': 'block'});
				isvisible = true;

			}
		}catch(error){} 
	}

	this.hide = function(){
		try{
			$(panel).css({"max-height":"none","height":"auto","display":"none"});
			isvisible = false;
		}catch(error){}
	}
	
	this.setItems = function(value)
	{
		try
		{
			if ((value != null) && (value != ""))
			{
				$(input).val("");
				
				$(panel).html(value);
				
				defaults = new Array();
				var index=0;
				$(panel).children().each(function(i, item)
				{
					com.LeadTran.Utils.DisableSelection(item);
					if($(item).attr("default") != undefined){
						defaults.push(item);
					}
					if($(item).attr("selected") != undefined){ index = i; }
					item.onclick = function()
					{
						try
						{
							clickItem(this);
						}catch(ev){}
					};
				});
				if(defaults.length > 0){
					div = $('<div class="sg_sel_items" value="" >---------------------</div>');
					self.addElementByIndex(div,0)
					$.each(defaults, function(index, value) { 
		  				self.addElementByIndex(value,0);
					});
				}
				self.setIndex(index);
				self.hide();
			}
		}catch(error){}
	}

	this.clearValue = function()
	{
		try
		{
			$(input).val("");
			$(tagspan).html("");
		}catch(e){}
	}

	this.showWaiting = function()
	{
		try
		{
			if ((parent != null) && (waiting != null) && (com.LeadTran.Utils.IsVisibleElement(parent) == true) && (com.LeadTran.Utils.IsVisibleElement(waiting) == false))
			{
				waiting.style.display = ((waiting_display != "") && (waiting_display != "none")) ? waiting_display : "block";
				waiting_display = com.LeadTran.Utils.GetStyle(waiting, "display");
			}
		}catch(e){}
	}
	
	this.hideWaiting = function()
	{
		try
		{
			if ((parent != null) && (waiting != null) && (com.LeadTran.Utils.IsVisibleElement(parent) == true) && (com.LeadTran.Utils.IsVisibleElement(waiting) == true))
			{
				waiting.style.display = "none";
			}
		}catch(e){}
	}

	this.disabled = function(disabled)
	{
		try
		{
			if (disabled == true)
			{
				if (disabled_select == false)
				{
					this.hide();
					if (tagspan != null)
					{
						tagspan_color = tagspan.style.color;
						tagspan.style.color = "#cfcfcf";
					}
					
					disabled_select = true;
				}
			}
			else
			{
				if (disabled_select == true)
				{
					if (tagspan != null)
					{
						tagspan.style.color = tagspan_color;
						tagspan_color = "";
					}
					
					disabled_select = false;
				}
			}
		}catch(e){}
	}

	this.isDisabled = function()
	{
		return disabled_select;
	}

	this.isVisible = function()
	{
		return com.LeadTran.Utils.IsVisibleElement(parent);
	}

	this.selectByValue = function(value)
	{
		try
		{
			if ((value != null)  && (this.size() > 0))
			{
				items = $(panel).children();
				for(var i in items)
				{
					if ((items[i] != null) && (com.LeadTran.Utils.GetAttribute(items[i], "value") == value))
					{
						change(items[i]);
						return true;
					}
				}
			}
		}catch(e){}
		
		return false;
	}

	function change(control){
		try{
			if(control == undefined)
				return;

			$(tagspan).html($(control).html());
			
			self.text = $(control).html();

			if($(control).attr("value") != undefined){
				self.value = $(control).attr("value");
			}else{
				self.value = $(control).html();
			}

			$(input).val(self.value);

			if(self.onchange != null && typeof(self.onchange) == "function" && lastItem != control){
				try{
				self.onchange(self);
				}catch(e){}
			}
			
			lastItem = control;
			self.hide();
		}catch(error){}
	}
	
	function clickItem(item){
		try{
			change(item);
			objectSelect = false;
		}catch(error){}
	}

	function clickSelect(item)
	{
		try{
			if(!isvisible){
				self.show();
			}else{
				self.hide();
			}
		
			try{
				if (self.onclick != null && typeof(self.onclick) == "function")
				{
					self.onclick(self);
				}
			}catch(error){}
			
			//e.stopPropagation();
		}catch(error){}
	}

	function clickDocument(e){
		try{
			if(isvisible && !objectSelect){
				self.hide();
			}
		}catch(error){}
	}

	function resize(){
		try{
			if (isvisible && !resizing && (disabled_select == false))
			{	
				resizing = true;
				self.hide();
				self.show();
				resizing = false;
			}
		}catch(error){}
	}
	
	function keypress(control, text){
		try{
			if ((!objectSelect) || (disabled_select == true)){ return false; }
			
			var patron = new RegExp("^"+text+".*$","i");
			
			if(text == lastKey){
				lindex = $(control).children().length;
				end = true;
				for(i = lastElement;i<lindex;i++){
					value = self.getElement(i);
					if(patron.test($(value).html()) && i != lastElement){
						lastElement = i;
						$(control).scrollTop((i)*$(value).innerHeight());
						end=false;
						return false;
					}
				}
				if(end){
					lastKey = "";
				}
			}
			if(text != lastKey)
			{
				lastKey = text;
				$(control).children().each(function(i,value){
					if(patron.test($(value).html()) && i != lastElement){
						lastElement = i;
						$(control).scrollTop((i)*$(value).innerHeight());
						return false;
					}
				});
			}
		}catch(error){}
		return true;
	}

	function isDefault(Element){
		try{
			ret = false;
			if(defaults != null && Element != null){
				$.each(defaults, function(index, value) { 
					if(value == Element){
						ret = true
						return false;
					}
				});
			}
		}catch(error){}
			return ret;
	}

	Constructor();
}

com.LeadTran.EventArgs = {
	Each: function()
	{
		this.target = null;
		this.remove = false;
		this.dispose = false;
		this.level = 1;
		this.cancel = false;
	}
}

com.LeadTran.HTML = {
	Length: function(element, all)
	{
		try
		{
			if ((com.LeadTran.Utils.iselement(element) == true) && (element.childNodes != null) && (element.childNodes.length > 0))
			{
				if ((all != null) && (typeof all == "boolean") && (all == true))
				{
					return element.childNodes.length;
				}
				else
				{
					var count = 0;
					var node = null;
					
					for(var i = 0; i < element.childNodes.length; i++)
					{
						node = element.childNodes[i];
						if (com.LeadTran.Utils.iselement(node) == true)
						{
							count++;
						}
					}
					
					return count;
				}	
			}
		}catch(e){}
		
		return 0;
	},	
	GetAttribute: function(element, attributename)
	{
		try
		{
			if ((element != null) && (attributename != null) && (attributename != ""))
			{
				var value = element.getAttribute(attributename);
				if (value != null)
				{
					return value;
				}
			}
		}catch(e){}
		
		return "";
	},
	RemoveElement: function(element)
	{
		try
		{
			if ((element != null) && (element.parentNode != null))
			{
				element.parentNode.removeChild(element);
			}
		}catch(e){}
	},
	AddElement: function(element, elementparent)
	{
		try
		{
			if ((element != null) && (elementparent != null))
			{
				elementparent.appendChild(element);
			}
		}catch(e){}
	},
	InsertElementAt: function(element, elementparent, index, force)
	{
		try
		{
			var Utils = com.LeadTran.Utils;
			if (Utils.iselement(element) && Utils.iselement(elementparent) && (elementparent.childNodes != null) && com.LeadTran.Utils.isnumber(index) && (index >= 0) && (((force != null) && (typeof force == "boolean")) || (("parentNode" in element) && (element.parentNode != elementparent))))
			{
				var length = com.LeadTran.HTML.Length(elementparent);
				
				if ((length == 0) || (index >= length))
				{
					elementparent.appendChild(element);
				}
				else 
				{
					var node = null;
					var count = 0;
					
					for(var i = 0; i < elementparent.childNodes.length; i++)
					{
						node = elementparent.childNodes[i];
						if (com.LeadTran.Utils.iselement(node) == true)
						{
							if (index == count)
							{
								elementparent.insertBefore(element, node);
								break;
							}
							
							count++;
						}
					}
				}
			}
		}catch(e){}
	},
	Each: function(element, settings)
	{
		try
		{
			if ((com.LeadTran.Utils.iselement(element) == true) && (com.LeadTran.Utils.isobject(settings) == true))
			{
				var callback = (("callback" in settings) && (com.LeadTran.Utils.isfunction(settings.callback) == true)) ? settings.callback : null;
				var recursive = (("recursive" in settings) && (settings.recursive != null) && (typeof settings.recursive == "boolean")) ? settings.recursive : false;
				var all = (("all" in settings) && (settings.all != null) && (typeof settings.all == "boolean")) ? settings.all : false;
				var reverse = (("reverse" in settings) && (settings.reverse != null) && (typeof settings.reverse == "boolean")) ? settings.reverse : false;
				
				if ((com.LeadTran.HTML.Length(element, all) > 0) && (callback != null))
				{
					var node = null;
					var count = 0;
					var args = new com.LeadTran.EventArgs.Each();
					var level = (("level" in settings) && com.LeadTran.Utils.isnumber(settings.level) && (settings.level > 0)) ? settings.level : 1;
					
					function RetrieveItem(i)
					{
						var reduceIndex = false;
						
						try
						{
							node = element.childNodes[i];
							if ((all == true) || (com.LeadTran.Utils.iselement(node) == true))
							{
								try
								{
									args.target = node;
									args.remove = false;
									args.dispose = false;
									args.level = level;
									args.cancel = false;
									
									callback.call(args, node, count);
								}catch(ev){}
								
								if (com.LeadTran.Utils.isobject(args) == true)
								{
									if (((args.remove == true) || (args.dispose == true)))
									{
										com.LeadTran.HTML.RemoveElement(node);
										if (args.dispose == true) delete node;
										node = null;
										
										if (reverse == false)
										{
											reduceIndex = true;
										} 
									}
									
									if (args.cancel == true) return false;
								}
								
								if (node != null)
								{
									count++;
									
									if ((recursive == true) && ("childNodes" in node) && (node.childNodes != null) && ("length" in node.childNodes) && (node.childNodes.length > 0))
									{
										settings.level = level + 1;
										if (com.LeadTran.HTML.Each(node, settings) == false)
										{
											return false;
										}
									}
								}	
							}
						}catch(en){}
						
						return reduceIndex;
					}
					
					if (reverse == true)
					{
						for(var i = element.childNodes.length; i >= 0; i--)
						{
							RetrieveItem(i);
						}
					}
					else
					{
						for(var i = 0; i < element.childNodes.length; i++)
						{
							if (RetrieveItem(i) == true)
							{
								i--;
							}
						}
					}
				}	
			}
		}catch(e){}
		
		return true;
	}
}

com.LeadTran.DOM = {
	TextPosition: function(start, end)
	{
		this.start = ((start != null) && (isNaN(start) == false)) ? start : 0;
		this.end = ((end != null) && (isNaN(end) == false)) ? end : 0;
	},
	Textarea: {
		extend: function(element)
		{
			try
			{
				if (this.is(element) == true)
				{
					if (("selectedText" in element) == false) element.selectedText = "";
					if (("selectedTextStart" in element) == false) element.selectedTextStart = 0;
					if (("selectedTextEnd" in element) == false) element.selectedTextEnd = 0;
					if (("oncustomselection" in element) == false) element.oncustomselection = null;
					
					var OnSelectedText = function()
					{
						try
						{
							var position = com.LeadTran.DOM.Textarea.getSelectionPosition(this);
							var text = com.LeadTran.DOM.Textarea.getSelectedText(this);
							
							this.selectedText = text;
							this.selectedTextStart = position.start;
							this.selectedTextEnd = position.end;
						}catch(e){};	
					};
					
					com.LeadTran.DOM.addEventListener(element, "keydown", OnSelectedText);
					com.LeadTran.DOM.addEventListener(element, "keyup", OnSelectedText);
					com.LeadTran.DOM.addEventListener(element, "mousedown", OnSelectedText);
					com.LeadTran.DOM.addEventListener(element, "mouseup", OnSelectedText);
					com.LeadTran.DOM.addEventListener(element, "mousemove", OnSelectedText);
					com.LeadTran.DOM.addEventListener(element, "change", OnSelectedText);
					
					com.LeadTran.DOM.addEventListener(element, "dblclick", function()
					{
						try
						{
							if (("oncustomselection" in this) && (this.oncustomselection != null) && (typeof this.oncustomselection == "function"))
							{
								var position = new com.LeadTran.DOM.TextPosition();
								position.start = null;
								position.end = null;
								
								this.oncustomselection.call(this, position);
								
								if (position != null)
								{
									var start = null;
									var end = null;
									
									if (("start" in position) && (position.start != null) && (isNaN(position.start) == false) && (position.start != this.selectedTextStart)) start = position.start;
									if (("end" in position) && (position.end != null) && (isNaN(position.end) == false) && (position.end != this.selectedTextEnd)) end = position.end;
									if ((start != null) || (end != null)) com.LeadTran.DOM.Textarea.setSelection(this, (start != null) ? start : this.selectedTextStart, (end != null) ? end : this.selectedTextEnd);
								}
							}
						}catch(e){}
					});
				}
			}catch(e){}
		},
		is: function(element)
		{
			try
			{
				if ((element != null) && ("nodeName" in element) && (element.nodeName != null) && (element.nodeName.toLowerCase() == "textarea"))
				{
					return true;
				}
			}catch(e){}
			
			return false;
		},
		insertTextAtPosition: function(element, text, startposition)
		{
			try
			{
				if ((this.is(element) == true) && (text != null))
				{
					var scrollPos = element.scrollTop;
					var strPos = 0;
					
					if ((startposition != null) && (isNaN(startposition) == false) && (startposition >= 0))
					{
						strPos = startposition;
					}
					else
					{
						strPos = this.getCaretPosition(element);
					}
					
					var front = (element.value).substring(0, strPos);
					var back = (element.value).substring(strPos, element.value.length);
					element.value = front + text + back;
					
					this.setCaretPosition(element, strPos + text.length);
					
					element.scrollTop = scrollPos;
				}
			}catch(e){}
		},
		getTextAtPosition: function(element, start, end)
		{
			try
			{
				if ((this.is(element) == true) && (start != null) && (isNaN(start) == false) && (end != null) && (isNaN(end) == false) && (end > start))
				{
					return (element.value).substring(start, end);
				}
			}catch(e){}
			
			return "";
		},
		getSelectedText: function(element)
		{
			try
			{
				if (this.is(element) == true)
				{
					var position = this.getSelectionPosition(element);
					return this.getTextAtPosition(element, position.start, position.end);
				}
			}catch(e){}
			
			return "";
		},
		replaceSelectedText: function(element, text)
		{
			try
			{
				if ((this.is(element) == true) && (text != null))
				{
					var scrollPos = element.scrollTop;
					var position = null;
					
					if (("selectedTextStart" in element) && ("selectedTextEnd" in element))
					{
						position = new com.LeadTran.DOM.TextPosition(element.selectedTextStart, element.selectedTextEnd);
					}
					else
					{
						position = this.getSelectionPosition(element);
					}
					
					var start = (element.value).substring(0, position.start);
					var end = (element.value).substring(position.end, element.value.length);
					
					element.value = start + text + end;
					element.scrollTop = scrollPos;
					
					this.setCaretPosition(element, position.start + text.length);
				}
			}catch(e){}
		},
		getCaretPosition: function(element)
		{
			try
			{
				if (this.is(element) == true)
				{
					return this.getSelectionPosition(element).start;
				}
			}catch(e){}
			
			return 0;
		},
		setCaretPosition: function(element, startposition)
		{
			try
			{
				if ((this.is(element) == true) && (startposition != null) && (isNaN(startposition) == false))
				{
					if ((element.selectionStart != null) && (element.selectionEnd != null))
					{
						element.focus();
						element.setSelectionRange(startposition, startposition);
					}
					else if (element.createTextRange != null)
					{
						var range = element.createTextRange();
						range.move('character', startposition);
						range.select();
						element.focus();
					}
					else
					{
						element.focus();
					}
					
					if (("selectedTextStart" in element) == true) element.selectedTextStart = startposition;
					if (("selectedTextEnd" in element) == true) element.selectedTextEnd = startposition;
					if (("selectedText" in element) == true) element.selectedText = "";
				}
			}catch(e){}
		},
		getSelectionPosition: function(element)
		{
			var position = new com.LeadTran.DOM.TextPosition();
			
			try
			{
				if (this.is(element) == true)
				{
					if ((element.selectionStart != null) && (element.selectionEnd != null))
					{
						position.start = element.selectionStart;
						position.end = element.selectionEnd;
					}
					else if ((document.selection != null) && (element.createTextRange != null))
					{
						element.focus();

						var range = document.selection.createRange();
						if (range != null)
						{
							var textrange = element.createTextRange();
							var textrangeclone = textrange.duplicate();
							
							textrange.moveToBookmark(range.getBookmark());
							textrangeclone.setEndPoint('EndToStart', textrange);
							position.start = textrangeclone.text.length;
							position.end = textrangeclone.text.length + range.text.length;
						}
					}
				}
			}catch(e){}
			
			return position;
		},
		setSelection: function(element, start, end)
		{
			try
			{
				if ((this.is(element) == true) && (start != null) && (isNaN(start) == false) && (end != null) && (isNaN(end) == false) && (end > start))
				{
					if ((element.selectionStart != null) && (element.selectionEnd != null))
					{
						element.focus();
						element.setSelectionRange(start, end);
						
						if (("selectedTextStart" in element) == true) element.selectedTextStart = start;
						if (("selectedTextEnd" in element) == true) element.selectedTextEnd = end;
						if (("selectedText" in element) == true) element.selectedText = this.getSelectedText(element);
					}
					else if (element.createTextRange != null)
					{
						var textrange = element.createTextRange ();
		                textrange.moveStart ("character", start);
		                textrange.collapse ();
		                textrange.moveEnd ("character", end - start);
		                textrange.select ();
						element.focus();
						
						if (("selectedTextStart" in element) == true) element.selectedTextStart = start;
						if (("selectedTextEnd" in element) == true) element.selectedTextEnd = end;
						if (("selectedText" in element) == true) element.selectedText = this.getSelectedText(element);
					}
				}
			}catch(e){}
		}
	},
	addEventListener: function(element, eventname, event)
	{
		try
		{
			if ((element != null) && (eventname != null) && (eventname != "") && (event != null) && (typeof event == "function"))
			{
				eventname = str_trim(eventname);
				
				if (eventname != "")
				{
					if (element.addEventListener != null)
					{
						if ((str_startwith(eventname, "on") == true) && (eventname.length > 2)) eventname = eventname.substring(2, eventname.length);
						element.addEventListener(eventname, event, false);
					}
					else
					{
						if (str_startwith(eventname, "on") == false) eventname = "on" + eventname;
						
						if (element.attachEvent != null)
						{
							var eventfunction = function()
							{
								try
								{
									event.call(element);
								}catch(ev){}
							};
							
							element.attachEvent(eventname, eventfunction);
							
							window.attachEvent('onunload', function()
							{
								element.detachEvent(eventname, eventfunction);
							});
						}
						else
						{
							element[eventname] = event;
						}
					}
				}	
			}
		}catch(e){}
	},
	Swap: function(element, settings, callback, elementparent)
	{
		try
		{
			var Utils = com.LeadTran.Utils;
			
			if (Utils.iselement(element) && Utils.isfunction(callback))
			{
				var oldstyle = {};
				var append = false;
				
				if (Utils.isobject(settings))
				{
					for(var key in settings)
					{
						try
						{
							oldstyle[key] = element.style[key];
							element.style[key] = settings[key];
						}catch(ep){}
					}
				}
				
				if ((Utils.iselement(element.parentNode) == false) && (Utils.iselement(elementparent)))
				{
					if (("index" in element) && (Utils.empty_number(element.index) == false))
					{
						com.LeadTran.HTML.InsertElementAt(element, elementparent, element.index, true);
					}
					else
					{
						com.LeadTran.HTML.AddElement(element, elementparent, true);
					}
					
					append = true;
				}
				
				try
				{
					callback.call(element);
				}catch(ev){}
				
				if (Utils.isobject(settings))
				{
					for(var key in settings)
					{
						try
						{
							element.style[key] = oldstyle[key];
						}catch(ep){}
					}
				}
				
				if (append == true)
				{
					com.LeadTran.HTML.RemoveElement(element);
				}
				
				delete oldstyle;
			}
		}catch(e){}
	}
}

com.LeadTran.Number = {
	GetRandom: function(size)
	{
		try
		{
			if ((size != null) && (isNaN(size) == false))
			{
				return Math.floor(size * Math.random());
			}
		}catch(e){}
		
		return Math.floor(100 * Math.random());
	},
	GetRandomUsingDate: function(size)
	{
		try
		{
			if ((size != null) && (isNaN(size) == false))
			{
				return new Date().getTime() + this.GetRandom(size);
			}
			else
			{
				return new Date().getTime();
			}
		}catch(e){}
		
		return this.GetRandom(size);
	}
}

com.LeadTran.Object = {
	RemoveProperty: function(element, value)
	{
		try
		{
			if ((element != null) && (typeof element == "object") && (value != null) && (value in element))
			{
				delete element[value];
			}
		}catch(e){}
	},
	Clone: function(element)
	{
		try
		{
			if ((element != null) && (typeof element == "object"))
			{
				var newobject = {};
				
				function add(parent, properties)
				{
					try
					{
						if ((parent != null) && (typeof parent == "object") && (properties != null) && (typeof properties == "object"))
						{
							for(var key in properties)
							{
								try
								{
									if (properties[key] != null)
									{
										if (typeof properties[key] == "object")
										{
											parent[key] = {};
											
											add(parent[key], properties[key]);
										}
										else
										{
											parent[key] = properties[key];
										}
									}
									else
									{
										parent[key] = null;
									}
								}catch(e){}
							}
						}	
					}catch(e){}
				}
				
				add(newobject, element);
				
				return newobject;
			}
		}catch(e){}
		
		return null;
	}
}

com.LeadTran.Net = {
	Guid: 1,
	RequestState: {
		READY_STATE_UNINITIALIZED: 0,
	    READY_STATE_LOADING: 1,
	    READY_STATE_LOADED: 2,
	    READY_STATE_INTERACTIVE: 3,
	    READY_STATE_COMPLETE: 4
	},
	Utils: {
		CreateGuid: function(json)
		{
			try
			{
				if (("Guid" in com.LeadTran.Net) == false) com.LeadTran.Net["Guid"] = 1;
			}catch(e){}
			
			try
			{
				if ((json != null) && (json == true) && ("JSON" in com.LeadTran.Net) && (com.LeadTran.Net.JSON != null) && (typeof com.LeadTran.Net.JSON == "object"))
				{
					var guid = -1;
					var attempts = 0;
					var permitattempts = 1000;
					
					try
					{
						while(true)
						{
							if (("CallBack" in com.LeadTran.Net.JSON) == false)
							{
								guid = (com.LeadTran.Net.Guid++) + "" + com.LeadTran.Number.GetRandomUsingDate();
								break;
							}
							else
							{
								guid = (com.LeadTran.Net.Guid++) + "" + com.LeadTran.Number.GetRandomUsingDate();
								
								if ((guid in com.LeadTran.Net.JSON.CallBack) == false)
								{
									break;
								}
							}
							
							attempts++;
							if (attempts >= permitattempts) break;
						}
					}catch(eg){}
					
					if (guid != -1) return guid;
				}
			}catch(e){}
			
			return (com.LeadTran.Net.Guid++) + "" + com.LeadTran.Number.GetRandomUsingDate();;
		},
		HasURLParams: function(url)
		{
			try
			{
				if ((url != null) && (url != ""))
				{
					return /\?/.test(url);
				}
			}catch(e){}
			
			return false;
		},
		SendAsync: function(settings, json)
	    {
	        try
	        {
	            if ((settings != null) && (typeof settings == "object"))
				{
					if (("url" in settings) && (str_trim(settings.url) != ""))
					{
						var oSuccess = (("success" in settings) && (settings.success != null) && (typeof settings.success == "function")) ? settings.success : null;
						var oError = (("error" in settings) && (settings.error != null) && (typeof settings.error == "function")) ? settings.error : null;
						var oParams = (("data" in settings) && (settings.data != null) && (typeof settings.data == "object")) ? settings.data : null;
						var sType = (("type" in settings) && (settings.type != null) && (str_trim(settings.type) != "")) ? str_trim(settings.type) : "";
						var oArg = (("arg" in settings) && (settings.arg != null)) ? settings.arg : null;
						var bUseJSON = ((json != null) && (json == true)) ? true : false;
						var oRequest = null;
						var oData = null;
						var sParams = "";
						var iNoCached = com.LeadTran.Net.Utils.CreateGuid();
						
						if (window.XMLHttpRequest)
						{
							oRequest = new XMLHttpRequest();
						}
						else
						{
							oRequest = new ActiveXObject("Microsoft.XMLHTTP");
						}
						
						if (oRequest != null)
						{
							if (oParams == null) oParams = {};
							
							oParams["incclnus" + iNoCached] = "NoCached";
							
							sParams = (oParams != null) ? com.LeadTran.Net.Params.parseObject(oParams) : "";
							
							oRequest.onreadystatechange = function()
				            {
				                if (this.readyState == com.LeadTran.Net.RequestState.READY_STATE_COMPLETE)
				                {
				                    if ((this.status == 200) || (this.status == 0))
				                    {
				                        try
										{
											if (bUseJSON == true)
											{
												eval("oData = " + this.responseText + ";");
												
												if ((oData != null) && (typeof oData != "object"))
												{
													oData = null;
												}
											}
										}catch(e){}
										
										try
				                        {
											if (bUseJSON == true)
											{
												if (oData == null)
												{
													if (oError != null) oError.call(oRequest, oArg);
												}
												else
												{
													if (oSuccess != null) oSuccess.call(oRequest, oData, oArg);
												}
											}
											else
											{
												if (oSuccess != null) oSuccess.call(oRequest, oArg);
											}
				                        }catch(e){}
										
										try
										{
											delete oRequest;
										}catch(e){}
				                    }
				                    else
				                    {
				                        try
				                        {
				                            if (oError != null) oError.call(oRequest, oArg);
				                        }catch(e){}
										
										try
										{
											delete oRequest;
										}catch(e){}
				                    }
				                }
				            };
							
							if ((sType == "") || (sType.toLowerCase() == "get"))
							{
								if (sParams != "")
								{
									if (com.LeadTran.Net.Utils.HasURLParams(settings.url) == true)
									{
										settings.url += "&" + sParams;
									}
									else
									{
										settings.url += "?" + sParams;
									}
								}
								
								oRequest.open('GET', settings.url, true);
								oRequest.send(null);
							}
							else
							{
								oRequest.open('POST', settings.url, true); 
								oRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
								oRequest.send(sParams);
							}
						}
					}
				} 
	        }catch(e){}
	    }
	},
	Params: {
		parseObject: function(element)
		{
			try
			{
				if ((element != null) && (typeof element == "object"))
				{
					function parse(prefix, params)
					{
						var value = "";
						var result = "";
						
						try
						{
							if ((params != null) && (typeof params == "object"))
							{
								prefix = ((prefix != null) && (prefix != "")) ? prefix : "";
								
								for(var key in params)
								{
									try
									{
										if (params[key] != null)
										{
											if (typeof params[key] == "object")
											{
												result = parse((prefix == "" ? encodeURIComponent(key) : prefix + "[" + encodeURIComponent(key) + "]"), params[key]);
												if (result != "")
												{
													value += (value != "" ? "&" : "") + result;
												}
											}
											else if (typeof params[key] == "function")
											{
												result = "";
												
												try
												{
													result = params[key].call();
												}catch(e){}
												
												if (result != null)
												{
													switch(typeof result)
													{
														case "string":
														case "number":
														case "boolean":
															value += (value != "" ? "&" : "") + (prefix == "" ? encodeURIComponent(key) : prefix + "[" + encodeURIComponent(key) + "]") + "=" + encodeURIComponent(result);
															break;
													}
												}
											}
											else
											{
												switch(typeof params[key])
												{
													case "string":
													case "number":
													case "boolean":
														value += (value != "" ? "&" : "") + (prefix == "" ? encodeURIComponent(key) : prefix + "[" + encodeURIComponent(key) + "]") + "=" + encodeURIComponent(params[key]);
														break;
												}
											}
										}
									}catch(e){}
								}
							}	
						}catch(e){}
						
						return value;
					}
					
					return parse("", element);
				}
			}catch(e){}
			
			return "";
		}
	},
	JSON: {
		CallBack: {},
		CrossDomain: function(settings)
		{
			try
			{
				if ((settings != null) && (typeof settings == "object"))
				{
					if (("url" in settings) && (str_trim(settings.url) != ""))
					{
						var oHead = document.getElementsByTagName('head')[0] || document.documentElement;
						if (oHead != null)
						{
							if (("CallBack" in com.LeadTran.Net.JSON) == false) com.LeadTran.Net.JSON["CallBack"] = {};
							
							var oSuccess = (("success" in settings) && (settings.success != null) && (typeof settings.success == "function")) ? settings.success : null;
							var oError = (("error" in settings) && (settings.error != null) && (typeof settings.error == "function")) ? settings.error : null;
							var sParams = (("data" in settings) && (settings.data != null) && (typeof settings.data == "object")) ? com.LeadTran.Net.Params.parseObject(settings.data) : "";
							var iCallBack = com.LeadTran.Net.Utils.CreateGuid(true);
							var sCallBack = "ltcb" + iCallBack;
							var oData = null;
							var bExecute = false;
							var oScript = document.createElement("script");
							
							oScript.type= "text/javascript";
							settings.url = settings.url.replace("=?", "=" + encodeURIComponent("com.LeadTran.Net.JSON.CallBack." + sCallBack));
							
							if (sParams != "")
							{
								if (com.LeadTran.Net.Utils.HasURLParams(settings.url) == true)
								{
									settings.url += "&" + sParams;
								}
								else
								{
									settings.url += "?" + sParams;
								}
							}
							
							com.LeadTran.Net.JSON.CallBack[sCallBack] = function(data)
							{
								bExecute = true;
								
								try
								{
									oData = com.LeadTran.Object.Clone(data);
									if (oSuccess != null) oSuccess.call(this, oData);
								}catch(e){}
								
								cleanScript();
							};
							
							oScript.onload = oScript.onreadystatechange = function()
							{
								try
								{
									if ("readyState" in this)
									{
										if ((this.readyState == "complete") || (this.readyState == "loaded"))
										{
											if (bExecute == false)
											{
												try
												{
													if (oError != null) oError.call(this);
												}catch(e){}
												
												cleanScript();
											}
										}
									}
									else
									{
										if (bExecute == false)
										{
											try
											{
												if (oError != null) oError.call(this);
											}catch(e){}
											
											cleanScript();
										}
									}
								}catch(e){}
							};
							
							oScript.onerror = oScript.onabort  = function()
							{
								try
								{
									if (oError != null) oError.call(this);
								}catch(e){}
								
								cleanScript();
							};
							
							function cleanScript()
							{
								try
								{
									oScript.onload = oScript.onreadystatechange = null;
									oScript.onerror = oScript.onabort = null;
									com.LeadTran.HTML.RemoveElement(oScript);
									com.LeadTran.Object.RemoveProperty(com.LeadTran.Net.JSON.CallBack, sCallBack);
								}catch(e){}
								
								try
								{
									delete oScript;
								}catch(e){}
							};
							
							oScript.src = settings.url;
							
							com.LeadTran.HTML.AddElement(oScript, oHead);
						}
					}
				}
			}catch(e){}
		},
		SendAsync: function(settings)
	    {
			try
			{
				com.LeadTran.Net.Utils.SendAsync(settings, true);
			}catch(e){}
	    }
	},
	SendAsync: function(settings)
    {
        try
		{
			com.LeadTran.Net.Utils.SendAsync(settings, false);
		}catch(e){}
    }
}

com.LeadTran.Menu = function(control)
{
	var oTopSection = null;
	var oSections = {};
	var self = this;
	var moving = false;
	var bounds = null;
	var window_onresize = null;
	
	var itemClicksArgs = function()
	{
		this.cancel = false;
	}
	this.onitemclick = null;
	
	function Constructor()
	{
		try 
		{	
			if ((control != null) && (control.childNodes != null) && (control.childNodes.length > 0))
			{
				var oNode = null;
				var oLastSeccion = null;
				var iSections = 0;
				var sLink = "";
				
				for (var i = 0; i < control.childNodes.length; i++)
				{
					try
					{
						oNode = control.childNodes[i];
						if ((oNode != null) && (oNode.nodeName != null) && (oNode.nodeName != "") && (oNode.nodeName.toLowerCase() == "div"))
						{
							com.LeadTran.Utils.DisableSelection(oNode);
							
							if ((oNode.className != null) && (oNode.className != "menuGroupItems"))
							{
								switch(oNode.className)
								{
									case "menuTop":
										oNode.menutype = "top";
										
										sLink = com.LeadTran.Utils.GetAttribute(oNode, "href");
										if (sLink != "")
										{
											oNode.link = sLink;
											oNode.onclick = gotoLink;
										}
										
										oTopSection = oNode;
										break;
									
									case "menuSectionUp":
									case "menuSectionDown":
										oNode.menutype = "section";
										oNode.visible = false;
										oNode.onclick = OnSectionClick;
										oSections[iSections] = oNode;
										oLastSeccion = oNode;
										oLastSeccion.items = {};
										oLastSeccion.container = null;
										iSections++;
										break;
								}
							}
							else
							{
								createItems(oLastSeccion, oNode);
							}
						}
					}catch(en){}
				}
				
				var WebBrowser = com.LeadTran.Utils.BrowserDetect.browser.toLowerCase();
				var WebBrowserVersion = com.LeadTran.Utils.BrowserDetect.version;
				if (("parentNode" in control) && (control.parentNode != null) && ("parentNode" in control.parentNode) && (control.parentNode.parentNode != null) && (WebBrowser == "explorer") && (isNaN(WebBrowserVersion) == false) && (WebBrowserVersion == 7.0))
				{
					moving = false;
					bounds = com.LeadTran.Utils.GetElementBounds(control.parentNode.parentNode);
					com.LeadTran.Utils.CSS.SetElementValue("#mainLeft", "left", bounds.left + "px");
					
					window_onresize = (("onresize" in window) && (window.onresize != null)) ? window.onresize : null;
					window.onresize = function()
					{
						try
						{
							if (window_onresize != null)
							{
								window_onresize.call(this);
							}
						}catch(e){}
						
						try
						{
							if (moving == false)
							{
								moving = true;
								
								var bounds = com.LeadTran.Utils.GetElementBounds(control.parentNode.parentNode);
								com.LeadTran.Utils.CSS.SetElementValue("#mainLeft", "left", bounds.left + "px");
								
								moving = false;
							}
						}catch(e){}
					}
				}
			}
		}catch(e){}
	}
	
	function createItems(section, node)
	{
		try 
		{	
			if ((section != null) && (section.items != null) && (section.container == null) && (section.menutype != null) && (section.menutype == "section") && (node != null) && (node.childNodes != null) && (node.childNodes.length > 0))
			{
				var oNode = null;
				var iItems = 0;
				var sLink = "";
				
				for (var i = 0; i < node.childNodes.length; i++)
				{
					try
					{
						oNode = node.childNodes[i];
						if ((oNode != null) && (oNode.nodeName != null) && (oNode.nodeName != "") && (oNode.nodeName.toLowerCase() == "div") && (oNode.className != null) && (oNode.className == "menuItem"))
						{				
							com.LeadTran.Utils.DisableSelection(oNode);
							
							oNode.menutype = "item";
							
							sLink = com.LeadTran.Utils.GetAttribute(oNode, "href");
							if (sLink != "")
							{
								oNode.link = sLink;
								oNode.onclick = gotoLink;
							}
							
							section.items[iItems] = oNode;
							iItems++;		
						}
					}catch(en){}
				}
				
				if (iItems > 0)
				{
					node.style.display = "none";
					section.container = node;
				}
			}
		}catch(e){}
	}
	
	function gotoLink()
	{
		try
		{
			if ((self.onitemclick != null) && (typeof self.onitemclick == "function"))
			{
				var args = new itemClicksArgs();
				
				self.onitemclick.call(self, this, args);
				
				if ((args != null) && (args.cancel == true))
				{
					return;
				}
			}
		}catch(e){}
		
		self.openLink(this);
	}
	
	this.openLink = function(item)
	{
		try
		{
			if ((item != null) && ("link" in item) && (item.link != ""))
			{
				window.location.href = item.link;
			}
		}catch(e){}
	}
	
	function OnSectionClick()
	{
		try
		{
			switch(this.menutype)
			{
				case "section":
					if (this.visible == true)
					{
						if (this.container != null)
						{
							this.className = "menuSectionDown";
							$(this.container).slideUp("fast");
							this.visible = false;
						}
					}
					else
					{
						closeSectionsExcept(this, false);
						
						if (this.container != null)
						{
							this.className = "menuSectionUp";
							$(this.container).slideDown("fast");
							this.visible = true;
						}
					}
					break;
					
				case "item":
					break;
			}
		}catch(e){}
	}
	
	function closeSectionsExcept(section, fast)
	{
		try
		{
			if ((oSections != null) && (section != null))
			{
				for(var key in oSections)
				{
					if ((oSections[key] != null) && (oSections[key] != section) && (oSections[key].container != null))
					{
						oSections[key].className = "menuSectionDown";
						
						if (fast == true)
						{
							oSections[key].container.style.display = "none";
						}
						else
						{
							$(oSections[key].container).slideUp("fast");
						}
						
						oSections[key].visible = false;
					}
				}
			}
		}catch(e){}
	}
	
	this.showSection = function(option, suboption, fast)
	{
		try
		{
			if ((option != null) && (isNaN(option) == false) && (option >= 1))
			{
				option = option - 1;
				
				if ((oSections != null) && (option in oSections) && (oSections[option] != null) && (oSections[option].container != null))
				{
					var section = oSections[option];
					closeSectionsExcept(section, fast);
					
					section.className = "menuSectionUp";
					
					if (fast == true)
					{
						section.container.style.display = "block";
					}
					else
					{
						$(section.container).slideDown("fast");
					}
					
					section.visible = true;
					
					
					if ((suboption != null) && (isNaN(suboption) == false) && (suboption >= 1))
					{
						suboption = suboption -1;
						
						if (("items" in oSections[option]) && (oSections[option].items != null) && (suboption in oSections[option].items) && (oSections[option].items[suboption] != null))
						{
							com.LeadTran.Utils.AddClass(oSections[option].items[suboption], "menuItemSelected");
						}
					}
				}
			}
		}catch(e){}
	}
	
	this.hideSection = function(option, fast)
	{
		try
		{
			if ((option != null) && (isNaN(option) == false) && (option >= 1))
			{
				option = option - 1;
				
				if ((oSections != null) && (option in oSections) && (oSections[option] != null) && (oSections[option].container != null))
				{
					var section = oSections[option];
					
					section.className = "menuSectionDown";
					
					if (fast == true)
					{
						section.container.style.display = "none";
					}
					else
					{
						$(section.container).slideUp("fast");
					}
					
					section.visible = false;
				}
			}
		}catch(e){}
	}
	
	Constructor();
}

com.LeadTran.MessageConfirm = function()
{
	var popup = null;
	var popupcontent = null;
	var otitle = null;
	var otext = null;
	var olink = null;
	var bounds = null;
	var contentbounds = null;
	var titlesize = null;
	var textsize = null;
	var linkbounds = null;
	var self = this;
	var document_keydown = null;
	var onclose = null;
	
	var result = "";
	var obuttonyes = null;
	var obuttonno = null;
	var obuttoncancel = null;
	var buttoncontainer = null;
	var buttonyesbounds = null;
	var buttonnobounds = null;
	var buttoncancelbounds = null;
	
	function Constructor()
	{
		try
		{
			
		}catch(e){}
	}
	
	function createMessage()
	{
		try
		{		
			popup = document.createElement("div");
			$(popup).attr("style", "width: 100%;background: #000000;position: fixed;top: 0;left:0;-moz-opacity:0.45;-khtml-opacity: 0.45;opacity: 0.45;filter:alpha(opacity=75);z-index:9999997;height:100%;display:none;");
			com.LeadTran.Utils.DisableSelection(popup);
			$("body").append(popup);
			
			popupcontent = document.createElement("div")
			$(popupcontent).attr("style", "font-family:Arial,Helvetica,Sans-serif;top:50%;left:50%;position: fixed; color:black; font-weight:bold;font-size:16px; z-index:9999998; cursor:default;border-radius: 6px;-moz-border-radius: 6px;-webkit-border-radius: 6px;background:white;border:2px solid #cfcfcf;-moz-opacity:0.92; -khtml-opacity: 0.92; opacity: 0.92; filter:alpha(opacity=92);display:none;box-shadow: 0px 0px 6px #000;-moz-box-shadow: 0px 0px 6px #000;-webkit-box-shadow: 0px 0px 6px #000;");
			com.LeadTran.Utils.DisableSelection(popupcontent);
			$("body").append(popupcontent);
			
			otitle = document.createElement("div");
			$(otitle).attr("style", "font-size:22px; font-weight:bold;color:#4B4B4B;text-align:center;float:left;");
			otitle.innerText = "";
			
			otext = document.createElement("div");
			$(otext).attr("style", "font-size:17px; font-weight:bold;color:#646464;text-align:center;float:left;");
			otext.innerText = "";
			
			buttoncontainer = document.createElement("div");
			$(buttoncontainer).attr("style", "float:left;text-align:center;");
			
			obuttonyes = createButton("Yes",
				function()
				{
					try
					{
						result = "yes";
						self.hide();
					}catch(ev){}
				}
			);
			
			obuttonno = createButton("No",
				function()
				{
					try
					{
						result = "no";
						self.hide();
					}catch(ev){}
				}
			);
			
			obuttoncancel = createButton("Cancel", 
				function()
				{
					try
					{
						result = "cancel";
						self.hide();
					}catch(ev){}
				}
			);
			
			$(buttoncontainer).append(obuttonyes);
			$(buttoncontainer).append(obuttonno);
			$(buttoncontainer).append(obuttoncancel);
			
			olink = document.createElement("div");
			$(olink).attr("style", "background:transparent url(/img/popup_close.png) no-repeat 0 0;width:43px;height:43px;position:fixed;left:50%;top:50%;z-index:9999999;cursor:pointer;cursor:hand;display:none;");
			$("body").append(olink);
			
			$(olink).click(
				function()
				{
					try
					{
						result = "cancel";
						self.hide();
					}catch(ev){}
				}
			);
			
			$(popupcontent).append(otitle);
			$(popupcontent).append(otext);
			$(popupcontent).append(buttoncontainer);
			
			$(popupcontent).css({
				width: "50px",
				height: "50px"
			});
		}catch(e){}
	}
	
	function createButton(text, onclick)
	{
		try
		{
			var button = document.createElement("button");
			$(button).attr("style", "min-width:80px;text-align:center;height:auto;padding:3px 1px 3px 1px;margin:0px 5px 0px 5px;font-size:14px; font-weight:bold;color:white;text-align:center;cursor:pointer;cursor:hand;border-radius: 4px;-moz-border-radius: 4px;-webkit-border-radius: 4px;background-color:#494948;box-shadow: 0px 0px 3px #000;-moz-box-shadow: 0px 0px 3px #000;-webkit-box-shadow: 0px 0px 3px #000;");
			button.innerText = (text != null) ? text : "";
			$(button).click(onclick);
			
			return button;
		}catch(e){}
		
		return null;
	}
	
	function isVisible(control)
	{
		try
		{
			if (control != null)
			{
				return com.LeadTran.Utils.GetStyle(control, "display") == "none" ? false : true;
			}
		}catch(e){}
		
		return false;
	}
	
	this.visible = function()
	{
		return isVisible(popup);
	}
	
	this.show = function(params)
	{
		try
		{
			if ((params != null) && (typeof params == "object"))
			{
				if (popup == null) createMessage();
				
				if ((popup != null) && (popupcontent != null) && ((otitle != null) || (otext != null)))
				{
					var title 	= (("title" in params) && (params["title"] != null) && (params["title"] != "")) ? params["title"] : "";
					var text 	= (("text" in params) && (params["text"] != null) && (params["text"] != "")) ? params["text"] : "";
					
					if ((title != "") || (text != ""))
					{
						var titletop	= false;
						var buttonwidth = 0;
						var buttonheight = 0;
						var buttondisplay = false;
						var width	= 0;
						var height	= 0;
						var yes 	= (("yes" in params) && (params["yes"] != null) && (params["yes"] != "")) ? params["yes"] : "";
						var no 		= (("no" in params) && (params["no"] != null) && (params["no"] != "")) ? params["no"] : "";
						var cancel 	= (("cancel" in params) && (params["cancel"] != null) && (params["cancel"] != "")) ? params["cancel"] : "";
						onclose 	= (("onclose" in params) && (params["onclose"] != null) && (typeof params["onclose"] == "function")) ? params["onclose"] : null;
						result 		= "";
						titlesize	= null;
						textsize	= null;
						buttonyesbounds = null;
						buttonnobounds = null;
						buttoncancelbounds = null;
						
						$(popupcontent).css({
							top: "-10000px",
							left: "-10000px",
							display: "block"
						});
						
						if (title != "")
						{
							otitle.style.display = "block";
							otitle.innerText = title;
							titlesize = com.LeadTran.Utils.GetTextSize(otitle.innerText, 22, "Arial,Helvetica,Sans-serif", "bold");
							titlesize.width += 40;
							height	+= titlesize.height + 16;
							titletop	= true;
						}
						else
						{
							otitle.style.display = "none";
						}
						
						if (text != "")
						{
							otext.style.display = "block";
							otext.innerText = text;
							textsize = com.LeadTran.Utils.GetTextSize(otext.innerText, 17, "Arial,Helvetica,Sans-serif", "bold");
							textsize.width += 40;
							height	+= textsize.height + ((titletop == true) ? 4 : 16);
						}
						else
						{
							otext.style.display = "none";
						}
						
						if (yes != "")
						{
							obuttonyes.style.display = "inline";
							obuttonyes.innerText = yes;
							buttonyesbounds = com.LeadTran.Utils.GetElementBounds(obuttonyes);
							buttonwidth	+= buttonyesbounds.width + 25;
							buttondisplay = true;
						}
						else
						{
							obuttonyes.style.display = "none";
						}
						
						if (no != "")
						{
							obuttonno.style.display = "inline";
							obuttonno.innerText = no;
							buttonnobounds = com.LeadTran.Utils.GetElementBounds(obuttonno);
							buttonwidth	+= buttonnobounds.width + 25;
							buttondisplay = true;
						}
						else
						{
							obuttonno.style.display = "none";
						}
						
						if (cancel != "")
						{
							obuttoncancel.style.display = "inline";
							obuttoncancel.innerText = cancel;
							buttoncancelbounds = com.LeadTran.Utils.GetElementBounds(obuttoncancel);
							buttonwidth	+= buttoncancelbounds.width + 25;
							buttondisplay = true;
						}
						else
						{
							obuttoncancel.style.display = "none";
						}
						
						width = Math.max((titlesize != null) ? titlesize.width : 0, (textsize != null) ? textsize.width : 0, buttonwidth);
						buttonheight = Math.max((buttonyesbounds != null) ? buttonyesbounds.height : 0, (buttonnobounds != null) ? buttonnobounds.height : 0, (buttoncancelbounds != null) ? buttoncancelbounds.height : 0);
						buttonheight = (buttonheight > 0) ? buttonheight + 28 : 0;
						height	= ((titlesize != null) ? titlesize.height : 0) + ((textsize != null) ? textsize.height : 0) + buttonheight;
						
						$(popupcontent).css({
							width: (width + 40) + "px",
							height: (height + 40) + "px",
							marginLeft: "-" + ((width + 40) / 2) + "px",
							marginTop: "-" + ((height + 40) / 2) + "px"
						});
						
						contentbounds = com.LeadTran.Utils.GetElementBounds(popupcontent);
						
						$(otitle).css({
							width: width + "px",
							marginTop: ((titletop == true) ? 16 : 0) + "px",
							marginLeft: ((contentbounds.width - width) / 2) + "px"
						});
						
						
						$(otext).css({
							width: width+ "px",
							marginTop: ((titletop == true) ? 4 : 16) + "px",
							marginLeft: ((contentbounds.width - width) / 2) + "px"
						});
						
						if (buttondisplay == true)
						{
							$(buttoncontainer).css({
								width: width+ "px",
								marginTop: "22px",
								marginLeft: ((contentbounds.width - width) / 2) + "px",
								display: "block"
							});
						}
						else
						{
							$(buttoncontainer).css({
								display: "none"
							});
						}
						
						popup.style.display = "block";
						$(popupcontent).css({
							left: "50%",
							top: "40%"
						});
						
						linkbounds = com.LeadTran.Utils.GetElementBounds(olink);
						$(olink).css({
							left: "50%",
							top: "40%",
							marginLeft: "-" + (((contentbounds.width / 2) + (linkbounds.width / 2)) - 9) + "px",
							marginTop: "-" + (((contentbounds.height / 2) + (linkbounds.height / 2)) - 9) + "px"
						});
						olink.style.display = "block";
						
						document_keydown = document.onkeydown;
						document.onkeydown = function(ev)
						{
							var evc = (('event' in window) == true) ? event : ev;
							
							try
							{
								if (evc.keyCode == 27)
								{
									result = "cancel";
									self.hide();
								}
							}catch(e){}
						}
					}
				}
			}	
		}catch(e){}
	}
	
	this.hide = function()
	{
		try
		{
			var close = false;
			
			if ((popupcontent != null) && (isVisible(popupcontent) == true))
			{
				popupcontent.style.display = "none";
				close = true;
			}
			
			if ((popup != null) && (isVisible(popup) == true))
			{
				popup.style.display = "none";
				close = true;
			}
			
			if ((olink != null) && (isVisible(olink) == true))
			{
				olink.style.display = "none";
				close = true;
			}
			
			if (close == true)
			{
				document.onkeydown = document_keydown;
				
				try
				{
					if (onclose != null)
					{
						if (result == "") result = "cancel";
						onclose.call(this, this, result);
					}
				}catch(ev){}
			}
		}catch(e){}
	}
	
	Constructor();
}

com.LeadTran.SubMenu = function(control)
{
	var oSections = {};
	var oLastMenu = null;
	var bDisabled = false;
	var self = this;
	
	var itemClicksArgs = function()
	{
		this.cancel = false;
	}
	this.onitemclick = null;
	
	function Constructor()
	{
		try 
		{	
			if ((control != null) && (control.childNodes != null) && (control.childNodes.length > 0))
			{
				var oNode = null;
				var oLastSeccion = null;
				var iSections = 0;
				var sLink = "";
				
				for (var i = 0; i < control.childNodes.length; i++)
				{
					try
					{
						oNode = control.childNodes[i];
						if ((oNode != null) && (oNode.nodeName != null) && (oNode.nodeName != "") && (oNode.nodeName.toLowerCase() == "div"))
						{
							com.LeadTran.Utils.DisableSelection(oNode);
							
							if (oNode.className != null)
							{
								switch(oNode.className)
								{
									case "submenuSection":
										oNode.menutype = "section";
										oNode.visible = false;
										
										com.LeadTran.Utils.AddClass(oNode, "sectionSelectable");
										
										oNode.link = com.LeadTran.Utils.GetAttribute(oNode, "href");;
										oNode.section = null;
										oNode.onclick = gotoLink;
										
										oSections[iSections] = oNode;
										oLastSeccion = oNode;
										oLastSeccion.items = {};
										oLastSeccion.container = null;
										iSections++;
										break;
										
									case "submenuGroupItems":
										if (oLastSeccion != null)
										{
											oLastSeccion.onmouseover = OnItemMouseOver;
											oLastSeccion.onmouseout = OnItemMouseOut;
											
											com.LeadTran.Utils.RemoveClass(oNode, "sectionSelectable");
											
											createItems(oLastSeccion, oNode);
										}
										break;
								}
							}	
						}
					}catch(en){}
				}
			}
		}catch(e){}
	}
	
	this.disabled = function(value)
	{
		try
		{
			if ((value != null) && ((value == true) || (value == false)) && (value != bDisabled))
			{
				if ((value == true) && (oLastMenu != null))
				{
					hideItems(oLastMenu);
				}
				
				bDisabled = value;
			}
		}catch(e){}
		
		return bDisabled;
	}
	
	function createItems(section, node)
	{
		try 
		{
			if ((section != null) && (section.items != null) && (section.container == null) && (section.menutype != null) && (section.menutype == "section") && (node != null) && (node.childNodes != null) && (node.childNodes.length > 0))
			{
				var oNode = null;
				var iItems = 0;
				
				for (var i = 0; i < node.childNodes.length; i++)
				{
					try
					{
						oNode = node.childNodes[i];
						if ((oNode != null) && (oNode.nodeName != null) && (oNode.nodeName != "") && (oNode.nodeName.toLowerCase() == "div") && (oNode.className != null) && (oNode.className == "submenuItem"))
						{				
							com.LeadTran.Utils.DisableSelection(oNode);
							
							oNode.link = com.LeadTran.Utils.GetAttribute(oNode, "href");
							oNode.menutype = "item";
							oNode.onclick = gotoLink;
							oNode.container = node;
							oNode.section = section;
							
							section.items[iItems] = oNode;
							iItems++;		
						}
					}catch(en){}
				}
				
				if (iItems > 0)
				{
					node.style.display = "none";
					node.onmouseout = OnContainerMouseOut;
					node.parentItem = section;
					
					section.container = node;
					section = null;
				}
			}
		}catch(e){}
	}
	
	function OnItemMouseOver()
	{
		try
		{
			if (bDisabled == false)
			{
				showItems(this);
			}
		}catch(e){}
	}
	
	function OnItemMouseOut(ev)
	{
		try
		{
			hideByPosition(this, ev, true);
		}catch(e){}
	}
	
	function OnContainerMouseOut(ev)
	{
		try
		{
			hideByPosition(this.parentItem, ev, false);
		}catch(e){}
	}
	
	function showItems(element)
	{
		try
		{
			if ((element != null) && ("container" in element) && (element.container != null) && ("visible" in element) && (element.visible == false))
			{
				oLastMenu = element;
				
				var bounds = com.LeadTran.Utils.GetElementBounds(element);
				var containerbounds = com.LeadTran.Utils.GetElementBounds(element.container);
				
				element.container.style.left = bounds.left + "px";
				element.container.style.top = (bounds.top + bounds.height + 3) + "px";
				
				if (bounds.width > containerbounds.width)
				{
					element.container.style.width = (bounds.width + 10) + "px";
				}
				
				com.LeadTran.Utils.RemoveClass(element, "sectionSelectable");
				com.LeadTran.Utils.AddClass(element, "sectionSelected");
				
				element.container.style.display = "block";
				element.visible = true;
			}
		}catch(e){}
	}
	
	function hideItems(element)
	{
		try
		{
			if ((element != null) && ("container" in element) && (element.container != null) && ("visible" in element) && (element.visible == true))
			{
				element.container.style.display = "none";
				
				com.LeadTran.Utils.RemoveClass(element, "sectionSelected");
				com.LeadTran.Utils.AddClass(element, "sectionSelectable");
				
				element.visible = false;
				
				oLastMenu = null;
			}
		}catch(e){}
	}
	
	function hideByPosition(element, ev, isElement)
	{
		try
		{
			if ((element != null) && ("container" in element) && (element.container != null)) 
			{
				var x, y;
			
				if (com.LeadTran.IE == true)
				{
					x = event.clientX;
					y = event.clientY;
				}
				else
				{
					x = ev.pageX;
					y = ev.pageY;
				}
				
				if (isElement == true)
				{
					if ((x < element.offsetLeft) || (x >= (element.offsetLeft + element.offsetWidth)))
					{
						hideItems(element);
					}
					else
					{
						if (y <= element.offsetTop)
						{
							hideItems(element);
						}
						else if (y >= (element.offsetTop + element.offsetHeight))
						{
							if ((x < element.container.offsetLeft) || (x >= (element.container.offsetLeft + element.container.offsetWidth)))
							{
								hideItems(element);
							}
						}
					}
				}
				else
				{
					if ((x < element.container.offsetLeft) || (x >= (element.container.offsetLeft + element.container.offsetWidth)))
					{
						hideItems(element);
					}
					else
					{
						if (y <= element.container.offsetTop)
						{
							if ((x < element.offsetLeft) || (x >= (element.offsetLeft + element.offsetWidth)))
							{
								hideItems(element);
							}
						}
						else if (y >= (element.container.offsetTop + element.container.offsetHeight))
						{
							hideItems(element);
						}
					}
				}
			}
		}catch(e){}
	}
	
	function gotoLink()
	{
		if (bDisabled == false)
		{
			hideItems(this.section);
			
			try
			{
				if ((self.onitemclick != null) && (typeof self.onitemclick == "function"))
				{
					var args = new itemClicksArgs();
					
					self.onitemclick.call(self, this, args);
					
					if ((args != null) && (args.cancel == true))
					{
						return;
					}
				}
			}catch(e){}
			
			self.openLink(this);
		}	
	}
	
	this.openLink = function(item)
	{
		try
		{
			if ((item != null) && ("link" in item) && (item.link != ""))
			{
				window.location.href = item.link;
			}
		}catch(e){}
	}
	
	Constructor();
}

com.LeadTran.SuiteView = function(parentnode)
{
	var oElement = null;
	var oParent = parentnode;
	var bVisible = false;
	var bSelectAll = false;
	var iSelected = 0;
	var oEmpty = null;
	var self = this;
	
	this.count = 0;
	this.items = {};
	this.tag = null;
	this.onitemselected = null;
	this.onitemchangeselect = null;
	this.onvisiblechanged = null;
	this.onitemretrieve = null;
	
	var Controls = {};
	
	Controls.Item = function(parentnode, index, eventselect, eventchangeselect, eventretrieve)
	{
		var oElement = null;
		var oParent = parentnode;
		var iIndex = ((index != null) && (isNaN(index) == false) && (index >= 0)) ? index : -1;
		var oParams = null;
		var oButtonContainer = null;
		var oAddButton = null;
		var oRemoveButton = null;
		var bSelected = false;
		var bSavedSelected = false;
		var self = this;
		
		this.tag = null;
		
		var itemRetrieveArgs = function(index)
		{
			var iIndex = ((index != null) && (isNaN(index) == false) && (index >= 0)) ? index : -1;
			var bSelected = false;
			
			this.cancel = false;
			this.element = null;
			this.buttoncontainer = null;
			this.params = null;
			this.addbuttontext = "";
			this.removebuttontext = "";
			
			this.index = function()
			{
				return iIndex;
			}
			
			this.select = function(value)
			{
				try
				{
					if ((value != null) && ((value == true) || (value == false)))
					{
						bSelected = value;
					}
				}catch(e){}
				
				return bSelected;
			}
		}
		
		function Constructor()
		{
			try
			{
				if (oParent != null)
				{
					OnItemRetrieve();
				}
			}catch(e){}
		}
		
		this.target = function()
		{
			return oElement;
		}
		
		this.parent = function()
		{
			return oParent;
		}
		
		this.index = function()
		{
			return iIndex;
		}
		
		this.select = function(value)
		{
			try
			{
				if ((value != null) && (oElement != null))
				{
					selectedItem(value, true);
				}
			}catch(e){}
			
			return bSelected;
		}
		
		this.savedselect = function(value)
		{
			try
			{
				if ((value != null) && (value == true))
				{
					bSavedSelected = bSelected;
				}
			}catch(e){}
			
			return bSavedSelected;
		}
		
		this.param = function(nameparam)
		{
			try
			{
				if ((oParams != null) && (nameparam in oParams))
				{
					return oParams[nameparam];
				}
			}catch(e){}
			
			return null;
		}
		
		function selectedItem(value, useevents)
		{
			try
			{
				if ((oElement != null) && (value != null) && ((value == true) || (value == false)))
				{
					if ((value == true) && (bSelected == false))
					{
						if ((oAddButton != null) && (oRemoveButton != null))
						{
							oAddButton.style.display = "none";
							oRemoveButton.style.display = "block";
						}
						
						com.LeadTran.Utils.AddClass(oElement, "itemselected");
						bSelected = true;
						
						if (useevents == true)
						{
							if (bSelected != bSavedSelected)
							{
								OnItemChangeSelect();
							}
							
							OnItemSelected();
						}
					}
					else if ((value == false) && (bSelected == true))
					{
						if ((oAddButton != null) && (oRemoveButton != null))
						{
							oRemoveButton.style.display = "none";
							oAddButton.style.display = "block";
						}
						
						com.LeadTran.Utils.RemoveClass(oElement, "itemselected");
						bSelected = false;
						
						if (useevents == true)
						{
							if (bSelected != bSavedSelected)
							{
								OnItemChangeSelect();
							}
							
							OnItemSelected();
						}
					}
				}
			}catch(e){}
		}
		
		function OnItemSelected()
		{
			try
			{
				if ((eventselect != null) && (typeof eventselect == "function"))
				{
					eventselect.call(self);
				}
			}catch(e){}
		}
		
		function OnItemChangeSelect()
		{
			try
			{
				if ((eventchangeselect != null) && (typeof eventchangeselect == "function"))
				{
					eventchangeselect.call(self);
				}
			}catch(e){}
		}
		
		function OnItemRetrieve()
		{
			try
			{
				if ((eventretrieve != null) && (typeof eventretrieve == "function") && (iIndex >= 0))
				{
					var args = new itemRetrieveArgs(iIndex);
					
					eventretrieve.call(self, args);
					
					if (args != null)
					{
						if ((args.cancel == false) && (args.element != null))
						{
							oElement = args.element;
							
							if (args.buttoncontainer != null)
							{
								oButtonContainer = args.buttoncontainer;
								
								createButtons();
							}
							
							if ((oAddButton != null) && (str_trim(args.addbuttontext) != ""))
							{
								oAddButton.innerHTML = str_trim(args.addbuttontext);
							}
							
							if ((oRemoveButton != null) && (str_trim(args.removebuttontext) != ""))
							{
								oRemoveButton.innerHTML = str_trim(args.removebuttontext);
							}
							
							if (args.params != null)
							{
								oParams = args.params;
							}
							
							if (args.select() == true)
							{
								selectedItem(args.select(), false);
								bSavedSelected = args.select();
							}
						}
					}
				}
			}catch(e){}
		}
		
		function createButtons()
		{
			try
			{
				if (oButtonContainer != null)
				{
					if (oAddButton == null)
					{
						oAddButton = document.createElement("span");
						oAddButton.className = "itembutton add" + (com.LeadTran.IE == true ? " buttonborder" : "");
						oAddButton.innerHTML = "Add item";
						oAddButton.onclick = function()
						{
							selectedItem(true, true);
						};
						
						oButtonContainer.appendChild(oAddButton);
					}
						
					if (oRemoveButton == null)
					{
						oRemoveButton = document.createElement("span");
						oRemoveButton.className = "itembutton remove" + (com.LeadTran.IE == true ? " buttonborder" : "");
						oRemoveButton.innerHTML = "Remove item";
						oRemoveButton.style.display = "none";
						oRemoveButton.onclick = function()
						{
							selectedItem(false, true);
						};
						
						oButtonContainer.appendChild(oRemoveButton);
					}
				}	
			}catch(e){}
		}
		
		Constructor();
	}
	
	function Constructor()
	{
		try
		{
			if (oEmpty == null)
			{
				createContainer();
				
				if (existContainer() == true)
				{
					oEmpty = document.createElement("div");
					oEmpty.className = "emptyview";
					oEmpty.innerHTML = "No items found";
					
					com.LeadTran.Utils.DisableSelection(oEmpty);
				}
			}
		}catch(e){}
	}
	
	this.retrieve = function(value)
	{
		try
		{
			if ((oParent != null) && (value != null) && (isNaN(value) == false) && (value > 0) && (this.onitemretrieve != null) && (typeof this.onitemretrieve == "function"))
			{
				createContainer();
				
				if (existContainer() == true)
				{
					var oItem = null;
					
					for(var i = 0; i < value; i++)
					{
						try
						{
							oItem = new Controls.Item(this, i, OnItemSelected, OnItemChangeSelect, OnItemRetrieved);
							if ((oItem != null) && (oItem.target() != null) )
							{
								oElement.appendChild(oItem.target());
								this.items[this.count] = oItem;
								this.count++;
								
								if (oItem.select() == true)
								{
									iSelected++;
								}
							}
						}catch(enew){}
					}
					
					if ((bSelectAll == false) && (iSelected >= this.count))
					{
						bSelectAll = true;
					}
				}
			}
		}catch(e){}
	}
	
	this.target = function()
	{
		return oElement;
	}
	
	this.parent = function()
	{
		return oParent;
	}
	
	this.visible = function()
	{
		return bVisible;
	}
	
	this.show = function()
	{
		try
		{
			if ((oElement != null) && (oParent != null) && (bVisible == false))
			{
				if (oEmpty != null)
				{
					if (this.count > 0)
					{
						if (oEmpty.style.display != "none")
						{
							oEmpty.style.display = "none";
							com.LeadTran.Utils.RemoveElement(oEmpty);
						}
					}
					else
					{
						if (oEmpty.style.display != "block")
						{
							oEmpty.style.display = "block";
							oElement.appendChild(oEmpty);
						}
					}
				}
				
				oElement.style.display = "block";
				bVisible = true;
				
				OnViewVisibleChanged();
			}
		}catch(e){}
	}
	
	this.hide = function()
	{
		try
		{
			if ((oElement != null) && (oParent != null) && (bVisible == true))
			{
				oElement.style.display = "none";
				bVisible = false;
				
				OnViewVisibleChanged();
			}
		}catch(e){}
	}
	
	this.selectedItems = function()
	{
		return iSelected;
	}
	
	this.selectAll = function(value)
	{
		try
		{
			if ((value != null) && ((value == true) || (value == false)) && (this.items != null) && (this.count > 0))
			{
				for(var key in this.items)
				{
					if (this.items[key] != null)
					{
						try
						{
							this.items[key].select(value);
						}catch(ef){}
					}
				}
			}
		}catch(e){}
		
		return bSelectAll;
	}
	
	this.emptyText = function(value)
	{
		try
		{
			if ((value != null) && (str_trim(value) != "") && (oEmpty != null))
			{
				oEmpty.innerHTML = value;
			}
		}catch(e){}
		
		return (oEmpty != null) ? oEmpty.innerHTML : "";
	}
	
	function existContainer()
	{
		return (oElement == null) ? false : true;
	}
	
	function createContainer()
	{
		try
		{
			if (oElement == null)
			{
				oElement = document.createElement("div");
				oElement.className = "viewcontainer";
				oElement.style.display = "none";
			}
		}catch(e){}
	}
	
	function OnItemSelected()
	{
		try
		{
			if (this.select() == true)
			{
				iSelected++;
			}
			else
			{
				iSelected--;
				if (iSelected < 0) iSelected = 0;
			}
			
			if (iSelected >= self.count)
			{
				bSelectAll = true;
			}
			else
			{
				bSelectAll = false;
			}
		}catch(e){}
		
		try
		{
			if ((self.onitemselected != null) && (typeof self.onitemselected == "function"))
			{
				self.onitemselected.call(this);
			}
		}catch(e){}
	}
	
	function OnItemChangeSelect()
	{
		try
		{
			if ((self.onitemchangeselect != null) && (typeof self.onitemchangeselect == "function"))
			{
				self.onitemchangeselect.call(this);
			}
		}catch(e){}
	}
	
	function OnViewVisibleChanged()
	{
		try
		{
			if ((self.onvisiblechanged != null) && (typeof self.onvisiblechanged == "function"))
			{
				self.onvisiblechanged.call(self);
			}
		}catch(e){}
	}
	
	function OnItemRetrieved(args)
	{
		try
		{
			if ((self.onitemretrieve != null) && (typeof self.onitemretrieve == "function") && (args != null))
			{
				self.onitemretrieve.call(this, args);
			}
		}catch(e){}
	}
	
	Constructor();
}

com.LeadTran.SystemWindowController = function()
{
	var self = this;
	var iCount = 0;
	var oItems = {};
		
	this.tag = null;
	
	var Controls = {};
	
	Controls.Item = function(parent, element, index, eventfocus)
	{
		var oElement = element;
		var oParent = parent;
		var iIndex = ((index != null) && (isNaN(index) == false) && (index >= 0)) ? index : -1;
		var bVisible = false;
		var bDragging = false;
		var oHeader = null;
		var oTitle = null;
		var oTitleSize = new com.LeadTran.Utils.Size();
		var oCloseButton = null;
		var oContent = null;
		var oContentSize = new com.LeadTran.Utils.Size();
		var oPopup = null;
		var bVisiblePopup = false;
		var bResized = false;
		var oBounds = new com.LeadTran.Utils.Bounds();
		var bIsDragging = false;
		var oWaiting = null;
		var bWaiting = false;
		var oMessage = null;
		var bMessage = false;
		var oMessageTimer = null;
		var self = this;
		
		var bounds = null;
		var documentsize = null;
		var ReduceX = 0;
		var ReduceY = 0;
		var document_mousemove = null;
		var document_mouseup = null;
		
		this.tag = null;
		this.onvisiblechanged = null;
		this.onmousedown = null;
		this.onopening = null;
		this.onclosing = null;
		this.ondragstart = null;
		this.ondragend = null;
		
		var EventArgs = function()
		{
			this.cancel = false;
		}
		
		var EventOnMouseDownListener = {
			count: 0,
			functions: {},
			execute: function()
			{
				try
				{
					if (this.count > 0)
					{
						for(var key in this.functions)
						{
							try
							{
								if ((this.functions[key] != null) && (typeof this.functions[key] == "function"))
								{
									this.functions[key].call(self);
								}
							}catch(evc){}
						}
					}
				}catch(e){}
			},
			add: function(value)
			{
				try
				{
					if ((value != null) && (typeof value == "function"))
					{
						this.functions[this.count] = value;
						this.count++;
					}
				}catch(e){}
			}
		}
		
		function Constructor()
		{
			try
			{
				createWindow();
			}catch(e){}
		}
		
		this.target = function()
		{
			return oElement;
		}
		
		this.parent = function()
		{
			return oParent;
		}
		
		this.index = function()
		{
			return iIndex;
		}
		
		this.title = function(value)
		{
			try
			{
				if ((value != null) && (value != "") && (oTitle != null))
				{
					oTitle.innerText = value;
				}
			}catch(e){}
			
			return ((oTitle != null) && ("innerText" in oTitle)) ? oTitle.innerText : "";
		}
		
		this.isdragging = function()
		{
			return bIsDragging;
		}
		
		this.visible = function()
		{
			return bVisible;
		}
		
		this.show = function()
		{
			try
			{
				if (oElement != null)
				{
					if (bVisible == false)
					{
						if (OnOpening() == true)
						{
							appendWindow();
							centerWindow();
							bVisible = true;
							
							this.focus();
							
							OnVisibleChanged();
						}	
					}
					else
					{
						this.focus();
					}	
				}
			}catch(e){}
		}
		
		this.hide = function()
		{
			try
			{
				if ((oElement != null) && (bVisible == true))
				{
					if (OnClosing() == true)
					{
						if (oCloseButton != null) oCloseButton.style.backgroundColor = "transparent";
						
						removeWindow();
						bVisible = false;
						
						OnVisibleChanged();
					}	
				}
			}catch(e){}
		}
		
		this.focus = function()
		{
			OnItemFocus();
		}
		
		this.content = function(value)
		{
			try
			{
				if ((value != null) && (value != "") && (oContent != null))
				{
					oContent.innerHTML = value;
				}
			}catch(e){}
			
			return ((oContent != null) && ("innerHTML" in oContent)) ? oContent.innerHTML : "";
		}
		
		this.appendChild = function(child)
		{
			try
			{
				if ((oContent != null) && (child != null))
				{
					com.LeadTran.Utils.AddElement(child, oContent);
				}
			}catch(e){}
		}
		
		this.removeChild = function(child)
		{
			try
			{
				if ((oContent != null) && (child != null) && (child.parentNode != null) && (child.parentNode == oContent))
				{
					com.LeadTran.Utils.RemoveElement(child);
				}
			}catch(e){}
		}
		
		this.size = function(width, height)
		{
			try
			{
				if ((oElement != null) && (oBounds != null) && (((width != null) && (isNaN(width) == false) && (width >= 30) && (width != oBounds.width)) || ((height != null) && (isNaN(height) == false) && (height >= 30) && (height != oBounds.height))))
				{
					configureWindow(width, height);
				}
			}catch(e){}
			
			return com.LeadTran.Utils.GetElementBounds(oElement);
		}
		
		this.center = function()
		{
			centerWindow();
		}
		
		this.addEventListener = function(eventname, value)
		{
			try
			{
				if ((eventname != null) && (eventname != "") && (value != null) && (typeof value == "function"))
				{
					switch(eventname)
					{
						case "mousedown":
							EventOnMouseDownListener.add(value);
							break;
					}
				}
			}catch(e){}
		}
		
		this.waiting = function(value, text)
		{
			try
			{
				if ((value != null) && (oWaiting != null) && ((value == true) || (value == false)))
				{
					if ((value == true) && (bWaiting == false))
					{
						showWaiting(text);
					}
					else if ((value == false) && (bWaiting == true))
					{
						hideWaiting();
					}
				}
			}catch(e){}
			
			return bWaiting;
		}
		
		this.message = function(value, text, timer, callback)
		{
			try
			{
				if ((value != null) && (oMessage != null) && ((value == true) || (value == false)))
				{
					if ((value == true) && (bMessage == false))
					{
						showMessage(text, timer, callback);
					}
					else if ((value == false) && (bMessage == true))
					{
						hideMessage();
					}
				}
			}catch(e){}
			
			return bMessage;
		}
		
		this.backgroundColor = function(value)
		{
			try
			{
				if ((value != null) && (value != "") && (oContent != null))
				{
					oContent.style.backgroundColor = value;
				}
			}catch(e){}
			
			return ((oContent != null) && ("style" in oContent)) ? oContent.style.backgroundColor : "white";
		}
		
		function createWindow()
		{
			try
			{
				if ((oElement != null) && (oElement.childNodes != null) && (oElement.childNodes.length > 0) && (iIndex != -1))
				{
					var oNode = null;
					var oSubNode = null;
					
					oElement.style.display = "none";
					oElement.style.zIndex = iIndex + 101;
					if (com.LeadTran.IE == true) oElement.style.border = "solid #cfcfcf 1px";
					
					oElement.onmousedown = OnWindowMouseDown;
					
					com.LeadTran.Utils.RemoveElement(oElement);
					
					try
					{
						oWaiting = document.createElement("div");
						oWaiting.className = "waitingwindow";
						com.LeadTran.Utils.DisableSelection(oWaiting);
					}catch(ew){}
					
					try
					{
						oMessage = document.createElement("div");
						oMessage.className = "messagewindow";
						com.LeadTran.Utils.DisableSelection(oMessage);
					}catch(ew){}
					
					for (var i = 0; i < oElement.childNodes.length; i++)
					{
						try
						{
							oNode = oElement.childNodes[i];
							if ((oNode != null) && (oNode.nodeName != null) && (oNode.nodeName != "") && (oNode.nodeName.toLowerCase() == "div"))
							{
								if (oNode.className != null)
								{
									switch(oNode.className)
									{
										case "windowheader":
											com.LeadTran.Utils.DisableSelection(oNode);
											oHeader = oNode;
											oHeader.onmousedown = OnHeaderMouseDown;
											oHeader.onmouseup = OnHeaderMouseUp;
											
											if ((oHeader.childNodes != null) && (oHeader.childNodes.length > 0))
											{
												for (var j = 0; j < oHeader.childNodes.length; j++)
												{
													try
													{
														oSubNode = oHeader.childNodes[j];
														if ((oSubNode != null) && (oSubNode.nodeName != null) && (oSubNode.nodeName != ""))
														{
															if (oSubNode.className != null)
															{
																switch(oSubNode.className)
																{
																	case "title":
																		oTitle = oSubNode;
																		if (str_trim(oTitle.innerHTML) == "")
																		{
																			oTitle.innerHTML = "Window " + iIndex;
																		}
																		break;
																		
																	case "buttonclose":
																		oCloseButton = oSubNode;
																		oCloseButton.innerText = "X";
																		oCloseButton.onmousedown = OnCloseButtonClick;
																		
																		oCloseButton.onmouseover = function()
																		{
																			this.style.backgroundColor = "#126796";
																		};
																		
																		oCloseButton.onmouseout = function()
																		{
																			this.style.backgroundColor = "transparent";
																		};
																		break;
																}
															}	
														}
													}catch(ens){}
												}
											}
											break;
											
										case "windowcontent":
											oContent = oNode;
											oContent.style.backgroundColor = "white";
											
											oPopup = document.createElement("div");
											oPopup.className = "windowdisabled";
											oPopup.style.display = "none";
											
											com.LeadTran.Utils.DisableSelection(oPopup);
											break;
									}
								}	
							}
						}catch(en){}
					}
					
					configureWindow(230, 130)
				}
			}catch(e){}
		}
		
		function OnItemFocus()
		{
			try
			{
				if ((eventfocus != null) && (typeof eventfocus == "function"))
				{
					eventfocus.call(self);
				}
			}catch(e){}
		}
		
		function OnOpening()
		{
			try
			{
				if ((self.onopening != null) && (typeof self.onopening == "function"))
				{
					var args = new EventArgs();
					
					self.onopening.call(self, args);
					
					if ((args != null) && (args.cancel == true))
					{
						return false;
					}
				}
			}catch(e){}
			
			return true;
		}
		
		function OnClosing()
		{
			try
			{
				if ((self.onclosing != null) && (typeof self.onclosing == "function"))
				{
					var args = new EventArgs();
					
					self.onclosing.call(self, args);
					
					if ((args != null) && (args.cancel == true))
					{
						return false;
					}
				}
			}catch(e){}
			
			return true;
		}
		
		function OnVisibleChanged()
		{
			try
			{
				if ((self.onvisiblechanged != null) && (typeof self.onvisiblechanged == "function"))
				{
					self.onvisiblechanged.call(self);
				}
			}catch(e){}
		}
		
		function OnWindowMouseDown()
		{
			OnItemFocus();
			
			EventOnMouseDownListener.execute();
			
			try
			{
				if ((self.onmousedown != null) && (typeof self.onmousedown == "function"))
				{
					self.onmousedown.call(self);
				}
			}catch(e){}
		}
		
		function OnHeaderMouseDown(ev)
		{
			try
			{
				if (oElement != null)
				{
					var x, y;
					
					if (com.LeadTran.IE == true)
					{
						x = event.clientX;
						y = event.clientY;
					}
					else
					{
						x = ev.pageX;
						y = ev.pageY;
					}
					
					startDragging(x, y);
				}	
			}catch(e){}
		}
		
		function OnHeaderMouseUp(ev)
		{
			try
			{
				stopDragging();
			}catch(e){}
		}
		
		function OnDocumentMouseMove(ev)
		{
			try
			{
				if (document_mousemove != null)
				{
					document_mousemove.call(this, ev);
				}
			}catch(e){}
			
			try
			{
				if ((bDragging == true) && (oElement != null))
				{
					if (bIsDragging == false)
					{
						bIsDragging = true;
						showDisabledPopup();
						OnDragStart();
					}
					
					var x, y;
				
					if (com.LeadTran.IE == true)
					{
						x = event.clientX;
						y = event.clientY;
					}
					else
					{
						x = ev.pageX;
						y = ev.pageY;
					}
					
					x = x + ReduceX;
					y = y + ReduceY;
					
					if (x <= 5)
					{
						oElement.style.left = "5px";
					}
					else if (documentsize != null)
					{
						if ((x + bounds.width + 5) > documentsize.width)
						{
							oElement.style.left = (documentsize.width - bounds.width - 5) + "px";
						}
						else
						{
							oElement.style.left = x + "px";
						}
					}
					else
					{
						oElement.style.left = x + "px";
					}
					
					if (y < 5)
					{
						oElement.style.top = "5px";
					}
					else if (documentsize != null)
					{
						if ((y + bounds.height + 5) > documentsize.height)
						{
							oElement.style.top = (documentsize.height - bounds.height - 5) + "px";
						}
						else
						{
							oElement.style.top = y + "px";
						}
					}
					else
					{
						oElement.style.top = y + "px";
					}	
				}
			}catch(e){}
		}
		
		function OnDocumentMouseUp(ev)
		{
			try
			{
				var x, y;
				
				if (com.LeadTran.IE == true)
				{
					x = event.clientX;
					y = event.clientY;
				}
				else
				{
					x = ev.pageX;
					y = ev.pageY;
				}
				
				stopDraggindByPosition(x, y);
			}catch(e){}
		}
		
		function OnCloseButtonClick(ev)
		{
			try
			{
				self.hide();
				
				com.LeadTran.Utils.StopEvent(ev);
			}catch(e){}
		}
		
		function OnDragStart()
		{
			try
			{
				if ((self.ondragstart != null) && (typeof self.ondragstart == "function"))
				{
					self.ondragstart.call(self);
				}
			}catch(e){}
		}
		
		function OnDragEnd()
		{
			try
			{
				if ((self.ondragend != null) && (typeof self.ondragend == "function"))
				{
					self.ondragend.call(self);
				}
			}catch(e){}
		}
		
		function startDragging(x, y)
		{
			try
			{
				if ((isNaN(x) == false) && (isNaN(y) == false) && (bDragging == false))
				{
					bounds = com.LeadTran.Utils.GetElementBounds(oElement);
					documentsize = com.LeadTran.Utils.GetDocumentSize();
					
					ReduceX = bounds.left - x;
					ReduceY = bounds.top - y;
					
					document_mousemove = (("onmousemove" in document) && (document.onmousemove != null)) ? document.onmousemove : null;
					document.onmousemove = OnDocumentMouseMove;
					
					document_mouseup = (("onmouseup" in document) && (document.onmouseup != null)) ? document.onmouseup : null;
					document.onmouseup = OnDocumentMouseUp;
					
					bDragging = true;
				}
			}catch(e){}
		}
		
		function stopDragging()
		{
			try
			{
				if (bDragging == true)
				{
					hideDisabledPopup();
					
					ReduceX = 0;
					ReduceY = 0;
					bounds = null;
					documentsize = null;
					
					document.onmousemove = document_mousemove;
					document_mousemove = null;
					
					document.onmouseup = document_mouseup;
					document_mouseup = null;
					
					bDragging = false;
					bIsDragging = false;
					
					OnDragEnd();
				}
			}catch(e){}
		}
		
		function stopDraggindByPosition(x, y)
		{
			try
			{
				if ((isNaN(x) == false) && (isNaN(y) == false) && (oHeader != null))
				{
					if ((x < oHeader.offsetLeft) || (x >= (oHeader.offsetLeft + oHeader.offsetWidth)))
					{
						stopDragging();
					}
					else
					{
						if ((y <= oHeader.offsetTop) || (y >= (oHeader.offsetTop + oHeader.offsetHeight)))
						{
							stopDragging();
						}
					}
				}
			}catch(e){}
		}
		
		function centerWindow()
		{
			try
			{
				if (oElement != null)
				{
					bounds = com.LeadTran.Utils.GetElementBounds(oElement);
					documentsize = com.LeadTran.Utils.GetDocumentSize();
					
					oElement.style.left = ((documentsize.width - bounds.width) / 2) + "px";
					oElement.style.top = ((documentsize.height - bounds.height) / 2) + "px";
					
					bounds = null;
					documentsize = null;
				}
			}catch(e){}
		}
		
		function appendWindow()
		{
			try
			{
				if (oElement != null)
				{
					oElement.style.left = "-10000px";
					oElement.style.top = "-10000px";
					oElement.style.display = "block";
					com.LeadTran.Utils.AddElement(oElement, document.body);
				}
			}catch(e){}
		}
		
		function removeWindow()
		{
			try
			{
				if (oElement != null)
				{
					oElement.style.display = "none";
					com.LeadTran.Utils.RemoveElement(oElement);
				}
			}catch(e){}
		}
		
		function showDisabledPopup()
		{
			try
			{
				if ((oContent != null) && (oContentSize != null) && (oPopup != null) && (bVisiblePopup == false) && (bWaiting == false) && (bMessage == false))
				{
					var minTop = 0;
					
					if ((oTitle != null) && (oTitleSize != null))
					{
						minTop = oTitleSize.height;
					}
					
					oPopup.style.display = "block";
					oPopup.style.top = minTop + "px";
					oPopup.style.width = oContentSize.width + "px";
					oPopup.style.height = (oContentSize.height + 2) + "px";
					oPopup.style.zIndex = 200;
					
					com.LeadTran.Utils.AddElement(oPopup, oContent);
					
					bVisiblePopup = true;
				}
			}catch(e){}
		}
		
		function hideDisabledPopup()
		{
			try
			{
				if ((oContent != null) && (oPopup != null) && (bVisiblePopup == true) && (bWaiting == false) && (bMessage == false))
				{
					oPopup.style.display = "none";
					oPopup.onclick = null;
					
					com.LeadTran.Utils.RemoveElement(oPopup);
					
					bVisiblePopup = false;
				}
			}catch(e){}
		}
		
		function showWaiting(text)
		{
			try
			{
				if ((oContent != null) && (oContentSize != null) && (oWaiting != null) && (bWaiting == false))
				{
					if (bMessage == true) hideMessage();
					
					showDisabledPopup();
					
					var minTop = 0;
					
					if ((oTitle != null) && (oTitleSize != null))
					{
						minTop = oTitleSize.height;
					}
					
					var waitingwidth = 32;
					var waitingheight = 32;
					
					oWaiting.style.display = "block";
					
					if ((text != null) && (text != ""))
					{
						oWaiting.innerText = text;
						
						var textsize =  com.LeadTran.Utils.GetTextSize(text, 14, "Arial", "bold");
						var left = 0;
						var top = 0;
						
						if (textsize.width > waitingwidth)
						{
							left = (textsize.width - waitingwidth) / 2;
							waitingwidth = textsize.width;
						}
						
						if (textsize.height > 0)
						{
							top = textsize.height + 2;
							waitingheight += textsize.height + 2;
						}
						
						if ((left > 0) || (top > 0))
						{
							oWaiting.style.backgroundPosition = left + "px " + top + "px";
						}
					}
					else
					{
						oWaiting.innerText = "";
						oWaiting.style.backgroundPosition = "0px 0px";
					}
					
					oWaiting.style.width = (waitingwidth + 5) + "px";
					oWaiting.style.height = waitingheight + "px";
					oWaiting.style.left = ((oContentSize.width > waitingwidth ? oContentSize.width - waitingwidth : waitingwidth - oContentSize.width) / 2) +  "px";
					oWaiting.style.top = minTop + ((oContentSize.height > waitingheight ? oContentSize.height - waitingheight : waitingheight - oContentSize.height) / 2) +  "px";
					
					com.LeadTran.Utils.AddElement(oWaiting, oContent);
					
					bWaiting = true;
				}
			}catch(e){}
		}
		
		function hideWaiting()
		{
			try
			{
				if ((oContent != null) && (oWaiting != null) && (bWaiting == true))
				{
					oWaiting.style.display = "none";
					
					com.LeadTran.Utils.RemoveElement(oWaiting);
					
					bWaiting = false;
					
					hideDisabledPopup();
				}
			}catch(e){}
		}
		
		function showMessage(text, timer, callback)
		{
			try
			{
				if ((oContent != null) && (oContentSize != null) && (oMessage != null) && (bMessage == false) && (text != null) && (typeof text == "string") && (text != ""))
				{
					if (bWaiting == true) hideWaiting();
					
					showDisabledPopup();
					
					var minTop = 0;
					
					if ((oTitle != null) && (oTitleSize != null))
					{
						minTop = oTitleSize.height;
					}
					
					var waitingwidth = 32;
					var waitingheight = 32;
					
					oMessage.style.display = "block";
					oMessage.innerHTML = text;
					
					var textsize =  com.LeadTran.Utils.GetTextSize(text, 18, "Arial", "bold");
					if (textsize.width > waitingwidth) waitingwidth = textsize.width;
					if (textsize.height > 0) waitingheight += textsize.height;
					
					oMessage.style.width = (waitingwidth + 5) + "px";
					oMessage.style.left = ((oContentSize.width > waitingwidth ? oContentSize.width - waitingwidth : waitingwidth - oContentSize.width) / 2) +  "px";
					oMessage.style.top = minTop + ((oContentSize.height > waitingheight ? oContentSize.height - waitingheight : waitingheight - oContentSize.height) / 2) +  "px";
					
					com.LeadTran.Utils.AddElement(oMessage, oContent);
					
					try
					{
						if (oPopup != null)
						{
							oPopup.onclick = function()
							{
								hideMessage();
								
								try
								{
									if ((callback != null) && (typeof callback == "function"))
									{
										callback.call(self);
									}
								}catch(ev){}
							};
						}
					}catch(eo){}
					
					try
					{
						if ((timer != null) && (isNaN(timer) == false) && (timer > 0))
						{
							oMessageTimer = setTimeout(function()
							{
								hideMessage();
								
								try
								{
									if ((callback != null) && (typeof callback == "function"))
									{
										callback.call(self);
									}
								}catch(ev){}
							}, timer);
						}
					}catch(et){}
					
					bMessage = true;
				}
			}catch(e){}
		}
		
		function hideMessage()
		{
			try
			{
				if ((oContent != null) && (oMessage != null) && (bMessage == true))
				{
					try
					{
						if (oMessageTimer != null)
						{
							clearTimeout(oMessageTimer);
							oMessageTimer = null;
						}
					}catch(et){}
					
					oMessage.style.display = "none";
					
					com.LeadTran.Utils.RemoveElement(oMessage);
					
					bMessage = false;
					
					hideDisabledPopup();
				}
			}catch(e){}
		}
		
		function configureWindow(width, height)
		{
			if (bVisible == false) appendWindow();
			
			try
			{
				if ((oElement != null) && (oBounds != null) && (((width != null) && (isNaN(width) == false) && (width >= 30)) || ((height != null) && (isNaN(height) == false) && (height >= 30))))
				{
					var bounds = null;
					var titlewidth = 0;
					var titleheight = 0;
					var realwidth = 0;
					
					if (oTitle != null)
					{
						bounds = com.LeadTran.Utils.GetElementBounds(oTitle);
						titlewidth = bounds.width;
						titleheight = (bounds.height + 4);
						
						oTitleSize.width = titlewidth;
						oTitleSize.height = titleheight;
					}
					
					if (updateWindowSize((titlewidth > width) ? titlewidth : width, height) == true)
					{
						if (oHeader != null)
						{
							var headerwidth = (oBounds.width - 9);
							
							oHeader.style.maxWidth = headerwidth + "px";
							oHeader.style.minWidth = headerwidth + "px";
							oHeader.style.width = headerwidth + "px";
						}
						
						if (oCloseButton != null)
						{
							bounds = com.LeadTran.Utils.GetElementBounds(oCloseButton);
							
							if (titleheight > 0)
							{
								oCloseButton.style.top = ((bounds.height > titleheight) ? "2" : ((titleheight - bounds.height) / 2)) + "px";
							}
							else
							{
								oCloseButton.style.top = "2px";
							}
							
							oCloseButton.style.left = ((bounds.width > oBounds.width) ? "1" : (oBounds.width - bounds.width - 4)) + "px";
						}
						
						if (oContent != null)
						{
							var contentwidth = oBounds.width;
							var contentheight = oBounds.height - titleheight - /*((com.LeadTran.IE == true) ? 19 :*/ 2/*)*/; 
							
							oContent.style.maxWidth = contentwidth + "px";
							oContent.style.minWidth = contentwidth + "px";
							oContent.style.width = contentwidth + "px";
							
							oContent.style.maxHeight = contentheight + "px";
							oContent.style.minHeight = contentheight + "px";
							oContent.style.height = contentheight + "px";
							
							oContentSize.width = contentwidth;
							oContentSize.height = contentheight;
						}
					}	
				}
			}catch(e){}
			
			if (bVisible == false) removeWindow();
		}
		
		function updateWindowSize(width, height)
		{
			var updated = false;
			
			try
			{
				if ((oElement != null) && (oBounds != null))
				{
					if ((width != null) && (isNaN(width) == false) && (width >= 30) && (width != oBounds.width))
					{
						oElement.style.minWidth = width + "px";
						oElement.style.maxWidth = width + "px";
						oElement.style.width = width + "px";
						
						oBounds.width = width;
						
						updateTitleGradient();
						
						updated = true;
					}
					
					if ((height != null) && (isNaN(height) == false) && (height >= 30) && (height != oBounds.height))
					{
						oElement.style.minHeight = height + "px";
						oElement.style.maxHeight = height + "px";
						oElement.style.height = height + "px";
						
						oBounds.height = height;
						
						updated = true;
					}
				}	
			}catch(e){}
			
			return updated;
		}
		
		function updateTitleGradient()
		{
			try
			{
				if ((oHeader != null) && (oBounds != null))
				{
					oHeader.style.background = "transparent url(/ws/createGradient.php?c1=24,70,131&c2=18,104,150&c3=7,133,200&w=" + (oBounds.width + 20) + ") repeat-y scroll 0 0";
					
					return true;
				}
			}catch(e){}
			
			return false;
		}
		
		Constructor();
	}
	
	function Constructor()
	{
		try
		{
			
		}catch(e){}
	}
	
	this.create = function(element)
	{
		return createNewWindow(element);
	}
	
	function createNewWindow(element)
	{
		try
		{
			var systemwindow = new Controls.Item(self, element, iCount, OnItemFocus);
			oItems[iCount] = systemwindow;
			iCount++;
				
			return systemwindow;
		}catch(e){}
		
		return new Controls.Item(self, null, -1, null);
	}
	
	function OnItemFocus()
	{
		try
		{
			if ((this.visible() == true) && (this.target() != null) && (this.target().style.zIndex < ((iCount - 1) + 101)) && (oItems != null) && (iCount > 1))
			{
				for(var i = 0; i < iCount; i++)
				{
					if ((i != this.index()) && (i in oItems) && (oItems[i] != null) && (oItems[i].target() != null))
					{
						oItems[i].target().style.zIndex = (oItems[i].target().style.zIndex - 1);
					}
				}
				
				this.target().style.zIndex = (iCount - 1) + 101;
			}
		}catch(e){}
	}
	
	Constructor();
}

com.LeadTran.Window = new com.LeadTran.SystemWindowController();

com.LeadTran.SystemTab = function(element)
{
	var oElement = element;
	var oTabGlobalOptions = null;
	var oTabOptions = null;
	var oTabGlobalContent = null;
	var oTabToolbar = null;
	var oTabContent = null;
	var oTabStatusBar = null;
	var oBackTab = null;
	var oNextTab = null;
	var iSelectedIndex = 0;
	var oSelected = null;
	var oItems = {};
	var iCount = 0;
	var bDisableTabSelected = false;
	var bResized = false;
	var oBounds = new com.LeadTran.Utils.Bounds();
	var iHide = 0;
	var self = this;
	
	this.ontabselected = null;
	this.disabled = false;
	
	var Controls = {};
	
	Controls.Item = function(parent, element, content, taboptions, tabcontent, index, eventselect, eventupdatebounds)
	{
		var oElement = element;
		var oContent = content;
		var oParent = parent;
		var iIndex = ((index != null) && (isNaN(index) == false) && (index >= 0)) ? index : -1;
		var bSelected = false;
		var oBounds = new com.LeadTran.Utils.Bounds();
		var bVisible = true;
		var self = this;
		
		function Constructor()
		{
			try
			{
				if ((oElement != null) && (oContent != null) && (oParent != null) && (taboptions != null) && (tabcontent != null))
				{
					com.LeadTran.Utils.RemoveElement(oElement);
					oElement.onclick = OnTabClick;
					oElement.style.display = "block";
					com.LeadTran.Utils.AddElement(oElement, taboptions);
					com.LeadTran.Utils.DisableSelection(oElement);
					
					updateBounds("create");
					
					com.LeadTran.Utils.RemoveElement(oContent);
					oContent.style.display = "none";
					oContent.style.width = "100%";
					com.LeadTran.Utils.AddElement(oContent, tabcontent);
				}
			}catch(e){}
		}
		
		this.target = function()
		{
			return oElement;
		}
		
		this.content = function()
		{
			return oContent;
		}
		
		this.parent = function()
		{
			return oParent;
		}
		
		this.index = function()
		{
			return iIndex;
		}
		
		this.select = function(value)
		{
			try
			{
				if ((value != null) && (oElement != null) && (oContent != null) && (oParent != null) && (oParent.disabled == false) && (bVisible == true))
				{
					selectedItem(value);
				}
			}catch(e){}
			
			return bSelected;
		}
		
		this.title = function(value)
		{
			try
			{
				if ((value != null) && (oElement != null) && ("innerText" in oElement) && (oParent != null) && (oParent.disabled == false))
				{
					if (value != oElement.innerText)
					{
						oElement.innerText = value;
						
						updateBounds("title");
					}
				}
			}catch(e){}
			
			return ((oElement != null) && ("innerText" in oElement)) ? oElement.innerText : "";
		}
		
		this.bounds = function()
		{
			return oBounds;
		}
		
		this.visible = function()
		{
			return bVisible;
		}
		
		this.show = function()
		{
			try
			{
				if ((oElement != null) && (oContent != null) && (oParent != null) && (oParent.disabled == false))
				{
					if (bVisible == false)
					{
						oElement.style.display = "block";
						bVisible = true;
						
						OnUpdatedBounds(null, "show");
						
					}	
				}
			}catch(e){}
		}
		
		this.hide = function()
		{
			try
			{
				if ((oElement != null) && (oContent != null) && (oParent != null) && (oParent.disabled == false))
				{
					if (bVisible == true)
					{
						oElement.style.display = "none";
						
						if (bSelected == true)
						{
							selectedItem(false);
						}
						
						bVisible = false;
						
						OnUpdatedBounds(null, "hide");
					}	
				}
			}catch(e){}
		}
		
		this.appendChild = function(child)
		{
			try
			{
				if ((oContent != null) && (child != null))
				{
					com.LeadTran.Utils.AddElement(child, oContent);
				}
			}catch(e){}
		}
		
		this.removeChild = function(child)
		{
			try
			{
				if ((oContent != null) && (child != null) && (child.parentNode != null) && (child.parentNode == oContent))
				{
					com.LeadTran.Utils.RemoveElement(child);
				}
			}catch(e){}
		}
		
		function selectedItem(value)
		{
			try
			{
				if ((value != null) && (oElement != null) && (oContent != null) && (oParent != null) && (oParent.disabled == false))
				{
					if ((value == true) && (bSelected == false)) 
					{
						com.LeadTran.Utils.AddClass(oElement, "tabselected");
						oContent.style.display = "block";
						bSelected = true;
						
						OnItemSelected();
					}
					else if ((value == false) && (bSelected == true))
					{
						com.LeadTran.Utils.RemoveClass(oElement, "tabselected");
						oContent.style.display = "none";
						bSelected = false;
						
						OnItemSelected();
					}
				}
			}catch(e){}
		}
		
		function OnTabClick()
		{
			try
			{
				selectedItem(true)
			}catch(e){}
		}
		
		function OnItemSelected()
		{
			try
			{
				if ((eventselect != null) && (typeof eventselect == "function"))
				{
					return eventselect.call(self);
				}
			}catch(e){}
			
			return false;
		}
		
		function OnUpdatedBounds(newbounds, updatetype)
		{
			try
			{
				if ((eventupdatebounds != null) && (typeof eventupdatebounds == "function"))
				{
					eventupdatebounds.call(self, oBounds, newbounds, updatetype);
				}
			}catch(e){}
		}
		
		function updateBounds(updatetype)
		{
			var updated = false;
			var newbounds = null;
			
			try
			{
				if ((oElement != null) && ("innerText" in oElement) && (updatetype != null) && (updatetype != ""))
				{
					var text = "";
					
					if (oElement.innerText != "")
					{
						text = oElement.innerText;
					}
					else if (oElement.innerHTML != "")
					{
						text = oElement.innerHTML;
					}
					
					newbounds = com.LeadTran.Utils.GetTextSize(text, 13, "Arial", "Bold");
					newbounds.width += 9;
					
					if ((newbounds.width != oBounds.width) || (newbounds.height != oBounds.height))
					{
						updated = true;
					}
				}
			}catch(e){}
			
			if ((updated == true) && (newbounds != null))
			{
				OnUpdatedBounds(newbounds, updatetype);
				
				oBounds.width = newbounds.width;
				oBounds.height = newbounds.height;
			}
		}
		
		Constructor();
	}
	
	function Constructor()
	{
		try 
		{	
			createTab();
		}catch(e){}
	}
	
	this.target = function()
	{
		return oElement;
	}
	
	this.size = function(width, height)
	{
		try
		{
			if ((oElement != null) && (oBounds != null) && (((width != null) && (isNaN(width) == false) && (width >= 100) && (width != oBounds.width)) || ((height != null) && (isNaN(height) == false) && (height >= 100) && (height != oBounds.height))))
			{
				configureTab(width, height);
			}
		}catch(e){}
		
		return com.LeadTran.Utils.GetElementBounds(oElement);
	}
	
	this.selectedIndex = function(index)
	{
		try
		{
			if ((index != null) && (isNaN(index) == false) && (oItems != null) && (index in oItems) && (oItems[index] != null) && (this.disabled == false))
			{
				enableSelectedEvent();
				oItems[index].select(true);
			}
		}catch(e){}
		
		return (oSelected != null) ? oSelected.index() : -1;
	}
	
	this.items = function(index)
	{
		try
		{
			if ((index != null) && (isNaN(index) == false) && (oItems != null) && (index in oItems) && (oItems[index] != null))
			{
				return oItems[index];
			}
		}catch(e){}
		
		return null;
	}
	
	this.createTab = function(title)
	{
		try
		{
			if ((title != null) && (oTabOptions != null) && (oTabContent != null) && (oItems != null))
			{
				var newElement = document.createElement("div");
				newElement.className = "tab";
				newElement.innerText = title;
				
				var newContent = document.createElement("div");
				newContent.className = "tabcontent";
				
				var newItem = new Controls.Item(self, newElement, newContent, oTabOptions, oTabContent, iCount, OnTabSelected, OnUpdateItemBounds);
				oItems[iCount] = newItem;
				
				if (iCount == 0)
				{
					disableSelectedEvent();
					
					newItem.select(true);
					oSelected = newItem;
					
					enableSelectedEvent();
				}
				
				iCount++;
				
				return newItem;
			}
		}catch(e){}
		
		return null;
	}
	
	function OnTabSelected()
	{
		if ((bDisableTabSelected == false) && (self.disabled == false))
		{
			try
			{
				if (oSelected != null)
				{
					disableSelectedEvent();
					
					oSelected.select(false);
					oSelected = null;
					
					enableSelectedEvent();
				}
				
				if (this.select() == true)
				{
					oSelected = this;
					viewCompleteItem(this);
				}
			}catch(e){}
			
			try
			{
				if ((self.ontabselected != null) && (typeof self.ontabselected == "function"))
				{
					self.ontabselected.call(this);
				}
			}catch(e){}
		}	
	}
	
	function OnMouseDownBackTab()
	{
		try
		{
			if ((oTabGlobalOptions != null) && (oTabGlobalOptions.scrollLeft >= 0))
			{
				var width = com.LeadTran.Utils.GetElementBounds(oTabGlobalOptions).width;
				
				oTabGlobalOptions.scrollLeft -= width;
				
				if (oTabGlobalOptions.scrollLeft < 0) oTabGlobalOptions.scrollLeft = 0;
			}
		}catch(e){}
	}
	
	function OnMouseDownNextTab()
	{
		try
		{
			if (oTabGlobalOptions != null)
			{
				var width = com.LeadTran.Utils.GetElementBounds(oTabGlobalOptions).width;
				oTabGlobalOptions.scrollLeft += width;
			}
		}catch(e){}
	}
	
	function createTab()
	{
		try 
		{	
			if (oElement != null)
			{
				var oNode = null;
				var oTabs = {};
				var iTabs = 0;
				var oContents = {};
				var iContents = 0;
				var oItem = null;
				
				if ((oElement.childNodes != null) && (oElement.childNodes.length > 0))
				{
					for (var i = 0; i < oElement.childNodes.length; i++)
					{
						try
						{
							oNode = oElement.childNodes[i];
							if ((oNode != null) && (oNode.nodeName != null) && (oNode.nodeName != "") && (oNode.nodeName.toLowerCase() == "div"))
							{
								if (oNode.className != null)
								{
									switch(oNode.className)
									{
										case "tab":
											oTabs[iTabs] = oNode;
											iTabs++;
											break;
											
										case "tabcontent":
											oContents[iContents] = oNode;
											iContents++;
											break;
											
										case "tabtoolbar":
											if (oTabToolbar == null)
											{
												oTabToolbar = oNode;
												oTabToolbar.className = "tabtoolbar";
											}
											break;
											
										case "tabstatusbar":
											if (oTabStatusBar == null)
											{
												oTabStatusBar = oNode;
												oTabStatusBar.className = "tabstatusbar";
											}
											break;
											
										default:
											com.LeadTran.Utils.RemoveElement(oNode);
											break;
									}
								}
								else
								{
									com.LeadTran.Utils.RemoveElement(oNode);
								}	
							}
						}catch(en){}
					}
				}
				
				oTabGlobalOptions = document.createElement("div");
				oTabGlobalOptions.className = "tabglobaloptions";
				com.LeadTran.Utils.AddElement(oTabGlobalOptions, oElement);
				
				oTabOptions = document.createElement("div");
				oTabOptions.className = "taboptions";
				oTabOptions.tabbed = {};
				oTabOptions.tabbed.bounds = null;
				configureDefaultTabOptions();
				com.LeadTran.Utils.AddElement(oTabOptions, oTabGlobalOptions);
				
				oBackTab = document.createElement("div");
				oBackTab.className = "backtab";
				oBackTab.onmousedown = OnMouseDownBackTab;
				
				oNextTab = document.createElement("div");
				oNextTab.className = "nexttab";
				oNextTab.onmousedown = OnMouseDownNextTab;
				
				oTabGlobalContent = document.createElement("div");
				oTabGlobalContent.className = "tabglobalcontent";
				
				oTabContent = document.createElement("div");
				oTabContent.className = "tabcontents";
				
				com.LeadTran.Utils.AddElement(oTabGlobalContent, oElement);
				com.LeadTran.Utils.AddElement(oTabContent, oTabGlobalContent);
				if (oTabToolbar != null) com.LeadTran.Utils.AddElement(oTabToolbar, oTabGlobalContent);
				if (oTabStatusBar != null) com.LeadTran.Utils.AddElement(oTabStatusBar, oTabGlobalContent);
				
				configureTab(100, 100);
				
				if ((oTabGlobalOptions != null) && (oTabGlobalContent != null) && (oTabOptions != null) && (oTabContent != null))
				{
					if ((iTabs > 0) && (iContents > 0))
					{
						for (var i = 0; i < iTabs; i++)
						{
							try
							{
								if ((i in oTabs) && (oTabs[i] != null) && (i in oContents) && (oContents[i] != null))
								{
									oItem = new Controls.Item(self, oTabs[i], oContents[i], oTabOptions, oTabContent, iCount, OnTabSelected, OnUpdateItemBounds);
									oItems[iCount] = oItem;
									
									if (iCount == 0)
									{
										disableSelectedEvent();
										
										oItem.select(true);
										oSelected = oItem;
										
										enableSelectedEvent();
									}
									
									iCount++;
								}
							}catch(en){}
						}
					}
				}
				
				oElement.style.visibility = "visible";
			}
		}catch(e){}
	}
	
	function disableSelectedEvent()
	{
		try
		{
			bDisableTabSelected = true;
		}catch(e){}
	}
	
	function enableSelectedEvent()
	{
		try
		{
			bDisableTabSelected = false;
		}catch(e){}
	}
	
	function configureDefaultTabOptions()
	{
		try
		{
			if (oTabOptions != null)
			{
				oTabOptions.style.minWidth = "0px";
				oTabOptions.style.maxWidth = "0px";
				oTabOptions.style.width = "0px";
				oTabOptions.style.minHeight = "100%";
				oTabOptions.style.maxHeight = "100%";
				oTabOptions.style.height = "100%";
				oTabOptions.tabbed.bounds = new com.LeadTran.Utils.Bounds();
			}	
		}catch(e){}
	}
	
	function getTabOptionsBounds()
	{
		try
		{
			if (oTabOptions != null)
			{
				if (oTabOptions.tabbed.bounds == null)
				{
					oTabOptions.tabbed.bounds = com.LeadTran.Utils.GetElementBounds(oTabOptions);
				}
				
				return oTabOptions.tabbed.bounds;
			}	
		}catch(e){}
		
		return new com.LeadTran.Utils.Bounds();
	}
	
	function configureTab(width, height)
	{
		try
		{
			if ((oElement != null) && (oBounds != null) && (((width != null) && (isNaN(width) == false) && (width >= 100)) || ((height != null) && (isNaN(height) == false) && (height >= 100))))
			{
				if (updateTabSize(width, height) == true)
				{
					var bounds = null;
					var optionswidth = 0;
					var globaloptionswidth = 0;
					var contentwidth = 0;
					var contentheight = 0;
					var reduceWidth = 0;
					var reduceHeight = 0;
					var itemcontentheight = 0;
					
					if (oTabOptions != null)
					{
						bounds = getTabOptionsBounds();
						optionswidth = bounds.width;
						
						if (optionswidth > width)
						{
							if (showOptionsControl() == true)
							{
								reduceWidth = 28;
								if (oTabGlobalOptions != null) oTabGlobalOptions.style.marginLeft = "14px";
							}
						}
						else
						{
							removeOptionsControl();
							oTabGlobalOptions.style.marginLeft = "0px";
						}
					}
					
					if (oTabGlobalOptions != null)
					{
						bounds = com.LeadTran.Utils.GetElementBounds(oTabGlobalOptions);
						
						globaloptionswidth = width - reduceWidth;
						
						oTabGlobalOptions.style.minWidth = globaloptionswidth + "px";
						oTabGlobalOptions.style.maxWidth = globaloptionswidth + "px";
						oTabGlobalOptions.style.width = globaloptionswidth + "px";
						oTabGlobalOptions.style.minHeight = "24px";
						oTabGlobalOptions.style.maxHeight = "24px";
						oTabGlobalOptions.style.height = "24px";
						
						reduceHeight += bounds.height;
					}
					
					if (oTabGlobalContent != null)
					{
						contentwidth = width - 2;
						contentheight = height - reduceHeight - 1;
						
						oTabGlobalContent.style.minWidth = contentwidth + "px";
						oTabGlobalContent.style.maxWidth = contentwidth + "px";
						oTabGlobalContent.style.width = contentwidth + "px";
						oTabGlobalContent.style.minHeight = contentheight + "px";
						oTabGlobalContent.style.maxHeight = contentheight + "px";
						oTabGlobalContent.style.height = contentheight + "px";
					}
					
					reduceHeight = 0;
					
					if (oTabToolbar != null)
					{
						bounds = com.LeadTran.Utils.GetElementBounds(oTabToolbar);
						
						oTabToolbar.style.minWidth = "100%";
						oTabToolbar.style.maxWidth = "100%";
						oTabToolbar.style.width = "100%";
						oTabToolbar.style.minHeight = bounds.height + "px";
						oTabToolbar.style.maxHeight = bounds.height + "px";
						oTabToolbar.style.height = bounds.height + "px";
						
						reduceHeight += bounds.height;
					}
					
					if (oTabStatusBar != null)
					{
						bounds = com.LeadTran.Utils.GetElementBounds(oTabStatusBar);
						
						oTabStatusBar.style.minWidth = "100%";
						oTabStatusBar.style.maxWidth = "100%";
						oTabStatusBar.style.width = "100%";
						oTabStatusBar.style.minHeight = bounds.height + "px";
						oTabStatusBar.style.maxHeight = bounds.height + "px";
						oTabStatusBar.style.height = bounds.height + "px";
						
						reduceHeight += bounds.height;
					}
					
					if (oTabContent != null)
					{
						itemcontentheight = contentheight - reduceHeight;
						
						oTabContent.style.minWidth = "100%";
						oTabContent.style.maxWidth = "100%";
						oTabContent.style.width = "100%";
						oTabContent.style.minHeight = itemcontentheight + "px";
						oTabContent.style.maxHeight = itemcontentheight + "px";
						oTabContent.style.height = itemcontentheight + "px";
					}
				}	
			}
		}catch(e){}
	}
	
	function updateTabSize(width, height)
	{
		var updated = false;
		
		try
		{
			if ((oElement != null) && (oBounds != null))
			{
				if ((width != null) && (isNaN(width) == false) && (width >= 100) && (width != oBounds.width))
				{
					oElement.style.minWidth = width + "px";
					oElement.style.maxWidth = width + "px";
					oElement.style.width = width + "px";
					
					oBounds.width = width;
					
					updated = true;
				}
				
				if ((height != null) && (isNaN(height) == false) && (height >= 100) && (height != oBounds.height))
				{
					oElement.style.minHeight = height + "px";
					oElement.style.maxHeight = height + "px";
					oElement.style.height = height + "px";
					
					oBounds.height = height;
					
					updated = true;
				}
			}	
		}catch(e){}
		
		return updated;
	}
	
	function showOptionsControl()
	{
		var show = false;
		
		try
		{
			if ((oElement != null) && (oTabGlobalOptions != null))
			{
				var bounds = com.LeadTran.Utils.GetElementBounds(oElement);
				
				if (oBackTab != null)
				{
					oBackTab.style.marginTop = "3px";
					oBackTab.style.marginLeft = "2px";
					oBackTab.style.display = "block";
					com.LeadTran.Utils.AddElement(oBackTab, oElement);
					show = true;
				}
				
				if (oNextTab != null)
				{
					oNextTab.style.marginTop = "3px";
					oNextTab.style.marginLeft = (bounds.width - 10) + "px";
					oNextTab.style.display = "block";
					com.LeadTran.Utils.AddElement(oNextTab, oElement);
					show = true;
				}
			}
		}catch(e){}
		
		return show;
	}
	
	function removeOptionsControl()
	{
		try
		{
			if (oTabGlobalOptions != null)
			{
				if (oBackTab != null)
				{
					oBackTab.style.display = "none";
					com.LeadTran.Utils.RemoveElement(oBackTab);
				}
				
				if (oNextTab != null)
				{
					oNextTab.style.display = "none";
					com.LeadTran.Utils.RemoveElement(oNextTab);
				}
			}
		}catch(e){}
	}
	
	function viewCompleteItem(item)
	{
		try
		{
			if ((oTabGlobalOptions != null) && (item != null))
			{
				var width = com.LeadTran.Utils.GetElementBounds(oTabGlobalOptions).width;
				var optionwidth = com.LeadTran.Utils.GetElementBounds(oTabOptions).width;
				var itembounds = item.bounds();
				var itemleft = itembounds.left - 1;
				var itemwidth = itembounds.width;
				
				if ((itembounds.left + itemwidth) >= optionwidth)
				{
					oTabGlobalOptions.scrollLeft = itembounds.left;
				}
				else
				{
					if (itemwidth > width)
					{
						oTabGlobalOptions.scrollLeft = itemleft;
					}
					else
					{
						if (itemleft < oTabGlobalOptions.scrollLeft)
						{
							oTabGlobalOptions.scrollLeft = itemleft;
						}
						else
						{
							oTabGlobalOptions.scrollLeft = (itemleft + itemwidth) - (oTabGlobalOptions.scrollLeft + width);
						}
					}
				}	
			}
		}catch(e){}
	}
	
	function OnUpdateItemBounds(lastbounds, newbounds, updatetype)
	{
		try
		{
			if ((lastbounds != null) && (updatetype != null) && (updatetype != ""))
			{
				var taboptionsbounds = null;
				var bounds = null;
				var updated = false;
				var extraWidth = 0;
				var reduceWidth = 0;
				var globaloptionswidth = 0;
				
				switch(updatetype)
				{
					case "create":
						if (this.visible() == false) return;
						if ((newbounds != null) && (newbounds.width > 0))
						{
							if (oTabOptions != null)
							{
								taboptionsbounds = getTabOptionsBounds();
								this.bounds().left = taboptionsbounds.width;
								taboptionsbounds.width += newbounds.width;
								updated = true;
							}
						}
						break;
						
					case "title":
						if (this.visible() == false) return;
						if ((newbounds != null) && (newbounds.width > 0))
						{
							extraWidth = newbounds.width - lastbounds.width;
							
							if ((oTabOptions != null) && (extraWidth != 0))
							{
								taboptionsbounds = getTabOptionsBounds();
								taboptionsbounds.width += extraWidth;
								
								configureItemPositionFrom(this.index(), extraWidth);
								
								updated = true;
							}
						}
						break;
						
					case "hide":
						extraWidth = -lastbounds.width;
						if (oTabOptions != null)
						{
							taboptionsbounds = getTabOptionsBounds();
							taboptionsbounds.width += extraWidth;
							
							configureItemPositionFrom(this.index(), extraWidth);
							
							if (iCount > 1)
							{
								if (this.index() == (iCount -1))
								{
									self.selectedIndex(this.index() - 1);
								}
								else
								{
									if (this.index() == 0)
									{
										self.selectedIndex(this.index() + 1);
									}
									else
									{
										self.selectedIndex(this.index() - 1);
									}
								}
							}
							
							iHide++;
							if (iHide >= iCount)
							{
								oSelected = null;
								iHide = iCount;
							}
							
							updated = true;
						}
						break;
						
					case "show":
						extraWidth = lastbounds.width;
						if (oTabOptions != null)
						{
							taboptionsbounds = getTabOptionsBounds();
							taboptionsbounds.width += extraWidth;
							
							configureItemPositionFrom(this.index(), extraWidth);
							
							if (iHide >= iCount)
							{
								this.select(true);
							}
							
							iHide--;
							if (iHide < 0) iHide = 0;
							
							updated = true;
						}
						break;
				}
				
				if ((updated == true) && (taboptionsbounds != null))
				{
					if (oTabOptions != null)
					{
						if (taboptionsbounds.width > oBounds.width)
						{
							if (showOptionsControl() == true)
							{
								reduceWidth = 28;
								if (oTabGlobalOptions != null) oTabGlobalOptions.style.marginLeft = "14px";
							}
						}
						else
						{
							removeOptionsControl();
							oTabGlobalOptions.style.marginLeft = "0px";
						}
						
						oTabOptions.style.minWidth = taboptionsbounds.width + "px";
						oTabOptions.style.maxWidth = taboptionsbounds.width + "px";
						oTabOptions.style.width = taboptionsbounds.width + "px";
					}
					
					if ((oTabGlobalOptions != null) && (reduceWidth != 0))
					{
						globaloptionswidth = oBounds.width - reduceWidth;
						
						oTabGlobalOptions.style.minWidth = globaloptionswidth + "px";
						oTabGlobalOptions.style.maxWidth = globaloptionswidth + "px";
						oTabGlobalOptions.style.width = globaloptionswidth + "px";
					}
				}
			}
		}catch(e){}
	}
	
	function configureItemPositionFrom(index, width)
	{
		try
		{
			if ((oItems != null) && (iCount > 0) && (index != null) && (isNaN(index) == false) && (index >= 0) && ((index + 1) <= (iCount - 1)) && (width != null) && (isNaN(width) == false) && (width != 0))
			{
				var oItem = null;
				
				for(var i = (index + 1); i < iCount; i++)
				{
					oItem = oItems[i];
					if (oItem != null)
					{
						oItem.bounds().left += width;
					}
				}
			}
		}catch(e){}
	}
	
	Constructor();
}

com.LeadTran.Map = function(mapname, parentelement)
{
	var oElement = null;
	var oMap = null;
	var sName = ((mapname != null) && (str_trim(mapname) != "")) ? mapname : null;
	var oImage = null;
	var oParent = parentelement;
	var oBounds = new com.LeadTran.Utils.Bounds();
	var bVisible = false;
	var bDisabled = false;
	var bDebug = false;
	var oStates = {};
	var iCount = 0;
	
	var oLabel = null;
	var oRowContent = null;
	var oDebugReset = null;
	var oDebugContent = null;
	var oDebugMousePosition = null;
	var oDebugCoords = null;
	var oButtonDebug = null;
	var oElementDebug = null;
	var oWindowDebug = null;
	
	var self = this;
	
	this.tag = null;
	this.onitemclick = null;
	
	var Controls = {};
	
	Controls.Item = function(parent, parentelement, map, statename, index, size, location, coords, defaultimg, selectedimg, hoverimg, eventmousemove, eventclick)
	{
		var oParent = parent;
		var iIndex = ((index != null) && (isNaN(index) == false) && (index >= 0)) ? index : -1;
		var sName = ((statename != null) && (str_trim(statename) != "")) ? statename : null;
		var oBounds = new com.LeadTran.Utils.Bounds();
		var bSelected = false;
		var bCreated = false;
		var oArea = null;
		var oDefaultImage = null;
		var oSelectedImage = null;
		var oHoverImage = null;
		var self = this;
		
		this.tag = null;
		
		function Constructor()
		{
			try 
			{
				if ((oParent != null) && (parentelement != null) && (map != null))
				{
					createState();
				}
			}catch(e){}
		}
		
		this.parent = function()
		{
			return oParent;
		}
		
		this.index = function()
		{
			return iIndex;
		}
		
		this.name = function()
		{
			return sName;
		}
		
		this.size = function(width, height)
		{
			try
			{
				if ((bCreated == true) && (oBounds != null) && (((width != null) && (isNaN(width) == false) && (width >= 10) && (width != oBounds.width)) || ((height != null) && (isNaN(height) == false) && (height >= 10) && (height != oBounds.height))))
				{
					if ((oParent != null) && (oParent.disabled() == false))
					{
						configureStateSize(width, height);
					}
				}
			}catch(e){}
			
			return oBounds;
		}
		
		this.bounds = function()
		{
			return oBounds;
		}
		
		this.select = function(value)
		{
			try
			{
				if ((value != null) && (bCreated == true) && ((value == true) || (value == false)) && (value != bSelected))
				{
					if ((oParent != null) && (oParent.disabled() == false))
					{
						if (value == true)
						{
							showImage("selected");
						}
						else
						{
							hideImage("selected");
						}
						
						bSelected = value;
					}	
				}
			}catch(e){}
			
			return bSelected;
		}
		
		this.created = function()
		{
			return bCreated;
		}
		
		function createState()
		{
			try 
			{	
				if ((sName != null) && (size != null) && ("width" in size) && (isNaN(size.width) == false) && ("height" in size) && (isNaN(size.height) == false) && (location != null) && ("left" in location) && (isNaN(location.left) == false) && ("top" in location) && (isNaN(location.top) == false) && (defaultimg != null) && (selectedimg != null) && (coords != null) && (((typeof coords == "string") && (str_trim(coords) != "")) || (typeof coords == "object")) && (str_trim(defaultimg) != "") && (str_trim(selectedimg) != ""))
				{
					if (typeof coords == "string")
					{
						oArea = document.createElement("area");
						oArea.setAttribute("shape", "poly");
						oArea.setAttribute("coords", coords);
						oArea.className = "state";
						oArea.onmouseover = OnMouseOver;
						oArea.onmouseout = OnMouseOut;
						oArea.onmousemove = OnMouseMove;
						oArea.onclick = OnClick;
						com.LeadTran.Utils.AddElement(oArea, map);
					}
					else if (typeof coords == "object")
					{
						var coord = "";
						
						for(var key in coords)
						{
							coord = coords[key];
							if (str_trim(coord) != "")
							{
								oArea = document.createElement("area");
								oArea.setAttribute("shape", "poly");
								oArea.setAttribute("coords", coord);
								oArea.className = "state";
								oArea.onmouseover = OnMouseOver;
								oArea.onmouseout = OnMouseOut;
								oArea.onmousemove = OnMouseMove;
								oArea.onclick = OnClick;
								com.LeadTran.Utils.AddElement(oArea, map);
							}
						}
					}
					
					oDefaultImage = document.createElement("img");
					oDefaultImage.src = defaultimg;
					oDefaultImage.style.backgroundColor = "transparent";
					oDefaultImage.style.border = "none";
					oDefaultImage.style.position = "absolute";
					oDefaultImage.style.zIndex = "3";
					oDefaultImage.style.display = "block";
					com.LeadTran.Utils.DisableSelection(oDefaultImage);
					com.LeadTran.Utils.AddElement(oDefaultImage, parentelement);
					
					oSelectedImage = document.createElement("img");
					oSelectedImage.src = selectedimg;
					oSelectedImage.style.backgroundColor = "transparent";
					oSelectedImage.style.border = "none";
					oSelectedImage.style.position = "absolute";
					oSelectedImage.style.zIndex = "3";
					oSelectedImage.style.display = "none";
					com.LeadTran.Utils.DisableSelection(oSelectedImage);
					com.LeadTran.Utils.AddElement(oSelectedImage, parentelement);
					
					if ((hoverimg != null) && (str_trim(hoverimg) != ""))
					{
						oHoverImage = document.createElement("img");
						oHoverImage.src = hoverimg;
						oHoverImage.style.backgroundColor = "transparent";
						oHoverImage.style.border = "none";
						oHoverImage.style.position = "absolute";
						oHoverImage.style.zIndex = "3";
						oHoverImage.style.display = "none";
						com.LeadTran.Utils.DisableSelection(oHoverImage);
						com.LeadTran.Utils.AddElement(oHoverImage, parentelement);
					}
					
					configureStateSize(size.width, size.height);
					configureDefaultStateLocation();
					configureStateLocation(location.top, location.left);
					
					bCreated = true;
				}
			}catch(e){}
		}
		
		function configureStateSize(width, height)
		{
			try
			{
				if ((oBounds != null) && (((width != null) && (isNaN(width) == false) && (width >= 10)) || ((height != null) && (isNaN(height) == false) && (height >= 10))))
				{
					if (width != oBounds.width)
					{
						if (oDefaultImage != null)
						{
							oDefaultImage.style.minWidth = width + "px";
							oDefaultImage.style.maxWidth = width + "px";
							oDefaultImage.style.width = width + "px";
						}
						
						if (oSelectedImage != null)
						{
							oSelectedImage.style.minWidth = width + "px";
							oSelectedImage.style.maxWidth = width + "px";
							oSelectedImage.style.width = width + "px";
						}
						
						if (oHoverImage != null)
						{
							oHoverImage.style.minWidth = width + "px";
							oHoverImage.style.maxWidth = width + "px";
							oHoverImage.style.width = width + "px";
						}
						
						oBounds.width = width;
					}
					
					if (height != oBounds.height)
					{
						if (oDefaultImage != null)
						{
							oDefaultImage.style.minHeight = height + "px";
							oDefaultImage.style.maxHeight = height + "px";
							oDefaultImage.style.height = height + "px";
						}
						
						if (oSelectedImage != null)
						{
							oSelectedImage.style.minHeight = height + "px";
							oSelectedImage.style.maxHeight = height + "px";
							oSelectedImage.style.height = height + "px";
						}
						
						if (oHoverImage != null)
						{
							oHoverImage.style.minHeight = height + "px";
							oHoverImage.style.maxHeight = height + "px";
							oHoverImage.style.height = height + "px";
						}
						
						oBounds.height = height;
					}
				}
			}catch(e){}
		}
		
		function configureDefaultStateLocation()
		{
			try
			{
				if ((oParent != null) && (oParent.size() != null))
				{
					var parentsize = oParent.size();
					var realtop = - parentsize.height;
					
					if (oDefaultImage != null)
					{
						oDefaultImage.style.marginTop = realtop + "px";
						oDefaultImage.style.marginLeft = "0px";
					}
					
					if (oSelectedImage != null)
					{
						oSelectedImage.style.marginTop = realtop + "px";
						oSelectedImage.style.marginLeft = "0px";
					}
					
					if (oHoverImage != null)
					{
						oHoverImage.style.marginTop = realtop + "px";
						oHoverImage.style.marginLeft = "0px";
					}
				}
					
			}catch(e){}
		}
		
		function configureStateLocation(top, left)
		{
			try
			{
				if ((oBounds != null) && (oParent != null) && (oParent.size() != null) && (((top != null) && (isNaN(top) == false)) || ((left != null) && (isNaN(left) == false))))
				{
					var parentsize = oParent.size();
					
					if (top != oBounds.top)
					{
						var realtop = (parentsize.height > top) ? top - parentsize.height : 0;
						
						if (oDefaultImage != null)
						{
							oDefaultImage.style.marginTop = realtop + "px";
						}
						
						if (oSelectedImage != null)
						{
							oSelectedImage.style.marginTop = realtop + "px";
						}
						
						if (oHoverImage != null)
						{
							oHoverImage.style.marginTop = realtop + "px";
						}
						
						oBounds.top = top;
					}
					
					if (left != oBounds.left)
					{
						if (oDefaultImage != null)
						{
							oDefaultImage.style.marginLeft = left + "px";
						}
						
						if (oSelectedImage != null)
						{
							oSelectedImage.style.marginLeft = left + "px";
						}
						
						if (oHoverImage != null)
						{
							oHoverImage.style.marginLeft = left + "px";
						}
						
						oBounds.left = left;
					}
				}
			}catch(e){}
		}
		
		function OnMouseOver()
		{
			try
			{
				if ((oParent != null) && (oParent.disabled() == false) && (oParent.debug() == false)) showImage("hover");
			}catch(e){}
		}
		
		function OnMouseOut()
		{
			try
			{
				if ((oParent != null) && (oParent.disabled() == false) && (oParent.debug() == false)) hideImage("hover");
			}catch(e){}
		}
		
		function OnMouseMove(ev)
		{
			try
			{
				
			}catch(e){}
			
			OnItemMouseMove(ev);
		}
		
		function OnClick(ev)
		{
			try
			{
				
			}catch(e){}
			
			OnItemClick(ev);
		}
		
		function OnItemMouseMove(ev)
		{
			try
			{
				if ((eventmousemove != null) && (typeof eventmousemove == "function"))
				{
					eventmousemove.call(self, ev);
				}
			}catch(e){}
		}
		
		function OnItemClick(ev)
		{
			try
			{
				if ((eventclick != null) && (typeof eventclick == "function"))
				{
					eventclick.call(self, ev);
				}
			}catch(e){}
		}
		
		function showImage(type)
		{
			try
			{
				if ((type != null) && (type != ""))
				{
					switch(type)
					{
						case "default":
							if (oDefaultImage != null)
							{
								if (oSelectedImage != null) oSelectedImage.style.display = "none";
								if (oHoverImage != null) oHoverImage.style.display = "none";
								
								oDefaultImage.style.display = "block";
							}
							break;
							
						case "selected":
							if (oSelectedImage != null)
							{
								if (oDefaultImage != null) oDefaultImage.style.display = "none";
								if (oHoverImage != null) oHoverImage.style.display = "none";
								
								oSelectedImage.style.display = "block";
							}
							break;
							
						case "hover":
							if (oHoverImage != null)
							{
								if (oDefaultImage != null) oDefaultImage.style.display = "none";
								if (oSelectedImage != null) oSelectedImage.style.display = "none";
								
								oHoverImage.style.display = "block";
							}
							break;
					}
				}
			}catch(e){}
		}
		
		function hideImage(type)
		{
			try
			{
				if ((type != null) && (type != ""))
				{
					switch(type)
					{
						case "default":
							if (oDefaultImage != null)
							{
								if (oSelectedImage != null) oSelectedImage.style.display = "none";
								if (oHoverImage != null) oHoverImage.style.display = "none";
								
								oDefaultImage.style.display = "none";
							}
							break;
							
						case "selected":
							if (oSelectedImage != null)
							{
								oSelectedImage.style.display = "none";
								if (oHoverImage != null) oHoverImage.style.display = "none";
								if (oDefaultImage != null) oDefaultImage.style.display = "block";
							}
							break;
							
						case "hover":
							if (oHoverImage != null)
							{
								oHoverImage.style.display = "none";
								if (oSelectedImage != null) oSelectedImage.style.display = "none";
								if (oDefaultImage != null) oDefaultImage.style.display = "block";
							}
							break;
					}
				}
			}catch(e){}
		}
		
		function hideImages()
		{
			try
			{
				if (oDefaultImage != null) oDefaultImage.style.display = "none";
				if (oSelectedImage != null) oSelectedImage.style.display = "none";
				if (oHoverImage != null) oHoverImage.style.display = "none";
			}catch(e){}
		}
		
		Constructor();
	}
	
	function Constructor()
	{
		try 
		{
			if (sName != null)
			{
				createMap();
				
				if ((oElement != null) && (oParent != null))
				{
					com.LeadTran.Utils.AddElement(oElement, oParent);
				}
			}	
		}catch(e){}
	}
	
	this.target = function()
	{
		return oElement;
	}
	
	this.parent = function()
	{
		return oParent;
	}
	
	this.map = function()
	{
		return oMap;
	}
	
	this.visible = function()
	{
		return bVisible;
	}
	
	this.name = function()
	{
		return sName;
	}
	
	this.show = function()
	{
		try
		{
			if ((oElement != null) && (bDisabled == false))
			{
				if (bVisible == false)
				{
					oElement.style.display = "block";
					if (oImage != null) oImage.style.display = "block";
					bVisible = true;
				}	
			}
		}catch(e){}
	}
	
	this.hide = function()
	{
		try
		{
			if ((oElement != null) && (bDisabled == false))
			{
				if (bVisible == true)
				{
					self.debug(false);
					
					oElement.style.display = "none";
					if (oImage != null) oImage.style.display = "none";
					bVisible = false;
				}	
			}
		}catch(e){}
	}
	
	this.disabled = function(value)
	{
		try
		{
			if ((value != null) && ((value == true) || (value == false)) && (value != bDisabled))
			{
				bDisabled = value;
			}
		}catch(e){}
		
		return bDisabled;
	}
	
	this.size = function(width, height)
	{
		try
		{
			if ((oElement != null) && (oBounds != null) && (((width != null) && (isNaN(width) == false) && (width >= 50) && (width != oBounds.width)) || ((height != null) && (isNaN(height) == false) && (height >= 50) && (height != oBounds.height))))
			{
				if (bDebug == false) configureMap(width, height);
			}
		}catch(e){}
		
		return oBounds;
	}
	
	this.bounds = function()
	{
		return oBounds;
	}
	
	this.states = function(index)
	{
		try
		{
			if ((index != null) && (isNaN(index) == false) && (oStates != null) && (index in oStates) && (oStates[index] != null))
			{
				return oStates[index];
			}
		}catch(e){}
		
		return null;
	}
	
	this.getStateByName = function(statename)
	{
		try
		{
			if ((statename != null) && (statename != "") && (oStates != null) && (statename in oStates) && (oStates[statename] != null))
			{
				return oStates[statename];
			}
		}catch(e){}
		
		return null;
	}
	
	this.selectStateByName = function(statename, value)
	{
		try
		{
			if ((statename != null) && (statename != "") && (oStates != null) && (value != null) && ((value == true) || (value == false)) && (statename in oStates) && (oStates[statename] != null))
			{
				oStates[statename].select(value);
			}
		}catch(e){}
	}
	
	this.selectAll = function(value)
	{
		try
		{
			if ((value != null) && ((value == true) || (value == false)) && (oStates != null) && (iCount > 0))
			{
				for(var key in oStates)
				{
					if (oStates[key] != null)
					{
						try
						{
							oStates[key].select(value);
						}catch(ef){}
					}
				}
			}
		}catch(e){}
	}
	
	this.count = function()
	{
		return iCount;
	}
	
	this.debug = function(value)
	{
		try
		{
			if ((value != null) && ((value == true) || (value == false)) && (value != bDebug) && (bVisible == true) && (bDisabled == false) && (oElement != null))
			{
				if (value == true)
				{
					if (oImage != null)
					{
						oImage.onmousemove = OnImageMouseMove;
						oImage.onclick = OnImageMouseClick;
					}
					
					if (oButtonDebug != null) oButtonDebug.style.display = "block";
				}
				else
				{
					if (oImage != null)
					{
						oImage.onmousemove = null;
						oImage.onclick = null;
					}
					
					if ((oWindowDebug != null) && (oWindowDebug.visible() == true)) oWindowDebug.hide();
					if (oButtonDebug != null) oButtonDebug.style.display = "none";
				}
				
				bDebug = value;
			}
		}catch(e){}
		
		return bDebug;
	}
	
	this.image = function(value)
	{
		try
		{
			if ((value != null) && (value != "") && (oImage != null))
			{
				oImage.src = value;
			}
		}catch(e){}
		
		return ((oImage != null) && ("src" in oImage)) ? oImage.src : "";
	}
	
	this.createState = function(statename, size, location, coords, defaultimg, selectedimg, hoverimg)
	{
		try
		{
			if ((statename != null) && (size != null) && ("width" in size) && (isNaN(size.width) == false) && ("height" in size) && (isNaN(size.height) == false) && (location != null) && ("left" in location) && (isNaN(location.left) == false) && ("top" in location) && (isNaN(location.top) == false) && (defaultimg != null) && (selectedimg != null) && (str_trim(statename) != "") && (coords != null) && (((typeof coords == "string") && (str_trim(coords) != "")) || (typeof coords == "object")) && (str_trim(defaultimg) != "") && (str_trim(selectedimg) != ""))
			{
				if ((statename in oStates) == false)
				{
					var newstate = new Controls.Item(this, oElement, oMap, statename, iCount, size, location, coords, defaultimg, selectedimg, hoverimg, OnItemMouseMove, OnItemClick);
					if ((newstate != null) && (newstate.created() == true))
					{
						oStates[iCount] = newstate;
						oStates[statename] = newstate;
						iCount++;
						
						return newstate;
					}
				}	
			}
		}catch(e){}
		
		return null;
	}
	
	function createMap()
	{
		try 
		{	
			if (oElement == null)
			{
				oElement = document.createElement("div");
				oElement.style.display = "none";
				oElement.style.backgroundColor = "transparent";
				
				oImage = document.createElement("img");
				oImage.setAttribute("usemap", "#" + sName);
				com.LeadTran.Utils.AddElement(oImage, oElement);
				
				oMap = document.createElement("map");
				oMap.style.border = "none";
				oMap.name = sName;
				com.LeadTran.Utils.AddElement(oMap, oElement);
				
				oButtonDebug = document.createElement("input");
				oButtonDebug.type = "button";
				oButtonDebug.value = "Debug";
				oButtonDebug.style.fontSize = "10px";
				oButtonDebug.style.position = "absolute";
				oButtonDebug.style.zIndex = "6";
				oButtonDebug.style.display = "none";
				oButtonDebug.style.marginTop = "-30px";
				oButtonDebug.onclick = OnClickDebug;
				com.LeadTran.Utils.AddElement(oButtonDebug, oElement);
				
				oElementDebug = document.createElement("div");
				oElementDebug.innerHTML = "<div class=\"windowheader\"><span class=\"title\">" + sName + " Map Debug</span><div class=\"buttonclose\"></div></div><div class=\"windowcontent\"></div>";
				oElementDebug.className = "systemwindow";
				com.LeadTran.Utils.AddElement(oElementDebug, oElement);
				
				oDebugContent = document.createElement("div");
				oDebugContent.style.padding = "4px";
				oDebugContent.style.width = "192px";
				
				oRowContent = document.createElement("div");
				oRowContent.style.width = "100%";
				oLabel = document.createElement("span");
				oLabel.innerText = "Position: ";
				oDebugMousePosition = document.createElement("input");
				oDebugMousePosition.setAttribute("readonly", "");
				oDebugMousePosition.style.width = "137px";
				oDebugMousePosition.style.backgroundColor = "white";
				oDebugMousePosition.style.border = "solid 1px #D5D5D5";
				com.LeadTran.Utils.AddElement(oLabel, oRowContent);
				com.LeadTran.Utils.AddElement(oDebugMousePosition, oRowContent);
				com.LeadTran.Utils.AddElement(oRowContent, oDebugContent);
				
				oRowContent = document.createElement("div");
				oRowContent.style.width = "100%";
				oRowContent.style.textAlign = "center";
				oRowContent.style.marginTop = "3px";
				oLabel = document.createElement("span");
				oLabel.innerText = "Coords: ";
				oDebugCoords = document.createElement("textarea");
				oDebugCoords.style.textAlign = "left";
				oDebugCoords.style.overflow = "auto";
				oDebugCoords.style.width = "188px";
				oDebugCoords.style.height = "86px";
				oDebugCoords.style.backgroundColor = "white";
				oDebugCoords.style.border = "solid 1px #D5D5D5";
				oDebugReset = document.createElement("input");
				oDebugReset.type = "button";
				oDebugReset.value = "Reset";
				oDebugReset.style.fontSize = "10px";
				oDebugReset.onclick = OnClickReset;
				com.LeadTran.Utils.AddElement(oLabel, oRowContent);
				com.LeadTran.Utils.AddElement(oDebugCoords, oRowContent);
				com.LeadTran.Utils.AddElement(oDebugReset, oRowContent);
				com.LeadTran.Utils.AddElement(oRowContent, oDebugContent);
				
				oWindowDebug = com.LeadTran.Window.create(oElementDebug);
				oWindowDebug.appendChild(oDebugContent);
				oWindowDebug.onopening = OnWindowDebugOpening;
				oWindowDebug.size(200,180);
				
				configureMap(50, 50);
				configureDefaultImageMap();
			}
		}catch(e){}
	}
	
	function configureMap(width, height)
	{
		try
		{
			if ((oElement != null) && (oBounds != null) && (((width != null) && (isNaN(width) == false) && (width >= 50)) || ((height != null) && (isNaN(height) == false) && (height >= 50))))
			{
				if (width != oBounds.width)
				{
					oElement.style.minWidth = width + "px";
					oElement.style.maxWidth = width + "px";
					oElement.style.width = width + "px";
					
					oBounds.width = width;
				}
				
				if (height != oBounds.height)
				{
					oElement.style.minHeight = height + "px";
					oElement.style.maxHeight = height + "px";
					oElement.style.height = height + "px";
					
					oBounds.height = height;
				}
			}
		}catch(e){}
	}
	
	function configureDefaultImageMap()
	{
		try
		{
			if (oImage != null)
			{
				oImage.style.backgroundColor = "transparent";
				oImage.style.border = "none";
				oImage.style.position = "relative";
				oImage.style.zIndex = "5";
				oImage.style.minWidth = "100%";
				oImage.style.maxWidth = "100%";
				oImage.style.width = "100%";
				oImage.style.minHeight = "100%";
				oImage.style.maxHeight = "100%";
				oImage.style.height = "100%";
				oImage.style.display = "none";
			}	
		}catch(e){}
	}
	
	function OnWindowDebugOpening(args)
	{
		try
		{
			if ((bDebug == true) && (bDisabled == false))
			{
				if (oDebugMousePosition != null) oDebugMousePosition.value = "";
				if (oDebugCoords != null) oDebugCoords.value = "";
			}
			else
			{
				args.cancel = true;
			}
		}catch(e){}
	}
	
	function OnClickDebug()
	{
		try
		{
			if ((bDebug == true) && (oWindowDebug != null) && (oWindowDebug.visible() == false))
			{
				oWindowDebug.show();
			}
		}catch(e){}
	}
	
	function OnClickReset()
	{
		try
		{
			if ((bDebug == true) && (oDebugCoords != null)) oDebugCoords.value = "";
		}catch(e){}
	}
	
	function OnImageMouseMove(ev)
	{
		try
		{
			if ((bDebug == true) && (bDisabled == false))
			{
				var x, y;
					
				if (com.LeadTran.IE == true)
				{
					x = event.clientX;
					y = event.clientY;
				}
				else
				{
					x = ev.pageX;
					y = ev.pageY;
				}
				
				var bounds = com.LeadTran.Utils.GetElementBounds(oImage);
				if (oDebugMousePosition != null) oDebugMousePosition.value = (x - bounds.left) + "," + (y - bounds.top);
			}	
		}catch(e){}
	}
	
	function OnImageMouseClick(ev)
	{
		try
		{
			if ((bDebug == true) && (bDisabled == false))
			{
				var x, y;
					
				if (com.LeadTran.IE == true)
				{
					x = event.clientX;
					y = event.clientY;
				}
				else
				{
					x = ev.pageX;
					y = ev.pageY;
				}
				
				var bounds = com.LeadTran.Utils.GetElementBounds(oImage);
				if (oDebugCoords != null) oDebugCoords.value += (oDebugCoords.value != "" ? "," : "") + (x - bounds.left) + "," + (y - bounds.top);
			}	
		}catch(e){}
	}
	
	function OnItemMouseMove(ev)
	{
		OnImageMouseMove(ev);
	}
	
	function OnItemClick(ev)
	{
		OnImageMouseClick(ev);
		
		try
		{
			if ((bDebug == false) && (self.onitemclick != null) && (typeof self.onitemclick == "function"))
			{
				self.onitemclick.call(this);
			}
		}catch(e){}
	}
	
	Constructor();
}

com.LeadTran.USAMap = function(parentelement)
{
	var oMap = null;
	var self = this;
	
	function Constructor()
	{
		try 
		{
			oMap = new com.LeadTran.Map("usa", parentelement);
			oMap.image("/img/maps/usa/map.png");
			oMap.size(386,271);
			
			oMap.createState("AK", new com.LeadTran.Utils.Size(123,77), new com.LeadTran.Utils.Location(0,195), "0", "/img/maps/usa/AK.png", "/img/maps/usa/AK_selected.png", null);
			oMap.createState("AL", new com.LeadTran.Utils.Size(28,45), new com.LeadTran.Utils.Location(260,140), "0", "/img/maps/usa/AL.png", "/img/maps/usa/AL_selected.png", null);
			oMap.createState("AR", new com.LeadTran.Utils.Size(36,33), new com.LeadTran.Utils.Location(214,131), "0", "/img/maps/usa/AR.png", "/img/maps/usa/AR_selected.png", null);
			oMap.createState("AZ", new com.LeadTran.Utils.Size(48,56), new com.LeadTran.Utils.Location(66,116), "0", "/img/maps/usa/AZ.png", "/img/maps/usa/AZ_selected.png", null);
			oMap.createState("CA", new com.LeadTran.Utils.Size(58,97), new com.LeadTran.Utils.Location(16,57), "0", "/img/maps/usa/CA.png", "/img/maps/usa/CA_selected.png", null);
			oMap.createState("CO", new com.LeadTran.Utils.Size(51,40), new com.LeadTran.Utils.Location(113,86), "0", "/img/maps/usa/CO.png", "/img/maps/usa/CO_selected.png", null);
			oMap.createState("CT", new com.LeadTran.Utils.Size(13,12), new com.LeadTran.Utils.Location(349,60), "0", "/img/maps/usa/CT.png", "/img/maps/usa/CT_selected.png", null);
			oMap.createState("DE", new com.LeadTran.Utils.Size(8,13), new com.LeadTran.Utils.Location(341,89), "0", "/img/maps/usa/DE.png", "/img/maps/usa/DE_selected.png", null);
			oMap.createState("FL", new com.LeadTran.Utils.Size(65,55), new com.LeadTran.Utils.Location(268,173), "0", "/img/maps/usa/FL.png", "/img/maps/usa/FL_selected.png", null);
			oMap.createState("GA", new com.LeadTran.Utils.Size(39,40), new com.LeadTran.Utils.Location(279,137), "0", "/img/maps/usa/GA.png", "/img/maps/usa/GA_selected.png", null);
			oMap.createState("HI", new com.LeadTran.Utils.Size(41,26), new com.LeadTran.Utils.Location(131,231), "0", "/img/maps/usa/HI.png", "/img/maps/usa/HI_selected.png", null);
			oMap.createState("IA", new com.LeadTran.Utils.Size(43,28), new com.LeadTran.Utils.Location(201,69), "0", "/img/maps/usa/IA.png", "/img/maps/usa/IA_selected.png", null);
			oMap.createState("ID", new com.LeadTran.Utils.Size(42,68), new com.LeadTran.Utils.Location(67,8), "0", "/img/maps/usa/ID.png", "/img/maps/usa/ID_selected.png", null);
			oMap.createState("IL", new com.LeadTran.Utils.Size(29,50), new com.LeadTran.Utils.Location(234,75), "0", "/img/maps/usa/IL.png", "/img/maps/usa/IL_selected.png", null);
			oMap.createState("IN", new com.LeadTran.Utils.Size(22,38), new com.LeadTran.Utils.Location(259,79), "0", "/img/maps/usa/IN.png", "/img/maps/usa/IN_selected.png", null);
			oMap.createState("KS", new com.LeadTran.Utils.Size(52,28), new com.LeadTran.Utils.Location(162,99), "0", "/img/maps/usa/KS.png", "/img/maps/usa/KS_selected.png", null);
			oMap.createState("KY", new com.LeadTran.Utils.Size(52,27), new com.LeadTran.Utils.Location(251,103), "0", "/img/maps/usa/KY.png", "/img/maps/usa/KY_selected.png", null);
			oMap.createState("LA", new com.LeadTran.Utils.Size(40,36), new com.LeadTran.Utils.Location(219,162), "0", "/img/maps/usa/LA.png", "/img/maps/usa/LA_selected.png", null);
			oMap.createState("MA", new com.LeadTran.Utils.Size(25,14), new com.LeadTran.Utils.Location(349,51), "0", "/img/maps/usa/MA.png", "/img/maps/usa/MA_selected.png", null);
			oMap.createState("MD", new com.LeadTran.Utils.Size(32,16), new com.LeadTran.Utils.Location(315,87), "0", "/img/maps/usa/MD.png", "/img/maps/usa/MD_selected.png", null);
			oMap.createState("ME", new com.LeadTran.Utils.Size(28,41), new com.LeadTran.Utils.Location(357,9), "0", "/img/maps/usa/ME.png", "/img/maps/usa/ME_selected.png", null);
			oMap.createState("MI", new com.LeadTran.Utils.Size(54,56), new com.LeadTran.Utils.Location(237,25), "0", "/img/maps/usa/MI.png", "/img/maps/usa/MI_selected.png", null);
			oMap.createState("MN", new com.LeadTran.Utils.Size(47,53), new com.LeadTran.Utils.Location(196,17), "0", "/img/maps/usa/MN.png", "/img/maps/usa/MN_selected.png", null);
			oMap.createState("MO", new com.LeadTran.Utils.Size(48,41), new com.LeadTran.Utils.Location(206,94), "0", "/img/maps/usa/MO.png", "/img/maps/usa/MO_selected.png", null);
			oMap.createState("MS", new com.LeadTran.Utils.Size(26,45), new com.LeadTran.Utils.Location(237,142), "0", "/img/maps/usa/MS.png", "/img/maps/usa/MS_selected.png", null);
			oMap.createState("MT", new com.LeadTran.Utils.Size(73,45), new com.LeadTran.Utils.Location(84,9), "0", "/img/maps/usa/MT.png", "/img/maps/usa/MT_selected.png", null);
			oMap.createState("NC", new com.LeadTran.Utils.Size(63,28), new com.LeadTran.Utils.Location(288,114), "0", "/img/maps/usa/NC.png", "/img/maps/usa/NC_selected.png", null);
			oMap.createState("ND", new com.LeadTran.Utils.Size(47,29), new com.LeadTran.Utils.Location(154,19), "0", "/img/maps/usa/ND.png", "/img/maps/usa/ND_selected.png", null);
			oMap.createState("NE", new com.LeadTran.Utils.Size(59,29), new com.LeadTran.Utils.Location(151,72), "0", "/img/maps/usa/NE.png", "/img/maps/usa/NE_selected.png", null);
			oMap.createState("NH", new com.LeadTran.Utils.Size(12,25), new com.LeadTran.Utils.Location(353,31), "0", "/img/maps/usa/NH.png", "/img/maps/usa/NH_selected.png", null);
			oMap.createState("NJ", new com.LeadTran.Utils.Size(10,22), new com.LeadTran.Utils.Location(341,71), "0", "/img/maps/usa/NJ.png", "/img/maps/usa/NJ_selected.png", null);
			oMap.createState("NM", new com.LeadTran.Utils.Size(49,51), new com.LeadTran.Utils.Location(107,122), "0", "/img/maps/usa/NM.png", "/img/maps/usa/NM_selected.png", null);
			oMap.createState("NV", new com.LeadTran.Utils.Size(45,70), new com.LeadTran.Utils.Location(42,64), "0", "/img/maps/usa/NV.png", "/img/maps/usa/NV_selected.png", null);
			oMap.createState("NY", new com.LeadTran.Utils.Size(53,40), new com.LeadTran.Utils.Location(309,37), "0", "/img/maps/usa/NY.png", "/img/maps/usa/NY_selected.png", null);
			oMap.createState("OH", new com.LeadTran.Utils.Size(30,34), new com.LeadTran.Utils.Location(277,73), "0", "/img/maps/usa/OH.png", "/img/maps/usa/OH_selected.png", null);
			oMap.createState("OK", new com.LeadTran.Utils.Size(61,32), new com.LeadTran.Utils.Location(155,126), "0", "/img/maps/usa/OK.png", "/img/maps/usa/OK_selected.png", null);
			oMap.createState("OR", new com.LeadTran.Utils.Size(57,48), new com.LeadTran.Utils.Location(21,21), "0", "/img/maps/usa/OR.png", "/img/maps/usa/OR_selected.png", null);
			oMap.createState("PA", new com.LeadTran.Utils.Size(41,27), new com.LeadTran.Utils.Location(305,66), "0", "/img/maps/usa/PA.png", "/img/maps/usa/PA_selected.png", null);
			oMap.createState("RI", new com.LeadTran.Utils.Size(6,7), new com.LeadTran.Utils.Location(360,60), "0", "/img/maps/usa/RI.png", "/img/maps/usa/RI_selected.png", null);
			oMap.createState("SC", new com.LeadTran.Utils.Size(36,28), new com.LeadTran.Utils.Location(296,134), "0", "/img/maps/usa/SC.png", "/img/maps/usa/SC_selected.png", null);
			oMap.createState("SD", new com.LeadTran.Utils.Size(49,33), new com.LeadTran.Utils.Location(152,46), "0", "/img/maps/usa/SD.png", "/img/maps/usa/SD_selected.png", null);
			oMap.createState("TN", new com.LeadTran.Utils.Size(60,22), new com.LeadTran.Utils.Location(245,122), "0", "/img/maps/usa/TN.png", "/img/maps/usa/TN_selected.png", null);
			oMap.createState("TX", new com.LeadTran.Utils.Size(99,96), new com.LeadTran.Utils.Location(125,130), "0", "/img/maps/usa/TX.png", "/img/maps/usa/TX_selected.png", null);
			oMap.createState("UT", new com.LeadTran.Utils.Size(40,50), new com.LeadTran.Utils.Location(78,72), "0", "/img/maps/usa/UT.png", "/img/maps/usa/UT_selected.png", null);
			oMap.createState("VA", new com.LeadTran.Utils.Size(56,32), new com.LeadTran.Utils.Location(291,93), "0", "/img/maps/usa/VA.png", "/img/maps/usa/VA_selected.png", null);
			oMap.createState("VT", new com.LeadTran.Utils.Size(12,23), new com.LeadTran.Utils.Location(344,34), "0", "/img/maps/usa/VT.png", "/img/maps/usa/VT_selected.png", null);
			oMap.createState("WA", new com.LeadTran.Utils.Size(47,35), new com.LeadTran.Utils.Location(33,0), "0", "/img/maps/usa/WA.png", "/img/maps/usa/WA_selected.png", null);
			oMap.createState("WI", new com.LeadTran.Utils.Size(38,41), new com.LeadTran.Utils.Location(223,36), "0", "/img/maps/usa/WI.png", "/img/maps/usa/WI_selected.png", null);
			oMap.createState("WV", new com.LeadTran.Utils.Size(32,32), new com.LeadTran.Utils.Location(296,85), "0", "/img/maps/usa/WV.png", "/img/maps/usa/WV_selected.png", null);
			oMap.createState("WY", new com.LeadTran.Utils.Size(50,41), new com.LeadTran.Utils.Location(104,49), "0", "/img/maps/usa/WY.png", "/img/maps/usa/WY_selected.png", null);
		
			self.map = oMap;
		}catch(e){}
	}
	
	this.map = null;
	
	this.getMap = function()
	{
		return oMap;
	}
	
	Constructor();
}

com.LeadTran.CanadaMap = function(parentelement)
{
	var oMap = null;
	var self = this;
	
	function Constructor()
	{
		try 
		{
			oMap = new com.LeadTran.Map("canada", parentelement);
			oMap.image("/img/maps/canada/map.png");
			oMap.size(386,271);
			
			oMap.createState("AB", new com.LeadTran.Utils.Size(47,81), new com.LeadTran.Utils.Location(77,141), "77,178,81,170,84,163,87,155,91,147,94,143,103,146,110,147,116,149,122,152,119,162,117,171,116,178,113,188,111,198,109,208,107,216,106,221,97,219,88,216,88,210,90,208,88,207,88,203,85,197,83,194,82,190,81,189,81,186,79,182,77,180", "/img/maps/canada/AB.png", "/img/maps/canada/AB_selected.png", null);
			oMap.createState("BC", new com.LeadTran.Utils.Size(55,109), new com.LeadTran.Utils.Location(38,108), "87,216,53,203,49,195,49,190,46,188,46,186,43,184,41,184,42,187,46,192,47,197,49,202,49,205,45,204,43,200,43,197,40,195,40,193,42,192,42,191,38,187,38,183,41,182,44,177,48,175,44,172,44,166,47,164,43,163,43,158,50,149,49,146,46,141,49,135,47,132,49,130,49,125,47,122,48,120,48,118,44,118,41,119,40,118,40,108,49,117,58,124,69,131,82,137,92,142,76,177,80,190,83,196,87,206,87,213", "/img/maps/canada/BC.png", "/img/maps/canada/BC_selected.png", null);
			oMap.createState("MB", new com.LeadTran.Utils.Size(49,75), new com.LeadTran.Utils.Location(144,155), "170,229,144,227,145,209,147,192,147,171,149,157,170,157,171,165,178,167,179,169,179,175,191,178,171,202,170,204,170,226", "/img/maps/canada/MB.png", "/img/maps/canada/MB_selected.png", null);
			oMap.createState("NB", new com.LeadTran.Utils.Size(26,21), new com.LeadTran.Utils.Location(286,206), "310,215,308,217,307,220,303,224,299,226,295,225,294,222,293,218,292,216,287,216,286,213,289,210,293,209,297,208,300,208,302,207,303,210,308,214,308,211,310,211,311,215,310,217", "/img/maps/canada/NB.png", "/img/maps/canada/NB_selected.png", null);
			oMap.createState("NL", new com.LeadTran.Utils.Size(86,63), new com.LeadTran.Utils.Location(264,131), "324,194,324,189,320,190,320,188,322,187,322,181,320,176,320,168,320,167,316,166,311,166,308,170,301,174,294,177,290,177,289,177,288,179,290,181,289,182,286,182,284,181,282,181,281,179,278,180,276,179,278,177,276,174,272,174,272,168,273,165,278,166,283,164,284,160,282,158,278,152,277,146,273,145,273,141,269,140,269,137,265,134,265,132,275,141,279,141,282,145,284,146,284,148,287,151,292,152,293,154,304,152,308,155,314,154,320,161,323,164,324,175,326,176,328,173,331,175,335,172,338,171,339,172,340,175,343,173,349,178,350,183,345,185,344,181,342,182,342,188,341,188,340,188,340,184,335,187,329,190", "/img/maps/canada/NL.png", "/img/maps/canada/NL_selected.png", null);
			oMap.createState("NS", new com.LeadTran.Utils.Size(22,34), new com.LeadTran.Utils.Location(307,200), "311,234,309,233,307,230,307,227,310,223,312,221,313,221,316,219,311,218,312,215,315,215,318,214,321,212,322,210,322,210,321,208,321,201,324,201,325,204,328,204,327,207,325,210,325,211,326,212,317,222,317,223,314,224,314,229,312,233", "/img/maps/canada/NS.png", "/img/maps/canada/NS_selected.png", null);
			oMap.createState("NT", new com.LeadTran.Utils.Size(80,123), new com.LeadTran.Utils.Location(72,32), new Array("147,154,136,153,121,150,105,145,91,139,82,135,82,130,76,126,76,118,73,117,75,115,75,109,77,107,77,100,74,98,78,92,78,91,76,89,78,85,79,82,75,80,82,71,87,69,86,70,104,72,106,78,106,81,110,81,113,85,110,92,110,95,116,101,118,106,124,115,129,116,130,121,134,123,139,124,145,127,150,129,150,140,149,146","119,73,113,73,114,67,112,65,112,63,120,58,121,53,123,53,124,54,127,54,127,57,130,58,133,60,133,63,134,65,136,67,139,70,139,72,141,73,139,81,138,86,134,87,128,86,123,85,125,84,128,84,131,85,134,85,133,83,129,81,125,81,123,78,123,77,129,77,130,75,124,73,124,71,127,68,125,66,119,70","146,58,141,59,139,59,139,57,143,55,143,54,136,53,134,51,136,49,139,46,142,46,144,50,146,53,146,57","128,42,132,42,137,38,142,38,140,41,138,44,137,41,135,41,135,44,133,45,132,46,129,45","146,41,146,37,148,36,147,33,150,32,152,33,152,34,151,36,150,40,146,40"), "/img/maps/canada/NT.png", "/img/maps/canada/NT_selected.png", null);
			oMap.createState("ON", new com.LeadTran.Utils.Size(97,94), new com.LeadTran.Utils.Location(171,177), "171,227,172,203,193,178,195,178,197,182,201,183,206,185,217,185,219,191,221,197,224,202,230,206,232,208,235,207,235,214,237,220,239,226,240,230,241,233,243,234,244,235,245,236,247,237,249,238,251,238,252,239,254,239,257,239,260,240,261,238,265,237,267,239,261,246,260,248,257,251,250,252,246,257,247,258,250,259,250,261,245,263,240,264,238,267,234,270,232,270,233,267,236,262,236,253,238,250,242,249,242,246,240,243,236,242,226,242,224,243,222,243,218,241,217,237,218,235,216,234,212,233,209,230,207,228,201,228,197,232,195,234,191,233,183,232,177,230,172,229", "/img/maps/canada/ON.png", "/img/maps/canada/ON_selected.png", null);
			oMap.createState("SK", new com.LeadTran.Utils.Size(42,78), new com.LeadTran.Utils.Location(106,151), "143,227,128,226,116,224,108,222,112,201,116,187,119,172,124,152,135,154,146,155,146,171,144,188,143,209,143,225", "/img/maps/canada/SK.png", "/img/maps/canada/SK_selected.png", null);
			oMap.createState("YT", new com.LeadTran.Utils.Size(45,77), new com.LeadTran.Utils.Location(37,59), "38,105,45,96,55,84,64,73,74,63,77,60,78,65,81,69,77,74,74,79,74,81,77,82,77,85,75,88,77,91,76,93,74,96,73,98,76,101,75,107,74,110,74,113,72,117,72,118,75,118,75,127,79,130,81,133,81,135,73,131,67,127,61,124,52,118,46,113,43,110,40,105", "/img/maps/canada/YT.png", "/img/maps/canada/YT_selected.png", null);
			oMap.createState("QC", new com.LeadTran.Utils.Size(97,109), new com.LeadTran.Utils.Location(222,131), new Array("263,237,260,239,254,239,250,237,245,235,241,229,239,223,237,215,236,206,237,199,236,196,229,186,233,183,235,179,237,174,237,168,233,164,229,160,226,158,226,155,228,151,228,148,224,145,224,141,222,138,222,135,227,135,231,134,234,132,238,132,242,136,248,136,251,140,252,143,254,146,253,150,257,148,262,149,264,145,264,135,269,140,271,141,272,145,276,147,276,151,282,159,282,162,278,164,273,164,271,170,271,173,273,176,277,177,276,179,277,181,280,181,286,183,291,183,290,178,292,178,297,178,303,174,306,172,310,170,313,168,317,168,314,172,312,178,312,182,306,185,300,188,294,190,292,192,289,194,286,197,286,201,285,204,282,208,280,211,279,216,277,221,274,225,272,229,278,225,281,220,283,214,284,210,286,207,289,204,293,200,297,199,300,199,301,201,301,203,298,205,295,206,291,209,287,211,287,212,285,216,284,218,284,224,283,231,281,233,280,235,272,238,268,239,267,237","298,193,303,193,306,193,308,192,307,191,301,191,298,192"), "/img/maps/canada/QC.png", "/img/maps/canada/QC_selected.png", null);
			oMap.createState("NU", new com.LeadTran.Utils.Size(146,156), new com.LeadTran.Utils.Location(111,0), new Array("172,156,162,155,149,154,150,146,151,138,151,129,146,126,139,123,132,121,131,117,131,115,126,115,124,111,120,106,118,103,118,101,115,98,112,95,111,93,112,90,113,88,115,86,118,89,120,91,122,92,124,92,125,94,125,95,124,96,123,96,122,98,123,99,126,100,131,102,135,103,138,105,138,110,140,111,140,101,138,101,140,99,142,99,143,98,146,98,145,101,154,107,162,107,163,101,161,99,163,97,164,94,166,94,169,99,169,101,168,108,169,110,171,110,171,106,174,102,174,100,173,97,169,91,169,87,172,82,175,83,177,85,177,97,180,97,182,99,182,103,184,104,185,98,188,101,188,106,190,109,193,108,194,104,194,96,192,95,192,93,198,93,202,95,203,97,201,99,201,101,205,105,205,108,199,113,193,113,192,114,198,120,203,121,207,126,212,127,212,130,209,130,204,129,200,135,199,135,198,131,194,132,196,128,195,121,187,119,183,119,187,123,192,124,191,126,189,129,186,130,184,133,182,133,181,135,183,137,181,139,178,140,176,144,174,147,172,151,172,153","204,136,206,135,209,134,209,136,208,138,205,140,205,140,205,138","215,137,217,136,218,137,218,140,217,141,215,140","218,128,218,126,221,127,222,130,219,130","145,94,141,96,133,97,130,96,129,93,127,91,125,89,124,86,128,86,132,87,136,88,139,89,140,85,142,81,142,77,142,72,144,71,144,78,145,80,147,78,147,70,149,69,152,66,154,68,152,72,152,80,153,85,156,89,159,91,159,93,153,93,153,96,155,96,155,98,150,98,147,95","216,104,215,102,214,99,216,97,219,97,220,100,220,102,218,103","256,125,248,126,243,124,238,124,236,122,233,121,229,118,224,119,220,122,217,120,217,118,220,115,223,115,227,113,228,111,223,110,226,106,227,99,216,91,216,94,214,95,212,94,213,92,214,91,206,85,204,85,204,88,198,90,192,90,190,89,185,89,185,88,184,86,182,82,181,70,184,68,187,68,188,71,188,76,189,80,192,82,193,82,193,78,191,77,191,69,194,68,196,67,198,69,199,73,200,76,201,74,202,70,200,68,200,66,202,65,205,66,207,68,207,71,211,72,213,75,216,76,218,74,220,77,226,77,226,80,231,80,230,83,233,83,231,88,253,92,253,98,252,102,253,104,250,104,245,101,240,100,239,104,241,106,244,107,246,109,249,109,253,113,255,117,255,119,250,118,247,116,243,117,243,118,249,121,254,122","163,84,157,74,159,73,160,74,160,70,159,68,161,67,167,67,167,70,165,72,167,74,167,79,164,82","170,75,170,69,174,66,179,67,179,70,177,73,177,75,173,75,173,79","172,62,170,60,170,58,171,57,173,57,174,59,173,61","164,61,162,59,163,56,159,56,162,49,167,50,167,55,166,58,165,60","153,57,147,57,147,54,149,54,148,47,150,46,151,51,154,52,155,52,155,55,153,57","196,60,190,61,184,62,182,61,179,62,177,60,177,54,175,52,172,50,170,48,170,47,175,49,179,49,179,54,182,55,186,56,191,53,195,53,196,55","181,49,181,46,183,44,181,41,184,40,184,39,181,38,182,36,185,34,188,34,189,31,184,29,181,30,179,35,177,37,174,35,173,35,172,33,174,32,174,30,170,30,170,27,172,26,172,20,173,17,176,22,178,26,181,26,183,24,186,26,188,27,187,23,188,21,189,18,188,17,182,21,180,18,177,18,176,14,181,11,192,1,194,2,199,3,200,6,199,8,197,9,197,12,199,12,201,10,198,19,199,22,196,24,194,26,193,28,197,31,197,34,195,37,195,41,193,42,194,44,197,44,196,46,193,49,192,47,189,48,186,49,182,49","176,44,176,41,179,41,180,42,179,45,178,45","173,44,171,43,168,42,167,39,166,34,169,33,171,36,171,39,174,42","164,41,161,38,158,36,158,32,158,31,162,31,164,33,165,37"), "/img/maps/canada/NU.png", "/img/maps/canada/NU_selected.png", null);
			oMap.createState("PE", new com.LeadTran.Utils.Size(11,5), new com.LeadTran.Utils.Location(307,207), "311,212,309,211,307,210,310,210,313,209,317,208,317,211,314,212", "/img/maps/canada/PE.png", "/img/maps/canada/PE_selected.png", null);
			
			self.map = oMap;
		}catch(e){}
	}
	
	this.map = null;
	
	this.getMap = function()
	{
		return oMap;
	}
	
	Constructor();
}

com.LeadTran.PreviewTemplate = function()
{
	var popup = null;
	var popupcontent = null;
	var otemplatecontent = null;
	var olink = null;
	var bounds = null;
	var contentbounds = null;
	var templatebounds = null;
	var linkbounds = null;
	var loading = false;
	var document_keydown = null;
	var document_keypress = null;
	var bVisible = false;
	var self = this;
	
	this.onbeforeopen = null;
	this.onopened = null;
	this.onclosed = null;
	this.onerror = null;
	
	function Constructor()
	{
		try
		{
			createMessage();
		}catch(e){}
	}
	
	function createMessage()
	{
		try
		{		
			popup = document.createElement("div");
			$(popup).attr("style", "width: 100%;background: #000000;position: fixed;top: 0;left:0;-moz-opacity:0.45;-khtml-opacity: 0.45;opacity: 0.45;filter:alpha(opacity=75);z-index:9999997;height:100%;display:none;");
			com.LeadTran.Utils.DisableSelection(popup);
			
			$(popup).click(
				function()
				{
					try
					{
						self.hide();
					}catch(ev){}
				}
			);
			
			popupcontent = document.createElement("div")
			$(popupcontent).attr("style", "top:50%;left:50%;position: fixed; color:black; font-weight:bold;font-size:16px; z-index:9999998; cursor:default;border-radius: 6px;-moz-border-radius: 6px;-webkit-border-radius: 6px;background:white;border:2px solid #cfcfcf;-moz-opacity:0.92; -khtml-opacity: 0.92; opacity: 0.92; filter:alpha(opacity=92);display:none;box-shadow: 0px 0px 6px #000;-moz-box-shadow: 0px 0px 6px #000;-webkit-box-shadow: 0px 0px 6px #000;");
			com.LeadTran.Utils.DisableSelection(popupcontent);
			
			otemplatecontent = document.createElement("div");
			$(otemplatecontent).attr("style", "color:black;font-size:17px; text-align:center;font-weight:bold;float:left;");
			otemplatecontent.innerHTML = "";
			
			olink = document.createElement("div");
			$(olink).attr("style", "background:transparent url(/img/popup_close.png) no-repeat 0 0;width:43px;height:43px;position:fixed;left:50%;top:50%;z-index:9999999;cursor:pointer;cursor:hand;display:none;");
			
			$(olink).click(
				function()
				{
					try
					{
						self.hide();
					}catch(ev){}
				}
			);
			
			$(popupcontent).append(otemplatecontent);
			
			$(popupcontent).css({
				width: "50px",
				height: "50px"
			});
		}catch(e){}
	}
	
	function validateID(value)
	{
		try
		{
			if ((value != null) && (isNaN(value) == false) && (value != -1))
			{
				return true;
			}
		}catch(e){}
		
		return false;
	}
	
	this.visible = function()
	{
		return bVisible;
	}
	
	this.isLoading = function()
	{
		return loading;
	}
	
	this.show = function(channelId, templateId, progressbarId, pagecontrolId, alertId, confirmId, cache, element)
	{
		if ((loading == false) && (bVisible == false))
		{
			loading = true;
			
			var loadingpreview = false;
			
			try
			{
				if ((popup != null) && (popupcontent != null) && (otemplatecontent != null))
				{
					if ((validateID(channelId) == true) && (validateID(templateId) == true) && (validateID(progressbarId) == true) && (validateID(pagecontrolId) == true) && (validateID(alertId) == true) && (validateID(confirmId) == true))
					{
						OnBeforeOpenPreview();
						
						if ((cache == true) && (element != null) && ("previewformcache" in element) && (element.previewformcache != null) && ("data" in element.previewformcache) && (element.previewformcache.data != null) && (element.previewformcache.data != "") && ("loaded" in element.previewformcache) && (element.previewformcache.loaded != null) && (element.previewformcache.loaded == true))
						{
							try
							{
								if (showPreviewCode(element.previewformcache.data) == true)
								{
									OnOpenedPreview();
								}
							}catch(ec){}
							
							loading = false;	
						}
						else
						{
							com.LeadTran.Net.SendAsync({
								type: "get",
								url: "/ws/getPreview.php",
								data: {
									ci: channelId,
									st: templateId,
									pb: progressbarId,
									pg: pagecontrolId,
									al: alertId,
									cf: confirmId
								},
								success: function()
								{
									try
									{
										if ((this.responseText != null) && (this.responseText != ""))
										{
											if (showPreviewCode(this.responseText) == true)
											{
												try
												{
													if ((cache == true) && (element != null))
													{
														if (("previewformcache" in element) == false)
														{
															element.previewformcache = {
																data: "",
																loaded: false
															};
														}
														
														element.previewformcache.data = this.responseText;
														element.previewformcache.loaded = true;
													}
												}catch(ec){}	
												
												OnOpenedPreview();
											}
										}
									}catch(ev){}
									
									loading = false;
								},
								error: function()
								{
									try
									{
										self.hide();
										loading = false;
									}catch(ev){}
									
									OnErrorPreview();
								}
							});
						}
						
						loadingpreview = true;
					}
				}
			}catch(e){}
			
			if (loadingpreview == false)
			{
				try
				{
					self.hide();
					loading = false;
				}catch(e){}
				
				OnErrorPreview();
			}
		}
	}
	
	this.showfromcache = function(element)
	{
		if ((loading == false) && (bVisible == false))
		{
			var cache = false;
			var show = false;
			
			try
			{
				if ((element != null) && ("previewformcache" in element) && (element.previewformcache != null) && ("data" in element.previewformcache) && (element.previewformcache.data != null) && (element.previewformcache.data != "") && ("loaded" in element.previewformcache) && (element.previewformcache.loaded != null) && (element.previewformcache.loaded == true))
				{
					if ((popup != null) && (popupcontent != null) && (otemplatecontent != null))
					{
						OnBeforeOpenPreview();
						
						cache = true;
						
						try
						{
							if (showPreviewCode(element.previewformcache.data) == true)
							{
								OnOpenedPreview();
								
								show = true;
							}
						}catch(ec){}
					}
						
				}
			}catch(e){}
			
			if ((cache == true) && (show == false)) OnErrorPreview();
		}
	}
	
	this.hide = function()
	{
		try
		{
			if (bVisible == true)
			{
				var close = false;
				
				if (popupcontent != null)
				{
					com.LeadTran.Utils.RemoveElement(popupcontent);
					popupcontent.style.display = "none";
					close = true;
				}
				
				if (popup != null)
				{
					com.LeadTran.Utils.RemoveElement(popup);
					popup.style.display = "none";
					close = true;
				}
				
				if (olink != null)
				{
					com.LeadTran.Utils.RemoveElement(olink);
					olink.style.display = "none";
					close = true;
				}
				
				if (close == true)
				{
					document.onkeydown = document_keydown;
					document.onkeypress = document_keypress;
					
					OnClosedPreview();
				}
				
				bVisible = false;
			}
		}catch(e){}
	}
	
	function OnBeforeOpenPreview()
	{
		try
		{
			if ((self.onbeforeopen != null) && (typeof self.onbeforeopen == "function"))
			{
				self.onbeforeopen.call(this);
			}
		}catch(e){}
	}
	
	function OnOpenedPreview()
	{
		try
		{
			if ((self.onopened != null) && (typeof self.onopened == "function"))
			{
				self.onopened.call(this);
			}
		}catch(e){}
	}
	
	function OnClosedPreview()
	{
		try
		{
			if ((self.onclosed != null) && (typeof self.onclosed == "function"))
			{
				self.onclosed.call(this);
			}
		}catch(e){}
	}
	
	function OnErrorPreview()
	{
		try
		{
			if ((self.onerror != null) && (typeof self.onerror == "function"))
			{
				self.onerror.call(this);
			}
		}catch(e){}
	}
	
	function showPreviewCode(data)
	{
		try
		{
			if ((popup != null) && (popupcontent != null) && (otemplatecontent != null) && (bVisible == false) && (data != null) && (data != ""))
			{
				$("body").append(popup);
				$("body").append(popupcontent);
				$("body").append(olink);
				
				otemplatecontent.innerHTML = data;
				
				com.LeadTran.PreviewTemplate.Utils.configurePreview(otemplatecontent);
				
				$(popupcontent).css({
					top: "-2000px",
					left: "-2000px"
				});
				popupcontent.style.display = "block";
				
				templatebounds = com.LeadTran.Utils.GetElementBounds(otemplatecontent);
				$(popupcontent).css({
					width: (templatebounds.width + 40) + "px",
					height: (templatebounds.height + 32) + "px",
					marginLeft: "-" + ((templatebounds.width + 40) / 2) + "px",
					marginTop: "-" + ((templatebounds.height + 32) / 2) + "px"
				});
				
				contentbounds = com.LeadTran.Utils.GetElementBounds(popupcontent);
				
				$(otemplatecontent).css({
					marginTop: "16px",
					marginLeft: ((contentbounds.width - templatebounds.width) / 2) + "px"
				});
				
				popup.style.display = "block";
				$(popupcontent).css({
					left: "50%",
					top: "50%"
				});
				
				linkbounds = com.LeadTran.Utils.GetElementBounds(olink);
				$(olink).css({
					left: "50%",
					top: "50%",
					marginLeft: "-" + (((contentbounds.width / 2) + (linkbounds.width / 2)) - 9) + "px",
					marginTop: "-" + (((contentbounds.height / 2) + (linkbounds.height / 2)) - 9) + "px"
				});
				olink.style.display = "block";
				
				document_keydown = document.onkeydown;
				document_keypress = document.onkeypress;
				document.onkeydown = document.onkeypress = function(ev)
				{
					var evc = (('event' in window) == true) ? event : ev;
					
					try
					{
						if (evc.keyCode == 27)
						{
							self.hide();
						}
					}catch(e){}
				}
				
				bVisible = true;
				
				return true;
			}
		}catch(e){}
		
		return false;
	}
	
	Constructor();
}

com.LeadTran.PreviewTemplate.Utils = {
	configurePreview: function(element)
	{
		try
		{
			if (com.LeadTran.Utils.iselement(element))
			{
				var oProgressBar = null;
				var oProgressParent = null;
				var oProgress = null;
				var bProgressBarConfigured = false;
				var oPageControl = null;
				
				com.LeadTran.HTML.Each(element, {
					recursive: true,
					all: false,
					callback: function(node, index)
					{
						var sId = com.LeadTran.HTML.GetAttribute(node, "afid");
						if (sId != "")
						{
							switch(sId)
							{
								case "progressctr":
									if (oProgressBar == null)
									{
										oProgressBar = node;
										
										com.LeadTran.HTML.Each(oProgressBar, {
											recursive: true,
											all: false,
											callback: function(node, index)
											{
												var sId = com.LeadTran.HTML.GetAttribute(node, "afid");
												if (sId != "")
												{
													node.afid = sId;
													node.index = index;
													
													switch(sId)
													{
														case "contentpb":
															if (oProgressParent == null)
															{
																oProgressParent = node;
																oProgressParent.style.display = "block";
															}
															break;
															
														case "progressbar":
															if (oProgress == null)
															{
																oProgress = node;
																oProgress.style.width = "0px";
																oProgress.style.display = "block";
																
																if ((oProgress.style.backgroundColor == null) || (oProgress.style.backgroundColor == ""))
																{
																	oProgress.style.backgroundColor = "red";
																}
															}
															break;
													}
												}
												
												if ((oProgressParent != null) && (oProgress != null) && (bProgressBarConfigured == false))
												{
													bProgressBarConfigured = true;
													
													var oParent = oProgressParent.parentNode;
													
													com.LeadTran.HTML.RemoveElement(oProgressParent);
													
													com.LeadTran.DOM.Swap(oProgressParent, {"position":"absolute", "visibility":"hidden", "display":"block"}, function()
													{														
														oProgress.style.width = (oProgressParent.offsetWidth / 2) + "px";
													}, document.body);
													
													com.LeadTran.HTML.InsertElementAt(oProgressParent, oParent, oProgressParent.index, true);
													
													this.cancel = true;
												}
												else
												{
													if (bProgressBarConfigured == true)
													{
														this.cancel = true;
													}
												}
											}
										});
										
										oProgressBar.style.display = "block";
									}
									break;
									
								case "pagecontrolctr":
									if (oPageControl == null)
									{
										oPageControl = node;
										
										com.LeadTran.HTML.Each(oPageControl, {
											recursive: true,
											all: false,
											callback: function(node, index)
											{
												var sId = com.LeadTran.HTML.GetAttribute(node, "afid");
												if (sId != "")
												{
													switch(sId)
													{
														case "pgbackdl":
														case "pgnextdl":
														case "pgsenddl":
														case "pgbackbt":
														case "pgnextbt":
														case "pgsendbt":
														case "pgnext":
															this.dispose = true;
															break;
														
														case "pgback":
														case "pgsend":
															break;
													}
												}
											}
										});
										
										oPageControl.style.display = "block";
									}
									break;
							}
						}
						
						if ((oProgressBar != null) && (oPageControl != null))
						{
							this.cancel = true;
						}
					}
				});
			}
		}catch(e){}
	},
	removeCache: function(element)
	{
		try
		{
			if ((element != null) && ("previewformcache" in element))
			{
				com.LeadTran.Utils.RemoveProperty(element, "previewformcache");
			}
		}catch(e){}
	},
	getCode: function(settings)
	{
		
		try
        {
            if ((settings != null) && (typeof settings == "object"))
			{
				var bCache = (("cache" in settings) && (settings.cache != null) && (typeof settings.cache == "boolean")) ? settings.cache : false;
				var oElement = (("element" in settings) && (settings.element != null)) ? settings.element : null;
				var oSuccess = (("success" in settings) && (settings.success != null) && (typeof settings.success == "function")) ? settings.success : null;
				var oError = (("error" in settings) && (settings.error != null) && (typeof settings.error == "function")) ? settings.error : null;
				var oArg = (("arg" in settings) && (settings.arg != null)) ? settings.arg : null;
				
				if ((bCache == true) && (oElement != null) && ("previewformcache" in oElement) && (oElement.previewformcache != null) && ("data" in oElement.previewformcache) && (oElement.previewformcache.data != null) && (oElement.previewformcache.data != "") && ("loaded" in oElement.previewformcache) && (oElement.previewformcache.loaded != null) && (oElement.previewformcache.loaded == true))
				{
					try
					{
						if ((oSuccess != null) && (typeof oSuccess == "function")) oSuccess.call(oElement.previewformcache.data, oArg, oElement.previewformcache.data);
					}catch(es){}
				}
				else
				{
					var oData = (("data" in settings) && (settings.data != null) && (typeof settings.data == "object")) ? settings.data : null;
					if (oData != null)
					{
						var iChannelId = (("channelId" in oData) && (oData.channelId != null) && (isNaN(oData.channelId) == false) && (oData.channelId != -1)) ? oData.channelId : -1;
						var iTemplateId = (("templateId" in oData) && (oData.templateId != null) && (isNaN(oData.templateId) == false) && (oData.templateId != -1)) ? oData.templateId : -1;
						var iProgressBarId = (("progressbarId" in oData) && (oData.progressbarId != null) && (isNaN(oData.progressbarId) == false) && (oData.progressbarId != -1)) ? oData.progressbarId : -1;
						var iPageControlId = (("pagecontrolId" in oData) && (oData.pagecontrolId != null) && (isNaN(oData.pagecontrolId) == false) && (oData.pagecontrolId != -1)) ? oData.pagecontrolId : -1;
						var iAlertId = (("alertId" in oData) && (oData.alertId != null) && (isNaN(oData.alertId) == false) && (oData.alertId != -1)) ? oData.alertId : -1;
						var iConfirmId = (("confirmId" in oData) && (oData.confirmId != null) && (isNaN(oData.confirmId) == false) && (oData.confirmId != -1)) ? oData.confirmId : -1;
						var oConfigurePreview = null;
						var sCodePreview = "";
						
						if ((iChannelId != -1) && (iTemplateId != -1) && (iProgressBarId != -1) && (iPageControlId != -1) && (iAlertId != -1) && (iConfirmId != -1))
						{
							com.LeadTran.Net.SendAsync({
								type: "get",
								url: "/ws/getPreview.php",
								data: {
									ci: iChannelId,
									st: iTemplateId,
									pb: iProgressBarId,
									pg: iPageControlId,
									al: iAlertId,
									cf: iConfirmId
								},
								success: function()
								{
									try
									{
										if ((this.responseText != null) && (this.responseText != ""))
										{
											oConfigurePreview = document.createElement("div");
											oConfigurePreview.style.visibility = "hidden";
											oConfigurePreview.style.top = "-10000px";
											oConfigurePreview.style.left = "-10000px";
											oConfigurePreview.style.position = "absolute";
											com.LeadTran.Utils.AddElement(oConfigurePreview, document.body);
											
											oConfigurePreview.innerHTML = this.responseText;
											
											com.LeadTran.PreviewTemplate.Utils.configurePreview(oConfigurePreview);
											
											sCodePreview = oConfigurePreview.innerHTML;
											
											try
											{
												if ((bCache == true) && (oElement != null))
												{
													if (("previewformcache" in oElement) == false)
													{
														oElement.previewformcache = {
															data: "",
															loaded: false
														};
													}
													
													oElement.previewformcache.data = sCodePreview;
													oElement.previewformcache.loaded = true;
												}
											}catch(ec){}	
											
											try
											{
												if ((oSuccess != null) && (typeof oSuccess == "function")) oSuccess.call(sCodePreview, oArg, sCodePreview);
											}catch(es){}
										}
									}catch(ev){}
									
									if (oConfigurePreview != null) com.LeadTran.Utils.RemoveElement(oConfigurePreview);
									try{delete oConfigurePreview;}catch(ev){}
									oConfigurePreview = null;
									sCodePreview = "";
								},
								error: function()
								{
									if (oConfigurePreview != null) com.LeadTran.Utils.RemoveElement(oConfigurePreview);
									try{delete oConfigurePreview;}catch(ev){}
									oConfigurePreview = null;
									sCodePreview = "";
									
									try
									{
										if ((oError != null) && (typeof oError == "function")) oError.call(null, oArg, null);
									}catch(ev){}
								}
							});
						}
						else
						{
							try
							{
								if ((oError != null) && (typeof oError == "function")) oError.call(null, oArg, null);
							}catch(ev){}
						}
					}
					else
					{
						try
						{
							if ((oError != null) && (typeof oError == "function")) oError.call(null, oArg, null);
						}catch(ev){}
					}
				}				
			} 
        }catch(e){}
	}
}

