String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };
String.prototype.ltrim = function() { return this.replace(/\s*((\S+\s*)*)/, "$1"); };
String.prototype.rtrim = function() { return this.replace(/((\s*\S+)*)\s*/, "$1"); };
String.prototype.leftPad = function (l, c) { return new Array(l - this.length + 1).join(c || '0') + this; }

Array.prototype.inArray = function(searchTerm)
{
	var i = this.length;

	if (i > 0)
	{
		do
		{
			if (this[i] === searchTerm)
			{
				return true;
			}

			i--;
		} while (i>0);
	}
	return false;
}


var userAgent=navigator.userAgent.toLowerCase();

var isIE=(typeof(window.VBArray)!='undefined');

var isIE5=/*@cc_on @_jscript_version == 5.1 ? true : @*/false;
var isIE55=/*@cc_on @_jscript_version == 5.5 ? true : @*/false;
var isIE6=/*@cc_on @_jscript_version == 5.6 ? true : @*/false;
var isIE7=/*@cc_on @_jscript_version == 5.7 ? true : @*/false;
var isIE8=/*@cc_on @_jscript_version == 5.8 ? true : @*/false;

var isOpera=typeof(window.opera)!="undefined";
var isSafari=/a/.__proto__=='//';
var isChrome=/source/.test((/a/.toString+''));

var tableRowDisplayType=((userAgent.indexOf('msie')+1)?'block':'table-row');
var tableDisplayType=((userAgent.indexOf('msie')+1)?'block':'table');


if (typeof($)=='undefined')
{
	eval('function $(objId) { return document.getElementById(objId); }');
}


// IE 7 checkbox onchange bugfix
window.jscript/*@cc_on=@_jscript_version@*/
if (typeof(window.jscript)!='undefined' && jscript==5.7)	//if IE7
{
	attachToEvent(window,'load',fixIE7CheckboxOnchange);
}


function fixIE7CheckboxOnchange()
{
	var inputs = document.getElementsByTagName("input"), i=-1, l=inputs.length;
	while (++i!==l)
	{
		var inputs_i=inputs[i];

		if ((inputs_i.type=="checkbox") && inputs_i.onchange)
		{
			inputs_i._onchange=inputs_i.onchange;
			inputs_i.onchange=null;
			inputs_i.onpropertychange=function() {if (event.propertyName=='checked') this._onchange();};
		}
	}
}

function addWindowOnLoad(functionName)
{
	if (typeof(__windowOnLoad)=='undefined')
	{
		__windowOnLoad=new Array();
		if (typeof(window.onload)!='undefined' && window.onload!=null)
		{
			__windowOnLoad[0]=window.onload;
		}
		window.onload=function()
		{
			var i;
			for (i=0;i<__windowOnLoad.length;i++)
			{
				if (typeof(__windowOnLoad[i])=='function')
				{
					__windowOnLoad[i]();
				}
				else
				{
					eval(__windowOnLoad[i]);
				}
			}
		}
	}
	__windowOnLoad[__windowOnLoad.length]=functionName;
}


function attachToEvent(obj,eventName,func)
{
	if(obj.addEventListener)
	{
		obj.addEventListener(eventName,func,false);
	}
	else
	{
		if(obj.attachEvent)
		{
			obj.attachEvent('on'+eventName,func);
		}
	}
}

function addFlash(contentId,content)
{
	var index;

	if (typeof(__objectContent)=='undefined')
	{
		__objectContent=new Array();
	}
	index=__objectContent.length;
	__objectContent[index]=new Array();
	__objectContent[index]['id']=contentId;
	__objectContent[index]['content']='type="application/x-shockwave-flash" '+content;
}


function addObject(contentId,content)
{
	var index;

	if (typeof(__objectContent)=='undefined')
	{
		__objectContent=new Array();
	}
	index=__objectContent.length;
	__objectContent[index]=new Array();
	__objectContent[index]['id']=contentId;
	__objectContent[index]['content']=content;
}


