function Initialize(swap)
{
    if (swap == '1')
    {
        var rnd_no = 1 + Math.round(14 * Math.random());
        
        if (document.getElementById("Header_Img") != null)
        {
            el = document.getElementById("Header_Img");
            el.className = el.className + ' bkg' + rnd_no;
        }
    }
	
	if ( Get_Cookie('currentsize') ) {
	currentsize = Get_Cookie('currentsize');
	ChangeSize(currentsize)
	}
	else {
		currentsize = '0'
	}
	externalLinks();
	document.getElementById("searchFocus").getElementsByTagName("input")[0].focus();
	 KidSpaceLadder();
}


function externalLinks() 
{
    if (!document.getElementsByTagName) 
        return;
    
    var anchors = document.getElementsByTagName("a");
 
    for (var i=0; i<anchors.length; i++) 
    {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
            anchor.target = "_blank";
    }
}

function KidSpaceLadder() {
	if(document.getElementById("LadderHeightID") != null){
		
		//alert(document.getElementById('Template_Space').clientHeight)
		//pageHeight = document.getElementById("LadderHeightID").clientHeight;
		pageHeight = document.getElementById('Template_Space').clientHeight;
		pageHeight -= 1075;
		
		document.getElementById("LadderRepeat").style.height = pageHeight+"px";
	}
}

