﻿//	**************************************************************************
//	Jena - Javascript Library (Core)
//
//	Written by Robert Swiston
//
//	Copyright 2010, RomiDesigns - All Rights Reserved
//
//	No part of this script may be reproducted or altered without the
//	expressed consent of RomiDesigns or its representative(s)
//	**************************************************************************
var body = document.getElementsByTagName("body")[0], page = "page", noConflictMode = false, helperMode = true;
var SET = 1, APPEND = 2, REMOVE = 3, PREPEND = 4, REPLACE = 5, CONTAINS = 6, INDEXOF = 7,
	LEFT_BUTTON = 1, RIGHT_BUTTON = 2,
	LAST = 9999;

//	**************************************************************************
//	Primary jenaCore function
//	**************************************************************************	
function jenaCore(pParam)
{
	if (body===undefined)body=document.getElementsByTagName("body")[0];
	this.member = null;
	this.isNull = true;
	this.size = 0;
	this.canHandle = {attachEvent:false, appendChild:false, insertBefore:false, createElement:false, addEventListener:false};
	
	//	base (core) public methods
	this.getMember = function(pId)
	{
		pId = (pId == null ? 0 : (pId === LAST ? this.size - 1 : pId));
		
		return (this.isNull ? null : (this.member[pId] == undefined ? this.member : this.member[pId]));
	};
	this.setMember = function(pId)
	{
		this.member = this.getMember(pId);
		
		this.isNull = (this.member == null);
		this.size = (this.isNull ? 0 : 1);
		this.canHandle =
		{
			attachEvent:this.isNull ? false : this.member.attachEvent,
			appendChild:this.isNull ? false : this.member.appendChild,
			insertBefore:this.isNull ? false : this.member.insertBefore,
			createElement:this.isNull ? false : this.member.createElement,
			addEventListener:this.isNull ? false : this.member.addEventListener
		};
		
		return this;
	};
	//	set the member control to the submitted parameters (if parameters is null then set it to the document)
	this.setParam = function(pParameter, pRoot)
	{
		if (pParameter == null) pParameter = document;
		
		function getElements()
		{
			return {root:pRoot, rootLength:(pRoot.length != undefined ? pRoot.length : 0)};
		};
		function getElement(i)
		{
			var retMember = getElements();

			if (i < retMember.rootLength) retMember.root = pRoot[i];
			else retMember.root = null;
			
			return retMember.root;
		};
		function getElementsByClassOrName(pClass)
		{
			var retMember = getElements(), i = 0;

			retMember.root = null;	
			if (retMember.rootLength > 0)
			{
				retMember.root = [];
				while (i < retMember.rootLength)
				{
					if (pClass.indexOf("~") === 1)
					{
						if ((pClass.substring(0,1) === "@" ? pRoot[i].className : pRoot[i].name).indexOf(pClass.substring(2)) >= 0) retMember.root[retMember.root.length] = pRoot[i];
					}
					else
					{
						if ((pClass.substring(0,1) === "@" ? pRoot[i].className : pRoot[i].name) === pClass.substring(1)) retMember.root[retMember.root.length] = pRoot[i];
					}
					
					i++;
				}
				if (retMember.root.length == 0) retMember.root = null;
			}
			
			return retMember.root;
		};
		
		if (typeof pParameter == "string")
		{
			var Parameters = pParameter.split(">");
			var iLength = Parameters.length,
				iLen = 0;
			
			while (iLen < iLength && pRoot != null)
			{
				var search = Parameters[iLen].trim(),
					iSearch = parseInt(search);
				
				if (iSearch.toString() === search) pRoot = getElement(iSearch - 1);
				else if (search.substring(0,1) === "#") pRoot = pRoot.getElementById(search.substring(1));
				else if (search.substring(0,1) === ".") pRoot = getElementsByClassOrName(search);
				else if (search.substring(0,1) === "@") pRoot = getElementsByClassOrName(search);
				else pRoot = pRoot.getElementsByTagName(search);

				iLen++;
			}
		}
		else
		{
			pRoot = pParameter;
		}
		
		this.isNull = pRoot == null || pRoot == undefined;
		this.size = pRoot != null ? pRoot.length == undefined ? 1 : pRoot.length : 0;
		this.canHandle =
		{
			attachEvent:this.isNull ? false : pRoot.attachEvent,
			appendChild:this.isNull ? false : pRoot.appendChild,
			insertBefore:this.isNull ? false : pRoot.insertBefore,
			createElement:this.isNull ? false : pRoot.createElement,
			addEventListener:this.isNull ? false : pRoot.addEventListener
		};
		
		return pRoot;
	};
	
	/*	initialize the library	*/
	this.member = this.setParam(pParam, document);

	/*	html object handling	*/
	//	append a new HTML Element
	this.append = function(pNew)
	{
		if (pNew != null && this.canHandle.appendChild)
		{
			if (typeof pNew === "string") pNew = document.createElement(pNew);
			
			this.member = this.member.appendChild(pNew);
		}
		return this;
	};
	// clone the current object
	this.clone = function()
	{
		var newObject = this.getMember().cloneNode(true);
		return this.parent().append(newObject);
	};	
	//	creat a new HTML element
	this.create = function(pNew)
	{
		if (pNew !== null && this.canHandle.createElement)
		{
			var newElement = document.createElement(pNew);
			this.member = newElement;
		}
		return this;
	};
	//	find the request HTML element
	this.find = function(pNewParam)
	{
		if (!this.isNull) this.member = this.setParam(pNewParam, this.member);
		return this;
	};
	//	insert a new HTML element
	this.insert = function(pNew, pSibling)
	{
		if (pNew !== null && pSibling !== null && this.canHandle.insertBefore)
		{
			if (typeof pSibling === "number") pSibling = this.member.childNodes[pSibling];
			if (typeof pNew === "string") pNew = document.createElement(pNew);

			if (pSibling !== null && pNew !== null) this.member = this.member.insertBefore(pNew, pSibling);
		}
		return this;
	};
	//	remove the desired HTML element
	this.remove = function(pReturnElement)
	{
		pReturnElement = pReturnElement || false;

		if (!this.isNull && this.getMember(LAST).parentNode)
		{
			var Parent = this.getMember(LAST).parentNode;
			var retValue = pReturnElement ? this.getMember(LAST) : this;

			Parent.removeChild(this.getMember(LAST));
			
			this.size -= 1;
			if (this.size > 0) this.member.pop();
			
			if (this.size === 0)
			{
				this.member = Parent;
				this.size = 1;
			}
		}
		return retValue;
	};
	
	//	lineage handling
	this.prevSibling = function(pTagName)
	{
		var found = false;
		
		while (!found && this.member.previousSibling)
		{
			this.member = this.member.previousSibling;
			
			if (this.member.tagName !== undefined)
			{
				if (this.member.tagName.toLowerCase() === pTagName.toLowerCase())
				{
					found = true;
				}
			}
		}
		
		return this;
	};
	this.nextSibling = function(pTagName)
	{
		var found = false;
		
		while (!found && this.member.nextSibling)
		{
			this.member = this.member.nextSibling;
			
			if (this.member.tagName !== undefined)
			{
				if (this.member.tagName.toLowerCase() === pTagName.toLowerCase())
				{
					found = true;
				}
			}
		}
		
		return this;
	};
	this.parent = function(pGenOrTag)
	{
		if (this.size > 1) this.setMember(0);
		
		pGenOrTag = pGenOrTag == null ? 1 : pGenOrTag;
		
		var loop = 0, 
			shouldBreak = false,
			gen = (typeof pGenOrTag == "number"),
			test = 0;

		if (!gen)
		{
			if (pGenOrTag.indexOf("@") === 0) test = 1;
			else if(pGenOrTag.indexOf(".") === 0) test = 2;
		}
		
		if (gen && pGenOrTag == 0) return this;
		
		while (this.getMember().parentNode && !shouldBreak)
		{
			this.member = this.getMember().parentNode;
			loop++;

			if (gen && (loop == pGenOrTag)) shouldBreak = true;
			else if (!gen)
			{
				if (test === 0 && (this.member.tagName.toLowerCase() == pGenOrTag.toLowerCase())) shouldBreak = true;
				if (test === 1 && (this.member.className.toLowerCase() == pGenOrTag.substring(1).toLowerCase())) shouldBreak = true;
			}
			
			if (!shouldBreak && loop > 999) shouldBreak = true;
			
			//if ((gen && loop == pGenOrTag) || (!gen && (this.member.tagName.toLowerCase() == pGenOrTag.toLowerCase()))) break;
			//if (loop > 999) break;
		}
		
		return this;
	};
	
	//	looping (for attributes and styles)
	this.forEach = function(pAction, pValue, pIsStyle)
	{
		var i = this.size;
		var IsStyle = pIsStyle || false;
		var ret = this;
		var Add = pValue != null ? (pValue.substring && pValue.substring(0, 1) == "+") : false;
		
		pValue = Add ? pValue.substring(1) : pValue;
		
		function write(pObject, pElement)
		{
			if (/[h|H]eight|[w|W]idth|[t|T]op|[l|L]eft/.test(pElement) && !/px/.test(pValue) && pValue !== "") pValue += "px";

			if (pObject != undefined && pObject[pElement] != pValue) pObject[pElement] = (Add ? pObject[pElement] : "") + pValue;
		};
		function read(pObject, pElement)
		{
			if (pObject != undefined) 
			{
				if (pObject[pElement] != undefined) return pObject[pElement];
				else if (pObject.getAttribute) return pObject.getAttribute(pElement);
				else if (pObject.attributes != null) return pObject.attributes.getNamedItem(pElement).value;
				else return null;
			}
		};
		
		while (i--)
		{
			var thismember = IsStyle ? this.getMember(i).style : this.getMember(i);

			if (pValue != null) write(thismember, pAction); else ret = read(thismember, pAction);
		}
		
		return ret;
	};
	
	//	attribute handling
	this.attribute = function(pAttribute, pValue)
	{
		return this.forEach(pAttribute, pValue);
	};
	//	build an object of attributes from the current member with the provided filter
	this.attributes = function(pFilter)
	{
		pFilter = pFilter || "";
		pFilter = pFilter.toLowerCase();
		
		var RetValue = {};
		
		for (var Key = 0; Key < this.member.attributes.length; Key++)
		{
			var KeyName = this.member.attributes[Key].name.toLowerCase();
			if (KeyName.indexOf(pFilter) >= 0)
			{
				RetValue[KeyName] = this.member.attributes[Key].value;
			}
		}
		
		return RetValue;
	};
	//	get or set the function of the event
	this.action = function(pEvent, pFunction)
	{
		var i = this.size;
		while (i--)
		{
			if (this.canHandle.addEventListener) 
			{
				this.getMember(i).addEventListener(pEvent.replace("on", ""), new Function(pFunction), false);
			}
			else if (this.canHandle.attachEvent) 
			{
				this.getMember(i).attachEvent(pEvent, new Function(pFunction));
			}
			else 
			{
				this.attribute(pEvent, pFunction);
			}
		}
		
		return this;
	};
	
	//	style handling
	this.style = function(pStyle, pValue)
	{
		if (typeof pStyle == "string") return this.forEach(pStyle, pValue, true);
		else
		{
			if (pValue != null)
			{
				for (var Key in pStyle) this.forEach(Key, pStyle[Key], true);	
				return this;
			}
			else
			{
				for (var Key in pStyle) pStyle[Key] = this.forEach(Key, null, true);
				return pStyle;
			}
		}
	};
	
	this.scrollPosition = function(pElement)
	{
		var ScrollTop = 0,
			ScrollLeft = 0;
		
		pElement = pElement || window;

		if (pElement == window)
		{	
			if (document.documentElement && !document.documentElement.scrollTop && window.pageYOffset)
			{
				ScrollLeft = window.pageXOffset;
				ScrollTop = window.pageYOffset;
			}
			else if (document.documentElement && document.documentElement.scrollTop)
			{
				ScrollLeft = document.documentElement.scrollLeft;
				ScrollTop = document.documentElement.scrollTop;
			}
			else if (document.body && document.body.scrollTop)
			{
				ScrollLeft = document.body.scrollLeft;
				ScrollTop = document.body.scrollTop;
			}
		}
		
		return {Left:ScrollLeft, Top:ScrollTop};
	};
	this.pageSize = function()
	{
		var h = Math.max(Math.max(document.body.scrollHeight, document.documentElement.scrollHeight), Math.max(document.body.offsetHeight, document.documentElement.offsetHeight), Math.max(document.body.clientHeight, document.documentElement.clientHeight)),
			w = Math.max(Math.max(document.body.scrollWidth, document.documentElement.scrollWidth), Math.max(document.body.offsetWidth, document.documentElement.offsetWidth), Math.max(document.body.clientWidth, document.documentElement.clientWidth));
					
		return {height:h, width:w};
	};
	this.windowSize = function()
	{
		var h = (!window.innerHeight ? (!document.documentElement.clientHeight == 0 ? document.documentElement.clientHeight : document.body.clientHeight) : window.innerHeight);
		var w = (!window.innerWidth ? (!document.documentElement.clientWidth == 0 ? document.documentElement.clientWidth : document.body.clientWidth) : window.innerWidth);
		
		return {height:h, width:w};
	};

	this.hasJava = function()
	{
		if (this.browser.safari) 
		{
			return true;
		}
		
		for (var i = 0; i < navigator.plugins.length; i++)
		{
			if (navigator.plugins[i].name.indexOf("Java Plug-in") >= 0)
			{
				return true;
			}
		}
		
		return false;
	};
	
	return this;
};

