


// CCI utility functions

// create an array which is a copy of a NodeList
// author: mrim
function cci_newArrayFromNodeList(nodeList) {
    var result = [];
    var n = nodeList.length;
    for (var i=0; i<n; ++i) {
        result[i] = nodeList[i];
    }
    return result;
}

// className functions

// Dean Edwards 2004.10.24
// http://dean.edwards.name/IE7/
// Work protected by a Creative Commons License (Attribution 2.0)
// http://creativecommons.org/licenses/by/2.0/
// Thanks Dean!

function addClass(element, className) {
	////alert(element+' addClass: '+className);
	if (!hasClass(element, className)) {
		if (element.className) element.className += " " + className;
		else element.className = className;
	}
};


function removeClass(element, className) {
	var regexp = new RegExp("(^|\\s)" + className + "(\\s|$)");
	element.className = element.className.replace(regexp, "$2");
};


function hasClass(element, className) {
	////alert(element+' hasClass: '+className);
    if (!element.className) {
        return false;
    }
    //alert("checking "+ element.className+ " for "+ className)
	var regexp = new RegExp("(^|\\s)" + className + "(\\s|$)");
	return regexp.test(element.className);
};


// end Dean Edwards class manipulation functions


//  Dev has references to this script, same as append_function in their common.js library
function appendFunction( newFunction, oldFunction, scope ) { // General Utility Function

	if ( oldFunction && ( (typeof( oldFunction )).toUpperCase() == 'FUNCTION' ) ) {

		var appended = function() {
			var el = scope;
			oldFunction(el);
			newFunction(el);

		}


		return appended;

	}

	return newFunction;

} // end appendFunction

function getNextSiblingElement( node ) { // General Utility Function

	var sibling = node;

	while ( ( sibling = sibling.nextSibling ) ) {

		if ( sibling.nodeType == 1 ) { return sibling; }

	}

	return false;

} // end getNextSiblingElement



function getPreviousSiblingElement( node ) { // General Utility Function

	var sibling = node;

	while ( ( sibling = sibling.previousSibling ) ) {

		if ( sibling.nodeType == 1 ) { return sibling; }

	}

	return false;

} // end getNextSiblingElement




function removeAllChildNodes( element ) {

	for ( var i = ( element.childNodes.length - 1 ); i >=0; i-- ) {

		element.removeChild( element.childNodes[i] );

	}

}

function addToWindowOnload( event_handler, event_capture ) {

	if ( window.attachEvent ) {

		return window.attachEvent( "onload", event_handler );


	}

	else {

		return window.addEventListener( "load", event_handler, event_capture );

	}

} // end addToWindowOnload


function isDecendantOfNodeWithClassOf( class_name, node, stop_node ) { // General Utility Function

	// window.dump('isDecendantOfNodeWithClassOf: looking for class ' + class_name + ' in ' + node + ' before reaching ' + stop_node + '\n');

	if ( node !== stop_node  ) {

		if ( ( node.nodeType == 1 ) && node.className == class_name ) {

			return node;

		}

		else {

			if ( node.parentNode ) {

				return isDecendantOfNodeWithClassOf( class_name, node.parentNode, stop_node );
			}

			return false;

		}


	}

	else {

		return false;

	}

} // end isDecendantOfNodeWithClassOf



function getElementsWithClassNameOf( class_name, current_element, matches  ) {

	if ( 	current_element
			&& current_element.nodeType
			&& ( current_element.nodeType == 1 )
			&& ( current_element.tagName.toLowerCase() != 'param' )
			&& ( current_element.tagName.toLowerCase() != 'select' )
		) {

		if ( current_element.className && ( hasClass( current_element, class_name ) ) ) {

			matches[matches.length] = current_element;

		}

		if ( current_element.childNodes && ( current_element.childNodes.length > 0 ) ) {

			for ( var c = 0; c < current_element.childNodes.length; c++ ) { //child in current_element.childNodes
				//alert(current_element.childNodes[c])
				matches = getElementsWithClassNameOf( class_name, current_element.childNodes[c], matches );

			}

		}

	}

	return matches;

} // end getElementsWithClassNameOf



function getSimilarElementsWithClassNameOf( class_name, tag_name, current_element  ) {
	//alert("getting "+ current_element);
	var elements = current_element.getElementsByTagName( tag_name );
	//alert("looking thru "+ elements.length);
	var matches = new Array();

	for ( var i = 0; i < elements.length; i++ ) {

		if ( hasClass( elements[i], class_name ) ) {

			matches[matches.length] = elements[i];

		}

	}
	//alert("got "+ matches.length);
	return matches;

} // end getSimilarElementsWithClassNameOf




///////////////////////////////////

/* ----- buildQueryString ----- */

/*
	utility funtion
	refactored from common.js


*/


function buildQueryString( f ){

    var args = '?';

    for (i = 0; i < f.length; i++)
    {
         var e = f.elements[i];

         var join = ( (i == 0) || (args == '?') )? '' : '&';

         if (e.name == '')
         {
             continue;
         }

         if ((e.type == 'checkbox' || e.type == 'radio') && e.checked == true)
         {
             value = e.value;

             if (value == '')
             {
                 value = 1;
             }

             args = args + join + e.name + '=' + escape(value);
         }
         else if (e.type == 'text' || e.type == 'hidden' || e.type == 'textarea')
         {
             args = args + join + e.name + '=' + escape(e.value);
         }
         else if (e.type == 'select-one' && e.options.selectedIndex > 0)
         {
             args = args + join + e.name + '=' + escape(e.options[e.options.selectedIndex].value);
         }
    }

    return args;

}


/* ----- end buildQueryString ----- */

//////////////////////////////////////////



/* ----- START LOADXML/EXTERNAL CONTENT FUNCTIONS ----- */

var XMLCache = new Array();

function create_xml_http_request(){
	try	{
		return new ActiveXObject('Microsoft.XMLHTTP');
	}
	catch (e) {
		return new XMLHttpRequest();
	}
}

function loadXMLContentInToElement(url, element_id, check_cache) {

	return loadXMLContentInTo( url, document.getElementById( element_id ), check_cache );

}

function loadXMLContentInTo( url, element, check_cache ) {

	//  This function is used to update the element when
	//  some external content is returned
	function updateDOM( response ) {
		element.innerHTML = response;
		// unbless container so that new inner content can be blessed.
		element.wasBlessed = false;
		cciWidgets.bless( element, true );
	}

	//	In preparation for receiving external content
	//  a loader screen is created and inserted as temporary content
	//  while the real content is being fetched

	//  declaring some vars we will need
	var elementH, hOffset,loaderDiv,loaderSpan;

	//  Get the height of the container
	//  use the height stored when it was built, else get the offsetHeight
	elementH = (element.storedHeight)? element.storedHeight : parseInt(element.offsetHeight);

	//  Calculate the height offest for the loader to sit centered in the element
	hOffset = 0;
	//  height of the loaderDiv
	loaderH = 50;
	if(elementH && elementH!=0){
		hOffset = ((elementH - loaderH)/2)+"px";
	}

	//  build the loading screen
	loaderDiv 					= document.createElement('div');
	loaderDiv.className 		= "xml_loading";
	loaderDiv.style.height 		= loaderH + "px";
	loaderDiv.style.marginTop 	= hOffset;

	//  clear the element and insert the loading screen
	element.innerHTML = '';
	element.appendChild(loaderDiv);

	//  If the we are suppose to use cached content, go get it
	if ( check_cache ) {
		cacheableXMLRequest( url, updateDOM );
		return;
	}

	//  Else go get fresh content
	XMLRequest( url, updateDOM );

}


function XMLRequest( url, callback ) {

	var xmlhttp = create_xml_http_request();

	xmlhttp.open( "GET", add_cache_burster_to_url(url), true );

	xmlhttp.onreadystatechange = function() {

		if ( xmlhttp.readyState == 4 ) {  // && xmlhttp.status == 200
			callback( getDocumentFragment( xmlhttp.responseText, url ) );

		}
	};

	xmlhttp.send('');

}


function cacheableXMLRequest( url, callback ) {

	var cached_response = checkXMLCache( url );

	if ( cached_response != null ) {

		callback( cached_response );

		return;

	}

	XMLRequest( getCachedURL( url ), function( response ) { addToXMLCache( url, response ); callback( getDocumentFragment( response, url ) ); } );
}

function getCachedURL( url ) {

	var cached_url = url;

	var anchor = document.createElement('a');
	anchor.setAttribute( 'href', url );

	if ( anchor.hash ) { // targeting a document fragment

		var regex = new RegExp( anchor.hash  );

		cached_url = url.replace( regex, '' );

	}
	return cached_url;

}


function checkXMLCache( url ){

	var cached_url = getCachedURL( url );

	for ( var i = 0; i < XMLCache.length; i++ ) {

		if ( XMLCache[i].cachedURL == cached_url ) {

			return getDocumentFragment( XMLCache[i].cachedHTML, url );
		}
	}
	return null;
}


function addToXMLCache( url, html ){

	var cached_url = getCachedURL( url );

	XMLCache[XMLCache.length] = "cacheID" + (XMLCache.length);
	XMLCache[XMLCache.length-1]  = {
			cachedURL 	:	cached_url,
			cachedHTML 	: 	html
	}
}


function getDocumentFragmentId( url ) {

	var anchor = document.createElement('a');
	anchor.setAttribute('href', url );

	if ( anchor.hash ) {
		var urlstr = anchor.hash.slice(1);

		if(urlstr.indexOf('?') > -1){
			urlstr = urlstr.slice(0, urlstr.indexOf('?') );
		}
		return urlstr;
	}
	return '';
}


function getDocumentFragment( html, url ) {

	var frag_id = getDocumentFragmentId( url );

	if ( frag_id  == '' ) { return html; }

	var div = document.createElement('div');
	div.style.display = 'none';

	var transfer_div = document.createElement('div');
	transfer_div.style.display = 'none';

	document.body.insertAdjacentElement('afterBegin', div );
	document.body.insertAdjacentElement('afterBegin', transfer_div );

	div.innerHTML = html;
	transfer_div.appendChild( document.getElementById( frag_id ) );

	var innerHTML = transfer_div.innerHTML;

	document.body.removeChild( div );
	document.body.removeChild( transfer_div );

	return innerHTML;
}

/* ----- END LOADXML/EXTERNAL CONTENT FUNCTIONS ----- */




/*
* cci namespace for the following functions will look to bind to
* @object cci
*/
if(!window.cci){
	cci = {};
}


/*
* utils namespace for various utility fuctions
* @object cci.utils
*/
cci.utils = {};


/*
	Tabs - Template designed to store tiers of content with one shared space
*/
cci.tabSet = {

	tabSets : [],

	initialize:function(element){

		var instance = {};

		// Declaring and Setting Object References
		instance.self = element;

		instance.optionsArea		= getElementsWithClassNameOf( 'navitems', element, new Array())[0];
		instance.tabOptions			= getElementsWithClassNameOf( 'navitem', instance.optionsArea, new Array());
		instance.displayArea		= getSimilarElementsWithClassNameOf( 'tabdisplay', 'div', element )[0];
		instance.tabs				= getSimilarElementsWithClassNameOf( 'tab', 'a', instance.optionsArea);
		instance.selectedField		= getElementsWithClassNameOf( 'selected_tab_field', instance.optionsArea, new Array())[0];

		instance.currentTabIndex = 0;

		for ( var i = 0; i < instance.tabs.length; i++ ) {

			var tab 		= instance.tabs[i];
			tab.index 		= i;
			var content 	= document.getElementById( tab.parentNode.id.split( '_option' )[0] );

			if ( !hasClass(content, "async") ) { 	// LOCAL: Display content is local

				tab.content = content;
				tab.content.style.display = "none";

				tab.displayTab = function(){
					displayTab(this.index);
					return false;
				}

				tab.onclick = tab.displayTab;

			} else { 								// EXTERNAL: Display content needs to be pulled from external source

				tab.content = content;
				var cache = (hasClass(content, "cache"))? true: false;

				var temp = document.createElement('div');
				temp.className = tab.content.className;
				temp.id = tab.content.id;

				tab.content.parentNode.replaceChild(temp, tab.content);
				temp.storedHeight = parseInt(temp.offsetHeight);
				temp.style.display = 'none';
				tab.content = temp;

				tab.loadContent = function(){
					loadXMLContentInTo(this.name, this.content, cache);
					//loadXMLContentInTo(this.name, this.content, false);
					displayTab(this.index);
					return false;
				}

				tab.onclick = tab.loadContent;

				if(instance.currentTabIndex == tab.index){
					tab.loadContent();
				}
			}
		}

		function displayTab(index) {
			hideItem(instance.currentTabIndex);
			showItem(index);
			instance.currentTabIndex = index;
		}

		function showItem(index) {
			if(instance.tabs.length == 0) { return; }
			instance.tabs[index].content.style.display = '';
			addClass(instance.tabOptions[index], 'navitem_selected');

			if (instance.selectedField != undefined){
				instance.selectedField.value = instance.tabs[index].content.id;
			}
		}

		function hideItem(index){
			if(instance.tabs.length == 0) { return; }
			instance.tabs[index].content.style.display = 'none';
			removeClass(instance.tabOptions[index], 'navitem_selected');
		}

		instance.getDefaultOption = function(){

			// precondition: this.options should have at least 1 option before calling this function!

			for ( var i = 0; i < this.tabs.length; i++ ) {

				if (  window.location.hash && ( window.location.hash == this.tabs[i].hash ) ) {
					return i;
				}
				else if ( this.selectedField && (this.selectedField.value == this.tabs[i].content.id) ) {
					return i;
				}
			}
			// if it was not found, check each tabs selected status...
			// the last tab indicated as selected is the default option...
			for ( var i = 0; i < this.tabs.length; i++ ) {

				if ( hasClass( this.tabs[i], 'navitem_selected' ) ) {
					return i;
				}
			}

			// last resort: select the first option in the list...
			return 0;

		} // End getDefaultOption


		displayTab(instance.getDefaultOption());

		element.resetTabs = function(){
			displayTab(0);
		}

	} // End initalize


} // End cci.tabSet




