// JavaScript Document

// Where We work - Homepage

var displaying = false;
		var displaying_source = "";
		var displaying_items = new Array();
		function hotSpot(id) {
			var source = document.getElementById(id);
			if (!source) return;
			displaying_source = source;
			displaying_items.push(source);
			displaying_source.style.visibility = "visible";
			displaying = true;
			setTimeout('updateHotSpot()',100);
		}
		function updateHotSpot() {
			for (var i = 0; i < displaying_items.length; i++) {
				if(displaying == true && displaying_source == displaying_items[i]) {
					displaying_items[i].style.visibility = "visible";
				} else {
					displaying_items[i].style.visibility = "hidden";
					displaying_items[i] = null;
				}
			}
			displaying_items = displaying_items.compact();
			if (displaying_items.length == 0) displaying = false;
			setTimeout('updateHotSpot()',100);
		}
		
/* Header Images */

function positionHeaderImageText(str_id) {
	var o_child = $(str_id);
	if (o_child) {
		var o_parent = 	o_child.up();
		if (o_parent) {
			var o_sibling = o_child.previous();
			if (o_sibling) {
				var parentDimensions = 	Element.getDimensions(o_parent);
				var siblingDimensions = Element.getDimensions(o_sibling);
				var objDimensions = o_child.getDimensions();
				var objPadLR = eval(o_child.getStyle('padding-left').replace(/px/,"")) * 2;
				var tgtWidth = parentDimensions.width - siblingDimensions.width - objPadLR;
				var objDimensions = o_child.getDimensions();
				if (tgtWidth < 370) o_child.setStyle({'width':tgtWidth+'px'});
				var objDimensions = o_child.getDimensions();
				var tgtMgnTop = (parentDimensions.height - objDimensions.height) / 2;
				if (tgtMgnTop > 0) o_child.setStyle({'marginTop':tgtMgnTop+'px'});
			}
		}
	}
}
function positionProgramsHeaderText(onPageLoad) {
	if (!onPageLoad) positionHeaderImageText('program_header_img_txt');
	else {
		setTimeout('positionHeaderImageText(\'program_header_img_txt\')',500);
	}
}

/* site specific listener functions */

var PageExtend = {
	id: "PageExtend",
	func: new Array(),
	funcTracking: new Object(),
	popins: new Array(),
	popin_bg: null,
	o_popin: null,
	current_popin: null,
	loaded: false,
	init: function() {
		// TODO: check for home page
		Event.observe(window, "load", this.startup.bind(this));
		Event.observe(window, "resize", this.resized.bind(this));
		Event.observe(window, "scroll", this.scrolled.bind(this));
		
	},
	startup: function() {
		
		this.loaded = true;
		this. main_div = $$('DIV.main')[0];
		// position home quote
		if ($('home_quote_right')) {
			var o_img = $('home_quote_right');
			o_img.setStyle({'marginTop':(o_img.previous().getHeight() - o_img.getHeight() - 7)+'px','visibility':'visible'});
		}
		
		// Track outbound/downloads/media links using urchin tracker
		addUrchinTrackingCode();
		addIETrackingCode();
		// functions executed when the text size stylesheet is loaded
		this.executeStartupFunctions(true);
	},
	resized: function() {
		this.adjustCurrentPopin();
		this.adjustSitemapIf();
		hideSearchBox();
	},
	scrolled: function() {
		this.adjustCurrentPopin();
	},
	addFunction: function(myFunc, run_local) {
		if (!run_local) var run_local = false;
		this.func.push(myFunc);
		this.funcTracking['' + (this.func.length - 1) + ''] = new Object({'run_local':run_local});
	},
	executeStartupFunctions: function(b_local) {
		if (!b_local) b_local = false;
		var myFunctions = this.func;
		var myFunctionTracking = this.funcTracking;
		for (var i = 0; i < myFunctions.length; i++) {
			if (myFunctionTracking['' + i + '']['run_local'] == b_local && typeof(myFunctions[i]) == "function") myFunctions[i]();	
		}
	},
	showPopin: function(o_src,tgt_id) {
		if (o_src) {
			this.showNewPopin(tgt_id);
			// embed the HTML content
			if (this.o_popin && typeof(tgt_id+"_content") != "undefined") {
				var o_container = this.o_popin.down(".youtube_container");
				if (o_container) o_container.update(window[tgt_id+"_content"]);
			}
		}
	},
	createPopinBG: function() {
		var bg = document.createElement('DIV');
		document.body.appendChild(bg);
		
		this.popin_bg = bg;
		Element.setStyle(this.popin_bg,{'position':'absolute','left':'0px','top':'0px','zIndex':'1000','display':'none','backgroundColor':'black','opacity':'0.5'});
	},
	totalDocDimensions: function() {
		return Element.getDimensions(document.body);
	},
	showNewPopin: function(p_id) {
		if (!this.loaded) return;
		
		if (!$(p_id)) return;
		if (this.popin_bg == null) this.createPopinBG();
		if (this.o_popin != null) this.hideCurrentPopin();
		this.o_popin = $(p_id);
		
		// if IE 6 popin appears behind background
		if (navigator.userAgent.indexOf("MSIE 6") != -1) {
			document.body.appendChild(this.o_popin.remove());
			this.o_popin.setStyle({'textAlign':'left'});
		}
		
		this.current_popin = this.o_popin;
		this.adjustCurrentPopin();
		this.popin_bg.style.display = 'block';
		
		
		//this.o_popin.style.visibility = 'visible';
		this.o_popin.setStyle({'visibility':'visible'});
		// set display for video for play
		if ($$('#' + this.o_popin.id + 'DIV.vid_base_vid')) {
			var video_div = $$('#' + this.o_popin.id + '  DIV.vid_base_vid');
			if (video_div && video_div.length > 0) { 
				video_div[0].style.display = 'block';
				setTimeout(this.playVideoPopin.bind(this),500);
			}
		}
		
		if (this.o_popin.controller) this.o_popin.controller.popinOpening();
	},
	playVideoPopin: function() {
		// start playing after the popin has opened
		// play video when showing only for video popin and not conflict with slideshow popin
		if ($$('#' + this.o_popin.id + 'DIV.vid_base_vid')) {
			var video_div = $$('#' + this.o_popin.id + '  DIV.vid_base_vid');
			if (video_div && video_div.length > 0) { 
				var ar_video = (navigator.userAgent.indexOf("MSIE") == -1) ? video_div[0].getElementsBySelector("EMBED") : video_div[0].getElementsBySelector("OBJECT");
				if(ar_video && ar_video.length > 0  && typeof(ar_video[0].SetVariable) != 'undefined') {
					ar_video[0].SetVariable("vcrCommand","play");
				}
			}
		}
	},
	hideCurrentPopin: function() {
		if (this.popin_bg != null) this.popin_bg.style.display = 'none';
		
		// stop video when hiding
		var ar_video = (navigator.userAgent.indexOf("MSIE") == -1) ? this.o_popin.getElementsBySelector("EMBED") : this.o_popin.getElementsBySelector("OBJECT");
		if(ar_video && ar_video.length > 0 ) {
			ar_video.each( function(obj) {
				if (typeof(obj.SetVariable) != 'undefined') {
					obj.SetVariable("vcrCommand","stop");
				}
			});
		}
		
		// remove the embedded youtube HTML
		var o_container = this.o_popin.down(".youtube_container");
		if (o_container) o_container.update("");
		
		this.o_popin.style.visibility = 'hidden';
		//if (this.o_popin.controller) this.o_popin.controller.popinClosing();
		this.o_popin = null;
	},
	adjustCurrentPopin: function() {
		if (this.o_popin != null) {
			var _left = Math.max(0,Math.floor(((document.viewport.getWidth()/2) - (this.o_popin.getWidth()/2)) + document.viewport.getScrollOffsets().left));
			var _top = Math.max(0,Math.floor(((document.viewport.getHeight()/2) - (this.o_popin.getHeight()/2)) + document.viewport.getScrollOffsets().top));
			this.o_popin.setStyle({'top': _top + 'px', 'left': _left + 'px'});
			this.adjustPopinBG();
		}
	},
	adjustPopinBG: function() {
		if (this.popin_bg != null) {
			var docDim = this.totalDocDimensions();
			Element.setStyle(this.popin_bg,{'left':'0px', 'width': docDim.width +'px','height':docDim.height + 'px'})	
		}
	},
	closePopin: function(clk_rrc) {
		var o_clk_popin = $(clk_rrc);
		if (this.current_popin != null && o_clk_popin == this.current_popin) {
			this.hideCurrentPopin();
		}
		else {
			this.hideCurrentPopin();
			this.current_popin = o_popin;
			this.hideCurrentPopin();
		}
	},
	adjustSitemapIf: function() {
		var o_sitemap = $('div_sitemap_top');
		var o_sitemap_positioner = $('footer_links_sitemap');
		if (o_sitemap && o_sitemap.style.display == 'block' && o_sitemap_positioner) {
			o_sitemap.setStyle({'left':o_sitemap_positioner.cumulativeOffset().left + 'px'});
		}
	}
};
PageExtend.init();

