/*
	VERSION:
		1.0.1	Added function 'createUID'. Updated 'createUID' so last 5 digits become last 4 digits. Misc syntax changes.
		1.0.0	Begin versioning.
*/
var CR = "\n";
var LF = "\r";
var TAB = "\t";
var BR = "<br />" + CR;

var arCountryList = ["Argentina","Austria","Australia","Aruba","Barbados","Belgium","Bermuda","Brazil","Bahamas","Canada","Cayman Islands","Chile","China","Costa Rica","Cyprus","Denmark","Egypt","Finland","France","France, Metropolitan","Germany","Great Britain","Greece","Guam","Guatemala","Hong Kong","Iceland","Ireland","Israel","Italy","Jamaica","Japan","Korea, Republic of","Kuwait","Luxembourg","Malawi","Malaysia","Mauritius","Mexico","Monaco","Netherlands","Netherlands Antilles","New Zealand","Norway","Panama","Peru","Philippines","Poland","Puerto Rico","Portugal","Saudi Arabia","Singapore","South Africa","Spain","Sweden","Switzerland","Taiwan","Thailand","Turkey","Trinidad and Tobago","United Arab Emirates","United States","US Minor Outlying Islands","Venezuela","Virgin Islands(U.S.)"];
var arCountryListAbbr = ["AR","AT","AU","AW","BB","BE","BM","BR","BS","CA","KY","CL","CN","CR","CY","DK","EG","FI","FR","FX","DE","GB","GR","GU","GT","HK","IS","IE","IL","IT","JM","JP","KR","KW","LU","MW","MY","MU","MX","MC","NL","AN","NZ","NO","PA","PE","PH","PL","PR","PT","SA","SG","ZA","ES","SE","CH","TW","TH","TR","TT","AE","US","UM","VE","VI"];
var arStateList = ["AK","AL","AR","AZ","CA","CO","CT","DC","DE","FL","GA","HI","IA","ID","IL","IN","KS","KY","LA","MA","MD","ME","MI","MN","MO","MS","MT","NC","ND","NE","NH","NJ","NM","NV","NY","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VA","VT","WA","WI","WV","WY"];


//this function checks for null, undefined, or zero length string value
function isNothing(v)	{ 
							v = new String(v);
							return ( v == 'undefined' || v == 'null' || v.length == 0 ? true : false );
						}

//	VARIABLES TO USE WITH DHTML OBJECTS
//------------------------------------------------------------------------------------------------------------------------------------------------------------
var isDOM = (document.getElementById ? true : false); 
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);

//the same as $(elem) in prototype.js
//deprecated, saved for backward compatibility
function getRef(id) {
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
};
function getSty(id) {
	return (isNS4 ? getRef(id) : getRef(id).style);
};

//------------------------------------------------------------------------------------------------------------------------------------------------------------
function createUID(rdm) {
	// UID will be output in this format yyyymmddhhmmxxxx
	// rdm is an option string to be used for the last five characters of UID
	// if rdm is false, then this function uses a random number from 0 - 9999 for xxxx
	// final rdm string will be padded with leading zeros if string-length < 4
	// NOTE: if createUID is to be called rapidly in succession (in a loop for instance)
	//		 then rdm should be passed as an iterator from 0 - 9999 to guarantee a unique id
	var d = new Date();
	var arUID = [d.getFullYear()];
	var	n = d.getMonth(); n = (n < 10 ? "0" + n : n);
		arUID.push(n);
		n = d.getDate(); n = (n < 10 ? "0" + n : n);
		arUID.push(n);
		n = d.getHours(); n = (n < 10 ? "0" + n : n);
		arUID.push(n);
		n = d.getMinutes(); n = (n < 10 ? "0" + n : n);
		arUID.push(n);
		
	if(!rdm) {
		n = d.getMilliseconds();
	} else {
		n = (rdm+"").substr(0, 4);
	}
	for(var i = 4-n.length-1; i >= 0; i--) {
		n = "0" + n;
	}
	return arUID.join("") + n;
};