/*
	Carousel - Template designed to paginate through a group of items
*/
cci.carousel = {

	carousels : [],

	initialize:function(element){
		var instance = {};

		// Declaring and Setting Object References
		instance.self = element;
		instance.itemContainer = getElementsByClassName(element, "div", 'carousel_items')[0];
		instance.arrayOfItems = getElementsByClassName(element, 'div', 'carousel_item');
		instance.miniSlide;
		instance.miniSlides = [];
		instance.loader;
		instance.itemCaptionContainer;
		instance.itemCaption;

		// Populating Properties
		instance.layoutType = instance.itemContainer.getAttribute("name"); // vertical | standard
		//alert(instance.layoutType);
		instance.totalItems = instance.arrayOfItems.length;
		instance.itemsPerSlide = element.getAttribute("alt");
		instance.totalSlides = Math.ceil(instance.totalItems / instance.itemsPerSlide);
		instance.viewingSlide = 0;
		instance.nextSlide = 0;
		instance.navigationLocked = true;
		instance.carouselWidth = instance.self.offsetWidth;
		instance.transitionType = element.getAttribute("name");

		//for vertical layout draw item caption
		if (instance.layoutType == "vertical") {
			buildItemCaption(self,true);
		}


		// Load Slides and Display First Slide:
		var slide1 = document.createElement("div");
		addClass(slide1, "carousel_slide");
		slide1.style.display = "none";
		slide1.style.position = "absolute";
		slide1.style.width = instance.carouselWidth + "px";
		instance.itemContainer.appendChild(slide1);
		instance.slideToShow = slide1;

		var slide2 = slide1.cloneNode(true);
		instance.itemContainer.appendChild(slide2);
		instance.slideToHide = slide2;

		if((instance.layoutType == "vertical") && (instance.arrayOfItems.length == 1)) {
			buildPagination('empty');
		}
		else{
			buildPagination('full');
		}

		cci.carousel.utils.populateSlide(instance, "next");

		// Try to set size of carousel:
		cci.carousel.utils.setCarouselHeight(instance);

		function buildPagination(type){

			// Create Container
			var pagination_container = document.createElement("div");
			instance.self.appendChild(pagination_container);
			addClass(pagination_container, "carousel_pagination");

			if(type!="empty") {

			// Create Previous Button
			var previous_button = document.createElement("a");
			previous_button.setAttribute('href','#');

				previous_button.onclick = function(){
					previousSlide(instance);
					//for vertical layout draw header
					if (instance.layoutType == "vertical") {
						buildItemCaption(instance,false);
					}
					this.blur();
					return false;
				};


			pagination_container.appendChild(previous_button);
			addClass(previous_button, "carousel_previous");

			if (instance.layoutType == "standard") {
				// Create MiniSlide Container
				instance.miniSlide = document.createElement("div");
				pagination_container.appendChild(instance.miniSlide);
				addClass(instance.miniSlide, "mini_slides");

				// Creating MiniSlides
				for (i=0; i<instance.totalSlides; i++){
					instance.miniSlides[i] = buildMiniSlides(i);
				}


			// Build Loading Animation
			instance.loader = document.createElement("div");
			pagination_container.appendChild(instance.loader);
			addClass(instance.loader, "loading_container");
			var loaderImage = document.createElement("img");
			loaderImage.setAttribute("src", "http://demo-static.blackplanet.com/shared/images/carousel/loader.gif");
			loaderImage.setAttribute("width", "70");
			loaderImage.setAttribute("height", "12");
			instance.loader.appendChild(loaderImage);
			instance.loader.style.display = "none";

			}

			// Create Next Button
			var next_button = document.createElement("a");
			next_button.setAttribute("href", "#");

				next_button.onclick = function(){
					nextSlide(instance);
					//for vertical layout draw header
					if (instance.layoutType == "vertical") {
						buildItemCaption(instance,false);
					}
					this.blur();
					return false;
				};

			pagination_container.appendChild(next_button);
			addClass(next_button, "carousel_next");
			}
		}

		function buildItemCaption(self,init) {
			//item caption is only supported in vertical layout and is appended to head of carousel
				if (instance.layoutType == "vertical" && (instance.arrayOfItems.length != 1)) {
					var currentItem = instance.viewingSlide;

					if (init == true) { currentItem = instance.viewingSlide + 1; }
					instance.itemCaption = "<div class='itemCaptionContainer'><h4>" + currentItem + " of " + instance.totalSlides + "<\/h4><\/div>";

					var carousel_header = getElementsByClassName(instance.self, "div", 'carousel_head')[0];
					carousel_header.innerHTML = instance.itemCaption;
				}
		}

		function buildMiniSlides(count){
			var miniSlideTmpl = document.createElement("a");
			miniSlideTmpl.setAttribute("href", "#");
			miniSlideTmpl.id = count.toString();
			miniSlideTmpl.onclick = function(){

				if((parseInt(this.id)+1) != instance.viewingSlide){
					instance.viewingSlide = parseInt(this.id);
					nextSlide(instance);
				}
				this.blur();
				return false;
			};
			var miniSlideTmplSpan = document.createElement("span");
			var miniSlideTmplSpanText = document.createTextNode("W");

			instance.miniSlide.appendChild(miniSlideTmpl);
			miniSlideTmpl.appendChild(miniSlideTmplSpan);
			miniSlideTmplSpan.appendChild(miniSlideTmplSpanText);
			instance.miniSlides[count] = miniSlideTmpl;

			return miniSlideTmpl;
		}

		function nextSlide(){

			if(instance.navigationLocked != true){
				instance.navigationLocked = true;
				// Swap Slides References
				var slideToHideRef = instance.slideToHide;
				instance.slideToHide = instance.slideToShow;
				instance.slideToShow = slideToHideRef;

				// Populate Next Slide
				cci.carousel.utils.populateSlide(instance, "next");
			}
		}

		function previousSlide(){
			if(instance.navigationLocked != true){
				instance.navigationLocked = true;

				// Swap Slides References
				var slideToHideRef = instance.slideToHide;
				instance.slideToHide = instance.slideToShow;
				instance.slideToShow = slideToHideRef;

				// Populate Next Slide
				cci.carousel.utils.populateSlide(instance, "previous");
			}
		}

		return instance;

	},

	setMiniSlideNavHLite:function(instance, selectedNum){
		for(i=0; i<instance.miniSlides.length; i++){
			if(instance.miniSlides[i].className){
				removeClass(instance.miniSlides[i], "selected");
			}
		}
		addClass(instance.miniSlides[selectedNum], "selected");
	},

	utils : {

		setCarouselHeight:function(instance){
			// Set height of carousel content based off of cotents height
			if (instance.layoutType == "standard") {
				instance.carouselHeight = instance.slideToShow.offsetHeight;
				instance.itemContainer.style.height = instance.carouselHeight + "px";
			}
		},

		populateSlide:function(instance, direction){
			instance.slideToShow.innerHTML = "";
			if(direction == "next"){
				if(instance.viewingSlide >= instance.totalSlides){
					instance.viewingSlide = 0;
					instance.nextSlide = 1;
				}
				instance.viewingSlide++;
				instance.nextSlide = instance.viewingSlide + 1;
			}
			if(direction == "previous"){
				instance.viewingSlide--;
				instance.nextSlide = instance.viewingSlide - 1;

				if(instance.viewingSlide == 0){
					instance.viewingSlide = instance.totalSlides;
					instance.nextSlide = instance.totalSlides - 1;
				}
			}

			var multiple = instance.viewingSlide * instance.itemsPerSlide;
			var placement = multiple - (instance.itemsPerSlide - 1);

			for(i=0; i<instance.itemsPerSlide; i++){
				var itemToPlace = instance.arrayOfItems[(placement + i) -1];
				if (itemToPlace){
					var clonedItem = itemToPlace.cloneNode(true);
					instance.slideToShow.appendChild(clonedItem);
				}
			}

			cci.carousel.utils.prepItem(instance);
			if (instance.layoutType == "standard") {
				cci.carousel.setMiniSlideNavHLite(instance, instance.viewingSlide - 1);
			}
		},

		multiCallBack: {

			callBackCount: 0,

			itemAdded:function(){
				cci.carousel.utils.multiCallBack.callBackCount++;
			},
			itemLoaded:function(instance){
				cci.carousel.utils.multiCallBack.callBackCount--;
				cci.carousel.utils.multiCallBack.checkCount(instance);
			},
			checkCount:function(instance){
				if(cci.carousel.utils.multiCallBack.callBackCount == 0){
					// All content has finished loading, run the following functions:
					cci.carousel.utils.transitions.manager(instance);
					cci.carousel.utils.toggleLoader(instance);
				}
			}
		},

		toggleLoader:function(instance){

			if(instance.miniSlide.style.display == "none"){
				instance.loader.style.display = "none";
				instance.miniSlide.style.display = "block";
			} else {
				instance.loader.style.display = "block";
				instance.miniSlide.style.display = "none";
			}
		},


		prepItem:function(instance){

			if (instance.layoutType == "vertical") { cci.carousel.utils.transitions.manager(instance); return; }

			var images = instance.slideToShow.getElementsByTagName("IMG");
			if(images.length != 0 ){
				cci.carousel.utils.toggleLoader(instance);
				for(i=0; i<images.length; i++){
					//if(hasClass(images[i], "not_prepped")){
						cci.carousel.utils.multiCallBack.itemAdded();
						images[i].src = images[i].title;
						images[i].title = "";
						//removeClass(images[i], "not_prepped");
						//addClass(images[i], "prepped");
						images[i].onload = function(){
							// OK to show this content
							//alert("here");
							cci.carousel.utils.multiCallBack.itemLoaded(instance);
						};
					//}
				}
				return instance.slideToShow;
			} else {
				cci.carousel.utils.transitions.manager(instance);
				return false;
			}
			cci.carousel.utils.transitions.manager(instance);
		},

		transitions : {

			manager:function(instance){
				switch (instance.transitionType){
					case "basic":
						cci.carousel.utils.transitions.basic(instance);
						break;
					case "fade":
						cci.carousel.utils.transitions.crossFade(instance);
						break;
					case "slide":
						if(instance.nextSlide > instance.viewingSlide){
							cci.carousel.utils.transitions.slide(instance, "right");
						} else {
							cci.carousel.utils.transitions.slide(instance, "left");
						}
						break;
					default:
						cci.carousel.utils.transitions.basic(instance);
				}
			},

			basic:function(instance){
				if (instance.slideToHide == null){
					showSlide(instance.slideToShow);
				}
				else {
					hideSlide(instance.slideToHide);
					showSlide(instance.slideToShow);
				}

				instance.navigationLocked = false;

				function showSlide(element){
					element.style.top = "0px";
					element.style.left = "0px";
					element.style.display = "block";
					cci.carousel.utils.setCarouselHeight(instance);
				}
				function hideSlide(element){
					element.style.top = "0px";
					element.style.left = "0px";
					element.style.display = "none";
				}
			},

			crossFade:function(instance){

				if (instance.slideToHide == null){
					// Do Nothing
				}
				else {
					instance.slideToShow.style.display = "block";
					instance.slideToHide.style.display = "block";
					cci.carousel.utils.setCarouselHeight(instance);

					var slideFadeIn = new YAHOO.util.Anim(instance.slideToShow, {opacity: { from: 0, to: 1 }}, 1, YAHOO.util.Easing.easeOut);
					slideFadeIn.animate();

					var slideFadeOut = new YAHOO.util.Anim(instance.slideToHide, {opacity: { from: 1, to: 0 }}, 1, YAHOO.util.Easing.easeOut);
					slideFadeOut.animate();
					slideFadeOut.onComplete.subscribe(function(){
						instance.navigationLocked = false;
					});
				}
			},

			slide:function(instance, direction){
				if(direction == "right"){
					var showFrom = instance.carouselWidth;
					var showTo = 0;
					var hideFrom = 0;
					var hideTo = instance.carouselWidth * (-1);
				} else {
					var showFrom = instance.carouselWidth * (-1);
					var showTo = 0;
					var hideFrom = 0;
					var hideTo = instance.carouselWidth;
				}

				instance.slideToShow.style.display = "block";
				instance.slideToHide.style.display = "block";
				cci.carousel.utils.setCarouselHeight(instance);

				var slideIn = new YAHOO.util.Anim(instance.slideToShow, {left: { from: showFrom, to: showTo }}, .5, YAHOO.util.Easing.easeOut);
				slideIn.animate();

				var slideOut = new YAHOO.util.Anim(instance.slideToHide, {left: { from: hideFrom, to: hideTo }}, .5, YAHOO.util.Easing.easeOut);
				slideOut.animate();
				slideOut.onComplete.subscribe(function(){
					instance.navigationLocked = false;
				});
			}

		},

		deBug:function(str){
			//document.body.innerHTML += str + "<br\/>";
		}
	}
}



/* ---- Release 1 JavaScript Code ----- */

/*
	Filename: lib.js
	Description: Sitewide JS functionality
*/
// Using feature detection to determine if
// the browser is older IE version, below 6
var is_standard = (window.XMLHttpRequest)? true : false;

//////////////////////////////////////////

/*
 * EventManager.js
 * by Keith Gaughan
 *
 * This allows event handlers to be registered unobtrusively, and cleans
 * them up on unload to prevent memory leaks.
 *
 * Copyright (c) Keith Gaughan, 2005.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Common Public License v1.0
 * (CPL) which accompanies this distribution, and is available at
 * http://www.opensource.org/licenses/cpl.php
 *
 * This software is covered by a modified version of the Common Public License
 * (CPL), where Keith Gaughan is the Agreement Steward, and the licensing
 * agreement is covered by the laws of the Republic of Ireland.
 */
 // Thank you Keith!

var EventManager =
{
    _registry: null,

    Initialise: function()
    {
        if (this._registry == null)
        {
            this._registry = [];

            // Register the cleanup handler on page unload.
            EventManager.Add(window, "unload", this.CleanUp);
        }
    },

    /**
     * Registers an event and handler with the manager.
     *
     * @param  obj         Object handler will be attached to.
     * @param  type        Name of event handler responds to.
     * @param  fn          Handler function.
     * @param  useCapture  Use event capture. False by default.
     *                     If you don't understand this, ignore it.
     *
     * @return True if handler registered, else false.
     */
    Add: function(obj, type, fn, useCapture)
    {
        this.Initialise();
        // If a string was passed in, it's an id.
        if (typeof obj == "string")
            obj = document.getElementById(obj);
        if (obj == null || fn == null)
            return false;

        // Mozilla/W3C listeners?
        if (obj.addEventListener)
        {
            obj.addEventListener(type, fn, useCapture);
            this._registry.push({obj: obj, type: type, fn: fn, useCapture: useCapture});
            return true;
        }

        // IE-style listeners?
        if (obj.attachEvent && obj.attachEvent("on" + type, fn))
        {
            this._registry.push({obj: obj, type: type, fn: fn, useCapture: false});
            return true;
        }

        return false;
    },

    /**
     * Cleans up all the registered event handlers.
     */
    CleanUp: function()
    {
        for (var i = 0; i < EventManager._registry.length; i++)
        {
            with (EventManager._registry[i])
            {
                // Mozilla/W3C listeners?
                if (obj.removeEventListener)
                    obj.removeEventListener(type, fn, useCapture);
                // IE-style listeners?
                else if (obj.detachEvent)
                    obj.detachEvent("on" + type, fn);
            }
        }

        // Kill off the registry itself to get rid of the last remaining
        // references.
        EventManager._registry = null;
    },

    Observable: function(obj)
    {
		EventManager.Initialise();

		// If a string was passed in, it's an id.
		if (typeof obj == "string")
			obj = document.getElementById(obj);
		if (obj == null)
			return false;

		var listeners =[];

		obj.o = this;

		this.addListener = function(fn){
			listeners.push(fn);
		}

		this.removeListeners = function(){
			for (var i = 0; i < listeners.length; i++){
				listeners[i] = null;
			}
		}

		this.broadcast = function(){
			for (var i = 0; i < listeners.length; i++){
				listeners[i](obj);
			}
		}

		return this;
    }
};





/* ----- BEGIN GENERIC OBJECT DEFINITIONS ----- */


/*

	OptionList v.1

*/

function OptionList( ) {

	this.selected = null; // reference to selected option(s)
	this.options = new Array(); // an array of optionItems

} // end OptionLIst


OptionList.prototype.onOptionSelect = undefined;
OptionList.prototype.onOptionDeselect = undefined;
OptionList.prototype.onChange = undefined;


function SelectOneOptionList( element ) {

	element.defaultOption = undefined;

	element.selected = this.selected;
	element.options = new Array();


	element.selectDefault = function() {

		this.select( this.defaultOption );

	} // end selectDefault


	element.optionSelect = function( option ) {

		if ( this.selected ) { this.selected.deselect(); }

		this.selected = option;

		if ( this.onOptionSelect != undefined ) { this.onOptionSelect( option ); }

	}

	element.optionDeselect = function( option ) {

		// do nothing...

		if ( this.onOptionDeselect != undefined ) { this.onOptionDeselect( option ); }

	} //  end optionDeselect



} // end SelectOneOptionList()

SelectOneOptionList.prototype = new OptionList(); // now SelectOneOptionList is a sub-class of OptionList



/* ----- End OptionList ----- */

/*


	OptionItem: v.2 - Abstract Input Element

	Generic OptionItem defines simple state behavior and functions to manipulate that behavior, add to OptionList class to create custom select-one, select-multiple inputs


*/

function OptionItem( element ) {

	element.select = function() {

		if ( !this.isOptionDisabled() && !this.isOptionSelected() ) {

			this.addState( 'selected' );

			this.selected = true;

			// window.dump('OptionItem: Select: Added selected state to item.\n' );

			if ( this.onOptionSelect ) { this.onOptionSelect(); }

			if ( this.optionList && ( this.optionList.optionSelect != undefined ) ) {

				this.optionList.optionSelect( this );

			}

		}

		return false;

	} // end element.select


	element.deselect = function() {

		this.removeState( 'selected', this.optionList );

		this.selected = false;

		if ( this.onOptionDeselect ) { this.onOptionDeselect(); }

		if ( this.optionList && ( this.optionList.optionDeselect != undefined ) ) {

			this.optionList.optionDeselect( this );

		}

	} // end element.deselect



	element.toggle =  function() {

		if ( this.isOptionSelected() ) {

			return this.deselect();

		}

		return this.select();

	} // end element.toggle



	element.addState = function( state ) {

		var stateNode = document.createElement('div');

		stateNode.className = state;

		var thisElement = this.parentNode.replaceChild( stateNode, this );

		stateNode.appendChild( thisElement );


	} // end addState


	element.removeState = function( state, stop_at ) {

		if ( stop_at == undefined ) { stop_at = document.body; }

		var stateNode = isDecendantOfNodeWithClassOf( state, this, stop_at );

		if ( stateNode ) {

			var childElementNode = stateNode.childNodes[0];

			if ( childElementNode.nodeType  != 1 ) {

				childElementNode = getNextSiblingElement( childElementNode );

			}

			stateNode.parentNode.replaceChild( childElementNode, stateNode );

			return true;

		}

		return false;


	} // end removeState



	element.disable = function() {

		this.addState( 'disabled' );

		if ( this.onOptionDisable ) { this.onOptionDisable(); }

		if ( this.optionList && ( this.optionList.optionDisable != undefined ) ) {

			this.optionList.optionDisable( this );

		}


	} // end element.disable



	element.enable = function() {

		this.removeState( 'disabled', this.optionList );

		if ( this.onOptionEnable ) { this.onOptionEnable(); }

		if ( this.optionList && ( this.optionList.optionEnable != undefined ) ) {

			this.optionList.optionEnable( this );

		}

	} // end element.enable

	element.isOptionSelected = function() {

		if ( this.selected == undefined ) {

			var node = isDecendantOfNodeWithClassOf( 'selected', this, this.optionList );

			if ( node ) { this.selected = true;  }

			else { this.selected = false; }

		}

		return this.selected;

	} // end this.isSelected



	element.isOptionDisabled = function() {

		if ( this.disabled == undefined ) {

			var node = isDecendantOfNodeWithClassOf( 'disabled', this, this.optionList );

			if ( node ) { this.disabled = true;  }

			else { this.disabled = false; }
		}

		return this.disabled;

	} // end element.isDisabled


	element.onclick = element.select;
	element.selected = undefined;			// default value for options
	element.disabled = undefined;			// default value for options
	element.optionList = null; 				// reference to list that holds this item


} // end OptionItem