function addUrchinTrackingCode() {
	var thisSiteURL = baseSiteURLJS;
	var a_tags = $$('a');
	a_tags.each( function (a_item) {
		if (a_item.href.indexOf(thisSiteURL) == -1 && a_item.href.match(/(http:|https:|ftp:)/) != null ) {
			var extURL = "/outgoing/" + a_item.href.replace(/(:\/\/|:)/g,'/');
			a_item.observe("click",function() { pageTracker._trackPageview(extURL); });
		}
	});
	var div_tags = $$('div.box_off');
	div_tags.each( function (div_item) {
		if (div_item.onclick != undefined && div_item.onclick.toString().match(/href/) != null) {
			var altUrl = div_item.onclick.toString().match(/\".*\"|'.*'/).toString().replace(/\"|'/g,"");
			if (altUrl.indexOf(thisSiteURL) == -1 && altUrl.indexOf("objects/") == -1) {
				altUrl = "/outgoing/" + altUrl.replace(/(:\/\/|:)/g,'/');
				div_item.observe("click",function() { pageTracker._trackPageview(altUrl); });
			}
			else if (altUrl.indexOf("objects/") != -1) {
				altUrl = "/media/" + altUrl.replace(/(:\/\/|:)/g,'/');
				div_item.observe("click",function() { pageTracker._trackPageview(altUrl); });
			}
		}
	});
}

function addIETrackingCode() {
	var thisSiteURL = baseSiteURLJS;
	var a_tags = $$('a');
	a_tags.each( function (a_item) {
		if (a_item.href.indexOf(thisSiteURL) == -1 && a_item.href.match(/(http:|https:|ftp:)/) != null ) {
			var extURL = "outgoing=" + a_item.href.replace(/(:\/\/|:)/g,'/');
			a_item.observe("click",function() { trackPageviewIE(extURL); });
		}
	});
	var div_tags = $$('div.box_off');
	div_tags.each( function (div_item) {
		if (div_item.onclick != undefined && div_item.onclick.toString().match(/href/) != null) {
			var altUrl = div_item.onclick.toString().match(/\".*\"|'.*'/).toString().replace(/\"|'/g,"");
			if (altUrl.indexOf(thisSiteURL) == -1 && altUrl.indexOf("objects/") == -1) {
				altUrl = "outgoing=" + altUrl.replace(/(:\/\/|:)/g,'/');
				div_item.observe("click",function() { trackPageviewIE(altUrl); });
			}
			else if (altUrl.indexOf("objects/") != -1) {
				//altUrl = "/media/" + altUrl;
				//div_item.observe("click",function() { trackPageviewIE(altUrl); });
			}
		}
	});
}
function trackPageviewIE(URIPart) {
	var thisSiteURL = baseSiteURLJS;
	var img = new Image(1,1);
	img.src = thisSiteURL + "?" + URIPart;
}

// sitemap show/hide
function toggleSiteMap(o_src, b_show) {	
	var o_sitemap = $('div_sitemap_top');
	var o_sitemap_positioner = $('footer_links_sitemap');
	if (o_sitemap && o_sitemap.down() && o_sitemap_positioner) {
		if ((b_show && o_sitemap.style.display == 'none') || (!b_show && o_sitemap.style.display == 'block')) {
			var sitemap = o_sitemap.down();
			
			var sitemap_positioner_pos = o_sitemap_positioner.cumulativeOffset();
			var sitemap_dimensions = sitemap.getDimensions();
			
			var sitemap_container_height = sitemap_positioner_pos.top;
			var sitemap_container_left = sitemap_positioner_pos.left;
			
			sitemap.makePositioned();
			o_sitemap.setStyle({'top': 0 + 'px', 'left':sitemap_container_left + 'px', 'height':sitemap_container_height + 'px'});
			if (!b_show && o_sitemap.style.display == 'block') {
				sitemap.setStyle({'left':'0px','top': (sitemap_container_height - sitemap_dimensions.height) + 'px','display':'block'});
				new Effect.Move(sitemap, {y: sitemap_container_height, mode:'absolute',transition: Effect.Transitions.sinoidal, duration:0.5, afterFinish:siteMapHidden });
				if (o_src && o_src.up()) {
					if (navigator.userAgent.indexOf("MSIE 6") != -1) {
						o_src.up().previous().fill.src = 'images/sitemap_arrow.png';
					}
					else o_src.up().className = 'sitemap_link';
				}
			}
			else if (b_show && o_sitemap.style.display == 'none') {
				o_sitemap.setStyle({'display':'block'});
				sitemap.setStyle({'left':'0px','top': sitemap_container_height + 'px','display':'block'});
				new Effect.Move(sitemap, {y: sitemap_container_height - sitemap.getHeight(), mode:'absolute',transition: Effect.Transitions.sinoidal, duration:0.5, afterFinish:siteMapShown});
				if (o_src && o_src.up()) {
					if (navigator.userAgent.indexOf("MSIE 6") != -1) {
						o_src.up().previous().fill.src = 'images/sitemap_arrow_rev.png';
					}
					else o_src.up().className = 'sitemap_link_rev';
				}
			}
		}
	}
}
function siteMapHidden() {
	var o_sitemap = $('div_sitemap_top');
	if (o_sitemap) {
		o_sitemap.setStyle({'height':'0px','display':'none'});	
	}
}
function siteMapShown() {
	var o_sitemap = $('div_sitemap_top');
	if (o_sitemap && o_sitemap.down()) {
		o_sitemap.setStyle({'top':o_sitemap.down().positionedOffset().top + 'px','height':o_sitemap.down().getHeight() + 'px'});	
		o_sitemap.down().setStyle({'top':'0px'});
	}
}
function showSiteMap(o_src) {
	if (o_src) {
		toggleSiteMap(o_src,true);
	}
}
var siteMapHideId = null;
function hideSiteMap(o_src) {
	if (o_src) {
		var o_sitemap = $('div_sitemap_top');
		var o_sitemap_mouseout_fix = o_sitemap.readAttribute('mouseoutfix');
		if (!o_sitemap_mouseout_fix) {
			o_sitemap.descendants().each( function(elem) { if(elem.tagName == 'DIV') { elem.observe('mouseover',catchSitemapHide);}});
			o_sitemap.writeAttribute({'mouseoutfix':'true'});
		}
		siteMapHideId = setTimeout(hideSiteMapNow,200);
	}
}
function hideSiteMapNow() {
	if (siteMapHideId != null) toggleSiteMap($('footer_link_sitemap'),false);
}
function catchSitemapHide() {
	if (siteMapHideId != null) clearTimeout(siteMapHideId);
}

/*
 * Autocompleter.GS - simple local autocompleter based on Autocompleter.Local
 */
Autocompleter.BCBSF = Class.create(Autocompleter.Base, {
  initialize: function(element, update, url, options) {
    this.baseInitialize(element, update, options);
    this.options.asynchronous  = true;
    this.options.onComplete    = this.onComplete.bind(this);
	this.options.onShow	   = this.onShow.bind(this);
	this.options.onHide	   = this.onHide.bind(this);
	this.options.autoSelect = false;
    this.options.defaultParams = this.options.parameters || null;
    this.url                   = url;
	this.update.observe('mouseover', this.updateMouseOver.bind(this));
	this.update.observe('mouseout', this.updateMouseOut.bind(this));
	this.menuObservers = false;
  },

  getUpdatedChoices: function() {
    this.startIndicator();

    var entry = encodeURIComponent(this.options.paramName) + '=' +
      encodeURIComponent(this.getToken());

    this.options.parameters = this.options.callback ?
      this.options.callback(this.element, entry) : entry;

    if(this.options.defaultParams)
      this.options.parameters += '&' + this.options.defaultParams;

    new Ajax.Request(this.url, this.options);
  },

  onComplete: function(request) {
    this.updateChoices(request.responseText);
  },
  updateChoices: function(choices) {
    if(!this.changed && this.hasFocus) {
	   
	   // remove any "meta" tags - NOTE: not trying to circumvent CF notices, they're just interfering with this display when developing locally
	  choices = choices.replace(/<meta[^>]*>/gi, "");
	  
      this.update.update(choices);
      Element.cleanWhitespace(this.update);
      Element.cleanWhitespace(this.update.down());

      if(this.update.firstChild && this.update.down().childNodes) {
        this.entryCount =
          this.update.down().childNodes.length;
        for (var i = 0; i < this.entryCount; i++) {
          var entry = this.getEntry(i);
          entry.autocompleteIndex = i;
          //this.addObservers(entry);
        }
      } else {
        this.entryCount = 0;
      }

      this.stopIndicator();
      this.index = 0;

      if(this.entryCount==1 && this.options.autoSelect) {
        this.selectEntry();
        this.hide();
      } else {
        this.render();
      }
	  
	  // update the go button target
	  var elm_go = this.element.up().select(".search_button").first();
	  if (elm_go) {
		  var that = this;
		  elm_go.stopObserving('click');
		  elm_go.observe('click',function() {
			  document.location.href = 'pages-search?criteria=' + that.element.value;
		  });
	  }
    }
  },
  onShow: function(element, update){ 
  	if (!this.menuObservers) {
		$('ddm_search_menu_src').observe('mouseover',this.showNow.bind(this));
		$('ddm_search_tab').observe('mouseout', this.hideNow.bind(this));
		this.menuObservers = true;
	}
	this.positionUpdate(update);
	//Effect.Appear(update,{duration:0.15});
	this.update.setStyle({'display':'block'});
	
  },
  positionUpdate: function(update) {
	  if ($('ddm_search_tab')) {
		var searchBoxTop = $('ddm_search_tab');
		var searchBoxPos = searchBoxTop.cumulativeOffset();
		var searchBoxHt = searchBoxTop.getHeight();
		update.setStyle({'left':searchBoxPos.left + 'px', 'top':(searchBoxPos.top + searchBoxHt) + 'px'});
	  }
	  /*if (typeof(window['menu_group_topnav']) != "undefined") {
		var menuController = window['menu_group_topnav'].getCurrentController();
		var menu_offset = menuController.menu.cumulativeOffset();
		var menu_height = menuController.menu.getHeight();
		update.setStyle({'left':menu_offset.left + 'px', 'top':(menu_offset.top + menu_height) + 'px'});
	  }*/
  },
  updateMouseOver: function() {
	  /*if (typeof(window['menu_group_topnav']) != "undefined") {
			var menuController = window['menu_group_topnav'].getCurrentController();
			if(menuController.catchHide) menuController.catchHide();
	  }*/
  },
  updateMouseOut: function() {
	  /*if (typeof(window['menu_group_topnav']) != "undefined") {
			var menuController = window['menu_group_topnav'].getCurrentController();
			if (menuController.hide) menuController.hide();
			setTimeout(this.hideNow.bind(this), 250);
	  }*/
  },
  showNow: function() {
	  if (this.update.style.display != 'block') {
		  this.positionUpdate(this.update);
		  //Effect.Appear(this.update,{duration:0.15});
		  this.update.setStyle({'display':'block'});
	  }
  },
  hideNow: function() {
	setTimeout(this.hideNowIf.bind(this),250);
  },
  hideNowIf: function() {
	  if ($('ddm_search_tab').style.visibility == 'hidden') {
		this.hasFocus = false;
		this.active = false;  
		this.hide();
	}
  },
  onHide: function(element, update){ 
	//Effect.Fade(update,{duration:0.15});	
	this.update.setStyle({'display':'none'});
  },
  hideSearchBox: function() {
	  if ($('ddm_search_tab')) {
		$('ddm_search_tab').style.visibility = 'hidden';
		this.hideNowIf();
	  }
  }
});

function showSearchBox(o_src, tgt, o_init) {
	if (typeof(o_init) == "object") {
		var offsetX = o_init.offsetX;
		var offsetY = o_init.offsetY;
	}
	
	// add IE 6 & 7
	var iEAddTop = 0;
	var iEAddLeft = 0;
	if (navigator.userAgent.indexOf("MSIE") != -1) {
		if (navigator.userAgent.indexOf("MSIE 6") != -1) {iEAddTop = 8; iEAddLeft = 0;}
		else if (navigator.userAgent.indexOf("MSIE 7") != -1) {iEAddTop = 3; iEAddLeft = 0;}
	}
	
	var o_tgt = $(tgt);
	if (o_tgt && o_src) {
		o_tgt.makePositioned();
		var o_src_position = o_src.cumulativeOffset();
		var _left = o_src_position.left + offsetX;
		var _top = o_src_position.top + offsetY;
		o_tgt.setStyle({'visibility':'visible','left':(_left + iEAddLeft) + 'px', 'top':(_top + iEAddTop) + 'px', 'zIndex':'999'});
	}
}

function hideSearchBox() {
	if (typeof(window['BCBSAutocompleterSearch']) != "undefined") {
		window['BCBSAutocompleterSearch'].hideSearchBox();
	}
}

BCBSIndexedSlider = Class.create({
	initialize: function(slider_id, o_init) {
		this.id = slider_id;
		this.o_slider = $(slider_id);
		this.o_slider.controller = this;
		this.o_slider_box = $$('#' + slider_id + ' DIV.c_slider_box');
		this.items = $$('#' + slider_id + ' DIV.c_slider_item');
		this.links = $$('#' + slider_id + ' A.c_slider_idx', '#' + slider_id + ' DIV.c_slider_idx');
		this.download_links = $$('#' + slider_id + ' .slideshow_slides_link');
		this.enlarge_links = $$("#" + slider_id + ' .c_slide_enlarge');
		this.currentSelection = 1;
		this.previousSelection = 1;
		this.selectedCssClass = "active";
		this.unselectedCssClass = "";
		this.linksOverCss = null;
		this.linksOffCss = null;
		this.tween = new Array();
		this.height = 344;
		this.calcHeight = true;
		this.width = 620;
		this.autoInterval = 10000;
		this.autoAdvance = true;
		this.sliderBoxDim = null;
		this.animDuration = 1;
		this.ajaxVideoURL = 'flv_ajax.cfm';
		this.ajaxRequests = new Array();
		this.swfVersion = MM_hasVersion;
		this.enlargedPhotoLayer = null;
		this.enlargedPhoto = null;
		
		// accept init variables
		if (typeof(o_init) == "object") for (var a in o_init) if (typeof(this[a]) != "undefined") this[a] = o_init[a];
		
		this.timer = (this.autoAdvance) ? setTimeout(this.moveNext.bind(this), this.autoInterval) : null;
		this.prepareItems();
		this.prepareLinks();
		this.fixOverlays();
		this.prepareEnlargeLinks();
	},
	prepareItems: function() { // also sets the width and height for this class
		var that = this;
		that.vidHTMLObj = new Object();
		var sliderBox = (that.o_slider_box && that.o_slider_box.length > 0) ? that.o_slider_box[0] : null;
		
		var maxHeight = 0;
		var totalWidth = 0;
		that.items.each( function(elem) {
			var _height = elem.getHeight();
			if (_height > maxHeight) maxHeight = _height;
			that.height = (this.calcHeight) ? maxHeight : that.height;
			totalWidth += elem.getWidth() + 2;
		});	
		// if the background div needs to be positioned
		if (sliderBox && that.sliderBoxDim) {
			var overrideHeight = (this.calcHeight) ? maxHeight : this.height;
			sliderBox.setStyle({'overflow': 'hidden', 'height': overrideHeight + 'px' });
			if (that.sliderBoxDim.left) sliderBox.setStyle({'left': that.sliderBoxDim.left + 'px'});
			if (that.sliderBoxDim.top) sliderBox.setStyle({'top': that.sliderBoxDim.top + 'px'});
			if (that.sliderBoxDim.width) { 
				sliderBox.setStyle({'width': that.sliderBoxDim.width + 'px'});
				that.width = that.sliderBoxDim.width;
			}
		}
		// there is always a div above the items as wide as cumulative item width
		var wideDiv = that.items[0].up();
		wideDiv.setStyle({'width': totalWidth + 'px'});
		
		// make all items positioned and set their initial position
		that.items.each( function(elem) {
			elem.makePositioned();
		});
	},
	prepareLinks: function() {
		var that = this;
		this.links.each( function(elem) {
			var name = elem.readAttribute('name');
			if (!isNaN(name) && eval(name) <= that.items.length) {
				elem.observe('click',that.sliderNavClicked.bind(that,elem));
				if (that.linksOverCss != null) elem.observe('mouseover',that.sliderNavMouseOver.bind(that,elem));
				if (that.linksOffCss != null) elem.observe('mouseout',that.sliderNavMouseOff.bind(that,elem));
			}
			else {
				if (elem.up() && elem.up().tagName == 'LI') elem.up().style.display = 'none';
				else elem.style.display = 'none';
			}
		});
	},
	prepareEnlargeLinks: function() {
		var that = this;
		this.enlarge_links.each( function(elem) {
			elem.observe('click',that.enlargeCurrentSlide.bind(that));
		});
	},
	fixOverlays: function() { // for home page
		var that = this;
		var ar_overlays = $$('#' + this.o_slider.id + ' DIV.noflash_overlay');
		ar_overlays.each( function(elem) {
			var top = that.height - elem.getHeight();
			elem.setStyle({'top':top + 'px'});
			elem.appear();
		});
	},
	sliderNavClicked: function(elem,evt) {
		if (this.tween.length != 0) return;
		
		if (this.autoAdvance) clearTimeout(this.timer);
		//var elem = Event.findElement(evt, 'A');
		//elem = (!elem) ? Event.findElement(evt, 'DIV') : elem;
		var name = elem.readAttribute('name');
		if (name && !isNaN(name) && eval(name) <= this.items.length) {
			this.setSelected(elem);
		}
		this.timer = (this.autoAdvance) ? setTimeout(this.moveNext.bind(this), this.autoInterval) : null;
	},
	setSelected: function(sel) {
		var that = this;
		this.links.each( function(elem) {
			var ref = (elem.up() && elem.up().tagName == 'LI') ? elem.up() : elem;
			var name = (ref.tagName == 'LI') ? elem.readAttribute('name') : ref.readAttribute('name');
			var appendcss = (eval(name) > 9) ? "2" : "";
			if (sel == elem) {
				if (!ref.hasClassName(that.selectedCssClass + appendcss)) ref.addClassName(that.selectedCssClass + appendcss);
				if (ref.hasClassName(that.unselectedCssClass + appendcss)) ref.removeClassName(that.unselectedCssClass + appendcss);
				that.previousSelection = that.currentSelection;
				that.currentSelection = name;
			}
			else {
				if (ref.hasClassName(that.selectedCssClass + appendcss)) ref.removeClassName(that.selectedCssClass + appendcss);
				if (!ref.hasClassName(that.unselectedCssClass + appendcss)) ref.addClassName(that.unselectedCssClass + appendcss);
			}
		});
		//alert(this.previousSelection + ", " + this.currentSelection);
		if (this.currentSelection != this.previousSelection) {
			this.showDownloadLinkIf();
			this.animate();
		}
	},
	animate: function() {
		var that = this;
		var current = null;
		var previous = null;
		for (var i = 0; i < this.items.length; i++) {
			if (i+1 == this.currentSelection) current = this.items[i];
			if (i+1 == this.previousSelection) previous = this.items[i];
		}		
		
		
		//alert(previous + ", " + current);
		if (current != null && previous != null) {
			// if video is already loaded then stop before moving
			var ar_video = (navigator.userAgent.indexOf("MSIE") == -1) ? previous.getElementsBySelector("EMBED") : previous.getElementsBySelector("OBJECT");
			if(ar_video && ar_video.length > 0 && typeof(ar_video[0].SetVariable) != 'undefined') {
				ar_video[0].SetVariable("vcrCommand","stop");
			}	
			
			
			// position current element
			if (eval(this.currentSelection) > eval(this.previousSelection)) {
				var currPos = (-this.width * (this.currentSelection-2));
				current.setStyle({'left':currPos + 'px', 'top': '0px'});
				this.tween.push(new Effect.Move(previous, {x:-this.width, mode:'relative', duration: this.animDuration, transition: Effect.Transitions.sinoidal, afterFinish: this.animDone.bind(this)}));
				this.tween.push(new Effect.Move(current, {x:currPos-this.width, mode:'absolute', duration: this.animDuration, transition: Effect.Transitions.sinoidal, afterFinish: this.animDone.bind(this)}));
			}
			else {
				var currPos = (this.width * this.currentSelection) * -1;
				current.setStyle({'left':currPos + 'px', 'top':'0px'});
				this.tween.push(new Effect.Move(previous, {x:this.width, mode:'relative', duration: this.animDuration, transition: Effect.Transitions.sinoidal, afterFinish: this.animDone.bind(this)}));
				this.tween.push(new Effect.Move(current, {x:currPos+this.width, mode:'absolute', duration: this.animDuration, transition: Effect.Transitions.sinoidal, afterFinish: this.animDone.bind(this)}));
			}
			
			// load video if not loaded already
			this.ajaxLoadVideo(current);
		}
	},
	showDownloadLinkIf: function() {
		if (this.download_links && this.download_links.length > 0) {
			var bot_link_curr = this.download_links[this.currentSelection - 1];
			var bot_link_prev = this.download_links[this.previousSelection - 1];
			bot_link_prev.setStyle({'display':'none'});
			if (!bot_link_curr.empty()) bot_link_curr.setStyle({'display':'inline'});
		}
	},
	ajaxVideoSuccess: function(resp) {
		this.ajaxComplete(resp);
	},
	ajaxVideoFailure: function(resp) {
		this.ajaxComplete(resp);
	},
	ajaxVideoSuccessFirst: function(resp) {
		setTimeout(this.startCurrentVideo.bind(this),1500);
		this.ajaxComplete(resp);
	},
	ajaxComplete: function(resp) {
		for (var i = 0; i < this.ajaxRequests.length; i++) {
			if (resp.request == this.ajaxRequests[i].request) {
				var o_container = $(this.ajaxRequests[i].container);
				o_container.update(resp.responseText);
				this.ajaxRequests[i] = null;
			}
		}
		this.ajaxRequests = this.ajaxRequests.compact();
		
		
	},
	animDone: function(obj) {
		for (var i = 0; i < this.tween.length; i++) {
			if (obj == this.tween[i]) this.tween[i] = null;
		}
		this.tween = this.tween.compact();
		
		this.startCurrentVideo();
		
		// if video is found then play the video 
		/*var ar_video = (navigator.userAgent.indexOf("MSIE") == -1) ? obj.element.getElementsBySelector("EMBED") : obj.element.getElementsBySelector("OBJECT");
		if (obj.element == this.items[this.currentSelection-1]) {
			if(ar_video && ar_video.length > 0 && typeof(ar_video[0].SetVariable) != 'undefined') {
				ar_video[0].SetVariable("vcrCommand","play");
			}
		}*/
	},
	moveNext: function() {
		if (this.tween.length != 0) return;
		
		var nextItem = (this.currentSelection == this.items.length) ? this.links[0] : this.links[this.currentSelection]
		this.setSelected(nextItem);
		if (this.autoAdvance) this.timer = setTimeout(this.moveNext.bind(this), this.autoInterval);
	},
	sliderNavMouseOver: function(o_elem,evt) {
		//var o_elem = Event.findElement(evt,'DIV');
		if (o_elem) {
			var name = o_elem.readAttribute('name');
			var appendcss = (eval(name) > 9) ? "2" : "";
			if (this.linksOverCss != null && this.linksOffCss != null && !o_elem.hasClassName(this.linksOverCss + appendcss)) o_elem.addClassName(this.linksOverCss + appendcss);
		}
	},
	sliderNavMouseOff: function(o_elem,evt) {
		//var o_elem = Event.findElement(evt,'DIV');
		if (o_elem) {
			var name = o_elem.readAttribute('name');
			var appendcss = (eval(name) > 9) ? "2" : "";
			if (this.linksOverCss != null && this.linksOffCss != null && name != this.currentSelection) {
				o_elem.removeClassName(this.linksOverCss + appendcss);
				o_elem.addClassName(this.linksOffCss + appendcss);
			}
		}
	},
	popinClosing: function() {
		// if video is found then show/hide the video 
		/*
		var obj_id = this.items[this.currentSelection-1].identify();
		var ar_videos = $$('#' + obj_id + ' DIV.c_slider_video');
		if (ar_videos && ar_videos.length > 0 ) {
			ar_videos[0].setStyle({'display':'none', 'visibility':'visible', 'height': ar_videos[0].getHeight() + 'px'});
		}
		*/
	},
	popinOpening: function() {
		if (this.items && this.items.length > 0) {
			var o_current = this.items[this.currentSelection-1];
			
			var obj_id = o_current.identify();
			var ar_videocontainers = $$('#' + obj_id + ' DIV.c_slider_video');
			if (ar_videocontainers && ar_videocontainers.length > 0 && ar_videocontainers[0].down() && ar_videocontainers[0].down().empty()) {
				this.ajaxLoadVideo(o_current, true);
			}
			else {
				// if video is found then play the video 
				var ar_video = (navigator.userAgent.indexOf("MSIE") == -1) ? o_current.getElementsBySelector("EMBED") : o_current.getElementsBySelector("OBJECT");
				if(ar_video && ar_video.length > 0 && typeof(ar_video[0].SetVariable) != 'undefined') {
					ar_video[0].SetVariable("vcrCommand","play");
				}
			}
			
		}
	},
	ajaxLoadVideo: function(obj_container, firstTime) {
		if (firstTime == undefined) firstTime = false;
		var successCall = (firstTime) 	? this.ajaxVideoSuccessFirst.bind(this) :this.ajaxVideoSuccess.bind(this);	
		
		// get video container and send ajax request to add video
		var obj_id = obj_container.identify();
		var ar_videocontainers = $$('#' + obj_id + ' DIV.c_slider_video');
		if (ar_videocontainers && ar_videocontainers.length > 0 && ar_videocontainers[0].down()) {
			if (ar_videocontainers[0].down().empty())  {
				//ar_videos[0].setStyle({'display':'block', 'visibility':'visible', 'height': ar_videos[0].getHeight() + 'px'});
				var oid = ar_videocontainers[0].readAttribute('oid');
				this.ajaxRequests.push({
									   request: new Ajax.Request(this.ajaxVideoURL,{parameters: {oid:oid,swfversion:this.swfVersion}, onSuccess:successCall, onFailure:this.ajaxVideoFailure.bind(this)})
									   , container: ar_videocontainers[0].down().identify()});
			}
			else {
				//this.startCurrentVideo();
			}
			
		}
	},
	startCurrentVideo: function() {
		// if video is found then play the video 
		var o_current = this.items[this.currentSelection-1];
		var ar_video = (navigator.userAgent.indexOf("MSIE") == -1) ? o_current.getElementsBySelector("EMBED") : o_current.getElementsBySelector("OBJECT");
		if(ar_video && ar_video.length > 0 && typeof(ar_video[0].SetVariable) != 'undefined') {
			ar_video[0].SetVariable("vcrCommand","play");
		}	
	},
	enlargeCurrentSlide: function() {
		var ar = [];
		try {
			ar.push("enlargeCurrentSlide=" + this.id);
			var o_current = this.items[this.currentSelection-1];
			if (o_current) {
				ar.push("o_current=" + (this.currentSelection-1));
				var o_img = o_current.select('.slideshow_image_1 IMG');
				if (o_img && o_img.length > 0) {
					ar.push("o_img=" + o_img[0].src);
					this.createEnlargedPhotoLayer();
					if(this.enlargedPhoto != null) this.enlargedPhoto.src = o_img[0].src;
					if (this.enlargedPhotoLayer != null) {
						ar.push("enlargedPhotoLayer");
						this.enlargedPhotoLayer.appear({duration:0.25, afterFinish:function(){ar.push('appearAfterFinish')}, afterUpdate:function(){ar.push('U')} });
					}
				}
			}
		} catch (e) {
			ar.push("error=" + e);
			ar.push("message=" + e.message);
		}
		setTimeout(function(){ Logger.info(ar.join(', ')) }, 1000);
		//Logger.info(ar.join(', '));
	},
	createEnlargedPhotoLayer: function() {
		if (this.enlargedPhotoLayer == null) {
			var o_div = document.createElement("DIV");
			Element.setStyle(o_div,{'width':'628px','height':'449px','position':'absolute','left':'21px','top':'23px','zIndex':'1006','backgroundColor':'black','display':'none'});
			var n_img = document.createElement("IMG");
			Element.setStyle(n_img,{'width':'532px','height':'345px','position':'absolute','left':'48px','top':'50px'});
			o_div.appendChild(n_img);
			var o_a_close = document.createElement("A");
			//o_a_close.className = 'pngfix';
			Element.addClassName(o_a_close,'c_enlarge_close');
			o_a_close.innerHTML = "close";
			//Element.setStyle(o_div_close,{'width':'16px','height':'16px','position':'absolute','left':'567px','top':'26px','backgroundColor':'white'});
			o_div.appendChild(o_a_close);
			
			this.enlargedPhotoLayer = o_div;
			this.enlargedPhoto = n_img;
			
			this.o_slider.appendChild(o_div);
			o_a_close.observe("click",this.hideEnlargedPhoto.bind(this));
		}
	},
	hideEnlargedPhoto: function() {
		if (this.enlargedPhotoLayer != null) {
			this.enlargedPhotoLayer.fade({duration:0.25});
		}
	}
});

BCBSSimpleSlider = Class.create({
	initialize: function(slider_id, o_init) {
		this.o_slider = $(slider_id);
		this.o_slider.controller = this;
		this.o_target = $$('#' + slider_id + ' DIV.c_slider_target')[0];
		this.items = $$('#' + slider_id + ' DIV.c_slider_items');
		this.navigation_items = $$('#' + slider_id + ' DIV.c_nav');
		this.num_items_visible = 4;
		this.tween = new Array();
		this.current_page = 0;
		this.move_by = (this.items.length == 0) ? 0 : this.items[0].getWidth();
		this.hover_opacity = 0.7;
		this.animDuration = 1;
		
		// accept init variables
		if (typeof(o_init) == "object") for (var a in o_init) if (typeof(this[a]) != "undefined") this[a] = o_init[a];
		
		this.adjustTarget();
		this.setupNavigation();
		this.setupHovers();
		
	},
	adjustTarget: function() {
		if (this.o_target && this.items.length > 0) {
			this.o_target.makePositioned();
			var tgtW = (this.items.length + 2) * this.items[0].getWidth();
			this.o_target.setStyle({'width':tgtW + 'px'});
		}
	},
	setupNavigation: function() {
		var that = this;
		this.navigation_items.each( function(elem) {
			var name = elem.readAttribute('name');
			if (name != null && name == 'previous') elem.style.display = 'none';
			if (name != null && name == 'previous_disabled') elem.style.display = 'block';
			if (name != null && name == 'next' ) elem.style.display = (that.items.length > that.num_items_visible) ? 'block' : 'none';
			if (name != null && name == 'next_disabled' ) elem.style.display = (that.items.length > that.num_items_visible) ? 'none' : 'block';
			if (name != null && name.indexOf("disabled") == -1) elem.observe('click',that.navClicked.bind(that,elem));
		});
	},
	setupHovers: function() {
		var that = this;
		this.items.each( function(elem) {
			if (elem.down() && elem.down().tagName == 'A') {
				elem.down().observe('mouseover',that.itemMouseOver.bind(that,elem.down()));
				elem.down().observe('mouseout',that.itemMouseOut.bind(that,elem.down()));
			}
		});
	},
	navClicked: function(o_elem,evt) {
		if (this.tween.length != 0) return;
		
		//var o_elem = Event.findElement(evt,'DIV');
		var action = o_elem.readAttribute('name');
		this.animate(action);
	},
	animate: function(action) {
		switch (action) {
			case 'next':
				this.current_page++;
				this.tween.push(new Effect.Move(this.o_target, {x:-this.move_by, mode:'relative', transition: Effect.Transitions.sinoidal, duration:this.animDuration, afterFinish: this.animDone.bind(this)}));
				break;
			case 'previous':
				this.current_page--;
				this.tween.push(new Effect.Move(this.o_target, {x:this.move_by, mode:'relative', transition: Effect.Transitions.sinoidal, duration:this.animDuration, afterFinish: this.animDone.bind(this)}));
				break;
				
		}
		this.adjustNavigation();
	},
	animDone: function(obj) {
		for (var i = 0; i < this.tween.length; i++) {
			if (obj == this.tween[i]) this.tween[i] = null;
		}
		this.tween = this.tween.compact();
	},
	adjustNavigation: function() {
		var that = this;
		this.navigation_items.each( function(elem) {
			var name = elem.readAttribute('name');
			if (name != null && name == 'previous') elem.style.display = (that.current_page < 1 || that.items.length <= that.num_items_visible) ? 'none' : 'block';
			if (name != null && name == 'next' ) elem.style.display = (that.items.length > that.num_items_visible && that.current_page < that.items.length - that.num_items_visible) ? 'block' : 'none';
			
			if (name != null && name == 'previous_disabled') elem.style.display = (that.current_page < 1 || that.items.length <= that.num_items_visible) ? 'block' : 'none';
			if (name != null && name == 'next_disabled' ) elem.style.display = (that.items.length > that.num_items_visible && that.current_page < that.items.length - that.num_items_visible) ? 'none' : 'block';
		});
	},
	itemMouseOver: function(o_elem,evt) {
		//var o_elem = Event.findElement(evt,'A');
		var o_img = o_elem.down();
		if (o_img && o_img.tagName == 'IMG') {
			o_img.setStyle({'opacity':this.hover_opacity});
		}
	},
	itemMouseOut: function(o_elem,evt) {
		//var o_elem = Event.findElement(evt,'A');
		var o_img = o_elem.down();
		if (o_img && o_img.tagName == 'IMG') {
			o_img.setStyle({'opacity':1.0});
		}
	}
});

/* toggles visibility of inner div elements of the parent div with name = div_name */
function toggleCssClass(obj,cl_prefix,is_short, mouse_evnt) {
	if (is_short) {
		obj.className = (obj.className == cl_prefix)? cl_prefix + "_on" : cl_prefix;
	}
	else {
		obj.className = (obj.className == cl_prefix + "_off")? cl_prefix + "_on" : cl_prefix + "_off";
		if (mouse_evnt) {
			obj.className = (obj.className == cl_prefix + "_off" && mouse_evnt == "on")? cl_prefix + "_on" : obj.className;
		}
	}
}

<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

function fue_swap(o, u) {
	if (o && o.childNodes.length) {
		var img=o.childNodes[0];
		// find img tag
		while (img && (typeof(img.tagName) != "string" || img.tagName != "IMG")) {
			img = img.nextSibling;
		}
		if (img) img.src = u;
	}
}

var showMenuIdRegex = /\_menu/;
function showMenuOver() { // this is the mousover source
	var menu = this.controller.menu;
	var tabId = menu.id.replace(showMenuIdRegex, "_tab");
	
	var iEAddTop = 0;
	var iEAddLeft = 0;
	if (navigator.userAgent.indexOf("MSIE") != -1) {
		if (navigator.userAgent.indexOf("MSIE 6") != -1) {iEAddTop = 3; iEAddLeft = 0;}
		else if (navigator.userAgent.indexOf("MSIE 7") != -1) {iEAddTop = 3; iEAddLeft = 0;}
	}
	Element.setStyle(menu,{'top':parseInt(menu.style.top) + iEAddTop + 'px'});
	var o_tab = MM_findObj(tabId);
	if (o_tab) {
		//var tab_top = (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) ? 41 : 41;
		var tab_top = 41;
		o_tab.style.left = parseInt(menu.style.left) + "px";
		o_tab.style.top = (parseInt(menu.style.top) - tab_top) + "px";
		o_tab.style.visibility = "visible";
	}
}
function showMenuOut() { // this is the mousover source
	var menu = this.controller.menu;
	var tabId = menu.id.replace(showMenuIdRegex, "_tab");
	var o_tab = MM_findObj(tabId);
	if (o_tab) {
		o_tab.style.visibility = "hidden";
	}
}


/********************************************************/
/* 				Scripts from existing site 				*/
/********************************************************/


/* small, medium large stylesheet loading */

// Style selection used for live/ROM links
function loadSavedStyle() {
	var ck = readCookie('style');
	if (ck != null) {
		setActiveStyleSheet(ck);
	}
}
function setActiveStyleSheet(title) {
  var i, a, main;

		 		 if (title == "null") { title = "Small"; }

  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }

  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
  PageExtend.executeStartupFunctions();
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));
	}
	return null;
}

