﻿



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';
}

isIE = false;
if (document.all) {
	isIE = true;
}

function init() {

	

	
		showTime();
	

	
	

	if(niftyCheck()) {
		rounded("div#mainHeader","all","#000000","#128bce", "smooth"); // 1st value transparency, 2nd value color of top row, 3rd value 
		rounded("div#navBar","all","#e6f0ff","#79AEFF","small smooth");
		rounded("div#footer","all","#e6f0ff","#79AEFF","small smooth border #cccccc");
	}

	
	var SEARCH_SHOW = getCookie('SEARCH_SHOW');
	var ALERTS_SHOW = getCookie('ALERTS_SHOW');

	
			
		
}



		
	


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 = document.getElementById('theTime');
	var dateString = document.getElementById('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 setSearchCookie(cookieValue) {
	document.cookie = 'SEARCH_SHOW=' + cookieValue + ';path=/';
}
function setAlertsCookie(cookieValue) {
	document.cookie = 'ALERTS_SHOW=' + cookieValue + ';path=/';
}

function toggleDisplay(elementName) {
	var el = document.getElementById(elementName);
	var currentState = el.style.display;
	var toggleImageName = '';

	if (currentState == 'none') {
		el.style.display = '';
		if (elementName == 'searchTable') {
			document.cookie="SEARCH_SHOW=1;path=/";
		}
		if (elementName == 'alertsTable') {
			document.cookie="ALERTS_SHOW=1;path=/";
		}
	} else {
		el.style.display = 'none';
		if (elementName == 'searchTable') {
			document.cookie="SEARCH_SHOW=0;path=/";
		}
		if (elementName == 'alertsTable') {
			document.cookie="ALERTS_SHOW=0;path=/";
		}
	}

	if (elementName == 'searchTable') {
		toggleImageName = 'searchToggleImg';
		SEARCH_SHOW = getCookie('SEARCH_SHOW');	
		updateAlertToggleImage(SEARCH_SHOW, toggleImageName);		
	}
	if (elementName == 'alertsTable') {
		toggleImageName = 'alertToggleImg';
		ALERTS_SHOW = getCookie('ALERTS_SHOW');	
		updateAlertToggleImage(ALERTS_SHOW, toggleImageName);		
	}
}

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));
}