//	**************************************************************************
//	Add the attribute/style collection methods to the core. This is done to
//	save keystrokes on development and file size for production
//	**************************************************************************
jenaCore.prototype = 
{
	//	the column span (for table cells)
	colSpan:function(pSpan)
	{
		return this.attribute("colSpan", (pSpan != null ? pSpan.toString() : null));
	},
	//	the css style
	css:function(pClass, pUpdate, pAltValue)
	{
		pUpdate = pUpdate || 1;
		var OrigClass = "";
		
		if (!this.isNull) OrigClass = this.getMember().className || "";
		
		switch (pUpdate)
		{
			case 2: //append the new class name
				pClass = OrigClass + pClass;
				break;
			case 3: //remove the class name
				pClass = OrigClass.replace(new RegExp(pClass, "gi"), "");
				break;
			case 4: //prepend the new class name
				pClass += OrigClass.className;
				break;
			case 5: //Replace the existance of class with the alternate value
				pClass = OrigClass.replace(new RegExp(pClass, "gi"), pAltValue);
				break;
			case 6: //return true/false for the class name containing the class
				return (OrigClass.indexOf(pClass) > -1);
				break;
			case 7: //return the int value where the class exists in the classname
				return OrigClass.indexOf(pClass);
				break;
		}

		return this.attribute("className", pClass);
	},
	//	the element id
	id:function(pId)
	{
		return this.attribute("id", pId);
	},
	//	the cellpadding (for tables)
	padding:function(pPadding)
	{
		return this.attribute("cellPadding", pPadding);
	},
	//	the row span (for table cells)
	rowSpan:function(pSpan)
	{
		return this.attribute("rowSpan", (pSpan != null ? pSpan.toString() : null));
	},
	//	the cellspacing (for tables)
	spacing:function(pSpacing)
	{
		return this.attribute("cellSpacing", pSpacing);
	},
	//	the src (used on images)
	src:function(pSource)
	{
		return this.attribute("src", pSource);
	},
	//	the inner HTML text
	text:function(pText)
	{
		if (pText != null && pText != undefined) pText = pText.toString();
		return this.attribute("innerHTML", pText);
	},
	//	the opacity
	opacity:function(pPercent)
	{
		if (pPercent <= 0) return this.hide();
		else
		{
			this.style("opacity", (pPercent / 100).toString());
			this.style("MozOpacity", (pPercent / 100).toString());
			this.style("KhtmlOpacity", (pPercent / 100).toString());
			this.style("filter", "alpha(opacity=" + pPercent + ")");
			return this.show();
		}
	},
	//	the height of the member (can be a % of the pElement)
	height:function(pValue, pElement)
	{
		if (pElement != null && pValue.indexOf("%") > 0)
		{
			if (pElement == page) pValue = ((parseInt(pValue) / 100) * this.pageSize().height) + "px";
			else pValue = ((parseInt(pValue) / 100) * pElement.offsetHeight) + "px";
		}
		return this.style("height", pValue);			
	},
	//	the width of the member (can be a % of the pElement)
	width:function(pValue, pElement)
	{
		if (pElement != null && pValue.indexOf("%") > 0)
		{
			if (pElement == page) pValue = ((parseInt(pValue) / 100) * this.pageSize().width) + "px";
			else pValue = ((parseInt(pValue) / 100) * pElement.offsetWidth) + "px";
		}
		return this.style("width", pValue);
	},
	//	show with style = pShowAs (default = block)
	show:function(pShowAs)
	{
		pShowAs = pShowAs || "block";

		return this.style("display", pShowAs);
	},
	hideError:function()
	{
		if (!this.isNull) return this.text("").hide();
	},
	//	format and show the error message
	showError:function(pText, pShowAs)
	{
		pText = pText.replace("Error:", "");
		
		if (this.isNull) alert(pText);
		else 
		{
			if (pText !== "") return this.text(pText.replace(/\;/g, "<br/>")).show(pShowAs);
			else return this.text("").hide();
		}
	},
	//	hide (set display=none)
	hide:function()
	{
		return this.style("display", "none");
	}
};

