



var tmpcookie = new Date();
var chkcookie = (tmpcookie.getTime() + '');
document.cookie = "chkcookie=" + chkcookie + "; path=/";
if (document.cookie.indexOf(chkcookie,0) < 0) {
	window.location = 'errors/error_cookie.cfm';
}

function init() {

	

	
	

	
}




function toggleIframe() {
	var el = $('_hidden');
	if (el.height > 0) {
		el.height='0px;';
	} else {
		el.height='500px;';
	}
}


function popup(handler, tAction) {
	var screenWidth = screen.width;
	var screenHeight = screen.height;
	var popWidth = 500;
	var popHeight = 450;
	var left = (screenWidth/2) - (popWidth/2);
	var top = (screenHeight/2) - (popHeight/2);
	var winAttributes = 'width=' + popWidth + ',height=' + popHeight +
		',resizable=1,status=1,scrollbars=yes,titlebar=0,margin=0,' +
		'top=' + top + ',left=' + left + '';
	var popUpUrl = 'index.cfm/handler/' + handler + '/tAction/' + tAction;
	var win = null;
	win = window.open('','popUpUrl', winAttributes);
	win.focus();
	win.location.href = popUpUrl;
	if (win.opener == null) {
		win.opener = self;
	}
}

var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');

function showTime() {

	var timeString = $('theTime');
	var dateString = $('theDate');

	var now = new Date;

	/* Time */
	var hours = now.getHours();
	var meridian;
	if ((hours >= 12)) {
		meridian = 'pm';
	} else {
		meridian = 'am';
	}
	hours = hours % 12;
	if (hours == 0) {hours = 12}//Midnight

	var minutes = now.getMinutes();
	if (minutes < 10) {minutes = '0' + minutes}

	var seconds = now.getSeconds();
	if (seconds < 10) {seconds = '0' + seconds}

	/* Day */
	var year = now.getFullYear();
	var month = months[now.getMonth()];
	var day = days[now.getDay()];
	var dayOfMonth = now.getDate();

	/* Update */
	timeString.innerHTML = hours + ':' + minutes + ':' + seconds + meridian;
	dateString.innerHTML = day + ' ' + month + ' ' + dayOfMonth + ', ' + year;

	/* Recurse every second */
	var cd = setTimeout('showTime();', 1000);
}

function getCookie(name) {
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) {
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	return unescape(dc.substring(begin + prefix.length, end));
}



function toggleDisplay(elementName) {
	var el = $(elementName);
	var currentState = el.style.display;
	if (currentState == 'none') {
		el.style.display = '';
	} else {
		el.style.display = 'none';
	}
}
function toggleCheckboxes(obj, state) {
	for (var i=0; i < obj.length; i++ ) {
		obj[i].checked = state;
	}
}
function rtrim(s) {
	while ((s.substring(s.length-1,s.length)==' ') || (s.substring(s.length-1,s.length)=='\t') || (s.substring(s.length-1,s.length)=='\r')) {
		s = s.substring(0,s.length-1);
	}
	return s;
}
function ltrim(s) {
	while ( (s.substring(0, 1) == ' ') || (s.substring(0, 1) == '\t') || (s.substring(0, 1) == '\r') ) {
		s = s.substring(1, s.length);
	}
	return s;
}
function trim(s) {
	return ltrim(rtrim(s));
}

function decimalFormat(num) {
	return numberAddCommas(numberRound(num, 2));
}
function numberRound(num, decimalPlaces) {
	if (decimalPlaces == undefined) {
		decimalPlaces = 0;
	}
	var divisor = Math.pow(10, decimalPlaces);
	var result = Math.round(num*divisor)/divisor;
	result = '' + result;
	var dec = result.split('.')[1];
	
	if (dec == undefined) {
		result = '' + result + '' + '.00';
	} else {
		if (dec.length < decimalPlaces) {
			for (var i = 0; i < (decimalPlaces-dec.length); i++) {
				result = '' + result + '' + '0';
			}
		}
	}
	return result;
}
function numberAddCommas(num) {
	num += '';
	x = num.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function getCheckedIndex( obj ) {
	for (var i = 0; i < obj.length; i++) {
		if (obj[i].checked == true) {
			return i;
		}
	}
	return -1;
}

function listAppend( list, newVal, delimiter ) {
	var newList = '';
	if (trim(list).length == 0) {
		newList = '' + newVal;
	} else {
		newList = '' + list + delimiter + newVal;
	}
	return newList;
}
