



	// CN: there are new separate js files for photo gallery, faq and sport pages; code that was here have been moved to the appropriate file

// CONSTANTS
var COOKIE_NAMES = { 
	COUNTRY: 'country',
	LANGUAGE: 'language',
	USE_VANCOUVER_TIME: 'useVancouverTime',
	SEARCH_QUERY: 'searchQuery',
	PHOTO_TERMS_ACCEPTED: 'acceptedTermsForPhotoDownload'
};
var DICTIONARY = {
	EN: { 
	  months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
		days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
		localTime: 'Local Time',
		vancouverTime: 'Vancouver Time',
		pacificTime: 'Pacific Time',
		switchTo: 'Switch to'
	},
	FR: {
		months: ['janvier', 'f&#233;vrier', 'mars', 'avril', 'mai', 'juin', 'juillet', 'ao&#251;t', 'septembre', 'octobre', 'novembre', 'd&#233;cembre'],
		days: ['Sunday', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'],
		localTime: 'Heure locale',
		vancouverTime: 'Heure du Vancouver',
		pacificTime: 'Heure du Pacifique',
		switchTo: 'Passage &#224;'
	}
};
var CURRENT_LANG;
var flashElements = [];

// NEW JQUERY FUNCTIONS
	jQuery.fn.delay = function(time,func){
		this.each(function(){ 
			setTimeout(func,time); 
		});
		return this;
	};

	jQuery.fn.alternateRowColors = function(){
		$('tbody tr.sortMe:odd', this).removeClass('even').addClass('odd');
		$('tbody tr.sortMe:even', this).removeClass('odd').addClass('even');
		return this;
	};

	jQuery.fn.log = function(msg){
		console.log("%s: %o", msg, this);
		return this;
	};

	jQuery.cookie = function(name, value, options) {
			if (typeof value != 'undefined') { // name and value given, set cookie
					options = options || {};
					if (value === null) {
							value = '';
							options.expires = -1;
					}
					var expires = '';
					if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
							var date;
							if (typeof options.expires == 'number') {
									date = new Date();
									date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
							} else {
									date = options.expires;
							}
							expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
					}
					// CAUTION: Needed to parenthesize options.path and options.domain
					// in the following expressions, otherwise they evaluate to undefined
					// in the packed version for some reason...
					var path = options.path ? '; path=' + (options.path) : '';
					var domain = options.domain ? '; domain=' + (options.domain) : '';
					var secure = options.secure ? '; secure' : '';
					document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
			} else { // only name given, get cookie
					var cookieValue = null;
					if (document.cookie && document.cookie != '') {
							var cookies = document.cookie.split(';');
							for (var i = 0; i < cookies.length; i++) {
									var cookie = jQuery.trim(cookies[i]);
									// Does this cookie string begin with the name we want?
									if (cookie.substring(0, name.length + 1) == (name + '=')) {
											cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
											break;
									}
							}
					}
					return cookieValue;
			}
	};
	
// OTHER METHOD EXTENSIONS
	Date.prototype.getFormattedTime = function() {
		var hours = this.getHours();
		//return ((hours == 0) ? '12' : (hours <= 12) ? hours : hours - 12) + ':' + ((this.getMinutes() < 10) ? '0' : '') + this.getMinutes() + ' ' + ((hours < 12) ? 'am' : 'pm');
		return hours + ((cmArr['lang'] == 'FR') ? ' h ' : ':') + ((this.getMinutes() < 10) ? '0' : '') + this.getMinutes();
	};
	
	Date.prototype.getFormattedDate = function(isShortMonth, addComma) {
		var month = CURRENT_LANG['months'][this.getMonth()];
		var mon = (month.substring(0, 3).indexOf('&') > -1) ? month.substring(0, 8) : month.substring(0, 3);
		if (cmArr['lang'] == 'FR') {
			return 'le ' + this.getDate() + ' ' + (isShortMonth ? mon : month);
		}
		else {
			return (isShortMonth ? mon : month) + ' ' + this.getDate() + (addComma ? ',' : '');
		}
	}