//	**************************************************************************
//	Add the browser object to the core
//	**************************************************************************
var userAgent = navigator.userAgent.toLowerCase();
jenaCore.prototype.browser = 
{
	agent:userAgent,
	version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [0,"0"])[1],
	safari:/webkit/.test(userAgent) && !/chrome/.test(userAgent),
	opera:/opera/.test(userAgent),
	msie:/msie/.test(userAgent) && !/opera/.test(userAgent),
	chrome:/chrome/.test(userAgent),
	mozilla:/mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
};
jenaCore.prototype.system = 
{
	window:/window/.test(userAgent) || /16bit/.test(agent),
	mac:/mac/.test(userAgent),
	macClassic:/mac/.test(userAgent) && !this.hasJava(),
	macOSx:/mac/.test(userAgent) && this.hasJava()
};
//var isWindows = ((agent.indexOf("win")!=-1) || (agent.indexOf("16bit")!=-1));
//var isMac = (agent.indexOf("mac")!=-1);
//var isMacClassic = (isMac && !hasJavaPlugin());
//var isMacOSX = (isMac && !isMacClassic);

//	**************************************************************************
//	Add the physical characteristics of the "member" functionality to the core
//	**************************************************************************
jenaCore.prototype.bounds = function()
{
	var thismember = this.getMember();
	
	return {x:thismember.offsetLeft, y:thismember.offsetTop, width:thismember.offsetWidth, height:thismember.offsetHeight};
};

