function printPage() {
	if (window.print) { window.print(); }
}


/* newer OOP popup script - added 5/22/09 BF */

var POP_popup = Class.create();
POP_popup.prototype = {
    initialize: function() {
        var popup_class = $$('a.popmeup');
        // var target_blank = $$('a[target^=_blank])');
        popup_class.invoke('observe', 'click', this.__Click.bindAsEventListener(this));
        // target_blank.invoke('observe', 'click', this.__Click.bindAsEventListener(this));
    },

    __Click: function(e) {

        var el = Event.element(e);
        var url = el.readAttribute('href');

        // Does the element have a title? If so use that as the window name
        if (el.readAttribute('title')) {
            var windowName = escape(el.readAttribute('title'));
        }
        else {
            var windowName = "popup";
        }

        // Check for options set in the rel
        if (el.readAttribute('rel')) {
            var options = el.readAttribute('rel');
        }
        // if not use some default values
        else {
            var options = "width=800,height=600,location=yes,menubar=yes,status=yes,toolbar=yes,scrollbars=yes";
        }

        // Open window and give it focus
        var win = window.open(url, windowName, options);
        if (window.focus) {
            win.focus()
        }

        // Stop default browser event
        Event.stop(e);
    }
}	


if (document.getElementById) {


	// config:  pop-up defaults
	var popClass = 'popup';
	var popName	= 'popWin';
	var popPrefix = 'pup-';
	var popW	= 340;
	var popH	= 435;
	
	if (typeof rootVirtual == 'undefined') {
		var rootVirtual = '';
	}
	
	//	var As = document.getElementsByTagName('a');


	/**
	 * popupHandler();
	 * Pop-up window launch handler. Keys off of specified CSS class.
	*/
	function popupHandler() { 
		var cl=popClass.length;
		var a=document.getElementsByTagName('a');
		//	var a = As;
		for(var i=0; i<a.length; i++) { 
			var ca=document.getAttribute?a[i].getAttribute('class').split(' '):a[i].className.split(' ');
			if(ca[0]===popClass) { 
				a[i].onclick=function () { 
					var w = popW;  var h = popH; var s='';
					var ca2=document.getAttribute ? this.getAttribute('class').split(' ') : this.className.split(' ');
					for (var i=0; i<ca2.length; i++) {
						if (ca2[i].substring(0,popPrefix.length) === popPrefix) {
							var aaa = ca2[i].substring(popPrefix.length,ca2[1].length);
							c = aaa.split('_');
							for (var z=0; z<c.length; z++) {
								if (c[z].substring(0,1)=='w') { w = c[z].substring(1,c[z].length); }
								else if (c[z].substring(0,1)=='h') { h = c[z].substring(1,c[z].length); }
								else { s += c[z] +'=1,'; }
							}					
						}
					}
					var t=this.getAttribute('target')?this.getAttribute('target'):popName;
					popUp(this.getAttribute('href'),t,w,h,s);
					return false;
				}
			}
		}
	}
	
	/**
	* popUp();
	* Pop-up window launcher.
	*/
	function popUp(winURL,t,w,h,s){
		var specs='width='+w+',height='+h+',';
		if (s && s!='') { specs += s; }
		var scrX=Math.round((screen.width/2)-(w/2));
		var scrY=Math.round((screen.height/2)-(h/2));
		if(scrY>100){ scrY=scrY-40; }
		specs+='top='+scrY+',left='+scrX;
		var win=window.open(winURL,t,specs);
		win.focus();
	}

	
	$pop.event.add(window,'load',popupHandler);



	/**
	* _styleTables
	* Unobtrusive init-type handler for table-related functions.
	* Helps convert ALA's "Zebra Tables" to unobtrusive implementation keying off of CSS class applied to table.
	* @param stripeClass string CSS class name to key off of.  Defaults to "stripe"; override with a global var.
	*/
	function _styleTables() {
		if (typeof stripeClass == 'undefined' || stripeClass == '')  { var stripeClass = 'stripe'; }
		//	if (typeof fancyClass == 'undefined' || fancyClass == '')  { var fancyClass = 'fancy'; }
		var tables = document.getElementsByTagName('table');
		var tableId;
		for (i=0; i<tables.length; i++) {
			// collect table's CSS classes and explode into array
			var tc=document.getAttribute ? tables[i].getAttribute('class').split(' ') : tables[i].className.split(' ');
			for (ii=0; ii<tc.length; ii++) {
				// if we have an ID to hook onto...
				if (tableId = tables[i].getAttribute('id')) { 
					// ...test and then do stuff
					if (tc[ii] == stripeClass) 	{ tableStripe(tableId); }
					//	if (tc[ii] == fancyClass) 	{ tableFancy(tableId); }
				}
			} // end for: CSS array loop
		} // end for: loop thru tables 
	} // Ende
	




	// [ Table Striper ] ----------------------------------------
	/**
	* tableStripe
	* Dynamically shades alternating rows of a table. Adapted from ALA's "Zebra Tables".
	* @source http://www.alistapart.com/articles/zebratables/
	*/
	
	function hasClass(obj) {  // required work around for IE bug
	   var result = false;
	   if (obj.getAttributeNode('class') != null) {result = obj.getAttributeNode('class').value;}
	   return result;
	}
	
	function tableStripe(id) {
	  var table = document.getElementById(id);
	  if (! table) { return; }
	  var even = false;
	  var evenColor = arguments[1] ? arguments[1] : 'evenColor';
	  var oddColor = arguments[2] ? arguments[2] : 'oddColor';
	  var tbodies = table.getElementsByTagName('tbody');
	  for (var h = 0; h < tbodies.length; h++) {
	    var trs = tbodies[h].getElementsByTagName('tr');
	    for (var i = 0; i < trs.length; i++) {
		   if (!hasClass(trs[i]) && ! trs[i].style.backgroundColor) {
		        var tds = trs[i].getElementsByTagName('td');
		        for (var j = 0; j < tds.length; j++) {
					var mytd = tds[j];
					var classTmp;
					if (hasClass(mytd)) {
						// get extant class(es), add to it, stick it back on
						classTmp = document.getAttribute ? mytd.getAttribute('class') : mytd.className;
						classTmp += even ? ' '+ evenColor : ' '+ oddColor;
						switch(document.setAttribute) {
							case 'true':
								mytd.setAttribute('class', classTmp);
								break;
							case 'false':
								mytd.className = classTmp; 
								break;
							default:
								mytd.className = classTmp; 
						} // end switch
						
					} else {
						mytd.className = even ? evenColor : oddColor
					}
					
			  	} // end for: tds
			} // end if: hasClass
	      even =  ! even;
		  
		} // end for: trs
	 } // end for: tbodies
			
	
	} // end func
	
	$pop.event.add(window,'load',_styleTables);
	
	// -- end table striper -------------------




// ===================================================================================================

	// POP UP - LEGACY ONLY -- DO NOT USE!
	// usage: popuplink(['js-only url',] this[, w[, h[, scroll[, extras]]]])
	// basic usage: <a href="popup.html" target="_blank" onclick="return(popuplink(this));">new pop</a>
	// advanced usage: <a href="popup_nojs.html" target="_blank" onclick="return(popuplink('popup_yesjs.html', this, 200, 100, false));">new pop</a>
	// site-wide defaults:
	POPUP_W = 400;
	POPUP_H = 300;
	POPUP_SCROLL = true;
	POPUP_EXTRAS = 'location=0,statusbar=0,menubar=0';
	function popuplink() {
		var undef, i=0, args=popuplink.arguments;
		var url = (typeof(args[i])=='string') ? args[i++] : args[i].getAttribute('href');
		var target = args[i++].getAttribute('target') || '_blank';
		var w = args[i++];
		var h = args[i++];
		var s = (args[i]===undef) ? POPUP_SCROLL : args[i++];
		var features = 'width=' + (w || POPUP_W)
					 + ',height=' + (h || POPUP_H)
					 + ',scrollbars=' + (s ? 'yes,' : 'no,')
					 + (args[i] || POPUP_EXTRAS);
		var win = window.open(url, target, features);
		win.focus();
		return false;
	}
	// END POP UP
	
	
	
	
	function SwapGiftInput(checkBox, divName) {
		if (checkBox.checked) {
			document.getElementById(divName).style.display = '';
		}
		else {
			document.getElementById(divName).style.display = 'none';
		}
	}
	
	function AdjustCompleteYouthVisibility(value)
	{
		var trCompleteYouth = document.getElementById('tr_Discounted Youth Packa');

		if (trCompleteYouth)
		{
			if (value == '11 Play')
			{
				trCompleteYouth.style.visibility = "visible";
			}
			else
			{
				trCompleteYouth.style.visibility = "hidden";
				
				var selCompleteYouth = document.getElementById('sel_Discounted Youth Packa');
				
				if (selCompleteYouth)
				{
					selCompleteYouth.selectedIndex = 0;
				}
			}
		}
	}
	
	/*
		Selects or clears the value of textbox if the radio selection matches a desired value.
	*/
	function SwapRadioOther(radioButton, textBox, keepItValue) 
	{
		try
		{
			if (radioButton.value == keepItValue) 
			{
				document.getElementById(textBox).focus();
			}
			else 
			{
				document.getElementById(textBox).value = '';
			}
			
			ShowRecognitionInput(radioButton.value);
		}
		catch (ex)
		{}
	}
	
	/*
		Selects a certain radio option.
	*/
	function SwapOtherRadio(radioPrefix, radioValue) 
	{
		try
		{
			radioItem = document.getElementById(radioPrefix + radioValue);
			
			radioItem.checked = true;
		}
		catch (ex) 
		{}
	}

	/*
		Shows a certain html element if a value is at least a minimum value.
	*/
	function ShowRecognitionInput(donationValue) 
	{
		// minDonationValue, inputDisplay and clearRadio are defined inline by the controls that render them
		// if they don't exist, its no big deal.
		try
		{
			if (-11111 < donationValue)
			{		
				if (donationValue >= minDonationValue)
				{
					document.getElementById(inputDisplay).style.display = "";
				}
				else
				{
					document.getElementById(inputDisplay).style.display = "none";
				}
				
				document.getElementById(clearRadio).checked = false;
			}
		}
		catch (ex) 
		{}
	}
	
	/**
	 * Manages the display of items associated with specific checkboxes. The state of the content
	 * element will always match the state of the checkbox
	 * Usage:
	 *  checkBoxContentToggler.add('cb_Securities','fs_Securities');
	 *  checkBoxContentToggler.add('cb_Gift','fs_Gift');
	 *  checkBoxContentToggler.add('cb_Honor','fs_Honor');
	 *  checkBoxContentToggler.add('cb_instalments','fs_instalmentsInner');
	 */
	var checkBoxContentToggler = {
	    _registry: {},
	    
	    /**
	     * Add a checkbox, content element pair to be toggled together
	     * @param {String} sCheckBoxId The id of the Checkbox
	     * @param {String} sElementId The id of the associated content element
	     * @param {bool} bInvert If the element should be the opposite of the state of the checkbox or not
	     * @return void
	     */
	    add: function(sCheckBoxId, sElementId, bInvert) 
	    {
	        bInvert = (bInvert == 'undefined') ? false : bInvert ;
	        var cb = $dom.getById(sCheckBoxId);
	        var el = $dom.getById(sElementId);
	        
	        if (!cb || !el) { return; }
	        
	        this._registry[cb.id] = {
	            el: el,
	            inverted: bInvert
	        }
	
	        $pop.event.add(cb,'click',this.__cb_Click, this);
	        
	        this.updateToggle(cb.id);
	    },
	    
	    __cb_Click: function(evt) {
	        var el = $pop.event.getTarget(evt);
	        this.updateToggle(el);
	    },
	    
	    /**
	     * Updates the state of the content element to match the checked state of the checkbox
	     * @param {String/DOMElement} mCheckBoxOrCheckBoxId The id of the Checkbox or the CheckBox element itself
	     * @return void
	     */
	    updateToggle: function(mCheckBoxOrCheckBoxId) {
	        var cb = (typeof mCheckBoxOrCheckBoxId == 'string') ? $dom.getById(mCheckBoxOrCheckBoxId) : mCheckBoxOrCheckBoxId ;
	        var state = (this._registry[cb.id].inverted) ? !cb.checked : cb.checked;
	        
	        this._registry[cb.id].el.style.display = (state) ? '' : 'none' ;
	    }
	}
	
// ---------------
} // modernity check, do not delete