/* ----- End OptionItem ----- */




/* ------- CCI WIDGETS ------- */


var cciWidgets = function() {

	var widgetController = new Object();

	widgetController.widgets =  new Object();

	widgetController.blessed = false;

	widgetController.docBlessed = false;

	widgetController.addWidget = function( className, handler, params ) {

		this.widgets[className] = {

			handler : handler,
			params	: params

		};

	};


	widgetController.bless = function( current_element, force ) {

		// //alert( this.blessed );

		if ( !this.blessed || force )  {

			this.blessed = true;

			this.blessWidgets( current_element, force );

		}

		return;

	};


	// widgetController.bless = function( current_element ) {
	widgetController.blessWidgets = function( current_element, force ) {

        //  Safari does not locate the body tag by id when first run
        //  assume that the first element passed that is null to be the body
        if (( current_element == null ) && !widgetController.docBlessed ){
        	current_element = document.body;
        }

        // if we are here, the element is the body or an object in it
        // declared the document blessed
       	widgetController.docBlessed = true;

       	// operate only on element nodes. Node.ELEMENT_NODE = 1
        if ( !current_element.nodeType || current_element.nodeType != 1 ) return;

        // never bless the same element twice
        if( current_element.wasBlessed && !force ) return;
        current_element.wasBlessed = true;
        // ignore param and select tags.
        var tagName = current_element.tagName.toLowerCase();
        if ( tagName == 'param' || tagName == 'select') return;

        // invoke handlers for "magic" class names.
        var clases = current_element.className.split(' ');
        for ( i = 0; i < clases.length; i++ ){
            var blesser = this.widgets[clases[i]];
            if ( blesser && (typeof blesser.handler === 'function' )) {
                blesser.handler(current_element, blesser.params);
            }
        }
        // bless all children if any
        if ( current_element.childNodes != null ) {
            // copy children to ensure nodelist is constant
            // this is to prevent subtle bug where child nodes are modified
            // during recursion.
            var children = cci_newArrayFromNodeList(current_element.childNodes);
            var nChildren = children.length;
            for ( var z = 0; z < nChildren; z++ ) {
                this.blessWidgets(children[z], force);
            }
        }
	};



	// Rollover Layer Positioning

	function getAnchorPosition(obj) {

		// This function will return an Object with x and y properties
		var useWindow=false;
		var coordinates=new Object();
		var x=0,y=0;

		// Browser capability sniffing
		var use_gebi=false, use_css=false, use_layers=false;

		getPageOffsetLeft = function(el){
			var ol=el.offsetLeft;
			while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
			return ol;
		}

		getWindowOffsetLeft = function(el) {
			return getPageOffsetLeft(el)-document.body.scrollLeft;
		}

		getPageOffsetTop = function(el) {
			var ot=el.offsetTop;
			while((el=el.offsetParent) != null) { ot += el.offsetTop; }
			return ot;
		}

		getWindowOffsetTop = function(el) {
			return getPageOffsetTop(el)-document.body.scrollTop;
		}

		if (document.getElementById) { use_gebi=true; }
		else if (document.all) { use_css=true; }
		else if (document.layers) { use_layers=true; }

		// Logic to find position
		if (use_gebi || document.all || use_css) {
			var o = obj;
			x=(o)?getPageOffsetLeft(o):0;
			y=(o)?getPageOffsetTop(o):0;
		}
		else if (use_layers) {
			x=(obj)?obj.x:0;
			y=(obj)?obj.y:0;
		}
		else {
			coordinates.x=0; coordinates.y=0; return coordinates;
		}
		coordinates.x=x;
		coordinates.y=y;
		////alert(coordinates.y + " | " + coordinates.x);
		return coordinates;
	}

	widgetController.getAnchorPosition 	= function(obj){
		return getAnchorPosition(obj);
	}

	function createPopLayer(id, popup){
		var prepend = '';

		if(!PopupWindow.hasBlocker){
			 prepend = "<div id=\"_blocking\" style=\"width: 100%; height: 800px;position: absolute; display: none; background-color: #bbb; width: 100%; height: 800px; opacity: 0.36; filter: alpha(opacity=36); \"><br/></div>";
			 PopupWindow.hasBlocker = true;
		}

		if(!document.getElementById(id)){
			document.body.insertAdjacentHTML("afterBegin", prepend +"<div id='" + id + "' style='position:absolute; visibility:hidden;' class='hoverLayer'></div>");
		}
	}

	// PopupWindow Class - This is used for username and help rollovers

	function PopupWindow(layerID, use_cache) {

		if(window.popupWindowHash && window.popupWindowHash[""+layerID]){
			return window.popupWindowHash[""+layerID];
		}

		createPopLayer(layerID, this);

		var elDOM;
		var check_cache = (arguments[1] == false)? false : true;

		var self = this;

		if (!window.popupWindowIndex) { window.popupWindowIndex = 0; }
		if (!window.popupWindowObjects) { window.popupWindowObjects = new Array(); }
		if (!window.popupWindowHash) { window.popupWindowHash = new Array(); }

		var index = popupWindowIndex++;

		window.popupWindowObjects[index] = this;
		window.popupWindowHash[""+layerID] = this;

		var divName = null;
		var divObj = null;

		var popupWindow = null;

		var width="auto";
		var height="auto";
		var populated = false;
		var visible = false;

		var autoHideEnabled = false;

		this.offsetX = 0;
		this.offsetY = 0;

		var x = 0;
		var y = 0;

		var prepend = "";
		var contents = "";
		var postpend = "";

		if (layerID && (layerID != '')) {
			divName = layerID;
		}else{
			return null;
		}

		var use_gebi = false;
		var use_css = false;
		var use_layers = false;

		if (document.getElementById) { use_gebi = true; }
		else if (document.all) { use_css = true; }
		else if (document.layers) { use_layers = true; }

		var el = (use_gebi)?	function(dEl){ return document.getElementById(dEl); } :
				 (use_css)?		function(dEl){ return document.all[dEl]; } :
				 (use_layers)?	function(dEl){ var elem = document.layers[dEl]; elem.style = elem; return elem; }: null;

		divObj = el(divName);

		var reset = function(){
			width = "auto";
			height = "auto";
			prepend = "";
			postpend = "";
		}

		this.getXYPosition = function(anchorname) {

			var coordinates;
				coordinates = getAnchorPosition(anchorname);
			x = coordinates.x;
			y = coordinates.y;
		}

		// Fill the window with contents
		this.populate = function(element){
			elDOM = element;
			contents = element;
			populated = false;
		}

		// Refresh the displayed contents of the popup
		this.refresh = function(){
			window_contents = prepend + contents + postpend;
			// refresh the DIV object
			if (use_gebi || use_css) {
				//var xmlURL = document.getElementById(layerID).getAttribute('name') + elDOM.getAttribute('name');
				var xmlURL = elDOM.getAttribute('name');

				loadXMLContentInToElement(xmlURL, layerID, check_cache);

			}
		}


		// Position and show the popup, relative to an anchor object
		this.showPopup = function() {

			divObj.innerHTML = "<div class='xml_loading'></div>";


			var args = arguments.length;
			if(arguments.length >1){
				args = 2;
			}
			if (arguments[0] && ((typeof( arguments[0] )).toUpperCase() == 'NUMBER' ) ){
				x = arguments[0];
				if ( arguments[1] && ((typeof( arguments[0] )).toUpperCase() == 'NUMBER' ) ){
					y = arguments[1];
				}else{
					y = arguments[0];
				}
			}else{
				self.getXYPosition(elDOM);
			}
			x += self.offsetX;
			y += self.offsetY;
			if (!populated && (contents != "")) {
				populated = true;
				self.refresh();
			}

			// Show the DIV object
			divObj.style.left = x + "px";
			divObj.style.top = y + "px";
			divObj.style.visibility = "visible";
			visible = true;

			reset();

		}

		// Hide the popup
		this.hidePopup = function(){
			divObj.style.visibility = "hidden";
			visible = false;
			reset();
		}

		this.isClicked = function(e) {
			if (use_layers) {
				var clickX = e.pageX;
				var clickY = e.pageY;
				var t = divObj;
					if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) {
						return true;
					}
				else { return false; }
			}
			else if (document.all) {

				// Need to hard-code this to trap IE for error-handling
				var t = window.event.srcElement;
				while (t.parentElement != null) {
					if (t.id==divName) {
						return true;
						}
					t = t.parentElement;
					}
				return false;
			}
			else if (use_gebi && e) {
				var t = e.originalTarget;
				try {
					while (t.parentNode != null) {
						if (t.id==divName) {
							return true;
						}
						t = t.parentNode;
					}
				} catch(e){

				}
				return false;
			}
			return false;
		}

		this.isVisible = function(){
			return visible;
		}

		this.hideIfNotClicked = function(e) {
			if (autoHideEnabled && !self.isClicked(e)) {
				self.hidePopup();
			}
		}

		this.autoHide = function() {
			autoHideEnabled = true;
		}

		this.hidePopupWindows = function(e) {
			for (var i=0; i<popupWindowObjects.length; i++) {
				if (popupWindowObjects[i] != null) {
					var p = popupWindowObjects[i];
					p.hideIfNotClicked(e);
				}
			}
		}

		this.timer = null;

		this.autoOpen = function(ms,x,y){


			clearTimeout(this.timer);
			var time = (ms>=0)? ms : 350;
			var show
			if(x){
				if(y){
					show =  function(){ self.showPopup(x,y) };
				}else{
					show =  function(){ self.showPopup(x,x) };
				}
			}else{
				show = function(){ self.showPopup() };

			}

			this.timer = setTimeout( show, time );

		};

		this.keepOpen = function(){
			clearTimeout(this.timer);
			reset();
		}

		this.autoClose = function(ms){
			clearTimeout(this.timer);
			var time = (ms>=0)? ms: 350;
			this.timer = setTimeout( function(){ self.hidePopup() }, time );
		}

		this.attachListener = function() {
			if (document.layers) {
				document.captureEvents(Event.MOUSEUP);
			}
			document.onmouseup = appendFunction( popupWindowObjects[index].hidePopupWindows, document.onmouseup );
		}

		if (!window.listenerAttached) {
			window.listenerAttached = true;
			self.attachListener();
		}

	}
	PopupWindow.hasBlocker = false;


	function popUpWindowCreator( element, params ){

		var regWin = params;//popUpWindowCreator.registeredWins[ element.className ];

		if(regWin){

			if(regWin.popwin == null){

			 	regWin.popwin = new PopupWindow( regWin.id, regWin.cache );
			}

			var popwin = regWin.popwin;

			if(regWin.autoClose) {

				popwin.autoHide();
				document.getElementById( regWin.id ).onmouseout = function(){

					popwin.autoClose(regWin.autoClose);

				}
			}

			if(regWin.offset) {
				if(regWin.offset.x) popwin.offsetX = regWin.offset.x;
				if(regWin.offset.y) popwin.offsetY = regWin.offset.y;

			}


			element[ regWin.openEvt ] = function() {

				popwin.populate(element);

				//if( regWin.size ) popwin.setSize( regWin.size.w, regWin.size.h );
				if( regWin.block ) document.getElementById( '_blocking' ).style.display = 'block';

				if( regWin.autoOpen ){

						popwin.autoOpen( regWin.autoOpen );

				}else{
					if(regWin.position){
						popwin.showPopup( regWin.position.x, regWin.position.y);
					}else{
						popwin.showPopup();
					}
				}

				if( regWin.keepOpen ){
					document.getElementById( regWin.id ).onmouseover = function(){
						popwin.keepOpen();
					};
				}
				return false;
			}

			if( regWin.closeEvt ) {

				element[ regWin.closeEvt ] = function() {

					if(regWin.autoClose) popwin.autoClose(regWin.autoClose);

					if( regWin.block ) document.getElementById( '_blocking' ).style.display = 'none';
				}
			}
		}

	}

	function UsernameRollover( element ) {

		popUpWindowCreator( element, {
			id:'usernameRollOver',
			popwin:null,
			openEvt:'onmouseover',
			closeEvt:'onmouseout',
			keepOpen:1,
			autoOpen:200,
			autoClose:400,
			offset:{
				x:20,
				y:17
			}
		});

	}

	widgetController.addWidget('username_rollover', UsernameRollover);

	function UsernameRolloverStatic( element ) {

		var makehovered=function(){addClass(element.parentNode.parentNode, 'hovered');}
		var makeunhovered=function(){removeClass(element.parentNode.parentNode, 'hovered');}

		element.parentNode.parentNode.onmouseover=makehovered;
		element.parentNode.parentNode.onmouseout=makeunhovered;

	}

	widgetController.addWidget('has_rollover', UsernameRolloverStatic);
	widgetController.addWidget('rollover', UsernameRolloverStatic);





	function InlineHelpLink( element ) {

		popUpWindowCreator( element, {
			id:'inlineHelpLayer',
			popwin:null,
			autoClose:400,
			keepOpen:1,
			openEvt:'onclick'
		});

	}

	widgetController.addWidget('inline_help_link', InlineHelpLink);



	function InlineEditLink( element ) {

		popUpWindowCreator( element, {
			id:'inlineEditLayer',
			popwin:null,
			openEvt:'onclick',
			keepOpen:1,
			block:1,
			position:{
				x:80,
				y:80
			}
		});

	}

	widgetController.addWidget('inline_edit_link', InlineEditLink);




	function closeWindowTrigger(element) {

		var hoverClass = 'hoverLayer';
		var stop_at	   = document.body;
		var hoverNode  = isDecendantOfNodeWithClassOf( hoverClass, element, stop_at );

		if(hoverNode && window.popupWindowHash[hoverNode.id]){

			element.onclick = function(){
					window.popupWindowHash[hoverNode.id].hidePopup();
					document.getElementById( '_blocking' ).style.display = 'none';
			}

		}
	}

	widgetController.addWidget('popwin_close_link', closeWindowTrigger );



	function formProcessor( element ){

		element.onclick = function(){

			var hoverClass = 'hoverLayer';
			var stop_at	   = document.body;
			var hoverNode  = isDecendantOfNodeWithClassOf( hoverClass, element, stop_at );

			var form  = this.form;
			var service = this.form.action;
			var query = '' + buildQueryString( form );

			var serviceQuery = '' + service + query;

			loadXMLContentInToElement( serviceQuery, hoverNode.id , false );

		}

	}

	widgetController.addWidget('process_form', formProcessor );

	/* ----- WindowShade ----- */
	function Windowshade( element ) {

		OptionItem( element );

		var label = getElementsWithClassNameOf( 'windowshade_label', element, new Array() )[0];

		element.label = label;

		var span = document.createElement('span');

		for( var i = (label.childNodes.length - 1); i >= 0; i-- ) {

			span.appendChild( label.removeChild( label.childNodes[i] ) );

		}

		label.appendChild( span );

		label.windowshade = element;

		label.onclick = function( event ) {

			this.windowshade.toggle();

			return false;

		}

		element.onclick = function() { return; }


	} // end Windowshade

	widgetController.addWidget('windowshade', Windowshade );




	function TabMenu( element ) {

		var l 			= element;
		l.displayArea 	= getSimilarElementsWithClassNameOf( 'tabdisplay', 'div', element )[0];
		l.tabOptionNode = getElementsWithClassNameOf( 'taboptions', element, new Array() )[0];//alert(element);
		l.tabs 			= getSimilarElementsWithClassNameOf( 'tab', 'a', l.tabOptionNode );
		l.selectedField = getElementsWithClassNameOf( 'selected_tab_field', l.tabOptionNode, new Array() )[0];

		l.current_item_index = 0;

		for ( var i = 0; i < l.tabs.length; i++ ) {

			var tab = l.tabs[i];

			tab.index = i;

			var content = document.getElementById( tab.parentNode.id.split( '_option' )[0] );

			if ( !hasClass(content, "async") ) { // internal resource

				tab.content = content;//.parentNode.removeChild( content );
				tab.content.style.display = 'none';

				tab.displayTab = function(){
					displayTab(this.index);
					return false;
				}

				tab.onclick = tab.displayTab;
			}

			else { // external resource

				tab.content = content;
				var cache = ( hasClass(content, "cache") )? true: false;
				var temp = document.createElement('div');
				temp.className = tab.content.className;
				temp.id = tab.content.id;

				tab.content.parentNode.replaceChild(temp, tab.content);
				// in order to use the height of this container later, store it
				// because when display is set to none, this info is lost.
				temp.storedHeight = parseInt(temp.offsetHeight);
				temp.style.display = 'none';
				tab.content = temp;

				tab.loadContent = function(){
					loadXMLContentInTo( this.href, this.content, cache );
					displayTab( this.index );
					return false;
				}

				tab.onclick = tab.loadContent;
				//EventManager.Add(tab, 'click', tab.loadContent, 1)

				if(l.current_item_index == tab.index){
					tab.loadContent();
				}

			}

		}

		function displayTab( index ) {

			hideItem( l.current_item_index );
			showItem( index );
			l.current_item_index = index;


		}

		function showItem( index ) {

			if(l.tabs.length == 0) { return; }

			l.tabs[index].content.style.display = '';
			addClass( l.tabs[index], 'selected' );

			if (l.selectedField != undefined){
				l.selectedField.value = l.tabs[index].content.id;
			}
		}

		function hideItem( index ) {

			if(l.tabs.length == 0) { return; }

			l.tabs[index].content.style.display = 'none';
			removeClass( l.tabs[index], 'selected' );

		}


		element.getDefaultOption = function() {

			// precondition: this.options should have at least 1 option before calling this function!

			for ( var i = 0; i < l.tabs.length; i++ ) {


				if (  window.location.hash && ( window.location.hash == this.tabs[i].hash ) ) {

					return i;

				}

				else if ( this.selectedField && (l.selectedField.value == this.tabs[i].content.id) ) {

					return i;

				}
			}

            // if it was not found, check each tabs selected status...
            // the last tab indicated as selected is the default option...
			for ( var i = 0; i < this.tabs.length; i++ ) {


				if ( hasClass( this.tabs[i], 'selected' ) ) {

					return i;

				}
			}

			// last resort: select the first option in the list...
			return 0;

		} // end getDefaultOption


		displayTab( element.getDefaultOption() );
		element.resetTabs = function(){
			displayTab( 0 );
		}


	} // end TabMenu


	widgetController.addWidget( 'tabmenu', TabMenu );


	function debugTool(c) {
		document.getElementById('navigation1').innerHTML += c;
	}

	// start DropDownNavigation
	function DropDownNavigation( element ) {

		if (document.all && document.getElementById) {
			navRoot = element;
			var allLIs = navRoot.getElementsByTagName("LI");
			for (i = 0; i < allLIs.length; i++ ) {
				var node = allLIs[i];
				node.onmouseover=function() {
					var tierTwo = getElementsByClassName(this,'div','tier2')[0];
					if (tierTwo) {
						var tierTwoChild = tierTwo.getElementsByTagName('UL')[0];
						tierTwoChild.style.display = "block";
					}
				};
				node.onmouseout=function() {
					var tierTwo = getElementsByClassName(this,'div','tier2')[0];
					if (tierTwo) {
					var tierTwoChild = tierTwo.getElementsByTagName('UL')[0];
						tierTwoChild.style.display = "none";
					}
				};
			}
		}
	}
	widgetController.addWidget('dropdown_links', DropDownNavigation);
	// end DropDownNavigation




	function RepeatableItemSet( element ){

		var inputElements = element.getElementsByTagName('input');
        var i;

		for (  i = 0 ; i < inputElements.length; i++ ) {

			if ( inputElements[i].getAttribute('name') == 'displayItem' ) {

				var displayItems = inputElements[i];

			}

		}


		if ( !displayItems || displayItems.value == undefined || displayItems.value == '' ) {

			element.displayItems = new Object();
			element.displayItems.value = 1;

		}

		else {

			element.displayItems = displayItems;
		}

		element.repeatableItems = getElementsWithClassNameOf( 'repeatableItem', element, new Array() );

		element.showNextItemButton = document.createElement('span');
		element.appendChild( element.showNextItemButton );
		element.showNextItemButton.appendChild( document.createTextNode('Add Item') );


		element.showNextItemButton.setAttribute('class', 'showNextItemButton');
		element.showNextItemButton.className = 'showNextItemButton'; // for IE


		element.showNextItemButton.repeatableItemSet = element;

		element.showNextItemButton.onclick = function() {

			this.repeatableItemSet.showNextItem();
			return false;

		};

		element.showNextItem = 	function() {

			if ( this.displayItems.value < this.repeatableItems.length ) {

				this.showItem( this.repeatableItems[this.displayItems.value] );
				this.displayItems.value++;

				if ( this.displayItems.value == this.repeatableItems.length ) {

					this.showNextItemButton.style.display = "none";

				}

				return true;

			}

			return false;

		};


		element.showItem = function( item ) {

			item.style.display = 'block';

		};


		// show items (hidden by default)...
		for ( i = 0; i < element.displayItems.value; i++) {

			element.showItem( element.repeatableItems[i] );

		}


	}//end Constructor for RepeatableItemSet Class


	widgetController.addWidget( 'repeatableItemSet', RepeatableItemSet );



	/* ----- Accordion ----- */
	function Accordion( element ) {

		SelectOneOptionList( element );

		var folds = getElementsWithClassNameOf( 'fold', element, new Array() );

		for ( var i = 0; i < folds.length; i++ ) {

			var fold = folds[i];
			OptionItem( fold );
			element.options[element.options.length] = fold;
			fold.optionList = element;


			var foldlabel = getElementsWithClassNameOf( 'foldlabel', fold, new Array() )[0];

			foldlabel.fold = fold;

			foldlabel.onclick = function() {

				this.fold.select();
				return false;

			}

			fold.onclick = function() {

				return;
			}


		}


		element.selected_fold = getElementsWithClassNameOf( 'selected_fold', element, new Array() )[0];

		element.onOptionSelect = function( option ) {

			this.selected_fold.value = this.selected.id;

		} // end onOptionSelect


		element.getDefaultOption = function() {

			if ( this.selected_fold && this.selected_fold.value ) {

				return document.getElementById( this.selected_fold.value );

			}

			// last resort: select the first option in the list...
			return this.options[0];

		} // end getDefaultOption


		element.selectDefaultOption = function() {

			this.defaultOption = this.getDefaultOption();

			if ( !this.defaultOption.isOptionSelected() ) {

				this.defaultOption.select();

			}

			else {

				this.selected = this.defaultOption;

			}

		} // end selectDefaultOption


		element.selectDefaultOption();

	} // end Accordion


	widgetController.addWidget( 'accordion', Accordion );


	function photoSelection( object ){

		// object.photoDisplay		=		cssQuery('.photoDisplay', object)[0];
		// object.selectMenu		=		cssQuery('select', object)[0];

		object.photoDisplay		=		getElementsWithClassNameOf('photoDisplay', object, new Array() )[0];
		object.selectMenu		=		object.getElementsByTagName('select')[0];

		object.selectMenu.onchange = function(){
			if(object.selectMenu.options[object.selectMenu.selectedIndex].value != "choose_one"){
				var newImageURL = '<img src="' + object.selectMenu.options[object.selectMenu.selectedIndex].value + '" border="0">';

				object.photoDisplay.innerHTML = newImageURL;
			}
		};
	}// end photoSelection


	widgetController.addWidget( 'photoSelection', photoSelection );


	//start themeSelection Class
	function themeSelection( object ){

		// object.controller 		= 		cssQuery( '.template_themes', object )[0];
		// object.display			=		cssQuery( '.template_layouts', object )[0];
		// object.allThemes 		= 		cssQuery( '.theme', object );

		object.controller 		= 		getElementsWithClassNameOf( 'template_themes', object, new Array() )[0];
		object.display			=		getElementsWithClassNameOf( 'template_layouts', object, new Array() )[0];
		object.allThemes 		= 		getElementsWithClassNameOf( 'theme', object, new Array() );

		for ( i = 0; i < object.allThemes.length; i++ ){

			var temp = new themes( object.allThemes[i], object.display );
		}

	}// end themeSelection


	//start themes Class
	function themes(object, display){

		object.onclick = function(){

			display.className = "layout_theme_" + this.id.slice( 6 );

		};


		if(getElementsWithClassNameOf( 'radio', object, new Array() )[0].checked){

			display.className = "layout_theme_" + object.id.slice( 6 );

		}

	}// end themes


	widgetController.addWidget( 'themeSelection', themeSelection );




	/* ----- Summary Widget ----- */
	function Summary( element ) {

		var selected_choices = getElementsWithClassNameOf( 'selected_choices', element, new Array() )[0];

		selected_choices.clearSelectedChoices = function() {

			for ( var i = ( this.childNodes.length - 1 ); i >= 0 ; i-- )  {

				this.removeChild( this.childNodes[i] );

			}

		}


		selected_choices.displaySelectedChoices = function() {

			this.clearSelectedChoices();

			var selected_options = new Array();

			for ( var i = 0; i < this.options.length; i++ ) {

				var option = this.options[i];

				var input = option.getElementsByTagName('input')[0];

				if ( input.checked  ) {

					var text_label = option.getElementsByTagName('span')[0];
					selected_options.push( text_label.childNodes[0].data );

				}

			}



			 if ( selected_options.length > 0 ) {

				var label = document.createElement("span");
				label.className = 'label'; // using className instead of setAttribute('class'... for IE
				label.appendChild( document.createTextNode('Currently Selected: ') );

				this.appendChild( label );

				this.appendChild( document.createTextNode( selected_options.join(', ') ) );

			}

			else {


				this.appendChild(  document.createTextNode( 'No items are selected.' ) );

			}


		}

		var options = element.getElementsByTagName( 'label' );

		for ( var i = 0; i < options.length; i++ ) {

			var option = options[i];

			var input = option.getElementsByTagName('input')[0];
			input.selected_choices = selected_choices;

			input.onclick = function() {

				this.selected_choices.displaySelectedChoices();

			}

		}

		selected_choices.options = options;

		selected_choices.displaySelectedChoices();


	} // end function Summary


	widgetController.addWidget( 'summary', Summary );



	function Gallery ( element ) {

		var current_item_number = 0;
		var gallery_items = getSimilarElementsWithClassNameOf( 'galleryItem', 'div', element );

		if ( gallery_items.length <= 0 ) { return; }

	 	function nextItem() {

			if ( ( current_item_number + 1 ) >= gallery_items.length ) {

				showItem( 0 );
				return;
			}

			showItem( current_item_number + 1 );

		}


		function prevItem() {

			if ( ( current_item_number - 1 ) < 0 ) {

				showItem( gallery_items.length - 1 );
				return;
			}

			showItem( current_item_number - 1 );

		}


		function showItem( itemNum ) {

			hideItem( current_item_number )
			gallery_items[itemNum].style.display = 'block';

			current_item_number = itemNum;
			updateCurrentItemNum();

		}

		function hideItem( itemNum ) {

			gallery_items[itemNum].style.display = '';

		}


		var current_item_indicator = getSimilarElementsWithClassNameOf('current_item_indicator', 'span', element )[0];

		var num_items_indicator = getSimilarElementsWithClassNameOf('num_items_indicator', 'span', element )[0];

		var prev_link = getSimilarElementsWithClassNameOf('prev_item', 'p', element )[0];
		prev_link.onclick = function( ) { prevItem();  }

		var next_link = getSimilarElementsWithClassNameOf('next_item', 'p', element )[0];
		next_link.onclick = function( ) { nextItem();  }



		function updateCurrentItemNum(  ) {

			removeAllChildNodes( current_item_indicator );

			current_item_indicator.appendChild( document.createTextNode( current_item_number + 1 ) );

		}

		function updateNumItemsNum(  ) {

			removeAllChildNodes( num_items_indicator );

			num_items_indicator.appendChild( document.createTextNode( gallery_items.length ) );

		}

		updateNumItemsNum();

		showItem( current_item_number );


	}


	widgetController.addWidget( 'gallery', Gallery );


	function PhotoGallery ( element ) {

		var displayArea = getElementsWithClassNameOf( 'displayArea', element, new Array() )[0];

		var current_item_number = 0;
		var displayed_item = getSimilarElementsWithClassNameOf( 'displayedItem', 'img', displayArea )[0];


		var galleryItems = getSimilarElementsWithClassNameOf( 'photoGalleryItems', 'div', element )[0];
		var navItems = galleryItems.getElementsByTagName('a');

		if ( navItems.length <= 0 ) { return; }

		for ( var i = 0; i < navItems.length; i++ ) {

			navItems[i].index = i;

			navItems[i].onclick = function() {

				showItem( this.index );

				return false;
			}

		}

	 	function nextItem() {

			if ( ( current_item_number + 1 ) >= navItems.length ) {

				showItem( 0 );
				return;
			}

			showItem( current_item_number + 1 );

		}


		function prevItem() {

			if ( ( current_item_number - 1 ) < 0 ) {

				showItem( navItems.length - 1 );
				return;
			}

			showItem( current_item_number - 1 );

		}


		function showItem( itemNum ) {

			hideItem( current_item_number );
			addClass( navItems[itemNum], 'selected' );

			var image = new Image();

			image.onload = function() { displayed_item.src = navItems[itemNum].href }

			image.src = navItems[itemNum];

			current_item_number = itemNum;

			updateCurrentItemNum();

			return true;

		}



		function hideItem( itemNum ) {

			removeClass( navItems[itemNum], 'selected' );

		}


		var current_item_indicator = getSimilarElementsWithClassNameOf('current_item_indicator', 'span', element )[0];

		var num_items_indicator = getSimilarElementsWithClassNameOf('num_items_indicator', 'span', element )[0];

		var prev_link = getSimilarElementsWithClassNameOf('prev_item', 'p', element )[0];
		prev_link.onclick = function( ) { prevItem(); return false; }

		var next_link = getSimilarElementsWithClassNameOf('next_item', 'p', element )[0];
		next_link.onclick = function( ) { nextItem(); return false; }


		function updateCurrentItemNum(  ) {

			removeAllChildNodes( current_item_indicator );

			current_item_indicator.appendChild( document.createTextNode( current_item_number + 1 ) );

		}

		function updateNumItemsNum(  ) {

			removeAllChildNodes( num_items_indicator );

			num_items_indicator.appendChild( document.createTextNode( navItems.length ) );

		}

		updateNumItemsNum();

		showItem( current_item_number );


	}


	widgetController.addWidget( 'photoGallery', PhotoGallery );



	function SimpleInjector( element ) {

		// var buttons = cssQuery( '.injector', element );
		var buttons = getElementsWithClassNameOf( 'injector', element, new Array() );


		for ( var i = 0; i < buttons.length; i ++ ) {

			var button = buttons[i];

			if ( !( button.parentEntry = isDecendantOfNodeWithClassOf( 'entry_a', element, document.body ) ) ) {

				button.parentEntry = isDecendantOfNodeWithClassOf( 'entry_b', element, document.body );

			}

			button.inputElements = button.parentEntry.getElementsByTagName('input');

			button.onclick = function() {

				this.inputElements[0].value = this.getAttributeNode('value').value;

			}

		}


	} // end simpleInjector


	widgetController.addWidget( 'simpleInjector', SimpleInjector );


	function DateInjector( element ) {

		// var buttons = cssQuery( '.injector', element );
		var buttons = getElementsWithClassNameOf( 'injector', element, new Array() );

		for ( var i = 0; i < buttons.length; i ++ ) {

			var button = buttons[i];

			if ( !( button.parentEntry = isDecendantOfNodeWithClassOf( 'entry_a', element, document.body ) ) ) {

				button.parentEntry = isDecendantOfNodeWithClassOf( 'entry_b', element, document.body );

			}

			button.inputElements = button.parentEntry.getElementsByTagName('input');

			button.onclick = function() {

				var value = this.getAttributeNode('value').value;
				var date_values = value.split('/');

				this.inputElements[0].value = date_values[0];
				this.inputElements[1].value = date_values[1];
				this.inputElements[2].value = date_values[2];

			}

		}


	} // end DateInjector


	widgetController.addWidget( 'dateInjector', DateInjector );


	// expose functions externally
	//popUpWindowCreator

	widgetController.UsernameRollover = UsernameRollover;
	widgetController.UsernameRolloverStatic = UsernameRolloverStatic;
	widgetController.InlineHelpLink = InlineHelpLink;
	widgetController.InlineEditLink = InlineEditLink;
	widgetController.closeWindowTrigger = closeWindowTrigger;
	widgetController.formProcessor = formProcessor;
	widgetController.Windowshade = Windowshade;
	widgetController.TabMenu = TabMenu;
	widgetController.RepeatableItemSet = RepeatableItemSet;
	widgetController.Accordion = Accordion;
	widgetController.photoSelection = photoSelection;
	widgetController.themeSelection = themeSelection;
	widgetController.Summary = Summary;
	widgetController.Gallery = Gallery;
	widgetController.PhotoGallery = PhotoGallery;
	widgetController.SimpleInjector = SimpleInjector;
	widgetController.DateInjector = DateInjector;
	widgetController.XMLRequest = XMLRequest;
	widgetController.DropDownNavigation = DropDownNavigation;
	widgetController.Carousel = cci.carousel.initialize;
	widgetController.TabSet = cci.tabSet.initialize;
	//widgetController.navSelected = navSelected;

	// Return widgetController object...
	return widgetController;

}(); // end cciWidgets