/* general functions */

function evtObserve(element, name, observer, useCapture) {
	if (element.addEventListener) {
		element.addEventListener(name, observer, useCapture);
	} else if (element.attachEvent) {
		element.attachEvent('on' + name, observer);
	}
}


function showPopup(n_id,n_title,w,h) {
	if (typeof(n_title) != 'undefined' && n_title != "") p_url = "pages-popup-page-" + n_title.substring(0,60).replace(/[^a-z0-9]+/gi,"_");
	else p_url = "pages-popup-page";
	
	var _w = (typeof(w) != 'undefined') ? w : 782;
	var _h = (typeof(h) != 'undefined') ? h : 600;
	
	var w=window.open(p_url+"?oid="+n_id, "popupWindow", 'toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width=' + _w + ',height=' + _h );
	w.focus();
}
var showVideo = showPopup;


// JavaScript Document
/* Array of windows to allow closing of all popups */

openWins = new Array();
curWin = 0;

function doPopUpFull(theURL, theWidth, theHeight, windowName ) {
	openWins[curWin] = window.open(theURL, windowName,
		'toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,' 
		+ 'width=' + theWidth + ',height=' + theHeight );

	openWins[curWin++].focus();
}

function doPopupName(theURL, windowName )	{
	doPopUpFull( theURL, 782, 400, windowName );
}