var UFO = {
	req: ["movie", "width", "height", "majorversion", "build"],
	opt: ["play", "loop", "menu", "quality", "scale", "salign", "wmode", "bgcolor", "base", "flashvars", "devicefont", "allowscriptaccess", "seamlesstabbing"],
	optAtt: ["id", "name", "align"],
	optExc: ["swliveconnect"],
	ximovie: "ufo.swf",
	xiwidth: "215",
	xiheight: "138",
	ua: navigator.userAgent.toLowerCase(),
	pluginType: "",
	fv: [0,0],
	foList: [],
		
	create: function(FO, id) {
		if (!UFO.uaHas("w3cdom") || UFO.uaHas("ieMac")) return;
		UFO.getFlashVersion();
		UFO.foList[id] = UFO.updateFO(FO);
		UFO.createCSS("#" + id, "visibility:hidden;");
		UFO.domLoad(id);
	},

	updateFO: function(FO) {
		if (typeof FO.xi != "undefined" && FO.xi == "true") {
			if (typeof FO.ximovie == "undefined") FO.ximovie = UFO.ximovie;
			if (typeof FO.xiwidth == "undefined") FO.xiwidth = UFO.xiwidth;
			if (typeof FO.xiheight == "undefined") FO.xiheight = UFO.xiheight;
		}
		FO.mainCalled = false;
		return FO;
	},

	domLoad: function(id) {
		var _t = setInterval(function() {
			if ((document.getElementsByTagName("body")[0] != null || document.body != null) && document.getElementById(id) != null) {
				UFO.main(id);
				clearInterval(_t);
			}
		}, 250);
		if (typeof document.addEventListener != "undefined") {
			document.addEventListener("DOMContentLoaded", function() { UFO.main(id); clearInterval(_t); } , null); // Gecko, Opera 9+
		}
	},

	main: function(id) {
		var _fo = UFO.foList[id];
		if (_fo.mainCalled) return;
		UFO.foList[id].mainCalled = true;
		document.getElementById(id).style.visibility = "hidden";
		if (UFO.hasRequired(id)) {
			if (UFO.hasFlashVersion(parseInt(_fo.majorversion, 10), parseInt(_fo.build, 10))) {
				if (typeof _fo.setcontainercss != "undefined" && _fo.setcontainercss == "true") UFO.setContainerCSS(id);
				UFO.writeSWF(id);
			}
			else if (_fo.xi == "true" && UFO.hasFlashVersion(6, 65)) {
				UFO.createDialog(id);
			}
		}
		document.getElementById(id).style.visibility = "visible";
	},
	
	createCSS: function(selector, declaration) {
		var _h = document.getElementsByTagName("head")[0]; 
		var _s = UFO.createElement("style");
		if (!UFO.uaHas("ieWin")) _s.appendChild(document.createTextNode(selector + " {" + declaration + "}")); // bugs in IE/Win
		_s.setAttribute("type", "text/css");
		_s.setAttribute("media", "screen"); 
		_h.appendChild(_s);
		if (UFO.uaHas("ieWin") && document.styleSheets && document.styleSheets.length > 0) {
			var _ls = document.styleSheets[document.styleSheets.length - 1];
			if (typeof _ls.addRule == "object") _ls.addRule(selector, declaration);
		}
	},
	
	setContainerCSS: function(id) {
		var _fo = UFO.foList[id];
		var _w = /%/.test(_fo.width) ? "" : "px";
		var _h = /%/.test(_fo.height) ? "" : "px";
		UFO.createCSS("#" + id, "width:" + _fo.width + _w +"; height:" + _fo.height + _h +";");
		if (_fo.width == "100%") {
			UFO.createCSS("body", "margin-left:0; margin-right:0; padding-left:0; padding-right:0;");
		}
		if (_fo.height == "100%") {
			UFO.createCSS("html", "height:100%; overflow:hidden;");
			UFO.createCSS("body", "margin-top:0; margin-bottom:0; padding-top:0; padding-bottom:0; height:100%;");
		}
	},

	createElement: function(el) {
		return (UFO.uaHas("xml") && typeof document.createElementNS != "undefined") ?  document.createElementNS("http://www.w3.org/1999/xhtml", el) : document.createElement(el);
	},

	createObjParam: function(el, aName, aValue) {
		var _p = UFO.createElement("param");
		_p.setAttribute("name", aName);	
		_p.setAttribute("value", aValue);
		el.appendChild(_p);
	},

	uaHas: function(ft) {
		var _u = UFO.ua;
		switch(ft) {
			case "w3cdom":
				return (typeof document.getElementById != "undefined" && typeof document.getElementsByTagName != "undefined" && (typeof document.createElement != "undefined" || typeof document.createElementNS != "undefined"));
			case "xml":
				var _m = document.getElementsByTagName("meta");
				var _l = _m.length;
				for (var i = 0; i < _l; i++) {
					if (/content-type/i.test(_m[i].getAttribute("http-equiv")) && /xml/i.test(_m[i].getAttribute("content"))) return true;
				}
				return false;
			case "ieMac":
				return /msie/.test(_u) && !/opera/.test(_u) && /mac/.test(_u);
			case "ieWin":
				return /msie/.test(_u) && !/opera/.test(_u) && /win/.test(_u);
			case "gecko":
				return /gecko/.test(_u) && !/applewebkit/.test(_u);
			case "opera":
				return /opera/.test(_u);
			case "safari":
				return /applewebkit/.test(_u);
			default:
				return false;
		}
	},
	
	getFlashVersion: function() {
		if (UFO.fv[0] != 0) return;  
		if (navigator.plugins && typeof navigator.plugins["Shockwave Flash"] == "object") {
			UFO.pluginType = "npapi";
			var _d = navigator.plugins["Shockwave Flash"].description;
			if (typeof _d != "undefined") {
				_d = _d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
				var _m = parseInt(_d.replace(/^(.*)\..*$/, "$1"), 10);
				var _r = /r/.test(_d) ? parseInt(_d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
				UFO.fv = [_m, _r];
			}
		}
		else if (window.ActiveXObject) {
			UFO.pluginType = "ax";
			try { // avoid fp 6 crashes
				var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
			}
			catch(e) {
				try { 
					var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
					UFO.fv = [6, 0];
					_a.AllowScriptAccess = "always"; // throws if fp < 6.47 
				}
				catch(e) {
					if (UFO.fv[0] == 6) return;
				}
				try {
					var _a = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
				}
				catch(e) {}
			}
			if (typeof _a == "object") {
				var _d = _a.GetVariable("$version"); // bugs in fp 6.21/6.23
				if (typeof _d != "undefined") {
					_d = _d.replace(/^\S+\s+(.*)$/, "$1").split(",");
					UFO.fv = [parseInt(_d[0], 10), parseInt(_d[2], 10)];
				}
			}
		}
	},

	hasRequired: function(id) {
		var _l = UFO.req.length;
		for (var i = 0; i < _l; i++) {
			if (typeof UFO.foList[id][UFO.req[i]] == "undefined") return false;
		}
		return true;
	},
	
	hasFlashVersion: function(major, release) {
		return (UFO.fv[0] > major || (UFO.fv[0] == major && UFO.fv[1] >= release)) ? true : false;
	},

	writeSWF: function(id) {
		var _fo = UFO.foList[id];
		var _e = document.getElementById(id);
		if (UFO.pluginType == "npapi") {
			if (UFO.uaHas("gecko") || UFO.uaHas("xml")) {
				while(_e.hasChildNodes()) {
					_e.removeChild(_e.firstChild);
				}
				var _obj = UFO.createElement("object");
				_obj.setAttribute("type", "application/x-shockwave-flash");
				_obj.setAttribute("data", _fo.movie);
				_obj.setAttribute("width", _fo.width);
				_obj.setAttribute("height", _fo.height);
				var _l = UFO.optAtt.length;
				for (var i = 0; i < _l; i++) {
					if (typeof _fo[UFO.optAtt[i]] != "undefined") _obj.setAttribute(UFO.optAtt[i], _fo[UFO.optAtt[i]]);
				}
				var _o = UFO.opt.concat(UFO.optExc);
				var _l = _o.length;
				for (var i = 0; i < _l; i++) {
					if (typeof _fo[_o[i]] != "undefined") UFO.createObjParam(_obj, _o[i], _fo[_o[i]]);
				}
				_e.appendChild(_obj);
			}
			else {
				var _emb = "";
				var _o = UFO.opt.concat(UFO.optAtt).concat(UFO.optExc);
				var _l = _o.length;
				for (var i = 0; i < _l; i++) {
					if (typeof _fo[_o[i]] != "undefined") _emb += ' ' + _o[i] + '="' + _fo[_o[i]] + '"';
				}
				_e.innerHTML = '<embed type="application/x-shockwave-flash" src="' + _fo.movie + '" width="' + _fo.width + '" height="' + _fo.height + '" pluginspage="http://www.macromedia.com/go/getflashplayer"' + _emb + '></embed>';
			}
		}
		else if (UFO.pluginType == "ax") {
			var _objAtt = "";
			var _l = UFO.optAtt.length;
			for (var i = 0; i < _l; i++) {
				if (typeof _fo[UFO.optAtt[i]] != "undefined") _objAtt += ' ' + UFO.optAtt[i] + '="' + _fo[UFO.optAtt[i]] + '"';
			}
			var _objPar = "";
			var _l = UFO.opt.length;
			for (var i = 0; i < _l; i++) {
				if (typeof _fo[UFO.opt[i]] != "undefined") _objPar += '<param name="' + UFO.opt[i] + '" value="' + _fo[UFO.opt[i]] + '" />';
			}
			var _p = window.location.protocol == "https:" ? "https:" : "http:";
			_e.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + _objAtt + ' width="' + _fo.width + '" height="' + _fo.height + '" codebase="' + _p + '//download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + _fo.majorversion + ',0,' + _fo.build + ',0"><param name="movie" value="' + _fo.movie + '" />' + _objPar + '</object>';
		}
	},
		
	createDialog: function(id) {
		var _fo = UFO.foList[id];
		UFO.createCSS("html", "height:100%; overflow:hidden;");
		UFO.createCSS("body", "height:100%; overflow:hidden;");
		UFO.createCSS("#xi-con", "position:absolute; left:0; top:0; z-index:1000; width:100%; height:100%; background-color:#fff; filter:alpha(opacity:75); opacity:0.75;");
		UFO.createCSS("#xi-dia", "position:absolute; left:50%; top:50%; margin-left: -" + Math.round(parseInt(_fo.xiwidth, 10) / 2) + "px; margin-top: -" + Math.round(parseInt(_fo.xiheight, 10) / 2) + "px; width:" + _fo.xiwidth + "px; height:" + _fo.xiheight + "px;");
		var _b = document.getElementsByTagName("body")[0];
		var _c = UFO.createElement("div");
		_c.setAttribute("id", "xi-con");
		var _d = UFO.createElement("div");
		_d.setAttribute("id", "xi-dia");
		_c.appendChild(_d);
		_b.appendChild(_c);
		var _mmu = window.location;
		if (UFO.uaHas("xml") && UFO.uaHas("safari")) {
			var _mmd = document.getElementsByTagName("title")[0].firstChild.nodeValue = document.getElementsByTagName("title")[0].firstChild.nodeValue.slice(0, 47) + " - Flash Player Installation";
		}
		else {
			var _mmd = document.title = document.title.slice(0, 47) + " - Flash Player Installation";
		}
		var _mmp = UFO.pluginType == "ax" ? "ActiveX" : "PlugIn";
		var _uc = typeof _fo.xiurlcancel != "undefined" ? "&xiUrlCancel=" + _fo.xiurlcancel : "";
		var _uf = typeof _fo.xiurlfailed != "undefined" ? "&xiUrlFailed=" + _fo.xiurlfailed : "";
		UFO.foList["xi-dia"] = { movie:_fo.ximovie, width:_fo.xiwidth, height:_fo.xiheight, majorversion:"6", build:"65", flashvars:"MMredirectURL=" + _mmu + "&MMplayerType=" + _mmp + "&MMdoctitle=" + _mmd + _uc + _uf };
		UFO.writeSWF("xi-dia");
	},

	expressInstallCallback: function() {
		var _b = document.getElementsByTagName("body")[0];
		var _c = document.getElementById("xi-con");
		_b.removeChild(_c);
		UFO.createCSS("body", "height:auto; overflow:auto;");
		UFO.createCSS("html", "height:auto; overflow:auto;");
	},

	cleanupIELeaks: function() {
		var _o = document.getElementsByTagName("object");
		var _l = _o.length
		for (var i = 0; i < _l; i++) {
			_o[i].style.display = "none";
			for (var x in _o[i]) {
				if (typeof _o[i][x] == "function") {
					_o[i][x] = null;
				}
			}
		}
	}

};

if (typeof window.attachEvent != "undefined" && UFO.uaHas("ieWin")) {
	window.attachEvent("onunload", UFO.cleanupIELeaks);
}


function setCookie(name, value)
{
  document.cookie =
    name+"="+escape(value);
}
function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}