jenaCore.prototype.pos = function()
{
	var thismember = this.getMember();
	var self = this;
	
	//find the absolute position of the element on the web page
	this.findAbsPosition = function(pElement)
	{
		pElement = pElement || thismember;
		
		var X = 0, Y = 0;
		
		X = pElement.offsetLeft;
		Y = pElement.offsetTop;
		
		while (pElement.offsetParent)
		{
			pElement = pElement.offsetParent;
			X += pElement.offsetLeft;
			Y += pElement.offsetTop;
		}
			
		return {x:X, y:Y};
	};
	//find the center of the element
	this.findCenter = function(pElement)
	{
		pElement = pElement || window;
		
		var h = (pElement == window ? this.windowSize().height : (pElement == document ? 0 : pElement.offsetHeight));
		var w = (pElement == window ? this.windowSize().width : (pElement == document ? 0 : pElement.offsetWidth));
		var Scroll = this.scrollPosition(pElement);

		var iX = ((w - thismember.offsetWidth) / 2) + Scroll.Left,
			iY = ((h - thismember.offsetHeight) / 2) + Scroll.Top;

		return {left:iX, top:iY};
	};
	//center the element
	this.center = function(pElement)
	{
		var pCenter = this.findCenter(pElement);
		this.style("left", pCenter.left + "px");
		return this.style("top", pCenter.top + "px");
	};
	this.moveTo = function(pLeft, pTop)
	{
		function adjust(pValue, pFrom)
		{
			if (pValue.substring(0, 1) === "+")
			{
				return parseInt(pFrom) + parseInt(pValue.substring(1));
			}
			else
			{
				return parseInt(pFrom) - parseInt(pValue.substring(1));
			}
		};
		
		pLeft = pLeft.replace("px", "");
		pTop = pTop.replace("px", "");
		
		if (/[-\+]/.test(pLeft)) pLeft = adjust(pLeft, this.style("left"));
		if (/[-\+]/.test(pTop)) pTop = adjust(pTop, this.style("top"));
		
		this.style("left", pLeft);
		return this.style("top", pTop);
	};
	//set the left (x) position of element (optionally relative to the object)
	this.left = function(pValue, pObject)
	{
		if (pObject != null)
		{
			var AbsPos = this.findAbsPosition(pObject);
			
			pValue = AbsPos.x + parseInt(pValue) + "px";
		}
		
		return this.style("left", pValue);
	};
	//set the top (y) position of element (optionally relative to the object)
	this.top = function(pValue, pObject)
	{
		if (pObject != null)
		{
			var AbsPos = this.findAbsPosition(pObject);
			
			pValue = AbsPos.y + parseInt(pValue) + "px";
		}
		
		return this.style("top", pValue);
	};
	return self;
};