function doBigPopup(theURL, windowName )	{
	doPopUpFull( theURL, 800, 600, windowName );
}

function doPopup(theURL)	{
	doPopUpFull( theURL, 782, 400, 'PopUpWindow' );
}

function doSmallPopup(theURL)	{
	doPopUpFull( theURL, 320, 240, 'PopUpWindow' );
}

function doMediumPopup(theURL)	{
	doPopUpFull( theURL, 400, 240, 'PopUpWindow' );
}

function closePopUps() {
	for(i=0; i < openWins.length; i++) {
		if (openWins[i] && !openWins[i].closed) {
			openWins[i].close();
		}
	}
}

// Flash check
	//var MM_minVersion = 5;
	var MM_hasVersion = 0;
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if ( plugin ) {
			var words = navigator.plugins["Shockwave Flash"].description.split(" ");
		    for (var i = 0; i < words.length; ++i)
		    {
			if (isNaN(parseInt(words[i])))
			continue;
			var MM_PluginVersion = words[i]; 
		    }
	}
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
	   && (navigator.appVersion.indexOf("Win") != -1)) {
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
		document.write('on error resume next \n');
		document.write('For flashvers = 2 to 9\n');
		document.write('	If Not IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & cstr(flashvers))) Then\n');
		document.write('		\n');
		document.write('	Else\n');
		document.write('		MM_PluginVersion = flashvers\n');
		document.write('	End If\n');
		document.write('Next\n');
		document.write('</SCR' + 'IPT\> \n');
	}
	/*function writeIfCanPlay(p_true, p_false) {
		document.write((MM_FlashCanPlay) ? p_true : p_false);
	}
	function writeFlashReplacer(p_id, p_data) {
		if (MM_FlashCanPlay) {
			var obj = MM_findObj(p_id);
			obj.innerHTML = p_data;
		}
	}*/
	var MM_FlashCanPlay = MM_PluginVersion >= 2;
	if ( MM_FlashCanPlay ) {
		MM_hasVersion = Math.round(MM_PluginVersion);
	}

	/*if(MM_FlashCanPlay)
		document.location.href="#JSStringFormat(trueURL)#";
	else
		document.location.href="#JSStringFormat(falseURL)#";*/
	
	//document.location.href="#JSStringFormat(flashURL)#" + MM_hasVersion;