function ChangeSize(x)
{
	if(currentsize == 0){
		document.body.style.fontSize='100.1%';
		document.getElementById("Nav").style.fontSize='75%';
		currentsize = 1;
		setCookie("currentsize", 0);
	}
	else if(currentsize == 1){
		document.body.style.fontSize='110.1%';
		document.getElementById("Nav").style.fontSize='75%';
		currentsize = 2;
		setCookie("currentsize", 1);
	}
	else{
		document.body.style.fontSize='70.1%';
		document.getElementById("Nav").style.fontSize='100%';
		currentsize = '0';
		setCookie("currentsize", 2);
	}
};

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}

function printThisPage()
{
 if (window.print != null)
 {
  window.print();
 }
 else
 {
  alert("Please select the Print option from the File menu or press 'Control P' as your browser doesn't support this option");
 }
}

function openAnnualReport() {
	window.open("/flash/AnnualReport.htm","AnnualReport","toolbar=no,width="+screen.width+",height="+screen.height+",top=0,left=0");
}

var bCancelHDI = false;

function wait(delay){
	string="pauseforalert("+delay+");";
	setTimeout(string,delay);
}
function pauseforalert(delay){
	if(bCancelHDI == false) {
		document.getElementById("HowDoI_List").style.display = 'none';
	}
}
function showHowDoI() {
	document.getElementById("HowDoI_List").style.display = 'block';
}
function hideHowDoI() {
	bCancelHDI = false;
	wait(2000);
};

