  	var server_time		= '';
 	var demandletsList 	= 'gallery,userSubmission,quiz,account,siteSearch,searchResults,userComments,tvSchedule,poll,downloads,onTonight,recArtists,commentCounter,blogArchives,latestFanCom,tagCloud,azList,daylifeCovers,singlePointField';
 	var user			='';
 	var cookieDomain	= 'fuse.tv';
	 
	/* start lightbox global variables */
	var lightBox;
	var detect = navigator.userAgent.toLowerCase();
	var OS,browser,version,total,thestring;
	// declaring a global variable to rewrite in case of multiple lightboxes on  blog email to friend links
	var sendFriendBlogRefUrl;
	/* end lightbox global variables */
	
	// document.observe("dom:loaded", function() {
 	Event.observe(window,'load',function() {
 		
 		user = new userAccount();
 		requiredLoginAnchor();
 				
 		//Check page permissions
 		if( (!user.isAuthenticated()) && (getMetaValue('page_permissions') == 1) ){
 			createCookie('perm_redirect',window.location.href,1);	
 			window.location.href = '/restricted.html';
 		}
 		//Proceed
 		else{
 			loadScript('/ipui/ip_demandlet.js',function(){demandletManager.load(demandletsList)});
	 		//loadScript('/ipui/control.modal.2.2.3.js',function(){initModals()});
			//
 			
			activeMenuItem();
	 		$$('div .userStatus').each(
				function(item){
					var headStr = '';
					if(user.isAuthenticated())
						headStr = '<ul><li>Hey, <a href="http://www.fuse.tv/profile.html">' +  user.getOlio('username') + '</a></li><li class="last"><a href="#" onclick="user.logout();return false;">Sign Out</a></li></ul>'
					else{
						headStr = '<ul><li><a href="http://www.fuse.tv/registration.html">Register</a></li>';
						if(document.location.href.indexOf('forums.')<0)
							headStr += '<li class="last"><a href="/ipui/demandlets/layout/modal_login.html" class="modal" action="login" onclick="return false;" id="login_link">Login</a></li></ul>';
							
					}
					item.innerHTML=headStr;
				}
			);
					
			var lk = $('login_link');		
			lightBox = new lightbox(lk, {oncomplete: function () {
				user.action('login');
			}});
			// added functionality for lightboxes - send to friend functionality on blog feeds.
			($$('a.sendFriendLink')).each( function(elem){
				var tempSendFriendBlogRefUrl = elem.href;
				elem.href = '/ipui/demandlets/layout/send-to-friend.html';
				lightBox = new lightbox(elem, {
					oncomplete: function(){
							sendFriendBlogRefUrl = tempSendFriendBlogRefUrl;
						}
				})
			})
			/*
			//used for page authentication
			if(!user.isAuthenticated() && getMetaValue('page_permissions') == 1 ){
				
				$('main_navigation').style.zIndex = '99999999';
				$('fuse-search').style.zIndex = '99999999';
				$('fuse-accountbar').style.zIndex = '99999999';
				$('logo').style.zIndex = '99999999';
				
				
				addLightboxMarkup();
				lightBox.params.noOverlayClick = true;
	 			lightBox.activate();
	 			$('overlay').style.opacity = '1';
	 			window.location.href = '/channelfinder.html';
	 			 
	 		}
	 		*/
	 		//If user was redirected to the resticted page
	 		if(window.location.pathname == '/restricted.html'){
	 			$$('.modal ').each(function(item){
				   lightBox = new lightbox(item, {oncomplete: function () {
						user.action('login');
					}}); 
				});
	 			if(user.isAuthenticated()){
	 				//Clear contents and specity that user is being re-directed
	 				$('cols-1').innerHTML = '';
					var div = document.createElement('div');
						div.innerHTML = 'Relocating... <img src="/ipui/demandlets/layout/small-loading.gif">';
					$('cols-1').appendChild(div);
					//Redirect
	 				if(readCookie('perm_redirect')){
	 					window.location.href = readCookie('perm_redirect');
	 				}else{
	 					window.location.href = '/';
	 				}
	 			}
	 		}
	 		
			
			if($('tvsched_controls')) {
				getShows();
			//	Event.observe('range_full', 'click', changeRange);
			//	Event.observe('range_prime', 'click', changeRange);
			//	Event.observe('timezone_dd', 'change', changeTimezone);
				Event.observe('byshow_dd', 'change', changeShow);
				Event.observe('go_search', 'click', keywordSearch);
			} 							
	  		/** end **/
			if($('tvsched_toolbar')) {
				/** added by rpatel **/
			   // initiateCalendar();
			    /** end **/
				Event.observe('tvsched_view', 'click', changeView);
				Event.observe('sched_print', 'click', function(e) {window.print(); Event.stop(e);});
			}
		
 		}
	});	
	
	function makeXML(content) 
	{
		var xmlDoc;
		try 
		{ //IE
		    xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.loadXML(content);
		}
		catch(e) 
		{ 
			try 
			{ //The Rest
			
				xmlDoc = (new DOMParser()).parseFromString(content, "text/xml");
		  	}
		  	catch(e){}
		}
		return xmlDoc;
	}
	
	function handleResponse(response)
	{ 	//extract xml from HTML response or XML response - fix for .nvManaged caching issue
		return (! (('responseXML' in response) && response.responseXML != null) 
						&& response.responseXML.firstChild ) ? makeXML(response.responseText) : response.responseXML;
	};
	
	function setSeatingId(){};
	/* 
	 * Toolbar for tv schedule
	 */
	 function getShows() {
		new Ajax.Request('/ajax/data/fuse/programList.xml', { 
				method:'get',
				parameters:{nC: noCache()},
				onSuccess:function(xml){ 
					var x = xml.responseXML.getElementsByTagName(get_firstchild(xml.responseXML.documentElement).nodeName);
					for (var i = 0; i < x.length; i++) {
						addOption($('byshow_dd'), getNodeValueByChildName(x[i], 'display_name'), getNodeValueByChildName(x[i], 'category_id'), false);
						$('byshow_dd').options[i+1].setAttribute('short_name', getNodeValueByChildName(x[i], 'short_name'));
					}
				}
			}
		);
		
	};
	function changeDate(calendar, date) {
		if (calendar.dateClicked) {
			calendar.callCloseHandler(); 
			gotoDate($$('.tvSchedule')[0], createDateObj(date));
		}
	};
	function closeCalendar(calendar) {calendar.destroy();};
	function changeRange(e) {
		var evt = e || window.event;
		var evtTarget = evt.target || evt.srcElement;
		changeSchedRange($$('.tvSchedule')[0], evtTarget.value);
	};
	function changeShow(e) {
		var evt = e || window.event;
		var evtTarget = evt.target || evt.srcElement;
		if (evtTarget.value != '') {
			viewSchedByShow($$('.tvSchedule')[0], evtTarget.value, evtTarget.options[evtTarget.selectedIndex].getAttribute('short_name'));
			//evtTarget.value = '';
		}
	};
	function keywordSearch() {
		if ($('kwsearch').value.length) {
			//if ($('kwsearch').value.length < 4)
			//	alert('Please enter 4 or more characters for search');
			//else
				viewSchedBySearch($$('.tvSchedule')[0], $('kwsearch').value);
		}
	};
	function initiateCalendar() {
		Calendar.setup( {
			ifFormat: "%m/%d/%Y %H:%M:%S",
			weekNumbers: false,
			button: 'popup_cal',
			inputField: 'goto_date',
			onSelect: changeDate,
			onClose: closeCalendar
			});
	};
	function changeView(e) {
		var evt = e || window.event;
		var evtTarget = evt.target || evt.srcElement;
		if (evtTarget.id == "list_view") 
			changeViewLayout($$('.tvSchedule')[0], "list");
		else if (evtTarget.id == "grid_view") 
			changeViewLayout($$('.tvSchedule')[0], "grid");
		else if (evtTarget.id == "detail_view")
			changeViewLayout($$('.tvSchedule')[0], "detail");
		Event.stop(e);
	};
	/* end toolbar for tv schedule */

	function userAccount() {
		var that=this;
		this.config		= {
			dob_endYear: 1995,
			dob_startYear: 1920,
			modal_forgot: '/ipui/demandlets/layout/forgot.html',
			login: '/ipui/demandlets/layout/login.html',
			modal_login: '/ipui/demandlets/layout/modal_login.html',
			modal_permissions_login:'/ipui/demandlets/layout/modal_permissions_login.html',
			profile: '/ipui/demandlets/layout/profile.html',
			registration: '/ipui/demandlets/layout/registration.html',
			modal_reset: '/ipui/demandlets/layout/reset.html',
			resource: '/ajax/account.jsp',
			modal: 'lbContent',
			cookieName: 'olio'
		};
		
		this.responseCodes = {
	        0: true,
	        1: 'There has been an error. Please try again.',
	        2: 'This is not a registered e-mail address. Please try again.',
	        3: 'This password is incorrect. Please try again.',
	        4: 'This account is not yet active. Please check your e-mail for the link to verify your account.',
	        8: 'This e-mail address and username are already registered.',
	        9: 'This e-mail address is already registered. Please try again.',
	        10: 'This username is already in use. Please try again.'               
		};

	 	this.getSiteId = function(){ // this will be moved to ipui
			return (getMetaValue('siteIdentifier')) ? getMetaValue('siteIdentifier') : '1';
	 	};
	 	this.action = function(action) {
	 		if(action=='login'   &&  ( (user.isAuthenticated() && getMetaValue('page_permissions') == 0) )  ) {
	 			//practically deactivated this feature. It is redundant
	 			new Ajax.Updater(this.config.modal,modal,{
					method:'get',
					parameters: {nc: noCache()},
					onComplete:
					function(){
						if(readCookie('memory')!=null) {
			 				var details = readCookie('memory').split('|');
			 				$('login_email').value = details[0];
			 				$('login_password').value = details[1];
			 				$('remember').checked=true;
			 			}
		 			}
		 		});
		 	}
	 	};
		
		this.loginProcess = function(frmObj) {
			if(checkForm(frmObj)) {
				eraseCookie('olio');
				$$('.action').each(function(item){Element.hide(item);});
				$$('.status').each(function(item){Element.show(item);});
				new Ajax.Request(this.config.resource, { 
					method: 'get', 
					parameters: {email:$F('login_email'), password:$F('login_password'), site_id:this.getSiteId(),nc:noCache()}, 
					onSuccess: function(xhr){
						$$('.status').each(function(item){Element.hide(item);});
						var response = that.validateResponse(getNodeValueByChildName(xhr.responseXML.documentElement, 'response'));
						if(response==true) {
							var uObj = {
									key: getNodeValueByChildName(xhr.responseXML.documentElement, 'identifier'), 
									first_name: getNodeValueByChildName(xhr.responseXML.documentElement, 'firstname'), 
									last_name: getNodeValueByChildName(xhr.responseXML.documentElement, 'lastname'), 
									email: $F('login_email'),
									user_name: getNodeValueByChildName(xhr.responseXML.documentElement, 'username')
								};
							if($('remember').checked){
								createCookie('memory',uObj.email+'|'+$F('login_password'));
							}
							else {
								eraseCookie('memory');
							}
											
							if(readCookie('fowardUrl') != null){
								document.location.href = readCookie('fowardUrl');
								eraseCookie('fowardUrl')
							}							
							else if(document.location.href.indexOf('confirmation.html')>-1 || document.location.href.indexOf('registration.html')>-1){
								document.location.href='/index.html';
							}
							else{
								document.location.reload();
							}
										
						}
						else {
							$$('.action').each(function(item){Element.show(item);});	
							alert(response);
						}
					} 
				});
			}
		};
	
		this.validateResponse = function(response) {
			return (response in this.responseCodes) ? this.responseCodes[response] : 'Failed (err code ' + response + ')';
		};
		
		this.resetPasswordProcess = function(frmObj) {
			if(checkForm(frmObj)) {			
				new Ajax.Request(this.config.resource, { 
					method: 'put', 
					parameters: {nc: noCache()},
					parameters: {update: 'resetPswd', user_id:$F('user_id'), password:$F('reset_password'), email: $F('reset_email'), site_id: this.getSiteId() }, 
					onComplete: function(xhr){
						var response = that.validateResponse(getNodeValueByChildName(xhr.responseXML.documentElement, 'response'));
						if( response==true )
							alert('Email has beent sent');
						else
							alert('Email not sent!\n\n' + response);	
						closeLightBox()
					} 
				});
			}
		};
		
		this.logout = function() {
			eraseCookie('olio');
			document.location.reload();
		};
		
	 	this.isAuthenticated = function() {
	 		return (readCookie(that.config.cookieName)) ? true : false;
	 	};
	 	
	 	this.getUID = function() {
	 		return (this.isAuthenticated()) ? this.getOlio('key'): null;
	 	};
	 	
	 	this.getOlio = function(key) {
	 		var keyIdx	= ['email','key','username','first_name','last_name'];
	 		var keyRef;
	 		for(var i=0;i<keyIdx.length;i++) { 
	 			if(keyIdx[i] == key) {
	 				return readCookie('olio').split('|')[i];
	 				break;
	 			}
	 		}
	 		return '';
	 	};

		this.forgotLayout = function() {
			new Ajax.Updater(this.config.modal,this.config.modal_forgot,{method:'get'});
		};
		
		this.forgotProcess = function(frmObj) {
			if(checkForm(frmObj)) {
				$$('.action').each(function(item){Element.hide(item);});
				$$('.status').each(function(item){Element.show(item);});
				new Ajax.Request(this.config.resource, { 
					method: 'put', 
					parameters: {update: 'resetPswd', email: $F('forgot_email'), site_id: this.getSiteId() }, 
					onComplete: function(xhr){
						$$('.action').each(function(item){Element.show(item);});
						$$('.status').each(function(item){Element.hide(item);});
						var response = that.validateResponse(getNodeValueByChildName(xhr.responseXML.documentElement, 'response'));
						if( response==true )
							alert('Email has beent sent');
						else
							alert('Email not sent!\n\n' + response);	
						closeLightBox();
					} 
				});
			}
		};
	};

	function paramOW(url){
	this.url = url;
	};
	
	paramOW.prototype = {
		omniture: function() {
			this.url		= this.parseURI(this.url);
			if(this.url.fileName == '')this.url.fileName = 'index';
			s.server        = this.isSpecified(omniture,'server',window.location.href.split('/')[2].split('.')[0] == 'fuse' ? 'www' : window.location.href.split('/')[2].split('.')[0]);
			s.pageName 		= this.isSpecified(omniture, 'pageName', s.server+ '' + SearchAndReplace(this.url.directoryPath+'','/',':') + this.url.fileName.split('.')[0]);
			s.channel  		= this.isSpecified(omniture, 'channel', this.url.directoryPath.split('/')[1]);
			s.pageType 		= this.isSpecified(omniture, 'pageType', '');
			s.hier     		= this.isSpecified(omniture, 'hier', s.server+ '' + SearchAndReplace(this.url.directoryPath+'','/',',') + this.url.fileName.split('.')[0]);
			s.prop1    		= this.isSpecified(omniture, 'prop1', s.hier.split(',')[2] ? s.hier.split(',')[2] : '' );
			s.prop2    		= this.isSpecified(omniture, 'prop2', s.hier.split(',')[3] ? s.hier.split(',')[3] : '' );
			s.prop3    		= this.isSpecified(omniture, 'prop3', s.hier.split(',')[4] ? s.hier.split(',')[4] : '' );
			s.prop4    		= this.isSpecified(omniture, 'prop4', s.hier.split(',')[5] ? s.hier.split(',')[5] : '' );
			s.campaign 		= this.isSpecified(omniture, 'campaign', '');
			s.state    		= this.isSpecified(omniture, 'state', '');
			s.zip      		= this.isSpecified(omniture, 'zip', '');
			s.events   		= this.isSpecified(omniture, 'events', '');
			s.products 		= this.isSpecified(omniture, 'products', '');
			s.purchaseID 	= this.isSpecified(omniture, 'purchaseID', '');
			s.eVar1    		= this.isSpecified(omniture, 'eVar1', '');
			s.eVar2    		= this.isSpecified(omniture, 'eVar2', '');
			s.eVar3    		= this.isSpecified(omniture, 'eVar3', '');
			s.eVar4    		= this.isSpecified(omniture, 'eVar4', '');
			s.eVar5    		= this.isSpecified(omniture, 'eVar5', '');
			 
			// DayLife pages
			if (this.url.directoryPath == '/news/')	 {
				if (this.url.name) {
					var dlName = this.url.name.replace(new RegExp(/-/g), '_'); 
					s.pageName = 'news:name:'+dlName;
					s.prop1='name';
					s.prop2=dlName;
				}
				if (this.url.article) {
					s.pageName = 'news:article:'+this.url.article;
					s.prop1='article';
					s.prop2=this.url.article;
				}
				if (this.url.topic) {
					s.pageName = 'news:topic:'+this.url.topic;
					s.prop1='topic';
					s.prop2=this.url.topic;
				} 
				if (this.url.name || this.url.article || this.url.topic) {
					s.channel = 'news';
					s.hier = s.pageName.replace(new RegExp(/:/g), ',');
				}
				
			}			
			
			//Forums								
			//---for testing purposes-- 	if( window.location.href.split('/')[2].split('.')[1] == 'forums' ){
			if(window.location.href.split('/')[2].split('.')[0] == 'forums'){	
				var fCategory = '';
				var fForum = '';
				var fThread = '';
									
				if($('jive-breadcrumbs').getElementsByTagName('a')[1]){
					var fCategory = ':'+escape($('jive-breadcrumbs').getElementsByTagName('a')[1].innerHTML).toLowerCase();
					
				}
				if($('jive-breadcrumbs').getElementsByTagName('a')[2]){
					var fForum = ':'+escape($('jive-breadcrumbs').getElementsByTagName('a')[2].innerHTML).toLowerCase();
					
				}
						
				if($$('.jive-page-title')[0].innerHTML.split(':')[0]){
					var checkThread = new RegExp("\\w+").exec($$('.jive-page-title')[0].innerHTML.split(':')[0])[0].toLowerCase();
					if(checkThread == 'thread' && document.getElementsByTagName('title')[0].innerHTML.split(':')[1])	
						var fThread = ':'+escape(SearchAndReplace(document.getElementsByTagName('title')[0].innerHTML.split(':')[1],'.',''))
				}
				
				if(!$('jive-breadcrumbs').getElementsByTagName('a')[1] && !$('jive-breadcrumbs').getElementsByTagName('a')[2] ){
					fCategory = ':index'
				}
				
				
				s.pageName 		= this.isSpecified(omniture, 'pageName',s.server+''+fCategory+''+fForum+''+fThread); 
				s.hier          = this.isSpecified(omniture,'hier', SearchAndReplace(s.pageName,':',','));
				s.channel       = this.isSpecified(omniture,'channel', s.pageName.split(':')[1]?s.pageName.split(':')[1]:'');
				s.prop1    		= this.isSpecified(omniture, 'prop1', s.pageName.split(':')[2]?s.pageName.split(':')[2]:'');
				s.prop2    		= this.isSpecified(omniture, 'prop2', s.pageName.split(':')[3]?s.pageName.split(':')[3]:'');
				s.prop3    		= this.isSpecified(omniture, 'prop3', '');
				s.prop4    		= this.isSpecified(omniture, 'prop4', '');
				
			}
			//pageNotFound
			
			if(document.getElementsByTagName('title')[0].innerHTML.split('-')[1]){
				if(document.getElementsByTagName('title')[0].innerHTML.split('-')[1].replace(/\s/g, '').toLowerCase() == 'pagenotfound' ){
					s.pageName 		= this.isSpecified(omniture, 'pageName', s.server+ ':404');
					s.hier          = this.isSpecified(omniture,'hier', SearchAndReplace(s.pageName,':',','));
					s.channel  		= this.isSpecified(omniture, 'channel', '404');
				}	
			}
						
			/*		
			console.info('s.server = ' + s.server+ '\ns.hier = '+ s.hier + '\ns.pageName = '+s.pageName +'\ns.channel = '+s.channel +
			'\ns.prop1 = ' +s.prop1+ '\ns.prop2 = ' + s.prop2+ '\ns.prop3 = ' +s.prop3 +'\ns.prop4 = '+s.prop4);
			*/ 
			 
		},
		
	
		ad1: function(){
			var url 		= this.parseURI(this.url);
			var jURL 		= (url.fullPath.substr(url.fullPath.length-1, url.fullPath.length)=='/') ? url.fullPath + 'index' : url.fullPath;
			tile1.jUrl		= SearchAndReplace( SearchAndReplace( jURL, '-','_'), '/','_').replace(/^\w/, '');
			tile1.url 		= SearchAndReplace( this.isSpecified(tile1, 'url', url.directoryPath) ,'-','_') + this.isSpecified(tile1, 'suffix', ''); 
			tile1.s1		= SearchAndReplace( this.isSpecified(tile1, 's1', url.fullPath.split('/')[1]).substr(0,57) ,'-','_'); 
			tile1.s2		= SearchAndReplace( this.isSpecified(tile1, 's2', url.fullPath.split('/')[2]).substr(0,57) ,'-','_'); 
			tile1.s3		= SearchAndReplace( this.isSpecified(tile1, 's3', url.fullPath.split('/')[3]).substr(0,57) ,'-','_');
			tile1.s4		= SearchAndReplace( this.isSpecified(tile1, 's4', url.fullPath.split('/')[4]).substr(0,57) ,'-','_');
			tile1.s5		= SearchAndReplace( this.isSpecified(tile1, 's5', url.fullPath.split('/')[5]).substr(0,57) ,'-','_');
			tile1.s6		= SearchAndReplace( this.isSpecified(tile1, 's6', url.fullPath.split('/')[6]).substr(0,57) ,'-','_');
			tile1.kw		= this.isSpecified(tile1, 'kw', url.query).substr(0,100);
			tile1.url		= tile1.url.substr(0,64).replace(/\/$/,'');
			for(var item in tile1) {if(tile1[item]=='undefined') tile1[item]=''};
		},

		ad2: function(){
			var url 		= this.parseURI(this.url);
			var jURL 		= (url.fullPath.substr(url.fullPath.length-1, url.fullPath.length)=='/') ? url.fullPath + 'index' : url.fullPath;
			tile2.jUrl		= SearchAndReplace( SearchAndReplace( jURL, '-','_'), '/','_').replace(/^\w/, '');
			tile2.url 		= SearchAndReplace( this.isSpecified(tile2, 'url', url.directoryPath).substr(0,57) ,'-','_') + this.isSpecified(tile2, 'suffix', ''); 
			tile2.s1		= SearchAndReplace( this.isSpecified(tile2, 's1', url.fullPath.split('/')[1]).substr(0,57) ,'-','_'); 
			tile2.s2		= SearchAndReplace( this.isSpecified(tile2, 's2', url.fullPath.split('/')[2]).substr(0,57) ,'-','_'); 
			tile2.s3		= SearchAndReplace( this.isSpecified(tile2, 's3', url.fullPath.split('/')[3]).substr(0,57) ,'-','_');
			tile2.s4		= SearchAndReplace( this.isSpecified(tile2, 's4', url.fullPath.split('/')[4]).substr(0,57) ,'-','_');
			tile2.s5		= SearchAndReplace( this.isSpecified(tile2, 's5', url.fullPath.split('/')[5]).substr(0,57) ,'-','_');
			tile2.s6		= SearchAndReplace( this.isSpecified(tile2, 's6', url.fullPath.split('/')[6]).substr(0,57) ,'-','_');
			tile2.kw		= this.isSpecified(tile2, 'kw', url.query).substr(0,100);
			tile2.url		= tile2.url.substr(0,64).replace(/\/$/,'');
			for(var item in tile2)if(tile2[item]=='undefined') tile2[item]='';
		},
		
		ad3: function(){
			var url 		= this.parseURI(this.url);
			var jURL 		= (url.fullPath.substr(url.fullPath.length-1, url.fullPath.length)=='/') ? url.fullPath + 'index' : url.fullPath;
			tile3.jUrl		= SearchAndReplace( SearchAndReplace( jURL, '-','_'), '/','_').replace(/^\w/, '');
			tile3.url 		= SearchAndReplace( this.isSpecified(tile3, 'url', url.directoryPath).substr(0,57) ,'-','_') + this.isSpecified(tile3, 'suffix', ''); 
			tile3.s1		= SearchAndReplace( this.isSpecified(tile3, 's1', url.fullPath.split('/')[1]).substr(0,57) ,'-','_'); 
			tile3.s2		= SearchAndReplace( this.isSpecified(tile3, 's2', url.fullPath.split('/')[2]).substr(0,57) ,'-','_'); 
			tile3.s3		= SearchAndReplace( this.isSpecified(tile3, 's3', url.fullPath.split('/')[3]).substr(0,57) ,'-','_');
			tile3.s4		= SearchAndReplace( this.isSpecified(tile3, 's4', url.fullPath.split('/')[4]).substr(0,57) ,'-','_');
			tile3.s5		= SearchAndReplace( this.isSpecified(tile3, 's5', url.fullPath.split('/')[5]).substr(0,57) ,'-','_');
			tile3.s6		= SearchAndReplace( this.isSpecified(tile3, 's6', url.fullPath.split('/')[6]).substr(0,57) ,'-','_');
			tile3.kw		= this.isSpecified(tile3, 'kw', url.query).substr(0,100);
			tile3.url		= tile3.url.substr(0,64).replace(/\/$/,'');
			for(var item in tile3)if(tile3[item]=='undefined') tile3[item]='';
		},
		
		/* Added by Tod Gillespie 3 August 2008 */
		ad: function(){
			var url 		= this.parseURI(this.url);
			var jURL 		= (url.fullPath.substr(url.fullPath.length-1, url.fullPath.length)=='/') ? url.fullPath + 'index' : url.fullPath;
			ad.jUrl		= SearchAndReplace( SearchAndReplace( jURL, '-','_'), '/','_').replace(/^\w/, '');
			ad.url 		= url.length > 0 ? url : SearchAndReplace( url.directoryPath.substr(0,57) ,'-','_') + this.isSpecified(ad, 'suffix', ''); 
			ad.s1		= SearchAndReplace( this.isSpecified(ad, 's1', url.fullPath.split('/')[1]).substr(0,57) ,'-','_'); 
			ad.s2		= SearchAndReplace( this.isSpecified(ad, 's2', url.fullPath.split('/')[2]).substr(0,57) ,'-','_'); 
			ad.s3		= SearchAndReplace( this.isSpecified(ad, 's3', url.fullPath.split('/')[3]).substr(0,57) ,'-','_');
			ad.s4		= SearchAndReplace( this.isSpecified(ad, 's4', url.fullPath.split('/')[4]).substr(0,57) ,'-','_');
			ad.s5		= SearchAndReplace( this.isSpecified(ad, 's5', url.fullPath.split('/')[5]).substr(0,57) ,'-','_');
			ad.s6		= SearchAndReplace( this.isSpecified(ad, 's6', url.fullPath.split('/')[6]).substr(0,57) ,'-','_');
			ad.kw		= this.isSpecified(ad, 'kw', url.query).substr(0,100);
			ad.url		= ad.url.substr(0,64).replace(/\/$/,'');
			for(var item in ad)if(ad[item]=='undefined') ad[item]='';
		},
		
				
		isSpecified: function(obj, key, dflt) {
			return (key in obj) ? obj[key] : dflt+'';
		},
		
		parseURI: function(sourceURI) {
			var uri = {};
		    var uriPartNames 	= ['source','protocol','authority','domain','port','path','directoryPath','fileName','querystring','anchor','currentFolder','fullPath'];
		    var uriParts 		= new RegExp('^(?:([^:/?#.]+):)?(?://)?(([^:/?#]*)(?::(\\d*))?)?((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[\\?#]|$)))*/?)?([^?#/]*))?(?:\\?([^#]*))?(?:#(.*))?').exec(sourceURI);
		    for(var i=0;i<uriPartNames.length;i++) uri[uriPartNames[i]]=(uriParts[i] ? uriParts[i] : '');
		    if(uri.directoryPath.length>0) uri.directoryPath=uri.directoryPath.replace(/\/?$/, '/');
		    if(uri.directoryPath.length>0) uri.fullPath = uri.directoryPath + uri.fileName.replace(getFileExtension(uri.fileName),'');
            if(uri.directoryPath.length>0) uri.currentFolder = uri.directoryPath.split('/')[uri.directoryPath.split('/').length-2];
            if(uri.querystring!='') {
                var params = uri.querystring.split('&');
                for(var i=0;i<params.length;i++) {
                    paramObj = params[i].split('=');
                    uri[paramObj[0]]=SearchAndReplace(paramObj[1]+'','%20','+');
                }
            }
		    return uri;
		}
				
	};
	
	function showOmniture(){
		alert('s.server = ' + s.server+ '\ns.hier = '+ s.hier + '\ns.pageName = '+s.pageName +'\ns.channel = '+s.channel +
			'\ns.prop1 = ' +s.prop1+ '\ns.prop2 = ' + s.prop2+ '\ns.prop3 = ' +s.prop3 +'\ns.prop4 = '+s.prop4);
	}
	
   		
	function addMetaNode(name, content) {
		if (!name || !content) return;
		var head = document.getElementsByTagName('head');
		if (head.length) {
			var metaTag = document.createElement('meta');
			metaTag.setAttribute('name', name);
			metaTag.setAttribute('content', content);
			head[0].appendChild(metaTag);
		}
	};
	function shows_sfHover(){
		if(document.getElementById('show-navigation')){
			new Ajax.Request('subnav.xml',{
				method: 'get',
				parameters:'nC='+noCache(),
				onFailure:ajaxRequest_Error,
				onSuccess:function(t){
					var mainNav = $('show-navigation');
					mainNav.innerHTML=renderShowNavigation(t,0);
					mainNav.firstChild.lastChild.firstChild.className += ' last';
					setSeatingId();
				}
			});	
		}
	};
	function sfHover(){
		if(document.getElementById('main_navigation')){
			new Ajax.Request('/global/subnav.xml',{
				method: 'get',
				parameters:'nC='+noCache(),
				onFailure:ajaxRequest_Error,
				onSuccess:function(t){
					var mainNav = $('main_navigation');
					var xmlObj;
					if (document.all)
					{
						xmlObj = new ActiveXObject("Microsoft.XMLDOM");
						xmlObj.async="false";
						xmlObj.loadXML(t.responseText);
					}
					else
					{
						xmlObj = (new DOMParser()).parseFromString(t.responseText, 'text/xml');
					};
					mainNav.innerHTML=renderMainNavigation(xmlObj,0);
					mainNav.firstChild.lastChild.firstChild.className += ' last';
					setSeatingId();
					$$('div#main_navigation ul#nav ul').each(function(e) {
						e.previous('a').addClassName('active');
						}
					);
				}
			});	
		}
	};
	function sfIeHover(){
		if(document.getElementById('main_navigation')){
			new Ajax.Request('/global/subnav.xml',{
				method: 'get',
				parameters:'nC='+noCache(),
				onFailure:ajaxRequest_Error,
				onSuccess:function(t){
					var mainNav = $('main_navigation');
					var xmlObj = new ActiveXObject("Microsoft.XMLDOM");
					xmlObj.async="false";
					xmlObj.loadXML(t.responseText);
					mainNav.innerHTML=renderMainNavigation(xmlObj,0);
					mainNav.firstChild.lastChild.firstChild.className += ' last';
					setSeatingId();
					$$('div#main_navigation ul#nav ul').each(function(e) {
						e.previous('a').addClassName('active');
						}
					);
					var el = document.getElementById("nav");
					if(!/\bnav\b/.test(el.className) && el.tagName == "UL")
						setIeHover(el);
					var ieNavs = document.getElementsByTagName('ul');
					for(i=0; i<ieNavs.length; i++) {
						var ul = ieNavs[i];
						if(/\bnav\b/.test(ul.className))
							setIeHover(ul);
					}
				}
			});	
		}
	};
	function setIeHover(nav) {
		var ieULs = nav.getElementsByTagName('ul');
		if (navigator.appVersion.substr(22,3)!="5.0") {
			// IE script to cover <select> elements with <iframe>s
			for (j=0; j<ieULs.length; j++) {
				var ieMat=document.createElement('iframe');
				if(document.location.protocol == "https:")
					ieMat.src="//0";
				else if(window.opera != "undefined")
					ieMat.src="";
				else
					ieMat.src="javascript:false";
				ieMat.scrolling="no";
				ieMat.frameBorder="0";
				ieMat.style.width=ieULs[j].offsetWidth+"px";
				ieMat.style.height=ieULs[j].offsetHeight+"px";
				ieMat.style.zIndex="-1";
				ieULs[j].insertBefore(ieMat, ieULs[j].childNodes[0]);
				ieULs[j].style.zIndex="101";
			}
			// IE script to change class on mouseover
			var ieLIs = nav.getElementsByTagName('li');
			for (var i=0; i<ieLIs.length; i++) {
				if (ieLIs[i]) { 
					// Add a sfhover class to the li
					ieLIs[i].onmouseover=function() { 
						if(!/\bsfhover\b/.test(this.className)) {
							this.className+=" sfhover";
						}
					}
					ieLIs[i].onmouseout=function() {
						if(!this.contains(event.toElement)) {
							this.className=this.className.replace(' sfhover', '');
						}
					}
				}
			}
		}
	};
	function activeMenuItem() {
		var root = location.pathname.match(/\w+(?=\/)/);
		if(root)document.body.id = root[0];
	};
	function prepareSendLinks(){
		if ($('send-email')) {
			$('send-email').onclick = function() { 
				newWindow('/send-to-friend.html','sendtoFriend',320,360,false,false,true);
        		this.blur();
        		return false; 
        	}
		}
		if ($('send-im')) {
			$('send-im').onclick = function() {  
				var siteUrl = window.location.href;
	   			var siteName = window.location.href.split('://')[1].split('/')[0];
    			sendIM(siteName, siteUrl); 
    			return false; 
  			}
    	}
    	if ($('send-print')) {
	    	$('send-print').onclick = function() { 
	    		window.print(); 
	    		return false; 
	    	}
	    }
	};
	function autoRedirect(siteIdentifier,redirectURL){if(readCookie('defaultSite')==siteIdentifier) document.location.href=redirectURL;};
	function siteRedirect(siteURL){document.location.href=siteURL;};
	function prepareSendFriendLink(lnk, f) {
		if (lnk) {
			lnk.onclick = function() {
				if (f) { 
					var s = $('response_panel');
					submit_FriendPopup(f, s);
				}
				return false;
			}
		}
	};
	function submit_FriendPopup(formObj,responseElem){
		
		if (!formObj) return false;  
		if (checkForm(formObj)) {
			if (!getMetaValue('siteIdentifier')) {
				var site = new Site();
				var site_id = site.getSiteId();
			} else {
				var site_id = getMetaValue('siteIdentifier'); 
			}
			
			if (sendFriendBlogRefUrl) {
				
			  var link = sendFriendBlogRefUrl;
			} else {
				// functionality below copied over does not work here - needs to be fixed - set link to default until fixed. 
				// var loc = window.opener.location.href;
				// loc = loc.split('://');
				var link = 'fuse.tv';  
			} 
	
			var params = formObj.serialize();
			new Ajax.Request('/ajax/sendFriend.jsp', {
					parameters:'nC='+noCache()+'&'+params+'&site_id='+site_id+'&link='+link,
					onSuccess: function(xml) {
						Element.hide(formObj);
						if (responseElem) {
							var response = xml.responseXML.getElementsByTagName(get_firstchild(xml.responseXML.documentElement).nodeName);
							var responseContent = responseElem.innerHTML;
							if (getNodeValue(response[0]) == 'success') 
								responseElem.innerHTML = responseContent.replace('<!--response-->','Thank you, your message has been sent.');
							else
								responseElem.innerHTML = responseContent.replace('<!--response-->','Sorry there was a problem with your request. Please try again later.');
							Element.show(responseElem);
						}
					}
				}
			);
		}
	};
	function sendmailSubmit(fObj) {
		if (checkForm(fObj)) {
			fObj.submit();
		}
	};
	function open_ReminderPopup(showtitle, episode, time, scheduleid) {
		newWindow('/reminder.html?showtitle='+showtitle+'&episode='+episode+'&time='+time, scheduleid+'', 315,400,false,false,true);
	};
	function submit_ReminderPopup(formObj,hideDivObj,showDivObj){
		if (checkForm(formObj)){
			var params = formObj.serialize();
			new Ajax.Request(
				'/ajax/showReminderSave.jsp', 
				{
					method:'POST',
					parameters:'&nC'+noCache()+'&'+params+'&scheduleid='+window.name,
					onSuccess: function(xml) 
					{
						var response 		= xml.responseXML.getElementsByTagName(get_firstchild(xml.responseXML.documentElement).nodeName);
						var responseContent = showDivObj.innerHTML;
						if (getNodeValue(response[0]) == 'success') 
							showDivObj.innerHTML = responseContent.replace('<!--response-->','Thank you, your reminder will be sent.');
						else
							showDivObj.innerHTML = responseContent.replace('<!--response-->','Sorry there was a problem with your request. Please try again later.');
						Element.hide(hideDivObj);
						Element.show(showDivObj);
					}
				}
			);
		}
	};
	function ajaxRequest_Error(){alert("An error occurred during the process");};
	function search_Submit(sObj){
		if($F(sObj)!=''){
			if(document.getElementById('page_id')) 
				document.location.href='/search.jsp?kword='+$F(sObj)+'&page_id='+$F('page_id');
			else 
				document.location.href='/search.jsp?kword='+$F(sObj);
		}
		else{
			alert('Please enter a keyword');
		}
	};
	function search_Page(pNum,sObj){$('page_id').value=pNum;search_Submit(sObj);};							
	function search_tvSchedule(fObj){
		if(checkForm(fObj)){
			new Ajax.Request('/ajax/tvScheduleProcess.jsp',{
					parameters:'&nC'+noCache()+'&keyword='+$F(fObj.id + '_keyword'),
					onSuccess:function (xml){
						display_tvScheduleResults(xml);
					}
				}
			);
		}
	};

	function render_programList(dObj){
		removeAllOptions(dObj);
		new Ajax.Request('/ajax/data/programList.xml',{
				method:'get',
				parameters:'&nC'+noCache(),
				onFailure:function(err){
					addOption(dObj,'No Programs Found','',false);
				},
				onSuccess:function(xml){ 
					var x = xml.responseXML.getElementsByTagName(get_firstchild(xml.responseXML.documentElement).nodeName);
					for (var i=0;i<x.length;i++)
						addOption(dObj,getNodeValue(x[i],'display_name'),getNodeValue(x[i],'category_id'),false);
				}
			}
		);
	};		
	
	function renderMainNavigation(req,parent_id){
		var tmp			= '';
		var subTmp		= '';
		var subNodes	= '';
		var k			= req.responseXML ? req.responseXML.getElementsByTagName('nav') : req.getElementsByTagName('nav');
		var navLen		= k.length;
		var topLevelCnt	= 0;
		for(var j=0;j<k.length;j++){
			tmp					= '';
			subNodes			= '';
			var nLabel			= getNodeAttribute(k[j],'label');
			var nUrl			= getNodeAttribute(k[j],'url');
			var popup			= getNodeAttribute(k[j],'popup');
			var popupWidth		= getNodeAttribute(k[j],'width');
			var popupHeight		= getNodeAttribute(k[j],'height');
			var popupScroll		= getNodeAttribute(k[j],'scroll');
			var popupToolbar	= getNodeAttribute(k[j],'toolbar');
			var popupResize		= getNodeAttribute(k[j],'resize');
			var nParent			= getNodeAttribute(k[j],'parent_id');
			var nOrder			= getNodeAttribute(k[j],'order');
			var nId				= getNodeAttribute(k[j],'nav_id');
			var topImg			= 'top_'+nId;
			if(nParent==parent_id){
				if(parent_id==0){
					topLevelCnt++;
					tmp = (popup=='1') ? '<a class="item'+ topLevelCnt + '" href="' + nUrl + '" target="_blank">' : '<a class="item'+ topLevelCnt + '" href="'+nUrl+'" target="_top">';
					tmp += '<span>' + nLabel + '</span></a>';
					subNodes = renderMainNavigation_sub1(req,nId,topImg);
					if(subNodes!='')
						tmp+='<ul>'+subNodes+'</ul>';
				}
			}
			if(tmp!='')
				subTmp += '<li class="item'+ topLevelCnt + '">'+tmp+'</li>';
		}
		return '<ul id="nav" class="nav">'+subTmp+'</ul>';
	};
	
	function renderMainNavigation_sub1(req,parent_id,mainImage){
		var tmp			= '';
		var subTmp		= '';
		var subNodes	= '';
		var k			= req.responseXML ? req.responseXML.getElementsByTagName('nav') : req.getElementsByTagName('nav');
		for(var j=0;j<k.length;j++){
			tmp	='';
			subNodes='';
			var nLabel			= getNodeAttribute(k[j],'label');
			var nUrl			= getNodeAttribute(k[j],'url');
			var popup			= getNodeAttribute(k[j],'popup');
			var popupWidth		= getNodeAttribute(k[j],'width');
			var popupHeight		= getNodeAttribute(k[j],'height');
			var popupScroll		= getNodeAttribute(k[j],'scroll');
			var popupToolbar	= getNodeAttribute(k[j],'toolbar');
			var popupResize		= getNodeAttribute(k[j],'resize');
			var nParent			= getNodeAttribute(k[j],'parent_id');
			var nOrder			= getNodeAttribute(k[j],'order');
			var nId				= getNodeAttribute(k[j],'nav_id');
			if(nParent==parent_id){
				tmp +='<li>';
				var link = (popup=='1') ? '<a href="'+nUrl+'" target="_blank">' + nLabel + '</a>' : '<a href="'+nUrl+'" target="_top">' + nLabel + '</a>';
				tmp += link;
				subNodes=renderMainNavigation_sub2(req,nId);
				if(subNodes!='')
					tmp+='<ul>'+subNodes+'</ul>\n';
			}
			if(tmp!='')
				subTmp+=tmp+'</li>\n';
		}
		return subTmp;
	};
	
	function renderMainNavigation_sub2(req,parent_id){
		var tmp='';
		var subTmp='';
		var k			= req.responseXML ? req.responseXML.getElementsByTagName('nav') : req.getElementsByTagName('nav');
		for (var j=0;j<k.length;j++){
			tmp='';
			var nLabel=getNodeAttribute(k[j],'label');
			var nUrl=getNodeAttribute(k[j],'url');
			var popup=getNodeAttribute(k[j],'popup');
			var popupWidth=getNodeAttribute(k[j],'width');
			var popupHeight=getNodeAttribute(k[j],'height');
			var popupScroll=getNodeAttribute(k[j],'scroll');
			var popupToolbar=getNodeAttribute(k[j],'toolbar');
			var popupResize=getNodeAttribute(k[j],'resize');
			var nParent=getNodeAttribute(k[j],'parent_id');
			var nOrder=getNodeAttribute(k[j],'order');
			var nId=getNodeAttribute(k[j],'nav_id');
			if(nParent==parent_id){
				tmp += '<li>';
				var link = (popup=='1') ? '<a href="'+nUrl+'" target="_blank">' + nLabel + '</a>' : '<a href="'+nUrl+'" target="_top" target="_top">' + nLabel + '</a>';
				tmp+=link;
				if(tmp!=''){
					tmp+='</li>\n';
				}
			}
			if(tmp!=''){
				subTmp+=tmp;
			}
		}
		return subTmp;
	};	
	
	function renderShowNavigation(req,parent_id){
		var tmp			= '';
		var subTmp		= '';
		var subNodes	= '';
		var k			= req.responseXML.getElementsByTagName('nav');
		var navLen		= k.length;
		var topLevelCnt	= 0;
		for(var j=0;j<k.length;j++){
			tmp					= '';
			subNodes			= '';
			var nLabel			= getNodeAttribute(k[j],'label');
			var nUrl			= getNodeAttribute(k[j],'url');
			var popup			= getNodeAttribute(k[j],'popup');
			var popupWidth		= getNodeAttribute(k[j],'width');
			var popupHeight		= getNodeAttribute(k[j],'height');
			var popupScroll		= getNodeAttribute(k[j],'scroll');
			var popupToolbar	= getNodeAttribute(k[j],'toolbar');
			var popupResize		= getNodeAttribute(k[j],'resize');
			var nParent			= getNodeAttribute(k[j],'parent_id');
			var nOrder			= getNodeAttribute(k[j],'order');
			var nId				= getNodeAttribute(k[j],'nav_id');
			var topImg			= 'top_'+nId;
			if(nParent==parent_id){
				topLevelCnt++;
				var link = (popup=='1') ? '<a href="'+nUrl+'" target="_blank"><span>' + nLabel + '</span></a>' : '<a href="'+nUrl+'"><span>' + nLabel + '</span></a>';
				tmp+=link;
				//subNodes = renderMainNavigation_sub1(req,nId,topImg);
				if(subNodes!='')
					tmp+='<ul>'+subNodes+'</ul>';
			}
			if(tmp!='')
				subTmp += '<li class="item'+ topLevelCnt + '">'+tmp+'</li>';
		}
		return '<ul id="show-nav" class="show-nav">'+subTmp+'</ul>';
	};

	//ip_common.js
	function newWindow(wURL,wName,wWidth,wHeight,wScroll,wResizable,wCentered){
		var settings = 'height='+wHeight+',width='+wWidth+'scrollbars='+wScroll+',resizable='+wResizable;
		if(wCentered==true){
			lPosition	= (screen.width) ? (screen.width-wWidth)/2 : 0;
			tPosition	= (screen.height) ? (screen.height-wHeight)/2 : 0;	
			settings	+= ',left=' + lPosition + ',top=' + tPosition;
		}
		var nWindow	= window.open(wURL,wName,settings);
		nWindow.focus();
	};
	
	function open_win(link, win_name, params) {window.open(link,win_name.replace("'",""),params);};
	function disableContextMenu(event){Event.stop(event);event.oncontextmenu = function(){return false;}};
	function truncateText_Append(txtString,len,append){
		  var trunc = txtString;
		  if (trunc.length > len){
		    trunc = trunc.substring(0, len);
		    trunc = trunc.replace(/\w+$/, '');
		    trunc += append;
		  }
		  return trunc;
	};
	function getPage(url){return url.substring(url.lastIndexOf('/') + 1);};
	function hasZero(value){return (value+0<10)? '0' + value : '' + value;};
	function noCache(){return Math.random(0, 1000)+'='+Math.random(0,1000);};
	function uniqueId(){var rndID = Math.random(0, 1000) + '';return rndID.replace('.','')};
	function addDays(myDate,days){return new Date(myDate.getTime() + days*24*60*60*1000);};	

	function getMetaValue(metaName){
		var metaArray = document.getElementsByTagName('meta');
		for(m=0;m<metaArray.length;m++){
			if(metaArray[m].name==metaName) {
				return metaArray[m].content;
				break;
			}	
		}
		return '';
	};
					
	function getFileExtension(fileName){
		if( fileName.length == 0 ) return ''; 
		var dot = fileName.lastIndexOf('.'); 
		if( dot == -1 ) return ''; 
		return fileName.substr(dot,fileName.length); 
	};

	function SearchAndReplace(Content, SearchFor, ReplaceWith){
	   var tmpContent = Content;
	   var tmpBefore = new String();   
	   var tmpAfter = new String();
	   var tmpOutput = new String();
	   var intBefore = 0;
	   var intAfter = 0;
	   if (SearchFor.length == 0) return;
	   while (tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase()) > -1) {
	      intBefore = tmpContent.toUpperCase().indexOf(SearchFor.toUpperCase());
	      tmpBefore = tmpContent.substring(0, intBefore);
	      tmpOutput = tmpOutput + tmpBefore;
	      tmpOutput = tmpOutput + ReplaceWith;
	      intAfter = tmpContent.length - SearchFor.length + 1;
	      tmpContent = tmpContent.substring(intBefore + SearchFor.length);
	   }
	   return tmpOutput + tmpContent;
	};
	
	function createCookie(name,value,days,allHosts){
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = '; expires='+date.toGMTString();
		}
		else var expires = '';
		if(allHosts == 1)document.cookie = name+'='+value+expires+'; domain=.'+getSubdomain()+'; path=/';
		else document.cookie = name+'='+value+expires+'; path=/';
		if (days == -1) {
			document.cookie = name+'='+value+expires+'; domain=.'+getSubdomain()+'; path=/';
		}
	};
	
	function readCookie(name) {
		var nameEQ = name + '=';
		var ca = document.cookie.split(';');
		for(var i=0;i<ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	};
	
	function eraseCookie(name){createCookie(name,'',-1);};
	
	function parseCookie() {
		var x = new Object();
		var y = readCookie('olio');
		if (y) {
			var tmp = y.split("|");
			if (tmp.length == 5) {
				x['userid'] = tmp[0]; 
				x['username'] = tmp[1];
				x['email'] = tmp[2];
				x['fname'] = tmp[3];
				x['lname'] = tmp[4];
			}
		}
		return x;
	};

	function getSubdomain() {
		var domainName = document.domain;
		var pieces = domainName.split('.');
		var subdomain = domainName;
		if (pieces.length > 1)
			subdomain = pieces[pieces.length-2] + '.' + pieces[pieces.length-1];
		return subdomain;
	};
		
	function loadScript(url, callback) {
		var f = arguments.callee;
		if (!("queue" in f))
			f.queue = {};
		var queue =  f.queue;
		if (url in queue) {
			if (callback) {
				if (queue[url])
					queue[url].push(callback);
				else
					callback();
			}
			return;
		}
		queue[url] = callback ? [callback] : [];
		var script = document.createElement("script");
		script.type = "text/javascript";
		if (/WebKit/i.test(navigator.userAgent)) {
			var _timer = setInterval(function() {
				if (/loaded|complete/.test(document.readyState)) {
					clearInterval(_timer);
					while (queue[url].length) {
						queue[url].shift()();
					}
					queue[url] = null;
				}
			}, 1000);
		} else {
			script.onload = script.onreadystatechange = function() {
				if (script.readyState && script.readyState != "loaded" && script.readyState != "complete")
					return;
				script.onreadystatechange = script.onload = null;
				while (queue[url].length) {
					queue[url].shift()();
				}
				queue[url] = null;
			};
		}
		script.src = url;
		document.getElementsByTagName("head")[0].appendChild(script);
	};
	
	// ip_xml.js
	function getPropertyNodeByName(object,name){try{var propertyNode=object.getElementsByTagName(get_firstchild(object).nodeName);var propertyLen=propertyNode.length; for(var j=0;j<propertyLen;j++){switch(getNodeAttribute(propertyNode[j],'name')){case name:return getNodeValue(propertyNode[j]);break;}}}catch(err){return '';}};
	function getNodeValueByChildName(node,childname){var tmpString='';try{if(node.getElementsByTagName(childname)[0].firstChild.nodeValue=='null'){ return '';}else{for(var i=0;i<node.getElementsByTagName(childname)[0].childNodes.length;i++){tmpString+=node.getElementsByTagName(childname)[0].childNodes[i].nodeValue;}}return tmpString;}catch(err){ return '';}};
	function getNodeValue(node){var tmpString='';try{for(var i=0;i<node.childNodes.length;i++){tmpString+=node.childNodes[i].nodeValue;}return tmpString;}catch(err){return '';}};
	function getNodeChildObj(obj,tag){var tmpString='';try{if(obj.getElementsByTagName(tag)[0].firstChild.nodeValue=='null'){return '';}else{return obj.getElementsByTagName(tag);}}catch(err){return '';}};
	function getNodeName(obj){return obj.firstChild.nodeName;};
	function getNodeAttribute(obj,attr) {try{return obj.getAttribute(attr);}catch(err){return '';}};
	function get_firstchild(n){try{var x=n.firstChild;while(x.nodeType!=1){x=x.nextSibling;}return x;}catch(err){return '';}};

	//ip_select.js
	function hasOptions(obj){return (obj!=null&&obj.options!=null) ? true : false;};
	function selectMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,'select',false);};
	function selectOnlyMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,'select',true);};
	function unSelectMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,'unselect',false);};
	function selectUnselectMatchingOptions(obj,regex,which,only) {
		if(window.RegExp){
			if(which=='select'){
				var selected1=true;
				var selected2=false;
			}
			else if(which=='unselect'){
				var selected1=false;
				var selected2=true;
			}
			else{
				return;
			}
			var re = new RegExp(regex);
			if(!hasOptions(obj)) return;
			for(var i=0;i<obj.options.length;i++){
				if(re.test(obj.options[i].text))
					obj.options[i].selected=selected1;
				else
					if(only==true) 
						obj.options[i].selected=selected2;
			}
		}
	};
	function removeSelectedOptions(from){
		if(!hasOptions(from))
			return;
		if(from.type=="select-one")
			from.options[from.selectedIndex]=null;
		else
			for(var i=(from.options.length-1);i>=0;i--){
				var o=from.options[i];
				if(o.selected)
					from.options[i]=null;
			}
		from.selectedIndex=-1;
	};
	function removeAllOptions(from){
		if(!hasOptions(from))
			return;
		for(var i=(from.options.length-1);i>=0;i--)
			from.options[i]=null;
		from.selectedIndex=-1;
	};
	function addOption(obj,text,value,selected){if(obj!=null&&obj.options!=null)obj.options[obj.options.length]=new Option(text,value,selected);};
	function removeOption(fOBJ,value){
		for(i=0;i<fOBJ.options.length;i++){
			if(fOBJ.options[i].value==value)
				fOBJ.options[i]=null;
		}
	};
	function getSelectList(fOBJ){
		var pars='';
		for(i=0;i<fOBJ.length;i++){
			if(i>0)
				pars=pars+',';
			pars=pars+fOBJ.options[i].value;
		}
		return pars;
	};
	function getSelectListSelected(fOBJ){
		var pars='';
		var count=0;
		for(i=0;i<fOBJ.length;i++){
			if(fOBJ.options[i].selected==true){
				if(count>0)
					pars=pars+',';
				count++;
				pars=pars+fOBJ.options[i].value;
			}
		}
		return pars;
	};
	function display_Select(sOptions,sSelected){
		var tmpData='';
		var x=sOptions.split(',');
		for(var i=0;i<x.length;i++){
			var sltcd='';
			var items=x[i].split('|');
			if(items[0]==sSelected)
				sltcd='selected="selected"';
			tmpData+='<option value="'+items[0]+'" '+sltcd+'>'+items[1]+'</option>';
		}
		return tmpData;
	};
	/*-- Adding Functionality for Send a Friend Pop-up --*/
	/* function prepareSendFriendLink(lnk, f) {
		if (lnk) {
			lnk.onclick = function() {
				if (f) {
				
					var s = $('response_panel');
					submit_FriendPopup(f, s);
				}
				return false;
			}
		}
	};
	function submit_FriendPopup(formObj,responseElem){
		if (!formObj) return false;
		if (checkForm(formObj)) {
			// var loc = window.location.href;
			/*
			if (!getMetaValue('siteIdentifier')) {
				var site = new Site();
				var site_id = site.getSiteId();
			} else {
				var site_id = getMetaValue('siteIdentifier');
			}
		
            // loc = loc.split('://');
            // var link = loc[1];
			var params = formObj.serialize();
			
			new Ajax.Request(
				'/ajax/sendFriend.jsp', 
				{
					parameters:'nC='+noCache()+'&'+params,   //+'&site_id='+site_id+'&link='+link,
					onSuccess: function(xml) 
					{
						Element.hide(formObj);
						if (responseElem) {
							var response = xml.responseXML.getElementsByTagName(get_firstchild(xml.responseXML.documentElement).nodeName);
							var responseContent = responseElem.innerHTML;
							if (getNodeValue(response[0]) == 'success') 
								responseElem.innerHTML = responseContent.replace('<!--response-->','Thank you, your message has been sent.');
							else
								responseElem.innerHTML = responseContent.replace('<!--response-->','Sorry there was a problem with your request. Please try again later.');
							Element.show(responseElem);
						}
					}
				}
			);
		} 
	};
	*/
	
	function submitEmail(frmObj, options){
	    if(checkForm(frmObj)){
	       new Ajax.Request('/ajax/sendEmail.jsp',{
	                        parameters: frmObj.serialize(),
	                        onComplete: function(xhr) {
	                            if(options && (options.onComplete)) options.onComplete();
	                        }
	                });
	    }
	}
	// ip_form.xml
	var dfltChars   = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.?-()[]+=_-;:/#@$%&!,*<>\"\'\n\r ';
	var dfltValue	= '';
	function checkForm(frmObj){
		
		var errFlag = false;
		$(frmObj).getElements()
				.reject(
					function(el){
						return !el.hasAttribute('required');
					}).each(
				    function(item) {
				        if(!checkElement(item).valid) {
				        	if(item.getAttribute('alert')!=null)
				        		
				        		alert( SearchAndReplace(item.getAttribute('alert'),'\\n','\n') );
				        	errFlag=true;
				        	throw $break;
				        }
				    }
				);
		return (errFlag) ? false : true;
	};
	function checkElement(el){
		try {
			if(el.getAttribute('id')) {
				el			= $(el);
		        oValue 		= $F(el);
		       	var oChars 	= (el.getAttribute('chars')!=null) ? el.getAttribute('chars') : dfltChars;
				var oMin 	= (el.getAttribute('minLen')!=null) ? el.getAttribute('minLen') : 1;
		        var oMax 	= (el.getAttribute('maxLen')!=null) ? el.getAttribute('maxLen') : 100;
		        var oMatch	= (el.getAttribute('match')!=null) ? el.getAttribute('match') : '';
		        	        
		        if( el.getAttribute('id').toLowerCase().indexOf('verify_email')>-1 && (  (oMatch!='' && ( $(oMatch)&&oValue.toLowerCase()!=$F(oMatch).toLowerCase() )) ) ) 
	            	return {valid: false, reason: 'no match'};
	            else if( el.getAttribute('id').toLowerCase().indexOf('email')>-1 ) 
	                return {valid: isValidEmail(oValue), reason: 'email'};
	            else if(oValue.length<oMin)
					return {valid: false, reason: 'short'};
				else if(oValue.length>oMax)
					return {valid: false, reason: 'long'};
				else if(!validate(oValue,oChars))
					return {valid: false, reason: 'invalid-character'};
	            else if( oMatch!='' && ( $(oMatch)&&oValue!=$F(oMatch) ) )
					return {valid: false, reason: 'no match'};
				else
					return {valid: true};
				
			}
		}
		catch(e) {return {valid: true}}

	};
	function isValidEmail(string){if(string.length<1)return false;if(string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)!=-1){return true;}else{return false;}};
	function validate(strVl,strChrs){if(!strVl) return false;if(strVl==dfltValue)return false;if(strVl.length<1)return false;for(i=0;i<strVl.length;i++){if(strChrs.indexOf(strVl.charAt(i))==-1)return false;}return true;};	
			 
	//ip_date.js
	function isDate(p_Expression){return !isNaN(new Date(p_Expression));};
	function dateAdd(p_Interval, p_Number, p_Date){
		if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
		if(isNaN(p_Number)){return "invalid number: '" + p_Number + "'";}	
		p_Number = new Number(p_Number);
		var dt = new Date(p_Date);
		switch(p_Interval.toLowerCase()){
			case "yyyy": {
				dt.setFullYear(dt.getFullYear() + p_Number);
				break;
			}
			case "q": {
				dt.setMonth(dt.getMonth() + (p_Number*3));
				break;
			}
			case "m": {
				dt.setMonth(dt.getMonth() + p_Number);
				break;
			}
			case "y":
			case "d":
			case "w": {
				dt.setDate(dt.getDate() + p_Number);
				break;
			}
			case "ww": {
				dt.setDate(dt.getDate() + (p_Number*7));
				break;
			}
			case "h": {
				dt.setHours(dt.getHours() + p_Number);
				break;
			}
			case "n": {
				dt.setMinutes(dt.getMinutes() + p_Number);
				break;
			}
			case "s": {
				dt.setSeconds(dt.getSeconds() + p_Number);
				break;
			}
			case "ms": {
				dt.setMilliseconds(dt.getMilliseconds() + p_Number);
				break;
			}
			default: {
				return "invalid interval: '" + p_Interval + "'";
			}
		}
		return dt;
	};
	function dateDiff(p_Interval, p_Date1, p_Date2, p_firstdayofweek, p_firstweekofyear){
		if(!isDate(p_Date1)){return "invalid date: '" + p_Date1 + "'";}
		if(!isDate(p_Date2)){return "invalid date: '" + p_Date2 + "'";}
		var dt1 = new Date(p_Date1);
		var dt2 = new Date(p_Date2);
		var iDiffMS = dt2.valueOf() - dt1.valueOf();
		var dtDiff = new Date(iDiffMS);
		var nYears  = dt2.getUTCFullYear() - dt1.getUTCFullYear();
		var nMonths = dt2.getUTCMonth() - dt1.getUTCMonth() + (nYears!=0 ? nYears*12 : 0);
		var nQuarters = parseInt(nMonths/3);	
		var nMilliseconds = iDiffMS;
		var nSeconds = parseInt(iDiffMS/1000);
		var nMinutes = parseInt(nSeconds/60);
		var nHours = parseInt(nMinutes/60);
		var nDays  = parseInt(nHours/24);
		var nWeeks = parseInt(nDays/7);
		var iDiff = 0;		
		switch(p_Interval.toLowerCase()){
			case "yyyy": return nYears;
			case "q": return nQuarters;
			case "m": return nMonths;
			case "y": 
			case "d": return nDays;
			case "w": return nDays;
			case "ww":return nWeeks;	
			case "h": return nHours;
			case "n": return nMinutes;
			case "s": return nSeconds;
			case "ms":return nMilliseconds;
			default: return "invalid interval: '" + p_Interval + "'";
		}
	};

	function datePart(p_Interval, p_Date, p_firstdayofweek, p_firstweekofyear){
		if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
		var dtPart = new Date(p_Date);
		switch(p_Interval.toLowerCase()){
			case "yyyy": return dtPart.getFullYear();
			case "q": return parseInt(dtPart.getMonth()/3)+1;
			case "m": return dtPart.getMonth()+1;
			case "y": return dateDiff("y", "1/1/" + dtPart.getFullYear(), dtPart);			// day of year
			case "d": return dtPart.getDate();
			case "w": return dtPart.getDay();	// weekday
			case "ww":return dateDiff("ww", "1/1/" + dtPart.getFullYear(), dtPart);		// week of year
			case "h": return dtPart.getHours();
			case "n": return dtPart.getMinutes();
			case "s": return dtPart.getSeconds();
			case "ms":return dtPart.getMilliseconds();	// millisecond	// <-- extension for JS, NOT available in VBScript
			default: return "invalid interval: '" + p_Interval + "'";
		}
	};
	// REQUIRES: isDate()
	// NOT SUPPORTED: firstdayofweek (does system default)
	function weekdayName(p_Date, p_abbreviate){
		if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
		var dt = new Date(p_Date);
		var retVal = dt.toString().split(' ')[0];
		var retVal = Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')[dt.getDay()];
		if(p_abbreviate==true){retVal = retVal.substring(0, 3)}	// abbr to 1st 3 chars
		return retVal;
	};
	// REQUIRES: isDate()
	function monthName(p_Date, p_abbreviate){
		if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
		var dt = new Date(p_Date);	
		var retVal = Array('January','February','March','April','May','June','July','August','September','October','November','December')[dt.getMonth()];
		if(p_abbreviate==true){retVal = retVal.substring(0, 3)}	// abbr to 1st 3 chars
		return retVal;
	};
	function DateAdd(p_Interval, p_Number, p_Date){return dateAdd(p_Interval, p_Number, p_Date);};
	function DateDiff(p_interval, p_date1, p_date2, p_firstdayofweek, p_firstweekofyear){return dateDiff(p_interval, p_date1, p_date2, p_firstdayofweek, p_firstweekofyear);};
	function DatePart(p_Interval, p_Date, p_firstdayofweek, p_firstweekofyear){return datePart(p_Interval, p_Date, p_firstdayofweek, p_firstweekofyear);};
	function getTimeFromDate(date_time){return hasZero(datePart('h', date_time)) + ":" + hasZero(datePart('n', date_time));};
	function parseDateObj(dateobj){
		var x = new Object();
		x['month'] = hasZero(dateobj.getMonth()-1);
		x['day'] = hasZero(dateobj.getDate());
		x['year'] = dateobj.getYear();
		x['hour'] = hasZero(dateobj.getHours());
		x['minute'] = hasZero(dateobj.getMinutes());
		x['second'] = hasZero(dateobj.getSeconds());
		return x;
	};
	function createDateObj(date_time){return new Date(Date.parse(date_time));};
	function convertTimeZone(dateObj, diff){
		var tmp = "";
		var plusminus = 1;
		if (diff.split("-").length > 1){
			tmp = diff.split("-")[1];
			plusminus = -1;
		} else if (diff.split("+").length > 1){
			tmp = diff.split("+")[1];
			plusminus = 1;
		}
		if (tmp.length){
			dateObj = dateAdd('n', plusminus * tmp.split(":")[1], dateObj);
			dateObj = dateAdd('h', plusminus * tmp.split(":")[0], dateObj);
		}
		return dateObj;
	};
	
	function convertToGMT(dateObj, diff){
		var tmp = "";
		var plusminus = 1;
		if (diff.split("-").length > 1){
			tmp = diff.split("-")[1];
			plusminus = 1;
		} else if (diff.split("+").length > 1){
			tmp = diff.split("+")[1];
			plusminus = -1;
		}
		if (tmp.length){
			dateObj = dateAdd('n', plusminus * tmp.split(":")[1], dateObj);
			dateObj = dateAdd('h', plusminus * tmp.split(":")[0], dateObj);
		}
		return dateObj;
	};
	function getServerTime() {
		var url = '/ajax/date.jsp';
		new Ajax.Request( url,
			{
				method:'get',
				asynchronous:false,
				parameters:'nC='+noCache(),
				onComplete:function(dt){
					server_time = dt.responseText;
				}
			}
		);
	};
	function convertHours(p_Date) {
	    if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
	    var regHr = p_Date.getHours();
	    if (regHr == 0) regHr = 12;
	    else if (regHr > 12) regHr -= 12;
	    return regHr;
	};
	function showAMPM(p_Date) {
		if(!isDate(p_Date)){return "invalid date: '" + p_Date + "'";}
	    var amPM;
	    if (p_Date.getHours() < 12) amPM = 'AM';
	    else amPM = 'PM';
	    return amPM;
	};
	function dateInRange(dx, begin, end) {
	    if (!isDate(dx) || !isDate(begin) || !isDate(end)) { return false; }
	    return (dateDiff('n', begin, dx) >= 0 && dateDiff('n', dx, end) >= 0)?true:false;
	};

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

	/**
	 * @author Ryan Johnson <ryan@livepipe.net>
	 * @copyright 2007 LivePipe LLC
	 * @package Control.Tabs
	 * @license MIT
	 * @url http://livepipe.net/projects/control_tabs/
	 * @version 2.1.1
	 */
	
	if(typeof(Control) == 'undefined')
		var Control = {};
	Control.Tabs = Class.create();
	Object.extend(Control.Tabs,{
		instances: [],
		findByTabId: function(id){
			return Control.Tabs.instances.find(function(tab){
				return tab.links.find(function(link){
					return link.key == id;
				});
			});
		}
	});
	Object.extend(Control.Tabs.prototype,{
		initialize: function(tab_list_container,options){
			this.activeContainer = false;
			this.activeLink = false;
			this.containers = $H({});
			this.links = [];
			Control.Tabs.instances.push(this);
			this.options = {
				beforeChange: Prototype.emptyFunction,
				afterChange: Prototype.emptyFunction,
				hover: false,
				linkSelector: 'li a',
				setClassOnContainer: false,
				activeClassName: 'active',
				defaultTab: 'first',
				autoLinkExternal: true,
				targetRegExp: /#(.+)$/,
				showFunction: Element.show,
				hideFunction: Element.hide
			};
			Object.extend(this.options,options || {});
			(typeof(this.options.linkSelector == 'string')
				? $(tab_list_container).getElementsBySelector(this.options.linkSelector)
				: this.options.linkSelector($(tab_list_container))
			).findAll(function(link){
				return (/^#/).exec(link.href.replace(window.location.href.split('#')[0],''));
			}).each(function(link){
				this.addTab(link);
			}.bind(this));
			this.containers.values().each(this.options.hideFunction);
			if(this.options.defaultTab == 'first')
				this.setActiveTab(this.links.first());
			else if(this.options.defaultTab == 'last')
				this.setActiveTab(this.links.last());
			else
				this.setActiveTab(this.options.defaultTab);
			var targets = this.options.targetRegExp.exec(window.location);
			if(targets && targets[1]){
				targets[1].split(',').each(function(target){
					this.links.each(function(target,link){
						if(link.key == target){
							this.setActiveTab(link);
							throw $break;
						}
					}.bind(this,target));
				}.bind(this));
			}
			if(this.options.autoLinkExternal){
				$A(document.getElementsByTagName('a')).each(function(a){
					if(!this.links.include(a)){
						var clean_href = a.href.replace(window.location.href.split('#')[0],'');
						if(clean_href.substring(0,1) == '#'){
							if(this.containers.keys().include(clean_href.substring(1))){
								$(a).observe('click',function(event,clean_href){
									this.setActiveTab(clean_href.substring(1));
								}.bindAsEventListener(this,clean_href));
							}
						}
					}
				}.bind(this));
			}
		},
		addTab: function(link){
			this.links.push(link);
			link.key = link.getAttribute('href').replace(window.location.href.split('#')[0],'').split('/').last().replace(/#/,'');
			this.containers[link.key] = $(link.key);
			link[this.options.hover ? 'onmouseover' : 'onclick'] = function(link){
				if(window.event)
					Event.stop(window.event);
				this.setActiveTab(link);
				return false;
			}.bind(this,link);
		},
		setActiveTab: function(link){
			if(!link)
				return;
			if(typeof(link) == 'string'){
				this.links.each(function(_link){
					if(_link.key == link){
						this.setActiveTab(_link);
						throw $break;
					}
				}.bind(this));
			}else{
				this.notify('beforeChange',this.activeContainer);
				if(this.activeContainer)
					this.options.hideFunction(this.activeContainer);
				this.links.each(function(item){
					(this.options.setClassOnContainer ? $(item.parentNode) : item).removeClassName(this.options.activeClassName);
				}.bind(this));
				(this.options.setClassOnContainer ? $(link.parentNode) : link).addClassName(this.options.activeClassName);
				this.activeContainer = this.containers[link.key];
				this.activeLink = link;
				this.options.showFunction(this.containers[link.key]);
				this.notify('afterChange',this.containers[link.key]);
			}
		},
		next: function(){
			this.links.each(function(link,i){
				if(this.activeLink == link && this.links[i + 1]){
					this.setActiveTab(this.links[i + 1]);
					throw $break;
				}
			}.bind(this));
			return false;
		},
		previous: function(){
			this.links.each(function(link,i){
				if(this.activeLink == link && this.links[i - 1]){
					this.setActiveTab(this.links[i - 1]);
					throw $break;
				}
			}.bind(this));
			return false;
		},
		first: function(){
			this.setActiveTab(this.links.first());
			return false;
		},
		last: function(){
			this.setActiveTab(this.links.last());
			return false;
		},
		notify: function(event_name){
			try{
				if(this.options[event_name])
					return [this.options[event_name].apply(this.options[event_name],$A(arguments).slice(1))];
			}catch(e){
				if(e != $break)
					throw e;
				else
					return false;
			}
		}
	});

	function compareDefaultTz(tz) {
		var defaultValue = getMetaValue('defaultTimeZone').split('GMT')[1];
		tz = tz.split('GMT')[1];
		defaultValue = parseFloat(defaultValue.replace(':', '.'));
		tz = parseFloat(tz);
		if (defaultValue == tz) {
			return 'same';
		} else if (defaultValue > tz) {
			return 'next';
		} else if (defaultValue < tz) {
			return 'previous';
		} else {
			return null;
		}
	};
	function addOverlay() {
		
       var overlay = Builder.node('div', {id: 'ue_overlay', style:'display: block;'});
       //var overlay = new Element('div').update('<span style="color:white">something</span>');
       //overlay.id = 'ue_overlay';
       //overlay.style.display='block';
             
       overlay.onclick = function() {
       		
        	if ($('ue_popup')) {
        		
        		var pos = getStyle($('ue_popup'), 'position');
        		closeEvPopup();
        		closeOverlay();
        		if(!document.all){        		
            		if (pos != 'fixed') {          		
            			$('filter_controls').style.visibility = 'visible';
            		}
        		}
            	
        	}
        }
       document.body.appendChild(overlay); 
       
	};
	function showOverlay() {
		
        if($('ue_overlay')){
        		try{
	                var overlay = $('ue_overlay');
                    overlay.style.height = pageHeight() + 'px';
	                overlay.style.width = pageWidth() + 'px';
	                Element.show(overlay);
	                //alert('tracking 82');
	                Event.observe(window, 'resize', adjustOverlay);
	                Event.stopObserving(window, 'resize', adjustOverlay);
	                //Event.observe(window, 'resize', function(){alert('ie goes crazy here')});
	                     
	                
        		}catch(err){
        			alert(err.description);
        		}
                           			
		}
	};
	function showEvPopup() {
		try{
	        if($('ue_popup')) {
	                var ue_popup = $('ue_popup');
	                if(ue_popup.style == 'undefined'){
	                	alert('error here!');
	                }
	                Element.show(ue_popup);
	                //alert('error right here!');
	                adjustEvPopup();
	                Event.observe(window, 'resize', adjustEvPopup);
	        }
        }
        catch(err){
        	alert(err.description);
        }
       
	};
	function closeEvPopup() {		
		if (!$('ue_popup')) {
			return false;
		}
		else {
			var ue_popup = $('ue_popup');
			if (ue_popup) {
				ue_popup.parentNode.removeChild(ue_popup);
			}
		};
		
	};
	function closeOverlay(){
		if (!$('ue_overlay')) {
			return false;
		}
		else {
			var overlay = $('ue_overlay');
			if (overlay) {
				overlay.parentNode.removeChild(overlay);
			}
		}	
	};
	function adjustOverlay() {
			if (!$('ue_overlay'))return false;
		    var overlay = $('ue_overlay');
			overlay.style.height = pageHeight() + 'px';
			overlay.style.width = pageWidth() + 'px';
	};
	function adjustEvPopup() {
			
	        if (!$('ue_popup')) return false;
	        var w = getWidth($('ue_popup'));
	        var h = getHeight($('ue_popup'));
	        
	        var position = getStyle($('ue_popup'), 'position');
	        if (position && position == 'fixed') {
	        	
	        	var t = (windowHeight() /2) - (h/2);
	       		var l = (windowWidth() / 2) - (w/2);
	        } else {
		        var t = scrollY() +(windowHeight() /2) - (h/2);
		        var l = scrollX() + (windowWidth() / 2) - (w/2);
	        }
	        if (t < 0) t = 0;
	        if (l < 0) l = 0;
	               
	        //If IE --> change position to absolute
	        if(document.all)$('ue_popup').style.position = 'absolute';
	        $('ue_popup').style.top = t + "px";
	        $('ue_popup').style.left = l + "px";             
	         
	};
	function getStyle(elem, name) {
	    if (elem) {
			if (elem.style[name]) 
				return elem.style[name];
			else 
				if (elem.currentStyle) 
					return elem.currentStyle[name];
				else 
					if (document.defaultView && document.defaultView.getComputedStyle) {
						name = name.replace(/([A-Z])/g, "-1$");
						name = name.toLowerCase();
						var s = document.defaultView.getComputedStyle(elem, "");
						return s && s.getPropertyValue(name);
					}
					else 
						return null;
		} 
	};
	function pageHeight(){return document.body.scrollHeight;};
	function pageWidth(){return document.body.scrollWidth;};
	function scrollX(){var de = document.documentElement;return self.pageXOffset || (de && de.scrollLeft) || document.body.scrollLeft;};
	function scrollY(){var de = document.documentElement;return self.pageYOffset || ( de && de.scrollTop) || document.body.scrollTop;};
	function getHeight(elem) {
	        if (getStyle(elem, 'display') != 'none')
	                return elem.offsetHeight || parseInt(getStyle(elem, 'height'));
	        var old = resetCSS(elem, {display:'', visibility:'hidden', position:'absolute'});
	        var h = elem.clientHeight || parseInt(getStyle(elem, 'height'));
	        restoreCSS(elem, old);
	        return h;
	};
	function getWidth(elem) {
	        if (getStyle(elem, 'display') != 'none')
	                return elem.offsetWidth || parseInt(getStyle(elem, 'width'));
	        var old = resetCSS(elem, {display:'', visibility:'hidden', position:'absolute'});
	        var w = elem.clientWidth || parseInt(getStyle(elem, 'width'));
	        restoreCSS(elem, old);
	        return w;
	};
	function resetCSS(elem, prop) {
	        var old = {};
	        for (var i in prop) {
	                old[i] = elem.style[i];
	                elem.style[i] = prop[i];
	        }
	        return old;
	};
	function restoreCSS(elem, prop) {
	        for (var i in prop)
	                elem.style[i] = prop[i];
	};
	function windowHeight() {
	        var de = document.documentElement;
	        return self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
	};
	function windowWidth() {
	        var de = document.documentElement;
	        return self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
	};
	function setSearchField(sField) {
		if (sField) {
			sField.onfocus = function() {
				this.value = '';
			}
			sField.onkeydown = function (e) {
				if (e) {
					if (e.keyCode == 13 && this.value.length) {
						window.location.href='http://www.fuse.tv/search-results.html?query='+this.value;
					}
				}
			}
		}
	};
	function setSearchGo(sField, sButton) {
		if (sButton) {
			sButton.onclick = function() {
				if (sField) {
					if (sField.value.length == 0) return false;
					else if (sField.value == 'SEARCH...') {
						window.location.href='http://www.fuse.tv/search-results.html';
					}
					else {
						window.location.href='http://www.fuse.tv/search-results.html?query='+sField.value;
					}
				} else {
					return false;
				}
			}
		}
	};
	function Site(loc){this.name=(loc)?loc.split('://')[1].split('/')[0]:window.location.href.split('://')[1].split('/')[0];};
	Site.sitesList={fuse: { live: /(prod.fuse.tv|cma.fuse.tv|preview.fuse.tv|fuse).tv/i }};
	Site.prototype.getSiteUrl = function() {return (this.name.match(Site.sitesList.fuse.live)) ? 'http://prod.fuse.tv/' : '' ;};
	Site.prototype.getSiteFolder = function() {return (this.name.match(Site.sitesList.fuse.live)) ? 'fuse' : 'fuse';};
	Site.prototype.getSiteId = function(){return (this.name.match(Site.sitesList.fuse.live)) ? 1 : 1;};
	Site.prototype.getTmPrefix=function(){};
	
	function closeEverything() {
		var pos = getStyle($('ue_popup'), 'position');
		closeEvPopup();
		closeOverlay();
		if(pos!= 'fixed'){$('filter_controls').style.visibility = 'visible';}
		return false;
	};
	
	/* end toolbar for tv schedule */
	function getUserLocation() {
		var value = readCookie('userLocation');
		var locInfo = { location: '', timezone: '', site: '' };
		if (value) {
			var pieces = value.split('__');
			locInfo.site = pieces[3] || '';
			locInfo.location = pieces[0] || '';
			locInfo.timezone = pieces[1] || '';
			locInfo.dropdownIndex = pieces[2] || '';
		}
		return locInfo;
	};
	function getUserLocale() {
		var uInfo = getUserLocation();
		if (document.location.hostname.indexOf(uInfo.site) < 0 || !uInfo.timezone || !uInfo.location) {
			uInfo.timezone = getMetaValue('defaultTimeZone');
			var value = readCookie('userLocation');
			if (value) {
				var pieces = value.split('__');
				uInfo.location = pieces[0];
			}
			else 
				uInfo.location = getMetaValue('siteCountry');
		}
		return  uInfo;
	};
	function xmlExtract(content, startTag, endTag) {
		var exContent = content.substring( content.indexOf(startTag), content.indexOf(endTag)+endTag.length );
		var xmlDoc;
		try { //IE
		    xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		    xmlDoc.loadXML(exContent);
		}
		catch(e) {
			try { //The Rest
		        xmlDoc = (new DOMParser()).parseFromString(exContent, "text/xml");
		  	}
		  	catch(e){}
		}
		return xmlDoc;
	};	
	function handleResponse(response){ //extract xml from HTML response or XML response - fix for JIVE FTL issue
		return (docRoot!='') ? xmlExtract(response.responseText.stripScripts(),'<xml>','</xml>') : response.responseXML;
	};
	
	
	/*
	Created By: Chris Campbell
	Website: http://particletree.com
	Date: 2/1/2006
	Inspired by the lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
	*/	
	//Browser detect script origionally created by Peter Paul Koch at http://www.quirksmode.org/
	
	function getBrowserInfo() {
		if (checkIt('konqueror')) {
			browser = "Konqueror";
			OS = "Linux";
		}
		else if (checkIt('safari')) browser 	= "Safari";
		else if (checkIt('omniweb')) browser 	= "OmniWeb";
		else if (checkIt('opera')) browser 		= "Opera";
		else if (checkIt('webtv')) browser 		= "WebTV";
		else if (checkIt('icab')) browser 		= "iCab";
		else if (checkIt('msie')) browser 		= "Internet Explorer";
		else if (!checkIt('compatible')) { 
			browser = "Netscape Navigator";
			version = detect.charAt(8);
		}
		else browser = "An unknown browser";
	
		if (!version) version = detect.charAt(place + thestring.length);
	
		if (!OS) {
			if (checkIt('linux')) OS 		= "Linux";
			else if (checkIt('x11')) OS 	= "Unix";
			else if (checkIt('mac')) OS 	= "Mac";
			else if (checkIt('win')) OS 	= "Windows";
			else OS 						= "an unknown operating system";
		}
	};
	
	function checkIt(string) {
		place = detect.indexOf(string) + 1;
		thestring = string;
		return place;
	};
	
	/*-----------------------------------------------------------------------------------------------*/
	Event.unloadCache = Prototype.emptyFunction 
	Event.observe(window, 'load', initialize, false);
	Event.observe(window, 'load', getBrowserInfo, false);
	Event.observe(window, 'unload', Event.unloadCache, false);
	
	var lightbox = Class.create();
	
	lightbox.prototype = {
		yPos : 0,
		xPos : 0,
		
		
		initialize: function(ctrl, params) {
		
			if (ctrl) {			
				//console.info(ctrl);
				this.content = ctrl.href;
				this.params = {};
				this.elem = ctrl;
				this.activateRef = this.activate.bindAsEventListener(this);
				if (ctrl.lbEvtQueue == undefined) {
					ctrl.lbEvtQueue = [this.activateRef];
				} else {
					ctrl.lbEvtQueue.push(this.activateRef);
				}
				if (ctrl.onclick) {	this.oldonclick = ctrl.onclick;	}
				Object.extend(this.params, params || {});
				Event.observe(ctrl, 'click', this.activateRef, false);
				ctrl.onclick = function(){return false;};
			}
			// Inert code
			//else function(){return false;}
	},
		
		// Turn everything on - mainly the IE fixes
		activate: function(event) {
			if (browser == 'Internet Explorer'&& navigator.appVersion.substr(22,3) == "6.0") {
				this.getScroll();
				this.prepareIE('100%', 'hidden');
				this.prepareIE('100%', 'hidden');
				this.setScroll(0,0);
				this.hideSelects('hidden');
			}
			this.displayLightbox("block");
		},
		
		// Ie requires height to 100% and overflow hidden or else you can scroll down past the lightbox
		prepareIE: function(height, overflow) {
			bod = document.getElementsByTagName('body')[0];
			bod.style.height = height;
			bod.style.overflow = overflow;
			htm = document.getElementsByTagName('html')[0];
			htm.style.height = height;
			htm.style.overflow = overflow; 
		},
		
		// In IE, select elements hover on top of the lightbox
		hideSelects: function(visibility) {
			selects = document.getElementsByTagName('select');
			for(i = 0; i < selects.length; i++) {
				selects[i].style.visibility = visibility;
			}
		},
		
		// Taken from lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
		getScroll: function() {
			if (self.pageYOffset) {
				this.yPos = self.pageYOffset;
			} else if (document.documentElement && document.documentElement.scrollTop){
				this.yPos = document.documentElement.scrollTop; 
			} else if (document.body) {
				this.yPos = document.body.scrollTop;
			}
		},
		
		setScroll: function(x, y) {
			window.scrollTo(x, y); 
		},
		
		displayLightbox: function(display) {
			$('overlay').style.display = display;
			if (!this.params.nodisplay || display == 'none') {
				if (display == 'none') {
					$('lightbox').style.top = null;
					$('lightbox').style.left = null;
					$('lightbox').style.width = null;
					$('lightbox').style.height = null;
				}
				$('lightbox').style.display = display;
			}
			if (this.params.nodisplay && display == 'block') {
				centerElem($('lightbox'));
				$('lightbox').style.display = 'block'; 
			}
			if (!this.params.noOverlayClick && display != 'none') {
				$('overlay').className = 'lbAction';
				$('overlay').rel = 'deactivate';
			}
			if (this.params.noOverlayClick) {
				$('overlay').className = '';
				$('overlay').rel = null;
				$('overlay').onclick = null;
			}
			if (display != 'none' && !this.params.noAjax) {
				this.loadInfo();
			}		
		},
		
		// Begin Ajax request based off of the href of the clicked linked
		loadInfo: function() {
			var myAjax = new Ajax.Request( this.content,
	        	{method: 'post', parameters: "", onComplete: this.processInfo.bindAsEventListener(this)});
	        	 
		},
		
		// Display Ajax response and Close Button
		processInfo: function(response) {
			if (this.params.nodisplay) $('lightbox').style.display = 'none';
			if ($('lbContent')) Element.remove($('lbContent'));
			info = "<div id='lbContent'>"+response.responseText+"</div>";
			if (screen.height <= 600) {
				var tmp = document.createElement('div');
				tmp.innerHTML = info;
				var close = $(tmp).getElementsByClassName('close')[0];
				close.next().addClassName('win800x600');
				
				//DEV HERE
				$('lightbox').style.left = '50%';
				info = tmp.innerHTML;
			}
			new Insertion.Before($('lbLoadMessage'), info);
			$('lightbox').className = "done";
			if (this.params.oncomplete) { this.params.oncomplete(); }
			this.actions();			
		},
		
		// Search through new links within the lightbox, and attach click event
		actions: function() {
			lbActions = $$('.lbAction');
			for(i = 0; i < lbActions.length; i++) {
				if (lbActions[i].id == 'overlay') {
					lbActions[i].onclick = this[lbActions[i].rel].bindAsEventListener(this);
				} else {
					Event.observe(lbActions[i], 'mousedown', this[lbActions[i].rel].bindAsEventListener(this), false);
					lbActions[i].onclick = function(){return false;};
					//alert('hit');
				}
			}
	
		},
		
		// Example of creating your own functionality once lightbox is initiated
		insert: function(e) {
		   var link = Event.element(e).parentNode;
		   Element.remove($('lbContent'));
		 
		   var myAjax = new Ajax.Request(
				  link.href,
				  {method: 'post', parameters: "", onComplete: this.processInfo.bindAsEventListener(this)}
		   );
		 
		},
		
		// Example of creating your own functionality once lightbox is initiated
		deactivate: function(e) {
			//alert('deactivate hit');
			if ($('lbContent')) Element.remove($('lbContent'));
			if (browser == "Internet Explorer" && navigator.appVersion.substr(22,3) == "6.0"){
				this.setScroll(0,this.yPos);
				this.prepareIE("auto", "auto");
				this.hideSelects("visible");
			}
			this.displayLightbox("none");
			$('lightbox').className = 'loading';
		},
		
		removeListener: function (restoreOld) {
			Event.stopObserving(this.elem, 'click', this.activateRef, false);
			if (restoreOld && this.oldonclick) {
				this.elem.onclick = this.oldonclick;
			}
		},
		
		flush: function () {
			while (this.elem.lbEvtQueue.length) {
				Event.stopObserving(this.elem, 'click', this.elem.lbEvtQueue.shift(), false);
			}
		}
	};
	/*-----------------------------------------------------------------------------------------------*/
	//kill lightbox
	function closeLightBox() {
		if(lightBox) lightBox.deactivate();
	};
	
	// Onload, make all links that need to trigger a lightbox active
	function initialize(){
		addLightboxMarkup(); 
		lbox = document.getElementsByClassName('lbOn');
		for(i = 0; i < lbox.length; i++) {
			valid = new lightbox(lbox[i]);
		}
	};
	
	// Add in markup necessary to make this work. Basically two divs:
	// Overlay holds the shadow
	// Lightbox is the centered square that the content is put into.
	function addLightboxMarkup() {
		bod 				= document.getElementsByTagName('body')[0];
		overlay 			= document.createElement('div');
		overlay.id		= 'overlay';	
		lb					= document.createElement('div');
		lb.id				= 'lightbox';
		lb.className 	= 'loading';
		lb.innerHTML	= '<div id="lbLoadMessage">' +
							  '<p>Loading</p>' +
							  '</div>';
		bod.appendChild(overlay);
		bod.appendChild(lb);
	};
	// ************** end of lightbox ************** //
	
	/**
	*  Base64 encode / decode  http://www.webtoolkit.info/
	**/
	
	var Base64 = {
	    // private property
	    _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
	
	    // public method for encoding
	    encode : function (input) {
	        var output = "";
	        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
	        var i = 0;
	
	        input = Base64._utf8_encode(input);
	
	        while (i < input.length) {
	
	            chr1 = input.charCodeAt(i++);
	            chr2 = input.charCodeAt(i++);
	            chr3 = input.charCodeAt(i++);
	
	            enc1 = chr1 >> 2;
	            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
	            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
	            enc4 = chr3 & 63;
	
	            if (isNaN(chr2)) {
	                enc3 = enc4 = 64;
	            } else if (isNaN(chr3)) {
	                enc4 = 64;
	            }
	
	            output = output +
	            this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
	            this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
	
	        }
	
	        return output;
	    },
	
	    // public method for decoding
	    decode : function (input) {
	        var output = "";
	        var chr1, chr2, chr3;
	        var enc1, enc2, enc3, enc4;
	        var i = 0;
	
	        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
	
	        while (i < input.length) {
	
	            enc1 = this._keyStr.indexOf(input.charAt(i++));
	            enc2 = this._keyStr.indexOf(input.charAt(i++));
	            enc3 = this._keyStr.indexOf(input.charAt(i++));
	            enc4 = this._keyStr.indexOf(input.charAt(i++));
	
	            chr1 = (enc1 << 2) | (enc2 >> 4);
	            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
	            chr3 = ((enc3 & 3) << 6) | enc4;
	
	            output = output + String.fromCharCode(chr1);
	
	            if (enc3 != 64) {
	                output = output + String.fromCharCode(chr2);
	            }
	            if (enc4 != 64) {
	                output = output + String.fromCharCode(chr3);
	            }
	
	        }
	
	        output = Base64._utf8_decode(output);
	
	        return output;
	
	    },
		    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }
	}

// parseAdXML -- parses ad xml from Brightcove player
function parseAdXML(input) {
  var xmlDoc = {};
  try { //Internet Explorer
    xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async="false";
    xmlDoc.loadXML(input);
  } catch(e) {
    try { //Firefox, Mozilla, Opera, etc.
      parser=new DOMParser();
      xmlDoc=parser.parseFromString(input,"text/xml");
    } catch(e) {
      alert(e.message);
    }
  }
  return xmlDoc;
}

// onAdComplete -- handles Brightcove AdComplete event.
function onAdComplete(message){
  setTimeout("document.getElementById('ad300x250').innerHTML = adOrigInnerHTML;", 15*1000);
}


// replaceBannerWithCoad -- replaces innerHTML of specified element with iframe tag from AdXML
function replaceBannerWithCoad(elementID, clickURL, bannerURL) {
  
  var url = typeof(ad.url) ? ad.url : 'homepage';
  var kwMatches = bannerURL.match(/;kw[^;]+/);
  var kw = kwMatches[0];
  
  var iframeTag = '<iframe src="http://ad.doubleclick.net/adi/cablevision.video.fuse' + url + kw + ';ftv=ad;pos=pre;sz=300x250;tile=2;ord=' + ord + '?" width="300" height="250" marginwidth="0" marginheight="0" frameborder="0" scrolling="no"></iframe>';
  document.getElementById(elementID).innerHTML = iframeTag;
  return true;
}

// called as an event by Brightcove player when config["externalAds"] is true
function playAd(adXML, callback) {
  try {
    // get stuff from xml
    prerollAdXmlDoc = parseAdXML(adXML);
    
    // banner vars to play the companion banner externally
    var expandedBannerURL = prerollAdXmlDoc.getElementsByTagName('expandedBannerURL')[0].childNodes[0].nodeValue;
    var expandedBannerClickURL = prerollAdXmlDoc.getElementsByTagName('expandedBannerClickURL')[0].childNodes[0].nodeValue;

    // replace 300 ad spot with companion banner
    adOrigInnerHTML = document.getElementById('ad300x250').innerHTML;
    replaceBannerWithCoad('ad300x250', expandedBannerClickURL, expandedBannerURL);
    
    var commaExplodeRegex = /[^,]+/;
    
    // ad object to pass back to the player
    
    var prerollAd = new Object();
    prerollAd.type = "videoAd";
    prerollAd.videoURL = "";
    prerollAd.videoClickURL = "";
    prerollAd.trackStartURLs = new Array();
    prerollAd.trackMidURLs =  new Array();
    prerollAd.trackEndURLs = new Array();
    prerollAd.trackPointTime = "";
    prerollAd.trackPointURLs =  new Array();
    prerollAd.version = "";
    prerollAd.duration = 0;
    
    prerollAd.videoURL = prerollAdXmlDoc.getElementsByTagName('videoURL')[0].childNodes[0].nodeValue;
    prerollAd.videoClickURL = prerollAdXmlDoc.getElementsByTagName('videoClickURL')[0].childNodes[0].nodeValue;
    prerollAd.trackStartURLs = prerollAdXmlDoc.getElementsByTagName('SynchedBanner468x60')[0].getAttribute('trackStartURLs').match(commaExplodeRegex);
    prerollAd.trackMidURLs = prerollAdXmlDoc.getElementsByTagName('SynchedBanner468x60')[0].getAttribute('trackMidURLs').match(commaExplodeRegex);
    prerollAd.trackEndURLs = prerollAdXmlDoc.getElementsByTagName('SynchedBanner468x60')[0].getAttribute('trackEndURLs').match(commaExplodeRegex);
    prerollAd.trackPointTime = prerollAdXmlDoc.getElementsByTagName('SynchedBanner468x60')[0].getAttribute('trackPointTime');
    prerollAd.trackPointURLs = prerollAdXmlDoc.getElementsByTagName('SynchedBanner468x60')[0].getAttribute('trackPointURLs').match(commaExplodeRegex);
    prerollAd.version = prerollAdXmlDoc.getElementsByTagName('SynchedBanner468x60')[0].getAttribute('version');
    prerollAd.duration = prerollAdXmlDoc.getElementsByTagName('SynchedBanner468x60')[0].getAttribute('duration');

    // play ad in the video player
    callbackFlash(callback);
    callFlash("addEventListener", "adComplete", "onAdComplete"); 
    callFlash('playAd', prerollAd);
    
  } catch(e) {
    callbackFlash(callback);
  }
}
	
function renderNavIE(folder,div_id,highlight_id){
	if(document.getElementById(div_id)){
		new Ajax.Request(folder + 'subnav.xml',{
			method: 'get',
			parameters:'nC='+noCache(),
			onFailure:ajaxRequest_Error,
			onSuccess:function(t){
				var mainNav = $(div_id);
				var xmlObj = new ActiveXObject("Microsoft.XMLDOM");
				xmlObj.async="false";
				xmlObj.loadXML(t.responseText);
				mainNav.innerHTML=renderSubNavigation(xmlObj,0,highlight_id);
				mainNav.firstChild.lastChild.firstChild.className += ' last';
				setSeatingId();
				$$('div#' + div_id + ' ul#nav ul').each(function(e) {
					e.previous('a').addClassName('active');
					}
				);
				var el = document.getElementById("nav");
				if(!/\bnav\b/.test(el.className) && el.tagName == "UL")
					setIeHover(el);
				var ieNavs = document.getElementsByTagName('ul');
				for(i=0; i<ieNavs.length; i++) {
					var ul = ieNavs[i];
					if(/\bnav\b/.test(ul.className))
						setIeHover(ul);
				}
			}
		});	
	}
};

function renderNav(folder,div_id,highlight_id){
	if(document.getElementById(div_id)){
		var xmlPath = folder + 'subnav.xml';
		new Ajax.Request(xmlPath,{
			method: 'get',
			parameters:'nC='+noCache(),
			onFailure:ajaxRequest_Error,
			onSuccess:function(t){
				var mainNav = $(div_id);
				var xmlObj;
				if (document.all)
				{
					xmlObj = new ActiveXObject("Microsoft.XMLDOM");
					xmlObj.async="false";
					xmlObj.loadXML(t.responseText);
				}
				else
				{
					xmlObj = (new DOMParser()).parseFromString(t.responseText, 'text/xml');
				};
				mainNav.innerHTML=renderSubNavigation(xmlObj,0,highlight_id);
				mainNav.firstChild.lastChild.firstChild.className += ' last';
				setSeatingId();
				$$('div#' + div_id + ' ul#nav ul').each(function(e) {
					e.previous('a').addClassName('active');
					}
				);
			}
		});	
	}
};	

function renderSubNavigation(req,parent_id,highlight_id){
	var tmp			= '';
	var subTmp		= '';
	var subNodes	= '';
	var k			= req.responseXML ? req.responseXML.getElementsByTagName('nav') : req.getElementsByTagName('nav');
	var navLen		= k.length;
	var topLevelCnt	= 0;
	var highlight = '';
	for(var j=0;j<k.length;j++){
		tmp					= '';
		subNodes			= '';
		var nLabel			= getNodeAttribute(k[j],'label');
		var nUrl			= getNodeAttribute(k[j],'url');
		var popup			= getNodeAttribute(k[j],'popup');
		var popupWidth		= getNodeAttribute(k[j],'width');
		var popupHeight		= getNodeAttribute(k[j],'height');
		var popupScroll		= getNodeAttribute(k[j],'scroll');
		var popupToolbar	= getNodeAttribute(k[j],'toolbar');
		var popupResize		= getNodeAttribute(k[j],'resize');
		var nParent			= getNodeAttribute(k[j],'parent_id');
		var nOrder			= getNodeAttribute(k[j],'order');
		var nId				= getNodeAttribute(k[j],'nav_id');
		var topImg			= 'top_'+nId;
		if(nParent==parent_id){
			if(parent_id==0){
				topLevelCnt++;
				highlight = topLevelCnt == highlight_id ? ' activate' : '';
				tmp = (popup=='1') ? '<a class="item'+ topLevelCnt + ' ' + highlight + '" href="' + nUrl + '" target="_blank">' : '<a class="item'+ topLevelCnt + ' ' + highlight + '" href="'+nUrl+'" target="_top">';
				tmp += '<span>' + nLabel + '</span></a>';
				subNodes = renderMainNavigation_sub1(req,nId,topImg);
				if(subNodes!='')
					tmp+='<ul>'+subNodes+'</ul>';
			}
		}
		if(tmp!='')
			subTmp += '<li class="item'+ topLevelCnt + '">'+tmp+'</li>';
	}
	return '<ul id="subnav" class="nav">'+subTmp+'</ul>';
};


function requiredLoginAnchor(){
	$$('a[url]').each(
			function(item){
				if(item.getAttribute('url') != ''){
					
					//check if user is logged in
					if(!user.isAuthenticated()){	
						var url = item.getAttribute('url');
						item.setAttribute('onclick','return false;');
						item.setAttribute('action','login');
						item.setAttribute('class','modal');
						item.setAttribute('href','/ipui/demandlets/layout/modal_login.html');
					
						var lightBox = new lightbox(item, {oncomplete: function () {
								user.action('login');
								createCookie('fowardUrl',url,1,1)
								
						}});
					}else if(user.isAuthenticated() && readCookie('fowardUrl') != ''){
						item.setAttribute('href',item.getAttribute('url'));
					}
					//item.setAttribute('url','');
				} 
			});
};

//check if enter key is pressed
function enterKeyPressed(element,evt){
	evt = (evt) ? evt : event;
	var charCode = (evt.charCode) ? evt.charCode:((evt.which) ? evt.which : evt.keyCode);
	if(charCode == 13){
		return true;
	}
	return false;
}
 