/* --- Testing --- */


function getAllFlashObjects( element ) {

	if ( element == undefined ) {

		element = document.body;

	}

	var matches = new Array();

	var objects  = element.getElementsByTagName('object');

	for( var i = 0; i < objects.length; i++ ) {

		var object = objects[i];

		if ( isFlashObject( object ) ) {

			matches[matches.length] = object;

		}


	}

	return matches;

}


function isFlashObject( element ) {

	if ( ( element.tagName.toLowerCase() == 'object' ) && ( element.getAttribute('type').toLowerCase() == "application/x-shockwave-flash" ) ) {

		return true;

	}

	return false;

}


function setFlashObjectsVisibility( visibility, element ) {

	var flash_objects  = getAllFlashObjects( element );

	for ( var i = 0; i < flash_objects.length; i++ ) {

		var flash_object = flash_objects[i];

		flash_object.style.visibility = visibility;

	}


} // end flash_objects

// This works for IE only please do not call this function anywhere else.
function makeHomepage(uri) {

	var theUri;
	if(uri) {
		theUri = uri;
	}
	else {
		theUri = location.href;
	}

	document.getElementById('make_homepage_1').style.behavior='url(#default#homepage)';
	document.getElementById('make_homepage_1').setHomePage(theUri);

}

// Testing only...
// addToWindowOnload( function() { setFlashObjectsVisibility('hidden'); } );