function cancelHideHowDoI() {
	bCancelHDI = true;
}

function sfHover() {
	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"), "");
		}
	}
}


//Class: Carousel
//Assists in the rotation of Carousel Items
//IN DEVELOPMENT - NEED DEBUG ON BALANCE
var carousel = Class.create({

	initialize: function(container, direction){
		//console.log('Initialize Carousel');
		
		//Set DOM Containers
		//console.log('Set DOM Containers');
		this.carouselContainer = container;
		this.carouselItems = this.carouselContainer.select('> li');
		this.carouselContainer.setStyle({
			position: 'relative'
		});
		
		//Set Size Constraints
		//console.log('Set Size Constraints');
		this.size = this.carouselItems.size();
		this.currentItem = 0;
		this.previousItem = this.size;
		
		//Set Dimensions & Positioning
		//console.log('Set Dimensions & Positioning');
		this.dimensions = $H(this.carouselContainer.getDimensions());
		
		if(direction == 'vertical'){
			this.measure = 'height';
		}
		else {
			this.measure = 'width';
		}
		
		//console.log('Carousel Items', this.carouselItems);
		this.itemDimensions = $H(this.carouselItems[0].getDimensions());
		this.lastPosition = 0;
		
		var carouselPointer = this;
		
	
	},
	
	get: function(itemIndex) {
		return this.carouselItems[itemIndex]
	},
	getChildren: function(){
		return this.carouselItems;
	},
	getIndex: function(){
		return { currentIndex: this.currentItem, previousIndex: this.previousItem};
	},
	move: function(itemMove){
		this.previousItem = this.currentItem;
		this.currentItem = (this.size + ((this.currentItem + itemMove) % this.size)) % this.size; //incrementally step up the index
		
		return { current: this.get(this.currentItem), previous: this.carouselItems[this.previousItem], currentIndex: this.currentItem, previousIndex: this.previousItem };
	},
	getCurrentItem: function(){
		return { current: this.carouselItems[this.currentItem], currentIndex: this.currentItem };
	}
});