function swapFlashif(d_id, min_version, new_html)
{
	var o_id = MM_findObj(d_id);
	if(o_id && MM_hasVersion >= min_version)
		o_id.innerHTML=new_html;
}

function isFlashVersion ( min_version ) {
	return (MM_hasVersion >= min_version);
}

/* tracing flash movie */
function traceFlash(txt) {
	if (!$('flash_trace')) return;
	var obj = document.getElementById('flash_trace');
	obj.innerHTML = obj.innerHTML + txt + "<br />";
}





// DD Belated png fix - from FUI
// Add selectors to the end of the list

/**
* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
* Author: Drew Diller
* Email: drew.diller@gmail.com
* URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/
* Version: 0.0.7a
* Licensed under the MIT License: http://dillerdesign.com/experiment/DD_belatedPNG/#license
*
* Example usage:
* DD_belatedPNG.fix('.png_bg'); // argument is a CSS selector
* DD_belatedPNG.fixPng( someNode ); // argument is an HTMLDomElement
**/

/*
PLEASE READ:
Absolutely everything in this script is SILLY.  I know this.  IE's rendering of certain pixels doesn't make sense, so neither does this code!
*/

var DD_belatedPNG = {

	ns: 'DD_belatedPNG',
	imgSize: {},
	
	createVmlNameSpace: function() { /* enable VML */
		if (document.namespaces && !document.namespaces[this.ns]) {
		  document.namespaces.add(this.ns, 'urn:schemas-microsoft-com:vml');
		}
		/*if (window.attachEvent) {
			window.attachEvent('onbeforeunload', function() {
				DD_belatedPNG = null;
			});
		}*/
	},
	
	createVmlStyleSheet: function() { /* style VML, enable behaviors */
		/*
			Just in case lots of other developers have added
			lots of other stylesheets using document.createStyleSheet
			and hit the 31-limit mark, let's not use that method!
			further reading: http://msdn.microsoft.com/en-us/library/ms531194(VS.85).aspx
		*/
		var style = document.createElement('style');
		document.documentElement.firstChild.insertBefore(style, document.documentElement.firstChild.firstChild);
		var styleSheet = style.styleSheet;
		styleSheet.addRule(this.ns + '\\:*', '{behavior:url(#default#VML)}');
		styleSheet.addRule(this.ns + '\\:shape', 'position:absolute;');
		styleSheet.addRule('img.' + this.ns + '_sizeFinder', 'behavior:none; border:none; position:absolute; z-index:-1; top:-10000px; visibility:hidden;'); /* large negative top value for avoiding vertical scrollbars for large images, suggested by James O'Brien, http://www.thanatopsic.org/hendrik/ */
		this.styleSheet = styleSheet;
	},
	
	readPropertyChange: function() {
		var el = event.srcElement;
		if (event.propertyName.search('background') != -1 || event.propertyName.search('border') != -1) {
			DD_belatedPNG.applyVML(el);
		}
		if (event.propertyName == 'style.display') {
			var display = (el.currentStyle.display == 'none') ? 'none' : 'block';
			for (var v in el.vml) {
				el.vml[v].shape.style.display = display;
			}
		}
		if (event.propertyName.search('filter') != -1) {
			DD_belatedPNG.vmlOpacity(el);
		}
	},
	
	vmlOpacity: function(el) {
		if (el.currentStyle.filter.search('lpha') != -1) {
			var trans = el.currentStyle.filter;
			trans = parseInt(trans.substring(trans.lastIndexOf('=')+1, trans.lastIndexOf(')')), 10)/100;
			el.vml.color.shape.style.filter = el.currentStyle.filter; /* complete guesswork */
			el.vml.image.fill.opacity = trans; /* complete guesswork */
		}
	},
	
	handlePseudoHover: function(el) {
		setTimeout(function() { /* wouldn't work as intended without setTimeout */
			DD_belatedPNG.applyVML(el);
		}, 1);
	},
	
	/**
	* This is the method to use in a document.
	* @param {String} selector - REQUIRED - a CSS selector, such as '#doc .container'
	**/
	fix: function(selector) {
		var selectors = selector.split(','); /* multiple selectors supported, no need for multiple calls to this anymore */
		for (var i=0; i<selectors.length; i++) {
			this.styleSheet.addRule(selectors[i], 'behavior:expression(DD_belatedPNG.fixPng(this))'); /* seems to execute the function without adding it to the stylesheet - interesting... */
		}
	},
	
	applyVML: function(el) {
		el.runtimeStyle.cssText = '';
		this.vmlFill(el);
		this.vmlOffsets(el);
		this.vmlOpacity(el);
		if (el.isImg) {
			this.copyImageBorders(el);
		}
	},
	
	attachHandlers: function(el) {
		var self = this;
		var handlers = {resize: 'vmlOffsets', move: 'vmlOffsets'};
		if (el.nodeName == 'A') {
			var moreForAs = {mouseleave: 'handlePseudoHover', mouseenter: 'handlePseudoHover', focus: 'handlePseudoHover', blur: 'handlePseudoHover'};
			for (var a in moreForAs) {
				handlers[a] = moreForAs[a];
			}
		}
		for (var h in handlers) {
			el.attachEvent('on' + h, function() {
				self[handlers[h]](el);
			});
		}
		el.attachEvent('onpropertychange', this.readPropertyChange);
	},
	
	giveLayout: function(el) {
		el.style.zoom = 1;
		if (el.currentStyle.position == 'static') {
			el.style.position = 'relative';
		}
	},
	
	copyImageBorders: function(el) {
		var styles = {'borderStyle':true, 'borderWidth':true, 'borderColor':true};
		for (var s in styles) {
			el.vml.color.shape.style[s] = el.currentStyle[s];
		}
	},
	
	vmlFill: function(el) {
		if (!el.currentStyle) {
			return;
		} else {
			var elStyle = el.currentStyle;
		}
		for (var v in el.vml) {
			el.vml[v].shape.style.zIndex = elStyle.zIndex;
		}
		el.runtimeStyle.backgroundColor = '';
		el.runtimeStyle.backgroundImage = '';
		var noColor = (elStyle.backgroundColor == 'transparent');
		var noImg = true;
		if (elStyle.backgroundImage != 'none' || el.isImg) {
			if (!el.isImg) {
				el.vmlBg = elStyle.backgroundImage;
				el.vmlBg = el.vmlBg.substr(5, el.vmlBg.lastIndexOf('")')-5);
			}
			else {
				el.vmlBg = el.src;
			}
			var lib = this;
			if (!lib.imgSize[el.vmlBg]) { /* determine size of loaded image */
				var img = document.createElement('img');
				lib.imgSize[el.vmlBg] = img;
				img.className = lib.ns + '_sizeFinder';
				img.runtimeStyle.cssText = 'behavior:none; position:absolute; left:-10000px; top:-10000px; border:none;'; /* make sure to set behavior to none to prevent accidental matching of the helper elements! */
				img.attachEvent('onload', function() {
					this.width = this.offsetWidth; /* weird cache-busting requirement! */
					this.height = this.offsetHeight;
					lib.vmlOffsets(el);
				});
				img.src = el.vmlBg;
				img.removeAttribute('width');
				img.removeAttribute('height');
				document.body.insertBefore(img, document.body.firstChild);
			}
			el.vml.image.fill.src = el.vmlBg;
			noImg = false;
		}
		el.vml.image.fill.on = !noImg;
		el.vml.image.fill.color = 'none';
		el.vml.color.shape.style.backgroundColor = elStyle.backgroundColor;
		el.runtimeStyle.backgroundImage = 'none';
		el.runtimeStyle.backgroundColor = 'transparent';
	},
	
	/* IE can't figure out what do when the offsetLeft and the clientLeft add up to 1, and the VML ends up getting fuzzy... so we have to push/enlarge things by 1 pixel and then clip off the excess */
	vmlOffsets: function(el) {
		var thisStyle = el.currentStyle;
		var size = {'W':el.clientWidth+1, 'H':el.clientHeight+1, 'w':this.imgSize[el.vmlBg].width, 'h':this.imgSize[el.vmlBg].height, 'L':el.offsetLeft, 'T':el.offsetTop, 'bLW':el.clientLeft, 'bTW':el.clientTop};
		var fudge = (size.L + size.bLW == 1) ? 1 : 0;
		
		/* vml shape, left, top, width, height, origin */
		var makeVisible = function(vml, l, t, w, h, o) {
			vml.coordsize = w+','+h;
			vml.coordorigin = o+','+o;
			vml.path = 'm0,0l'+w+',0l'+w+','+h+'l0,'+h+' xe';
			vml.style.width = w + 'px';
			vml.style.height = h + 'px';
			vml.style.left = l + 'px';
			vml.style.top = t + 'px';
		};
		makeVisible(el.vml.color.shape, (size.L + (el.isImg ? 0 : size.bLW)), (size.T + (el.isImg ? 0 : size.bTW)), (size.W-1), (size.H-1), 0);
		makeVisible(el.vml.image.shape, (size.L + size.bLW), (size.T + size.bTW), (size.W), (size.H), 1);
		
		var bg = {'X':0, 'Y':0};
		var figurePercentage = function(axis, position) {
			var fraction = true;
			switch(position) {
				case 'left':
				case 'top':
					bg[axis] = 0;
					break;
				case 'center':
					bg[axis] = .5;
					break;
				case 'right':
				case 'bottom':
					bg[axis] = 1;
					break;
				default:
					if (position.search('%') != -1) {
						bg[axis] = parseInt(position)*.01;
					}
					else {
						fraction = false;
					}
			}
			var horz = (axis == 'X');
			bg[axis] = Math.ceil(fraction ? ( (size[horz?'W': 'H'] * bg[axis]) - (size[horz?'w': 'h'] * bg[axis]) ) : parseInt(position));
			if (bg[axis] == 0) {
				bg[axis]++;
			}
		};
		for (var b in bg) {
			figurePercentage(b, thisStyle['backgroundPosition'+b]);
		}
		
		el.vml.image.fill.position = (bg.X/size.W) + ',' + (bg.Y/size.H);
		
		var bgR = thisStyle.backgroundRepeat;
		var dC = {'T':1, 'R':size.W+fudge, 'B':size.H, 'L':1+fudge}; /* these are defaults for repeat of any kind */
		var altC = { 'X': {'b1': 'L', 'b2': 'R', 'd': 'W'}, 'Y': {'b1': 'T', 'b2': 'B', 'd': 'H'} };
		if (bgR != 'repeat') {
			var c = {'T':(bg.Y), 'R':(bg.X+size.w), 'B':(bg.Y+size.h), 'L':(bg.X)}; /* these are defaults for no-repeat - clips down to the image location */
			if (bgR.search('repeat-') != -1) { /* now let's revert to dC for repeat-x or repeat-y */
				var v = bgR.split('repeat-')[1].toUpperCase();
				c[altC[v].b1] = 1;
				c[altC[v].b2] = size[altC[v].d];
			}
			if (c.B > size.H) {
				c.B = size.H;
			}
			el.vml.image.shape.style.clip = 'rect('+c.T+'px '+(c.R+fudge)+'px '+c.B+'px '+(c.L+fudge)+'px)';
		}
		else {
			el.vml.image.shape.style.clip = 'rect('+dC.T+'px '+dC.R+'px '+dC.B+'px '+dC.L+'px)';
		}
	},
	
	fixPng: function(el) {
		el.style.behavior = 'none';
		if (el.nodeName == 'BODY' || el.nodeName == 'TD' || el.nodeName == 'TR') { /* elements not supported yet */
			return;
		}
		else if (typeof(el.className) != 'undefined' && el.className == 'no_pngfix') { /* added exception of any images that we don't need pngfix for - SHEHZAD */
			return;
		}
		el.isImg = false;
		if (el.nodeName == 'IMG') {
			if(el.src.toLowerCase().search(/\.png$/) != -1) {
				el.isImg = true;
				el.style.visibility = 'hidden';
			}
			else {
				return;
			}
		}
		else if (el.currentStyle.backgroundImage.toLowerCase().search('.png') == -1) {
			return;
		}
		var lib = DD_belatedPNG;
		el.vml = {color: {}, image: {}};
		var els = {shape: {}, fill: {}};
		for (var r in el.vml) {
			for (var e in els) {
				var nodeStr = lib.ns + ':' + e;
				el.vml[r][e] = document.createElement(nodeStr);
			}
			el.vml[r].shape.stroked = false;
			el.vml[r].shape.appendChild(el.vml[r].fill);
			el.parentNode.insertBefore(el.vml[r].shape, el);
		}
		el.vml.image.shape.fillcolor = 'none'; /* Don't show blank white shapeangle when waiting for image to load. */
		el.vml.image.fill.type = 'tile'; /* Ze magic!! Makes image show up. */
		el.vml.color.fill.on = false; /* Actually going to apply vml element's style.backgroundColor, so hide the whiteness. */
		
		lib.attachHandlers(el);
		
		lib.giveLayout(el);
		lib.giveLayout(el.offsetParent);
		
		/* set up element */
		lib.applyVML(el);
	}
	
};
try {
	document.execCommand("BackgroundImageCache", false, true); /* TredoSoft Multiple IE doesn't like this, so try{} it */
} catch(r) {}
if (navigator.userAgent.indexOf("MSIE 6") != -1) { // Added check for IE6 because issues with existing JS - SHEHZAD
	DD_belatedPNG.createVmlNameSpace();
	DD_belatedPNG.createVmlStyleSheet();
	
	//	add css classes to this string
	//	string argument can be any CSS selector
	DD_belatedPNG.fix('img, .pngfix');
}

