function MantisAddNS(ns) {
	if (!ns) return null;
	var levels=ns.split(".");
	var root=window;
	for (var i=0;i<levels.length;i++) {
		if (root[levels[i]]==undefined) root[levels[i]]={};
		root=root[levels[i]];
	}
	return root;
}

MantisAddNS("Mantis");

Mantis.AddNS=MantisAddNS;

Mantis.Version="07.01.20.01";
Mantis.LastModified=new Date(2007,0,20);

Mantis.ScriptPath="/Js/Global/";
Mantis.RootPath="/";

Mantis.Browser={
	Detect:function () {
		var agent=navigator.userAgent.toLowerCase();

		this.Opera=agent.indexOf("opera")!=-1;
		this.IE=agent.indexOf("msie")!=-1 && !this.Opera;
		this.IE7=this.IE && !/msie 6\./i.test(agent) && !this.Opera;
		this.IE6=this.IE && !this.IE7;
		this.Safari=agent.search(/(konqueror|safari|khtml)/i)>-1;
		this.Gecko=agent.indexOf("gecko")!=-1 && !this.Safari;
	},
	Copy:function (s) {
		if (window.clipboardData) clipboardData.setData("Text",s);
	}
};

Mantis.Init=function () {
	Mantis.Browser.Detect();

	Mantis.Utils.InitPrototypes();

	// global functions
	window.copy=function () { Mantis.Debug.Copy.apply(Mantis.Debug,arguments); };
	window.r=function () { Mantis.Debug.Alert.apply(Mantis.Debug,arguments); };
	window.stt=Mantis.Debug.Status;
	window.$=Mantis.DOM.Get;
	window.$A=Array.From;
	window._=window.$E=Mantis.DOM.Create;
	window.undefined=undefined;
	window.h=Object.Hash;
	window.$DL=Mantis.Events.DocumentLoad;
	window.$OL=function (f) { Mantis.Events.Add(window,"load",f); };

	$(window);
	$(document);
	$(document.documentElement);
	$(document.body);

	$DL(function () {
		Mantis.Position.Init();
		Mantis.Ajax.AjaxPro.Init();
		Mantis.DOM.InitExternalLinks();
		Mantis.Extensions.ElementInit();
		window.$=Mantis.DOM.Get;
		// extend window and document objects
		AddListener("unload",Mantis.Events.UnloadCache.Bind(Mantis.Events));

		// prevents ie6 bg image flickering when ajaxing
		try { document.execCommand("BackgroundImageCache",false,true); } catch (ex) {}
	});

	Mantis.Utils.LoadExternalScripts();
};

Mantis.DOM={
	Get:function (el) {
		if (!el) return null;
		if (typeof(el)=="string" && el.nodeType!=1) el=document.getElementById(el);
		if (!el) return null;
		Mantis.Extensions.Extend(el,Mantis.Extensions.Element);
		return el;
	},

	// Creates new HTMLElement from given parameters
	Create:function (tag,parent,props,before) {
		var el;
		if (tag.charAt(0)=="<") el=Mantis.DOM.GetElementFromMarkup(tag);
		else el=document.createElement(tag);
		if (parent) parent.insertBefore(el,before ? before : null);
		if (props) Mantis.Extensions.Extend(el,props);
		// when creating lots of elements and not needed to extend them all, disable it. use then $/Mantis.Extensions.Extend if an element needs an extension
		if (!Mantis.Extensions.Element.Disabled) Mantis.Extensions.Extend(el,Mantis.Extensions.Element);
		return el;
	},
	// Creates new HTMLElement from markup
	GetElementFromMarkup:function (markup) {
		var div=$E("div");
		div.innerHTML=markup;
		div.RemoveTextNodes();
		return div.firstChild;
	},
	// Removes an element
	Remove:function (el) {
		if (el.parentNode) el.parentNode.removeChild(el);
		return el;
	},
	// Removes an element
	ClearChildren:function (el) {
		while (el.hasChildNodes()) el.removeChild(el.lastChild);
	},
	// Does an element contains a another given element?
	Contains:function (el,child) {
		return child==el || (child && Mantis.DOM.Contains(el,child.parentNode));
	},
	// Searches for an element which passes the func function
	FindParent:function (el,func) {
		while (!func($(el)) && el && el!=document.documentElement) el=el.parentNode;
		return el==document.documentElement ? null : el;
	},
	// Searches for all children elements which pass the func function
	FindChildren:function (el,func,tag) {
		var tags=el.getElementsByTagName(tag || "*"),arr=[];
		for (var i=0,c;c=tags[i];i++) if (func($(c))) arr.push(c);
		return arr;
	},

	UniqueId:function (el) {
		if (!el.__MantisUniqueId) {
			if (!arguments.callee.count) arguments.callee.count=0;
			el.__MantisUniqueId="__Mantis_id_"+arguments.callee.count++;
		}
		return el.__MantisUniqueId;
	},

	TextContent:function (el) {
		return el.innerText || el.textContent || "";
	},

	RemoveTextNodes:function (el) {
		if (el._RemovedTextNodes) return;
		$A(el.childNodes).Each(
			function (o) { if (o.nodeType==3 && /^\s+$/.test(o.data)) o.parentNode.removeChild(o); }
		);
		el._RemovedTextNodes=true;
		return el;
	},

	InitExternalLinks:function () {
		function externalLinkClick(e,s) { var a=s.FindParent(function (o) { return o.tagName=="A"; });e.Stop();window.open(a.href,"_blank");e.Stop();return false; }
		$A(document.getElementsByTagName("a")).Each(
			function (a) {
				if (a.rel=="External") Mantis.Events.Add(a,"click",externalLinkClick);
			}
		);
	},

	Selection:{
		Disable:function (el) {
			el.onselectstart=function () { return false; };
			el.style.MozUserSelect="none";
			el.style.KhtmlUserSelect="none";
			return el;
		},
		Enable:function (el) {
			el.onselectstart=null;
			el.style.MozUserSelect="";
			el.style.KhtmlUserSelect="";
			return el;
		}
	}
};