function alertBox(){
	var alertBox = $('alertBox');
	var pageHeight = $('Template_Home').getHeight();
	
	if(!alertBox) return false;
	var isCookie = readCookie('CCPLAfterDark');
	
	if(isCookie == 'NeverAgain'){
		alertBox.addClassName('hide');
		event.stop();
	}
	
	alertBox.addClassName('show');
	
	alertBox.setStyle({
		height: pageHeight + 'px'
	});
	
	var highlights = $$('#alertBox div.highlight');
	
	heightBalance(highlights, 3);
	
	//var bookShelfDrawer = $('shelfContents');
	//var bookShelfDrawerLid = $('shelfContents').next('h3');
	var bookShelfGallery = $('bookCarousel');
	
	if(bookShelfGallery.select('li').size() < 2) return false;
	
	var galleryCarousel = new carousel(bookShelfGallery, 'horizontal');
	var galleryItems = galleryCarousel.getChildren();
		
	var currentPosition = 0;
	var itemWidth = galleryItems[0].getWidth() + 28;
	var minPosition = 0 - itemWidth;
	var maxPosition = 0;
	
	galleryItems.each(function(galleryItem){
		
		//window.log(galleryItem.measure('width'));
		//window.log(galleryItem.getDimensions());
		
		//handle truncating content.
		/*var bookTitle = galleryItem.down('dl').down('dd.title').innerHTML;
		bookTitle = bookTitle.truncate(145, ' [...]');
		galleryItem.down('dl').down('dd.title').update(bookTitle);
		
		var bookSummary = galleryItem.down('dl').down('dd.summary').innerHTML;
		bookSummary = bookSummary.truncate(310, ' [...]');
		galleryItem.down('dl').down('dd.summary').update(bookSummary);
		
		var bookLink = galleryItem.down('dl').down('dd.more').innerHTML;
		galleryItem.down('dl').down('dd.summary').update(bookSummary + ' ' + bookLink);*/
		
		
		galleryItem.position = currentPosition;
		
		galleryItem.setStyle({
			position: 'absolute',
			left: galleryItem.position + 'px'
		});
		
		maxPosition = currentPosition;
		
		currentPosition = currentPosition + itemWidth;
		
	});
	
	var galleryLock = false;
	
	//window.log(galleryItems);
	
	var carouselNavContainer = new Element('ul').writeAttribute('id','carouselNav');
	var carouselNavElements = [];
	carouselNavElements[0] = 'Previous';
	carouselNavElements[1] = 'Next';
	
	bookShelfGallery.insert({
		after: carouselNavContainer
	});
	
	carouselNavElements.each(function(carouselNavElement, navIndex){
		var el = new Element('li');
		el.innerHTML = carouselNavElement;
		
		var navMove = (navIndex * 2) - 1;
		
		carouselNavContainer.insert({
			bottom: el
		});
		
		el.observe('click', function(event){
		
			var queue = Effect.Queues.get('galleryQueue');
			//window.log(queue);
			if(queue.effects.size() > 0){
				event.stop();
				return false;
			}
			
			var moveInfo = galleryCarousel.move(navMove);
			//window.log(moveInfo.previousIndex);
			
			if(navMove == -1){
				//window.log('previous', moveInfo.currentIndex);
				
				galleryItems[moveInfo.currentIndex].setStyle({
					left: minPosition + 'px'
				});
				
				galleryItems[moveInfo.currentIndex].position = minPosition;
			}

			galleryItems.each(function(galleryItem, index){
				var newPosition = galleryItem.position - (itemWidth * navMove);
				

				
				/*galleryItem.setStyle({
					left: newPosition + 'px'
				});*/
				
				new Effect.Tween(galleryItem, galleryItem.position, newPosition, {
					duration: .4,
					transition: Effect.Transitions.sinoidal,
					beforeStart: function(){
						
					},
					afterFinish: function(){
						//window.log('Index', index);
						if(navMove == 1 && index == galleryItems.size() - 1){
							//window.log('next and previous index is ', moveInfo.previousIndex);
							galleryItems[moveInfo.previousIndex].setStyle({
								left: maxPosition + 'px'
							});
							
							//window.log('Setting Previous Item to ', maxPosition, 'from ', galleryItems[moveInfo.previousIndex].position);
							galleryItems[moveInfo.previousIndex].position = maxPosition;
							
						}
						else {
							//window.log('Setting Item to ', newPosition, 'from ', galleryItem.position);
							
						}
						if(index != moveInfo.previousIndex && navMove == 1){
							galleryItem.position = newPosition;
						}
						else if (navMove == -1) {
							galleryItem.position = newPosition;
						}
						
					},
					queue: {scope: 'galleryQueue'}
				},
				function(value){
					this.setStyle({
						left: value + 'px'
					});
				});
				
				//galleryItem.position = newPosition;
			});
			
			
			event.stop();
		});
	});
	
	
	carouselNavContainer.firstChild.addClassName('first');
	
	//Start functionality for controlling detail preview, drawer opening, etc.
	
	var galleryLock = false;
	
	//Handle closing, fires ccpl:closeAlertBox
	var closeButton = new Element('p').addClassName('close').update('Close Window');
	var closePanel = new Element('div').addClassName('closePanel').update('&nbsp;');
	
	closePanel.setStyle({
		height: pageHeight + 'px'
	});
	
	alertBox.down('div').insert({
		top: closeButton
	});
	
	alertBox.insert({
		top: closePanel
	});
	closePanel.observe('click', function(event){
		closePanel.fire('ccpl:closeAlertBox');
	});
	
	closeButton.observe('click', function(event){
		closeButton.fire('ccpl:closeAlertBox');
	});
	
	var supportNavs = $$('ul.supportNav');
	
	supportNavs.each(function(supportNav){
		var supportLinks = supportNav.select('li');
		
		var neverShowLink = supportLinks[2];
		var goHomeLink = supportLinks[1];
		var showHelpLink = supportLinks[0];
		
		neverShowLink.observe('click', function(event){
			closeButton.fire('ccpl:closeAlertBox');
			//Set Cookie!
			setCookie( 'CCPLAfterDark', 'NeverAgain', 30, '/', '', '' );
			event.stop();
		});
	
		goHomeLink.observe('click', function(event){
			goHomeLink.fire('ccpl:closeAlertBox');
		});
		
		showHelpLink.observe('click', function(event){
			var detailText = $('helpText');
			
			if(!detailText.hasClassName('open')){
				detailText.addClassName('open');
				showHelpLink.down('a').update('Hide this.');
				
			} else {
				detailText.removeClassName('open');
				showHelpLink.down('a').update('What is this?');
			}
			event.stop();
		});
	});
	
	var highlightInputs = $$('#alertBox div.highlight input');
	
	highlightInputs.each(function(highlightInput){
		highlightInput.initialValue = highlightInput.value;
		highlightInput.observe('focus', function(event) {
			if(highlightInput.value == highlightInput.initialValue){
				highlightInput.clear();
			}
		});
		highlightInput.observe('blur', function(event){
			if(highlightInput.value.blank() == true) {
				highlightInput.value = highlightInput.initialValue;
			}
		});
	});

	
	//Handle closing the drawer and deselecting, by clicking the drawer front.
	/*bookShelfDrawerLid.observe('click', function(event){
		if(bookShelfDrawerLid.hasClassName('open')){
			bookShelfDrawerLid.fire('ccpl:closeDrawer');
				galleryItems.each(function(items){
					items.removeClassName('selected');
				});
			
		}	
	});*/
	
	
	
	
	document.observe('ccpl:closeAlertBox', function(event){
		//window.log('closing light box');
		
		new Effect.Fade(alertBox, {
			duration: .35,
			afterFinish: function(){
				alertBox.remove();
			}
		});
		
		//alertBox.remove();
		
	});
}