function putObject()
{
	var i;

	if (typeof(__objectContent)=='undefined' || __objectContent.length<1)
	{
		return;
	}
	for (i=0;i<__objectContent.length;i++)
	{
		document.getElementById(__objectContent[i]['id']).innerHTML='<object " '+__objectContent[i]['content']+'</object>';
	}
}

attachToEvent(window, 'load', putObject);

function getObjXY(Obj)
{
	var Cord,leftpos,toppos,aTag,IE;

	if(typeof Obj != "object")
	{
		Obj = document.getElementById(Obj);
	}

	IE=(typeof(Obj.currentStyle)!='undefined');
	Cord = new Array();
	leftpos = Obj.offsetLeft;
	toppos = Obj.offsetTop;

	if ((IE?Obj.currentStyle['position']:Obj.style.position)!='absolute')
	{
		aTag = Obj;
		do
		{
			aTag = aTag.offsetParent;
			leftpos += aTag.offsetLeft;
			toppos += aTag.offsetTop;
			if (aTag.style.position=='absolute')
			{
				leftpos -= aTag.offsetLeft;
				toppos -= aTag.offsetTop;
				break;
			}
		} while(aTag.tagName!="BODY" && aTag.tagName!="HTML" && (IE?aTag.currentStyle['position']:aTag.style.position) == 'static');
	}
	Cord[0]=leftpos;
	Cord[1]=toppos;
	return Cord;
}