// ON LOAD FUNCTIONS
	$(function(){
						 
	  CURRENT_LANG = DICTIONARY[cmArr['lang']];
		
		// load flash elements
		for (var flashIndex = flashElements.length - 1; flashIndex >= 0; flashIndex--) {
			var flashObj = flashElements[flashIndex];
			var flashDiv = $('.' + flashObj.divId);
			if (flashDiv) {
				eval('var flashTags = AC_FL_RunContent_GenerateOnly("' + flashObj.arguments.join('","') + '")');
				flashDiv.append(flashTags);
			}
		}
		
		// create extra markup to display rounded corner boxes
		$('.boxItUp').wrapInner('<div class="bordRight"><div class="bordLeft"><div class="boxLining"></div></div></div>').append('<div class="topRight"><div class="topLeft"><!-- --></div></div><div class="bottomRight"><div class="bottomLeft"><!-- --></div></div>');

		// default actions if JS is enabled
			$('body').removeClass('noJs');
			$('.metaContent').remove();
			$('.accessBar ul').before('<p>This site is using enhanced visual functionalities that might affect your experience. <a href="#default" class="defaultBox">Restore default browser behaviors accross the website</a>.</p>');
			

			/*  =====>>> remettre apres le d?but de la torche
			
			var homeclass = Math.floor(Math.random()*16);
			var homeparaclass = Math.floor(Math.random()*5+19);
			if ($('#home .footerExtra2')) {$('#home .footerExtra2').addClass('footerExtraspe'+homeclass);}
			if ($('#home_para .footerExtra2')) {$('#home_para .footerExtra2').addClass('footerExtraspe'+homeparaclass);}
			
			=====> remove?
			var homeheaderclass = Math.floor(Math.random()*22);
			var homeheaderparaclass = Math.floor(Math.random()*6+30);
			if ($('#home .bodyExtra')) {$('#home .bodyExtra').addClass('bodyExtraSpe'+homeheaderclass);}
			if ($('#home_para .bodyExtra')) {$('#home_para .bodyExtra').addClass('bodyExtraSpe'+homeheaderparaclass);}
			
			*/
			
			
			
		// transform all <select> tags into custom dropdowns
			/*
			 * No longer done on load - now this is done by writing out the content ahead of time. load time reduced 50ms
			$('select').each(function(){
				var whichDrop = $(this).attr('id');
				var whichAction = $(this).attr('class');
				$(this).after('<div class="drpElement" onclick="getDropdown(\''+whichDrop+'\');return false;"><div class="drpSelect '+whichDrop+'" rel="'+whichAction+'"><div class="drpShowSelected"></div><ul class="'+whichDrop+'"></ul></div></div>');
				$(this).find('option').each(function(){
					var whichValue = $(this).attr('value');
					var whichId = whichValue.substring(0,3);
					var whichURL = whichValue.substring(4,whichValue.length);
					var whichPath = $(this).attr('rel');
					if(whichPath != undefined){
						var imageTag = '<img src="images/'+whichPath+'/'+whichURL+'.png" alt="'+$(this).text()+'" />';
					}else{
						var imageTag = '';
					}
					$('ul.'+whichDrop).append('<li><a id="'+whichDrop+whichId+'" href="'+whichURL+'" onclick="changeSelectedIndex(\''+whichDrop+'\',\''+whichPath+'\',\''+whichAction+'\',\''+whichId+'\',\''+whichURL+'\');">'+imageTag+$(this).text()+'</a></li>');
					if($(this).val() == $(this).parent().find('option:selected').val()){
						changeSelectedIndex(whichDrop,whichPath,'init',whichId,whichURL);
					}
				});
				$('#'+whichDrop).parent().find('input').remove();
				$('#'+whichDrop).remove();
			});
			*/

		// tab links
			$('.hTabs .hTabsExtra li:not(.active)').hover(function(){
				$(this).addClass('hover');
			},function(){
				$(this).removeClass('hover');
			});

		// pull down menu
      // for safari, store full width of flash elements
			/*if ($.browser.safari) {
				var flashContainers = $('object[classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000]').parent();
				flashContainers.css('overflow', 'hidden');
				flashContainers.attr('originalWidth', flashElements.width());
			}*/
			
			$('.pullDown').hover(function(){
				$(this).siblings('.pullDown').find('a.active').addClass('fadeOut');
				$(this).children('ul').each(function(){
					$('.subNavPlaceHolder').addClass('fadeOut');
					$(this).removeClass('accessAlt').prev('a').addClass('active');
					/*if ($.browser.safari) {
						flashContainers.width('1px');  // set width to 1px - Safari still shows flash
					}*/
				});
			},function(){
				$(this).parent().find('a.fadeOut').removeClass('fadeOut');
				$(this).children('ul').each(function(){
					$(this).addClass('accessAlt').prev('a').removeClass('active');
					$('.subNavPlaceHolder').removeClass('fadeOut');
					/*if ($.browser.safari) {
						flashContainers.width(flashContainers.attr('originalWidth'));
					}*/
				});
			});

		// show static menu when pulldown section is active
			var isFullWidth = ($('.col8', '#content').filter(function(){ return ($(this).width() > 629);}).length > 0);
			
			/*var cols = document.getElementById('content').firstChild.childNodes;
			var isFullWidth = false;
			for (var colIndex = cols.length - 1; colIndex >= 0; colIndex--) {
				if (cols[colIndex].offsetWidth > 629) {
					isFullWidth = true;
				}
			}*/
			
			if(!isFullWidth && $('.sub_spectatorGuide > a').hasClass('active')){
				$('.subNav').find('.sub_spectatorGuide > ul').removeClass('accessAlt').appendTo('.subNavPlaceHolder').parents('body').find('.sub_spectatorGuide > a').addClass('active');
			}
			if(!isFullWidth && $('.sub_moreInformation > a').hasClass('active')){
				$('.subNav').find('.sub_moreInformation > ul').removeClass('accessAlt').appendTo('.subNavPlaceHolder').find('ul').removeClass('accessAlt').parents('body').find('.sub_moreInformation > a').addClass('active');
			}
			
		// restore all custom dropdowns into their original <select> when the user clicks on an element with the class 'defaultBox'
			$('.defaultBox').click(function(){
				$('.drpSelect').each(function(){
					var whichAction = $(this).attr('rel');
					var whichDrop = $(this).attr('class');
					whichDrop = whichDrop.substring(14,whichDrop.length);
					$(this).parent('div.drpElement').before('<select id="drp_'+whichDrop+'" name="drp_'+whichDrop+'" class="'+whichAction+'"></select><input id="btn_'+whichDrop+'" type="submit" value="go" />');
					$(this).find('li a').each(function(){
						var whichURL = $(this).attr('href');
						var whichId = $(this).attr('id');
						whichId = whichId.substring(whichId.length-3,whichId.length);
						var whichValue = whichId+'_'+whichURL;
						if($(this).attr('class') == 'activeIndex'){
							$('select#drp_'+whichDrop).append('<option value="'+whichValue+'" selected="selected">'+$(this).text()+'</option>');
						}else{
							$('select#drp_'+whichDrop).append('<option value="'+whichValue+'">'+$(this).text()+'</option>');
						}
					});
					$(this).parent('div.drpElement').remove();
				});
			});

		// restore all custom dropdowns into their original <select> when the user clicks on an element with the class 'defaultBox'
			$('.moreEvents').click(function(){
				$(".moreEvents").toggleClass('openEvents');
				$(".searchUnit").toggleClass('accessAlt');
				return false;	
			});

		// table sorting
			$('table.sortable').each(function(){
				var $table = $(this);
				$table.alternateRowColors($table);
				$('th', $table).each(function(column){		
					var findSortKey;
					if ($(this).is('.sort-alpha')){
						findSortKey = function($cell){
							return $cell.find('.sort-key').text().toUpperCase() + ' ' + $cell.text().toUpperCase();
						};
					}
					else if ($(this).is('.sort-numeric')){
						findSortKey = function($cell){
							var key = parseFloat($cell.text().replace(/:/g,''));
							return isNaN(key) ? 0 : key;
						};
					}
					if ($(this).is('.sort-image')){
						findSortKey = function($cell){
							return $cell.find('a').attr('title').toUpperCase();
						};
					}
					if (findSortKey){
						$(this).addClass('clickable').hover(function(){
							$(this).addClass('hover');
						}, function(){
							$(this).removeClass('hover');
						}).click(function(){
							var $myCell = $(this).attr('id');
							if($table.hasClass('reverse')){
								var newDirection = -1;
							}else{
								var newDirection = 1;
							}
							if ($(this).is('.sorted-asc')){
								newDirection = -1;
							}
							if ($(this).is('.sorted-desc')){
								newDirection = 1;
							}
							var rows = $table.find('tbody > tr.sortMe').get();
							$.each(rows, function(index, row){
								row.sortKey = findSortKey($(row).children('td.'+$myCell));
							});
							rows.sort(function(a, b){
								if (a.sortKey < b.sortKey) return -newDirection;
								if (a.sortKey > b.sortKey) return newDirection;
								return 0;
							});
							$.each(rows, function(index, row){
								$table.children('tbody').append(row);
								row.sortKey = null;
								var myId = $(row).attr('id');
								myId = myId.substring(4,myId.length);
								var myRow = $('#atl_'+myId);
								var myDetails = $('#atlDetails_'+myId);
								var myClass = myDetails.attr('class');
								var myContent = '<tr id="atlDetails_'+myId+'" class="'+myClass+' ">'+myDetails.html()+'</tr>';
								if(myDetails.html()!=null) {$(myRow).after(myContent);}
								myDetails.remove();
							});
							$table.find('th').removeClass('sorted-asc').removeClass('sorted-desc');
							var $sortHead = $table.find('th#'+$myCell);
							if (newDirection == 1){
								$sortHead.addClass('sorted-asc');
							}else{
								$sortHead.addClass('sorted-desc');
							}
							$table.find('td.'+$myCell).removeClass('sorted').addClass('sorted');
							$table.alternateRowColors($table);
						});
					}
				});

			});
			
			setSliderHeight();

		//set the first item active in htabSlider
			$('.hTabSlider').each(function(){
				$(this).find('.tabSlider .tabItem').addClass('tabOff');
				$(this).find('.tabSlider .tabItem:first').addClass('tabCurrent');
			});
			
		// language cookie - disabled
		/*	$('#languageSelect').click(function(){
			  $.cookie(COOKIE_NAMES.LANGUAGE, ((this.innerHTML == 'English') ? 'en' : 'fr'), { expires: getCookieExpiresDate() });
			});*/
			

		// country select cookie
			$('#drp_flag_js a').click(function(){
			  $.cookie(COOKIE_NAMES.COUNTRY, encodeURI($.trim($(this).text())), { expires: getCookieExpiresDate() });
			});
			
		// date and time conversion
		//convertTimes($('.datetime'), true);
		$('.timeSwitch').click(function() {
			setTimeCookie($.cookie(COOKIE_NAMES.USE_VANCOUVER_TIME) != 'true');
			convertTimes($('.datetime'), true);
			return false;
		});
		
		// torch countdown
		if ($('#torchCountdownDays')) {
			var gamesStart = new Date(2010, 1, 12, 18, 0);
			gamesStart.setHours(gamesStart.getHours() - getLocalTimeAdjust(gamesStart));
			var countdownDays = Math.ceil((gamesStart.getTime() - (new Date()).getTime()) / (1000 * 60 * 60 * 24));
			$('#torchCountdownDays').html(countdownDays + ' ' + ($.cookie(COOKIE_NAMES.LANGUAGE) == 'fr' ? 'Jour' : 'Day') + (countdownDays > 1 ? 's' : ''));
		}
		
		// login link
		if (isLoggedIn()) {
			$('#login').css('display', 'none');
			$('#manageProfile').css('display', 'inline');
			$('#loginLinks').css('display', 'inline');
		}
		else {
			$('#manageProfile').css('display', 'none');
			$('#login').css('display', 'inline');
			$('#loginLinks').css('display', 'inline');
		}
		
		// mousewheel scrolling
		/*$('.lfContentScroll .lfContentScrollContainer').mousewheel(function(event, delta) {
			var way = delta > 0 ? 'top' : 'bottom';
			slidelfContent2(way, $(this).parents('.lfContentScroll').parent()[0].className.split(' ')[0], true)
			return false;
		});*/

	});