var iShim = {
	id: 'ishim',

	_getshim: function(){
		return document.getElementById(this.id);
	},

	getshim: function(){
		var ishim = this._getshim();
		if(ishim) return ishim;
		return this.create();
	},

	create: function(){
		var ishim = this._getshim();
		if(ishim) return ishim;

		ishim = document.createElement("IFRAME");
		ishim.id 			= "ishim";
		ishim.src 			= "javascript:false;";
		ishim.scrolling 	= "no";
		ishim.setAttribute("frameborder","0");
		ishim.style.filter = "alpha(opacity=0)";
		ishim.style.opacity = 0;
		ishim.style.position = "absolute";
		ishim.style.top 	= "0";
		ishim.style.left	= "0";
		ishim.style.display = "none";
		ishim.onclick = "javascript:void(0);";

		document.body.appendChild(ishim);
		return ishim;
	},

	show_with: function(host){
		if(!host || (!host.style && !document.getElementById(host)) || cci.browserDetect.browser != "Explorer") return;
		var s = this.getshim();
		var h = (host.style)? host : document.getElementById(host);
		s.style.width 	= parseInt(h.offsetWidth)+"px";
    	s.style.height 	= parseInt(h.offsetHeight)+"px";
    	s.style.top 	= parseInt(h.offsetTop)+"px";
    	s.style.left 	= parseInt(h.offsetLeft)+"px";
    	s.style.zIndex 	= h.style.zIndex - 1;
    	s.style.display = "block";
	},

	hide: function(){
		if(cci.browserDetect.browser != "Explorer") return;
		var s = this._getshim();
		if(!s) return;
		s.style.display = "none";
	}

}



/***
 * inPagePopup
 * Manages hiding an showing layers in the page
 *
 */
 var inPagePopup = new function(){
 	var self = this;

 	var getPopLayer   = function(id){ return document.getElementById(id).parentNode };
	var layers = []
	var evts = []; // stored custom events that can be attached to

	function createEvent(evt){
		self[evt] = new customEvent;
	}

	/***
	 * class used create a object for storing
	 * listenters and firing them
	 */
	function customEvent(){
		this.listeners = [];
		this.fire = function(id){
			for( var i = 0; i < this.listeners.length; i++){
				this.listeners[i](id);
			}
		}
	}

	/***
	 * adds listeners to custom functions defined above
	 * @evt {string} custom event handle
	 * @fn {function} listener function to fire when event occurs
	 */
	this.addListener = function( evt, fn ){
		if(self[evt]) self[evt].listeners.push(fn);
	}

	createEvent('onClose');
	createEvent('onOpen');


	function init_layer(id){
		if(layers[id]) return;
		var layer = getPopLayer(id);

		layer.parentNode.removeChild(layer);
		document.body.appendChild(layer);

		layer.style.zIndex = 100010;
		layers[id] = 'true';
	}

	this.openLayer = function(id){ // show layer
		init_layer(id);
		var scroll_dist = document.documentElement.scrollTop || document.body.scrollTop;
		var _popLayer = getPopLayer(id);
		var _screenh = parseInt(screen.availHeight);
		var _poph 	= parseInt(_popLayer.offsetHeight)

		if(is_standard){
			// if browser is IE 7 and above, fix the layer postion
			// so that it stays in the same position if you scroll the page
			// does work in older IE, blows up the layout
			_popLayer.style.position = "fixed";
		}else{
			// if browser is IE 6 and below, just set the layer at central point in the current window
			// will not follow the screen as it scrolls
			_popLayer.style.top = scroll_dist+"px";
		}

		_popLayer.style.display = "block";

		/*alert(document.body.clientWidth);*/

		_popLayer.style.left = (document.body.clientWidth-(750))/2 + "px";

		// force screen redraw for IE browsers
		redraw();
		cci.blockScreen.show();
		// fire the custom onOpen event for listeners to this popup
		self.onOpen.fire(id);
	}

	this.closeLayer = function(id){  // hide layer
		self.onClose.fire(id);
		getPopLayer(id).style.display = "none";
		cci.blockScreen.hide();

	}

 };

function redraw(){
	// use feature testing to determine if
	// we are dealing with IE
	if(window.showModalDialog){
		// test if we are working with IE6 and older
		if(!is_standard){
			// fire and modal window and close it, forcing a repaint of the screen
			window.showModalDialog("javascript:document.writeln('<" + "script" + ">window.close();<\/" + "script" + ">')");

		}else{
			// prior method does not work in IE7
			// resizing the window with a delay does the trick
			// does not work in IE6
			function repaint(){
				window.resizeBy(-1, -1);
				window.resizeBy(1, 1);
			}

		 	setTimeout(repaint,10);
		}
	}
}



/**
 * overlay.toggle
 * container for functions to create and toggle layers
 */
 var overlay = {};

/**
 * creates a toggle if does not exist, then toggles it
 *
 * @node {dom element} used to find the dom elements for layer and optional context
 * @lyrclass {string} layer element is found by class within the node dom object
 * @contextclass	{string} the context is found by class (if given, else it is the node)
 * and the layer is offset to the bottom left corner of the context
 */

 overlay.set_toggle = function(lyr_context, lyr_node, lyr_anchor){

	if(typeof(lyr_node) == 'string'){
		var l=[];
		getElementsWithClassNameOf(lyr_node, lyr_context, l);
		lyr_node = l[0];
	}

	if(!overlay.toggles[lyr_node.id]) {
		if( lyr_node == null ) return;
		// if toggle doesn't exist, try to create it
		if(!lyr_node.id ||!overlay.toggles[lyr_node.id]){
			var _anchor_node;
			lyr_context.style.position = 'relative';
			if(!lyr_node.id) lyr_node.id = 'ov_'+ new Date().getTime();

			if(typeof(lyr_anchor) == 'string'){
				var l=[];
				getElementsWithClassNameOf(lyr_anchor, lyr_context, l);
				_anchor_node = l[0];
			}else{
				_anchor_node = lyr_anchor;
			};

			//position and store layer
			if(lyr_node){
				lyr_node.style.position = 'absolute';
				lyr_node.style.top 		= parseInt(_anchor_node.offsetHeight) + "px";
				lyr_node.style.left 	= 0;
				lyr_node.style.zIndex 	= 100;
				overlay.toggles[lyr_node.id]  =
					{
						"layer":lyr_node,
						"context": lyr_context
					}

			}
		}
	}
	//toggle it
	overlay.toggle(lyr_node.id);
	return true;
}

/**
 * toggles a stored toggle
 *
 * @id {string} matched against [name,value] pair to find toggle
 */

 overlay.toggle = function(id, state){
	//no toggle, then exit
	var toggle, toggle_state;

	toggle = overlay.toggles[id];
	if(!toggle) return;
	if(state) {
		if(state == "block"){
			toggle_state = "none";
		}else if(state == "none"){
			toggle_state = "block";
		}
	}

	toggle_state = toggle_state? toggle_state : toggle.layer.style.display;
	//if hidden show it, else hide it
	if(toggle_state == 'block'){
		toggle.layer.style.display = 'none';
		toggle.context.style.zIndex = 0;
	}else{
		toggle.layer.style.display = 'block';
		toggle.context.style.zIndex = 100;
	}
 }

/**
 * store of toggles
 */
 overlay.toggles = [];

/**
 * Reads a cookie given a name
 */
function ReadCookie(cookieName) {
    var theCookie = "" + document.cookie;
    var ind = theCookie.indexOf(cookieName);
    if (ind == -1 || cookieName == "")
        return "";
    var ind1 = theCookie.indexOf(';',ind);
    if (ind1 == -1)
        ind1 = theCookie.length;
    return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}

function SetCookie(cookieName,cookieValue,nDays) {
    var today = new Date();
    var expire = new Date();
    if (nDays == null || nDays == 0)
        nDays=1;
    expire.setTime(today.getTime() + 3600000*24*nDays);
    document.cookie = cookieName+"="+escape(cookieValue)
        + ";expires="+expire.toGMTString();
}

// The cci.browserDetect object contains the browser name, version, and client OS.
// Implemented feb '07 by Benjamin Apple, written by (quirksmode.org).

cci.browserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
		this.is_supported();
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	is_supported: function () {

		if (!(this.browser == 'Firefox' || this.browser == 'Explorer' || this.browser == 'Safari' || this.browser == 'Chrome'))
		{
			var cookie = document.cookie;
			if (ReadCookie('unsupported_browser'))
			{
				// do nothing;
			}
			else
			{
				//set cookie and redirect
				SetCookie('unsupported_browser', 1, 14);
				window.location = '/misc/browser_detect.html?redirect_url='
								 + location.href;
			}
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
cci.browserDetect.init();


// For functions that may be receiving DOM elements or just element IDs.
// Receives a string or element as argument, returns the element. Written/added feb '07 by Benjamin Apple
function elCheck(element){
	return (document.getElementById(element)) ? document.getElementById(element) : element;
}


function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }
    }
    return (arrReturnElements)
}



/**
* strToInitialCaps is a utility used convert strings to Initial Caps
* @method cci.utils.strToInitialCaps
* @param {String}	str		A string object for the function to operate on
*/
cci.utils.strToInitialCaps = function(str) {
	var index;
	var tmpStr;
	var tmpChar;
	var preString;
	var postString;
	var strlen;

	if(!str||(typeof(str) != 'string')) return;

	tmpStr = str.toLowerCase();
	strLen = tmpStr.length;

	if (strLen > 0)  {
		for (index = 0; index < strLen; index++)  {

		if (index == 0)  {

			tmpChar 	= tmpStr.substring(0,1).toUpperCase();
			postString 	= tmpStr.substring(1,strLen);
			tmpStr 		= tmpChar + postString;

		} else {

			tmpChar = tmpStr.substring(index, index+1);

			if (tmpChar == " " && index < (strLen-1))  {
				tmpChar 	= tmpStr.substring(index+1, index+2).toUpperCase();
				preString 	= tmpStr.substring(0, index+1);
				postString 	= tmpStr.substring(index+2,strLen);
				tmpStr 		= preString + tmpChar + postString;
			}
		 }
	  }
   }
   return tmpStr;
}

/**
* getXY takes a DOMobject and returns it's x and y
* @method cci.utils.getXY
* @param {DOMObject}	obj	DOMobject.
* @returns {object} contains x, y as numbers
*/
cci.utils.getXY = function(obj) {
	var xPos, yPos, tempEl;

	function getBorderOffset(obj, dir){
	  if(cci.browserDetect.browser == "Explorer"){
	  	if(dir == "t"){
	  		var tOff = parseInt(obj.currentStyle['borderTopWidth']);
	  		tOff = (isNaN(tOff))? 0 : tOff;
	  		return tOff;
	  	}
	  	if(dir == "l"){
	  		var lOff = parseInt(obj.currentStyle['borderLeftWidth']);
	  		lOff = (isNaN(lOff))? 0 : lOff;
	  		return lOff;
	  	}
	  }
	  return 0;
	}

	xPos 	= obj.offsetLeft + getBorderOffset(obj,"l");
	yPos 	= obj.offsetTop + getBorderOffset(obj,"t");;
	tempEl 	= obj.offsetParent;

	while (tempEl != null) {
		xPos 	+= tempEl.offsetLeft + getBorderOffset(tempEl,"l");
		yPos 	+= tempEl.offsetTop + getBorderOffset(tempEl,"t");
		tempEl 	= tempEl.offsetParent;
	}

	return { x:xPos, y:yPos };
}

/**
* Screen builds an off used blocking screen used in the lightbox effect
* @object cci.BlockScreen
*/
cci.blockScreen = {

	screenId: 'block_screen',

	objArry: null,

	embedArry: null,

	ads: null,

	closeFn: function(){},

	show: function (closeFn, zindex) {
		var height, blayer;

		height = (parseInt(screen.availHeight) > document.body.offsetHeight) ?
		parseInt(screen.availHeight) : document.body.offsetHeight;
		zindex = (zindex)? zindex : 99999;

		blayer 					= this._getScreen();
		blayer.style.height 	= 80 + height + "px";
		blayer.style.width		= document.body.offsetWidth + "px";
		blayer.style.display 	= "block";
		blayer.style.zIndex 	= zindex;


		this._shiftDomObjects();
		iShim.show_with(blayer);

		if(!closeFn) return;
		this.closeFn = closeFn;
		if(YAHOO && YAHOO.util.Event) YAHOO.util.Event.addListener(blayer, "mousedown", this.closeFn);
	},

	hide: function(){
		var blayer = this._getScreen();
		if(YAHOO && YAHOO.util.Event) YAHOO.util.Event.removeListener(blayer, "mousedown", this.closeFn);

		blayer.style.display = "none";
		iShim.hide();
		this._unshiftDomObjects()
	},

	_getScreen:function (){
		var blayer = document.getElementById(this.screenId);

		function moveBlayer(){
			if(blayer && !blayer.moved){
				document.body.insertBefore(blayer,document.body.childNodes[0]);
				blayer.moved = true;
			}
		}

		if(blayer){
			moveBlayer();

			return blayer;
		}

		blayer = document.createElement('div');
		blayer.id = this.screenId;
		blayer.style.display = 'none';
		blayer.style.position = 'absolute';
		blayer.style.top = 0;
		blayer.style.left = 0;
		blayer.style.zIndex = 5;

		moveBlayer();
		return blayer;
	},

	_shiftDomObjects:function (){
		if(!this.objArry) this.objArry = document.getElementsByTagName('object');
		if(!this.embedArry) this.embedArry = document.getElementsByTagName('embed');
		if(!this.ads){
			this.ads = [];
			getElementsWithClassNameOf('ad', document.body, this.ads);
		}

		if(!this.widgets){
			this.widgets = [];
			getElementsWithClassNameOf('widget', document.body, this.widgets);
		}

		for( var o=0; o < this.objArry.length; o++ ){
			this.objArry[o].style.visibility = 'hidden';
		}

		for( var e=0; e < this.embedArry.length; e++ ){
			this.embedArry[e].style.visibility = 'hidden';
		}

		for( var a=0; a < this.ads.length; a++ ){
			this.ads[a].style.visibility = 'hidden';
		}

		if (cci.browserDetect.browser != "Explorer") {
			for( var i=0; i < this.widgets.length; i++ ){

				this.widgets[i]._opacity = this.widgets[i].style.opacity.toString();
				this.widgets[i].style.opacity = 1;

			}
		}

	},

	_unshiftDomObjects:function (){
		if(!this.objArry) this.objArry = document.getElementsByTagName('object');
		if(!this.embedArry) this.embedArry = document.getElementsByTagName('embed');
		if(!this.ads){
			this.ads = [];
			getElementsWithClassNameOf('ad', document.body, this.ads);
		}

		if(!this.widgets){
			this.widgets = [];
			getElementsWithClassNameOf('widget', document.body, this.widgets);
		}

		for( var o=0; o < this.objArry.length; o++ ){
			this.objArry[o].style.visibility = 'visible';
		}

		for( var e=0; e < this.embedArry.length; e++ ){
			this.embedArry[e].style.visibility = 'visible';
		}

		for( var a=0; a < this.ads.length; a++ ){
			this.ads[a].style.visibility = 'visible';
		}
		if (cci.browserDetect.browser != "Explorer") {
			for( var i=0; i < this.widgets.length; i++ ){
				this.widgets[i].style.opacity = this.widgets[i]._opacity;
			}
		}
	}
}


/**
* plopUp is a manager object responsible for creating dynamic layers using members of YUI Container Class
* @object cci.plopUp
*/

