function ReverseWords(sInput) {
var sOuput = "",
arrReversed = sInput.split(" ").reverse();
for (i=0; i < arrReversed.length; i++)
{
sOuput = sOuput + arrReversed[i];
if (i < arrReversed.length-1)
{
sOuput = sOuput + " ";
}
}
return sOuput;
}
function TrimCommonWordEndings(sWord) {
var sOutput = $.trim(sWord);
sOutput = TrimWordEnding(sOutput, "ies");
sOutput = TrimWordEnding(sOutput, "es");
sOutput = TrimWordEnding(sOutput, "s");
sOutput = TrimWordEnding(sOutput, "e");
sOutput = TrimWordEnding(sOutput, "y");
sOutput = TrimWordEnding(sOutput, "ing");
sOutput = TrimWordEnding(sOutput, "er");
return sOutput;
}
function TrimCommonWordEndingsArray(arrWords) {
for (var nWord = 0; nWord < arrWords.length; nWord++)
{ arrWords[nWord] = TrimCommonWordEndings(arrWords[nWord]); }
return arrWords;
}
function ArrayToText(arrText) {
var sOutput = "[ ";
for (var nIndex = 0; nIndex < arrText.length; nIndex++)
{ sOutput += arrText[nIndex] + " | "; }
sOutput += "]";
return sOutput;
}
function CountArrayMatches(arr1, arr2) {
var nMatches = 0;
for (var nIndex1 = 0; nIndex1 < arr1.length; nIndex1++)
{
for (var nIndex2 = 0; nIndex2 < arr2.length; nIndex2++)
{
if (arr1[nIndex1] == arr2[nIndex2])
{ nMatches++; }
}
}
return nMatches;
}
function CountArrayMatchesLength(arr1, arr2) {
var nMatchesLength = 0;
for (var nIndex1 = 0; nIndex1 < arr1.length; nIndex1++)
{
for (var nIndex2 = 0; nIndex2 < arr2.length; nIndex2++)
{
if (arr1[nIndex1] == arr2[nIndex2])
{ nMatchesLength += arr1[nIndex1].length; }
}
}
return nMatchesLength;
}
function GetArrayMatches(arr1, arr2) {
var sMatchingChars = "";
for (var nIndex1 = 0; nIndex1 < arr1.length; nIndex1++)
{
for (var nIndex2 = 0; nIndex2 < arr2.length; nIndex2++)
{
if (arr1[nIndex1] == arr2[nIndex2])
{ sMatchingChars += arr1[nIndex1]; }
}
}
return sMatchingChars;
}
function SubtractArray(arrToSubtractFrom, arrToSubtract) {
for (nItemToCheck = 0; nItemToCheck < arrToSubtractFrom.length; nItemToCheck++)
{
for (nItemToRemove = 0; nItemToRemove < arrToSubtract.length; nItemToRemove++)
{
if (arrToSubtractFrom[nItemToCheck] == arrToSubtract[nItemToRemove])
{
arrToSubtractFrom.splice(nItemToCheck, 1);
nItemToCheck--;
}
}
}
}
function TrimWordEnding(sWord, sEnding) {
var sOutput = $.trim(sWord);
if (sOutput.substring(sOutput.length-sEnding.length,sOutput.length).toLowerCase() == sEnding.toLowerCase())
{ sOutput = sOutput.substring(0,sOutput.length-sEnding.length); }
return sOutput;
}
function Carousel_initCallback(carousel) {
var vTimeOut;
// Disable autoscrolling if the user clicks the prev or next button.
carousel.buttonNext.bind('click', function() {
clearTimeout(vTimeOut);
carousel.stopAuto();
vTimeOut = setTimeout("carousel.startAuto(3);", 10000);
});
carousel.buttonPrev.bind('click', function() {
clearTimeout(vTimeOut);
carousel.stopAuto();
setTimeout("carousel.startAuto(3);", 10000);
});
// Pause autoscrolling if the user moves with the cursor over the clip.
carousel.clip.hover(function() {
carousel.stopAuto();
}, function() {
carousel.startAuto();
});
};
//|----------------------------------
//| Forms Functions
//|----------------------------------
function Forms_UpdateDateInput(sInputName, oForm) {
oHiddenDate = eval('oForm.' + sInputName);
oHiddenDateInt = eval('oForm.' + sInputName + '_Int');
oMonthSelect = eval('oForm.' + sInputName + '_Month');
oDaySelect = eval('oForm.' + sInputName + '_Day');
oYearSelect = eval('oForm.' + sInputName + '_Year');
oHiddenDate.value = oMonthSelect.value + '/' + oDaySelect.value + '/' + oYearSelect.value;
oHiddenDateInt.value = (oYearSelect.value * 10000) + (oMonthSelect.value * 100) + (oDaySelect.value * 1);
}
//|----------------------------------
//| Ads Functions
//|----------------------------------
function GenerateAdBox(sTitle, sImgFile, sBody, nAdID) {
var sAdBox = "
" +
"
";
if (sImgFile != "")
{
sAdBox += "
";
}
sAdBox += "
";
return sAdBox;
}
//|----------------------------------
//| DHTML Functions
//|----------------------------------
function ToggleObjectVisibility(objectId) {
var styleObject = GetStyleObject(objectId);
if (styleObject) {
if (styleObject.display == "block")
{ styleObject.display = "none"; }
else
{ styleObject.display = "block"; }
return true;
} else {
return false;
}
}
function ChangeObjectVisibility(objectId, newVisibility) {
var styleObject = GetStyleObject(objectId);
if (styleObject) {
styleObject.display = newVisibility;
return true;
} else {
return false;
}
}
function GetStyleObject(objectId) {
if(document.getElementById && document.getElementById(objectId)) {
return document.getElementById(objectId).style;
}
else if (document.all && document.all(objectId)) {
return document.all(objectId).style;
}
else if (document.layers && document.layers[objectId]) {
return document.layers[objectId];
} else {
return false;
}
}
function GetObject(objectId) {
if(document.getElementById && document.getElementById(objectId)) {
return document.getElementById(objectId);
}
else if (document.all && document.all(objectId)) {
return document.all(objectId);
}
else if (document.layers && document.layers[objectId]) {
return document.layers[objectId];
} else {
return false;
}
}
function initHighlight() {
if (!document.getElementsByTagName)
{ return; }
var arrInputFields = document.getElementsByTagName("input");
var arrTextAreas = document.getElementsByTagName("textarea");
for (var i=0; i' +
'
' +
'' +
sHTML +
'';
nImagePopupID = nImageID;
$("#ImagePagePopup").CenterAtTop();
}
);
}
}
function ShowGalleryPagePopup(event, nGalleryID) {
bHidingGalleryPagePopup = false;
nPadding = 20;
nDivWidth = 700;
if (nGalleryPopupID != nGalleryID)
{
oGalleryPagePopupDiv = GetObject("GalleryPagePopup");
oGalleryPagePopupDivStyle = GetStyleObject("GalleryPagePopup");
oGalleryPagePopupDivStyle.width = nDivWidth + "px";
oGalleryPagePopupDivStyle.height = "auto"
oGalleryPagePopupDiv.innerHTML = AjaxLoadingMessageWithSkipLink("Gallery.asp?GalleryID=" + nGalleryID);
PopupObject(event,"GalleryPagePopup");
$("#GalleryPagePopup").CenterAtTop();
$("#GalleryPagePopupMask").css("display", "block");
$("#GalleryPagePopupMask").Maximize();
$.get("Gallery_Preview.asp?GalleryID=" + nGalleryID,
function(sHTML)
{
oGalleryPagePopupDiv.innerHTML =
'';
nGalleryPopupID = nGalleryID;
$("#GalleryPagePopup").CenterAtTop();
}
);
}
}
function CenterOnScreen(sObjectName) {
bCenteringPopup = true;
oObjectToCenter = GetObject(sObjectName);
oObjectToCenterStyle = GetStyleObject(sObjectName);
nWidth = oObjectToCenter.offsetWidth;
nHeight = oObjectToCenter.offsetHeight;
var theBody = document.getElementsByTagName("BODY")[0];
var scTop = parseInt(getScrollTop(),10);
var scLeft = parseInt(theBody.scrollLeft,10);
var fullHeight = getViewportHeight();
var fullWidth = getViewportWidth();
oObjectToCenterStyle.top = (scTop + ((fullHeight - nHeight) / 2)) + "px";
oObjectToCenterStyle.left = (scLeft + ((fullWidth - nWidth) / 2)) + "px";
bCenteringPopup = false;
}
function AjaxLoadingMessageWithSkipLink(sSkipToURL) {
return "

" +
"Loading, please wait...
";
}
function AjaxLoadingMessage() {
return "
Loading...";
}
function AjaxSavingMessage() {
return "
Saving...";
}
function UserLinkFastCustom(sDisplayName, sStyle, sClassNames, nUserAccountLevel, nMaxDisplayChars) {
var sOutput = '' + LimitLength(FixDisplayNameURL(sDisplayName), nMaxDisplayChars) + "";
return sOutput;
}
function GetGalleryRootURL(sDisplayName) {
var sOutput = "";
if (sDisplayName != "")
{ sOutput = "http://www.CreativeBicycles.org/" + FixDisplayNameURL(sDisplayName); }
return sOutput;
}
function FixDisplayNameURL(sDisplayName) {
var sOutput = FixFileName(sDisplayName).replace("_", "");
return sOutput;
}
function ShowThumbNailPopup(event, sLinkURL, sThmFileURL, nThmWidth, nThmHeight) {
bHidingThumbNailPopup = false;
if (sPopupThmFileURL != sThmFileURL)
{
oThumbNailPopupDiv = GetObject("ThumbNailPopup");
oThumbNailPopupDivStyle = GetStyleObject("ThumbNailPopup");
oThumbNailPopupDivStyle.width = nThmWidth + "px";
oThumbNailPopupDivStyle.height = nThmHeight + "px";
oThumbNailPopupDiv.innerHTML = '
"';
sPopupThmFileURL = sThmFileURL;
PopupObject(event,"ThumbNailPopup");
}
}
function HideAllPopups() {
HideThumbNailPopup();
HideGalleryPagePopup();
HideImagePagePopup();
hidePopWin(false);
$(".PopupMask").hide();
}
function HideTopPopup() {
if ($("#ImagePagePopup").css("display") == "block")
{ HideImagePagePopup(); }
else if ($("#GalleryPagePopup").css("display") == "block")
{ HideGalleryPagePopup(); }
else
{ hidePopWin(false); }
}
function HideThumbNailPopup() {
bHidingThumbNailPopup = true;
setTimeout("if (bHidingThumbNailPopup) { ChangeObjectVisibility('ThumbNailPopup', 'none'); bHidingThumbNailPopup = false; sPopupThmFileURL = ''; }",100);
}
function HideGalleryPagePopup() {
$("#GalleryPagePopup").css("display", "none");
$("#GalleryPagePopupMask").css("display", "none");
nGalleryPopupID = 0;
}
function HideImagePagePopup() {
$("#ImagePagePopup").css("display", "none");
$("#ImagePagePopupMask").css("display", "none");
nImagePopupID = 0;
}
//|----------------------------------
//| Form Handling Functions
//|----------------------------------
function CheckTextArea(oTextArea, nMaxLength, sCharsLeftDiv) {
if (oTextArea.value.length > nMaxLength)
{
oTextArea.value = oTextArea.value.substring(0,nMaxLength);
alert('You have reached the maximum character limit.');
}
var CharsLeft = GetObject(sCharsLeftDiv);
if (CharsLeft)
{ CharsLeft.innerHTML = '(' + nMaxLength + ' characters maximum. ' + (nMaxLength-oTextArea.value.length) + ' characters left.'; }
}
function getCheckedValue(radioObj) {
if(!radioObj)
return "";
var radioLength = radioObj.length;
if(radioLength == undefined)
if(radioObj.checked)
return radioObj.value;
else
return "";
for(var i = 0; i < radioLength; i++) {
if(radioObj[i].checked) {
return radioObj[i].value;
}
}
return "";
}
function setCheckedValue(radioObj, newValue) {
if(!radioObj)
return;
var radioLength = radioObj.length;
if(radioLength == undefined) {
radioObj.checked = (radioObj.value == newValue.toString());
return;
}
for(var i = 0; i < radioLength; i++) {
radioObj[i].checked = false;
if(radioObj[i].value == newValue.toString()) {
radioObj[i].checked = true;
}
}
}
//|----------------------------------
//| Location Handling Functions
//|----------------------------------
function GetAnchor() {
var sAnchorName = "",
nPoundPos = window.location.href.lastIndexOf("#");
if (nPoundPos > 10)
{ sAnchorName = window.location.href.substring(nPoundPos+1, window.location.href.length); }
return sAnchorName;
}
function SetAnchor(sAnchorName) {
var sBaseURL = window.location.href;
nPoundPos = sBaseURL.lastIndexOf("#");
if (nPoundPos > 10)
{ sBaseURL = sBaseURL.substring(0, nPoundPos); }
window.location.href = sBaseURL + "#" + sAnchorName;
}
//|----------------------------------
//| Window Handling Functions
//|----------------------------------
function WindowReload(returnVal) {
window.document.reload();
}
function getViewportHeight() {
if (window.innerHeight!=window.undefined) return window.innerHeight;
if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
if (document.body) return document.body.clientHeight;
return window.undefined;
}
function getViewportWidth() {
var offset = 17;
var width = null;
if (window.innerWidth!=window.undefined) return window.innerWidth;
if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth;
if (document.body) return document.body.clientWidth;
}
function getScrollTop() {
if (self.pageYOffset) // all except Explorer
{
return self.pageYOffset;
}
else if (document.documentElement && document.documentElement.scrollTop)
// Explorer 6 Strict
{
return document.documentElement.scrollTop;
}
else if (document.body) // all other Explorers
{
return document.body.scrollTop;
}
}
function getScrollLeft() {
if (self.pageXOffset) // all except Explorer
{
return self.pageXOffset;
}
else if (document.documentElement && document.documentElement.scrollLeft)
// Explorer 6 Strict
{
return document.documentElement.scrollLeft;
}
else if (document.body) // all other Explorers
{
return document.body.scrollLeft;
}
}
function LaunchLink(sLink) {
this.open(Unscramble(sLink), "Win" + Math.floor(Math.random()*10000), "toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes,status=yes");
}
function BrowseToLink(sLink) {
var sUnscrambled = Unscramble(sLink);
window.status = "~" + sUnscrambled;
window.location.href = sUnscrambled;
window.status = "-" + window.location;
}
//|----------------------------------
//| AJAX Functions
//|----------------------------------
function GetXmlHttpObject() {
var xmlHttp=null;
try
{ xmlHttp=new XMLHttpRequest(); } // Firefox, Opera 8.0+, Safari
catch (e)
{
try
{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } // Internet Explorer
catch (e)
{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
}
return xmlHttp;
}
function TransformToOutput(sTemplateContainerID, sDataURL, sOutputContainerID) {
$.get(sDataURL,
function(sDataSet)
{
$("#" + sOutputContainerID)
.html(
TransformTemplate
(
$("#" + sTemplateContainerID).html(),
sDataSet
)
);
}
);
}
function TransformTemplate(sTemplate, sSlimData) {
return TransformTemplateAdv(sTemplate, sSlimData, ".-$$", "$$-.");
}
function TransformTemplateAdv(sTemplate, sSlimData, sIdentifierPrefix, sIdentifierSuffix) {
var sOutput;
sOutput = "";
sRowSeparator = sSlimData.substring(0,1);
sColumnSeparator = sSlimData.substring(1,2);
debug("data = " + sSlimData);
arrRows = sSlimData.substring(2,sSlimData.length).split(sRowSeparator);
if (arrRows.length > 1)
{
arrColumnNames = arrRows[0].split(sColumnSeparator);
for (nRowIndex = 1; nRowIndex < arrRows.length; nRowIndex++)
{
sSection = sTemplate;
sRowData = arrRows[nRowIndex];
arrRowData = sRowData.split(sColumnSeparator);
for (nColumnIndex = 0; nColumnIndex < arrColumnNames.length; nColumnIndex++)
{
sColumnName = arrColumnNames[nColumnIndex];
sIdentifier = sIdentifierPrefix + sColumnName.toLowerCase() + sIdentifierSuffix;
while ( sSection.indexOf(sIdentifier) >= 0 )
{ sSection = sSection.replace(sIdentifier, arrRowData[nColumnIndex]); }
}
if (!((sSection.indexOf(sIdentifierPrefix) >= 0) || (sSection.indexOf(sIdentifierSuffix) >= 0)))
{ sOutput = sOutput + sSection; }
else
{ debug("BAD SECTION: " + sSection ); }
}
}
return sOutput;
}
//|----------------------------------
//| String Formatting Functions
//|----------------------------------
function LimitLength(sInput, nMaxLength) {
var sOutput = "";
//sOutput = Trim(sInput);
sOutput = GetStr(sInput);
if (sOutput.length > nMaxLength)
{
if (nMaxLength > 3)
{ sOutput = Trim(sOutput.substring(0, nMaxLength - 3)) + "..."; }
else
{ sOutput = Trim(sOutput.substring(0, nMaxLength)); }
}
return sOutput;
}
function URLEncode(str) {
str = escape(str);
str = str.replace('+', '%2B');
str = str.replace('%20', '+');
str = str.replace('*', '%2A');
str = str.replace('/', '%2F');
str = str.replace('@', '%40');
return str;
}
function URLDecode(str) {
str = str.replace('+', ' ');
str = unescape(str);
return str;
}
function FilterString_ValidCharsOnly(sInput, sValidChars) {
var sChar, sOutput;
sOutput = "";
for (nChar = 0; nChar < sInput.length; nChar++)
{
sChar = sInput.charAt(nChar);
if (sValidChars.indexOf(sChar) >= 0)
{sOutput = sOutput + sChar;}
}
return sOutput;
}
function FilterString_ValidCharsOnly_WithGapChar(sInput, sValidChars, sGapChar) {
var sChar, sOutput;
sOutput = "";
for (nChar = 0; nChar < sInput.length; nChar++)
{
sChar = sInput.charAt(nChar);
if (sValidChars.indexOf(sChar) >= 0)
{sOutput = sOutput + sChar;}
else
{sOutput = sOutput + sGapChar;}
}
while (sOutput.indexOf(sGapChar + sGapChar) >= 0)
{ sOutput = ReplaceAll(sOutput, sGapChar + sGapChar, sGapChar); }
return sOutput;
}
function ReplaceAll(sStringToSearch, sStringToFind, sReplaceWith) {
var sOutput;
sOutput = sStringToSearch.replace(eval("/" + sStringToFind + "/gi"), sReplaceWith);
return( sOutput );
}
function PadString(sStringToPad, nLength, sPadChars, bPadOnLeft) {
var sOutput = "";
sOutput = sStringToPad;
while (sOutput.length < nLength)
{
if (bPadOnLeft)
{ sOutput = sPadChars + sOutput; }
else
{ sOutput = sOutput + sPadChars; }
}
return sOutput;
}
function USW(sScrambled) {
document.write(Unscramble(sScrambled));
}
function Unscramble(sScrambled) {
var sUnscrambled = "";
for (var i=0; i" + Unscramble(sScrambledEmail) + "");
}
function FixFileName(sFileName) {
var sOutput, sValidChars;
sValidChars = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-."
sOutput = ReplaceAll(sFileName, "&", "and");
sOutput = FilterString_ValidCharsOnly_WithGapChar(sOutput, sValidChars, "_");
while (sOutput.indexOf("--") >= 0) { sOutput = ReplaceAll(sOutput, "--", "-"); }
while (sOutput.indexOf("..") >= 0) { sOutput = ReplaceAll(sOutput, "..", "."); }
return sOutput;
}
function EscapeHTML(sInput) {
var sOutput = "";
sOutput = sInput.toString();
sOutput = ReplaceAll(sOutput, "&", "&");
sOutput = ReplaceAll(sOutput, "<", "<");
sOutput = ReplaceAll(sOutput, ">", ">");
sOutput = ReplaceAll(sOutput, "\"", """);
sOutput = ReplaceAll(sOutput, "'", "'");
return sOutput;
}
function GetFullSizePath(sImgFile) {
var sOutput = "";
nImgID = GetImageID(sImgFile);
sThousand = (Math.floor(nImgID/1000)*1000).toString();
sOutput = "/Images/FullSize/" + PadString(sThousand, 9, "0", true) + "/";
return sOutput;
}
function GetThumbNailPath(sThmFile) {
var sOutput = "";
nThmID = GetImageID(sThmFile);
sThousand = (Math.floor(nThmID/1000)*1000).toString();
sOutput = "/Images/ThumbNails/" + PadString(sThousand, 9, "0", true) + "/";
return sOutput;
}
function GetImageID(sImageFile) {
var nImageID = 0;
n_Pos = sImageFile.indexOf("_");
if ( n_Pos >= 4 )
{
if ((sImageFile.substring(0,3).toLowerCase() == "thm") || (sImageFile.substring(0,3).toLowerCase() == "img"))
{ nImageID = GetInt(sImageFile.substring(3, n_Pos)); }
}
return nImageID;
}
//|----------------------------------
//| String Trimming
//|--------------------------------
function Trim(sInput) {
var sOutput, sCharactersToTrim;
sCharactersToTrim = " "
sOutput = TrimChars(sInput, sCharactersToTrim);
return sOutput;
}
function TrimChars(sInput, sCharactersToTrim) {
var sOutput;
sOutput = TrimCharsRight(TrimCharsLeft(sInput, sCharactersToTrim), sCharactersToTrim);
return sOutput;
}
function TrimCharsLeft(sInput, sCharactersToTrim) {
var sOutput;
sOutput = "";
if (sInput.length > 0)
{
sOutput = GetStr(sInput);
while (sCharactersToTrim.indexOf(sOutput.substring(0,1)) >= 0)
{ alert(sOutput); sOutput = sOutput.substring(1); }
}
return sOutput;
}
function TrimCharsRight(sInput, sCharactersToTrim) {
var sOutput;
sOutput = "";
if (sInput.length > 0)
{
sOutput = GetStr(sInput);
while (sCharactersToTrim.indexOf(sOutput.substring(sOutput.length-2,sOutput.length-1)) >= 0)
{ sOutput = sOutput.substring(0,sOutput.length-2); }
}
return sOutput;
}
function TrimString(sInput, sStringToTrim) {
var sOutput;
sOutput = TrimStringRight(TrimStringLeft(sInput, sStringToTrim), sStringToTrim);
return sOutput;
}
function TrimStringLeft(sInput, sStringToTrim) {
var sOutput;
sOutput = GetStr(sInput);
while ( sOutput.substring(0,sStringToTrim.length).toLowerCase() == sStringToTrim.toLowerCase() )
{ sOutput = sOutput.substring(sStringToTrim.length); }
return sOutput;
}
function TrimStringRight(sInput, sStringToTrim) {
var sOutput;
sOutput = GetStr(sInput);
while ( sOutput.substring(sOutput.length-sStringToTrim.length-1,sOutput.length-1).toLowerCase() == sStringToTrim.toLowerCase() )
{ sOutput = sOutput.substring(0, sOutput.length-sStringToTrim.length-1); }
return sOutput;
}
//|---------------------------------------------------------------------------
//| Type Conversion Functions
//|---------------------------------------------------------------------------
function GetNumeric(vInput) {
var nOutput = 0;
if (!isNaN(vInput))
{
try { nOutput = parseFloat(vInput); }
catch (e) { nOutput = 0; }
}
return nOutput;
}
function GetStr(vInput) {
var sOutput = "";
try { sOutput = vInput.toString(); }
catch (e) { sOutput = ""; }
return sOutput;
}
function GetInt(vInput) {
var nOutput = 0;
if (!isNaN(vInput))
{
try { nOutput = parseInt(vInput); }
catch (e) { nOutput = 0; }
}
return nOutput;
}
function GetBit(vInput) {
var nOutput;
nOutput = GetInt(vInput);
if (nOutput > 0) { nOutput = 1; }
return nOutput;
}
//|---------------------------------------------------------------------------
//| Numeric & Math Functions
//|---------------------------------------------------------------------------
function GreaterOf(nInput1, nInput2) {
if (GetNumeric(nInput1) > GetNumeric(nInput2))
{ return nInput1; }
else
{ return nInput2; }
}
function LesserOf(nInput1, nInput2) {
if (GetNumeric(nInput1) < GetNumeric(nInput2))
{ return nInput1; }
else
{ return nInput2; }
}
function LimitTo(nInput, nMin, nMax) {
return LesserOf(GreaterOf(nInput, nMin), nMax);
}
//|----------------------------------
//| Event Handling Functions
//|----------------------------------
function addEvent(oObject, sEventType, oListenerFunction) {
if (oObject.addEventListener)
{
oObject.addEventListener(sEventType, oListenerFunction, false);
return true;
}
else if (oObject.attachEvent)
{
var r = oObject.attachEvent("on"+sEventType, oListenerFunction);
return r;
}
else
{ return false; }
}
function removeEvent(oObject, sEventType, oListenerFunction, useCapture) {
if (oObject.removeEventListener)
{
oObject.removeEventListener(sEventType, oListenerFunction, useCapture);
return true;
}
else if (oObject.detachEvent)
{
var r = oObject.detachEvent("on" + sEventType, oListenerFunction);
return r;
}
}
function addEventWithCache( oObject, sEventType, oListenerFunction ) {
if (oObject.addEventListener)
{
oObject.addEventListener( sEventType, oListenerFunction, false );
EventCache.add(oObject, sEventType, oListenerFunction);
}
else if (oObject.attachEvent)
{
oObject["e" + sEventType + oListenerFunction] = oListenerFunction;
oObject[sEventType + oListenerFunction] = function() { oObject["e" + sEventType + oListenerFunction]( window.event ); }
oObject.attachEvent( "on" + sEventType, oObject[sEventType + oListenerFunction] );
EventCache.add(oObject, sEventType, oListenerFunction);
}
else
{
oObject["on" + sEventType] = oObject["e" + sEventType + oListenerFunction];
}
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function'){
window.onload = func;
} else {
window.onload = function(){
oldonload();
func();
}
}
}
//|----------------------------------
//| Utility functions
//|----------------------------------
function debug(sOutput) {
$("#DebugOutput").html($("#DebugOutput").html() + "
" + sOutput);
}
function kp(e) {
var kC = (window.event)?event.keyCode:e.keyCode;
var Esc = (window.event)?27:e.DOM_VK_ESCAPE;
if(kC==Esc)
{ HideTopPopup(); }
}
//|----------------------------------
//| Global Page Init
//|----------------------------------
addLoadEvent(initHighlight);
var EventCache = function(){
var listEvents = [];
return {
listEvents : listEvents,
add : function(node, sEventName, fHandler){
listEvents.push(arguments);
},
flush : function(){
var i, item;
for(i = listEvents.length - 1; i >= 0; i = i - 1){
item = listEvents[i];
if(item[0].removeEventListener){
item[0].removeEventListener(item[1], item[2], item[3]);
};
if(item[1].substring(0, 2) != "on"){
item[1] = "on" + item[1];
};
if(item[0].detachEvent){
item[0].detachEvent(item[1], item[2]);
};
item[0][item[1]] = null;
};
}
};
}();
addEventWithCache(window,'unload',EventCache.flush);
bCenteringPopup = false;
bHidingThumbNailPopup = false;
bHidingGalleryPagePopup = false;
bHidingImagePagePopup = false;
sPopupThmFileURL = "";
nGalleryPopupID = 0;
nImagePopupID = 0;