// FUNCTIONS

function getCookieExpiresDate() {
	var expires = new Date();
	expires.setTime(expires.getTime() + (1000 * 24 * 60 * 60 * 1000));
	return expires.toUTCString();
}

function updateTorch(data)
{
	if (cmArr['lang'] == 'FR')
	{
		$('#lfbodyPrevFR').html(data.bodyPrevFR);
		$('#lfbodyFR').html(data.bodyFR);
		$('#lftitleFR').html(data.titleFR);
	}
	else
	{
		$('#lfbodyPrev').html(data.bodyPrev);
		$('#lfbody').html(data.body);
		$('#lftitle').html(data.title);
	}
	var e = $('#daysLeft'); 
	e.prepend(data.daysLeft + ' ');
	e.removeClass('hidden');
}
/*
var flagSlinding=false;
function showSelectList(selectList) {
	// hide any currently shown list
	if(slideAnim!=false) {

		var visibleDrop = $('div.drpSelect > div.FlagSlider:visible');
		var visibleClass = visibleDrop.attr('class');
		if (visibleDrop.length){
			visibleDrop.fadeOut(150);
		}
		
		// show new list
		var optionList = $('div.FlagSlider', selectList);
		if (optionList.attr('class') != visibleClass){
			optionList.fadeIn(50);
			$(selectList).bind('mouseleave',function(){
				$(this).delay(100,function(){
					optionList.fadeOut(150);
				});
			});
		}
	
	}
	
}

function changeSelected(thisOption, formValue) {
	var optionList = thisOption.parentNode.parentNode;
	var selectElement = optionList.parentNode;
	var currentSelected = $('.drpShowSelected');
	// take any image in this option and apply it as background to the show-selected area
	if ($('img', thisOption).length > 0) {
		var imgUrl = $('img', thisOption)[0].src;
		currentSelected.css( { backgroundImage: 'url(' + imgUrl + ')' } );
	}
	
	// copy text of this option to the show-selected area
	currentSelected.html(thisOption.innerHTML);
	
	// turn off old selected option
	$('.activeIndex', optionList).removeClass('activeIndex');
	
	// turn on this option
	$(thisOption).addClass('activeIndex');
	
	// if a form value is included, write it to the matching form field
	if (formValue) {
		var formField = $('#' + optionList.className)[0];
		if (formField.nodeName.toLowerCase() == 'select') {
			$('option[value=' + formValue + ']', formField)[0].selected = true;
		}
		else if (formField.nodeName.toLowerCase() == 'input') {
			$('#' + optionList.className).val(formValue);
		}
	}
	
	// load new page is needed
	if (selectElement.getAttribute('rel') == 'external') {
	  window.location.href = thisOption.href;
	}
	return false;
}*/

