liltype = function()
{
	this.inherited = null;
}
new liltype();

liltype.dbg = function(id)
{
	if (id)
	{
		this.id = id;
		this.active = true;
	}
}
new liltype.dbg();

liltype.dbg.prototype.m = function(txt)
{
	var n = document.getElementById(this.id);
	if (this.active && n)
	{
		n.innerHTML += txt+"<br />\n";
	}
}

liltype.attach = function(obj, path, dat)
{
	var i, c, stub;

	if (!obj.liltype)
	{
		obj.liltype = {};
	}

	path = path.split(/\./);
	for (stub = obj.liltype, i = 0, c = path.length - 1; i < c; i++)
	{
		if (!stub[path[i]])
		{
			stub[path[i]] = {};
		}
		stub = stub[path[i]];
	}
	stub[path[i]] = dat;
}

liltype.getCookie = function(key)
{
	var m;
	if (m = document.cookie.match(new RegExp("(^|\\s)"+key+"=([^;]+)(;|$)")))
	{
		return m[2];
	}
	else
	{
		return "";
	}
}

liltype.setCookie = function(dat, data)
{
	var expry = null;

	if (dat.expryInDays != 0)
	{
		expry = new Date();
		expry.setTime(expry.getTime() + (dat.expryInDays * 86400000));
	}

	document.cookie =
		dat.cookieKey+"="+data+
		(expry ? ("; expires="+(expry.toUTCString ? expry.toUTCString() : expry.toGMTString())) : "")+
		(dat.path ? ("; path="+dat.path) : "")+
		(dat.domain ? ("; domain=."+dat.domain) : "");
}

/*
	START: Cookie utility
*/
	liltype.cookieUtil = function(code, key, expryInDays)
	{
		if (key)
		{
			this.expryInDays = expryInDays ? expryInDays : 0;
			this.dat = new Array();
			this.touches = new Array();
			this.cookieKey = key;
			liltype.cookieUtil.utils[code] = this;
		}
	}
	new liltype.cookieUtil(null, null, null);
	liltype.cookieUtil.utils = new Array();
	
	liltype.cookieUtil.get = function(code, key)
	{
		return this.utils[code].get(key);
	}
	
	liltype.cookieUtil.set = function(code, key, val)
	{
		this.utils[code].set(key, val);
	}
	
	liltype.cookieUtil.domain = function()
	{
		var domain = window.location.hostname;
		if ((domain.match(/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/)) ||
			  (domain.toLowerCase() == "localhost"))
		{
			domain = "";
		}
		else
		{
			domain = domain.replace(/^.+\.([^\.]+\.[^\.]+)$/, "$1");
		}
		return domain;
	}

	liltype.cookieUtil.init = function()
	{
		var cu = liltype.cookieUtil.prototype;

		cu.domain = this.domain();

		cu.path = "/";
		
		cu.keys = new Array();

		cu.init = function()
		{
			var rgs, dat, i, c, tuple, datStr;
			this.dat = [];
			if (dat = decodeURIComponent(liltype.getCookie(this.cookieKey)))
			{
				dat = dat.split(/\&/);
	
				for (i = 0, c = dat.length; i < c; i++)
				{
					tuple = dat[i].split(/=/);
					this.dat[tuple[0]] =
					 decodeURIComponent(tuple[1]);
				}
			}
			this.inited = true;
		}

		cu.get = function(key)
		{
			var v;
			if (!this.inited)
			{
				this.init();
			}
			return (v = this.dat[this.keys[key]]) ? v : "";
		}

		cu.set = function(key, val)
		{
			var k, v, dat, domain;
			if (!this.inited)
			{
				this.init();
			}
			val = ""+val;
			this.dat[this.keys[key]] = val;
			this.touches[this.keys[key]] = true;
		
			dat = "";
			for (k in this.dat)
			{
				if (this.dat[k].length)
				{
					dat += "&"+k+"="+encodeURIComponent(this.dat[k]);
				}
			}

			liltype.setCookie(this, encodeURIComponent(dat.substr(1)));
			this.inited = false;
		}
	
		cu.touched = function(key)
		{
			return this.touches[this.keys[key]];
		}
	}
	liltype.cookieUtil.init();	

/*
	END: Cookie utility
*/

liltype.imgPreloads = new Array();

liltype.imgPreload = function(src)
{
	var img = new Image();
	img.src = src;
	liltype.imgPreloads[src] = img;
}

liltype.imgReload = function(src)
{
	var img = liltype.imgPreloads[src];
	img = img ? img : new Image();
	return img;
}

liltype.rollOverOut = function(selectorA)
{
	var i, imgs = jQuery(selectorA+" img"), img, docImg;

	for (i = 0; i < imgs.length; i++)
	/* Preload 'over' image */
	{
		docImg = imgs.get(i);

		img = new Image();
		img.src =	docImg.src;
		this.attach(docImg, "imageOut", img);

		img = new Image();
		img.src = docImg.src.replace(/(\.|\-|_)(out|selected)\.([^\.]+)/, "$1over.$3");
		this.attach(docImg, "imageOver", img);
	}

	if (imgs.length)
	{
		jQuery(selectorA).mouseover
		(
			function ()
			{
				var img = jQuery("img", this).get(0);
				img.src = img.liltype.imageOver.src;
			}
		).mouseout
		(
			function ()
			{
				var img = jQuery("img", this).get(0);
				img.src = img.liltype.imageOut.src;
			}
		);
	}
}


liltype.PopUpWindow = function(url, name, width, height)
/* Pass a fifth argument of false to stop the window from immediately popping up */
{
	var pop;
	if (arguments.length)
	{
		this.url = url;
		this.name = name;
		this.width = width;
		this.height = height;
		this.toolbar = 'no';
		this.location = 'no';
		this.directories = 'no';
		this.status = 'no';
		this.menubar = 'no';
		this.scrollbars = 'yes';
		this.resizable = 'yes';
		this.win = null;

		if ((arguments[4] != undefined) ? arguments[4] : true)
		{
			this.pop();
		}
	}
}
new liltype.PopUpWindow();

liltype.PopUpWindow.prototype.pop = function()
{
	var widgets = 
	 "toolbar=" + this.toolbar + "," +
	 "location=" + this.location + "," +
	 "directories=" + this.directories + "," +
	 "status=" + this.status + "," +
	 "menubar=" + this.menubar + "," +
	 "scrollbars=" + this.scrollbars + "," +
	 "resizable=" + this.resizable + "," +
	 "width=" + this.width + "," +
	 "height=" + this.height;
	this.win = window.open(this.url, this.name, widgets);

	if(this.win.opener != null)
	{
		if(this.win.opener.top != null)
		{
			if((this.win.opener.top.name == null) ||
				 (this.win.opener.top.name == ""))
			{
				try
				{
					this.win.opener.top.name= "opener";
				}
				catch (e)
				{
				}
			}
		}
	}
	this.win.focus();
}

liltype.parentClass = function(jq, className)
{
	var p;
	if (!jq.length)
	{
		return null;
	}
	else
	{
		p = jq.parent();	
		if (p.hasClass(className))
		{
			return p;
		}
		else
		{
			return this.parentClass(p, className);
		}
	}
}