/* ----------------------- */
// Redesign additions (4128)
/* ----------------------- */

/* Event Tracking Handler 	*/
/* (C) POP 2007, 2008	 	*/
/****************************/
function pop_trackEvent(oArgs) {
	// common params to all projects
	var _source = oArgs.source || document.location.pathname+document.location.search+document.location.hash;
	var _type = oArgs.type || 'pageview';	// used for branching/switching based on type, e.g. 'event'
	var _media = oArgs.media || 'js';		// flash, js, etc.
	var _object = oArgs.object || '';		// name of object. e.g. video player, slideshow
	var _action = oArgs.action || ''; 		// what is the activity, e.g. 'play', 'next'
	var _label = oArgs.label || '';			// title of element in question, e.g. 'Finding_Nemo', 'img_Dora'
	var _value = oArgs.value || '';			// dollar value or numerical/index value
	var _target = oArgs.target || '';		// destination uri/object
	
	// Project specific params
	//var _usertype = oArgs.usertype || '';

	// Customize sReport string formatting and params per project needs, and pass to Web Analytics tracking function
	//var sReport = encodeURI(_source + '/media='+_media+',/object='+_object+',/action='+_action+',/label='+_label+',/value='+_value+',/target='+_target);
	//var sReport = encodeURI('/_event'+_source+'/object='+_object+'/action='+_action+'/label='+_label);
	var sReport = encodeURI(document.location.pathname+'?utm_category='+_object+'&utm_action='+_action+'&utm_label='+_label);
	try{
		urchinTracker(sReport);
		// Only uncomment during debugging
		/*
		console.log("urchinTracker being called with: %s", sReport);
		console.dir(oArgs);
		*/
	}
	catch(e){}
}