function getElementsByClassName(oElm, strTagName, oClassNames)
{
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var arrRegExpClassNames = new Array();
	if(typeof oClassNames == "object")
	{
		for(var i=0; i<oClassNames.length; i++)
		{
			arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
		}
	}
	else
	{
		arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
	}
	var oElement;
	var bMatchesAll;
	for(var j=0; j<arrElements.length; j++)
	{
		oElement = arrElements[j];
		bMatchesAll = true;
		for(var k=0; k<arrRegExpClassNames.length; k++){
			if(!arrRegExpClassNames[k].test(oElement.className))
			{
				bMatchesAll = false;
				break;
			}
		}
		if(bMatchesAll)
		{
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}


function resetFileInput(formObj)
{
	var origValue= new Array();
	var index;

	for (index=0;index<formObj.elements.length;index++)
	{
		origValue[index]=new Array();
		origValue[index][0]=formObj.elements[index].type;
		origValue[index][1]=formObj.elements[index].value;
		if (origValue[index][0]!='file' && origValue[index][0]!='submit' && origValue[index][0]!='reset')
		{
			origValue[index][2]=formObj.elements[index].disabled;
		}
		if (origValue[index][0]=='radio')
		{
			origValue[index][3]=formObj.elements[index].checked;
		}
	}
	formObj.reset();
	for (index=0;index<formObj.elements.length;index++)
	{
		if (origValue[index][0]!='file' && origValue[index][0]!='submit' && origValue[index][0]!='reset')
		{
			formObj.elements[index].value=origValue[index][1];
			formObj.elements[index].disabled=origValue[index][2];
			if (origValue[index][0]=='radio')
			{
				formObj.elements[index].checked=origValue[index][3];
			}
		}
	}
}

//------------------------------------------------------------------------------------------------------------
//################################## -Modal popup object------------ #########################################
//------------------------------------------------------------------------------------------------------------

var ModalPopup = {

	mResult: null,
	mNewWindow: null,
	mAction: null,

	open: function (aUrl, aParams, aWindowFeatures, aAction, aContext)
	{
		if ((typeof(aAction) != "undefined") && aAction)
		{
			if (typeof(aContext) != "undefined")
			{
				this.mAction = function (aParam) { aAction.call(aContext, aParam); };
			}
			else
			{
				this.mAction = aAction;
			}
		}
		if (window.showModalDialog)
		{
			var WindowFeatures = aWindowFeatures.replace(/,/g, ";").replace(/=/g, ": ").replace(/width/g, "dialogWidth").replace(/height/g, "dialogHeight");
			this.mResult = showModalDialog(aUrl, aParams, WindowFeatures);
			if ((this.mAction != null) && (this.mResult != null))
			{
				this.mAction(this.mResult);
			}
		}
		else
		{
			this.mResult = this.openGeckoModalDialog(aUrl, aParams, aWindowFeatures);
		}
	},
	openGeckoModalDialog: function (aUrl, aParams, aWindowFeatures)
	{
		if (this.mNewWindow)
		{
			this.mNewWindow.close();
			this.mNewWindow = null;
		}
		this.mNewWindow = window.open(aUrl, "ModalDialog", aWindowFeatures + ",modal=yes,dialog=yes");
		this.mNewWindow.dialogArguments = aParams;
		this.mNewWindow.onunload = function (e)
		{
			if ((this.opener.ModalPopup.mAction != null) && (this.returnValue != null))
			{
				this.opener.ModalPopup.mAction(this.returnValue);
			}
		};
	}
}

var HM_DOM = document.getElementById ? true : false;
var HM_IE  = document.all ? true : false;
var HM_NS4 = document.layers ? true : false;

function HM_f_ToggleElementList(show,elList,toggleBy)
{
	if(!(HM_DOM||HM_IE||HM_NS4))
	{
		return true;
	}

	if(HM_NS4&&(toggleBy=="tag"))
	{
		return true;
	}

	for(var i=0; i<elList.length; i++)
	{
		var ElementsToToggle = [];
		switch(toggleBy)
		{
			case "tag":
				ElementsToToggle = (HM_DOM) ? document.getElementsByTagName(elList[i]) : document.all.tags(elList[i]);
				break;
			case "id":
				ElementsToToggle[0] = (HM_DOM) ? document.getElementById(elList[i]) : (HM_IE) ? document.all(elList[i]) : document.layers[elList[i]];
			break;
		}
		for(var j=0; j<ElementsToToggle.length; j++)
		{
			var theElement = ElementsToToggle[j];
			if(!theElement)
			{
				continue;
			}
			if(HM_DOM||HM_IE)
			{
				theElement.style.visibility = show ? "inherit" : "hidden";
			}
			else if (HM_NS4)
			{
				theElement.visibility = show ? "inherit" : "hide";
			}
		}
	}
	return true;
}

var theArray = new Object;
theArray[0] = 'select';
theArray[1] = 'form';
theArray.length = 2;


//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["additionalIframe1","additionalIframe2","additionalIframe3","additionalIframe4","additionalIframe5","additionalIframe6","additionalIframe7","additionalIframe8","additionalIframe9","additionalIframe10","additionalIframe11","additionalIframe12","additionalIframe13","additionalIframe14","additionalIframe15","additionalIframe16","additionalIframe17","additionalIframe18","additionalIframe19","additionalIframe20"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller()
{
	var dyniframe=new Array()
	for (var i=0; i<iframeids.length; i++)
	{
		if (document.getElementById)
		{
			resizeIframe(iframeids[i])
		}
		//reveal iframe for lower end browsers? (see var above):
		if ((document.all || document.getElementById) && iframehide=="no")
		{
			var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
			tempobj.style.display="block"
		}
	}
}

function resizeIframe(frameid)
{
	var currentfr=document.getElementById(frameid)
	if (currentfr && !window.opera)
	{
		currentfr.style.display="block"
		if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
		{
			currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
		}
		else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
		{
			currentfr.height = currentfr.Document.body.scrollHeight+15;
		}

		if (currentfr.addEventListener)
		{
			currentfr.addEventListener("load", readjustIframe, false)
		}
		else if (currentfr.attachEvent)
		{
			currentfr.detachEvent("onload", readjustIframe) // Bug fix line
			currentfr.attachEvent("onload", readjustIframe)
		}
	}
}

function readjustIframe(loadevt)
{
	var crossevt=(window.event)? event : loadevt
	var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement

	if (iframeroot)
	{
		resizeIframe(iframeroot.id);
	}
}

function loadintoIframe(iframeid, url)
{
	if (document.getElementById)
	{
		document.getElementById(iframeid).src=url
	}
}

attachToEvent(window, 'load', resizeCaller);