Mantis.Style={
	// Adds another css class for a given element
	Add:function (el,cls) {
		if (el) !Mantis.Style.Contains(el,cls) ? el.className+=" "+cls : el.className;
		return el;
	},
	// Removes another css class for a given element
	Remove:function (el,cls) {
		if (el) return el.className=el.className.replace(new RegExp("\\b"+cls.ToRx()+"\\b"),"");
		return el;
	},
	// Does an element has a class name?
	Contains:function (el,cls) {if (cls) return new RegExp("\\b"+cls.ToRx()+"\\b").test(el.className);},
	// Toggles a className
	Toggle:function (el,cls,b) {
		if (b===true) Mantis.Style.Add(el,cls);
		else if (b===false) Mantis.Style.Remove(el,cls);
		else Mantis.Style[Mantis.Style.Contains(el,cls) ? "Remove" : "Add"](el,cls);
		return el;
	},
	// The current style of an element
	// gets background-color, margin-top etc
	Get:function (el,style,toInt) {
		var value=el.style[style];

		var value=el.style[style];
		if (!value) {
			var dv=document.defaultView;
			if (dv && dv.getComputedStyle) {
				var css=dv.getComputedStyle(el,null);
				value=css ? css.getPropertyValue(style) : null;
			}
			else if (el.currentStyle) value=el.currentStyle[style.replace(/-([a-z])/g,function (whole,match) { return match.toUpperCase() })];
		}
		if (typeof(value)=="string" && value.indexOf("rgb(")>-1) value=Mantis.Style.parseRGBColor(value);
		return toInt ? parseInt(value) || 0 : value;
	},

	// Parses ff's rgb(r,b,g) into #rrggbb
	parseRGBColor:function (s) {
		if (!Mantis.Style.parseRGBColor.rx) Mantis.Style.parseRGBColor.rx=/rgb\((\d+), ?(\d+), ?(\d+)\)/;
		return s.replace(
			Mantis.Style.parseRGBColor.rx,
			function (whole,r,g,b) { return "#"+Mantis.Text.Pad((+r).toString(16))+Mantis.Text.Pad((+g).toString(16))+Mantis.Text.Pad((+b).toString(16)); }
		);
	},

	// gets background-color, margin-top etc, can be called Set(el,{"top":"10px","background-color":"red"}) or Set(el,"color","green");
	Set:function (el,style) {
		if (typeof(style)=="string" && arguments[2]!=undefined) { var name=style;style={};style[name]=arguments[2]; }
		for (var i in style) {
			if (typeof(style[i])=="function") continue;
			el.style[i.replace(/-([a-z])/g,function (whole,match) { return match.toUpperCase() })]=style[i];
		}
		return el;
	},

	Opacity:{
		Set:function (el,value) {
			el.style.filter="alpha(opacity="+(value*100)+")";
			el.style.opacity=value;
			el.style["-khtml-opacity"]=value;
			return el;
		},
		Get:function (el) {
			var value;
			if (el.filters) {
				try { value=el.filters.item("DXImageTransform.Microsoft.Alpha").opacity/100; }
				catch (e) { try { value=el.filters.item("alpha").opacity/100; } catch (e) {} }
			}
			else value=el.style["-khtml-opacity"] || el.style.opacity;

			return value!=undefined ? value : 1;
		}
	},

	Display:{
		Visible:function (el) { return !$(el).HasClassName("hidden"); },
		Show:function (el) { $(el).RemoveClassName("hidden"); return el; },
		Hide:function (el) { $(el).AddClassName("hidden"); return el; },
		Toggle:function (el,b) { $(el).ToggleClassName("hidden",b!==undefined ? !b : undefined); return el; }
	}
};

