﻿// JScript File
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.Browser={
	Detect:function () {
		var agent=navigator.userAgent.toLowerCase();

		this.IE=agent.indexOf("msie")!=-1;
		this.Gecko=agent.indexOf("gecko")!=-1;
		this.Opera=agent.indexOf("opera")!=-1;
		this.Safari=agent.search(/(konqueror|safari|khtml)/i)>-1;
		this.Other=!this.IE && !this.Gecko && !this.Safari;
	},
	Copy:function (s) {
		if (window.clipboardData) clipboardData.setData("Text",s);
		else if (window.netscape) {
			try {
				netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
				var clip=Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
				var trans=Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
				trans.addDataFlavor('text/unicode');
				var str=Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString) || {};
				str.data=s;
				trans.setTransferData("text/unicode",str,s.length*2);
				var clipid=Components.interfaces.nsIClipboard;
				clip.setData(trans,null,clipid.kGlobalClipboard);
			}
			catch (ex) {
				if (confirm("Copy function is not available in Mozilla and Firefox.\nDo you want more information about this issue?")) open("http://www.mozilla.org/editor/midasdemo/securityprefs.html");
			}
		}
	}
};

Mantis.Init=function () {
	Mantis.Browser.Detect();
	Mantis.QS.Init();

	Mantis.InitPrototypes();

	// global functions
	window.copy=function () { Mantis.Debug.Copy.apply(Mantis.Debug,arguments); };
	window.r=function () { Mantis.Debug.Alert.apply(Mantis.Debug,arguments); };
	window.$=Mantis.DOM.Get;
	window.$A=Array.From;
	window._=Mantis.DOM.Create;
	window.undefined=undefined;
	window.h=Object.Hash;

	Mantis.Events.DocumentLoad(
		function () {
			Mantis.Position.Init();
			Mantis.Ajax.AjaxPro.Init();
			window.$=Mantis.DOM.Get;
		}
	);
	Mantis.Events.Add(
		window,
		"unload",
		function () {
			Mantis.Events.UnloadCache();
			//Mantis.Extensions.UnloadCache();
		}
	);
};

Mantis.DOM={
	MaxCssValue:32000,

	Get:function (el) {
		if (!el) return null;
		if (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=document.createElement("div");
		div.innerHTML=markup;
		return div.firstChild;
	},
	// Removes an element
	Remove:function (el) {
		if (el.parentNode) el.parentNode.removeChild(el);
	},	
	// Does an element contains a another given element?
	Contains:function (el,parent) {
		return parent==el || (el && Mantis.DOM.Contains(parent,el.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;
	},

	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;
	},

	// IE select and the rest's flash and video objects hides dom elements. hides them temporarily
	ProblematicElementsVisiblility:{
		Set:function (b) {
			if (Mantis.Browser.IE) this.toggleProblematicTagVisibility("select",b);
			this.toggleProblematicTagVisibility("embed",b);
			this.toggleProblematicTagVisibility("object",b);
		},

		toggleProblematicTagVisibility:function (tag,b) {
			try {
				var s=document.getElementsByTagName(tag);
				for (var i=0;i<s.length;i++) {
					if (!b) s[i].setAttribute("lastVisibility",s[i].style.visibility);
					s[i].style.visibility=b ? s[i].getAttribute("lastVisibility") : "hidden";
				}
			}
			catch (ex) {}
		}
	},

	Selection:{
		Disable:function (el) {
			el.onselectstart=function () { return false; };
			el.style.MozUserSelect="none";
			el.style.KhtmlUserSelect="none";
		},
		Enable:function (el) {
			el.onselectstart=null;
			el.style.MozUserSelect="";
			el.style.KhtmlUserSelect="";
		}
	}
};

Mantis.Style={
	// Adds another css class for a given element
	Add:function (el,cls) {
		if (el) return !Mantis.Style.Contains(el,cls) ? el.className+=" "+cls : el.className;
	},
	// 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"),"");
	},
	// Does an element has a class name?
	Contains:function (el,cls) {if (el) return new RegExp("\\b"+cls.ToRx()+"\\b").test(el.className);},
	// Toggles a className
	Toggle:function (el,cls) {
		Mantis.Style[Mantis.Style.Contains(el,cls) ? "Remove" : "Add"](el,cls);
	},
	// The current style of an element
	// gets background-color, margin-top etc
	Get:function (el,style,toInt) {
		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() })];
		}
		return toInt ? parseInt(value) || 0 : value;
	},

	// gets background-color, margin-top etc
	Set:function (el,style) {
		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];
		}
	},

	Opacity:{
		Set:function (el,value) {
			el.style.filter="alpha(opacity="+(value*100)+")";
			el.style.opacity=value;
			el.style["-moz-opacity"]=value;
			el.style["-khtml-opacity"]=value;
		},
		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["-moz-opacity"] || el.style["-khtml-opacity"] || el.style.opacity;

			return value;
		}
	},

	Display:{
		Visible:function (el) { return !$(el).HasClassName("hidden"); },
		Show:function (el) { $(el).RemoveClassName("hidden"); },
		Hide:function (el) { $(el).AddClassName("hidden"); },
		Toggle:function (el) { $(el).ToggleClassName("hidden"); }
	}
};