function showSelectList(selectList) {
	
	// hide any currently shown list
	var visibleDrop = $('div.drpSelect > ul:visible');
	var visibleClass = visibleDrop.attr('class');
	if (visibleDrop.length){
		visibleDrop.fadeOut(150);
	}
	
	// show new list
	var optionList = $('ul', selectList).parent();
	if (optionList.attr('class') != visibleClass){
		optionList.fadeIn(150);
		$(selectList).bind('mouseleave',function(){
			$(this).delay(100,function(){
				optionList.fadeOut(150);
			});
		});
	}
	
	// show scrollbar if needed
	if ($('ul', optionList).height() > 500) {
		$('.drpListScrollNav', selectList).css('display', 'block');
		optionList.height(200).css('overflow', 'hidden');
		$('ul', optionList).css( { position: 'absolute', top: 0 } );
	}
}

function changeSelected(thisOption, formValue) {
	var optionList = thisOption.parentNode.parentNode;
	var selectElement = optionList.parentNode.parentNode;
	var currentSelected = $('.drpShowSelected', selectElement);
	
	// take any image in this option and apply it as background to the show-selected area
	if ($('img', thisOption).length > 0) {
		var imgUrl = $('img', thisOption)[0].src;
		currentSelected.css( { backgroundImage: 'url(' + imgUrl + ')' } );
	}
	
	// copy text of this option to the show-selected area
	currentSelected.html(thisOption.innerHTML);
	
	// turn off old selected option
	$('.activeIndex', optionList).removeClass('activeIndex');
	
	// turn on this option
	$(thisOption).addClass('activeIndex');
	
	// if a form value is included, write it to the matching form field
	if (formValue) {
		var formField = $('#' + optionList.className)[0];
		if (formField.nodeName.toLowerCase() == 'select') {
			$('option[value=' + formValue + ']', formField)[0].selected = true;
		}
		else if (formField.nodeName.toLowerCase() == 'input') {
			$('#' + optionList.className).val(formValue);
		}
	}
	
	// load new page is needed
	if (selectElement.getAttribute('rel') == 'external') {
	  window.location.href = thisOption.href;
	}
	
	return false;
}

