//////////////////////
// Global Variables //
//////////////////////
var domain = 'www.alternateimage.com';
////////////////////////////////
// Include other script files //
////////////////////////////////
// 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((Date.parse(compare2) - Date.parse(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;
}
// 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;
}
// Applet Wrapper
//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
//Generate applet object
function generateAppletObject(objAttrs, params, embedAttrs) {
var str = '';
document.write(str);
}
//Run content for applet.
//Arguments are the applet 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: 'archive', 'javaArchive.jar', 'width', '140'
//...and it continues on for all of the other attributes.
function runAppletContent() {
var ret = compileAppletAttributes(arguments);
generateAppletObject(ret.objAttrs, ret.params);
}
//Compile object attributes.
function compileAppletAttributes(args) {
var ret = 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) {
//Element Specific
case "type":
case "codebase":
case "codetype":
case "code":
case "alt":
case "archive":
case "title":
case "lang":
case "standby":
case "mayscript":
ret.objAttrs[args[i]] = args[i+1];
break;
//Events
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 "onresize":
case "onresizestart":
case "onresizeend":
case "onrowenter":
case "onrowexit":
case "onrowsdelete":
case "onrowsinserted":
case "onstart":
case "onscroll":
case "onbeforeeditfocus":
case "onactivate":
case "onbeforedeactivate":
case "ondeactivate":
ret.objAttrs[args[i]] = args[i+1];
break;
//HTML Standard
case "width":
case "height":
case "align":
case "vspace":
case "hspace":
case "class":
case "accesskey":
case "name":
case "id":
case "unselectable":
case "tabindex":
case "usemap":
case "border":
ret.objAttrs[args[i]] = args[i+1];
break;
//Params
default:
ret.objAttrs[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= 2 && arguments[1] == false) { clearField = false; }
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 = true;
if (arguments.length >= 2 && arguments[1] == false) { clearField = false; }
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= 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 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 = 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 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 == thisForm[i].defaultValue){
alert("Please enter " + thisForm[i].VALIDATENAME + " before submitting this form.");
thisForm[i].select();
thisForm[i].focus();
return false;
}
}
}
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);
}
////////////////////
// Math Functions //
////////////////////
// mod function
function mod(div,base) {
return Math.round(div - (Math.floor(div/base)*base));
}
////////////////////
// Date Functions //
////////////////////
// todays date
function now() {
return "2008-05-17";
}
///////////////////
// 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(thisComponent, thisMethod, thisArgument, thisForm) {
// initialize variables
var e = "";
var wddxFrame = document.getElementById('wddxFrame');
var newSrc = '/templates/admin/general/wddx_iframe.cfm';
var thisFormId = 'none';
// override the src argument
if (arguments.length >= 5) { newSrc = arguments[4]; }
// if FORM.id exists
if (thisForm.id) { thisFormId = thisForm.id; }
// change the src attribute of the iframe
newSrc = newSrc + '/thisComponent/' + thisComponent + '/thisMethod/' + thisMethod + '/thisArgument/' + thisArgument + '/thisForm/' + thisFormId.value;
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 = "real";
var regex = new RegExp("[^0-9.]", "g");
var newValue = obj.value;
var allownegative = (arguments.length >= 3 && arguments[2] == true) ? true : false;
var isnegative = (allownegative == true && newValue.substring(0,1) == "-") ? true : false;
// real(can have decimal point) or integer(cannot have decimal point)
if (arguments.length >= 2) {
numericType = arguments[1];
}
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 t = 0;
var e = "";
var x = 0;
var z = 0;
var fromValue = "";
var byTagName = false;
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) {
document.body.insertAdjacentHTML("beforeEnd", "");
var doc = printHiddenFrame.document;
doc.open();
doc.write('');
doc.write(document.getElementById(id).innerHTML);
doc.write('');
doc.close();
}
function javascriptWrite(item) {
document.write(item);
}
function CF_RunContent(src) {
javascriptWrite(src);
}
function getDom() {
var thisdom = 'ie';
if (document.getBoxObjectFor) { thisdom = 'ff'; }
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 = ",";
var result = 0;
var a = 0;
var z = 0;
var e = "";
if (arguments.length >= 3) {
delimiter = arguments[2];
}
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;
}