var Logger = {
	enabled: false,
	info: function(message) {
		if (!this.enabled) return;
		var img = new Image();
		img.src = baseSiteURLJS + "log.cfm?info=" + escape(message) + "&ua=" + escape(navigator.userAgent);
	}
};

function truncatedDollarCurrency(num) {
	// resize with UoM
	var uom = "";
	if (num >= 1000000) {
		num /= 1000000;
		uom = "M";	
	} else if (num >= 1000) {
		num /= 1000;
		uom = "K";	
	}
	// generate string format
	num = Math.round(num*10) / 10;
	var dec = Math.round((Math.abs(num)-Math.floor(Math.abs(num)))*10);
	num = Math.floor(num); // no cents!
	sign = (num == (num = Math.abs(num)));
	num = num.toString();
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
	if (num.length == 1) num += "." + dec;
	return (((sign)?'':'-') + '$' + num) + uom;
}
function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	num = Math.floor(num/100).toString();
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num);
}
function formatInt(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	num = Math.floor(num/100).toString();
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num);
}
function showTooltip(x, y, contents) {
	jQuery('<div id="tooltip" class="chart_tooltip">' + contents + '</div>').css( { top: y + 5, left: x + 5, opacity:0.8 }).appendTo(jQuery("body"));
}
function configureTooltip(jChart, f_getContents) {
	var previousPoint = null;
	jChart.bind("plothover", function (event, pos, item) {
		if (item) {
			if (previousPoint != item.seriesIndex) {
				previousPoint = item.seriesIndex;
				
				jQuery("#tooltip").remove();
				showTooltip(pos.pageX, pos.pageY, f_getContents(item));
			}
		}
		else {
			jQuery("#tooltip").remove();
			previousPoint = null;            
		}
	});
}