Mantis.Events={
	cache:[],
	// Adds event
	Add:function (el,evt,func) {
		if (typeof(func)!="function") return;

		$(el);

		// wraps the func with event extender
		// then calls it with the element scope
		func[el.UniqueId()]=function (e) {
			Mantis.Extensions.Extend(e,Mantis.Extensions.Event);
			func.call(el,e,e.SrcElement());
		};

		var callback=func[el.UniqueId()];

		//if (evt=="keypress" && (Mantis.Browser.Safari || Mantis.Browser.IE)) evt="keydown";
		if (el.attachEvent) el.attachEvent("on"+evt,callback);
		else if (el.addEventListener) el.addEventListener(evt,callback,false);

		Mantis.Events.cache.push([el,evt,func]);

		return el;
	},
	// Removes event
	Remove:function (el,evt,func) {
		if (typeof(func)!="function") return;

		if (!el) el=window;

		var callback=func[el.UniqueId()];

		if (!callback) return;

		//if (evt=="keypress" && (Mantis.Browser.Safari || Mantis.Browser.IE)) evt="keydown";
		if (el.detachEvent) el.detachEvent("on"+evt,callback);
		else if (el.removeEventListener) el.removeEventListener(evt,callback,false);

		return el;
	},
	GetEventObject:function (e) { return e || window.event; },
	SourceElement:function (e) { if (!e) e=Mantis.Events.GetEventObject(e); return $(e.srcElement || e.target); },
	RelatedElement:function (e,out) { if (!e) e=Mantis.Events.GetEventObject(e); return e.relatedTarget || (out ? e.toElement : e.fromElement); },
	KeyCode:function (e) { return e.keyCode; },
	CharCode:function (e) { return Mantis.Browser.Gecko ? e.charCode : e.keyCode; },
	Char:function (e) { return String.fromCharCode(e.CharCode()); },
	// Unloads all event listeners (prevents memory leaks)
	UnloadCache:function () {
		for (var i=0;i<Mantis.Events.cache.length;i++) {
			Mantis.Events.Remove.apply(Mantis.Events,Mantis.Events.cache[i]);
			Mantis.Events.cache[i][0]=null;
		}
		Mantis.Events.cache.length=0;
	},
	// Keys Enum
	Keys:{
		BACKSPACE:	8,
		TAB:		9,
		ENTER:		13,
		SPACE:		32,
		ESC:		27,
		LEFT:		37,
		UP:			38,
		RIGHT:		39,
		DOWN:		40,
		DELETE:		46
	},
	MousePosition:function (e) {
		return new Mantis.Position.Coor(
			e.pageX || (e.clientX+(document.documentElement.scrollLeft || document.body.scrollLeft)),
			e.pageY || (e.clientY+(document.documentElement.scrollTop || document.body.scrollTop))
		);
	},
	Button:function (e) {
		var btn=e.button;
		switch (e.which) { case 1: btn=1; break; case 2: btn=4; break; case 3: btn=2; break; }
		return btn;
	},
	Buttons:{
		CLICK:		1,
		CONTEXT:	2,
		WHEEL:		4
	},
	Stop:function (e) {
		if (e.preventDefault) {
			e.preventDefault();
			e.stopPropagation();
		}
		else {
			e.returnValue=false;
			e.cancelBubble=true;
		}
		return e;
	},
	DocumentLoad:function (f) {
		if (Mantis.Browser.Gecko && document.addEventListener) document.addEventListener("DOMContentLoaded",f,false);
		else if (Mantis.Browser.IE)  {
			var old=document.onreadystatechange;
			document.onreadystatechange=function () {
				if (document.readyState=="complete") {
					if (typeof(old)=="function") old();
					f();
				}
			};
		}
		else addEventListener("load",f,false);
	}
};