//	**************************************************************************
//	Add the parameter handling functionality to the core
//	**************************************************************************
jenaCore.prototype.args = function(pArgs)
{
	var self = this;
	
	this.concat = function(pArguments, pStartAt)
	{
		pArgs = pArguments || pArgs;
		pStartAt = pStartAt || 0;
		
		var RetValue = "";
				
		for (var i = pStartAt; i < pArgs.length; i+=2)
		{
			if (pArgs[i].constructor === Array)
			{
				for (var j = 0; j < pArgs[i].length; j+=2)
				{
					RetValue += "&" + pArgs[i][j] + "=" + pArgs[i][j + 1].toString().Escape();
				}
			}
			else
			{
				RetValue += "&" + pArgs[i] + "=" + pArgs[i + 1].toString().Escape();
			}
		}
		
		
		return RetValue;
	};
	this.setDefault = function(pKeyValue)
	{
		for (var Key in pKeyValue)
		{
			pArgs[Key] = (pArgs[Key] == null || pArgs[Key] == "undefined") ? pKeyValue[Key] : pArgs[Key];
		}
		return pArgs;
	};
	
	return self;
};

//	**************************************************************************
//	Add the image handling functionality to the core
//	**************************************************************************
jenaCore.prototype.images = function()
{
	var self = this;
	
	this.findObject = function(n, d)
	{
		var p, i, x;
		if (!d)
		{
			d = document;
		}
		
		if ((p = n.indexOf("?")) > 0 && parent.frames.length)
		{
			d = parent.frames[n.substring(p + 1)].document;
			n = n.substring(0, p);
		}
		
		if (!(x = d[n]) && d.all)
		{
			x = d.all[n];
		}
		
		for (i = 0; !x&&i < d.forms.length; i++)
		{
			x = d.forms[i][n];
		}
		for (i = 0; !x && d.layers && i < d.layers.length; i++)
		{
			x = this.FindObject(n, d.layers[i].document);
		}
		
		if (!x && d.getElementById)
		{
			x = d.getElementById(n);
		}
		
		return x;
	};
	this.swapImage = function()
	{
		var j = 0,
			x,
			a = this.swapImage.arguments;
			
		document.ImagesArray = new Array;
		
		for (var i = 0; i < (a.length -2); i+=3)
		{
			if ((x = this.findObject(a[i])) != null)
			{
				document.ImagesArray[j++] = x;
				if (!x.oSrc)
				{
					x.oSrc = x.src;
				}
				
				x.src = a[i + 2];
			}
		}
	};	
	this.restore = function()
	{
		var i, 
			x, 
			a = document.ImagesArray; 
		for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) 
		{
			x.src=x.oSrc
		}
	};
	
	return self;
};

