/* 10/28/2008 BL */
/********************************************************
GlobalUtils - A series of utility functions and variables 
********************************************************/

var GlobalUtils = {	

	//IE6 Variable, only true if running IE6
	IE6: false /*@cc_on || @_jscript_version < 5.7 @*/,
	//IE7 Variable, only true if running IE7
	IE7: false /*@cc_on || @_jscript_version >= 5.7 @*/,
	
	//Firefox Max Detector, only true if running FF Mac < version 3.0
	detectMacFirefox2: function() {
		var ua = navigator.userAgent.toLowerCase();
		if (/firefox[\/\s](\d+\.\d+)/.test(ua)) {
			var firefox_version = new Number(RegExp.$1);
			if (firefox_version < 3 && ua.indexOf('mac') != -1) {
				return true;
			}
		}
		return false;
	},
	
	/****************************************************************
	iFrameShim
	*****************************************************************
	function which inserts an invisible iframe beneath positioned
	elements to fix an IE6 issue where select lists appear above all
	other elements.
	****************************************************************/
	iFrameShim: function (callType, elParent, shimId) {
		//IE6 Check
		if (!this.IE6) { return; }
		
		var id =  shimId || 'ie6_shim';
		if (callType == "activate") {
			var parentDim = elParent.getDimensions();
			var shim = document.createElement('iframe');
			shim.setAttribute('width',parentDim.width);
			shim.setAttribute('id', shimId);
			shim.setAttribute('height',parentDim.height);
			shim.style.position = 'absolute';
			shim.style.zIndex = '-1';
			shim.style.left = '0px';
			shim.style.top = '0px';
			elParent.appendChild(shim);
			shim.style.filter = 'alpha(opacity=0)';
		}
		if (callType == "deactivate") {
			if($(shimId)){ $(shimId).remove(); }
		}
	},
	
	/****************************************************************
	ieHover
	*****************************************************************
	Allows css hovering in IE6 by attaching a css class on mouseover.
	****************************************************************/
	ieHover: function(elementSelector, cssClass){	
		var hoverEl = $$(elementSelector);
		if(!hoverEl) { return; } // element check		
		hoverEl.each(function(el){
			Event.observe(el, "mouseover", function(){el.addClassName(cssClass)});
			Event.observe(el, "mouseout", function(){el.removeClassName(cssClass)});
		});
	},
	
	/***********************************************************************
	No JS Remover - Removes all classes of "nojs" if javascript is available
	***********************************************************************/	
	noJsRemover: function() {
		$$("body").reduce().select(".nojs").invoke('removeClassName', 'nojs');
	},

	/***********************************************************************
	Query String Decoder - Turns the URL query string into an object
	***********************************************************************/		
	queryStringDecoder: function() {
		this.queryString = window.location.search.toQueryParams();
	}
}


/************************************************************************
Flash Background - adds fancy animated flash sidebars
************************************************************************/

var FlashBackground = {	
	initialize: function(){
		// if you do not have flash player 8, are on the homepage, or a page flagged to not have the flash sidebars, return
		if (swfobject.getFlashPlayerVersion().major < 8 || 
			$$("body").reduce().id == "homepage" || 
			$$("body.").reduce().hasClassName("popup_window") == true ||
			$$("div.no_flash_sidebars").length > 0) { 
				return; 
			}
		
		// mark up for the entire flash container, added in JS to reduce changes to existing pages
		var markUp ='<div class="flash_wrapper">'+
						'<div class="flash_container">'+
							'<div class="flash_holder">'+
								'<div class="flash_left">'+
									'<div id="flash_left_content"></div>'+
								'</div>'+
								'<div class="flash_right">'+
									'<div id="flash_right_content"></div>'+
								'</div>'+
							'</div>'+
						'</div>'+
					'</div>'
		
		// insert markup into top of body
		$$("body").reduce().insert({top: markUp});

		// embed flash
		this.embedFlash();
	},
	
	embedFlash: function(){
		
		// left panel flash embed
		swfobject.embedSWF(
			"http://sites.target.com/images/company/flash/global/leftPanel.swf", 
			"flash_left_content", 
			"269", 
			"366", 
			"8.0.0",
      "expressInstall.swf",
      {},
			{
			allowScriptAccess: "always",				
			menu: "false",
			scale: "noscale",
			wmode: "opaque"
			}
		);

		// right panel flash embed
		swfobject.embedSWF(
			"http://sites.target.com/images/company/flash/global/rightPanel.swf", 
			"flash_right_content", 
			"269", 
			"366", 
			"8.0.0",
      "expressInstall.swf",
      {},
			{
			allowScriptAccess: "always",				
			menu: "false",
			scale: "noscale",
			wmode: "opaque"
			}
		);

		// remove background - Fixes Mac FF and Safari flash player bug
		$("page_wrapper").style.background = "none";
	},

	unembedFlash: function(){
		
		// unembed left flash
		var flashLeftDiv = document.createElement("div");
		flashLeftDiv.id = "flash_left_content";
		$("flash_left_content").insert({before: flashLeftDiv}).remove();
		
		// unembed right flash
		var flashRightDiv = document.createElement("div");		
		flashRightDiv.id = "flash_right_content";				
		$("flash_right_content").insert({before: flashRightDiv}).remove();
		
		// remove "background: none" style
		$("page_wrapper").removeAttribute("style");
	}	
}


/************************************************************************
InputCopier - adds a button that copies the contents of an input on click
************************************************************************/

var InputCopier = Class.create();