// Sample usage:
// trackEvent({media:'flash', object:'free_player', action:'play', label:'finding_nemo', value: '200', target: '/movies/moviedetail.aspx?id=1772'});


var TabSwitcher = Class.create({
	initialize: function(aTabs, aContents, options) {
		this.options = Object.extend({
			callback: function(){}
		}, options || {});

		this.tabs = aTabs;
		this.contents = aContents;
		// Loop through each and attach a click handler
		for(var i=0; i<this.tabs.length; i++) {
			Event.observe(this.tabs[i], 'click', this.__Click.bindAsEventListener(this));
		}
		// Show the first content item
		this.show(0);
	},
	/**
	 * Show a specific content item
	 */
	show: function(iWhich) {
		for (var i=0; i<this.contents.length; i++) {
			if (i == iWhich) {					    
				$(this.contents[i]).show();
				$(this.tabs[i].parentNode).addClassName("on"); // turn on first li by default when page loads
				if (this.elementLi) {                          // if an li has been clicked
				    this.hideClassName();                     // turn of all other li's first
				    this.elementLi.addClassName("on");	      // then turn on specific li   
				}
			} else {
				$(this.contents[i]).hide();
				$(this.tabs[i].parentNode).removeClassName("on");
			}
		}
		this.options.callback();
	},
	
	hideClassName: function() {
	    var allLi = $$('.round_right ul li');
	    for (var i=0; i<allLi.length; i++) {
	        allLi[i].removeClassName("on");
	    }
	},
	
	/**
	 * Deal with a clicked link
	 */
	__Click: function(e) {
		var e = e || window.event;
		Event.stop(e);
		var element = Event.element(e);
		this.elementLi = Event.findElement(e, "LI");    // storing li relative to event
		for (var i=0; i<this.tabs.length; i++) {
			if (this.tabs[i] == element) {
				this.show(i);
				// track switch
				var anchorName = element.readAttribute('href').replace('#','');
				pop_trackEvent({"object": 'tab', "action": 'click', "label": anchorName});
				break;
			}
		}
	}
});