function slideDrpList(direction, content) {
	var parent = content.parent();
	var currentTop = parseInt(content.css('top'));
	var scrollDistance = parent.height();
	if (((direction == '1' && currentTop < 0) || (direction == '-1' && (content.height() + currentTop) >= scrollDistance)) && scrollAnim){
		scrollAnim = false;
		content.animate( { top: (currentTop + (scrollDistance * direction)) }, 400 );
		setTimeout("scrollAnim = true;",450);
	}
}

  function switchUrl(url){
		if(url != 'linkGoesHere'){
			top.window.location.href =url;
		}else{
			alert('This link "'+url+'" doesn\'t seem to be right.');
		}
	}

	var slideAnim = true;
	function slideTabContent(way, object) {
		if (slideAnim) {
			slideAnim = false;
			
			// no object? assume sports Event Info / Records / etc slider
			var parent = (object) ? $(object).parents('.hTabSlider') : $('.hTabSlider');
			parent.children('.tabContainer').each(function(){
				if($(this).hasClass("hidden")==false) {
					var tabContainer = $(this);
					//var tabContainer = parent.children('.tabContainer');
					var tabSlider = tabContainer.children('.tabSlider');
					var activeTab = tabSlider.children('.tabCurrent');			
					var activeWidth = activeTab.width();
					var top = tabContainer.css('top');
					top = (top) ? Number(top.replace(/px/, "")) + 1 : 35;
					var top2 = tabSlider.css('margin-top');
					top2 = (top2) ? Number(top2.replace(/px/, "")) : 0;
					var top3 = tabSlider.css('margin-bottom');
					top3 = (top3) ? Number(top3.replace(/px/, "")) : 0;
					top=top+top2+top3;
					
					
					if (way == 'left') {
						activeWidth = -activeWidth;  // backward animation
						newTab = activeTab.prev('.tabSlider .tabItem');
						if (newTab.html() == null) {
							newTab = tabSlider.children('.tabItem:last');
						}
					}
					else {
						newTab = activeTab.next('.tabSlider .tabItem');
						if (newTab.html() == null) {
							newTab = tabSlider.children('.tabItem:first');
						}
					}
					
					var tabHeight = newTab.height() + top;
					newTab.css( {left: activeWidth, top: 0} );
					activeTab.animate( {left: -activeWidth}, 400);
					newTab.animate( {left: 0}, 400);
					newTab.delay(400, function() {
						activeTab.removeClass('tabCurrent');
						newTab.addClass('tabCurrent');
					});
		
					parent.removeClass('tabClosed');
					parent.children('.tabContainerToggle').removeClass('tabContainerToggleExpand');
					parent.animate( {height: tabHeight} );
					setTimeout("slideAnim = true;",450);
				}
			});
		}
	}
	
	
	/*function slideFlagTabContent(way, object) {
		if (slideAnim) {
			slideAnim = false;
			// no object? assume sports Event Info / Records / etc slider
			var parent = (object) ? $(object).parents('.hTabSlider') : $('.hTabSlider');
			var tabContainer = parent.children('.tabContainer');
			var tabSlider = tabContainer.children('.tabSlider');
			var activeTab = tabSlider.children('.tabCurrent');			
			var activeHeight = activeTab.height();
			
			if (way == 'bottom') {
				activeHeight = -activeHeight;  // backward animation
				newTab = activeTab.prev('.tabSlider .tabItem');
				if (newTab.html() == null) {
					newTab = tabSlider.children('.tabItem:last');
				}
			}
			else {
				newTab = activeTab.next('.tabSlider .tabItem');
				if (newTab.html() == null) {
					newTab = tabSlider.children('.tabItem:first');
				}
			}
			
			newTab.css( {top: activeHeight} );
			activeTab.animate( {top: -activeHeight}, 400);
			newTab.animate( {top: 0}, 400);
			newTab.delay(400, function() {
				activeTab.removeClass('tabCurrent');
				newTab.addClass('tabCurrent');
			});

      parent.removeClass('tabClosed');
			parent.children('.tabContainerToggle').removeClass('tabContainerToggleExpand');
			setTimeout("slideAnim = true;",450);
		}	
	}*/

	/*
	function slideTabContent(way){
		if(slideAnim){
			slideAnim = false;
			var $el = $('.hTabSlider .tabItem');
			var $quantity = $el.size();
			var $width = $el.width();
			var maxLeft = 0;
			var maxRight = eval('-'+($quantity-1)*$width);
			var leftPos = $('.hTabSlider .tabSlider').css('left');
			leftPos = leftPos.substring(leftPos,leftPos.length-2);
			if(way == 'right'){
				if(leftPos > maxRight){
					leftPos = eval(leftPos)-$width;
				}else{
					leftPos = 0;
				}
			}
			if(way == 'left'){
				if(leftPos < maxLeft){
					leftPos = eval(leftPos)+$width;
				}else{
					leftPos = maxRight;
				}
			}
			$('.hTabSlider .tabSlider').animate({left:leftPos+'px'},400);
			$('.hTabSlider').removeClass('tabClosed');
			$('.tabContainerToggle').removeClass('tabContainerToggleExpand');
			setSlider(way, maxLeft, maxRight, leftPos);
			setTimeout("slideAnim = true;",450)
		}
	}
	*/

  // CN: not used? only reference to this function is in above commented-out function
	function setSlider(way, maxLeft, maxRight, leftPos){
		var tabHeight = $('.hTabSlider').height();
		var positiontabSlider = ($('.tabSlider').position());
		$('.hTabSlider .tabContainer .tabSlider .tabItem').each(function(){
			var positiontabItem = ($(this).position());
			if (positiontabSlider.left == -1*positiontabItem.left){
				if(way=='right'){
					if(leftPos == 0){
						tabHeight = 35 + $('.hTabSlider .tabContainer .tabSlider .tabItem:first').height();
					}else{
						tabHeight = 35 + $(this).next().height();
					}
				}else if(way=='left'){
					if(leftPos == maxRight){
						tabHeight = 35 + $('.hTabSlider .tabContainer .tabSlider .tabItem:last').height();
					}else{
						tabHeight = 35 + $(this).prev().height();
					}
				}
			}
		});
		$('.hTabSlider').css({height:tabHeight});
		
	}

	function setSliderHeight(){
		var tabHeight = 0;
		$('.col12 .hTabSlider .tabContainer .tabSlider .tabItem').each(function(){
			if($(this).height() > tabHeight){ 
				tabHeight = 35 + $(this).height();
			}
		});
		$('.col12 .hTabSlider').css({height:tabHeight});
	}

	function highlightMe(el){
		var $this = $("#" + el);
		var $w = $this.width();
		var $h = $this.height();
		var $offset = $this.offset();
		$this.parents('body').append('<div id="highLight" class="" style="position:absolute; left:'+$offset.left+'px; top:'+$offset.top+'px; width:'+$w+'px; height:'+$h+'px; background:url(\'images/common/bg_dataResultsHighlight.gif\') left top repeat-x; z-index:100000;"></div>');
		$('#highLight').animate({'opacity':0},1000).delay(1100,function(){
			$('#highLight').remove();
		});
	}

	function jqCheckAll( id, name, doCheck ){  // subscribe
	  $("div#" + id + " INPUT[@name=" + name + "][type='checkbox']").attr('checked', doCheck);
	}

