/*
	Standards Compliant rollover script 
	Author : Daniel Nolan 
	www.bleedingego.co.uk/webdev.php

	On the page use the class imgover -	
	<img src="whatever.gif" class="imgover">
	and the javascript substitutes whatever-on.gif 
*/

function initrollovers() {
	if (!document.getElementById) return;
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');
	
	for (var i = 0; i < aImages.length; i++) {
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '-on'+ftype);
			aImages[i].setAttribute('hsrc', hsrc);
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('-on'+ftype, ftype);
				this.setAttribute('src', sTempSrc); 
			}
		}
	}
}

<!--
// The purpose of this function is to center the body of the site in browser windows
// greater than 800x600. With any luck, it should only have to affect the background image 
// and the primary div. The style sheet should take care of the rest of the pieces.
// Note that the style sheet has initial positioning info for the background and div. 
// This ensures that the page rests on the left side if javascript is disabled.

function centerPage() {
	var bdy = document.getElementById("entirety");
	var ctt = document.getElementById("content");
	var ggs = document.getElementById("searcher");
	var scw = window.screen.availWidth;
	var dcw = document.body.clientWidth;
	
	//alert(dcw);
	
	var contentWidth = 785;
	//var bgStartPt = -1190;
	var cttStartPt = 0;
	
	var shiftPt = 0;
	
	if(dcw <= 800) {
		var bgStartPt = -10;
		bdy.style['backgroundImage'] = "url(http://www.cbnco.com/images/CBN_bg_800.gif)";
	} else if (dcw <= 1200) {
		var bgStartPt = -291;
		bdy.style['backgroundImage'] = "url(http://www.cbnco.com/images/CBN_bg_1024.jpg)";
	} else {
		var bgStartPt = -1190;
		bdy.style['backgroundImage'] = "url(http://www.cbnco.com/images/CBN_bkgd.gif)";
	}
	
	shiftPt = (dcw - contentWidth)/2;
	bgStartPt += shiftPt;
	cttStartPt += shiftPt;
	
	//bdy.style['backgroundImage'] = "url(http://webdemo/images/CBN_bkgd.gif)";
	bdy.style['backgroundPosition'] = bgStartPt + "px 0%";
	bdy.style['backgroundRepeat'] = "no-repeat";
	bdy.style['backgroundAttachment'] = "fixed";
	ctt.style['left'] = cttStartPt + "px";
	ctt.style.marginLeft = "auto";
	ctt.style.marginRight = "auto";
	ggs.style['display'] = "block";

}

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

function cSupportAction(form) {
	//var cSupport = document.getElementById("supportForm");
	if(form.site.value == "financial" || form.site.value == "cbnlottery") {
		var hProto = "http";
	} else {
		var hProto = "https";
	}
	
	form.action = hProto + "://support.cbnco.com/" + form.site.value + "/login.php3";
	//this.submit;
	//alert (form.action);
}

// code for PIMS diagram using JSON (JavaScript Object Notation)
// care of A List Apart - A More Accessible Map by Seth Duffey