var TextareaMaxlength = Class.create (
{
    initialize: function(textarea, maxlength)
    {
        this.textarea = textarea;
        this.maxlength = maxlength;
        // attach event handlers
        Event.observe(this.textarea, 'keyup', this.__Key.bindAsEventListener(this));
    },

    __Key: function(e)
    {
        var e = e || window.event;
        Event.stop(e);
        var element = Event.element(e);
        this.enforce();
    },

    // Enforce textarea maxlength
    enforce: function()
    {
        if ($F(this.textarea).length >= this.maxlength)
        {
            this.textarea.value = $F(this.textarea).substring(0, this.maxlength);
        }
    }

});


var homeHover = {
    init: function() {        
        
        // watch mouseover on prod detail list items
        $$('li#top_left a img')[0].observe('mouseover', homeHover.displayToolTip.bindAsEventListener(homeHover));
        $$('li#bottom_left a img')[0].observe('mouseover', homeHover.displayToolTip.bindAsEventListener(homeHover));
        $$('li#bottom_right a img')[0].observe('mouseover', homeHover.displayToolTip.bindAsEventListener(homeHover));
        
        
        // watch mouseout on prod detail list items
        $$('li#top_left a img')[0].observe('mouseout', homeHover.checkToolTipDisplay.bindAsEventListener(homeHover));
        $$('li#bottom_left a img')[0].observe('mouseout', homeHover.checkToolTipDisplay.bindAsEventListener(homeHover));
        $$('li#bottom_right a img')[0].observe('mouseout', homeHover.checkToolTipDisplay.bindAsEventListener(homeHover));


    
        // watch mouseover/out on opened prod hover popups
        homeHover.allHoverItems = $$('div.home_hover');
        for(var i=0; i<homeHover.allHoverItems.length; i++) {
            $(homeHover.allHoverItems[i]).observe('mouseover', homeHover.toolTipHovered.bindAsEventListener(homeHover));
            $(homeHover.allHoverItems[i]).observe('mouseout', homeHover.hideAllToolTips.bindAsEventListener(homeHover));
        }
        
    },
    
    displayToolTip: function(e) {
        // display related production popup
        
        var e = e || window.event;
        var element = Event.element(e);    
    
        var elementAnchor = Event.findElement(e, "A");
        var elAlt = $(elementAnchor).readAttribute("REL");   
        var elNum = elAlt.charAt(elAlt.length- 1);            // get last character in alt tag

        try {
            $('div_pos' + elNum + 'Flyout').show();             // show that related div with that character, and open the child div
        } 
        catch(Error) 
        {
            return;
        }
    },
    
    toolTipHovered: function(e) {
       // force related production popup to stay open when hovered over
       
       var e = e || window.event;
       var element = Event.element(e); 
 
       var elementDiv = Event.findElement(e, "DIV.home_hover");
       elementDiv.show();        
       return;

    },
    
    checkToolTipDisplay: function(e) {   

        var element = Event.element(e); 
        
        for(var i=0; i<homeHover.allHoverItems.length; i++) {
            // only hide if the element is not a descendent of the tooltip
            if (element != homeHover.allHoverItems[i] && !(element.descendantOf(homeHover.allHoverItems[i]))) {
                homeHover.allHoverItems[i].hide(); 
            }
           
        }
  
    },
    
    hideAllToolTips: function() {           
        for(var i=0; i<homeHover.allHoverItems.length; i++) {
                homeHover.allHoverItems[i].hide(); 
        }
  
    }
    
}