cci.plopUp = {

	active: null,

	plopUps : [],

	/**
	* makePlopUp accepts a cfg object which it uses to make the plopUp or return one if it already exists
	* @method makePlopUp
	* @param {Object}	cfgs	The configuration object literal containing the configuration that should be set for the plopUp.
	*/
	makePlopUp : function(cfgs){
		if (!cfgs) return;

		var  wdgId	 	 = cfgs.id;
		var  wdgType 	 = cci.utils.strToInitialCaps(cfgs.type);
		var  wdgSettings = cfgs.settings;
		var  wdgContent	 = cfgs.content;

		if(!wdgId ||!wdgType || !YAHOO.widget[wdgType]) return;

		var plopUp 	= YAHOO.widget[wdgType];
		var tmp 	= this.getPlopUp(wdgId);

		if(!tmp){
			// build the plopUp window and store the reference or
			tmp = this.plopUps[wdgId] = new plopUp(wdgId, wdgSettings);
		}
		else{
			// update the existing plopup with new settings
			tmp.cfg.applyConfig(wdgSettings);
		}

		var buildBody = {
			// if a url is specified, fill an iframe and place that in the body.
			useSrc : function(){
				return '<iframe id="' + wdgId + '_frame" name="' + wdgId + '_frame" style="border-style: none; border-width: 0pt; visibility: inherit; width: 100%; height:0; margin-left:0; margin-top:0;" frameBorder="0" scrolling="no" src="'+wdgContent.body.src+'"\/>';
			},
			// if body context is specified, grab from the context and plug that in. otherwise, make it an empty string.
			useContext : function(){
				var host, html;

				host = document.getElementById(wdgContent.body.context);
				if(!host) return "";

				html = host.innerHTML;
				//host.parentNode.removeChild(host);

				return html;
			},
			// if body content is specified, plug that in. otherwise, make it an empty string. Comment added to avoid self close
			useContent : function(){
				return wdgContent.body.content || "<!-- !! -->";
			}
		}

		/**
		* resizeIframeContentWindow resizes the content area if has an iframe as its container
		* @method resizeIframeContentWindow
		* @param {Number}	h	height to resize content window. if 0, then assume loading and show loading screen
		*/
		function resizeIframeContentWindow(h){
			var frameElement, frameName, desiredFrame, frameHeight;
			//var contentHeight = 0;

			frameElement 	= get_object(wdgId + '_frame');
			if(!frameElement||!frameElement.tagName.match('FRAME')) return;

			// apply new height to iframe
			frameElement.style.height = (h!=0)? parseInt(h) + "px" : 0;
			tmp.body.style.height = (h!=0)? "auto": getContentAreaHeight() + "px";
			if(frameElement.style.height == 0){
				addClass(tmp.body, "xml_loading");
			}else{
				removeClass(tmp.body, "xml_loading");
			}
			// fixes the display of the shadow;
			tmp.cfg.refireEvent("underlay");
			// set iframe to scroll if too large
			//if(contentHeight > frameHeight) frameElement.scrolling = "auto";
		}

		function collapseWindow(){
			if(tmp.header) addClass(tmp.header, "hide");
			hideMatte();
			tmp.cfg.refireEvent("underlay");

		}


		/**
		* getContentAreaHeight determines the content window height using the default window height setting
		* @method getContentAreaHeight
		* @returns {Number}
		*/
		function getContentAreaHeight(){
			var areaHeight, wrapOffsetH = 0;
			wrapOffsetH 	+= (get_object(wdgId + '_h'))? get_object(wdgId + '_h').offsetHeight : 0;
			wrapOffsetH 	+= (get_object(wdgId + '_f'))? get_object(wdgId + '_f').offsetHeight : 0;

			return areaHeight = (parseInt(wdgSettings.cheight) - wrapOffsetH)||'auto';
		}

		function showScreen(){
			cci.blockScreen.show(null, 5);
		}

		function showMatte(){
			if(wdgSettings.cmodal){
				showScreen();
				YAHOO.widget.Overlay.windowResizeEvent.subscribe(showScreen);
			}
		}

		function hideMatte(){
			if(wdgSettings.cmodal){
				cci.blockScreen.hide();
				YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(showScreen);
			}
		}

		function releasePlopUp(){
			cci.plopUp.active = null;
			//alert(cci.plopUp.active);
		}

		function assignPlopUp(){
			cci.plopUp.active = tmp;
			//alert(cci.plopUp.active);
		}

		function clearContent(){
			var frameElement;
			//var contentHeight = 0;

			frameElement 	= get_object(wdgId + '_frame');
			if(!frameElement||!frameElement.tagName.match('FRAME')) return;

			// apply new height to iframe
			frameElement.parentNode.removeChild(frameElement);
		}

		function closeAllOtherPlopUps(){
			for ( p in cci.plopUp.plopUps ) {
				if(cci.plopUp.plopUps[p] != tmp) cci.plopUp.plopUps[p].hide();
			}
		}

		if(wdgContent){
			var header, body, footer, method;

			header = wdgContent.header||'<div class="plopup_branding"><!-- empty --></div>';
			footer = wdgContent.footer||'<!-- empty -->';

			method = (wdgContent.body.src)? 'useSrc' : (wdgContent.body.context)? 'useContext' : (wdgContent.body.content)? 'useContent': null;
			body   = (method)? buildBody[method]() : "";

			if(!(header=='')) tmp.setHeader(header);
			if(wdgContent.footer) tmp.setFooter(footer);
			tmp.setBody(body);
		}

		tmp.render(document.body);

		if(!(wdgContent && wdgContent.header=='')) addClass(tmp.header, "plopup_header");

		addClass(tmp.body, "plopup_body xml_loading");
		if(wdgContent.footer) addClass(tmp.footer, "plopup_footer");

		var contentAreaH = getContentAreaHeight();

		tmp.body.style.height = (contentAreaH == 'auto'||0)? contentAreaH: contentAreaH +"px";

		if(!tmp.initd){
			tmp.resizeIframeContentWindow = resizeIframeContentWindow;
			tmp.collapse = collapseWindow;

			// add hiding and show of matte blocking layer
			tmp.beforeShowEvent.subscribe(closeAllOtherPlopUps, tmp, true);
			tmp.beforeShowEvent.subscribe(showMatte, tmp, true);
			tmp.beforeShowEvent.subscribe(assignPlopUp, tmp, true);

			tmp.hideEvent.subscribe(hideMatte, tmp, true);
			tmp.hideEvent.subscribe(releasePlopUp, tmp, true);
			tmp.initd = true;
		}
		// bless the content to init widgets
		var widgetDom = getElementsByClassName(get_object(wdgId), 'div', 'plopup_body')[0];
		cciWidgets.blessWidgets( widgetDom, true );

		return tmp;
	},

	/**
	* getPlopUp returns a plopUp if it exists
	* @method getPlopUp
	* @param {String}	wdgId	Id used when the plopUp was created.
	* @return {Object}	object of the YUI Container classes.
	*/
	getPlopUp : function(wdgId){
		return this.plopUps[wdgId];
	},

	/**
	*	cci.plopUp.EZ_Modal a common type of Modal PlopUp used on the site
	*	@id   		the name that will be used to refer to the plopup
	*	@width      plopup width
	*	@height     plopup height
	*	@cbody		object specifying head content and body context
	*				example: { header:"This is my header", body: { content: true }}
	*				({ src: true }|{ content: true }|{ context: null }) indicates where the content will come from
	**/
	EZ_Modal: function(id, width, height, cbody, hide_close_button){

		function respositionTo(xy){
			var scroll_dist = document.documentElement.scrollTop || document.body.scrollTop;
			var new_y = parseInt(scroll_dist)+parseInt(xy[1]);
			return [xy[0],new_y];
		}

		window[id] = {

			plopup: null,

			timer: null,

			isOpen: false,

			csrc: (cbody.body)? cbody.body.src+"": null,

			cfgs: {
				id	: "pid",

				type: "dialog",

				settings : {
					width:"580px",
					cheight:"580px",
					fixedcenter : (cbody.xy)? false : true,
					setxy: (cbody.xy)? cbody.xy : null,
					visible : false,
					cmodal: true,
				        close: (hide_close_button)? false : true,
					unfocusclose: true,
					constraintoviewport: true
				},

				content : cbody
			},

			open: function(c){

				var body = this.cfgs.content.body;
				var source  = (body.src)? 'src': (body.content)? 'content' : (body.context)? 'context' : '' ;
				var h = height;

				if(source && c) this.cfgs.content.body[source] = c;
				if(this.cfgs.settings.setxy){
					this.cfgs.settings.xy = respositionTo(this.cfgs.settings.setxy);

				}

				this.plopup = cci.plopUp.makePlopUp(this.cfgs);
				this.plopup.show();
				this.isOpen = true;

				clearTimeout(this.timer);

				if((this.csrc) && (this.csrc == "external")){
					this.plopup.resizeIframeContentWindow(h);
				}
			},

			close: function(ms, collapse, fade){
				var time = ms||0;
				if(!this.plopup||!this.isOpen) return;

				function hide(){
					if(fade) window[id].plopup.cfg.applyConfig({effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:1}});
					window[id].plopup.hide();
					window[id].isOpen = false;
					window[id].plopup.cfg.applyConfig({effect:null});
				}

				clearTimeout(this.timer);
				if(collapse) window[id].plopup.collapse();

				this.timer = setTimeout(hide, time);
			},

			resize: function(h){
				if(!this.plopup) return;
				this.plopup.resizeIframeContentWindow(h);
			},

			autoShowContent: function(){
				try{
					if((parent != window) && parent[this.cfgs.id]){
						var self = this;
						function resize(){
							var h = document.body.clientHeight;
							parent[self.cfgs.id].resize(h);
						}
						setTimeout(resize, 10);
					}
				}catch(e){}
			},

			autoHideContent: function(){
				try{
					if((parent != window) && parent[this.cfgs.id]){
						parent[this.cfgs.id].resize(0);
					}
				}catch(e){}
			},

			init: function(){
				this.cfgs.id = id;
				this.cfgs.settings.width = width;
				if(height) this.cfgs.settings.cheight = height;
				//this.cfgs.content.source = source;
			}
		}
		window[id].init();

		if(cbody && cbody.body && cbody.body.src){
			EventManager.Add( window, "load", function(){eval("window['"+id+"'].autoShowContent()")});
			EventManager.Add( window, "unload", function(){eval("window['"+id+"'].autoHideContent()")});
		}
	},

	/**
	*	cci.plopUp.EZ_PlopUp common cfgs for PlopUp used on the site
	*	@id   		the name that will be used to refer to the plopup
	*	@type      	YUI container type
	*	@width      plopup width
	*	@height     plopup height
	*	@cbody		object specifying head content and body context
	*				example: { header:"This is my header", body: { content: true }}
	*				({ src: true }|{ content: true }|{ context: null }) indicates where the content will come from
	*	@offset 	object specifying x and y offset of the plopup from the context
	*	@pause 		number in milliseconds indicating duration of pause before closing
	**/
	EZ_PlopUp: function(id, type, width, height, cbody, offset, pause){

		window[id] = {

			plopup: null,

			context_id: "#",

			timer: null,

			pauseTime: pause,

			isOpen: false,

			offset: {x:0, y:0},

			cfgs: {
				id: "pid",

				type: type,

				settings : {
					width : "295px",
					visible : false,
					close : true,
					unfocusclose : false,
					constraintoviewport : true
				},

				content : {}
			},

			open: function(refObj, contextObj){

				clearTimeout(this.timer);

				var ref_obj = get_object(refObj);
				var context_obj = get_object(contextObj);

				this.repositionTo(ref_obj, context_obj);
				if(this.isOpen) return;

				this.plopup.show();
				this.isOpen = true;
			},

			repositionTo: function(ref_obj, context_obj){
				if(context_obj.id == this.context_id) return;
				var refPos  = cci.utils.getXY(ref_obj);

				function removeListeners(){
					var win  = get_object(id);
					YAHOO.util.Event.removeListener( win, "mouseover", window[id].pauseClose);
					YAHOO.util.Event.removeListener( win, "mouseout", window[id].close);
				}

				function addListeners(){
					var win  = get_object(id);
					YAHOO.util.Event.addListener( win, "mouseover", window[id].pauseClose);
					YAHOO.util.Event.addListener( win, "mouseout", window[id].close);
				}

				if(this.plopup){
					this.plopup.hide();
					// remove existing listeners
					removeListeners();
					this.isOpen = false;
				}
				// prep and build/reset plopup
				this.cfgs.content.body.context 	= this.context_id = context_obj.id;
				this.cfgs.settings.xy 			= [(refPos.x + this.offset.x), (refPos.y + this.offset.y)];
				this.cfgs.settings.zindex 		= 10;
				this.plopup 					= cci.plopUp.makePlopUp(this.cfgs);

				addListeners();
				this.plopup.show();
				this.isOpen = true;

			},

			close: function(ms){
				var pause = parseInt(ms)||window[id].pauseTime||0;
				if(!window[id].plopup||!window[id].isOpen) return;

				function hide(){
					window[id].plopup.hide();
					window[id].isOpen = false;
				}
				window[id].timer = setTimeout(hide, pause);
			},

			resize: function(h){
				if(!this.plopup) return;
				this.plopup.resizeIframeContentWindow(h);
			},

			autoShowContent: function(){
				try{
					if((parent != window) && parent[this.cfgs.id]){
						var self = this;
						function resize(){
							var h = document.body.clientHeight;
							parent[self.cfgs.id].resize(h);
						}
						setTimeout(resize, 10);
					}
				}catch(e){}
			},

			autoHideContent: function(){
				try{
					if((parent != window) && parent[this.cfgs.id]){
						parent[this.cfgs.id].resize(0);
					}
				}catch(e){}
			},

			pauseClose: function(){
				clearTimeout(window[id].timer);
			},

			init: function(){
				this.cfgs.id = id;
				this.cfgs.settings.width = width;
				this.cfgs.settings.zindex = 10;
				if(height) this.cfgs.settings.cheight = height;
				if(offset && offset.x) this.offset.x = offset.x;
				if(offset && offset.y) this.offset.y = offset.y;
				this.cfgs.content = cbody;
			}
		}

		window[id].init();
	}
}




new cci.plopUp.EZ_Modal('secretAdmirerSuccessPlop', '580px', '150px', { body: { content: true }} );
new cci.plopUp.EZ_Modal('secretAdmirerPlayPlop', '480px', '150px', { body: { src: true }} );

new cci.plopUp.EZ_Modal('notePlopUp', '500px', '405px', { body: { src: true }} );
/* new cci.plopUp.EZ_Modal('commentPlopUp', '550px', '460px', { body: { src: true }} ); */
new cci.plopUp.EZ_Modal('commentPlopUp', '550px', '379px', { body: { src: true }} );
new cci.plopUp.EZ_Modal('cellRegistrationPlopUp', '551px', '110px', { body: { src: true }} );

new cci.plopUp.EZ_Modal('giftsPlopUp', '550px', '480px', { body: { src: true } } );
new cci.plopUp.EZ_Modal('sendNotes', '550px', '480px', { body: { src: true } } );
new cci.plopUp.EZ_Modal('cablePoll', '550px', '450px', { body: { src: true } } );
new cci.plopUp.EZ_Modal('sendCrush', '550px', '480px', { body: { src: true } } );
new cci.plopUp.EZ_Modal('commentOnStatus', '550px', '480px', { body: { src: true } } );
new cci.plopUp.EZ_Modal('sealCongratsPlopUp', '550px', '480px', { body: { src: true } } );
new cci.plopUp.EZ_Modal('sealConfirmPlopUp', '550px', '480px', { body: { src: true } } );
new cci.plopUp.EZ_Modal('newRegisterPlopUp', '600px', '550px', { body: { src: true } }, true);

new cci.plopUp.EZ_Modal('newsPlopup', '550px', '480px', { body: { src: true } } );
new cci.plopUp.EZ_Modal('bulletinPlopup', '550px', '480px', { body: { src: true } } );
new cci.plopUp.EZ_Modal('professionalPlopup', '550px', '480px', { body: { src: true } } );
new cci.plopUp.EZ_Modal('composeConfirmPlopup', '550px', '480px', { body: { src: true } } );


new cci.plopUp.EZ_Modal('seeDemoPlopUp', '550px', '378px', { body: { src: 'external' }} );
new cci.plopUp.EZ_Modal('truthsLiePlopUp', '314px', '172px', { body: { src: true }} );

new cci.plopUp.EZ_Modal('friendInvitePlopUp', '500px', '405px', { body: { src: true }} );
new cci.plopUp.EZ_Modal('sponsorPlopUp', '495px','430px', { header:"", body: { src: true }} );

new cci.plopUp.EZ_Modal('reportAbusePlopUp', '500px', '405px', { body: { src: true }} );

new cci.plopUp.EZ_Modal('findSexualPreference', '580px', '150px', { body: { src: true }} );

new cci.plopUp.EZ_Modal('updateEmailAddress', '580px', '400px', { body: { src: true }} );

new cci.plopUp.EZ_Modal('PostRegOnboarding', '580px', '400px', { body: { src: true }}, true);
new cci.plopUp.EZ_Modal('inviteFriendsPlopUp', '580px', '400px', { body: { src: true }});

new cci.plopUp.EZ_Modal('datingIBPPlopup', '499px', '400px', { body: { src: true }} );

new cci.plopUp.EZ_PlopUp('newMemberPlopUp', 'overlay', '300px', null, { body: { context: null }}, {x:85, y:-75}, 1000);