// Cookie Functions
// Set the cookie 
function setCookie(name, value, expires, path, domain, secure) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

// Read the cookie 
function readCookie(name) { 
	var needle = name + "="; 
	var cookieArray = document.cookie.split(';'); 
	for(var i=0;i < cookieArray.length;i++) { 
		var pair = cookieArray[i]; 
		while (pair.charAt(0)==' ') { 
			pair = pair.substring(1, pair.length); 
		} 
		if (pair.indexOf(needle) == 0) { 
			return pair.substring(needle.length, pair.length); 
		} 
	} 
	return null; 
}


//Height Balance
//Normalizes the height of the elements passed in,
//based on the number of columns desired
function heightBalance(balanceElements, columns){
	balanceElements.eachSlice(columns, function(balanceElementSlice){
		var sliceHeight = balanceElementSlice.max(function(sliceElement){
			return sliceElement.getHeight();
		});
		
		balanceElementSlice.each(function(balanceElement){
			balanceElement.setStyle({
				height: sliceHeight + 'px'
			});
		});
	});
}



//Navigation Hovers
//Note: Prototype Driven
function navHover() {
	var navigationListItems = $$('#navigation ul li');
	
	navigationListItems.each(function(navigationListItem){
		navigationListItem.observe('mouseenter', function(event){
			navigationListItem.addClassName('hover sfhover');
		});
		navigationListItem.observe('mouseleave', function(event){
			navigationListItem.removeClassName('hover sfhover');
		});
	});
}


//Replacement for Window Onload - Loads before images, cross-browser
document.observe("dom:loaded", function() {
	alertBox();
	navHover(); //Converted old non-prototype version to prototype version.
});

// usage: log('inside coolFunc',this,arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
	log.history = log.history || [];   // store logs to an array for reference
	log.history.push(arguments);
	if(this.console){
		console.log( Array.prototype.slice.call(arguments) );
	}
};

// catch all document.write() calls
(function(doc){
	var write = doc.write;
	doc.write = function(q){
		log('document.write(): ',arguments);
		if (/docwriteregexwhitelist/.test(q)) write.apply(doc,arguments); 
	};
})(document);