var jCore = function(pElement)
{
	return new jenaCore(pElement);
};

$jenaPage = $jPage = jenaPage = jPage = new function()
{
	this.currentUrl = self.location.href;
	this.addTimer = function(pUrl)
	{
		var Inclusion = "t=",
			Base = pUrl.replace("&t=","ANDT=").replace("?t=","ANDT=").split("ANDT="),
			thisDay = new Date(),
			Iteration = parseInt
			(
				thisDay.getFullYear().toString() + 
				(thisDay.getMonth() + 1).toString().padLeft("0", 2) + 
				thisDay.getDate().toString().padLeft("0", 2) + 
				thisDay.getHours().toString().padLeft("0", 2) + 
				thisDay.getMinutes().toString().padLeft("0", 2) + 
				thisDay.getSeconds().toString().padLeft("0", 2) + 
				thisDay.getMilliseconds().toString().padLeft("0", 3)
			);

		var RetValue = Base[0] + (Base[0].indexOf("?") > 0 ? "&" : "?") + Inclusion + Iteration;
		
		if (Base.length > 1)
		{
			if (Base[1].indexOf("&") >= 0)
			{
				var Elements = Base[1].substring(Base[1].indexOf("&"));
				RetValue += Elements;
			}
		}

		return RetValue;
	};
	this.mousePos = function(pEvent, pAdjustForScroll)
	{
		var objNetscape = document.getElementById&&!document.all,
			X = objNetscape ? pEvent.clientX : event.clientX,
			Y = objNetscape ? pEvent.clientY : event.clientY;
	
		if (pAdjustForScroll === null) pAdjustForScroll = true;

		if (pAdjustForScroll)
		{
			var scroll = jCore().scrollPosition();
			X += scroll.Left;
			Y += scroll.Top;
		}
		
		return {x:X, y:Y};
	};	
	this.navigate = function(pUrl)
	{
		pUrl = pUrl || self.location.href;
		
		if (pUrl.indexOf(".aspx") < 0) 
		{
			if (pUrl.indexOf("?") < 0) pUrl += "Default.aspx";
			else pUrl = pUrl.replace("?", "Default.aspx?");
		}

		self.location.href = this.addTimer(pUrl);
	};
	this.print = function(pControlId, pStyles)
	{
		pStyles = pStyles || "";
		
		var control = pControlId;
		if (typeof pControlId === "string")
		{
			if (pControlId.indexOf("#") < 0) pControlId = "#" + pControlId;
			control = jCore(pControlId).getMember(0);
		};
		
		var windowOptions = "toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes,width=750,height=500,left=100,top=25",
			windowHTML = jCore(control).text(),
			windowPrint = window.open("", "", windowOptions);
			
		while (windowHTML.indexOf(" cssclass") > 0)
		{
			windowHTML = windowHTML.replace(" cssclass", " class");
		}
		
		windowPrint.document.open();
		windowPrint.document.write("<html><head>");
		if (pStyles !== null)
		{
			var styles = pStyles.split(",");
			for (var iStyle = 0; iStyle < styles.length; iStyle++)
			{
				windowPrint.document.write("<link href=\"" + styles[iStyle] + "\" type=\"text/css\" rel=\"stylesheet\"/>");
			}
		}

		windowPrint.document.write("</head><body>");
		windowPrint.document.write(windowHTML);
		windowPrint.document.write("</body></html>");
		windowPrint.document.close();
		windowPrint.print();
		windowPrint.close();
		
		return false;
	};
	this.queryValue = function(pKey, pDefault)
	{
		if (pDefault === null) pDefault = "";
		pKey = pKey.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		
		var RegEx = new RegExp("[\\?&/]" + pKey + "[=/]([^&#/]*)");
		var QuerySearch = RegEx.exec(window.location.href);
		
		if (QuerySearch === null) return pDefault;
		else return QuerySearch[1];
	};
	this.setQuery = function()
	{
		var currentUrl = window.location.href,
			args = this.setQuery.arguments;
		
		for (var iArg = 0; iArg < args.length; iArg+=2)
		{
			sep = "=";
			
			if (window.location.href.indexOf("/" + args[iArg] + "/") > 0) sep = "/";
			
			var currentValue = this.queryValue(args[iArg]),
				oldResult = args[iArg] + sep + currentValue,
				newResult = args[iArg] + sep + args[iArg + 1];
				
			currentUrl = currentUrl.replace(oldResult, newResult);
		}
		
		return currentUrl;
	};
};