new cci.plopUp.EZ_PlopUp('emoticonPlopUp', 'overlay', '110px', null, { body: { context: null }}, {x:0, y:20}, 200);
new cci.plopUp.EZ_PlopUp('albumPlopUp', 'overlay', '247px', null, { body: { context: null }}, {x:76, y:0}, 50);

new cci.plopUp.EZ_PlopUp('yummyPlopUp', 'overlay', '247px', null, { body: { context: null }}, {x:0, y:-60}, 50);

new cci.plopUp.EZ_PlopUp('cancelOneClickPlopUp', 'panel', '295px', '64px',
						 { header: '<div class="head"><h2><span>Stop Receiving 1-Click Notes?<\/span><\/h2><\/div>',
						   body: { context: null }},
						 {x:-5, y:-64}, 50);

new cci.plopUp.EZ_PlopUp('sendOneClickOptionsPlopUp', 'panel', '295px', '148px',
						 { header: '<div class="head"><h2><span>More 1-Click Options<\/span><\/h2><\/div>',
						   body: { context: null }},
						 {x:-5, y:-120}, 50);

new cci.plopUp.EZ_PlopUp('sendOneClickPlopUp', 'panel', '285px', null,
						 { header: '<div class="head"><h2><span>Send a 1-Click Reply<\/span><\/h2><\/div>',
						   body: { context: null }},
						 {x:-5, y:-56}, 500);

new cci.plopUp.EZ_PlopUp('privacySettingPlopUp', 'panel', '72px', null,
						 { body: { context: null }},
						 {x:-0, y:-0}, 60);

new cci.plopUp.EZ_Modal('changePasswordPlopUp', '580px', '200px', { body: { context: true }} );


new cci.plopUp.EZ_Modal('uploadMoviePlop', '600px', '340px', { body: { context: true }} );


	/*
new cci.plopUp.EZ_PlopUp('changePasswordPlopUp', 'panel', '500px', null,
						 { header: '<div class="head"><h2><span>Change your password<\/span><\/h2><\/div>',
						   body: { context: null }}, {x:-56, y:-56});

	*/


/**
* focusLayer is used to highlight an area on the page, displaying additional info
* @object cci.focusLayer
*/

cci.focusLayer = {

	aFocusLayer:[],

	aDirection:{
		"top":"top",
		"right":"right",
		"bottom":"bottom",
		"left":"left"
	},

	/**
	* FocusLayer class
	* @class cci.focusLayer.FocusLayer
	* @param {String}	id			identifies the focusLayer.
	* @param {String}	direction 	indicates which direction the new info should appear.
	*/
	FocusLayer: function(id, direction, cfgs) {
		if (!id||!document.getElementById(id)) return;

		var tmpLayerId, tmpLayer, msgContainer, msgWidth, msgHeight, layerZindex, direction, isOpen, layer, paddingDir, lyrPadding;

		tmpLayerId 	= "focusLayerShim";
		msgWidth 	= (cfgs && cfgs.width)?  cfgs.width  : 200;
		msgHeight 	= (cfgs && cfgs.height)? cfgs.height : 200;
		layerZindex = (cfgs && cfgs.zindex)? cfgs.zindex : 10000;
		paddingDir	= "padding" + cci.utils.strToInitialCaps(direction);
		lyrPadding 	= (direction=="left"||direction=="right")? msgWidth : msgHeight;

		direction 	= (cci.focusLayer.aDirection[direction])? direction : "right";
		layer 		= document.getElementById(id);

		var self = this;

		this.open = function(cfgs) {
			var focusEl = (cfgs && cfgs.focus)? document.getElementById(cfgs.focus) : null;

			if(isOpen){
				if(focusEl){
					focusEl.focus();
					focusEl.select();
				}
				return;
			}
			expandLayer();
			focusEl.focus();
			focusEl.select();
			//cci.blockScreen.show(self.close, layerZindex-1);
		}

		this.close = function() {
			collapseLayer();
			//cci.blockScreen.hide();
		}

		function collapseLayer() {
			var anim;

			if(!isOpen) return;

			anim = new YAHOO.util.Anim("fl_msg", {opacity: { to:0 }}, .25, YAHOO.util.Easing.easeOut);
			anim.animate();

			layer.style.position 	= "static";
			layer.style.zIndex 		= "0";
			layer.style[paddingDir] = (parseInt(layer.style[paddingDir]) - lyrPadding) + "px";

			removeClass(layer, "focusLayer");
			tmpLayer.parentNode.replaceChild(layer, tmpLayer);
			msgContainer.parentNode.removeChild(msgContainer);
			isOpen = false;
		}

		function expandLayer() {
			var anim, height, width, parent, xy, xOffset, yOffset, currentPadding;
			if(isOpen) return;

			//isOpen  = true;
			height 	= layer.offsetHeight;
			width 	= layer.offsetWidth;
			parent 	= layer.parentNode;
			xy		= cci.utils.getXY(layer);

			xOffset	= (direction=="left")? msgWidth : 0;
			yOffset	= (direction=="top")? msgHeight : 0;

			// create tmp layer to hold content position
			tmpLayer = document.createElement("div");
			tmpLayer.style.height 	= height + "px";
			tmpLayer.style.width  	= width + "px";
			tmpLayer.setAttribute("id", tmpLayerId);

			// create msg container to hold new content
			msgContainer = document.createElement("div");
			msgContainer.style.height 	= msgHeight + "px";
			msgContainer.style.width  	= msgWidth + "px";
			msgContainer.setAttribute("id", "fl_msg");
			msgContainer.className = "focusLayer_msg";

			msgContainer.style.position = "absolute";

			if(direction == 'right'){
				msgContainer.style.right = "0";
			}else{
				msgContainer.style.left = "260px";	/* changed from 0 to 295 on 1-15-09 for the phishing alert story */
			}

			if(direction == 'bottom'){
				msgContainer.style.bottom = "0";
			}else{
				msgContainer.style.top = "230px";	 /* changed from 0 to 215 on 1-15-09 for the phishing alert story */
			}

			msgContainer.style.opacity = "0";
			msgContainer.style.filter = "alpha(opacity=0)";
			layer.appendChild(msgContainer);
			// add tmp layer to dom
			parent.insertBefore(tmpLayer, layer);

			// move layer to end of page
			document.body.appendChild(layer);


			// position layer in original position, accounting for new size
			layer.style.position 	= "absolute";
			layer.style.zIndex 		= layerZindex;
			layer.style.height 		= height + "px";
			layer.style.width 		= width + "px";
			layer.style.left 		= (xy.x - xOffset) + "px";
			layer.style.top 		= (xy.y - yOffset) + "px";

			// expand the size of the layer
			currentPadding = parseInt(layer.style[paddingDir]) || 0;
			layer.style[paddingDir] = (currentPadding + lyrPadding) + "px";

			addClass(layer, "focusLayer");

			anim = new YAHOO.util.Anim("fl_msg", {opacity: { to:1 }}, .5, YAHOO.util.Easing.easeOut);
			anim.animate();
			isOpen  = true;
		}
	}
}


/**
* dock is an object responsible for creating bottom,right positioned layer
uses members of YUI Container Class*
*The Dock is bottom and center aligned EA102908
* @object cci.dock
*/
cci.dock = {

	dockInstance: null,

	// Element References:
	self: null,
	dockNavContainer: null,
	selectedTabRef: null,
	iframeEl: null,

	// Dock Properties:
	dockWidth:	null,
	dockHeight:	null,
	dockTop:	null,
	dockLeft:	null,
	dockGutter: 30,
	iframeName: "dockIframe",
	iframeUrl: null,
	tabs: null,
	contentLayout: null,
	verticalLayout: null,
	dockCookieClose: null,

	// Dock Dimensions:
	dockDims: {
		frameWidth: null,
		dockDefaultHdrH: 20,
		dockDefaultNavH: 4,
		dockDefaultIframeH: 86
	},

	//control number of results based on resolution
	// based on heights 600, 768, 1024
	size: null,

	isSet: null,
	//dockIsMin: null,

	// sets the dimensions of dock based on viewport resolutions
	// takes tabURLs to refresh http content in each tab
	// takes id to set width on dock based on content type
	setDockDims : function(tabs){

		//set dock width
		if(cci.dock.contentLayout == 'narrow') {
			/*cci.dock.dockWidth = 920; /*YAHOO.util.Dom.getViewportWidth() - 100;*/

			/*cci.dock.dockWidth = YAHOO.util.Dom.getViewportWidth() - 20;*/
			cci.dock.dockWidth = 840;



			cci.dock.dockDims.frameWidth = cci.dock.dockWidth; //cci.dock.dockWidth;
		}
		else {
			cci.dock.dockWidth = 264;
			cci.dock.dockDims.frameWidth = cci.dock.dockWidth;
		}
		cci.dock.dockInstance.cfg.setProperty("width", cci.dock.dockWidth + "px");

		//this reloads the dock content. it is no longer needed as the dock is now at the bottom
		//if(cci.dock.dockIsMin != true) {

			//cci.dock.size = cci.dock.getUserViewHeight();
			//cci.dock.reloadTabContent();
			//cci.dock.setFrameHeight();
			//cci.dock.dockHeight = (cci.dock.dockDims.dockDefaultIframeH + cci.dock.dockDims.dockDefaultHdrH + cci.dock.dockDims.dockDefaultNavH);
			//cci.dock.dockInstance.cfg.setProperty("height", cci.dock.dockHeight + "px");
		//}

	},

	make : function (id, dockTitle, pageURL, tabURLs) {

		//make vars
		cci.dock.tabs = tabURLs;
		cci.dock.iframeUrl = pageURL;

		//wide or narrow?
		cci.dock.setLayout(id);

		cci.dock.dockInstance = new YAHOO.widget.Panel(id, {
			width: cci.dock.dockWidth + "px",
			height: cci.dock.dockHeight + "px",
			fixedcenter: false,
			underlay: false, /*underlay: "shadow",*/
			close: false, /* disable close */
			visible: true,
			draggable: false,
			zIndex: 4}
		);

		cci.dock.setDockDims(cci.dock.tabs);
		var dockMinCookie = getCookie("isDockMinimized");

		cci.dock.dockIsMin = (dockMinCookie == 'true') ? true : false;

		buildHeader(id, dockTitle, tabURLs);

		//check min session first, then build if necessary
		if (cci.dock.dockIsMin == false) { buildContent(cci.dock.iframeUrl); }

		cci.dock.dockInstance.render(document.body);

		cci.dock.self = document.getElementById(id + "_c");

		addClass(cci.dock.self, 'dock');

		// on page load if dock cookie is set to true, call min function
		if (cci.dock.dockIsMin == true) { cci.dock.minimize(true); }

		cci.dock.setPosition();

		// Private Function: Build Header
		function buildHeader(containerID, dockTitle, tabURLs) {

			// draw dock header container
			var dockHeaderContainer = document.createElement('div');

			//draw handle
			var dockHandle = document.createElement('div');
			dockHandle.setAttribute('id','dockHandle');
			dockHeaderContainer.appendChild(dockHandle);

			// draw dock title container
			var dockHandleHdr = document.createElement('h2');
			dockHandle.appendChild(dockHandleHdr);

			//dock header text
			var dockHandleText = document.createTextNode(dockTitle);
			dockHandleHdr.appendChild(dockHandleText);

			// draw dock min anchor & span for text
			var dockHandleBtn = document.createElement('a');
			dockHandleBtn.setAttribute('id', 'dockMinBtn');
			dockHandleBtn.setAttribute('class','minimize');
			dockHandleBtn.setAttribute('href','#');
			dockHandle.appendChild(dockHandleBtn);

			var dockHandleBtnSpan = document.createElement('span');
			dockHandleBtn.appendChild(dockHandleBtnSpan);

			var dockHandleBtnText = document.createTextNode('[minimize]');
			dockHandleBtnSpan.appendChild(dockHandleBtnText);

			// draw tabs
			cci.dock.dockNavContainer = document.createElement('div');
			addClass(cci.dock.dockNavContainer, "pagenav");
			cci.dock.dockNavContainer.setAttribute('id','pagenav');
			dockHeaderContainer.appendChild(cci.dock.dockNavContainer);

			var dockNavUl = document.createElement('ul');
			cci.dock.dockNavContainer.appendChild(dockNavUl);

			for (var i=0; i < tabURLs.length; i++){
				//create list element
				var listElement = document.createElement('li');
				if (tabURLs[i].selected == true) {
					addClass(listElement, "navitem_selected");
					dockNavUl.appendChild(listElement);
					cci.dock.selectedTabRef = getElementsWithClassNameOf('navitem_selected', dockNavUl, new Array() )[0];
					}
				else {
					addClass(listElement, "navitem");
					dockNavUl.appendChild(listElement);
				}

				// create anchor
				var anchorElement = document.createElement('a');
				anchorElement.setAttribute('href',tabURLs[i].url + "&size=" + cci.dock.size);
				//addClass(anchorElement, "tab");
				anchorElement.target = cci.dock.iframeName;
				//anchorElement.setAttribute('target','dockFrame');
				listElement.appendChild(anchorElement);

				//create span
				var spanElement = document.createElement('span');
				anchorElement.appendChild(spanElement);

				var textElement = document.createTextNode(tabURLs[i].text);
				spanElement.appendChild(textElement);

				anchorElement.onclick = function() {
					if (cci.dock.iframeName) {
						document.getElementsByName(cci.dock.iframeName)[0].src = this.href;
					}
					//alert(this.href);
					if (cci.dock.selectedTabRef) {
						addClass(cci.dock.selectedTabRef, "navitem");
						removeClass(cci.dock.selectedTabRef, "navitem_selected");
						addClass(this.parentNode, "navitem_selected");
						removeClass(this.parentNode, "navitem");
						cci.dock.selectedTabRef = this.parentNode;
					}
					return false;
				};
			}

			cci.dock.dockInstance.setHeader(dockHeaderContainer);
			if (cci.dock.dockIsMin) {
				cci.dock.dockNavContainer.style.display = "none";
			}

			// set onclick event
			dockHandle.onclick = function(){
				cci.dock.minimize();
				return false;
			};

		}

		// Private Function: Build Content (iFrame)
		function buildContent(pageURL) {
			//			dockIframe = "<iframe id='dockFrameId' frameBorder='0' scrolling='no' border='0' height='"+ cci.dock.dockDims.dockDefaultIframeH +"px' width='" + cci.dock.dockDims.frameWidth + "px' name='"+ cci.dock.iframeName +"' src='"+ cci.dock.iframeUrl + "'\/>";
			dockIframe = "<iframe id='dockFrameId' frameBorder='0' scrolling='no' border='0' height='"+ cci.dock.dockDims.dockDefaultIframeH +"px' width='" + cci.dock.dockDims.frameWidth + "px' name='"+ cci.dock.iframeName +"' src='"+ cci.dock.iframeUrl + "'\/>";
			cci.dock.dockInstance.setBody(dockIframe);
		}

		YAHOO.widget.Overlay.windowResizeEvent.subscribe(cci.dock.setDockDims);
		YAHOO.widget.Overlay.windowResizeEvent.subscribe(cci.dock.setPosition);
		YAHOO.widget.Overlay.windowScrollEvent.subscribe(cci.dock.setPosition);

		cci.dock.dockInstance.hideEvent.subscribe(cci.dock.end, this, true);

		var parent = document.getElementById(id);
		var closeElement = getElementsByClassName( parent ,'span', 'container-close');
		YAHOO.util.Event.addListener(closeElement, "mouseover", cci.dock.addHover, this);
		YAHOO.util.Event.addListener(closeElement, "mouseout", cci.dock.removeHover, this);
	},

	setLayout : function (id) {
		//set dock horizontal layout
		if(id == 'memberDock') {
			cci.dock.contentLayout = 'narrow';
		}
		else {
			cci.dock.contentLayout = 'wide';
		}

		//set dock vertical layout
		if(id == 'memberDock') {
			cci.dock.verticalLayout = 'member';
		}
		else if(id == 'videoDock') {
			cci.dock.verticalLayout = 'video';
		}
		else{
			cci.dock.verticalLayout = 'blog';
		}

	},

	reloadTabContent : function () {
		if(cci.dock.iframeUrl != null) {
				// for changing dock dim on event, we need to refresh http headers with this new url
				//alert(cci.dock.iframeUrl);
				if (cci.dock.iframeUrl.indexOf('size') == -1) {
					cci.dock.iframeUrl = cci.dock.iframeUrl + "&size=" + cci.dock.size;
				}
				else {

					var pageNav = document.getElementById('pagenav');
					var tabElement = pageNav.getElementsByTagName('li');
					var tabSelected = getElementsByClassName(pageNav,'li', 'navitem_selected');
					var oSelectedChild = tabSelected[0].childNodes[0];
					var oAnchors = new Array();

					for (i = 0; i < tabElement.length; i++) {

						var oChildren = tabElement[i].childNodes[0];
						//alert(oElement);
						oAnchors.push(oChildren);
						//alert(tabURLs[i].url);
						oAnchors[i].href = cci.dock.tabs[i].url + "&size=" + cci.dock.size;
						//oAnchors = tabURLs[i].url + "&size=" + cci.dock.size;
					}
					if(document.getElementsByName(cci.dock.iframeName)[0].src != oSelectedChild.href){
						document.getElementsByName(cci.dock.iframeName)[0].src = oSelectedChild.href;
					}
				}
			}
	},

	setFrameHeight : function() {


	cci.dock.dockDims.dockDefaultIframeH = 60;


		/*switch(cci.dock.size) {

				case "xs":
					if(cci.dock.verticalLayout == 'blog') {
						cci.dock.dockDims.dockDefaultIframeH = 213;
					}
					else if (cci.dock.verticalLayout == 'video'){
						cci.dock.dockDims.dockDefaultIframeH = 204;
					}
					else {
						cci.dock.dockDims.dockDefaultIframeH = 178;
					}
					break
				case "s":
					if(cci.dock.verticalLayout == 'blog') {
						cci.dock.dockDims.dockDefaultIframeH = 336;
					}
					else if (cci.dock.verticalLayout == 'video'){
						cci.dock.dockDims.dockDefaultIframeH = 318;
					}
					else {
						cci.dock.dockDims.dockDefaultIframeH = 285;
					}
					break
				case "m":
					if(cci.dock.verticalLayout == 'blog') {
						cci.dock.dockDims.dockDefaultIframeH = 459;
					}
					else if (cci.dock.verticalLayout == 'video'){
						cci.dock.dockDims.dockDefaultIframeH = 432;
					}
					else {
						cci.dock.dockDims.dockDefaultIframeH = 392;
					}
					break
				case "l":
					if(cci.dock.verticalLayout == 'blog') {
						cci.dock.dockDims.dockDefaultIframeH = 459;
					}
					else if (cci.dock.verticalLayout == 'video'){
						cci.dock.dockDims.dockDefaultIframeH = 546;
					}
					else {
						cci.dock.dockDims.dockDefaultIframeH = 499;
					}
					break
				default:
					if(cci.dock.verticalLayout == 'blog') {
						cci.dock.dockDims.dockDefaultIframeH = 459;
					}
					else if (cci.dock.verticalLayout == 'video'){
						cci.dock.dockDims.dockDefaultIframeH = 432;
					}
					else {
						cci.dock.dockDims.dockDefaultIframeH = 392;
					}
					break

			}*/

	},

	end : function () {
		//onload if session has ended, dont show dock
		setCookie('isDockClosed', true, null, "/");
	},


	addHover : function() {
		addClass(this, 'hover');
	},

	removeHover : function() {
		removeClass(this, 'hover');
	},

	debug : function (d) {
		document.getElementById('debug_me').innerHTML += d + ":";
	},

	setPosition : function () {
		//cci.dock.debug("dock is setting");
		// Private Function: Set Position of Dock
		var scrollTopVal = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;

		/*cci.dock.dockTop = ((YAHOO.util.Dom.getViewportHeight() - cci.dock.dockHeight) + scrollTopVal) - cci.dock.dockGutter;*/
		/*cci.dock.dockLeft = (YAHOO.util.Dom.getViewportWidth() - cci.dock.dockWidth) - cci.dock.dockGutter;*/


		cci.dock.dockTop = ((YAHOO.util.Dom.getViewportHeight() - cci.dock.dockHeight) + scrollTopVal);
		cci.dock.dockLeft = Math.abs(Math.round((YAHOO.util.Dom.getViewportWidth() - cci.dock.dockWidth) /2)) ; //10 //(YAHOO.util.Dom.getViewportWidth() - cci.dock.dockWidth) /2 ; //this determines where the top left of the dock starts

		/*cci.dock.dockInstance.cfg.setProperty("y", cci.dock.dockTop);*/
		cci.dock.dockInstance.cfg.setProperty("x", cci.dock.dockLeft);
		/*var y = cci.dock.dockInstance.cfg.getProperty("y");*/
		var x = cci.dock.dockInstance.cfg.getProperty("x");

		/*alert(cci.dock.dockInstance.cfg.getProperty("x"));*/

		cci.dock.isSet = true;

		/*ie 7 has decided to stop recieving the style attribute, so we are hardcoding it. EA033009 */
		document.getElementById('memberDock_c').style.left=cci.dock.dockLeft+"px";


	},


	minimize : function(init){
		var iframeRef = document.getElementById("dockFrameId");

		//maximize dock
		if (init == undefined && cci.dock.dockIsMin) {
			//cci.dock.debug("init:" + init);

			cci.dock.dockHeight = (cci.dock.dockDims.dockDefaultIframeH + cci.dock.dockDims.dockDefaultHdrH + cci.dock.dockDims.dockDefaultNavH);
			cci.dock.dockInstance.cfg.setProperty("height", cci.dock.dockHeight + "px");
			cci.dock.dockNavContainer.style.display = "block";
			if(iframeRef){iframeRef.style.display = "block";}
			else{
				dockIframe = "<iframe id='dockFrameId' frameBorder='0' scrolling='no' border='0' height='"+ cci.dock.dockDims.dockDefaultIframeH +"px' width='" + cci.dock.dockDims.dockDefaultW + "px' name='"+ cci.dock.iframeName +"' src='"+ cci.dock.iframeUrl + "&size=" + cci.dock.size + "' \/>";
				cci.dock.dockInstance.setBody(dockIframe);
				cci.dock.dockInstance.render();
			}
			cci.dock.dockIsMin = false;
		}

		//minimize dock
		else {
			cci.dock.dockHeight = cci.dock.dockDims.dockDefaultHdrH;
			cci.dock.dockInstance.cfg.setProperty("height", cci.dock.dockHeight + "px");
			if(cci.dock.dockNavContainer) {
				cci.dock.dockNavContainer.style.display = "block";
			}
			if(iframeRef) { iframeRef.style.display = "none"; }
			cci.dock.dockIsMin = true;
		}
		cci.dock.setPosition();
		setCookie('isDockMinimized', cci.dock.dockIsMin, null, "/");

		if(cci.instant_alert.instant_alertInstance) {
			cci.instant_alert.set();
		}

	},

	getUserViewHeight : function (){
		var rScale = YAHOO.util.Dom.getViewportHeight();
		// round viewport height to less than 600, 768 or 1024
		// xs -> less than 350px viewport
		// s -> greater than 350 px less than or 550
		// m -> greater than 550 less than 700
		// l -> greater than 700


		xs = rScale < 350 ? true : false;
		s = (rScale <= 550 && (rScale > 350)) ? true : false;
		m = ((rScale <= 700) && (rScale > 550)) ? true : false;
		l = (rScale > 700) ? true : false;

		var viewSize = [
			{"xsScreenSize" : xs, "name" : "xs"},
			{"sScreenSize" : s,"name" : "s"},
			{"mScreenSize" : m, "name" : "m"},
			{"lScreenSize" : l, "name" : "l"}
		]


		function selectView(){
			var i;
			var j;
			for (i in viewSize) {
					for (j in viewSize[i]) {
							if(viewSize[i][j] == true){ // ?????
									return viewSize[i].name;
							}
					}
			}
		}

		var myView = selectView();
		//viewport/result - o - meter
		//alert(myView);
		return myView;
	}

}



