//////////////////////
// Global Variables //
//////////////////////
var domain = 'sbdcdaytona.com';
////////////////////////////////
// Include other script files //
////////////////////////////////
// LoadJSFile and LoadCSSFile
// John's LoadJSFile and LoadCSSFile Functions
// These need to be separate from the rest of scripts.js.cfm so they can be loaded individually if necessary.
// Dynamically loads a javascript file.
function loadJSFile(jsrc) {
var allscr = document.getElementsByTagName("script");
var cbtest = (arguments.length > 1) ? arguments[1] : "";
var cbfunc = (arguments.length > 2 && typeof arguments[2] == "function") ? arguments[2] : "";
var cbeval = "";
var isdupe = 0;
var isload = 0;
for(var s = 0; s < allscr.length; s++) {
if(allscr[s].src == jsrc) {
isdupe = 1;
break;
}
}
if(cbtest != "") {
if(eval(cbtest) == true) {
isload = 1;
}
}
if(isdupe == 0 && isload == 0) {
var scrtag = document.createElement("script");
scrtag.setAttribute("type","text/javascript");
scrtag.setAttribute("language","Javascript");
scrtag.setAttribute("src",jsrc);
if(typeof scrtag != "undefined") document.getElementsByTagName("head")[0].appendChild(scrtag);
}
if(typeof cbfunc == "function") {
if(cbtest != "") {
cbeval = function() {
if(eval(cbtest) == true) {
cbfunc();
} else {
setTimeout(function() { cbeval(); },150);
}
}
setTimeout(function() { cbeval(); },150);
} else {
cbfunc();
}
}
}
// Dynamically loads a stylesheet.
function loadCSSFile(csrc) {
var stytag = document.createElement("link");
var allsty = document.getElementsByTagName("link");
for(var c = 0; c < allsty.length; c++) {
if(allsty[c].rel == "stylesheet" && allsty[c].href && allsty[c].href == csrc) return true;
}
stytag.setAttribute("rel","stylesheet");
stytag.setAttribute("type","text/css");
stytag.setAttribute("media","screen");
stytag.setAttribute("href",csrc);
if(typeof stytag != "undefined") document.getElementsByTagName("head")[0].appendChild(stytag);
}
// WDDX Scripts
///////////////////////////////////////////////////////////////////////////
// serializeValue() serializes any value that can be serialized
// returns true/false
function wddxSerializer_serializeValue(obj) {
var bSuccess = true;
var val;
if (obj == null)
{
// Null value
this.write("");
}
else if (typeof(val = obj.valueOf()) == "string")
{
// String value
this.serializeString(val);
}
else if (typeof(val = obj.valueOf()) == "number")
{
// Distinguish between numbers and date-time values
if (
typeof(obj.getTimezoneOffset) == "function" &&
typeof(obj.toGMTString) == "function")
{
// Possible Date
// Note: getYear() fix is from David Flanagan's
// "JS: The Definitive Guide". This code is Y2K safe.
this.write("" +
(obj.getYear() < 1000 ? 1900+obj.getYear() : obj.getYear()) + "-" + (obj.getMonth() + 1) + "-" + obj.getDate() +
"T" + obj.getHours() + ":" + obj.getMinutes() + ":" + obj.getSeconds());
if (this.useTimezoneInfo)
{
this.write(this.timezoneString);
}
this.write("");
}
else
{
// Number value
this.write("" + val + "");
}
}
else if (typeof(val = obj.valueOf()) == "boolean")
{
// Boolean value
this.write("");
}
else if (typeof(obj) == "object")
{
if (typeof(obj.wddxSerialize) == "function")
{
// Object knows how to serialize itself
bSuccess = obj.wddxSerialize(this);
}
else if (
typeof(obj.join) == "function" &&
typeof(obj.reverse) == "function" &&
typeof(obj.sort) == "function" &&
typeof(obj.length) == "number")
{
// Possible Array
this.write("");
for (var i = 0; bSuccess && i < obj.length; ++i)
{
bSuccess = this.serializeValue(obj[i]);
}
this.write("");
}
else
{
// Some generic object; treat it as a structure
// Use the wddxSerializationType property as a guide as to its type
if (typeof(obj.wddxSerializationType) == 'string')
{
this.write('')
}
else
{
this.write("");
}
for (var prop in obj)
{
if (prop != 'wddxSerializationType')
{
bSuccess = this.serializeVariable(prop, obj[prop]);
if (! bSuccess)
{
break;
}
}
}
this.write("");
}
}
else
{
// Error: undefined values or functions
bSuccess = false;
}
// Successful serialization
return bSuccess;
}
///////////////////////////////////////////////////////////////////////////
// serializeAttr() serializes an attribute (such as a var tag) using JavaScript
// functionality available in NS 3.0 and above
function wddxSerializer_serializeAttr(s) {
for (var i = 0; i < s.length; ++i)
{
this.write(this.at[s.charAt(i)]);
}
}
///////////////////////////////////////////////////////////////////////////
// serializeAttrOld() serializes a string using JavaScript functionality
// available in IE 3.0. We don't support special characters for IE3, so
// just throw the unencoded text and hope for the best
function wddxSerializer_serializeAttrOld(s) {
this.write(s);
}
///////////////////////////////////////////////////////////////////////////
// serializeString() serializes a string using JavaScript functionality
// available in NS 3.0 and above
function wddxSerializer_serializeString(s) {
this.write("");
for (var i = 0; i < s.length; ++i)
{
if (s.charCodeAt(i) > 255)
this.write(s.charAt(i));
else
this.write(this.et[s.charAt(i)]);
}
this.write("");
}
///////////////////////////////////////////////////////////////////////////
// serializeStringOld() serializes a string using JavaScript functionality
// available in IE 3.0
function wddxSerializer_serializeStringOld(s) {
this.write("");
if (pos != -1)
{
startPos = 0;
while (pos != -1)
{
this.write(s.substring(startPos, pos) + "]]>]]>", startPos);
}
else
{
// Work around bug in indexOf()
// "" will be returned instead of -1 if startPos > length
pos = -1;
}
}
this.write(s.substring(startPos, s.length));
}
else
{
this.write(s);
}
this.write("]]>");
}
///////////////////////////////////////////////////////////////////////////
// serializeVariable() serializes a property of a structure
// returns true/false
function wddxSerializer_serializeVariable(name, obj) {
var bSuccess = true;
if (typeof(obj) != "function")
{
this.write("");
bSuccess = this.serializeValue(obj);
this.write("");
}
return bSuccess;
}
///////////////////////////////////////////////////////////////////////////
// write() appends text to the wddxPacket buffer
function wddxSerializer_write(str) {
this.wddxPacket[this.wddxPacket.length] = str;
}
///////////////////////////////////////////////////////////////////////////
// writeOld() appends text to the wddxPacket buffer using IE 3.0 (JS 1.0)
// functionality. Unfortunately, the += operator has quadratic complexity
// which will cause slowdowns for large packets.
function wddxSerializer_writeOld(str) {
this.wddxPacket += str;
}
///////////////////////////////////////////////////////////////////////////
// initPacket() initializes the WDDX packet
function wddxSerializer_initPacket() {
this.wddxPacket = new Array();
}
///////////////////////////////////////////////////////////////////////////
// initPacketOld() initializes the WDDX packet for use with IE 3.0 (JS 1.0)
function wddxSerializer_initPacketOld() {
this.wddxPacket = "";
}
///////////////////////////////////////////////////////////////////////////
// extractPacket() extracts the WDDX packet as a string
function wddxSerializer_extractPacket() {
return this.wddxPacket.join("");
}
///////////////////////////////////////////////////////////////////////////
// extractPacketOld() extracts the WDDX packet as a string (IE 3.0/JS 1.0)
function wddxSerializer_extractPacketOld() {
return this.wddxPacket;
}
///////////////////////////////////////////////////////////////////////////
// serialize() creates a WDDX packet for a given object
// returns the packet on success or null on failure
function wddxSerializer_serialize(rootObj) {
this.initPacket();
this.write("");
var bSuccess = this.serializeValue(rootObj);
this.write("");
if (bSuccess)
{
return this.extractPacket();
}
else
{
return null;
}
}
///////////////////////////////////////////////////////////////////////////
// WddxSerializer() binds the function properties of the object
function WddxSerializer() {
// Compatibility section
if (navigator.appVersion != "" && navigator.appVersion.indexOf("MSIE 3.") == -1)
{
// Character encoding table
// Encoding table for strings (CDATA)
var et = new Array();
// Numbers to characters table and
// characters to numbers table
var n2c = new Array();
var c2n = new Array();
// Encoding table for attributes (i.e. var=str)
var at = new Array();
for (var i = 0; i < 256; ++i)
{
// Build a character from octal code
var d1 = Math.floor(i/64);
var d2 = Math.floor((i%64)/8);
var d3 = i%8;
var c = eval("\"\\" + d1.toString(10) + d2.toString(10) + d3.toString(10) + "\"");
// Modify character-code conversion tables
n2c[i] = c;
c2n[c] = i;
// Modify encoding table
if (i < 32 && i != 9 && i != 10 && i != 13)
{
// Control characters that are not tabs, newlines, and carriage returns
// Create a two-character hex code representation
var hex = i.toString(16);
if (hex.length == 1)
{
hex = "0" + hex;
}
et[n2c[i]] = "";
// strip control chars from inside attrs
at[n2c[i]] = "";
}
else if (i < 128)
{
// Low characters that are not special control characters
et[n2c[i]] = n2c[i];
// attr table
at[n2c[i]] = n2c[i];
}
else
{
// High characters
et[n2c[i]] = "" + i.toString(16) + ";";
at[n2c[i]] = "" + i.toString(16) + ";";
}
}
// Special escapes for CDATA encoding
et["<"] = "<";
et[">"] = ">";
et["&"] = "&";
// Special escapes for attr encoding
at["<"] = "<";
at[">"] = ">";
at["&"] = "&";
at["'"] = "'";
at["\""] = """;
// Store tables
this.n2c = n2c;
this.c2n = c2n;
this.et = et;
this.at = at;
// The browser is not MSIE 3.x
this.serializeString = wddxSerializer_serializeString;
this.serializeAttr = wddxSerializer_serializeAttr;
this.write = wddxSerializer_write;
this.initPacket = wddxSerializer_initPacket;
this.extractPacket = wddxSerializer_extractPacket;
}
else
{
// The browser is most likely MSIE 3.x, it is NS 2.0 compatible
this.serializeString = wddxSerializer_serializeStringOld;
this.serializeAttr = wddxSerializer_serializeAttrOld;
this.write = wddxSerializer_writeOld;
this.initPacket = wddxSerializer_initPacketOld;
this.extractPacket = wddxSerializer_extractPacketOld;
}
// Setup timezone information
var tzOffset = (new Date()).getTimezoneOffset();
// Invert timezone offset to convert local time to UTC time
if (tzOffset >= 0)
{
this.timezoneString = '-';
}
else
{
this.timezoneString = '+';
}
this.timezoneString += Math.floor(Math.abs(tzOffset) / 60) + ":" + (Math.abs(tzOffset) % 60);
// Common properties
this.preserveVarCase = false;
this.useTimezoneInfo = true;
// Common functions
this.serialize = wddxSerializer_serialize;
this.serializeValue = wddxSerializer_serializeValue;
this.serializeVariable = wddxSerializer_serializeVariable;
}
///////////////////////////////////////////////////////////////////////////
//
// WddxRecordset
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// isColumn(name) returns true/false based on whether this is a column name
function wddxRecordset_isColumn(name) {
// Columns must be objects
// WddxRecordset extensions might use properties prefixed with
// _private_ and these will not be treated as columns
return (typeof(this[name]) == "object" &&
name.indexOf("_private_") == -1);
}
///////////////////////////////////////////////////////////////////////////
// getRowCount() returns the number of rows in the recordset
function wddxRecordset_getRowCount() {
var nRowCount = 0;
for (var col in this)
{
if (this.isColumn(col))
{
nRowCount = this[col].length;
break;
}
}
return nRowCount;
}
///////////////////////////////////////////////////////////////////////////
// getColumnList() returns the column names in the wddx packet
function wddxRecordset_getColumnList() {
var columnList = '';
for (var col in this) {
if (this.isColumn(col)) {
if (columnList == '') {
columnList = col;
} else {
columnList = columnList + ',' + col;
}
}
}
return columnList;
}
///////////////////////////////////////////////////////////////////////////
// addColumn(name) adds a column with that name and length == getRowCount()
function wddxRecordset_addColumn(name) {
var nLen = this.getRowCount();
var colValue = new Array(nLen);
for (var i = 0; i < nLen; ++i) {
colValue[i] = null;
}
this[this.preserveFieldCase ? name : name.toLowerCase()] = colValue;
}
///////////////////////////////////////////////////////////////////////////
// addRows() adds n rows to all columns of the recordset
function wddxRecordset_addRows(n) {
for (var col in this)
{
if (this.isColumn(col))
{
var nLen = this[col].length;
for (var i = nLen; i < nLen + n; ++i)
{
this[col][i] = null;
}
}
}
}
///////////////////////////////////////////////////////////////////////////
// getField() returns the element in a given (row, col) position
function wddxRecordset_getField(row, col) {
return this[this.preserveFieldCase ? col : col.toLowerCase()][row];
}
///////////////////////////////////////////////////////////////////////////
// setField() sets the element in a given (row, col) position to value
function wddxRecordset_setField(row, col, value) {
this[this.preserveFieldCase ? col : col.toLowerCase()][row] = value;
}
///////////////////////////////////////////////////////////////////////////
// wddxSerialize() serializes a recordset
// returns true/false
function wddxRecordset_wddxSerialize(serializer) {
// Create an array and a list of column names
var colNamesList = "";
var colNames = new Array();
var i = 0;
for (var col in this)
{
if (this.isColumn(col))
{
colNames[i++] = col;
if (colNamesList.length > 0)
{
colNamesList += ",";
}
colNamesList += col;
}
}
var nRows = this.getRowCount();
serializer.write("");
var bSuccess = true;
for (i = 0; bSuccess && i < colNames.length; i++)
{
var name = colNames[i];
serializer.write("");
for (var row = 0; bSuccess && row < nRows; row++)
{
bSuccess = serializer.serializeValue(this[name][row]);
}
serializer.write("");
}
serializer.write("");
return bSuccess;
}
///////////////////////////////////////////////////////////////////////////
// dump(escapeStrings) returns an HTML table with the recordset data
// It is a convenient routine for debugging and testing recordsets
// The boolean parameter escapeStrings determines whether the <>&
// characters in string values are escaped as <>&
function wddxRecordset_dump(escapeStrings) {
// Get row count
var nRows = this.getRowCount();
// Determine column names
var colNames = new Array();
var i = 0;
for (var col in this)
{
if (typeof(this[col]) == "object")
{
colNames[i++] = col;
}
}
// Build table headers
var o = "
RowNumber
";
for (i = 0; i < colNames.length; ++i)
{
o += "
" + colNames[i] + "
";
}
o += "
";
// Build data cells
for (var row = 0; row < nRows; ++row)
{
o += "
" + row + "
";
for (i = 0; i < colNames.length; ++i)
{
var elem = this.getField(row, colNames[i]);
if (escapeStrings && typeof(elem) == "string")
{
var str = "";
for (var j = 0; j < elem.length; ++j)
{
var ch = elem.charAt(j);
if (ch == '<')
{
str += "<";
}
else if (ch == '>')
{
str += ">";
}
else if (ch == '&')
{
str += "&";
}
else
{
str += ch;
}
}
o += ("
" + str + "
");
}
else
{
o += ("
" + elem + "
");
}
}
o += "
";
}
// Close table
o += "
";
// Return HTML recordset dump
return o;
}
///////////////////////////////////////////////////////////////////////////
// WddxRecordset([flagPreserveFieldCase]) creates an empty recordset.
// WddxRecordset(columns [, flagPreserveFieldCase]) creates a recordset
// with a given set of columns provided as an array of strings.
// WddxRecordset(columns, rows [, flagPreserveFieldCase]) creates a
// recordset with these columns and some number of rows.
// In all cases, flagPreserveFieldCase determines whether the exact case
// of field names is preserved. If omitted, the default value is false
// which means that all field names will be lowercased.
function WddxRecordset() {
// Add default properties
this.preserveFieldCase = false;
// Add extensions
if (typeof(wddxRecordsetExtensions) == "object")
{
for (var prop in wddxRecordsetExtensions)
{
// Hook-up method to WddxRecordset object
this[prop] = wddxRecordsetExtensions[prop]
}
}
// Add built-in methods
this.getRowCount = wddxRecordset_getRowCount;
this.addColumn = wddxRecordset_addColumn;
this.addRows = wddxRecordset_addRows;
this.isColumn = wddxRecordset_isColumn;
this.getField = wddxRecordset_getField;
this.setField = wddxRecordset_setField;
this.wddxSerialize = wddxRecordset_wddxSerialize;
this.dump = wddxRecordset_dump;
this.getColumnList = wddxRecordset_getColumnList;
// Perfom any needed initialization
if (WddxRecordset.arguments.length > 0)
{
if (typeof(val = WddxRecordset.arguments[0].valueOf()) == "boolean")
{
// Case preservation flag is provided as 1st argument
this.preserveFieldCase = WddxRecordset.arguments[0];
}
else
{
// First argument is the array of column names
var cols = WddxRecordset.arguments[0];
// Second argument could be the length or the preserve case flag
var nLen = 0;
if (WddxRecordset.arguments.length > 1)
{
if (typeof(val = WddxRecordset.arguments[1].valueOf()) == "boolean")
{
// Case preservation flag is provided as 2nd argument
this.preserveFieldCase = WddxRecordset.arguments[1];
}
else
{
// Explicitly specified recordset length
nLen = WddxRecordset.arguments[1];
if (WddxRecordset.arguments.length > 2)
{
// Case preservation flag is provided as 3rd argument
this.preserveFieldCase = WddxRecordset.arguments[2];
}
}
}
for (var i = 0; i < cols.length; ++i)
{
var colValue = new Array(nLen);
for (var j = 0; j < nLen; ++j)
{
colValue[j] = null;
}
this[this.preserveFieldCase ? cols[i] : cols[i].toLowerCase()] = colValue;
}
}
}
}
///////////////////////////////////////////////////////////////////////////
//
// WddxRecordset extensions
//
// The WddxRecordset class has been designed with extensibility in mind.
//
// Developers can add new properties to the object and as long as their
// names are prefixed with _private_ the WDDX serialization function of
// WddxRecordset will not treat them as recordset columns.
//
// Developers can create new methods for the class outside this file as
// long as they make a call to registerWddxRecordsetExtension() with the
// name of the method and the function object that implements the method.
// The WddxRecordset constructor will automatically register all these
// methods with instances of the class.
//
// Example:
//
// If I want to add a new WddxRecordset method called addOneRow() I can
// do the following:
//
// - create the method implementation
//
// function wddxRecordset_addOneRow()
// {
// this.addRows(1);
// }
//
// - call registerWddxRecordsetExtension()
//
// registerWddxRecordsetExtension("addOneRow", wddxRecordset_addOneRow);
//
// - use the new function
//
// rs = new WddxRecordset();
// rs.addOneRow();
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// registerWddxRecordsetExtension(name, func) can be used to extend
// functionality by registering functions that should be added as methods
// to WddxRecordset instances.
function registerWddxRecordsetExtension(name, func) {
// Perform simple validation of arguments
if (typeof(name) == "string" && typeof(func) == "function")
{
// Guarantee existence of wddxRecordsetExtensions object
if (typeof(wddxRecordsetExtensions) != "object")
{
// Create wddxRecordsetExtensions instance
wddxRecordsetExtensions = new Object();
}
// Register extension; override an existing one
wddxRecordsetExtensions[name] = func;
}
}
///////////////////////////////////////////////////////////////////////////
//
// WddxBinary
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// wddxSerialize() serializes a binary value
// returns true/false
function wddxBinary_wddxSerialize(serializer) {
serializer.write(
"" + this.data + "");
return true;
}
///////////////////////////////////////////////////////////////////////////
// WddxBinary() constructs an empty binary value
// WddxBinary(base64Data) constructs a binary value from base64 encoded data
// WddxBinary(data, encoding) constructs a binary value from encoded data
function WddxBinary(data, encoding) {
this.data = data != null ? data : "";
this.encoding = encoding != null ? encoding : "base64";
// Custom serialization mechanism
this.wddxSerialize = wddxBinary_wddxSerialize;
}
// Date Scripts
////////////////////
// Date Functions //
////////////////////
// initialize global varaibles
// for changeDate function
var allowequaldates = false;
var enforceMaxdays = true;
var defaultMaxDays = 35;
var maxDayLimit = defaultMaxDays;
var caller = false;
// for format function
// a global day names array
var gsDayNames = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
// a global month names array
var gsMonthNames = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
// is valid date
function isDate(value) {
// initialize variables
// month argument must be in the range 1 - 12
var month = value.substring(5,7) - 1; // javascript month range : 0- 11
var year = value.substring(0,4);
var day = value.substring(8,10);
var tempDate = new Date(year,month,day);
var result = false;
if ((tempDate.getYear() == year) && (month == tempDate.getMonth()) && (day == tempDate.getDate())) { result = true; }
return result;
}
// today's date as YYYYMMDD
function todaysDateClient() {
// initialize variables
var today = new Date();
var todayMonth = today.getMonth() + 1;
var todayMonth = todayMonth.zf(2);
var todayDay = today.getDate();
var todayDay = todayDay.zf(2);
var todayYear = today.getFullYear();
var dateToday = todayYear + "" + todayMonth + "" + todayDay;
return dateToday;
}
// today's date as YYYYMMDD
function todaysDate() {
// initialize variables
var today = now();
var todaySplit = today.split('-');
var todayMonth = todaySplit[1];
var todayMonth = todayMonth.zf(2);
var todayDay = todaySplit[2];
var todayDay = todayDay.zf(2);
var todayYear = todaySplit[0];
var dateToday = todayYear + "" + todayMonth + "" + todayDay;
return dateToday;
}
// date1 & date2 will be the form names that make up the date values in a comma seperated list year,month,day
// date1 will always be previous to date2
function changeDate(formName,date1,date2,priority) {
// initialize varaibles
var date1Split = date1.split(",");
var date2Split = date2.split(",");
// in date
var inDate = "";
var inYear = eval('formName.' + date1Split[0] + '.value') + "";
var inMonth = eval('formName.' + date1Split[1] + '.value') + "";
var inDay = eval('formName.' + date1Split[2] + '.value').rz() + "";
var inDayInteger = inDay;
var inDateDiff = 0;
// out date
var outDate = "";
var outYear = eval('formName.' + date2Split[0] + '.value') + "";
var outMonth = eval('formName.' + date2Split[1] + '.value') + "";
var outDay = eval('formName.' + date2Split[2] + '.value').rz() + "";
var outDayInteger = outDay;
var outDateDiff = 0;
// last day of month for in & out dates
var lastInDay = getLastDayOfMonth(inMonth,inYear).rz() + "";
var lastOutDay = getLastDayOfMonth(outMonth,outYear).rz() + "";
// today
var today = todaysDate();
var todayYear = "";
var todayMonth = "";
var todayDay = "";
// tomorrow
var tomorrow = "";
var tomorrowYear = "";
var tomorrowMonth = "";
var tomorrowDay = "";
// yesterday
var yesterday = "";
var yesterdayYear = "";
var yesterdayMonth = "";
var yesterdayDay = "";
// maximum in date span from out date
var maxInDate = "";
var maxInYear = "";
var maxInMonth = "";
var maxInDay = "";
// maximum out date span from in date
var maxOutDate = "";
var maxOutYear = "";
var maxOutMonth = "";
var maxOutDay = "";
// in date plus 1 year
var inDatePlus = "";
var inDatePlusYear = "";
var inDatePlusMonth = "";
var inDatePlusDay = "";
// in date plus 1 year
var outDatePlus = "";
var outDatePlusYear = "";
var outDatePlusMonth = "";
var outDatePlusDay = "";
// out date
var callerDate = "";
// overload arguments
if (arguments.length >= 5) { caller = arguments[4]; }
// use actual today date hidden in form to correct for client ignorance (wrong clock date)
if (formName.today) { today = formName.today.value; }
todayYear = today.substring(0,4);
todayMonth = today.substring(4,6);
todayDay = today.substring(6,8);
// if day is greater than last day of month
if (parseInt(inDay) > parseInt(lastInDay)) { inDay = lastInDay + ""; changeDateField(formName,date1Split[2],inDay); }
if (parseInt(outDay) > parseInt(lastOutDay)) { outDay = lastOutDay + ""; changeDateField(formName,date2Split[2],outDay); }
// assure month and day are in MM & DD format respectively
inMonth = inMonth.zf(2);
inDay = inDay.zf(2);
outMonth = outMonth.zf(2);
outDay = outDay.zf(2);
// set in & out dates
inDate = inYear + "" + inMonth + "" + inDay;
outDate = outYear + "" + outMonth + "" + outDay;
// add 1 year to in date or out date
if (caller != false && caller == 'month') {
if (priority == "date1" && inDate < today) {
// add a year to in date
inDatePlus = date_add(inDate,0,0,1);
inDatePlusYear = inDatePlus.substring(0,4);
inDatePlusMonth = inDatePlus.substring(4,6);
inDatePlusDay = inDatePlus.substring(6,8);
// set to today
changeDateField(formName,date1Split[0],inDatePlusYear);
changeDateField(formName,date1Split[1],inDatePlusMonth);
changeDateField(formName,date1Split[2],inDatePlusDay);
inDate = inDatePlusYear + "" + inDatePlusMonth + "" + inDatePlusDay;
maxDayLimit = 3;
} else if (outDate < today) {
// add a year to out date
outDatePlus = date_add(outDate,0,0,1);
outDatePlusYear = outDatePlus.substring(0,4);
outDatePlusMonth = outDatePlus.substring(4,6);
outDatePlusDay = outDatePlus.substring(6,8);
// set to today
changeDateField(formName,date2Split[0],outDatePlusYear);
changeDateField(formName,date2Split[1],outDatePlusMonth);
changeDateField(formName,date2Split[2],outDatePlusDay);
outDate = outDatePlusYear + "" + outDatePlusMonth + "" + outDatePlusDay;
// maxDayLimit = 3; // commented out on 2007-10-11
}
}
if (priority == "date1") {
// change date2 if previous to date1
if (caller != false) {
if (dateDiff('d',(inYear + "" + inMonth + "" + inDay),(outYear + "" + outMonth + "" + outDay)) > maxDayLimit) {
if (caller == "year") {
callerDate = inYear + "" + outMonth + "" + outDay;
} else if (caller == "month") {
callerDate = outYear + "" + inMonth + "" + outDay;
} else if (caller == "day") {
// callerDate = outYear + "" + outMonth + "" + inDay;
}
}
}
if (outDate <= inDate || callerDate != "") {
if (allowequaldates == true && outDate == inDate) {
tomorrow = date_add(inDate,0);
} else if (callerDate != "" && parseInt(callerDate) > inDate) {
tomorrow = callerDate.toString();
} else {
tomorrow = date_add(inDate,1);
}
tomorrowYear = tomorrow.substring(0,4);
tomorrowMonth = tomorrow.substring(4,6);
tomorrowDay = tomorrow.substring(6,8);
// change date2
changeDateField(formName,date2Split[0],tomorrowYear);
changeDateField(formName,date2Split[1],tomorrowMonth);
changeDateField(formName,date2Split[2],tomorrowDay);
outDate = tomorrowYear + "" + tomorrowMonth + "" + tomorrowDay;
}
} else {
// change date1 if after to date2
if (caller != false) {
outDateDiff = dateDiff('d',(inYear + "" + inMonth + "" + inDay),(outYear + "" + outMonth + "" + outDay));
if (outDateDiff > maxDayLimit) {
if (caller == "year") {
callerDate = outYear + "" + inMonth + "" + inDay;
} else if (caller == "month") {
if (inMonth == outMonth && inYear == outYear && outDayInteger <= inDayInteger) {
outDay = parseInt(inDayInteger) + 1;
outDay = (outDay > lastInDay) ? inDay : outDay;
outDay = outDay.zf(2);
changeDateField(formName,date2Split[2],outDay);
outDate = outYear + "" + outMonth + "" + outDay;
}
// callerDate = inYear + "" + outMonth + "" + inDay;
} else if (caller == "day") {
// callerDate = inYear + "" + inMonth + "" + outDay;
}
} else if (outDateDiff <= 0 && caller == "month") {
if (inMonth == outMonth && inYear == outYear && outDayInteger <= inDayInteger) {
outDay = parseInt(inDayInteger) + 1;
outDay = (outDay > lastInDay) ? inDay : outDay;
outDay = outDay.zf(2);
changeDateField(formName,date2Split[2],outDay);
outDate = outYear + "" + outMonth + "" + outDay;
}
}
}
if (inDate >= outDate || callerDate != "") {
if (allowequaldates == true && outDate == inDate) {
yesterday = date_add(outDate,0);
} else if (callerDate != "" && parseInt(callerDate) < outDate) {
yesterday = callerDate.toString();
} else {
yesterday = date_add(outDate,-1);
}
yesterdayYear = yesterday.substring(0,4);
yesterdayMonth = yesterday.substring(4,6);
yesterdayDay = yesterday.substring(6,8);
// change date1
changeDateField(formName,date1Split[0],yesterdayYear);
changeDateField(formName,date1Split[1],yesterdayMonth);
changeDateField(formName,date1Split[2],yesterdayDay);
inDate = yesterdayYear + "" + yesterdayMonth + "" + yesterdayDay;
}
}
// change date1 if previous to today
if (inDate < today) {
// set to today
changeDateField(formName,date1Split[0],todayYear);
changeDateField(formName,date1Split[1],todayMonth);
changeDateField(formName,date1Split[2],todayDay);
inDate = todayYear + "" + todayMonth + "" + todayDay;
}
// change date2 if previous to today
if (outDate <= today) {
if (allowequaldates == true && today == inDate) {
tomorrow = date_add(today,0);
} else {
tomorrow = date_add(today,1);
}
tomorrowYear = tomorrow.substring(0,4);
tomorrowMonth = tomorrow.substring(4,6);
tomorrowDay = tomorrow.substring(6,8);
// set to today + 1
changeDateField(formName,date2Split[0],tomorrowYear);
changeDateField(formName,date2Split[1],tomorrowMonth);
changeDateField(formName,date2Split[2],tomorrowDay);
outDate = tomorrowYear + "" + tomorrowMonth + "" + tomorrowDay;
}
// cannot check more than a maxDayLimit day span
maxInDate = date_add(outDate,(-1 * maxDayLimit));
maxOutDate = date_add(inDate,maxDayLimit);
if (enforceMaxdays == true) {
if (priority == "date1" && outDate > maxOutDate) {
maxOutYear = maxOutDate.substring(0,4);
maxOutMonth = maxOutDate.substring(4,6);
maxOutDay = maxOutDate.substring(6,8);
// change date2
changeDateField(formName,date2Split[0],maxOutYear);
changeDateField(formName,date2Split[1],maxOutMonth);
changeDateField(formName,date2Split[2],maxOutDay);
outDate = maxOutYear + "" + maxOutMonth + "" + maxOutDay;
} else if (priority == "date2" && inDate < maxInDate) {
maxInYear = maxInDate.substring(0,4);
maxInMonth = maxInDate.substring(4,6);
maxInDay = maxInDate.substring(6,8);
// change date1
changeDateField(formName,date1Split[0],maxInYear);
changeDateField(formName,date1Split[1],maxInMonth);
changeDateField(formName,date1Split[2],maxInDay);
inDate = maxInYear + "" + maxInMonth + "" + maxInDay;
}
}
// reset max day limit to default
maxDayLimit = defaultMaxDays;
}
// change date - changes only one form field at a time
function changeDateField(formName,thisField,thisValue) {
// initialize variables
var newField = eval('formName.' + thisField);
var curValue = eval('newField.options[newField.selectedIndex].value');
var curIndex = eval('newField.selectedIndex');
var newValue = "" + thisValue.rz();
var newIndex = "";
newIndex = curIndex - (curValue - parseInt(newValue));
if (newIndex < 0) { newIndex = 0; }
newField.selectedIndex = newIndex;
}
// need to pass year to check leap year for Feb.
function getLastDayOfMonth(thisMonth,thisYear) {
// initialize variables
var isLeap = mod(thisYear, 4);
var lastDay = 30;
var newMonth = thisMonth.rz();
// Months With 31 days
if (newMonth == 1 || newMonth == 3 || newMonth == 5 || newMonth == 7 || newMonth == 8 || newMonth == 10 || newMonth == 12) {
lastDay = 31;
} else if (newMonth == 2) {
// Feb.
if (isLeap == 0) {
// Leap Year - 29 Days
lastDay = 29;
} else {
// Non Leap Year - 28 days
lastDay = 28;
}
}
return lastDay;
}
// create date string
function createDateString(formName,thisDate) {
// initialize variables
var returnArray = new Array();
var dateSplit = thisDate.split(",");
var thisYear = parseInt(eval('formName.' + dateSplit[0] + '.value'));
var thisMonth = eval('formName.' + dateSplit[1] + '.value').rz() + "";
var thisDay = eval('formName.' + dateSplit[2] + '.value').rz() + "";
returnArray[0] = thisYear;
returnArray[1] = thisMonth;
returnArray[2] = thisDay;
return returnArray;
}
// create date object
function createDateObject(thisDate) {
// initialize variables
var dateArray = breakDate(thisDate);
var returnObject = new Date(dateArray[0],(dateArray[1]-1),dateArray[2]);
return returnObject;
}
// Breaks up YYYYMMDD, returns a 3 element array [0] = year, [1] = month, [2] = day
function breakDate(thisDate) {
// initialize variables
var thisDate = thisDate + "";
var itemYear = thisDate.substring(0,4);
var itemMonth = thisDate.substring(4,6);
var itemDay = thisDate.substring(6,8);
var dateArray = new Array(3);
dateArray[0] = itemYear;
dateArray[1] = itemMonth;
dateArray[2] = itemDay;
return dateArray;
}
// date passed in must be in YYYYMMDD format
// adds days (can be a negative number) to date passed in, returned as YYYYMMDD
function date_add(thisDate,days) {
// initialize variables
var dateArray = breakDate(thisDate);
var thisYear = dateArray[0];
var thisMonth = dateArray[1].rz();
var thisDay = dateArray[2].rz();
var newDate = "";
var newMonth = "";
var newDay = "";
var newYear = "";
var returnDate = "";
// overload arguments
if (arguments.length >= 3) { thisMonth = parseInt(thisMonth) + arguments[2]; }
if (arguments.length >= 4) {thisYear = parseInt(thisYear) + arguments[3]; }
thisDay = parseInt(thisDay) + days;
thisMonth = parseInt(thisMonth) - 1;
newDate = new Date(thisYear, thisMonth, thisDay);
newMonth = "" + parseInt(newDate.getMonth() + 1);
newMonth = newMonth.zf(2);
newDay = "" + newDate.getDate().zf(2);
newYear = "" + newDate.getFullYear();
returnDate = newYear + "" + newMonth + "" + newDay;
return returnDate;
}
// returns the first day of the week
// date passed in must be in YYYYMMDD format
function FirstDayOfWeek(thisDate) {
var date_object = createDateObject(thisDate);
var dow = -1 * date_object.getDay();
var yyyymmdd = date_add(thisDate, dow);
return yyyymmdd;
}
// returns the last day of a week
// date passed in must be in YYYYMMDD format
function LastDayOfWeek(thisDate) {
var date_object = createDateObject(thisDate);
var dow = 7 - (date_object.getDay() + 1);
var yyyymmdd = date_add(thisDate, dow);
return yyyymmdd;
}
function dateDiff(datepart, date1, date2) {
var result = 0;
var dateArray1 = breakDate(date1);
var dateArray2 = breakDate(date2);
var compare1 = new Date(dateArray1[0],(dateArray1[1]-1),dateArray1[2]);
var compare2 = new Date(dateArray2[0],(dateArray2[1]-1),dateArray2[2]);
var diffArray = getDiffs(date1,date2);
switch (datepart.toLowerCase().substr(0,1)) {
case 'y':
if(diffArray[0] != 0) {
if(diffArray[1] < 0) {
result = parseInt(((dateArray2[2] > dateArray1[2]) ? diffArray[1] + 1 : diffArray[1]) / 12);
} else if(diffArray[1] > 0) {
result = parseInt(((dateArray2[2] < dateArray1[2]) ? diffArray[1] - 1 : diffArray[1]) / 12);
} else {
result = diffArray[0];
}
} else {
result = diffArray[0];
}
break;
case 'm':
if(diffArray[1] < 0) {
result = (dateArray2[2] > dateArray1[2]) ? diffArray[1] + 1 : diffArray[1];
} else if(diffArray[1] > 0) {
result = (dateArray2[2] < dateArray1[2]) ? diffArray[1] - 1 : diffArray[1];
} else {
result = diffArray[1];
}
break;
case 'd': result = Math.round((compare2 - compare1) / (24 * 60 * 60 * 1000)); break;
}
return result;
}
function getDiffs(date1,date2) {
var dateArray1 = breakDate(date1);
var dateArray2 = breakDate(date2);
var results = new Array(3);
results[0] = dateArray2[0] - dateArray1[0];
results[1] = dateArray2[1] - dateArray1[1] + (results[0] != 0 ? results[0] * 12 : 0);
results[2] = dateArray2[2] - dateArray1[2];
return results;
}
// the date format prototype
Date.prototype.format = function(f) {
var d = this;
if (!d.valueOf()) { return ' '; }
return f.replace(/(yyyy|yy|mmmm|mmm|mm|dddd|ddd|dd|hhh|hh|h|nn|ss|a\/p)/gi,
function($1) {
switch ($1.toLowerCase()) {
case 'yyyy': return d.getFullYear();
case 'yy': return d.getFullYear().toString().substr(2,4);
case 'mmmm': return gsMonthNames[d.getMonth()];
case 'mmm': return gsMonthNames[d.getMonth()].substr(0,3);
case 'mm': return (d.getMonth() + 1).zf(2);
case 'dddd': return gsDayNames[d.getDay()];
case 'ddd': return gsDayNames[d.getDay()].substr(0,3);
case 'dd': return d.getDate().zf(2);
case 'hhh': return d.getHours().rz();
case 'hh': return ((h = d.getHours() % 12) ? h : 12).zf(2);
case 'h': return ((h = d.getHours() % 12) ? h : 12).rz();
case 'nn': return d.getMinutes().zf(2);
case 'ss': return d.getSeconds().zf(2);
case 'a/p': return d.getHours() < 12 ? 'a' : 'p';
}
}
);
}
// Zero-Fill
Number.prototype.zf = function(l) { return this.toString().zf(l); }
String.prototype.zf = function(l) { return '0'.string(l - this.length) + this; }
String.prototype.string = function(l) { var s = '', i = 0; while (i++ < l) { s += this; } return s; }
// Replace leading zero(s) - i.e. 0004 = 4, 040 = 40
Number.prototype.rz = function() { return this.toString().rz(); }
String.prototype.rz = function() { var n = this; var l = n.length; var i = -1; while (i++ < l) { if (this.substring(i,i+1) == 0) { n = n.substring(1,n.length); } else { i = l; } } return n; }
// Math Scripts
// correctly adds numbers together
function add() {
var result = 0;
var integers = new Array();
var fractions = new Array();
var thislen = arguments.length;
var a = 0;
var l = 0;
var x = 0;
var numstr = "";
var numsplit = "";
var integerTotal = 0;
var fractionTotal = 0;
var thisFraction = 0;
var fractionLen = 0;
var fractionDiv = 0;
var fractionSign = "";
for (a; a < thislen; a++) {
numstr = arguments[a] + "";
numsplit = numstr.split(".");
if (numsplit[0] != 0) {
integers[integers.length] = numsplit[0];
}
if (numsplit.length > 1 && numsplit[1] != 0) {
thisFraction = numsplit[1];
if (numsplit[0] < 0) {
thisFraction = -1 * ("." + thisFraction);
thisFraction = thisFraction.toString();
while (thisFraction.indexOf("-0") == 0) {
thisFraction = thisFraction.replace("-0","-");
}
thisFraction = thisFraction.replace(".","");
}
fractions[fractions.length] = thisFraction;
}
}
// add all integers
a = 0;
thislen = integers.length;
for (a; a < thislen; a++) {
integerTotal = integerTotal + +integers[a];
}
// add all fractions
a = 0;
thislen = fractions.length;
for (a; a < thislen; a++) {
fractionDiv = 1;
thisFraction = fractions[a];
fractionLen = 1;
fractionSign = "";
if (thisFraction.indexOf("-") != -1) {
fractionSign = "-";
thisFraction = thisFraction.replace("-","");
}
// fractionLen = Math.abs(thisFraction).toString().length;
while (thisFraction.indexOf("0") == 0) {
thisFraction = thisFraction.substring(1,thisFraction.length);
fractionLen += 1;
}
fractionLen += (thisFraction.toString().length - 1);
if (fractionSign == "-") {
thisFraction = -1 * thisFraction;
}
for (l = 1; l <= fractionLen; l++) {
fractionDiv = fractionDiv * 10;
}
fractionTotal = +fractionTotal + (thisFraction/fractionDiv);
}
result = integerTotal + fractionTotal;
return result;
}
// Skin Scripts
// SKIN SCRIPTS (Updated 2009-07-24)
// Common scripts used with our skins framework.
// Extends the CSS styles of target with what is passed in 'style'.
function doOver(target,style) {
// Replace Comma at the End
style = style.replace(new RegExp(";$","g"),"");
// Split Style By ;
var style_array = style.split(';');
var item_index = 0;
var style_item = "";
var style_value = "";
for(var a = 0; a < style_array.length; a++) {
// Gotta split it this way because background-images can have full http(s) urls with colons in them.
item_index = style_array[a].indexOf(':');
style_item = style_array[a].substring(0,item_index);
style_value = style_array[a].substring(item_index+1,style_array[a].length);
jQuery(target).css(jQuery.trim(style_item),jQuery.trim(style_value));
}
}
// Both of these functions do the same thing; the second one is just a wrapper for readability.
function doOut(target,style) { doOver(target,style); }
// Flash Wrapper
//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
//Generate flash object
function generateObject(objAttrs, params, embedAttrs) {
var str = '';
document.write(str);
}
//Run content for flash.
//Arguments are the flash object's attributes defined in a pair of arguments. The first arg
//defines the name of the attribute, the second defines what the value is.
//Example: 'movie', 'header_home.swf', 'width', '140'
//...and it continues on for all of the other attributes.
function runFlashContent() {
var ret = compileAttributes(arguments);
generateObject(ret.objAttrs, ret.params, ret.embedAttrs);
}
//Compile object attributes.
function compileAttributes(args) {
var ret = new Object();
ret.embedAttrs = new Object();
ret.params = new Object();
ret.objAttrs = new Object();
for(var i=0; i < args.length; i=i+2) {
var currArg = args[i].toLowerCase();
switch(currArg) {
case "classid":
ret.objAttrs["classid"] = args[i+1];
break;
case "type":
ret.embedAttrs["type"] = args[i+1];
break;
case "pluginspage":
ret.embedAttrs[args[i]] = args[i+1];
break;
case "src":
case "movie":
ret.embedAttrs["src"] = args[i+1];
ret.params["movie"] = args[i+1];
break;
case "onafterupdate":
case "onbeforeupdate":
case "onblur":
case "oncellchange":
case "onclick":
case "ondblClick":
case "ondrag":
case "ondragend":
case "ondragenter":
case "ondragleave":
case "ondragover":
case "ondrop":
case "onfinish":
case "onfocus":
case "onhelp":
case "onmousedown":
case "onmouseup":
case "onmouseover":
case "onmousemove":
case "onmouseout":
case "onkeypress":
case "onkeydown":
case "onkeyup":
case "onload":
case "onlosecapture":
case "onpropertychange":
case "onreadystatechange":
case "onrowsdelete":
case "onrowenter":
case "onrowexit":
case "onrowsinserted":
case "onstart":
case "onscroll":
case "onbeforeeditfocus":
case "onactivate":
case "onbeforedeactivate":
case "ondeactivate":
case "type":
case "codebase":
ret.objAttrs[args[i]] = args[i+1];
break;
case "width":
case "height":
case "align":
case "vspace":
case "hspace":
case "class":
case "title":
case "accesskey":
case "name":
case "id":
case "tabindex":
ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
break;
default:
ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
}
}
return ret;
}
//////////////////////
// Errors Functions //
//////////////////////
// suppress all javascript errors
window.onerror = null;
// prevent scrolling
function noscroll() { document.body.scrollTop = 0; document.body.scrollLeft = 0; }
//////////////////////////
// Macromedia Functions //
//////////////////////////
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i0&&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 1 && arguments[1] == false) ? false : true;
if(isTextField && (isTextField == "text" || isTextField == "password" || isTextField == "textarea") && obj.className == 'text_field') { obj.className = 'text_field_highlite'; }
if(obj.value == obj.defaultValue && clearField == true) { obj.value = ""; }
}
function blurred(obj) {
var isTextField = obj.type;
var clearField = (arguments.length > 1 && arguments[1] == false) ? false : true;
if(isTextField && (isTextField == "text" || isTextField == "password" || isTextField == "textarea") && obj.className == 'text_field_highlite') { obj.className = 'text_field'; }
if(obj.value == "" && clearField == true) { obj.value = obj.defaultValue; }
}
function showItem(this_item) {
var argLen = arguments.length;
var thisDisplay = this_item.style.display;
var displayNone = "none";
if (argLen == 2) {
thisDisplay = arguments[1];
} else if (thisDisplay == displayNone) {
thisDisplay = "";
} else {
thisDisplay = displayNone;
}
this_item.style.display = thisDisplay;
}
function showHideAll(item,elem){
var elemArr = document.getElementsByTagName(elem);
for (i=0;i 1) ? arguments[1] : "gb";
if(jQuery("#" + prefix + "Layer").css("display") == "none") {
jQuery("#" + prefix + "Layer").fadeIn("fast",function(){
jQuery("#" + prefix + "Left").attr("src","/common/images/admin/admin_" + color + "_l_s.gif");
jQuery("#" + prefix + "Bg").css({'background-image':"url('/common/images/admin/admin_" + color + "_bg_s.gif')"});
jQuery("#" + prefix + "Bg2").css({'background-image':"url('/common/images/admin/admin_" + color + "_bg_s.gif')"});
jQuery("#" + prefix + "Right").attr("src","/common/images/admin/admin_" + color + "_r_s.gif");
jQuery("#" + prefix + "Minmax").attr("src","/common/images/admin/admin_minimize.gif");
});
} else {
jQuery("#" + prefix + "Layer").fadeOut("fast",function(){
jQuery("#" + prefix + "Left").attr("src","/common/images/admin/admin_" + color + "_l.gif");
jQuery("#" + prefix + "Bg").css({'background-image':"url('/common/images/admin/admin_" + color + "_bg.gif')"});
jQuery("#" + prefix + "Bg2").css({'background-image':"url('/common/images/admin/admin_" + color + "_bg.gif')"});
jQuery("#" + prefix + "Right").attr("src","/common/images/admin/admin_" + color + "_r.gif");
jQuery("#" + prefix + "Minmax").attr("src","/common/images/admin/admin_maximize.gif");
});
}
}
function newWindow(pageSource) {
// initialize variables
var leName = "newWindow";
var leWindow = "";
var args = "";
var width = 480;
var height = 500;
var status = 0;
var
var scrollbars = 0;
var left = 15;
var top = 20;
var resizable = 0;
var menubar = 0;
var toolbar = "no";
// overload arguments
if (arguments.length >= 2 && arguments[1] != "default") { width = arguments[1]; }
if (arguments.length >= 3 && arguments[2] != "default") { height = arguments[2]; }
if (arguments.length >= 4 && arguments[3] != "default") { status = arguments[3]; }
if (arguments.length >= 5 && arguments[4] != "default") { location = arguments[4]; }
if (arguments.length >= 6 && arguments[5] != "default") { scrollbars = arguments[5]; }
if (arguments.length >= 7 && arguments[6] != "default") { left = arguments[6]; }
if (arguments.length >= 8 && arguments[7] != "default") { top = arguments[7]; }
if (arguments.length >= 9 && arguments[8] != "default") { resizable = arguments[8]; }
if (arguments.length >= 10 && arguments[9] != "default") { menubar = arguments[9]; }
if (arguments.length >= 11 && arguments[10] != "default") { toolbar = arguments[10]; }
args = "toolbar=" + toolbar + ",width=" + width + ",height=" + height + ",status=" + status + ",location=" + location + ",scrollbars=" + scrollbars + ",left=" + left + ",top=" + top + ",resizable=" + resizable + ",menubar=" + menubar;
leWindow = window.open(pageSource, leName, args);
}
function confirmDelete(formName, this_item) {
var confirmString = "Are you sure you want to delete this " + this_item + "?";
var agree = confirm(confirmString);
if(agree) {
if(typeof(formName) == 'object') {
if(formName.deleteMode) {
formName.mode.value = formName.deleteMode.value;
} else {
formName.mode.value = "delete";
}
}
return true;
} else {
return false;
}
}
function setSelectOptions(the_form, the_select, do_check) {
var selectObject = document.forms[the_form].elements[the_select];
var selectCount = selectObject.length;
for(var i = 0; i < selectCount; i++) { selectObject.options[i].selected = do_check; }
}
function getSelectedOptions(obj) {
var selectedOptions = new Array();
var i = 0;
var l = obj.options.length;
for(i; i < l; i++) {
if(obj.options[i].selected) {
selectedOptions.push(obj.options[i]);
}
}
return selectedOptions;
}
function removeFromArray(obj, index) { obj.remove(index); }
function addToArray(obj, item) {
// insert the new item at the end
obj.options[obj.options.length] = item;
}
// URI encoded name-value pairs
function encodeURIForm(thisform) {
var results = '';
var elems = thisform.elements;
var a = 0;
var z = elems.length;
var addValue = true;
var elemName = '';
var elemValue = '';
for(a; a < z; a++) {
if(typeof(elems[a].name) != 'undefined' && typeof(elems[a].value) != 'undefined') {
addValue = true;
elemName = elems[a].name;
elemValue = elems[a].value;
if(elems[a].type.toLowerCase() == 'checkbox' || elems[a].type.toLowerCase() == 'radio') { addValue = elems[a].checked; }
if(addValue == true) { results += '&' + elemName + '=' + elemValue; }
}
}
// replace leading '&'
results = results.substring(1,results.length);
return encodeURI(results);
}
//////////////////////////
// Validation Functions //
/////////////////////////
function emailCheck (emailStr) {
var checkTLD=0;
var knownDomsPat=/ ^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|cc|tv)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
alert("The Email Address Is Invalid");
return false;
}
var user=matchArray[1];
var domainName=matchArray[2];
for (i=0; i127) {
alert("The Username Contains Invalid Characters.");
return false;
}
}
for (i=0; i127) {
alert("Ths Domain Name Contains Invalid Characters.");
return false;
}
}
if (user.match(userPat)==null) {
alert("The Username Is Invalid.");
return false;
}
var IPArray=domainName.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray>255) {
alert("The Destination IP Address Is Invalid.");
return false;
}
}
return true;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domainName.split(".");
var len=domArr.length;
for (i=0;i -1);
}
function checkoutValidate() {
if (!validCCForm(document.resForm.credit_number)) {
document.resForm.credit_number.focus();
return false;
} else if (document.resForm.credit_expiration.value == "") {
alert("Please enter your credit card expiration date.");
document.resForm.credit_expiration.select();
document.resForm.credit_expiration.focus();
return false;
} else if (!document.resForm.stayed_before[0].checked && !document.resForm.stayed_before[1].checked) {
alert("Please indicate if you have stayed with us before.");
return false;
} else if (!validateForm(resForm)) {
return false;
} else {
return true;
}
}
function validatePassReset() {
if ((document.passForm.new_pass1.value == document.passForm.new_pass2.value) &&
document.passForm.new_pass1.value != null && document.passForm.new_pass1.value != "" &&
document.passForm.new_pass2.value != null && document.passForm.new_pass2.value != "") {
return true;
} else {
alert("Your passwords do not match each other.");
document.passForm.new_pass1.focus();
document.passForm.new_pass1.select();
return false;
}
}
function validateForm(formName) {
var thisForm = formName.elements;
// Loop and Validate Form Elements
for(var i = 0; i < thisForm.length; i++) {
with(thisForm[i]) {
var validateMode = thisForm[i].getAttribute("validate", 0);
var validateName = thisForm[i].getAttribute("validatename", 0);
if(!validateMode) continue;
if(!validateName) validateName = getAttribute("id", 0);
var thisValue = trim(value);
thisValue = xss_clean(thisValue);
if(validateMode == "email") {
if(!emailCheck(thisValue)) {
thisForm[i].select();
thisForm[i].focus();
return false;
}
}
else if(validateMode == "cc") {
if(!validCCForm(thisForm[i]) || thisValue == "" || thisValue == NULL) {
thisForm[i].select();
thisForm[i].focus();
return false;
}
}
else if(validateMode == "select") {
if(thisForm[i].selectedIndex == 0 || thisValue == "") {
alert("Please select " + validateName + " before submitting this form.");
thisForm[i].focus();
return false;
}
}
else if(validateMode == "multipleSelect") {
var thisDefault = thisForm[i].getAttribute("default", 0);
if(thisValue == "") {
alert("Please enter " + validateName + " before submitting this form.");
return false;
} else if(typeof(thisDefault) != 'undefined' && trim(thisDefault) == trim(thisValue)) {
alert("Please enter " + validateName + " before submitting this form.");
return false;
}
}
else if(validateMode == "requiredDefault") {
var thisDefault = thisForm[i].getAttribute("default", 0);
if(thisValue == "") {
alert("Please enter " + validateName + " before submitting this form.");
thisForm[i].select();
thisForm[i].focus();
return false;
} else if(typeof(thisDefault) != 'undefined' && trim(thisDefault) == trim(thisValue)) {
alert("Please enter " + validateName + " before submitting this form.");
thisForm[i].select();
thisForm[i].focus();
return false;
}
}
else if(validateMode == "notZero") {
if(thisValue == "" || thisValue == 0 || thisValue == 0.00) {
alert("One of your GDS rates is set to either zero or blank.");
return false;
}
}
else if(validateMode == "notZeroActive") {
var thisElement = thisForm[i].name;
var iLen = thisElement.length;
var first = thisElement.indexOf("_");
var code = thisElement.substring(0, first);
var last = thisElement.lastIndexOf("_") + 1;
var num = thisElement.substring(last, iLen);
var validChars = "0123456789";
var newNum = "";
for(forLoop = 0; forLoop < num.length; forLoop++) {
thisChar = num.charAt(forLoop);
if(validChars.indexOf(thisChar) != -1) {
newNum = newNum + thisChar + "";
}
}
var thisActive = "active" + code + newNum;
var obj = MM_findObj(thisActive);
if(obj.checked) {
if(thisValue == "" || thisValue == 0 || thisValue == 0.00) {
alert("One of your GDS rates is set to either zero or blank.");
return false;
}
}
}
else if(validateMode == "wholesalerActiveDates") {
var thisElement = thisForm[i].name;
var iLen = thisElement.length;
var findActive = thisElement.indexOf("_");
var findActive = findActive + 1;
var newString = thisElement.substring(findActive, iLen);
var first = newString.indexOf("_");
var thisId = newString.substring(0, first);
var last = newString.lastIndexOf("_") + 1;
var thisNum = newString.substring(last, iLen);
var obj = MM_findObj(thisElement);
var dateToday = todaysDate();
if(obj.checked) {
var newStartDay = "date_start_" + thisId + "_" + thisNum + "_date";
var newStartMonth = "date_start_" + thisId + "_" + thisNum + "_month";
var newStartYear = "date_start_" + thisId + "_" + thisNum + "_year";
var newStopDay = "date_stop_" + thisId + "_" + thisNum + "_date";
var newStopMonth = "date_stop_" + thisId + "_" + thisNum + "_month";
var newStopYear = "date_stop_" + thisId + "_" + thisNum + "_year";
var startDayObj = MM_findObj(newStartDay);
var startMonthObj = MM_findObj(newStartMonth);
var startYearObj = MM_findObj(newStartYear);
var stopDayObj = MM_findObj(newStopDay);
var stopMonthObj = MM_findObj(newStopMonth);
var stopYearObj = MM_findObj(newStopYear);
var dateStart = startYearObj.value + "" + numberZeroFormat(startMonthObj.value) + "" + numberZeroFormat(startDayObj.value);
var dateStop = stopYearObj.value + "" + numberZeroFormat(stopMonthObj.value) + "" + numberZeroFormat(stopDayObj.value);
if(parseInt(dateStop) < parseInt(dateStart) || parseInt(dateStop) < parseInt(dateToday)) {
alert("A stop date cannot be prior to today or prior to its respective start date.");
stopMonthObj.focus();
return false;
}
// check start dates
if(startMonthObj.value == 2) {
if(startYearObj.value == 2008) {
if(startDayObj.value > 29) {
alert("There are date errors in your form.");
startDayObj.focus();
return false;
}
} else {
if(startDayObj.value > 28) {
alert("There are date errors in your form.");
startDayObj.focus();
return false;
}
}
} else if(startMonthObj.value == 4 || startMonthObj.value == 6 || startMonthObj.value == 9 || startMonthObj.value == 11) {
if (startDayObj.value > 30) {
alert("There are date errors in your form.");
startDayObj.focus();
return false;
}
}
// check stop dates
if(stopMonthObj.value == 2) {
if(stopYearObj.value == 2008) {
if(stopDayObj.value > 29) {
alert("There are date errors in your form.");
stopDayObj.focus();
return false;
}
} else {
if(stopDayObj.value > 28) {
alert("There are date errors in your form.");
stopDayObj.focus();
return false;
}
}
} else if(stopMonthObj.value == 4 || stopMonthObj.value == 6 || stopMonthObj.value == 9 || stopMonthObj.value == 11) {
if(stopDayObj.value > 30) {
alert("There are date errors in your form.");
stopDayObj.focus();
return false;
}
}
}
}
else if(thisValue == "" || thisValue == trim(thisForm[i].defaultValue)) {
// alert(jQuery("#status").attr("id"))
alert("Please enter " + validateName + " before submitting this form.");
thisForm[i].select();
thisForm[i].focus();
return false;
}
}
}
// Loop and disable form elements marked for it.
for(var i = 0; i < thisForm.length; i++) {
with(thisForm[i]) {
var disableItem = thisForm[i].getAttribute("disableonsubmit", 0);
if(!disableItem) continue;
if(disableItem == true || disableItem.toLowerCase() == "yes" || disableItem.toLowerCase() == "true") {
thisForm[i].disabled = true;
}
}
}
// Record form_name in the FORM for submission
var thisFormId = formName.attributes['id'].value;
if(typeof(document.forms[thisFormId].form_name) == "undefined") {
var nameField = document.createElement("input");
nameField.setAttribute("type","hidden",0);
nameField.setAttribute("name","form_name",0);
nameField.setAttribute("id","form_name",0);
nameField.setAttribute("value",thisFormId,0);
document.forms[thisFormId].appendChild(nameField);
}
return true;
}
//////////////////////////
// Formatting Functions //
//////////////////////////
function replaceNoCase(string,substring1,substring2,scope) {
var temp = "" + string.toLowerCase(); // temporary holder
if(scope == "One") {
pos = temp.indexOf(substring1);
temp = "" + (temp.substring(0, pos) + substring2 +
temp.substring((pos + substring1.length), temp.length));
} else {
while(temp.indexOf(substring1)>-1) {
pos = temp.indexOf(substring1);
temp = "" + (temp.substring(0, pos) + substring2 +
temp.substring((pos + substring1.length), temp.length));
}
}
return temp;
}
function trim(inputString) {
if(typeof inputString != "string") { return inputString; }
var retValue = inputString;
var ch = retValue.substring(0, 1);
while(ch == " ") { // Check for spaces at the beginning of the string
retValue = retValue.substring(1, retValue.length);
ch = retValue.substring(0, 1);
}
ch = retValue.substring(retValue.length-1, retValue.length);
while(ch == " ") { // Check for spaces at the end of the string
retValue = retValue.substring(0, retValue.length-1);
ch = retValue.substring(retValue.length-1, retValue.length);
}
while(retValue.indexOf(" ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); // Again, there are two spaces in each of the strings
}
return retValue; // Return the trimmed string back to the user
}
// $0.00
function dollar_format(y) {
max_length = 12; //max_length= length of text input
spacing = " ";
x = (y < 0) ? Math.ceil(y) : Math.floor(y);
xx = y - x;
xx = xx + "00.000"; //xx=the cents only (with zeroes).
a = xx.indexOf(".");
q = x + xx.substring(a,a+4);
ql = (q.length= 5) {r = parseFloat(r) + parseFloat(.01); }
r = "" + r;
a = r.indexOf(".");
if (a < 0) {
rLeft = r;
rRight = ".00";
} else {
if (r.length < a+3) {r = r + "0";}
rLeft = r.substring(0,a);
rRight = r.substring(a,a+3);
}
r = rLeft + rRight;
if (r == 0) { r = " 0.00"; }
r = "$" + trim(r);
return (r);
}
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;
}
////////////////////
// Math Functions //
////////////////////
// mod function
function mod(div,base) { return Math.round(div - (Math.floor(div/base)*base)); }
////////////////////
// Date Functions //
////////////////////
// todays date
function now() { return "2014-06-25"; }
///////////////////
// Tab Functions //
///////////////////
function switchTab(tab,css) {
var tabsContainer = tab.parentNode;
var tabPanels = tabsContainer.parentNode.getElementsByTagName('DIV').item(1).childNodes; // all tabpanels child
var tabs = tabsContainer.getElementsByTagName('A'); // all tabs
var tabPos; // clicked tab position
var tempArr = new Array(1);
var j = 0;
var i = 0;
for (i=0;i < tabs.length;i++)
if (tabs[i] == tab) {
tabPos = i;
addClassName(tab, css);
} else {
removeClassName(tabs[i], css);
}
for (i=0;i < tabPanels.length;i++) // retrieve only divs from the tabpanels
if (tabPanels[i].nodeName == 'DIV') {
tempArr[j] = tabPanels[i];
j = j + 1;
}
for (i=0;i < tempArr.length;i++)
i==tabPos?tempArr[i].style.display='block':tempArr[i].style.display='none'
}
function addClassName(el, sClassName) {
var s = el.className;
var p = s.split(" ");
var l = p.length;
for (var i = 0; i < l; i++) {
if (p[i] == sClassName)
return;
}
p[p.length] = sClassName;
el.className = p.join(" ").replace( /(^\s+)|(\s+$)/g, "" );
}
function removeClassName(el, sClassName) {
var s = el.className;
var p = s.split(" ");
var np = [];
var l = p.length;
var j = 0;
for (var i = 0; i < l; i++) {
if (p[i] != sClassName)
np[j++] = p[i];
}
el.className = np.join(" ").replace( /(^\s+)|(\s+$)/g, "" );
}
////////////////////////////
// Remote Query Functions //
////////////////////////////
// remoteQuery
function remoteQuery(comp, method, arg, formtag) {
// initialize variables
var newSrc = (arguments.length > 4) ? arguments[4] : "/templates/admin/general/wddx_iframe.cfm";
var thisFormId = (typeof formtag.attributes != "undefined" && typeof formtag.attributes['id'].value != "undefined") ? formtag.attributes['id'].value : "none";
var wddxFrame = document.getElementById("wddxFrame");
var e = "";
// change the src attribute of the iframe
newSrc += '/thisComponent/' + comp + '/thisMethod/' + method + '/thisArgument/' + arg + '/thisForm/' + thisFormId;
try {
document.frames['wddxFrame'].location = newSrc;
} catch (e) {
try {
wddxFrame.src = newSrc;
} catch (e) { }
}
}
// determines what function was initially called and calls appropriate update function
function remoteUpdate() { if(typeof(updateFunction) != "undefined" && updateFunction != "") eval(updateFunction); }
////////////////////
// Misc Functions //
////////////////////
// copy's the value from @from into all elements in the @to list
function copyValue(from,to) {
var thisValue = document.getElementById(from).value;
var toSplit = to.split(",");
var toLen = toSplit.length;
var t = 0;
for (t; t < toLen; t++) {
document.getElementById(toSplit[t]).value = thisValue;
}
}
// strips everything but numbers,letters,dashes,and underscores
function requireAlphaNumeric(obj) {
var regex = new RegExp("[^0-9A-Za-z_-]", "g");
var newValue = obj.value;
newValue = newValue.replace(regex,'');
if (obj.value != newValue) {
obj.value = newValue;
}
}
// strips all non-numeric characters from a form field value
function requireNumeric(obj) {
var numericType = (arguments.length > 1) ? arguments[1] : "real"; // real(can have decimal point) or integer(cannot have decimal point)
var allownegative = (arguments.length > 2 && arguments[2] == true) ? true : false;
var regex = new RegExp("[^0-9.]", "g");
var newValue = obj.value;
var isnegative = (allownegative == true && newValue.substring(0,1) == "-") ? true : false;
if(numericType == "integer") { regex = new RegExp("[^0-9]", "g"); }
newValue = newValue.replace(regex,'');
newValue = (isnegative == true) ? ("-" + newValue) : newValue;
if(numericType != "integer") { newValue = stripAdditionalDecimals(newValue); }
if(obj.value != newValue) { obj.value = newValue; }
}
// strip additional decimals
function stripAdditionalDecimals(item) {
var newItem = item;
var decimals = newItem.split(".");
var dLen = decimals.length;
var d = 0;
if (dLen > 1) {
for (d; d < dLen; d++) {
if (d == 0) {
newItem = decimals[d] + ".";
} else {
newItem = newItem + "" + decimals[d];
}
}
}
return newItem;
}
// copy checked true/false from @from into all elements in the @to list
function copyChecked(from,to) {
var thisValue = document.getElementById(from).checked;
var toSplit = to.split(",");
var toLen = toSplit.length;
var fromValue = "";
var byTagName = false;
var t = 0;
var e = "";
var x = 0;
var z = 0;
if(arguments.length >= 3 && (arguments[2] == true || arguments[2] == false)) { thisValue = arguments[2]; }
if(arguments.length >= 4) {
fromValue = arguments[3];
byTagName = true;
}
for(t; t < toLen; t++) {
if(byTagName == true) {
e = document.getElementsByName(toSplit[t]);
z = e.length;
x = 0;
for(x; x < z; x++) {
if(e[x].value == fromValue || fromValue == true) {
e[x].checked = thisValue;
}
}
} else {
e = document.getElementById(toSplit[t]);
e.checked = thisValue;
}
}
}
function changeInnerHTML(thisId,newHTML) { document.getElementById(thisId).innerHTML = newHTML; }
function changeMyStyle(itemName) { return false; }
function printElement(id) {
var content = jQuery("#" + id).html();
var iframehtml = "";
var iframedoc = "";
jQuery(document.body).append(iframehtml);
iframedoc = printHiddenFrame.document;
iframedoc.open();
iframedoc.write('
');
iframedoc.write(content);
iframedoc.write('');
iframedoc.close();
}
function javascriptWrite(item) { document.write(item); }
function CF_RunContent(src) { javascriptWrite(src); }
function getDom() {
var thisdom = 'ie';
if(document.getBoxObjectFor) { thisdom = 'ff'; }
else if(jQuery.browser.mozilla == true) { thisdom = 'ff'; }
else if(jQuery.browser.webkit == true) { thisdom = 'webkit'; }
else if(jQuery.browser.safari == true) { thisdom = 'safari'; }
else if(jQuery.browser.opera == true) { thisdom = 'opera'; }
return thisdom;
}
function joinLines(item) {
var result = item;
var regex = new RegExp("(\\s){1,}","g");
result = trim(result.replace(regex, " "));
return result;
}
function ListFind(list, value) {
var delimiter = (arguments.length > 2) ? arguments[2] : ",";
var result = 0;
var a = 0;
var z = 0;
var e = "";
if(typeof(list) != "object") {
try {
list = list.split(delimiter);
z = list.length;
} catch(e) { }
}
try {
z = list.length;
} catch(e) { }
for(a; a < z; a++) {
if(list[a] == value) {
result = a + 1;
a = z;
break;
}
}
return result;
}
String.prototype.stripHTML = function() {
var matchTag = /<(?:.|\s)*?>/g;
return this.replace(matchTag, "");
};
if(!Array.indexOf) {
Array.prototype.indexOf = function(obj){
for(var i=0; i