var mapMaker = {
  offsetX:     5, // tooltip X offset
  offsetY:     5,  // tooltip Y offset
	element: false,
	DLs:     false,
	DTs:     false,
	on:      false,

	/* constructor - sets events */
	init: function(){ // sets up the maps
		var i  = 0;
		var ii = 0;
		var category;
		mapMaker.DLs = document.getElementsByTagName('dl');
		mapMaker.DTs = document.getElementsByTagName('dt');

		if(mapMaker.on == false) {
			while( mapMaker.DLs.length > i ){
				if( mapMaker.DLs[i].className == 'diagram' ){
					mapMaker.DLs[i].className = 'diagram on';
					mapMaker.stripWhitespace( mapMaker.DLs[i] );
					mapMaker.stripWhitespace( mapMaker.DTs[i] );
					while( mapMaker.DTs.length > ii ){
						category = mapMaker.DTs[ii].firstChild;
						mapMaker.addEvt( category, 'mouseover', mapMaker.showTooltip );
						mapMaker.addEvt( category, 'mouseout', mapMaker.hideTooltip );
						mapMaker.addEvt( category, 'focus', mapMaker.showTooltip );
						mapMaker.addEvt( category, 'blur', mapMaker.hideTooltip );
						ii++;
					};
					ii = 0;
				}
				i++;
			};
			mapMaker.on = true;
		};
	},
  showTooltip: function(){	// shows the tooltip
		var a = this;
		//Find DD to display - based on currently hovered anchor move to parent DT then next sibling DD
		var tooltip = a.parentNode.nextSibling;
		mapMaker.element = tooltip;//set for the hideTooltip
		// get width and height of background map
		var mapWidth  = tooltip.parentNode.offsetWidth;
		var mapHeight = tooltip.parentNode.offsetHeight;
		//get width and height of the DD
		var toolTipWidth = tooltip.offsetWidth;
		var toolTipHeight = tooltip.offsetHeight;
		//figure out where tooltip should be based on point location
		var newX = a.offsetLeft + mapMaker.offsetX + a.offsetWidth;
		var newY = a.offsetTop + mapMaker.offsetY - toolTipHeight;
		//check if tooltip fits map width 
		//if ((newX + toolTipWidth) > mapWidth) {
		//	tooltip.style.left = newX-toolTipWidth-24 + 'px';
		//} else {
			tooltip.style.left = newX + 'px';
		//};
		//check if tooltip fits map height 
		//if ((newY + toolTipHeight) > mapHeight) {
		//	tooltip.style.top = newY-toolTipHeight-14 + 'px';
		//} else {
			tooltip.style.top = newY + 'px';
		//};
  },
  hideTooltip: function(){	// hides the tooltip
		mapMaker.element.style.left = '-9999px';
  },
  addEvt: function( element, type, handler ){	// adds the events
		// assign each event handler a unique ID
		if (!handler.$$guid) handler.$$guid = mapMaker.addEvt.guid++;
		// create a hash table of event types for the element
		if (!element.events) element.events = {};
		// create a hash table of event handlers for each element/event pair
		var handlers = element.events[type];
		if (!handlers) {
			handlers = element.events[type] = {};
			// store the existing event handler (if there is one)
			if (element["on" + type]) {
				handlers[0] = element["on" + type];
			};
		};
		// store the event handler in the hash table
		handlers[handler.$$guid] = handler;
		// assign a global event handler to do all the work
		element["on" + type] = mapMaker.handleEvent;
  },
	handleEvent: function(event) {
		var returnValue = true;
		// grab the event object (IE uses a global event object)
		event = event || mapMaker.fixEvent(window.event);
		// get a reference to the hash table of event handlers
		var handlers = this.events[event.type];
		// execute each event handler
		for (var i in handlers) {
			this.$$handleEvent = handlers[i];
			if (this.$$handleEvent(event) === false) {
				returnValue = false;
			};
		};
		return returnValue;
	},
	fixEvent: function(event) {
		// add W3C standard event methods
		event.preventDefault = mapMaker.fixEvent.preventDefault;
		event.stopPropagation = mapMaker.fixEvent.stopPropagation;
		return event;
	},
	stripWhitespace: function( el ){
		for(var i = 0; i < el.childNodes.length; i++){
			var node = el.childNodes[i];
			if( node.nodeType == 3 && !/\S/.test(node.nodeValue)) {
				node.parentNode.removeChild(node);
			};
		};
	}
};
mapMaker.fixEvent.preventDefault = function() {this.returnValue = false;};
mapMaker.fixEvent.stopPropagation = function() {this.cancelBubble = true;};
mapMaker.addEvt.guid = 1;

// set event listeners */


if (typeof window.addEventListener != 'undefined')
{
	/* Safari, Konqueror, etc. */
	window.addEventListener("load", initrollovers, false);
	window.addEventListener("load", mapMaker.init, false);
	window.addEventListener("load", centerPage, false);
	window.addEventListener("resize", centerPage, false);
}
else if (typeof document.addEventListener != 'undefined')
{
	/* Mozilla */
	document.addEventListener("DOMContentLoaded", mapMaker.init, null);
	document.addEventListener("DOMContentLoaded", centerPage, null);
	document.addEventListener("DOMContentLoaded", initrollovers, null);
	document.addEventListener("onresize", centerPage, null);
}
else if (typeof window.attachEvent != 'undefined')
{
	/* Internet Explorer */
	window.attachEvent("onload", sfHover);
	window.attachEvent("onload", mapMaker.init);
	window.attachEvent("onload", initrollovers);
	window.attachEvent("onload", centerPage);
	window.attachEvent("onresize", centerPage);
}
else
{
	window.alert('Failed to attach an Event Listener\n\n Please Report');
}