/* firebugx.js */
// prevent errors from console calls to browsers that don't provide firebug's debugging console.
if (!window.console || !console.firebug) {
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
    "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

    window.console = {};
    for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() {}
}

// BetterInnerHTML v1.2, (C) OptimalWorks.net
function BetterInnerHTML(o,p,q){function r(a){var b;if(typeof DOMParser!="undefined")b=(new DOMParser()).parseFromString(a,"application/xml");else{var c=["MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XMLDOM"];for(var i=0;i<c.length&&!b;i++){try{b=new ActiveXObject(c[i]);b.loadXML(a)}catch(e){}}}return b}function s(a,b,c){a[b]=function(){return eval(c)}}function t(b,c,d){if(typeof d=="undefined")d=1;if(d>1){if(c.nodeType==1){var e=document.createElement(c.nodeName);var f={};for(var a=0,g=c.attributes.length;a<g;a++){var h=c.attributes[a].name,k=c.attributes[a].value,l=(h.substr(0,2)=="on");if(l)f[h]=k;else{switch(h){case"class":e.className=k;break;case"for":e.htmlFor=k;break;default:e.setAttribute(h,k)}}}b=b.appendChild(e);for(l in f)s(b,l,f[l])}else if(c.nodeType==3){var m=(c.nodeValue?c.nodeValue:"");var n=m.replace(/^\s*|\s*$/g,"");if(n.length<7||(n.indexOf("<!--")!=0&&n.indexOf("-->")!=(n.length-3)))b.appendChild(document.createTextNode(m))}}for(var i=0,j=c.childNodes.length;i<j;i++)t(b,c.childNodes[i],d+1)}p="<root>"+p+"</root>";var u=r(p);if(o&&u){if(q!=false)while(o.lastChild)o.removeChild(o.lastChild);t(o,u.documentElement)}}