//	**************************************************************************
//	Window Loading functionality
//	**************************************************************************
var windowOnLoad = [];

function addOnLoad(pFunction)
{
	windowOnLoad[windowOnLoad.length] = pFunction;
};

window.onload = function()
{
	if (windowOnLoad.length > 0)
	{
		for (var woln = 0; woln < windowOnLoad.length; woln++)
		{
			windowOnLoad[woln]();
		}
	}
};

//	**************************************************************************
//	Javescript base protoyping
//	**************************************************************************
//	Javescript string protoyping
//	**************************************************************************
String.prototype.Escape = function()
{
	var RetString = escape(this);
	return RetString.replace(/\+/g, "%2B");
};
String.prototype.Unescape = function()
{
	var RetString = unescape(this);
	return RetString.replace(/\%2B/gi, "+");
};
String.prototype.Xml2Html = function()
{
	var RetString = this;
	return RetString.replace(/\>/g, "&gt;").replace(/\</g, "&lt;").replace(/\n/g, "<br/>").replace(/\t/g, "&nbsp;&nbsp&nbsp;");
};
String.prototype.isNullOrEmpty = function()
{
	return (((this == null || this == "undefined" || this == "null") ? "" : this) == "");
};
String.prototype.setNullValue = function(pValue)
{
	if (this.isNullOrEmpty()) return pValue;
	else return this;
};
String.prototype.trim = function() 
{
    return this.replace( /^\s+|\s+$/, "");
};
String.prototype.padLeft = function(pChar, pLength)
{
	var RetValue = this;
	while (RetValue.length < pLength) RetValue = pChar + RetValue;
	return RetValue;
};
String.prototype.padRight = function(pChar, pLenght)
{
	var RetValue = this;
	while (RetValue.length < pLength) RetValue += pChar;
	return RetValue;
};