var scrollAnim = true;

function slidelfContent(way, container, fullView){
	var container = container || '';
	if(scrollAnim){
		scrollAnim = false;
		var $items = $(container + '.lfContentScroll .lfContentScrollData');
		var $itemHeight = $items.height();
		var $totalHeight = 0;
		var $viewableHeight = $(container + '.lfContentScroll')[0].offsetHeight;
		//$items.each(function() { $totalHeight += this.offsetHeight; });
		lastItem = $items[$items.length - 1]
		$totalHeight = lastItem.offsetTop + lastItem.offsetHeight - $items[0].offsetTop;
		var maxTop = 0;
		var maxBottom = -$totalHeight + $(container + '.lfContentScroll')[0].offsetHeight;
		var topPos = parseInt($(container + '.lfContentScroll .lfContentScrollContainer').css('top'));
		if(way == 'bottom'){
			topPos = (topPos > maxBottom) ? (eval(topPos) - (fullView ? $viewableHeight - 20 : $itemHeight)) : 0;
		}
		if(way == 'top'){
			topPos = (topPos < maxTop) ? (eval(topPos) + (fullView ? $viewableHeight - 20 : $itemHeight)) : maxBottom;
		}
		$(container + '.lfContentScroll .lfContentScrollContainer').animate({top:topPos+'px'},400);
		setTimeout("scrollAnim = true;",450)
	}
}