Mantis.Position={
	Init:function () {
		Mantis.Position.DocumentDirectionRTL=Mantis.Style.Get(document.documentElement,"direction")=="rtl";
	},
	DocumentDirectionRTL:false,
	Coor:function (x,y) { this.X=x;this.Y=y; },
	Get:function (el) {
		var coor=new Mantis.Position.Coor(0,0),box,parent=null;

		if (!el.parentNode || Mantis.Style.Get(el,"display")=="none") return null;

		var temp=el;

		function getMaxValue(name) {
			return Math.max(document.documentElement[name],document.body[name]);
		}

		if (el.getBoundingClientRect) { // IE
			box=el.getBoundingClientRect();

			var scrollTop=getMaxValue("scrollTop");
			var scrollLeft=getMaxValue("scrollLeft");

			var scrollerWidth=getMaxValue("offsetWidth")-getMaxValue("clientWidth")-4;
			var scrollRight=getMaxValue("offsetWidth")-scrollLeft;

			coor.X=box.left+scrollLeft-2;
			if (Mantis.Position.DocumentDirectionRTL) coor.X-=scrollerWidth;
			coor.Y=box.top+scrollTop-2;
		}
		else if (document.getBoxObjectFor) { // gecko
			box=document.getBoxObjectFor(el);

			var borderLeft=Mantis.Style.Get(el,"border-left-width",true);
			var borderTop=Mantis.Style.Get(el,"border-top-width",true);

			coor.X=box.x-borderLeft;
			coor.Y=box.y-borderTop;

			parent=el.parentNode;

			var borderLeft=0,borderTop=0;
			while (parent && parent!=document.body && parent!=document.documentElement) {
				if (!borderLeft) {
					borderLeft=Mantis.Style.Get(parent,"border-left-width",true);
					coor.X+=borderLeft;
				}
				if (!borderTop) {
					borderTop=Mantis.Style.Get(parent,"border-top-width",true);
					coor.Y+=borderTop;
				}

				if (borderLeft && borderTop) break;

				parent=parent.parentNode;
			}
		}
		else {
			coor.X=el.offsetLeft;
			coor.Y=el.offsetTop;

			parent=el.offsetParent;
			if (parent!=el) {
				while (parent) {
					coor.X+=parent.offsetLeft;
					coor.Y+=parent.offsetTop;
					parent=parent.offsetParent;
				}
			}
			return coor;
		}

		return coor;
	},
	Set:function (el) {
		var coor;
		if (arguments[1] instanceof Mantis.Position.Coor) coor=arguments[1];
		else coor=new Mantis.Position.Coor(arguments[1],arguments[2]);
		if (coor.X!==null && coor.X!==undefined) el.style.left=coor.X+"px";
		if (coor.Y!==null && coor.Y!==undefined) el.style.top=coor.Y+"px";
	}
};
Mantis.Position.Coor.prototype.toString=function () { return this.X+":"+this.Y; };

