/* toolTip variables */
var tipAccMng = 'View your Mordel.Net Account Profile';
var tipAdmin = 'Perform all administrative functions';
var tipCalendar = 'View the Calendar for upcoming events';
var tipERS = 'Create an Electronic Request ticket on Mordel.Net';
var tipLogout = 'Click to logout of Mordel.Net';
var tipMessaging = 'Access your Mordel.Net Site Messaging Center';
var tipOpenBM = 'Load an existing design';
var tipPass = 'Your Mordel.Net Password';
var tipStore = 'Browse the Store and spend your Credits';
var tipUser = 'Your Mordel.Net Username';
/* Sets the color of a specified element */
function setColor(e,c)
{
document.getElementById(e).style.backgroundColor = c;
}
/* Sets the color of a specified element */
function setFont(e,fw)
{
document.getElementById(e).style.fontWeight = fw;
}
/* Clears the text of an element if equal to the supplied text */
function clrText(e,t)
{
if (e.value == t) e.value='';
}
/* Will switch the src image based on what image is currently visible */
function swapImg(e,i1,i2)
{
var curImg = e.src;
var arrI1 = i1.split("/");
var arrI2 = i2.split("/");
var arrImg = curImg.split("/");
if (arrImg[arrImg.length-1] == arrI1[arrI1.length-1])
e.src = i2;
else if (arrImg[arrImg.length-1] == arrI2[arrI2.length-1])
e.src = i1;
}
/* Update the auto login hidden variable */
function setAutologin()
{
document.getElementById('persistent').value = (document.getElementById('persistent').value==0)?1:0;
}
/* Find the Y position of an object */
function getYCoord(obj)
{
var curtop = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}
/* Find the X position of an object */
function getXCoord(obj)
{
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
}
/* Show a full news article and hide the blurb */
function setNewsDisplay(i,b,t)
{
document.getElementById('newsBlurb' + i).style.display = b;
document.getElementById('newsText' + i).style.display = t;
scrollTo(getXCoord(document.getElementById('newsTop' + i)),getYCoord(document.getElementById('newsTop' + i)));
}
/* This function returns the upperleft x,y coordinates of the specified image */
function imgXY(imgID)
{
var XY = new Object();
var imgObj = document.images[imgID];
if (imgObj)
{
if (document.layers) {
XY.x = eval(imgObj).x;
XY.y = eval(imgObj).y;
} else {
var x,y, tempEl;
x = eval(imgObj).offsetLeft;
y = eval(imgObj).offsetTop;
tempEl = eval(imgObj).offsetParent;
while (tempEl != null) {
x += tempEl.offsetLeft;
y += tempEl.offsetTop;
tempEl = tempEl.offsetParent;
}
XY.x = x;
XY.y = y;
}
}
return XY;
}
/* detect the coordinates of image named 'marker' and pass to showPermPanel to display menu panel 'Bar' */
/* If you have used different names, please change the two lines below accordingly */
function displayMenu()
{
var imgPosition = imgXY('menuAlign');
if (imgPosition.x)
{
if (navigator.userAgent.indexOf("MSIE")!=-1) imgPosition.y -= 5;
showPermPanelCentered('MENUBAR', imgPosition.x, imgPosition.y);
}
}
window.onresize = function() {displayMenu();}
function isInteger(s)
{
var i;
if (isEmpty(s))
if (isInteger.arguments.length == 1) return 0;
else return (isInteger.arguments[1] == true);
for (i = 0; i < s.length; i++)
{
var c = s.charAt(i);
if (!isDigit(c)) return false;
}
return true;
}
function isEmpty(s)
{
return ((s == null) || (s.length == 0))
}
function isDigit (c)
{
return ((c >= "0") && (c <= "9"))
}
/* Reload the page with the page passed in */
function paginationReload(max,args)
{
// get the value entered
var val = document.frmPagination.pageJump.value;
// Make sure the value entered is valid
if ((isInteger(val) == false) || (val > max) || (val < 1))
{
document.frmPagination.pageJump.value='';
alert('You have not entered a valid page number');
return False;
}
// replace placeholder with page number
strURL = args.replace("%s",val);
// Jump to the new page
window.location.href = strURL;
return True;
}
/* Trim an input field */
function trim(s)
{
// If it's already empty, just return the empty string
if (s==null) return s;
// Remove spaces from the left
while (s.substring(0,1) == ' ')
{
s = s.substring(1, s.length);
}
// Remove spaces from the right
while (s.substring(s.length-1, s.length) == ' ')
{
s = s.substring(0,s.length-1);
}
return s;
}
/* The function to create the spell check functionality */
function openSpellChecker( txt )
{
var speller = new spellChecker( txt );
speller.openChecker();
}
/* Make sure search criteria is entered */
function checkSearch(formObj)
{
if (trim(formObj.search.value)=='')
{
alert('You have not entered any search words!');
return false;
}
}
/* Set the style for buttons when the mouse is hovering over it */
function buttonActivate(objectId)
{
document.getElementById(objectId).style.cursor = 'pointer';
setColor(objectId, '#F0E1C2');
document.getElementById(objectId).style.borderColor = '#31319C';
}
/* Normalizes a button style to its default state */
function buttonNormalize(objectId)
{
document.getElementById(objectId).style.cursor = 'default';
setColor(objectId, '#BDBFC9');
document.getElementById(objectId).style.borderColor = '#000000';
}
/* Mark or Unmark a graphical checkbox by setting the value of the hidden input */
function simulateCheckbox(id)
{
// Get the currently selected value
var $selected = document.getElementById('inputCbx' + id).value;
// Let's do the swapping
if ($selected=="0")
document.getElementById('inputCbx' + id).value = "1"
else
document.getElementById('inputCbx' + id).value = "0"
}
/* Format a number with commas */
function addCommas(nStr)
{
nStr += '';
x = nStr.split('.');
x1 = x[0];
x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + ',' + '$2');
}
return x1 + x2;
}
/* Function to limit decimal places */
function limitDecimalPlaces(originalNumber, placesToLimitTo)
{
originalNumber = originalNumber.toString();
var decimalIndex = originalNumber.search(/\./);
//if there was a decimal point, then go from the start of the string
//to one more after the decimal index (because we want the decimal) plus
//the placesToLimitTo that was passed in
if (decimalIndex > -1)
{
var limitedToDecimal = originalNumber.substring(0, decimalIndex + 1 + placesToLimitTo);
for (var a=placesToLimitTo; a>(originalNumber.length - 1 - decimalIndex); a--) limitedToDecimal += '0';
}
else
{
var limitedToDecimal = originalNumber + '.';
for (var a=1; a<=placesToLimitTo; a++) limitedToDecimal += '0';
}
// remove trailing period if no decimals are wanted
if (placesToLimitTo == 0)
{
limitedToDecimal = limitedToDecimal.substr(0, limitedToDecimal.length-1);
}
return(limitedToDecimal);
}
/* Round a number to a certain number of decimals */
function roundNumber(num, dec)
{
var result = Math.round(num * Math.pow(10,dec)) / Math.pow(10,dec);
return result;
}
/* Created the indexOf method for arrays */
if (!Array.prototype.indexOf)
{
Array.prototype.indexOf = function(elt /*, from*/)
{
var len = this.length;
var from = Number(arguments[1]) || 0;
from = (from < 0) ? Math.ceil(from) : Math.floor(from);
if (from < 0)
from += len;
for (; from < len; from++)
{
if (from in this && this[from] === elt)
return from;
}
return -1;
};
}
/* Show the Review Comments Preview as it is being typed */
function showReviewCommentsPreview(obj)
{
// Get the keyword text entered
var strComments = obj.value;
// Hide the preview if the field is blank
if (strComments=='')
{
document.getElementById('tr_revCommentsPrev').style.display = 'none';
document.getElementById('span_revCommentsPrev').innerHTML = '';
}
// Otherwise show the preview
else
{
// Set the display property for showing based on browser
if(navigator.appName.indexOf("Microsoft") > -1)
var iDisplay = 'block'
else
var iDisplay = 'table-row';
// Replace all [Enter] symbols
strComments = strComments.replace(/\r|\n|\r\n/g, "
");
// Show the row
document.getElementById('tr_revCommentsPrev').style.display = iDisplay;
// Set the inner html with the text entered
document.getElementById('span_revCommentsPrev').innerHTML = strComments;
}
}
/* Disable autocomplete for fields in a way that validates in HTML */
function disableAutocomplete()
{
if (document.getElementsByTagName)
{
var inputElements = document.getElementsByTagName("input");
for (i=0; inputElements[i]; i++)
{
if (inputElements[i].className && (inputElements[i].className.indexOf("disableAutocomplete") != -1))
{
inputElements[i].setAttribute("autocomplete","off");
}//if current input element has the disableAutoComplete class set.
}//loop thru input elements
}//basic DOM-happiness-check
}
/* Used for browser detection, when needed (http://www.quirksmode.org/js/detect.html) */
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;i