Mantis.Events={
	cache:[],
	// Adds event
	Add:function (el,evt,func) {
		if (typeof(func)!="function") return;

		var callback=function (e) {
			Mantis.Extensions.Extend(e,Mantis.Extensions.Event);
			func(e,e.SrcElement());
		}

		if (!el) el=window;
		//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,callback]);
	},
	// Removes event
	Remove:function (el,evt,func) {
		if (typeof(func)!="function") return;
		if (!el) el=window;
		//if (evt=="keypress" && (Mantis.Browser.Safari || Mantis.Browser.IE)) evt="keydown";
		if (el.detachEvent) el.detachEvent("on"+evt,func);
		else if (el.removeEventListener) el.removeEventListener(evt,func,false);
	},
	// Gets Event Object
	GetEventObject:function (e) {
		return e || window.event;
	},
	// Gets Source Element
	SourceElement:function (e) { if (!e) e=GetEventObject(e); return $(e.srcElement || e.target); },
	// 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,
		ESC:		27,
		LEFT:		37,
		UP:			38,
		RIGHT:		39,
		DOWN:		40,
		DELETE:		46
	},
	Mouse:function (event) {
		return new Mantis.Position.Coor(
			event.pageX || (event.clientX+(document.documentElement.scrollLeft || document.body.scrollLeft)),
			event.pageY || (event.clientY+(document.documentElement.scrollTop || document.body.scrollTop))
		);
	},
	Stop:function (event) {
		if (event.preventDefault) {
			event.preventDefault();
			event.stopPropagation();
		}
		else {
			event.returnValue=false;
			event.cancelBubble=true;
		}
	},
	DocumentLoad:function (f) {
		if (document.addEventListener) document.addEventListener("DOMContentLoaded",f,false);
		else {
			var old=document.onreadystatechange;
			document.onreadystatechange=function () {
				if (document.readyState=="complete") {
					if (typeof(old)=="function") old();
					f();
				}
			};
		}
	}
};

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:[],
	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) {
		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) {
		var d=new Date();d.setTime(d.getTime()+365*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); };
			}
		},
		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) {
		var loadingNotifier=Mantis.Ajax.LoadingNotifier;
		if (start) {
			$(document.body);
			document.body.SetStyle({cursor:"wait"});
			
			if (!loadingNotifier) {
				loadingNotifier=_("div",document.body);
				loadingNotifier.AddClassName("loadingNotifier");
				loadingNotifier.innerHTML="Loading...";
				Mantis.Ajax.LoadingNotifier=loadingNotifier;
			}
			else loadingNotifier.Show();
		}
		else {
			document.body.SetStyle({cursor:""});
			loadingNotifier.Hide();
		}
	}
};

Mantis.Flash={
	GetHtml:function (url,width,height,id) {
		return '\
			<object type="application/x-shockwave-flash" data="'+url+'" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'">\
			<param name="movie" value="'+url+'" />\
			<param name="wmode" value="transparent" />\
			</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(); } }
};

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.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 (iIndex) {if (iIndex<0 || iIndex>=this.length) return;for (var i=iIndex+1;i<this.length;i++) this[i-1]=this[i];this.length--;return this;};
	Array.$break={};Array.$continue={};
	Array.prototype.Each=function (f) {
		if (typeof(f)!="function") return;
		for (var i=0;i<this.length;i++) {
			try { f(this[i],i); } catch (ex) { if (ex==Array.$break) break;else if (ex==Array.$continue) continue;else throw ex; }
		}
	};
	String.prototype.ToRx=function () {return this.replace(/(\(|\)|\{|\}|\[|\]|\:|\^|\$|\!|\=|\+|\*|\/|\,|\-|\||\?)/g,"\\$1");};
	Function.prototype.Bind=function () {var __method=this,args=$A(arguments),object=args.shift();return function() { return __method.apply(object,args.concat($A(arguments))); }};
	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:["ראשון","שני","שלישי","רביעי","חמישי","שישי","שבת"],
		HebShortDays:["א","ב","ג","ד","ה","ו","ש"],
		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; }
	};
};

Mantis.Site={
	Debug:true
};

Mantis.Extensions={
	ElementInit:function () {
		if (Browser.Safari && !window.HTMLElement) {
			var HTMLElement={};
			HTMLElement.prototype=document.createElement('div').__proto__;
		}

		if (typeof HTMLElement!="undefined") { 
			Mantis.Extensions.Extend(HTMLElement,Mantis.Extensions.Element);
			Mantis.Extensions.Element.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,
		TextContent:Mantis.DOM.TextContent,
		Remove:Mantis.DOM.Remove,
		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,
		Stop:Mantis.Events.Stop
	},

	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(null,[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();

function GoToRegion(id) {
	Mantis.QS.Add(new Mantis.QS.Item("RegionId",id));
}
function GoToCountry(id) {
	Mantis.QS.Add(new Mantis.QS.Item("CountryId",id));
}



function addFlash(url,id,width,height,bgcolor,wmode,salign,align)
{
      str = '<object type="application/x-shockwave-flash" data="'+url+'" width="'+width+'" height="'+height+'">' +
            '<param name="movie" value="'+url+'" />' +
			'<param name="wmode" value="transparent" />' +
			'</object>';
	  document.getElementById("flashPostition").innerHTML = str;
}

function addHpFlash(url,id,width,height,bgcolor,wmode,salign,align)
{
      str = '<object type="application/x-shockwave-flash" data="'+url+'" width="'+width+'" height="'+height+'">' +
            '<param name="movie" value="'+url+'" />' +
			'<param name="wmode" value="transparent" />' +
			'</object>';
	  document.getElementById("flashArt").innerHTML = str;
}



function GilatFlash(url,width,height,id)
{
      str = '<object type="application/x-shockwave-flash" data="'+url+'" width="'+width+'" height="'+height+'">' +
            '<param name="movie" value="'+url+'" />' +
			'<param name="wmode" value="transparent" />' +
			'</object>';
	  document.getElementById(id).innerHTML = str;
}

