$ = function (Element) { return document.getElementById(Element); };
show = function (Element) { Element.style.display = "block"; };
hide = function (Element) { Element.style.display = "none"; };
isVisible = function (Element) { return getStyle(Element, "display") == "block"; };
getVisibility = function (Element) { return Element.style.display; };
setVisibility = function (Element, Visibility) { Element.style.visibility = Visibility; };
getHeight = function (Element) { var OriginallyVisible = isVisible(Element); if (!isVisible(Element)) show(Element); var Height = Element.offsetHeight; if (!OriginallyVisible) hide(Element); return Height; };
setHeight = function (Element, Height) {  if (isNaN(Height)) Element.style.height = Height; else Element.style.height = Height + "px"; };
getWidth = function (Element) { var OriginallyVisible = isVisible(Element); if (!isVisible(Element)) show(Element); var Width = Element.offsetWidth; if (!OriginallyVisible) hide(Element); return Width; };
setWidth = function (Element, Width) { if (isNaN(Width)) Element.style.width = Width; else Element.style.width = Width + "px"; };
getOffsetTop = function (Element) { var Top = 0; while (Element.offsetParent) { Top += getTop(Element); Element = Element.offsetParent; } return Top; };
getTop = function (Element) { var OriginallyVisible = isVisible(Element); if (!isVisible(Element)) show(Element); var Top = Element.offsetTop; if (!OriginallyVisible) hide(Element); return Top; };
setTop = function (Element, Top) { Element.style.top = Top + "px"; };
getOffsetLeft = function (Element) { var Left = 0; while (Element.offsetParent) { Left += getLeft(Element); Element = Element.offsetParent; } return Left; };
getLeft = function (Element) { var OriginallyVisible = isVisible(Element); if (!isVisible(Element)) show(Element); var Left = Element.offsetLeft; if (!OriginallyVisible) hide(Element); return Left; };
setLeft = function (Element, Left) { Element.style.left = Left + "px"; };
getClip = function (Element) { var clips = Element.style.clip.toString().replace(/[^0-9\s]/gi, "").split(" "); return { top: clips[0], right: clips[1], bottom: clips[2], left: clips[3], width: clips[1] - clips[3], height: clips[2] - clips[0] }; };
setClip = function (Element, Top, Left, Width, Height) { Element.style.clip = "rect(" + Top + "px, " + (Left + Width) + "px, " + (Top + Height) + "px, " + Left + "px)"; };
getZindex = function (Element) { return Element.style.zIndex; };
setZindex = function (Element, Index) { Element.style.zIndex = Index; };
setHTML = function (Element, HTML) { Element.innerHTML = HTML; };
getScrollX = function () { try { return document.documentElement.scrollLeft + document.body.scrollLeft; } catch (e) { return window.scrollX; } };
getScrollY = function () { try { return document.documentElement.scrollTop + document.body.scrollTop; } catch (e) { return window.scrollY; } };
getMouseX = function (Event) { if (!Event) Event = window.event; return Event.clientX + getScrollX(); };
getMouseY = function (Event) { if (!Event) Event = window.event; return Event.clientY + getScrollY(); };
removeItemFromArray = function (ArrayItem, OriginalArray) { var NewArray = new Array(); for (var i = 0; i < OriginalArray.length; i++) { if (OriginalArray[i] != ArrayItem) NewArray.push(OriginalArray[i]); } return NewArray; };
attachEventListener = function (Element, Method, Function, Capture) { if (Element.addEventListener) Element.addEventListener(Method, Function, Capture); else if (Element.attachEvent) Element.attachEvent("on" + Method, Function); else eval("Element.on" + Method + "=" + Function); };
detachEventListener = function (Element, Method, Function, Capture) { if (Element.removeEventListener) Element.removeEventListener(Method, Function, Capture); else if (Element.detachEvent) Element.detachEvent("on" + Method, Function); else eval("delete Element.on" + Method); };
cancelEventBubble = function (Event) { if (!Event) Event = window.event; if (Event.cancelBubble){ Event.cancelBubble = true;	Event.returnValue = false; } if (Event.preventDefault) Event.preventDefault(); if (Event.stopPropagation) Event.stopPropagation(); };
getEventTarget = function (Event) { var Target; if (!Event) var Event = window.event; if (Event.target) Target = Event.target; else if (Event.srcElement) Target = Event.srcElement; if (Target && Target.nodeType == 3) Target = Target.parentNode; return Target; };
getKeyCode = function (Event) { if (!Event) var Event = window.event; if (Event.keyCode) return Event.keyCode; else if (Event.which) return Event.which; };
isEnterKey = function (Event) { if (getKeyCode(Event) == 13) return true; else return false; };
ignoreEnterKey = function (Event) { if (isEnterKey(Event)) return false; };
getDocumentWidth = function () { if (window.innerWidth) return window.innerWidth; if (document.documentElement.clientWidth) return document.documentElement.clientWidth; if (document.body.clientWidth) return document.body.clientWidth; }	;
getDocumentHeight = function () { if (window.innerHeight) return window.innerHeight; if (document.documentElement.clientHeight) return document.documentElement.clientHeight; if (document.body.clientHeight) return document.body.clientHeight; }	;
getScrollTop = function () { if (document.documentElement && document.documentElement.scrollTop) return document.documentElement.scrollTop; else if (document.body) return document.body.scrollTop; else return 0; };
getScrollLeft = function () { if (document.documentElement && document.documentElement.scrollLeft) return document.documentElement.scrollLeft; else if (document.body) return document.body.scrollLeft; else return 0; };
isValidEmail = function (Email) { return Email.match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3} \.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)/gi); };
isValidFormText = function (Text) { return !Text.match(/[\&\#\<\>]+/gi); };
isValidExtension = function (FilePath, Extension) { var Extensions = Extension.split(","); for (var i = 0; i < Extensions.length; i++) { if (FilePath.match(new RegExp(Extensions[i] + "$", "gi"))) return true; } return false; };
isValidDate = function (Text) { return Text.match(/^[0-9]{1,2}\s(January|February|March|April|May|June|July|August|September|October|November|December)\s[0-9]{4}$/gi); };
isValidDateTime = function (Text) { return Text.match(/^[0-9]{1,2}\s(January|February|March|April|May|June|July|August|September|October|November|December)\s[0-9]{4}\s[0-9]{2}:[0-9]{2}$/gi); };
isEmpty = function (Text) { return !Text.match(/[^\s]+/gi); };
sentenceCase = function (Text) { var Words = Text.split(" "); var Sentence = ""; for (var i = 0; i < Words.length; i++) { Sentence += Words[i].replace(/^[a-z]/gi, Words[i].substr(0,1).toUpperCase()) + (i < Words.length - 1 ? " " : ""); } return Sentence; };
trimWhiteSpace = function (Text) { return Text.replace(/^\s*/, "").replace(/\s*$/, ""); };
truncate = function(Text, Length, Suffix) { return (Text.length <= Length) ? Text : Text.substr(0, Length) + "..."; };
toggleSelectBoxes = function (State) { if (!document.all) return; var Selects = document.getElementsByTagName("select"); for (var i = 0; i < Selects.length; i++) Selects[i].style.visibility = (State == "on") ? "visible" : "hidden"; };
hideSelectBoxes = function () { toggleSelectBoxes("off"); };
showSelectBoxes = function () { toggleSelectBoxes("on"); };
strongEaseOut = function (t, b, c, d) { return c*((t=t/d-1)*t*t*t*t + 1) + b; };
strongEaseIn = function (t, b, c, d) { return c*(t/=d)*t*t*t*t + b; };
strongEaseInOut = function (t, b, c, d) { if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; return c/2*((t-=2)*t*t*t*t + 2) + b; };
noSpam = function () { var EmailHtml = ""; for (var i = 0; i < arguments.length; i++) { EmailHtml += arguments[i]; if (i == 0) EmailHtml += "@"; else if (i < arguments.length - 1) EmailHtml += "."; } EmailHtml = "<a href=\"mail" + "to:" + EmailHtml + "\" title=\"Send an e-mail to " + EmailHtml + "\">" + EmailHtml + "</a>"; document.write (EmailHtml); };
showPopupImage = function (Src, Width, Height) { var Html = "<a href=\"#\" onclick=\"clearInterval($('PopupImage').ResizeListener);closeModal();return false;\" id=\"PopupClose\"></a><img id=\"PopupImage\" src=\"" + Src + "\" width=\"" + Width + "\" height=\"" + Height + "\" alt=\"\" />"; showModal(Html, "auto"); setImageSize(Width, Height); if ($("PopupImage").ResizeListener) clearInterval($("PopupImage").ResizeListener); $("PopupImage").ResizeListener = setInterval("setImageSize(" + Width + ", " + Height + ")", 50); };
setImageSize = function (Width, Height) { var paddingWidth = 50; var paddingHeight = 100; if (Width > (getDocumentWidth() - paddingWidth)) { var Ratio = (getDocumentWidth() - paddingWidth) / Width; Width = getDocumentWidth() - paddingWidth; Height *= Ratio; } if (Height > (getDocumentHeight() - paddingHeight)) { var Ratio = (getDocumentHeight() - paddingHeight) / Height; Height = getDocumentHeight() - paddingHeight; Width *= Ratio; } setWidth($("PopupImage"), Width); setHeight($("PopupImage"), Height); setModal(); };
showAlert = function (Message) { var Html = "<div class=\"Message\">" + Message + "</div><div class=\"Buttons\"><button onclick=\"closeModal();\">OK</button></div>"; showModal(Html); };
submitUpload = function () { var NeatUploadId = ""; var Inputs = document.getElementsByTagName("INPUT"); for (var i = 0; i < Inputs.length; i++) { if (Inputs[i].type.toLowerCase() == "file" && Inputs[i].value.match(/[^\s]+/gi)) { NeatUploadId = Inputs[i].name.match(/^NeatUpload_[0-9A-Z]+/gi); } } if (NeatUploadId != "") { showModal(""); if (!$("ModalIframe")) { var ModalIframe = document.createElement("iframe"); ModalIframe.setAttribute("id", "ModalIframe"); ModalIframe.setAttribute("width", "400"); ModalIframe.setAttribute("height", "100"); ModalIframe.setAttribute("scrolling", "no"); ModalIframe.setAttribute("frameborder", "0"); $("ModalDialogue").appendChild(ModalIframe); } $("ModalIframe").src = "/Common/Scripts/Upload/UploadProgressHtml.aspx?postBackID=" + NeatUploadId; setTimeout("document.forms[0].submit();", 1000); } else { document.forms[0].submit(); } };
showModal = function (Html, Width) { hideSelectBoxes(); if (!$("ModalOverlay")) { var ModalOverlay = document.createElement("div"); ModalOverlay.setAttribute("id", "ModalOverlay"); document.body.appendChild(ModalOverlay); } if (!$("ModalDialogue")) { var ModalDialogue = document.createElement("div"); ModalDialogue.setAttribute("id", "ModalDialogue"); ModalDialogue.setAttribute("style", "display:none;top:-10000;left:-10000;"); document.body.appendChild(ModalDialogue); } setHTML($("ModalDialogue"), Html); if (Width) setWidth($("ModalDialogue"), Width); setModal(); if ($("ModalOverlay").StageListener) clearInterval($("ModalOverlay").StageListener); $("ModalOverlay").StageListener = setInterval("setModal()", 50); };
closeModal = function () { if ($("ModalOverlay") && $("ModalOverlay").StageListener) clearInterval($("ModalOverlay").StageListener); if($("ModalDialogue")) $("ModalDialogue").parentNode.removeChild($("ModalDialogue")); if($("ModalOverlay")) $("ModalOverlay").parentNode.removeChild($("ModalOverlay")); showSelectBoxes(); };
setModal = function () { setTop($("ModalOverlay"), getScrollTop()); setLeft($("ModalOverlay"), getScrollLeft()); setHeight($("ModalOverlay"), getDocumentHeight()); setTop($("ModalDialogue"), getScrollTop() + (getDocumentHeight() - getHeight($("ModalDialogue"))) / 2); setLeft($("ModalDialogue"), getScrollLeft() + (getDocumentWidth() - getWidth($("ModalDialogue"))) / 2); show($("ModalDialogue")); };
monitorTaskProgress = function (TaskId) { sendPostRequest("/Common/Scripts/Task/TaskProgressXml.aspx", "<request taskid=\"" + TaskId + "\" abort=\"false\" />", "getTaskProgress"); };
abortTask = function (TaskId) { sendPostRequest("/Common/Scripts/Task/TaskProgressXml.aspx", "<request taskid=\"" + TaskId + "\" abort=\"true\" />", "getTaskProgress"); };
getTaskProgress = function (Request) { var Xml = Request.responseXML; var Id =  Xml.documentElement.getAttribute("id"); var PercentComplete = Xml.documentElement.getAttribute("percentcomplete"); var ElapsedTime = Xml.documentElement.getAttribute("elapsedtime"); var Status = Xml.documentElement.getAttribute("status"); var Error = Xml.documentElement.firstChild.nodeValue; UpdateTaskProgress(PercentComplete, Error); if (PercentComplete < 1) sendPostRequest("/Common/Scripts/Task/TaskProgressXml.aspx", "<request taskid=\"" + Id + "\" abort=\"false\" />", "getTaskProgress"); };
makeHttpRequest = function (ScriptUrl, Method, PostData, SuccessCallbackFunction, FailureCallbackFunction) { var Request; var RefreshQS = "Refresh=" + (Math.random() * 999999); if (ScriptUrl.indexOf("?") > -1) ScriptUrl += "&" + RefreshQS; else ScriptUrl += "?" + RefreshQS; if (window.XMLHttpRequest) { Request = new XMLHttpRequest(); Request.onreadystatechange = function () { if(Request.readyState == 4) { if (Request.status != 200) eval(FailureCallbackFunction + "(Request);"); else eval(SuccessCallbackFunction + "(Request);"); } }; Request.open(Method, ScriptUrl, true);  if (Method.toUpperCase() == "POST") Request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");  Request.send(PostData); } else if (window.ActiveXObject) { Request = new ActiveXObject("Microsoft.XMLHTTP"); if (Request) { Request.onreadystatechange = function () { if(Request.readyState == 4) { if (Request.status != 200) eval(FailureCallbackFunction + "(Request);"); else eval(SuccessCallbackFunction + "(Request);"); } }; Request.open(Method, ScriptUrl, true); if (Method.toUpperCase() == "POST") Request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); Request.send(PostData); } } return Request; };
makeHttpRequestFailed = function (Request) { showAlert(Request.responseText); /*"<div class=\"Warning\">Unable to complete request!</div>"); */};
sendPostRequest = function (ScriptUrl, PostData, CallbackFunction) { makeHttpRequest (ScriptUrl, "POST", PostData, CallbackFunction, "makeHttpRequestFailed"); };
sendGetRequest = function (ScriptUrl, CallbackFunction) { makeHttpRequest (ScriptUrl, "GET", "", CallbackFunction, "makeHttpRequestFailed"); };
getStyle = function (Element, Property, CssProperty) { if (Element.currentStyle) return Element.currentStyle[Property]; if (window.getComputedStyle) return window.getComputedStyle(Element, "").getPropertyValue(CssProperty ? CssProperty : Property); return null; }