function slidelfContent2(way){
	//var parent = (object) ? '.'+object+' ' : '.lfInPageContent ';
	slidelfContent(way, '.lfInPageContent ', true)
	//slidelfContent(way, '.lfInPageContent ')
}

/*********
	Converting to / from local time for events times
	*/
	
function getLocalTimeAdjust(date) {
	return (date.getTimezoneOffset() / 60) - 8;
}

function setTimeCookie(isVancouverTime) {
	$.cookie(COOKIE_NAMES.USE_VANCOUVER_TIME, isVancouverTime, { expires: getCookieExpiresDate() });
}

function getPstTime(element) {
	return Number(element.id.substring(5));
}

function convertTimes(times, switchTimeZone) {
	var useLocalTime = $.cookie(COOKIE_NAMES.USE_VANCOUVER_TIME) != 'true';
	var localTimeAdjust;
	times.each(function() {
		var thisTime = getPstTime(this);
		if (thisTime) {
			localTimeAdjust = useLocalTime ? 0 : getLocalTimeAdjust(new Date(thisTime));
	    var convertedTime = new Date(thisTime + (localTimeAdjust * 1000 * 60 * 60));
			
			if ($(this).hasClass('.format_time')) {
				$(this).text(convertedTime.getFormattedTime());
			}
			else if ($(this).hasClass('.format_time_zone')) {
				$(this).text(convertedTime.getFormattedTime() + ' ' + (useLocalTime ? CURRENT_LANG['localTime'] : CURRENT_LANG['pacificTime']));
			}
			else if ($(this).hasClass('.format_month_day')) {
				$(this).text(convertedTime.getFormattedDate(false, false));
			}
			else if ($(this).hasClass('.format_month_day_year')) {
				$(this).text(convertedTime.getFormattedDate(false, true) + ' ' + convertedTime.getFullYear());
			}
			else if ($(this).hasClass('.format_mon_day')) {
				$(this).text(convertedTime.getFormattedDate(true, false));
			}
			else if ($(this).hasClass('.format_mon_day_time')) {
				$(this).text(convertedTime.getFormattedDate(true, true) + ' ' + convertedTime.getFormattedTime());
			}
			else if ($(this).hasClass('.format_mon_day_time_zone')) {
				$(this).text(convertedTime.getFormattedDate(true, true) + ' ' + convertedTime.getFormattedTime() + ' ' + (localTimeAdjust == 0) ? CURRENT_LANG['pacificTime'] : CURRENT_LANG['localTime']);
			}
		}
	});
	
	if (switchTimeZone) {
		
		// updated any "switch to X time" buttons
		$('.timeSwitch').each(function() {
			if (getLocalTimeAdjust(new Date()) != 0) {
				var timeButton = $(this);
				var buttonText = CURRENT_LANG['switchTo'] + ' ' + (useLocalTime ? CURRENT_LANG['vancouverTime'] : CURRENT_LANG['localTime']);
				timeButton.text(buttonText);
				timeButton.attr('title', buttonText);
				timeButton.removeClass(useLocalTime ? 'toLocal' : 'toVancouver').addClass(useLocalTime ? 'toVancouver' : 'toLocal');
				timeButton.css('display', 'block');
			}
		});
	
		// do any page-specific layout changes
		timeConversionContentUpdate(localTimeAdjust);
	}
}