cci.instant_alert = {

	instant_alertInstance: null,

	/* Element References:*/

	// instant_alert Properties:
	instant_alertWidth:	226,
	instant_alertHeight:	null,
	instant_alertTop:	null,
	instant_alertLeft:	null,
	instant_alertGutter: 10,
	iframeName: "instant_alertIframe",
	iframeUrl: null,
	siblingY: null,
	headBuilt: false,
	contentBuilt: false,

	// instant_alert Dimensions:
	/*instant_alertDims: {
		instant_alertDefaultW: 226,
		instant_alertDefaultHdrH: 20,
		instant_alertDefaultNavH: 27,
		instant_alertDefaultIframeH: 512 //392
	},*/

	instant_alertCookieClose: null,
	//instant_alertIsMin: null,

	make : function (id, instant_alertTitle, pageURL) { //make : function (id, instant_alertTitle, pageURL, tabURLs) {

		var self = this;
		var active_plopup = cci.plopUp.active;

		if(active_plopup){
			return active_plopup.hideEvent.subscribe(delayed_make, self, true);
		}

		function delayed_make(){
			cci.instant_alert.make(id, instant_alertTitle, pageURL);
			active_plopup.hideEvent.unsubscribe(delayed_make, self, true);
		}

		cci.instant_alert.instant_alertInstance = new YAHOO.widget.Panel(id, {
			width: cci.instant_alert.instant_alertWidth + "px",
			height: cci.instant_alert.instant_alertHeight + "px",
			fixedcenter: false,
			underlay: false, //"shadow",
			close: true, /* disable close */
			visible: true,
			draggable: false,
			zIndex: 8}
		);


		cci.instant_alert.iframeUrl = pageURL;

		cci.instant_alert.instant_alertHeight = 136;
		cci.instant_alert.instant_alertInstance.cfg.setProperty("height", cci.instant_alert.instant_alertHeight + "px");

		var instant_alertMinCookie = getCookie("isinstant_alertMinimized");

		cci.instant_alert.instant_alertIsMin = (instant_alertMinCookie == 'true') ? true : false;

		if (cci.instant_alert.headBuilt == false) {
			buildHeader(id, instant_alertTitle); //buildHeader(id, instant_alertTitle, tabURLs);
		}

		//if instant_alert is built, reuse it
		if (cci.instant_alert.contentBuilt == false) {
			buildContent(cci.instant_alert.iframeUrl);
		}
		else {
			document.getElementsByName(cci.instant_alert.iframeName)[0].src = cci.instant_alert.iframeUrl;
		}

		//cci.instant_alert.debug("render me");
		cci.instant_alert.instant_alertInstance.render(document.body);

		addClass((document.getElementById(id + "_c")), 'instant_alert');

		// on page load if instant_alert cookie is set to true, call min function
		if (cci.instant_alert.instant_alertIsMin == true) { cci.instant_alert.minimize(true); }

		cci.instant_alert.set();

		// Private Function: Build Header
		function buildHeader(containerID, instant_alertTitle) { //function buildHeader(containerID, instant_alertTitle, tabURLs) {
			cci.instant_alert.headBuilt = true;

			// draw instant_alert header container
			var instant_alertHeaderContainer = document.createElement('div');

			//draw handle
			var instant_alertHandle = document.createElement('div');
			instant_alertHandle.setAttribute('class','instant_alertHandle');
			instant_alertHeaderContainer.appendChild(instant_alertHandle);

			// draw instant_alert title container
			var instant_alertHandleHdr = document.createElement('h2');
			instant_alertHandle.appendChild(instant_alertHandleHdr);

			//instant_alert header text
			var instant_alertHandleText = document.createTextNode(instant_alertTitle);
			instant_alertHandleHdr.appendChild(instant_alertHandleText);

			cci.instant_alert.instant_alertInstance.setHeader(instant_alertHeaderContainer);
			if (cci.instant_alert.instant_alertIsMin) {
				cci.instant_alert.instant_alertNavContainer.style.display = "none";
			}

			// set onclick event
			instant_alertHandle.onclick = function(){
				cci.instant_alert.end;
				return false;
			};

		}

		// Private Function: Build Content (iFrame)
		function buildContent(pageURL) {
			cci.instant_alert.contentBuilt = true;
			cci.instant_alert.instant_alertIframe = "<iframe class='instant_alertFrame' frameBorder='0' scrolling='no' border='0' height='101px' width='219px' name='"+ cci.instant_alert.iframeName +"' src='"+ cci.instant_alert.iframeUrl + "'\/>";
			cci.instant_alert.instant_alertInstance.setBody(cci.instant_alert.instant_alertIframe);
		}

		// in IE6 this event fires endlessly (for instant_alert object only), this needs to be fixed in order to prevent load issues
		YAHOO.widget.Overlay.windowResizeEvent.subscribe(cci.instant_alert.set);

		YAHOO.widget.Overlay.windowScrollEvent.subscribe(cci.instant_alert.set);

		cci.instant_alert.instant_alertInstance.hideEvent.subscribe(up_clear_all, this, true);

		var parent = document.getElementById(id);
		var closeElement = getElementsByClassName( parent ,'span', 'container-close');
		YAHOO.util.Event.addListener(closeElement, "mouseover", cci.instant_alert.addHover, this);
		YAHOO.util.Event.addListener(closeElement, "mouseout", cci.instant_alert.removeHover, this);
	},

	end : function (instant_alertId) {
		var instant_alert = document.getElementById(instant_alertId + '_c');
		if(instant_alert.style.visibility == "visible") {
			instant_alert.style.visibility = "hidden";
		}
	},

	debug : function (d) {
		document.getElementById('debug_me').innerHTML += d + "<br />";
	},

	set : function () {

		//cci.instant_alert.debug("set it");

		//before computing Y, wait till dock is rendered
		if ((cci.dock.dockInstance !=null) && (cci.dock.isSet)) {

			cci.instant_alert.siblingY = cci.dock.dockTop;

			//cci.instant_alert.debug('instant_alertTopbefore'+ cci.instant_alert.instant_alertTop);

			// Private Function: Set Position of instant_alert
			var scrollTopVal = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
			cci.instant_alert.instant_alertTop = (cci.instant_alert.siblingY - cci.instant_alert.instant_alertHeight) - cci.instant_alert.instant_alertGutter; //edit
			cci.instant_alert.instant_alertLeft = (YAHOO.util.Dom.getViewportWidth() - cci.instant_alert.instant_alertWidth) - cci.instant_alert.instant_alertGutter;
			cci.instant_alert.instant_alertInstance.cfg.setProperty("y", cci.instant_alert.instant_alertTop);
			cci.instant_alert.instant_alertInstance.cfg.setProperty("x", cci.instant_alert.instant_alertLeft);
			var y = cci.instant_alert.instant_alertInstance.cfg.getProperty("y");
			var x = cci.instant_alert.instant_alertInstance.cfg.getProperty("x");
			//if (t) { clearTimeout(t); }
		}
		else {

			// Private Function: Set Position of instant_alert
			var scrollTopVal = (document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;

			cci.instant_alert.instant_alertTop = ((YAHOO.util.Dom.getViewportHeight() - cci.instant_alert.instant_alertHeight) + scrollTopVal) - cci.instant_alert.instant_alertGutter;

			cci.instant_alert.instant_alertLeft = (YAHOO.util.Dom.getViewportWidth() - cci.instant_alert.instant_alertWidth) - cci.instant_alert.instant_alertGutter;
			cci.instant_alert.instant_alertInstance.cfg.setProperty("y", cci.instant_alert.instant_alertTop);
			cci.instant_alert.instant_alertInstance.cfg.setProperty("x", cci.instant_alert.instant_alertLeft);
			var y = cci.instant_alert.instant_alertInstance.cfg.getProperty("y");
			var x = cci.instant_alert.instant_alertInstance.cfg.getProperty("x");
			//if (t) { clearTimeout(t); }
		}
		//var t = setTimeout('cci.instant_alert.set()',10);
	}

}




// simple function called from page to instantiate dock object
function dockInit(dockId, dockTitle, pageURL, tabURLs, openDock){
		if(openDock) {
			setCookie('isDockMinimized', false, null, "/");
			setCookie('isDockClosed', false, null, "/");
		}
		if(getCookie("isDockClosed") == 'true') return;
		new cci.dock.make(dockId, dockTitle, pageURL, tabURLs);
}

// simple function called from page to instantiate im_alert object
function instant_alertInit(instant_alertId, instant_alertTitle, pageURL){
	new cci.instant_alert.make(instant_alertId, instant_alertTitle, pageURL);
}

function endAlert(instant_alertId) {
  cci.instant_alert.end(instant_alertId);
}


/* nav bar */
function navigation_bar() {

	//alert("navelo!!");

	var ids = ["nav_mfind", "nav_mypage", "nav_connect", "nav_fun", "nav_look"];
	var a_ids = [ "a_nav_connect", "a_nav_fun", "a_nav_look"];
	var navigation2 = "navigation2";
	var delayTimer;

	function fnDisableAnchor(e) {
		YAHOO.util.Event.preventDefault(e);
	}

	function fnRemovelo() {
		YAHOO.util.Dom.removeClass(ids, "selected");
		YAHOO.util.Dom.removeClass(navigation2, "undernav");
		clearTimeout(delayTimer);
	}

	function fnSelectalo(e) {
		fnRemovelo();
		YAHOO.util.Dom.addClass(navigation2, "undernav");
		YAHOO.util.Dom.addClass(this.id, "selected");
	}

	function delayUnSelectalo(e) {

		delayTimer = setTimeout(fnRemovelo, 650);

	}

	YAHOO.util.Event.addListener(a_ids, "click", fnDisableAnchor);
	YAHOO.util.Event.addListener(ids, "mouseover", fnSelectalo);
	YAHOO.util.Event.addListener("nav_home", "mouseover", fnRemovelo);
	YAHOO.util.Event.addListener(ids, "mouseout", delayUnSelectalo);
}

navigation_bar();