InputCopier.prototype = {
	initialize: function(inputId, btnClass, btnText) {	
		//element check
		if(!$(inputId)){ return; }
		
		// variables
		this.input = $(inputId);
		this.btnClass = btnClass;
		this.btnText = btnText;
		
		// if you are in IE create button node and attach event listener to call ieCopy function on click
		if (this.input.createTextRange) {
			this.createButton();
			Event.observe(this.copyBtn, "click", this.ieCopy.bindAsEventListener(this));		
		}
		
		// if you are not in IE and your flash player version is less than 8 return
		if (!this.input.createTextRange && swfobject.getFlashPlayerVersion().major < 8){ return; }
		
		// if you are not in IE and your flash player version is greater than 8, create button node and attach otherCopy function on click
		if (!this.input.createTextRange && swfobject.getFlashPlayerVersion().major > 8){		
			this.createButton();
			Event.observe(this.copyBtn, "click", this.otherCopy.bindAsEventListener(this));
		}
		
	},
	
	createButton: function() {
	
		//create button node
		this.copyBtn = document.createElement('a');
		this.copyBtn.className = this.btnClass;		
		var copyBtnSpan = document.createElement('span');
		var copyBtnText = document.createTextNode(this.btnText);
		
		//append button node
		copyBtnSpan.appendChild(copyBtnText);
		this.copyBtn.appendChild(copyBtnSpan);				
		this.input.insert({after: this.copyBtn});
	
	},
	
	ieCopy: function(){
		var range = this.input.createTextRange();
		range.execCommand('Copy');	
	},
	
	otherCopy: function(e){

		var flashcopier = 'flashcopier';
		// if flash embed container doesn't exist..
		if(!$(flashcopier)) {
			// create and append flash embed container
			var divholder = document.createElement('div');
			divholder.id = flashcopier;
			document.body.appendChild(divholder);
		}
		// clear and flash embed container
		$(flashcopier).update();
		$(flashcopier).update('<embed src="../../../images/company/flash/global/_clipboard.swf" FlashVars="clipboard='+escape(this.input.value)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>');		
	}
}

/***********************************************************************
FormClearer - Adds a clear form button and clears the form on click
***********************************************************************/

var FormClearer = {	
	initialize: function(form) {
		//element check
		if (!$(form) || !$(form).select("div.footer")) { return; }
		
		// set variables
		var formInputs = $(form).select('input');
		var formTextAreas = $(form).select('textarea');
		this.formElements = formInputs.concat(formTextAreas);
		
		//create button node and append to footer
		var clearButtonNode = document.createElement('a');			
		$(form).select("div.footer").reduce().appendChild(clearButtonNode);
		clearButtonNode.className = "btn_medium btn_clearform";	
		
		//attach event listener to button node
		Event.observe(clearButtonNode, "click", this._linkClick.bindAsEventListener(this));		
	},
	
	_linkClick: function(e) {
		// set all form values to ""
		document.frmEmailArticle.txtToEmail.value = "";
		document.frmEmailArticle.txtFromEmail.value = "";
		document.frmEmailArticle.txtToName.value = "";
		document.frmEmailArticle.txtFromName.value = "";
		document.frmEmailArticle.txtMessage.value = "";
	}
}


/***************************************************************************************
Dropdown Nav - Turns a <ul> into a <select>  that can be used for navigation
***************************************************************************************/

var DropDownNav = Class.create();

DropDownNav.prototype = {
	
	initialize: function(elClass, defaultText, btnClass, btnValue) {
		//element checks
		if(!$$(elClass)) return; 		
		if(defaultText == "") defaultText = "Select...";
		this.btnClass = btnClass || false;
		this.btnValue = btnValue || false;
		// get all elements with a class of elClass
		var els = $$(elClass);

		for (var i=0;i<els.length;i++){
			
			//set el to the current element
			var el = els[i];
			
			//create default selected <option>
			var defaultOptionNode = document.createElement('option');
			var defaultTextNode = document.createTextNode(defaultText);
			defaultOptionNode.setAttribute('value', '');
			defaultOptionNode.setAttribute('selected', 'selected');
			defaultOptionNode.appendChild(defaultTextNode);
		
			//if the element is a <div> call the list transformer function
			if (el.nodeName.toLowerCase() == "div") this.listTransformer(el, defaultOptionNode);	
		}		
	},	
	
	listTransformer: function(el, defaultOptionNode) {		

		//get <ul> and <li>'s
		var unorderedList = el.select("ul").reduce();
		var listItems = unorderedList.childElements();

		// create new nodes for select list
		this.formNode = document.createElement('form');
		var selectNode = document.createElement('select');
		
		//append default <option>
		selectNode.appendChild(defaultOptionNode);
		
		for (var i=0;i<listItems.length;i++){
		
			//get anchors from inside <li>
			var itemAnchor = listItems[i].childElements().reduce();
			
			//create option, text, and attribute node's
			var optionNode = document.createElement('option');
			var textValue = itemAnchor.childNodes[0].nodeValue;
			var textNode = document.createTextNode(textValue);
			optionNode.setAttribute('value', itemAnchor.getAttribute('href'));
			
			// append nodes to select
			optionNode.appendChild(textNode);
			selectNode.appendChild(optionNode);
		}
		
		//append select to form
		this.formNode.appendChild(selectNode);
		
		// if a button URL is defined
		if(this.btnClass) {
			//create form button
			this.buttonNode = document.createElement('a');
			var buttonSpan = document.createElement('span');			
			var spanText = document.createTextNode(this.btnValue);
			this.buttonNode.className = this.btnClass+" btn_medium";			
			
			//create clearing div
			var clearNode = document.createElement('div');			
			
			// append nodes to form
			buttonSpan.appendChild(spanText);
			this.buttonNode.appendChild(buttonSpan);
			this.formNode.appendChild(this.buttonNode);						
			this.formNode.appendChild(clearNode);
			clearNode.style.clear = "both";
		}
		
		// append form to div
		el.appendChild(this.formNode);
		
		//attach event handler to list for navigation
		Event.observe(selectNode, "change", this._selectChange.bindAsEventListener(this));
		
		//remove original <ul>
		el.removeChild(unorderedList);
	},
	
	_selectChange: function(e) {
		
		var e = e || window.event;  // ie check
		
		//get source of change which should be <option>
		var elSrc = Event.element(e); 
		
		//get <option> value
		var elSrcValue = elSrc.value;
		
		// if you have a button attach the value to the buttons href
		if(this.btnClass) {
			this.buttonNode.setAttribute('href', elSrcValue)
		// else, open on change
		} else {
			window.open(elSrcValue,'_self');
		}
	}
}


/***************************************************************************************
Pop-up Box - Shows A Pop-up box with border expanding animation when you click an anchor
***************************************************************************************/

var PopUpBox = Class.create({
	
	initialize: function(links, popups, closeLinks, dimBackground, ajax) {
		// element check
		if(!$$(links) || !$$(popups) || !$$(closeLinks)) { return; }
		
		// variables
		this.links = $$(links);
		this.popupSelector = popups;
		this.popups = $$(popups);
		this.dimBackground = dimBackground || false;
		this.ajax = ajax || false;
		
		// return false if links and items do not exist 
		if (this.popups.length == 0 || this.links.length == 0) { return; }		
		
		// add event listeners
		this.links.invoke("observe", "click", this._linkClick.bindAsEventListener(this));
		
		//hide all items
		this.hideAll(); 
		
		// transform "back to top" links to "close" links
		this.closeLinkTransformer(closeLinks); 
		
		// check to see if there is a query string to have a popup open by default
		// updated to fix JS IE 6 Error - BL / SV 1/23/2009
		if (GlobalUtils.queryString && GlobalUtils.queryString.popupID){
			this.quickSetItem(GlobalUtils.queryString.popupID);
		}
	},
	
	_linkClick: function(e) {
		Event.stop(e);  // stop event
		var link = Event.findElement(e, 'a');		
		
		// if the link clicked has a class name of "close" call closeItem, otherwise call setItem
		(link.hasClassName("close")) ? this.closeItem(link) : this.setItem(link);
	},
	
	hideAll: function() {		
		this.popups.each(function(currentPopup){
			currentPopup.style.display = "none";
			GlobalUtils.iFrameShim("deactivate", currentPopup);
		});		
	}, 
	
	closeItem: function(link){
		var popupContainer = link.up(this.popupSelector); // get the popup container
		this.outlineCreator(popupContainer); // create the outline div
		popupContainer.style.display = "none"; // hide the popup
		GlobalUtils.iFrameShim("deactivate", popupContainer); // hide the popup iframe
		
		for (var i=0; i < this.links.length; i++) {
			
			if (this.ajax == true){

				// get link dimensions and position
				var currentLink = this.ajaxOrigin; 
				// display animation
				if(this.dimBackground == false){
					this.closeAnimation(link, currentLink);					
				} else {
					this.closeAnimation(link, currentLink);
				}								
				break;

			} else {
				// get href attribute of the link without the #
				var hrefAttr = this.links[i].getAttribute("href").replace(/.*#+/, '');				

				if (hrefAttr == popupContainer.id) {  // if item id is equal to link href then hide item
					
					// get link dimensions and position
					var currentLink = this.links[i]; 
	
					// display animation
					if(this.dimBackground == false){
						this.closeAnimation(link, currentLink);					
					} else {
						this.closeAnimation(link, currentLink);
					}								
					break;
				}
			}
		}
	},
	
	closeAnimation: function(link, currentLink){	
		// get link dimensions and position
		var linkDim = currentLink.getDimensions();																	
		var linkPos = currentLink.cumulativeOffset();		
		
		// animate border
		new Effect.Morph(this.borderDiv, { 
			style: {
				width: linkDim.width+'px',
				height: linkDim.height+'px',
				top: linkPos.top+'px',
				left: linkPos.left+'px'
			},
			duration: 0.4,
			fps: 60,
			afterFinish: function(){
				$("animated_outline").remove();
				// if background dimming is on...
				if(this.dimBackground == true){
					// Show all selects in IE6
					if(GlobalUtils.IE6 == true){ 
				        $$("select").invoke('setStyle', {visibility: "visible"}); 
					}		
				
					// short timeout for IE performance
					this.timeOut = setTimeout(function(){
					
						// background fade
						new Effect.Appear(this.backgroundDiv, { 
							from: 0.5,
							to: 0.0,
							duration: 0.3,
							fps: 60,
							afterFinish: function(){
								$("background_dim").remove();
							}.bind(this)
						});	

					}.bind(this), 300);
					
				}		
			}.bind(this)
		});	
	},

	quickSetItem: function(popupID) {
		
		// get popup, dimensions, and position
		var popup = $(popupID);
		var viewportDim = document.viewport.getDimensions();
		var viewportOffsets = document.viewport.getScrollOffsets();
		var popupDim = popup.getDimensions();			
		var popupTopPos = viewportOffsets.top + (((viewportDim.height) - (popupDim.height))/2)
		var popupLeftPos = viewportOffsets.left + (((viewportDim.width) - (popupDim.width))/2)				
		
		// set popup to visible with no animation
		popup.style.position = "absolute";
		GlobalUtils.iFrameShim("activate", popup);
		popup.style.left = popupLeftPos + "px";
		popup.style.top = popupTopPos + "px";
		popup.style.display = "block";
	},
	
	setItem: function(link) {

		this.hideAll();
		
		if (this.ajax == true){
			
			// get the url for the ajax request
			var url = link.getAttribute("href");			

			// get rel attribute of the link without the #
			var hrefAttr = link.rel || "ajax_popup";
			this.ajaxOrigin = link;
			
			// fill popup with contents of ajax request
			var popupRequest = new Ajax.Request(url, {
				method: 'get',
				onComplete: function(response) {
						
					this.popups.each(function(currentPopup){

						if (currentPopup.id == hrefAttr) {							
							// temporary storage for the full response
							var tempContainer = document.createElement("div");
							tempContainer.className = "hidden";
							tempContainer.id = "temp_ajax_container";
							document.body.insert({top: tempContainer});							
							$("temp_ajax_container").update(response.responseText);							
							
							var ajaxCloseLinks = "div#temp_ajax_container div.close a"
							this.closeLinkTransformer(ajaxCloseLinks);
							
							// popup body from response
							var linkedPopupBody = $("temp_ajax_container").select("div.popup_box div.body").first();
							var linkedPopupHeader = $("temp_ajax_container").select("div.popup_box div.header h1").first();
							
							// popup body on page							
							var currentPopupBody = currentPopup.select("div.popup_body").first();
							var currentPopupHeader = currentPopup.select("div.header").first();
							
							// add response popup body to page popup body
							currentPopupBody.update(linkedPopupBody);
							currentPopupHeader.select("h1").each(function(s){s.remove()});
							currentPopupHeader.insert({top: linkedPopupHeader});
							
							
							// display animation
							if(this.dimBackground == false){
								this.openAnimation(link, currentPopup);
							} else {
								this.backgroundCreator(link, currentPopup);
							}
						}
					}.bind(this));
				}.bind(this)
			});			
		} else {
			// get href attribute of the link without the #
			var hrefAttr = link.getAttribute("href").replace(/.*#+/, ''); 
		
			for (var i=0; i < this.popups.length; i++) {
				if (this.popups[i].id == hrefAttr) {  // if item id is equal to link href then show item
					
					// variables
					var currentPopup = this.popups[i];			
	
					// display animation
					if(this.dimBackground == false){
						this.openAnimation(link, currentPopup);					
					} else {					
						this.backgroundCreator(link, currentPopup);
					}				
				}
			}
		}			
		
	},
	outlineCreator: function(link){
		// get item dimensions and position
		var borderDim = link.getDimensions();
		var borderPos = link.cumulativeOffset();
				
		// create border div and append it to the body
		this.borderDiv = document.createElement("div");
		this.borderDiv.id = "animated_outline";
		this.borderDiv.style.width = borderDim.width+"px";
		this.borderDiv.style.height = borderDim.height+"px";
		this.borderDiv.style.position = "absolute";
		this.borderDiv.style.top = borderPos.top+"px";
		this.borderDiv.style.left = borderPos.left+"px";
		this.borderDiv.style.border = "1px solid #ccc";
		this.borderDiv.style.zIndex = "101";
		document.body.appendChild(this.borderDiv);			
	},

	backgroundCreator: function(link, currentPopup) {
		
		// Hide all selects in IE6
		if(GlobalUtils.IE6 == true){	       
	        $$("select").invoke('setStyle', {visibility: "hidden"}); 
		}
		
		// get body and viewport height
		var bodyHeight = document.body.getHeight();
		var viewportHeight = document.viewport.getHeight();
		
		// create and insert background div
		this.backgroundDiv = document.createElement("div");
		this.backgroundDiv.id = "background_dim";
		document.body.insert({top: this.backgroundDiv});
		
		// set background div style
		$("background_dim").setStyle({
			background: "#000000",
			left: "0px",
			margin: "auto",
			top: "0px",
			width: "100%",
			zIndex: "100",
			position: "absolute",
			opacity: "0"
		});
		
		// set div height to viewport height or body height, whichever is largest
		if (bodyHeight > viewportHeight){ 
			$("background_dim").setStyle({height: bodyHeight+"px"});
		} else {
			$("background_dim").setStyle({height: viewportHeight+"px"});
		}

		// if you are running FF Mac use PNG instead of opacity to fix flash player bug
		if(GlobalUtils.detectMacFirefox2() == true){			
			$("background_dim").setStyle({
				opacity: "inherit",
				background: "url(../../../images/company/global/base/background_dim.png)"
			});
			this.openAnimation(link, currentPopup);
		// fade in animation
		} else {
			new Effect.Appear(this.backgroundDiv, { 
				from: 0.0,
				to: 0.6,
				duration: 0.3,
				fps: 60,
				afterFinish: function(){
					// timeout for IE performance
					this.timeOut = setTimeout(function(){
						// outline animation
						this.openAnimation(link, currentPopup);
					}.bind(this), 300);
				}.bind(this)
			});
		}
	},
		
	openAnimation: function(link, currentPopup){
		
		// get popup and viewport sizes and positions
		var viewportDim = document.viewport.getDimensions();
		var viewportOffsets = document.viewport.getScrollOffsets();
		var popupDim = currentPopup.getDimensions();
		var popupTopPos = viewportOffsets.top + (((viewportDim.height) - (popupDim.height))/2);
		var popupLeftPos = viewportOffsets.left + (((viewportDim.width) - (popupDim.width))/2);
				
		// create outline div
		this.outlineCreator(link);
		
		// animate outline div
		new Effect.Morph(this.borderDiv, { 
			style: {
				width: popupDim.width+'px',
				height: popupDim.height+'px',
				top: popupTopPos+'px',
				left: popupLeftPos+'px'
			},
			duration: 0.4,
			fps: 60,
			afterFinish: function(){				
				// remove outline
				$("animated_outline").remove();
				
				//display popup					
				currentPopup.style.position = "absolute";
				GlobalUtils.iFrameShim("activate", currentPopup);
				currentPopup.style.left = popupLeftPos + "px";
				currentPopup.style.top = popupTopPos + "px";
				currentPopup.style.display = "block";	
				currentPopup.style.zIndex = "100";
			}
		});		
	},
	
	closeLinkTransformer: function(closeLinks) {
		// get all "close" links
		var closeLinks = $$(closeLinks);	
		
		//change text and class names from "Back To Top" to "Close"
		closeLinks.each(function(s){ 			
			s.removeClassName('back_to_top').addClassName('close');			
			if (s.firstChild.nodeValue.toLowerCase() == "back to top"){			
				s.firstChild.nodeValue = "Close"
			}
			$(s.parentNode).removeClassName('back_to_top').addClassName('close');
		});
		
		// Attach event handlers to links
		for (var i=0; i < closeLinks.length; i++) {     
			Event.observe(closeLinks[i], "click", this._linkClick.bindAsEventListener(this));
		}						
	}
});

/**************************************************************************************
ListSlider - collapses a list of items into clickable bars that expand to show content.
**************************************************************************************/

var ListSlider = Class.create();

ListSlider.prototype = {
	initialize: function(headerContentSelector, triggerSelector, drawerSelector, speed, introParagraph){	
			
		// variables
		this.headerContent = $$(headerContentSelector).reduce() || false;
		this.triggers = $$(triggerSelector);
		this.drawers = $$(drawerSelector);
		this.introParagraph = introParagraph;
		this.duration = speed;
		this.allClosed = false;
		
		// element check
		if (!this.triggers.length || !this.drawers.length){ return; }	

		// if there is only one trigger/drawer set class on single drawer and return
		if (this.drawers.length < 2){ this.drawers.reduce().addClassName("single_item"); return;}
		
		if (this.headerContent != false){
			// create and insert expand/collapse all link and paragraph
			this.allTrigger = new Element("a", {id: "expand_all", href: "javascript: void(0)", onclick: "return false;"}).update("expand all.");
			if(this.introParagraph) { 
				this.introParagraph = new Element("p").update(this.introParagraph); 
				this.headerContent.insert({bottom: this.introParagraph});
			}
			this.introParagraph.insert({bottom: this.allTrigger});
			Event.observe(this.allTrigger, "click", this.expandCollapseAll.bindAsEventListener(this));			
		}


		// add accessibility labels and anchors
		this.triggers.each(function(currentItem){
			currentItem.select("h3")[0].insert('<span class="accessibility_label">Click here to open drawer</span>');
		});
		this.drawers.each(function(currentDrawer){
			var accessibleAnchor = new Element("a", {href: "javascript: void(0)", onclick: "return false;"});
			accessibleAnchor.insert('<span class="accessibility_label">Content available below for this drawer. Click here to close drawer.</span>');
			currentDrawer.insert({top: accessibleAnchor});			
			Event.observe(accessibleAnchor, "click", this.slideAnim.bindAsEventListener(this));
		}.bind(this));		
		this.triggers.each(function(currentItem){
			var accessibleAnchor = new Element("a", {href: "javascript: void(0)", onclick: "return false;"});
			var innerItems = currentItem.select("h3 *");
			currentItem.select("h3")[0].insert(accessibleAnchor);
			innerItems.each(function(currentItem){
				accessibleAnchor.insert(currentItem)
			});
		});
		
		
		
		
		// get all the original drawer heights and set them to the rel
		this.drawers.each(function(currentDrawer){
			currentDrawer.rel = currentDrawer.getHeight();
		});
		
		// set hover on triggers for IE6
		if(GlobalUtils.IE6 == true){ GlobalUtils.ieHover(triggerSelector, "iehover"); }
		
		// collapse all by default
		this.expandCollapseAll();
		
		// attach event handlers
		this.triggers.invoke("observe", "click", this.slideAnim.bindAsEventListener(this));
	},
	
	expandCollapseAll: function(){
		// if all are closed
		if (this.allClosed == true){
			// add class name of open on triggers
			this.triggers.each(function(currentTrigger){
				currentTrigger.removeClassName("closed").addClassName("open");
			});	
			// show drawers
			this.drawers.each(function(currentDrawer){				
				currentDrawer.setStyle({
					height: currentDrawer.rel+"px",
					overflow: "hidden",
					position: "relative"
				});
				currentDrawer.removeClassName("is_hidden");			
			});
			this.allClosed = false;
			this.allTrigger.update("collapse all.");

			// modify accessibility label	
			this.triggers.each(function(currentTrigger){		
				currentTrigger.select("span.accessibility_label")[0].update("Click here to close drawer");
			});	



		// if all are not closed
		} else {
			// add class name of closed on triggers
			this.triggers.each(function(currentItem){
				currentItem.removeClassName("open").addClassName("closed");
			});
			// hide drawers
			this.drawers.each(function(currentDrawer){
				// set rel attribute to original height
				currentDrawer.setStyle({
					height: "0px",
					overflow: "hidden",
					position: "relative"
				});
				currentDrawer.addClassName("is_hidden");							
			});	
			
			// modify accessibility label	
			this.triggers.each(function(currentTrigger){		
				currentTrigger.select("span.accessibility_label")[0].update("Click here to open drawer");
			});	
						
			this.allClosed = true;	
			if(this.headerContent != false) {
				this.allTrigger.update("expand all.");
			}
		}
	},
	
	slideAnim: function(e){
		
		var currentTrigger = Event.element(e).up("div.slider").down("div.trigger") || Event.element(e);
		var currentDrawer = currentTrigger.up("div.slider").down("div.drawer");
		
		// if current drawer is hidden...
		if(currentDrawer.hasClassName("is_hidden") == true){
			// slide down animation
			new Effect.Scale(
				currentDrawer,
				100,
				{ 
				scaleX: false,
				scaleFrom: 0,
				duration: this.duration,
				scaleContent: false,
				transition: Effect.Transitions.sinoidal,
				scaleMode: { originalHeight: currentDrawer.rel },
				beforeStart: function(){
					currentDrawer.removeClassName("is_hidden");	
					currentTrigger.removeClassName("closed").addClassName("open");
				}
				}
			);			
			// modify accessibility label			
			currentTrigger.select("span.accessibility_label")[0].update("Click here to close drawer");							
			
		// if current drawer is visible
		} else {
			
			// focus on trigger when closing
			currentTrigger.select("a")[0].focus();
			// slide up animation
			new Effect.Scale(
				currentDrawer,
				0,
				{ 
				scaleX: false,
				scaleFrom: 100,
				duration: this.duration,
				scaleContent: false,
				transition: Effect.Transitions.sinoidal,
				scaleMode: { originalHeight: currentDrawer.rel },
				afterFinish: function(){
					currentTrigger.removeClassName("open").addClassName("closed");
					currentDrawer.addClassName("is_hidden");
				}
				}			
			);
			// modify accessibility label			
			currentTrigger.select("span.accessibility_label")[0].update("Click here to open drawer");			
		}
	}
}

/*****************************************************************************************
ScrollingRollover - Expand a scrolling div of content on click
*****************************************************************************************/

var ScrollingRollover = Class.create();

ScrollingRollover.prototype = {
	initialize: function(triggerSelector, drawerSelector, speed){		
		// variables
		this.trigger = $$(triggerSelector).first();
		this.drawer = $$(drawerSelector).first();
		this.duration = speed;
		
		// element check
		if (!this.trigger || !this.drawer){ return; }	
		
		// set hover on triggers for IE6
		if(GlobalUtils.IE6 == true){ GlobalUtils.ieHover(triggerSelector, "iehover"); }
	
		// collapse all by default
		this.collapseAll();
		
		// attach event handlers
		Event.observe(this.trigger, "click", this.slideAnim.bindAsEventListener(this));

	},
	collapseAll: function(){

		// add class name of closed on triggers
		this.trigger.removeClassName("open").addClassName("closed");

		// show drawers
		this.drawer.setStyle({
			height: "0px",
			overflow: "hidden",
			position: "relative"
		});
		this.drawer.addClassName("is_hidden");
	},
	slideAnim: function(e){
		var currentTrigger = Event.element(e).up("div.trigger") || Event.element(e);
		var currentDrawer = currentTrigger.up("div.slider").down("div.drawer");
		
		// if current drawer is hidden
		if(currentDrawer.hasClassName("is_hidden") == true){
			
			// slide down animation
			new Effect.Scale(
				currentDrawer,
				100,
				{ 
				scaleX: false,
				scaleFrom: 0,
				duration: this.duration,
				scaleContent: false,
				transition: Effect.Transitions.sinoidal,
				scaleMode: { originalHeight: 200 }
				}
			);
			currentTrigger.removeClassName("closed").addClassName("open");
			currentDrawer.removeClassName("is_hidden");
		
		// if current drawer is visible
		} else {
			// slide up animation
			new Effect.Scale(
				currentDrawer,
				0,
				{ 
				scaleX: false,
				scaleFrom: 100,
				duration: this.duration,
				scaleContent: false,
				transition: Effect.Transitions.sinoidal,
				scaleMode: { originalHeight: 200 }
				}			
			);
			currentTrigger.removeClassName("open").addClassName("closed");
			currentDrawer.addClassName("is_hidden");	
		}
	}
}



/************************************************************
PopTip - add simple tooltips to a page on mouseover or click.
************************************************************/

var PopTip = Class.create();

PopTip.prototype = {

	initialize: function(elTrigger, elTip, hPrefs){
		// element check
		if(!$$(elTrigger) || !$(elTip)){ return; }
		
		// preferences
		prefs = Object.extend({
			orientation: 'south', // prefer the tip element to be oriented North, South, East, or West
			xOffset: 0,
			yOffset: 0,
			minMargin: 0,
			triggerType: 'mouseover',
			mouseOverDelay: '1000',
			useCentering: false
		}, hPrefs || {});		
		
		// basic variables
		this.elTrigger = $$(elTrigger);
		this.elTip = $(elTip);
		this.tipOrientClass = prefs.orientation;
		
		// set up variable defaults
		this.timeOut = null;
		this.mousedIntoTrigger = false;
		this.mousedIntoTip = false;
		this.tipLeft;
		this.tipTop;
		this.elArrow = this.elTip.down('div.arrow') || false;
		if(this.elArrow){
			this.arrowTop = 0;
			this.arrowLeft = 0;
			this.arrowDim = this.elArrow.getDimensions();
		}		
		
		// attach event listener to close button if one exists
		this.elCloseBtn = this.elTip.down('a.close') || false;		
		if(this.elCloseBtn){
			Event.observe(this.elCloseBtn, "click", this.deactivate.bindAsEventListener(this));
		}
		
		// hide all tooltip content divs
		this.elTrigger.each(function(s){ $(s.rel).style.position = "absolute"; });
		
		// attach event listeners to all triggers
		// click event
		if (prefs.triggerType == "click") { 
			this.elTrigger.invoke("observe", "click", this.activate.bindAsEventListener(this));
		}
		//mouseover/out events
		if (prefs.triggerType == "mouseover") {	
			Event.observe(this.elTip, "mouseover", this.activate.bindAsEventListener(this));
			Event.observe(this.elTip, "mouseout", this.deactivate.bindAsEventListener(this));			
			this.elTrigger.invoke("observe", "mouseover", this.activate.bindAsEventListener(this));
			this.elTrigger.invoke("observe", "mouseout", this.deactivate.bindAsEventListener(this));
		}
	},
	
	activate: function(e) {
		
		//clear any previous timer
		clearTimeout(this.timeOut);		
			
		// get viewport dimensions and offset
		this.viewportDim = document.viewport.getDimensions();
		this.viewportOffset = document.viewport.getScrollOffsets();		
		
		// set variable for selected trigger
		var elTrigSelected = Event.element(e);
		
		// if the mouseover is on the tooltip or a descendant of the tooltip...
		if (elTrigSelected === this.elTip || elTrigSelected.descendantOf(this.elTip)){
			// set variable if you moused into tip
			this.mousedIntoTip = true;
		} else {
			// clear iFrame Shim - IE6
			GlobalUtils.iFrameShim('deactivate', this.elTip);	
			
			// set variable if you moused into trigger and run addTipContent function			
			this.timeOut = setTimeout(function(){
				this.mousedIntoTrigger = true;
				this.addTipContent(elTrigSelected);			
			}.bind(this), prefs.mouseOverDelay);			
		}		
	},
	
	deactivate: function(e) {

		//clear any previous timer
		clearTimeout(this.timeOut);
				
		var elTrigSelected = Event.element(e);
		
		// if you mouse out of the tooltip into a descendant of the tooltip...
		if (this.mousedIntoTip && (e.relatedTarget === this.elTip || e.relatedTarget.descendantOf(this.elTip))){			
			this.mousedIntoTip = false;
			return;
		}		
		
		// if you mouse out of the tooltip...
		if (this.mousedIntoTip && (!e.relatedTarget === this.elTip || !e.relatedTarget.descendantOf(this.elTip))){
			// call the deactivation timer
			this.activateTimer();
		}
		
		// if you mouse out of trigger into the the tooltip or a tooltip descendant...		
		if (this.mousedIntoTrigger && (e.relatedTarget === this.elTip || e.relatedTarget.descendantOf(this.elTip))){
			this.mousedIntoTrigger = false;
			return;
			}
		
		// if you mouse out of trigger...	
		if (this.mousedIntoTrigger && (e.relatedTarget != this.elTip || !e.relatedTarget.descendantOf(this.elTip))){
			// call the deactivation timer
			this.activateTimer();
		}		
	},
	
	activateTimer: function() {
	
		//clear any previous timer
		clearTimeout(this.timeOut);
		
		// set timer for deactivation
		this.timeOut = setTimeout(function(){
		
			// clear iFrame Shim - IE6
			GlobalUtils.iFrameShim('deactivate', this.elTip);
			
			// set both mousedInto variabled to false
			this.mousedIntoTip = false;
			this.mousedIntoTrigger = false;

			// positon tip off screen
			this.elTip.setStyle({left: '-50001px', top: '-50001px'});

			// return arrow to default position
			if(this.elArrow){this.elArrow.setStyle({left: '0px', top: '0px'});}
			
		}.bind(this), prefs.mouseOverDelay);	
	},
	
	addTipContent: function(elTrigSelected) {
		
		//clone the node that the trigger rel points to
		var contentCopy = $(elTrigSelected.rel).cloneNode(true);
		
		// remove trigger href
		$(elTrigSelected).removeAttribute("href");
		
		// set cloned node to be visible
		contentCopy.style.position = "static";
		
		// insert cloned node into tooltip content div
		this.elTip.select('div.content').reduce().update(contentCopy);
		
		// get dimensions of tip again with new content
		this.tipDim = this.elTip.getDimensions();

		// call position calculation function
		this.positionCalculation(elTrigSelected);
	},	
	
	positionCalculation: function(elTrigSelected){

		// set offset and dimension variables
		this.trigOffset = elTrigSelected.cumulativeOffset();
		this.trigDim = elTrigSelected.getDimensions();
		this.trigVpOffset = elTrigSelected.viewportOffset();
		
		// a bunch of confusing math for tip left/right orientation calculation
		switch(prefs.orientation){
			case 'north':
			case 'south':
				if(prefs.useCentering){
					this.tipLeft = (this.trigOffset.left + prefs.xOffset) - Math.ceil(this.tipDim.width/2 - this.trigDim.width/2);
				}
				else{
					this.tipLeft = this.trigOffset.left  + prefs.xOffset;
				}			
				if(this.tipLeft < (prefs.minMargin + prefs.xOffset)){ // too far to the left;
					this.tipLeft = prefs.minMargin + prefs.xOffset;
				}

				if((this.tipLeft + this.tipDim.width + prefs.minMargin) > (this.viewportDim.width + this.viewportOffset.left)){ // too far to the right
					this.tipLeft = (this.viewportDim.width + this.viewportOffset.left) - (this.tipDim.width + prefs.minMargin);
				}
				if (this.elArrow) {
					if(prefs.useCentering){
						this.arrowLeft = (this.trigOffset.left + Math.ceil(this.trigDim.width/2 - this.arrowDim.width/2)) - this.tipLeft;
					}
					else{
						this.arrowLeft = (this.trigOffset.left) - this.tipLeft;
					}
					if(this.arrowLeft < 0){// arrow is left of tip
						this.arrowLeft = 0;
					}
					else if((this.arrowLeft + this.arrowDim.width) > this.tipDim.width){// arrow is right of tip
						this.arrowLeft = this.tipDim.width - this.arrowDim.width;	
					}					
				}
				break;
			case 'east':
				this.tipLeft = this.trigOffset.left + this.trigDim.width + prefs.xOffset;
				if (this.elArrow) {this.arrowLeft = 0;}
				this.tipOrientClass = 'east';
				
				if((this.tipLeft + this.tipDim.width + prefs.minMargin) > this.viewportDim.width){// if too far to the right
					// put to the left
					this.tipLeft = this.trigOffset.left - this.tipDim.width - prefs.xOffset;
					if (this.elArrow) {this.arrowLeft = this.tipDim.width - this.arrowDim.width;}
					this.tipOrientClass = 'west';
				}
				break;
			case 'west':
				this.tipLeft = this.trigOffset.left - (prefs.xOffset + this.tipDim.width);
				if (this.elArrow) {this.arrowLeft = this.tipDim.width - this.arrowDim.width;}
				this.tipOrientClass = 'west';
				
				if(this.tipLeft < (prefs.minMargin + prefs.xOffset)){ // too far to the left;
					this.tipLeft = this.trigOffset.left + this.trigDim.width + prefs.xOffset;
					if (this.elArrow) {this.arrowLeft = 0;}
					this.tipOrientClass = 'east';
				}				
				break;
		}
		
		// a bunch of confusing math for tip up/down orientation calculation
		switch(prefs.orientation){
			case 'east':
			case 'west':
				if(prefs.useCentering){
					
					this.tipTop = (this.trigOffset.top - prefs.yOffset - (Math.ceil(this.tipDim.height/2 - this.trigDim.height/2)));
				}
				else{
					this.tipTop = (this.trigOffset.top - prefs.yOffset);
				}
				
				if(this.tipTop < (prefs.minMargin + this.viewportOffset.top)){ // too far above
					this.tipTop = this.viewportOffset.top + prefs.minMargin;
				}
				
				if((this.tipTop + this.tipDim.height) > (this.viewportDim.height + this.viewportOffset.top)){ // too far below
					this.tipTop -= (this.tipTop + this.tipDim.height + prefs.minMargin) - (this.viewportDim.height + this.viewportOffset.top);	
				}
				
				if (this.elArrow) {
					if(prefs.useCentering){
						this.arrowTop = (this.trigOffset.top - this.tipTop) + Math.ceil(this.trigDim.height/2 - this.arrowDim.height/2);
					}
					else{
						this.arrowTop = this.trigOffset.top - this.tipTop;
					}
					if(this.arrowTop < 0){// arrow is above tip
						this.arrowTop = 0;
					}
					else if((this.arrowTop + this.arrowDim.height) > this.tipDim.height){// arrow is below tip
						this.arrowTop = this.tipDim.height - this.arrowDim.height;				
					}
				}
				break;
				
			case 'north':
				this.tipTop = ((this.trigOffset.top - prefs.yOffset) - this.tipDim.height);
				if(this.elArrow){this.arrowTop = this.tipDim.height - this.arrowDim.height;}
				this.tipOrientClass = 'north';
					
				if(this.elArrow){this.arrowTop = this.tipDim.height - this.arrowDim.height;}				
				if((this.tipTop - prefs.minMargin) < this.viewportOffset.top){ // too far above
					this.tipTop = (this.trigOffset.top + prefs.yOffset + this.trigDim.height);
					if(this.elArrow){this.arrowTop = 0;}
					this.tipOrientClass = 'south';
				}
				break;
				
			case 'south':
				this.tipTop = (this.trigOffset.top + prefs.yOffset + this.trigDim.height);	
				if(this.elArrow){this.arrowTop = 0;}
				this.tipOrientClass = 'south';
				
				if((this.tipTop + prefs.minMargin + this.tipDim.height) > (this.viewportDim.height + this.viewportOffset.top)){ // too far below
					this.tipTop = ((this.trigOffset.top - prefs.yOffset) - this.tipDim.height);
					if(this.elArrow){this.arrowTop = this.tipDim.height - this.arrowDim.height;}
					this.tipOrientClass = 'north';
					
				}
				break;
		}
		this.positionTip();	
	},
	
	positionTip: function() {
		
		// remove orientation class set on the tip
		var scope = this; // scope for following ".each"		
		$w('north south east west').each(function(orient){
			scope.elTip.removeClassName(orient);
		});	

		// add orientation class to tip
		this.elTip.addClassName(this.tipOrientClass);
		

		// call iFrameShim function for IE6		
		GlobalUtils.iFrameShim('activate', this.elTip);

		
		// position tip
		this.elTip.setStyle({left: this.tipLeft+'px', top: this.tipTop+'px'});
		
		// position arrow
		if(this.elArrow){this.elArrow.setStyle({left: this.arrowLeft + 'px', top: this.arrowTop + 'px'});}
	}
}


/********************************************************************************************************
SWFObject v2.1 <http://code.google.com/p/swfobject/>
Copyright (c) 2007-2008 Geoff Stearns, Michael Williams, and Bobby van der Sluis
This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
********************************************************************************************************/
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();


/*************************************************
Dom Loader - Loads functions when the DOM is ready
*************************************************/
var DomLoader = {
	
	initialize: function(){
		// If safari keep polling ready state		
		if(/Safari/i.test(navigator.userAgent)){ 
			var _timer=setInterval(function(){
			if(/loaded|complete/.test(document.readyState)){					
					clearInterval(_timer);
					// call load function
					DomLoader.load();
				}
			}, 500);
		} else {
			// call load function
			this.load();
		}		
	},
	
	load: function(){
		
		/** Nojs Remover **/
		GlobalUtils.noJsRemover();
								
		/** Query String Decoder **/
		GlobalUtils.queryStringDecoder();
		
		/** Flash Background **/
		FlashBackground.initialize();
				
		/** Form Clearer **/
		FormClearer.initialize("sendfriend_form");
								
			
		/* Popups ***********************************************************/
		/* Example:															*/
		/*																	*/	
		/* var experiencedProfPop = new PopUpBox(							*/
		/* 	"ul#career_list li a", 					<-- links				*/
		/* 	"div.career_info_box" , 				<-- popup box container */
		/* 	"div.career_info_box div.back_to_top a"	<-- back to top link	*/
		/*  true									<-- dim background?	    */
		/*  true									<-- ajax?	   			*/
		/* ); 																*/
		/*																	*/		
		/********************************************************************/
		var experiencedProfPop = new PopUpBox(
			"ul#career_list li a", 					
			"div.career_info_box" , 				
			"div.career_info_box div.back_to_top a",
			false
		);	
		var pressRoomPopup = new PopUpBox(
			"ul#image_album li a", 					
			"div.photo_info_box" , 					
			"div.photo_info_box div.back_to_top a",
			false
		);
		var emailPopup = new PopUpBox(
			"ul#send_friend_link li a", 				
			"div.popup_box",
			"div.popup_box div.back_to_top a",
			false
		);
		var dreamInColorPopup = new PopUpBox(
			"div.dic-person a",
			"div.dic_popup",
			"div#dic_popups div.back_to_top a",
			true
		);
		var tcoePopups = new PopUpBox(
			"div#fundraising_slider a.ajax_popup",
			"div.popup_box",
			"div.popup_box div.back_to_top a",
			false,
			true
		);
		var interstitialPopup = new PopUpBox(
			"ul#interstitial_link li a", 				
			"div.popup_box",
			"div.popup_box div.back_to_top a",
			false,
			true
		);
										
		/* Dropdowns ********************************************************/
		/* Example:															*/
		/*																	*/	
		/* var careersDropdown = new DropDownNav(							*/
		/* 	".careers_select_nav", 			<-- css selector for container 	*/
		/* 	"View careers in...",			<-- default Text for Select List*/
		/* 	"btn_go", 						<-- class for button (optional)	*/
		/* 	"Go"							<-- text value for button		*/
		/* );																*/
		/*																	*/		
		/********************************************************************/
		var careersDropdown = new DropDownNav(
			".careers_select_nav", 								
			"Explore careers in...",								
			"btn_go", 	
			"Go"												
		);
		var statesDropdown = new DropDownNav(
			".state_select_nav", 								
			"Select a state",									
			"btn_go", 											
			"Go"												
		);
		var careersDropdownTwo = new DropDownNav(
			".link_dropdown", 									
			"Select Age Range",
			"btn_go", 											
			"Go"										
		);										
		var undergraduateDropDown = new DropDownNav(
			".undergraduate_select_nav",  							
			"Explore careers in...", 												
			"btn_go", 	
			"Go"												
		);
				
		/* Tooltips *********************************************************************/
		/* Example:																		*/
		/*																				*/	
		/* var helpTip = new PopTip(													*/
		/*     "a.investors_tooltip_link",  <-- trigger link							*/
		/* 	   "tooltip",					<-- tooltip id								*/
		/* 	   {																		*/
		/* 	   orientation: 'south', 		<-- orientation: north, south, east, west	*/
		/* 	   xOffset: -40,				<-- horizontal offset						*/
		/* 	   yOffset: -7,					<-- vertical offset							*/		
		/* 	   minMargin: 0,				<-- minimum margin							*/
		/* 	   triggerType: 'mouseover',	<-- trigger type: mouseover, click			*/	
		/* 	   mouseOverDelay: '1500'		<-- mouseover delay in milliseconds			*/
		/*     }																		*/
		/* );																			*/
		/*																				*/		
		/********************************************************************************/	
		var helpTip = new PopTip(
			"a.investors_tooltip_link", 
			"tooltip",
			{
			orientation: 'south', // prefer the tip element to be oriented North, South, East, or West
			xOffset: -140,
			yOffset: -7,
			minMargin: 0,
			triggerType: 'mouseover',
			mouseOverDelay: '500'
			}
		);	
		
		/* Copy URL Buttons *************************************************/
		/* Example:															*/
		/*																	*/	
		/* var expProfBtn = new InputCopier(								*/ 
		/* 	"experienced_rss_url",		<-- field to copy					*/
		/* 	"btn_medium btn_copy_url",	<-- button classes					*/ 
		/* 	"Copy URL"					<-- button text						*/
		/* )																*/
		/*																	*/		
		/********************************************************************/
		var expProfBtn = new InputCopier(
			"experienced_rss_url",
			"btn_medium btn_copy_url",
			"Copy URL"
		);
		var recGradBtn = new InputCopier(
			"graduates_rss_url",
			"btn_medium btn_copy_url",
			"Copy URL"
		);
				
		/* List Slider ******************************************************/
		/* Example:															*/
		/*																	*/	
		/* var careerAreas = new ListSlider(								*/
		/*     "div#slider_list div.header div.content",  <-- list header	*/
		/* 	    "div#slider_list div.slider div.trigger", <-- list triggers	*/
		/* 	    "div#slider_list div.slider div.drawer",  <-- list drawers	*/
		/* 	    "0.75"									  <-- speed			*/
		/*		"lorem ipsum dolor sit amet."			  <-- intro <p>		*/
		/* );																*/
		/*																	*/		
		/********************************************************************/	
		var careerAreas = new ListSlider(
			"div#career_slider div.header div.content",
			"div#career_slider div.slider div.trigger", 
			"div#career_slider div.slider div.drawer",
			"0.75",
			"Click on a career area to see example roles and skills we&rsquo;re looking for, or  "
		);
			
		var JobAreas = new ListSlider(
			"div#job_slider div.header div.content",
			"div#job_slider div.slider div.trigger", 
			"div#job_slider div.slider div.drawer",
			"0.75",
			"Click on a job area to see example roles and skills we&rsquo;re looking for, or  "
		);	
	
		var InternAreas = new ListSlider(
			"div#intern_slider div.header div.content",
			"div#intern_slider div.slider div.trigger", 
			"div#intern_slider div.slider div.drawer",
			"0.75",
			"Click on the locations below to learn about various types of internships, or  "
		);
	
		var Timeline = new ListSlider(
			"div#timeline_slider div.header div.content",
			"div#timeline_slider div.slider div.trigger", 
			"div#timeline_slider div.slider div.drawer",
			"0.75",
			"Click on a time period to see how Target has evolved through the years, or  "
		);	
			
		var Timeline = new ListSlider(
			"",
			"div#fundraising_slider div.slider div.trigger", 
			"div#fundraising_slider div.slider div.drawer",
			"0.75"
		);	
		
		/* Scrolling Rollover ***********************************************/
		/* Example:															*/
		/*																	*/	
		/* var InvestorsRollover = new ListSlider(							*/
		/* 	    "div#slider_list div.slider div.trigger", <-- list triggers	*/
		/* 	    "div#slider_list div.slider div.drawer",  <-- list drawers	*/
		/* 	    "0.75"									  <-- speed			*/
		/* );																*/
		/*																	*/		
		/********************************************************************/		
		var InvestorsRollover = new ScrollingRollover(
			"div#investors_slider div.slider div.trigger", 
			"div#investors_slider div.slider div.drawer",
			"0.75"	
		);
			
		var TcoeSlider = new ScrollingRollover(
			"div#tcoe_slider div.slider div.trigger", 
			"div#tcoe_slider div.slider div.drawer",
			"0.75"	
		);
				
		/* SWFObject Embeds *************************************************************/
		/* Example:																		*/
		/*	swfobject.embedSWF(															*/
		/* 		"../flash/company/home/homepage.swf", 		<-- swf to embed			*/
		/* 		"flash_content", 							<-- container ID			*/
		/* 		"100%", 									<-- width					*/
		/* 		"407", 										<-- height					*/
		/* 		"8.0.0", 									<-- flash version			*/
		/* 		"../flash/company/home/expressInstall.swf", <-- express install			*/
		/* 		flashvars, 									<-- {} of flash vars		*/
		/* 		params, 									<-- {} of flash params		*/
		/* 		attributes									<-- {} of flash attributes	*/
		/* 	);																			*/
		/* 																				*/
		/*																				*/			
		/********************************************************************************/
		swfobject.embedSWF(
			"../../../images/company/flash/careers/msm_overview.swf", 
			"careers_overview", 
			"654", 
			"290", 
			"8.0.0", 
			"../../../images/company/flash/global/expressInstall.swf", 
			{
			xmlFile: "../../../images/company/flash/careers/xml/msm_overview.xml",
			swfPath: "../../../images/company/flash/careers/"
			},
			{
			allowScriptAccess: "always",				
			menu: "false",
			scale: "noscale",
			wmode: "opaque"
			},
			{id: "none"}
		);
		
		swfobject.embedSWF(
			"../../../images/company/flash/our_company/msm_overview.swf", 
			"our_company_overview", 
			"654", 
			"290", 
			"8.0.0", 
			"../../../images/company/flash/global/expressInstall.swf", 
			{
			xmlFile: "../../../images/company/flash/our_company/xml/msm_overview.xml",
			swfPath: "../../../images/company/flash/our_company/"
			},
			{
			allowScriptAccess: "always",				
			menu: "false",
			scale: "noscale",
			wmode: "opaque"
			},
			{id: "none"}
		);
		
		// /* SOMPOO Videos */
		// /* Jerome Hearn*/
		// swfobject.embedSWF(
		// 	"http://sites.target.com/images/corporate/diversity/videos/0108/detroit.swf", 
		// 	"jerome_hearn", 
		// 	"193", 
		// 	"191", 
		// 	"6.0.0",
		// 	"/target/corporate/flash/company/global/expressInstall.swf", 
		// 	{},
		// 	{
		// 	allowScriptAccess: "always",				
		// 	bgcolor: "#F9F9F9"
		// 	},
		// 	{id: "none"}
		// );
		// 
		// /* Angela White Smith */
		// swfobject.embedSWF(
		// 	"http://sites.target.com/images/corporate/diversity/videos/0108/tfs.swf", 
		// 	"angela_white_smith", 
		// 	"193", 
		// 	"191", 
		// 	"6.0.0",
		// 	"/target/corporate/flash/company/global/expressInstall.swf", 
		// 	{},
		// 	{
		// 	allowScriptAccess: "always",				
		// 	bgcolor: "#F9F9F9"
		// 	},
		// 	{id: "none"}
		// );	
		// 
		// /* Angel Baul */
		// swfobject.embedSWF(
		// 	"http://sites.target.com/images/corporate/diversity/videos/0108/tts.swf", 
		// 	"angel_baul", 
		// 	"193", 
		// 	"191", 
		// 	"6.0.0",
		// 	"/target/corporate/flash/company/global/expressInstall.swf", 
		// 	{},
		// 	{
		// 	allowScriptAccess: "always",				
		// 	bgcolor: "#F9F9F9"
		// 	},
		// 	{id: "none"}
		// );	
		// 	
		// /* Roberto Rodriguex */
		// swfobject.embedSWF(
		// 	"http://sites.target.com/images/corporate/diversity/videos/0108/suffolk.swf", 
		// 	"roberto_rodriguez", 
		// 	"193", 
		// 	"191", 
		// 	"6.0.0",
		// 	"/target/corporate/flash/company/global/expressInstall.swf", 
		// 	{},
		// 	{
		// 	allowScriptAccess: "always",				
		// 	bgcolor: "#F9F9F9"
		// 	},
		// 	{id: "none"}
		// );		
		// 	
		// /* Danielle Welsh */
		// swfobject.embedSWF(
		// 	"http://sites.target.com/images/corporate/diversity/videos/0108/statenisland.swf", 
		// 	"danielle_welsh", 
		// 	"193", 
		// 	"191", 
		// 	"6.0.0",
		// 	"/target/corporate/flash/company/global/expressInstall.swf", 
		// 	{},
		// 	{
		// 	allowScriptAccess: "always",				
		// 	bgcolor: "#F9F9F9"
		// 	},
		// 	{id: "none"}
		// );

	}
}

document.observe("dom:loaded", function(){
	DomLoader.initialize();
});