Mantis.QS={
	Length:0,
	Data:[],
	Initiated:false,
	Init:function () {
		this.Length=0;
		this.Data.length=0;
		var qs=location.search.substr(1),item;
		if (!qs) return;
		qs=qs.split("&");
		for (var i=0;i<qs.length;i++) {
			item=qs[i].split("=");
			item[1]=unescape(item[1]) || "";
			this.Data[item[0].toLowerCase()]=item[1];
			this.Data[i]=new Mantis.QS.Item(item[0],item[1]);
			this.Length++;
		}
		this.Item.prototype.toString=function () { return this.Name+"="+this.Value; };
	},
	Get:function (item) {
		if (!this.Initiated) {
			this.Init();
			this.Initiated=true;
		}
		return this.Data[(item+"").toLowerCase()];
	},
	Item:function (name,value) {
		this.Name=name;
		this.Value=value;
	},
	Add:function () {
		var a;
		if (typeof arguments[0]=="string" && arguments[1]!=undefined) a=[new this.Item(arguments[0],arguments[1])];
		else if (arguments[0] instanceof Array) a=arguments[0];
		else a=arguments;
		var qs="",hash="",rxQS,item,value;
		if (/\?([^#]*)(#.*)?$/.test(location.href)) {
			qs=RegExp.$1;
			hash=RegExp.$2;
		}
		for (var i=0;i<a.length;i++) {
			if (!(a[i] instanceof this.Item)) continue;
			item=a[i].Name;
			value=a[i].Value;
			rxQS=new RegExp("(^|&)"+item.ToRx()+"=?[^\&#]*(&|$)");
			qs=rxQS.test(qs) ? qs.replace(rxQS,"$1"+item+"="+value+"$2") : qs+(qs ? "&" : "")+item+"="+value;
		}
		location.href="?"+qs+hash;
	}
};

Mantis.Cookies={
	Get:function (name) {
		if (document.cookie && new RegExp("\\b"+name+"=([^;]*)").test(document.cookie)) return unescape(RegExp.$1);
	},
	Set:function (name,value,expInDays) {
		var d=new Date();d.setTime(d.getTime()+(expInDays||14)*24*3600*1000);
		document.cookie=name+"="+escape(value)+"; expires="+d.toGMTString();/*path=/; */
	},
	Del:function (name) {
		if (this.Get(name)) document.cookie=name+"=; expires=Thu, 01-Jan-70 00:00:01 UTC";
	}
};

Mantis.Window={
	Open:function (url,name,width,height,resizable,scroll) {
		if (resizable==undefined) resizable=false;
		if (scroll==undefined) scroll=true;

		resizable=resizable ? "yes" : "no";
		scroll=scroll ? "yes" : "no";

		return open(url,name,"width="+width+",height="+height+",resizable="+resizable+",scrollbars="+scroll+",left="+(screen.width-width)/2+",top="+(screen.height-height)/2);
	},
	DialogArguments:{},
	GetDialogArguments:function (closeIfNull) {
		try { return opener.Mantis.Window.DialogArguments[window.name] || window.dialogArguments || null; }
		catch (e) { if (closeIfNull) close();else return null; }
	},
	Dialog:function (url,name,args,width,height,resizable,scroll) {
		if (resizable==undefined) resizable=false;
		if (scroll==undefined) scroll=true;

		resizable=resizable ? "yes" : "no";
		scroll=scroll ? "yes" : "no";

		var win;
		//if (window.showModalDialog) win=showModalDialog(url,args,"dialogWidth:"+(width)+"px;dialogHeight:"+(height)+"px;resizable:"+resizable+";scroll:"+scroll+";help:no;center:yes;status:yes;");
		//else {
			Mantis.Window.DialogArguments[name]=args;
			win=window.open(url,name,"height="+height+",width="+width+",toolbar=no,directories=no,status=yes,menubar=no,modal=yes,resizable="+resizable+",scrollbars="+scroll);
			if (win && !win.closed) {
				win.dialogArguments=args;
				if (win.focus) {
					win.focus();
					if (win.onblur) win.onblur=function () { win.focus(); };
				}
			}
		//}
		return win;
	},
	Alert:function (msg) {
		alert(msg);
	},
	Confirm:function (msg,func,value) {
		if (confirm(msg,value || "") && typeof(func)=="function") func();
	}
};

Mantis.Xml={
	DOM:function () {if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLDOM");else if (document.implementation && document.implementation.createDocument) return document.implementation.createDocument("","",null);},
	HTTP:function () {if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");else if (window.XMLHttpRequest) return new XMLHttpRequest();},
	LoadXML:function (markup) {var dom;if (window.DOMParser) {dom=new DOMParser().parseFromString(markup,"text/xml");}else {try {dom=Mantis.Xml.DOM();dom.async=false;dom.loadXML(markup);}catch (e) {throw new Error("Markup could not be loaded.");}}return dom;}
};

Mantis.Ajax={
	cache:{},
	Cache:{
		Insert:function (key,obj) { Mantis.Ajax.cache[key]=obj; },
		Get:function (key) { return Mantis.Ajax.cache[key] || null; },
		Remove:function (key) { delete Mantis.Ajax.cache[key]; },
		Clear:function () { Mantis.Ajax.cache={}; }
	},
	AjaxPro:{
		Init:function () {
			if (typeof(AjaxPro)=="object") {
				AjaxPro.onError=function (ex) { alert(ex.h()); };
				AjaxPro.onLoading=function (b) { Mantis.Ajax.Wait(b); };
				Object.extend(Ajax.Web.Dictionary.prototype, {
					setValue:function(k, v) {
						for(var i=0; i<this.keys.length && i<this.values.length; i++) {
							if(this.keys[i] == k){
								this.values[i] = v;
								return i;
							}
						}
						return this.add(k, v);
					}
				});
			}
		},
		Output:function (func) {
			return function (req) {
				if (req.error) return Mantis.Debug.Confirm(
					req.error.Hash()+"\n\n"+func,
					function () {
						Mantis.Debug.Copy(req.error.Hash()+"\n\n"+func);
					}
				);
				if (req.value!==null) func(req.value);
			}
		}
	},
	Wait:function (start,loadingNotifier) {
		if (start) {
			document.body.AddClassName("wait");
			if (loadingNotifier) loadingNotifier.Show();
		}
		else {
			document.body.RemoveClassName("wait");
			if (loadingNotifier) loadingNotifier.Hide();
		}
	}
};

Mantis.Flash={
	GetHtml:function (url,width,height,id,bgColor,flashVars) {
		if (!width) width="";
		if (!height) height="";
		if (!flashVars) flashVars="";
		bgColor=bgColor ? '<param name="bgColor" value="'+bgColor+'" />' : "";
		return '<object type="application/x-shockwave-flash" id="'+id+'" data="'+url+'" style="width:'+width+'px;height:'+height+'px;"><param name="movie" value="'+url+'" /><param name="wmode" value="transparent" /><param name="flashvars" value="'+flashVars+'" />'+bgColor+'</object>';
	},
	GetElement:function () { return Mantis.DOM.GetElementFromMarkup(this.GetHtml.apply(null,arguments)); },
	Insert:function () { document.write(this.GetHtml.apply(null,arguments)); }
};

Mantis.Debug={
	Alert:function () { if (Mantis.Site.Debug) alert($A(arguments).join("\n")); },
	Copy:function (s) { if (Mantis.Site.Debug) Mantis.Browser.Copy($A(arguments).join("\n")); },
	Confirm:function (s,f) { if (Mantis.Site.Debug) { if (confirm(s)) f(); } },
	Status:function (s,add) { add?status+=s:status=s==undefined?"":s; }
};

Mantis.Text={
	Pad:function (s,n,chr) {n=n || 2;chr=chr || "0";s=""+s;while (s.length<n) s=chr+s;return s;},
	Escape:function (str,html) { if (typeof str=="string" && str.length) {if (!html) {str=str.replace(/>/g,"&gt;").replace(/</g,"&lt;");}else {str=str.replace(/\r?\n/g,"<br/>");}str=str.replace(/"/g,"&quot;").replace(/'/g,"&#39;");}return str;}
};

Mantis.Utils={
	InitPrototypes:function () {
		Array.From=function (o) { if (!o) return [];var a=[];for (var i=0;i<o.length;i++) a.push(o[i]);return a; };
		Array.prototype.IndexOf=function (v) {var i=0;while (i<this.length && this[i]!=v) i++;return i==this.length ? -1 : i;};
		Array.prototype.Contains=function (v) {return this.IndexOf(v)>-1;};
		Array.prototype.Remove=function (idx) {if (idx<0 || idx>=this.length) return;for (var i=idx+1;i<this.length;i++) this[i-1]=this[i];this.length--;return this;};
		Array.prototype.RemoveItem=function (item) {return this.Remove(this.IndexOf(item));};
		Array.$break={};Array.$continue={};
		Array.prototype.Each=function (f) {if (typeof(f)!="function") return;for (var i=0;i<this.length;i++) { var act=f.call(this[i],this[i],i); if (act==Array.$break) break;else if (act==Array.$continue) continue; }};
		// Searches for all items in a collection which pass the func function
		Array.prototype.FindAll=function (a,f) {var arr=[];$A(a).Each(function (i) { if (f.call(coll,i)) arr.push(c); } );return arr;};
		String.prototype.ToRx=function () {return this.replace(/(\(|\)|\{|\}|\[|\]|\:|\^|\$|\!|\=|\+|\*|\/|\,|\-|\||\?)/g,"\\$1");};
		String.prototype.Trim=function () {return this.replace(/^\s+|\s+$/g,"");};
		Function.prototype.Bind=function (scope,args) {var __method=this;return function() { return __method.apply(scope,args || []); }};
		Object.Hash=function (o,funcs,showFuncContent) {var s=[];for (var i in o) {if (typeof o[i]=="function" && funcs) s.push(i+"\t\t"+(showFuncContent ? o[i] : o[i].toString().substr(0,o[i].toString().search(/[\n\{]/))));else if (typeof o[i]!="function") s.push(i+"\t\t"+o[i]);}return "\r\n"+s.join("\r\n")+"\r\n";};
		//Object.prototype.Hash=function (funcs,showFuncContent) {return Object.Hash(this,funcs,showFuncContent);};
		//Object.prototype.h=Object.prototype.H=Object.prototype.Hash;
		Date.Format=function (date,format) { if (!date instanceof Date) date=new Date(date) || new Date();format=format || "h:I:S d/m/Y";format=format.split("");var a=[];for (var i=0;i<format.length;i++) a.push(Date.FormatIntervals[format[i]] ?  Date.FormatIntervals[format[i]](date) : format[i]);return a.join(""); };
		Date.prototype.Format=function (format) {return Date.Format(this,format);};
		Date.FormatIntervals={
			Months:["January","February","March","April","May","June","July","August","September","October","November","December"],HebMonths:["ינואר","פברואר","מרץ","אפריל","מאי","יוני","יולי","אוגוסט","ספטמבר","אוקטובר","נובמבר","דצמבר"],Days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],HebDays:["ראשון","שני","שלישי","רביעי","חמישי","שישי","שבת"],
			d:function (o) { return o.getDate(); },
			D:function (o) { return Mantis.Text.Pad(this.d(o)); },
			m:function (o) { return o.getMonth()+1; },
			M:function (o) { return Mantis.Text.Pad(this.m(o)); },
			n:function (o) { return this.N(o).substr(0,3); },
			N:function (o) { return this.Months[this.m(o)-1]; },
			B:function (o) { return this.HebMonths[this.m(o)-1]; },
			y:function (o) { return (""+this.Y(o)).substr(2); },
			Y:function (o) { return o.getFullYear(); },
			h:function (o) { return o.getHours(); },
			H:function (o) { return Mantis.Text.Pad(this.h(o)); },
			i:function (o) { return o.getMinutes(); },
			I:function (o) { return Mantis.Text.Pad(this.i(o)); },
			s:function (o) { return o.getSeconds(); },
			S:function (o) { return Mantis.Text.Pad(this.s(o)); },
			w:function (o) { return this.W(o).substr(0,3); },
			W:function (o) { return this.Days[o.getDay()]; },
			r:function (o) { return o.getDay()==6 ? "ש" : String.fromCharCode(o.getDay()+"א".charCodeAt()); },
			R:function (o) { return this.HebDays[o.getDay()]; },
			t:function (o) { var s="th",d=o.getDate();if (Math.floor(d/10)!=1) switch (d%10) { case 1: s="st"; break; case 2: s="nd"; break; case 3: s="rd"; break; } return s; }
		};
	},
	LoadExternalScripts:function () {
		var script;
		$A(document.getElementsByTagName("script")).Each(function (s) {if (s.src && /(.*)Mantis.js(?:\?Load=(.*))?/.test(s.src)) {script=s;return Array.$break;}});
		if (script) {
			var path=RegExp.$1,includes=RegExp.$2;
			Mantis.ScriptPath=path;
			Mantis.RootPath=path.replace(/JS\/Global\/\/?/,"");
			Mantis.Utils.LoadExternalCss("Mantis.css");
			if (includes) includes.split(",").Each(function (name) {Mantis.Utils.LoadExternalJs("Mantis."+name+".js");});
		}
	},
	LoadExternalJs:function (src) { document.write('<script type="text/javascript" src="'+Mantis.ScriptPath+""+src+'"><\/script>'); },
	LoadExternalCss:function (src) { document.write('<link rel="stylesheet" href="'+Mantis.ScriptPath+src+'" type="text/css"/>'); }
};

Mantis.Site={
	Debug:true
};

Mantis.OOP={
	Inherit:function (subClass,baseClass) {
		// inheirt without activating the base constructor at the statement
		// useage: function B() { alert("B"); } B.prototype.M=function () { alert('B.M'); }; function D() { D.baseConstructor.call(this); alert('D'); } Mantis.OOP.Inherit(D,B);
		function inheritance() {}
		inheritance.prototype=baseClass.prototype;

		var instance=new inheritance();

		for (var i in instance) {
			if (subClass.prototype[i]==undefined) subClass.prototype[i]=instance[i];
		}

		subClass.prototype.constructor=subClass;
		subClass.baseConstructor=baseClass;
		subClass.base=baseClass.prototype;
	},
	BaseInit:function (instance,args) {
		arguments.callee.caller.baseConstructor.apply(instance,args);
	},
	Base:function () {
		return arguments.callee.caller.baseConstructor;
	}
};

Mantis.Extensions={
	ElementInit:function () {
		if (Mantis.Browser.Safari && !window.HTMLElement) {
			var HTMLElement={};
			HTMLElement.prototype=document.createElement('div').__proto__;
		}

		if (typeof HTMLElement!="undefined") {
			Mantis.Extensions.Extend(HTMLElement.prototype,Mantis.Extensions.Element);
			Mantis.Extensions.Element.Disabled=true;
		}
		if (typeof Event!="undefined") {
			Mantis.Extensions.Extend(Event.prototype,Mantis.Extensions.Event);
			Mantis.Extensions.Event.Disabled=true;
		}
	},

	Element:{
		AddClassName:Mantis.Style.Add,
		RemoveClassName:Mantis.Style.Remove,
		HasClassName:Mantis.Style.Contains,
		ToggleClassName:Mantis.Style.Toggle,
		GetStyle:Mantis.Style.Get,
		SetStyle:Mantis.Style.Set,
		SetOpacity:Mantis.Style.Opacity.Set,
		GetOpacity:Mantis.Style.Opacity.Get,
		Visible:Mantis.Style.Display.Visible,
		Show:Mantis.Style.Display.Show,
		Hide:Mantis.Style.Display.Hide,
		FindParent:Mantis.DOM.FindParent,
		FindChildren:Mantis.DOM.FindChildren,
		TextContent:Mantis.DOM.TextContent,
		UniqueId:Mantis.DOM.UniqueId,
		Remove:Mantis.DOM.Remove,
		ClearChildren:Mantis.DOM.ClearChildren,
		Contains:Mantis.DOM.Contains,
		Toggle:Mantis.Style.Display.Toggle,
		AddListener:Mantis.Events.Add,
		RemoveListener:Mantis.Events.Remove,
		GetPosition:Mantis.Position.Get,
		SetPosition:Mantis.Position.Set,
		RemoveTextNodes:Mantis.DOM.RemoveTextNodes,
		DisableSelection:Mantis.DOM.Selection.Disable,
		EnableSelection:Mantis.DOM.Selection.Enable
	},
	Event:{
		SrcElement:Mantis.Events.SourceElement,
		RelatedElement:Mantis.Events.RelatedElement,
		Button:Mantis.Events.Button,
		MousePosition:Mantis.Events.MousePosition,
		Stop:Mantis.Events.Stop,
		KeyCode:Mantis.Events.KeyCode,
		CharCode:Mantis.Events.CharCode,
		Char:Mantis.Events.Char
	},
	Extend:function (el,o) {
		if (!el._Extensions) el._Extensions=[];
		if (el._Extensions.Contains(o)) return;
		for (var p in o) {
			var v=o[p],f;
			if (typeof(v)=="function") {
				if (Mantis.Extensions.cache[p]!=undefined) f=Mantis.Extensions.cache[p];
				else {
					f=Mantis.Extensions.addThisArg(v);
					Mantis.Extensions.cache[p]=f;
				}
				el[p]=f;
			}
			else el[p]=v;
		}
		Mantis.Extensions.elementsCache.push(o);
		el._Extensions.push(o);
	},
	addThisArg:function (f) {
		return function () { return f.apply(this,[this].concat($A(arguments))); }
	},
	cache:{},
	elementsCache:[],
	UnloadCache:function () {var c=this.elementsCache;for (var i=0;i<c.length;i++) {for (var a in c[i]) {delete c[i][a];c[i][a]=null;}delete c[i];c[i]=null;}delete c;c.length=0;}
};

Mantis.Init();