// override on a per-page basis to perform any layout or content changes required by a conversion to local time
function timeConversionContentUpdate(localTimeAdjust) {}


/************************
	Form validation error reporting
	*/
	
function reade(element) {
	var A = location.href;
	var P = /[-|_]e(\d{1,2})[-|.]/;
	var e = A.match(P);
	if (e != null) {
		document.getElementById(element).innerHTML = rc[cmArr['lang']][RegExp.$1];
		document.getElementById(element).style.color = "#D32C26";
	}
}

function logout() {
	$.cookie('v2010sse', null, { path: '/', domain: cmArr.cd });
	$('#login').css('display', 'inline');
	$('#manageProfile').css('display', 'none');
	if (cmArr['lang']=='FR')
		window.location.href = "http://www.vancouver2010.com/fr/";
	else	
		window.location.href = "http://www.vancouver2010.com";
}

function isLoggedIn() {
	var B = $.cookie('v2010sse');
	if (B && B.length > 0) {
		var A = B.indexOf("_");
		if (A > 0) {
			cmArr.cu = B.substr(B.indexOf("_") + 1)
		} else {
			cmArr.cu = ""
		}
		return true
	}
	return false
}

function readc(D) {
	var C = "" + document.cookie;
	var B = C.indexOf(D);
	if (B == -1 || D == "") {
		return ""
	}
	var A = C.indexOf(";", B);
	if (A == -1) {
		A = C.length
	}
	return unescape(C.substring(B + D.length + 1, A))
}

rc = { EN: [], FR: [] };
rc.EN[5] = "Login failed. Please try again.";
rc.FR[5] = "&#201;chec d'ouverture de session.";
rc.EN[6] = "This feature is currently unavailable. Please try again later.";
rc.FR[6] = "Cette fonction n'est pas disponible en ce moment. Veuillez r&#233;essayer plus tard.";
rc.EN[7] = "This feature is currently unavailable. Please try again later.";
rc.FR[7] = "Cette fonction n'est pas disponible en ce moment. Veuillez r&#233;essayer plus tard.";
rc.EN[11] = "Error: Display Name is required";
rc.FR[11] = "Erreur : Le nom &#224; afficher est obligatoire";
rc.EN[12] = "Error: Location is required";
rc.FR[12] = "Erreur : L'endroit est obligatoire";
rc.EN[13] = "Error: Comment field is empty";
rc.FR[13] = "Erreur : Le champ de commentaire est vide";
rc.EN[14] = "Updated failed.  Please try again.";
rc.FR[14] = "Impossible de mettre &#224; jour.  S'il vous pla&#206;t essayez de nouveau.";
rc.EN[15] = "Failed to change password.  Please try again.";
rc.FR[15] = "&#201;chou&#233; &#224; changer mot de passe. S'il vous pla&#206;t essayez de nouveau.";
rc.EN[16] = "There is an error on the form.  Please correct and try again.";
rc.FR[16] = "Il ya une erreur sur le formulaire. S'il vous pla?t essayez de nouveau.";


/****************
	Utils
	*/
	
function getQueryParams( queryString ) {
	queryString = queryString || location.search;
	var pairs = (queryString.indexOf('?') != -1 ? 
			queryString.split('?')[1].split('&') :
			queryString.split('&')
		);
	var map = {};
	var nameValue = [];
	for( var i = pairs.length - 1; i >= 0; i-- ) {
		nameValue = pairs[i].split('=');
		map[decodeURIComponent(nameValue[0])] = decodeURIComponent(nameValue[1]);
	}
	return map;
}




<!--generated: Tue Nov 03 16:26:40 PST 2009, host: '42', release: v.3.0.14 r.9747 id:72676 -->