var rhapPlayer;
var theScreenWidth = screen.width;
var theScreenHeight = screen.height;
var openFromLeftAt = (theScreenWidth-290);

function resizeWindowInnerSize( width, height ) {
	if( navigator.userAgent.toLowerCase().indexOf("chrome")>=0 ) {
		var diffw = window.outerWidth - window.innerWidth;
		var diffh = window.outerHeight - window.innerHeight;
		return window.resizeTo( width + diffw, height + diffh );
		return;
	}
	else {
		window.resizeTo( width, height );
		var diffw = width - ((typeof window.innerWidth == 'undefined')?document.documentElement.clientWidth:window.innerWidth);
		var diffh = height - ((typeof window.innerHeight == 'undefined')?document.documentElement.clientHeight:window.innerHeight);
		return window.resizeTo( width + diffw, height + diffh );
	}
}

function fixNameForJS( theName ) {
	theName = theName.replace(/\'/g,"&#39;");
	theName = theName.replace(/\"/g,"&quot;");
	return theName;
}


function fixNameForHtml( theName ) {
	theName = theName.replace(/</g,"&lt;");
	theName = theName.replace(/>/g,"&gt;");
	return theName;
}

function wmpDetect(){
	try {
		if(window.external.version && window.external.version !== "" && window.external.version != "undefined"){
			setWMPDetectCookie();
		}
	} catch (e) {
		
	}
}

wmpDetect();

var RhapsodyUtility = {
	meddlesomeElements: [ 'ad_homepageSlideshow', 'homepageBillboardAd', 'ad_homepageBillboardAd_holder', 'query', 'searchtype', 'ad_C2', 'ad_C2_holder', 'ad_B1', 'ad_subnavPromoSpotAkaTheHat', 'ad_adTall_holder', 'videoPlaybackAdSpace','hasPlayerTrue'],
	getCheckboxes: function getCheckboxes() {
		var node_list = document.getElementsByTagName('input');
		var items = [];
		for (var i=0; i < node_list.length; i++) {
		  var node = node_list[i];
		  if (node.getAttribute('type') == 'checkbox') {
			items.push(node);
		  }
		}
		return items;
	},
	getSystemClockDeltaFromCookie: function(){
		var toReturn = CookieManager.hasCookie( 'srvrDelta', CookieManager.PERMANENT_USER )? CookieManager.getCookie( 'srvrDelta', CookieManager.PERMANENT_USER ): null;
		return parseInt( toReturn, 10 );
	},
	setSystemClockDeltaToCookie: function( systemDate, serverDate ){
		var storedServerDate = CookieManager.getCookie( 'srvrDt', CookieManager.PERMANENT_USER );
		if( storedServerDate != serverDate.getTime() ){
			var newDelta = serverDate - systemDate;
			CookieManager.setCookie( 'srvrDt', serverDate.getTime() );
			CookieManager.setCookie( 'srvrDelta',  newDelta );
			return newDelta;
		} else { return this.getSystemClockDeltaFromCookie(); }
	},
	getChildrenByClassName: function( theElement, theClassName ){
		var elementsToReturn = [];
		if( typeof theElement == 'string' ){ theElement = document.getElementById( theElement ); }
		for( var i=0; i<theElement.childNodes.length; i++ ){
			var elementsClassName = theElement.childNodes[i].className;
			if( typeof elementsClassName == 'string' ){
				if( ( elementsClassName == theClassName )
				|| ( elementsClassName.match( ' ' + theClassName ) )
				|| ( elementsClassName.match( theClassName + ' ' ) )
				) {
					elementsToReturn.push( theElement.childNodes[i] );
				}
			}
		}
		return elementsToReturn.length > 0 ? elementsToReturn : null;
	},
	getChildrenByTagName: function( theElement, theTagName ){
		var elementsToReturn = [];
		for( var i=0; i<theElement.childNodes.length; i++ ){
			if( theElement.childNodes[i].tagName == theTagName ){ elementsToReturn.push( theElement.childNodes[i] ); }
		}
		return elementsToReturn.length > 0 ? elementsToReturn : null;
	},
	addLoadEvent: function(func){
	    var oldonload = window.onload;
	    if (typeof window.onload != 'function') {
	        window.onload = func;
	    } else {
	        window.onload = function(){
	            oldonload();
	            func();
	        };
	    }
	},
	isArray: function(arr){
		if( ( typeof arr == 'object' ) && ( typeof arr.pop != 'undefined' ) ){ return true; }
		else{ return false; }
	},
	addEvent: function( theElement, theEvent, theCallback ){
		if( theElement.addEventListener ){
			theElement.addEventListener( theEvent, theCallback, false );
		}
		else if( theElement.attachEvent ){
			theElement.attachEvent( "on" + theEvent, theCallback );
		} else { return; }
	},
	setAlpha: function( theElement, percentage ) {
		if( typeof theElement == 'string' ){ theElement = document.getElementById( theElement ); }
		if( typeof theElement.style.opacity != 'undefined' ){
			theElement.style.opacity = percentage / 100;
		}
		else if( typeof theElement.style.filter != 'undefined' ){
			theElement.style.filter = "alpha(opacity=" + percentage + ")";
		}
	},
	doFadein: function( theElementId, maximum, speedMulitplier, start ){
		var theSpeedMultiplier = speedMulitplier ? speedMulitplier : 1;
		var theStart = start? start: 0;
		RhapsodyUtility.setAlpha( theElementId, theStart );
		for( var i=0 + theStart; i <= maximum; i += 3 ) {
			var doFadeinTO = setTimeout( "RhapsodyUtility.setAlpha('" + theElementId + "'," + i + ")", ( i * 8 ) / theSpeedMultiplier );
		}
		var doFadeinTO = setTimeout( "RhapsodyUtility.setAlpha('" + theElementId + "'," + maximum + ")", ( maximum * 8 ) / theSpeedMultiplier );
	},
	doFadeout: function( theElementId, maximum, speedMultiplier ) {
		var theSpeedMultiplier = speedMultiplier ? speedMultiplier : 1;
		var i;
		for( i=maximum; i <= 100 ; i += 3 ) {
			var doFadeoutTO = setTimeout( "RhapsodyUtility.setAlpha('" + theElementId + "'," + ( 100 - i ) + ")", i * 8 / theSpeedMultiplier );
		}
		var doFadeoutTO = setTimeout( "RhapsodyUtility.setAlpha('" + theElementId + "',0)", i * 8 / theSpeedMultiplier );
	},
	doBuildMask: function( theElementToMask ){
		if( typeof theElementToMask == 'string' ){ theElementToMask = document.getElementById( theElementToMask ); }
		var maskElement = document.createElement( "DIV" );
		var maskElementText = document.createTextNode( " " );
		var maskElementWidth = theElementToMask.offsetWidth;
		var maskElementHeight = theElementToMask.offsetHeight;
		maskElement.appendChild( maskElementText );
		maskElement.className = "maskElement";
		maskElement.style.width = maskElementWidth + "px";
		maskElement.style.height = maskElementHeight + "px";
		theElementToMask.parentNode.insertBefore( maskElement, theElementToMask );
		RhapsodyUtility.setAlpha( maskElement, 80 );
		return maskElement;
	},
	setSliderThingie: function( theX, theY, theWidth, theHeight ) {
		var theSliderThing = document.getElementById( "topNavSliderThing" );
		theSliderThing.style.visibility = ( theWidth && theHeight )? "visible" : "hidden";
		theSliderThing.style.left = theX + "px";
		theSliderThing.style.top = theY + "px";
		theSliderThing.style.width = theWidth + "px";
		theSliderThing.style.height = theHeight + "px";
	},
	getLeft: function( element ) {
		if( element ) {
			return element.offsetLeft + RhapsodyUtility.getLeft(element.offsetParent);
		}
		else{ return 0; }
	},
	getTop: function( element ) {
		if( element ) {
			return element.offsetTop + RhapsodyUtility.getTop(element.offsetParent);
		}
		else{ return 0; }
	},
	doThrob: function( theElementId, fromElement ) {
		var numBlinks = 10;
		var blinkMsec = 200;
		var theTargetElement = document.getElementById( theElementId );
		var theSliderThing = document.getElementById( "topNavSliderThing" );
		
		if( theTargetElement && fromElement && theSliderThing ) {
			var theToX = RhapsodyUtility.getLeft(theTargetElement) + theTargetElement.clientWidth / 2;
			var theToY = RhapsodyUtility.getTop(theTargetElement) + theTargetElement.clientHeight / 2;

			var theFromX = fromElement.offsetLeft + document.body.scrollLeft;
			var theFromY = fromElement.offsetTop + document.body.scrollTop;
			var theWidth = fromElement.clientWidth;
			var theHeight = fromElement.clientHeight;

			var numSteps = 25;
			var amountOfTime = 500;
			
			var theDeltaX = (theToX - theFromX) / numSteps;
			var theDeltaY = (theToY - theFromY) / numSteps;
			var theDeltaWidth = theWidth / numSteps;
			var theDeltaHeight = theHeight / numSteps;
			
			for( var i=0 ; i <= numSteps ; i++ ) {
				var thisX = theFromX + i*theDeltaX;
				var thisY = theFromY + i*theDeltaY;
				var thisWidth = theWidth - i*theDeltaWidth;
				var thisHeight = theHeight - i*theDeltaHeight;
				setTimeout( "RhapsodyUtility.setSliderThingie("+thisX+","+thisY+","+thisWidth+","+thisHeight+")", i * amountOfTime / numSteps );
			}
			setTimeout( "RhapsodyUtility.setSliderThingie(0,0,0,0)", amountOfTime );

			for( var i=0 ; i<numBlinks ; i++ ) {
				var theColor = i%2 ? "#e0e0e0" : "#d8d8d8";
				setTimeout( "document.getElementById('" + theElementId + "').style.backgroundColor = '" + theColor + "'", i * blinkMsec + amountOfTime );
			}
			setTimeout( "document.getElementById('" + theElementId + "').style.backgroundColor = '#EFEFEF'", numBlinks * blinkMsec + amountOfTime );
		}
	},
	/**
	* @method toggleMeddlesomeElements
	* @param {boolean} showOnly (Optional)
	* @return {String} Returns a string value containing name and greeting
	* @description show or hide meddlesome elements on a page
	* @note the input param is optional by design. If you omit the input param, it should just toggle between visible and hidden states for the visibility style of the meddlesome elements
	*/
	toggleMeddlesomeElements: function( showOnly ){	
		var elementsToToggleIds = this.meddlesomeElements;
		var ettidsLength = elementsToToggleIds.length;
		for( var i=0; i < ettidsLength; i++ ){
			var elementToToggle = document.getElementById( elementsToToggleIds[ i ] );
			if( elementToToggle && ( typeof elementToToggle != 'undefined' ) ){
				if( elementToToggle.style.visibility == 'hidden' ){//if the elementToToggle has the visibility style defined and it is hidden, make it visible.
					elementToToggle.style.visibility = 'visible';
				}
				else if( !showOnly ){//if the elementToToggle does not have the visibility style defined and the element should not be shown, make its visibility style hidden.
					elementToToggle.style.visibility = 'hidden';
				}
				else { return; }
			}
		}
	},
	getBrowserOs: function(){
		var os = null;
		if( navigator.appVersion.indexOf( 'Win' ) != -1 ) os = "Windows";
		else if( navigator.appVersion.indexOf( 'Mac' ) != -1 ) os = "Macintosh";
		else if( ( navigator.appVersion.indexOf( "X11" ) != -1 ) || ( navigator.appVersion.indexOf( "Linux" ) != -1 ) ) os = "Unix";
		else os = "other";
		return os;
	},
	Client: {
		isIE6: function(){
			return ( window.external && typeof window.XMLHttpRequest == "undefined" );
		},
		isFirefox: function(){
			return ( navigator.userAgent.toLowerCase().indexOf( "firefox" ) > -1 );
		}
	},
	StringUtil: {
		truncateTextByElement: function( elemId, maxChars, cutClean) { //hasn't been used.  needs to be tested
			var clipElement = document.getElementById( elemId) ;
			var clipContents = clipElement.innerHTML;
			var origLength = clipContents.length;
			clipContents = clipContents.substring( 0, maxChars );
			if( origLength > ( maxChars + 4 ) ){
				if(cutClean){
					clipContents = clipContents.replace(/\w+$/, '...');
				}else{
					clipContents = clipContents+"...";
				}
			}
			clipElement.innerHTML = clipContents;
		},
		truncateTextString: function( text, maxChars, cutClean ){
			var resultText = text.substring( 0, maxChars );
			if( text.length > ( maxChars + 4 ) ){
				if(cutClean){
					resultText = resultText.replace(/\w+$/, '...');
				}else{
					resultText = resultText+"...";
				}
			}
			return resultText;
		}
	},
	Node: {
		getNextSiblingByType: function( nextFromElement, theNodeType ){
			do{
				nextFromElement = nextFromElement.nextSibling;
			}
			while( nextFromElement && nextFromElement.nodeType != theNodeType )
			return nextFromElement?nextFromElement:null;
		}
	},
	Ajax: {
		includeHtml: function( argObj ){
			var theTarget = argObj.target;
			var theAjaxParameters = ( typeof argObj.params != 'undefined' )? argObj.params: null;
			var disableShowError = ( ( typeof argObj.disableShowError != 'undefined' ) && ( argObj.disableShowError ) );
			var passedSuccessCallback = ( typeof argObj.successCallback != 'undefined' )? argObj.successCallback: null;
			if( typeof theTarget == 'string' ) theTarget = document.getElementById( argObj.target );
			var theAjaxCall = function(){
				if( argObj.useLoadMessage ){
					if( argObj.useLoadMessageVariant ){
						theTarget.innerHTML = RhapsodyUtility.Ajax.getSpinnerHtml( null, argObj.useLoadMessageVariant);
					} else theTarget.innerHTML = RhapsodyUtility.Ajax.getSpinnerHtml();
				}
				
				theTarget.style.display = "block";
				theTarget.style.visibility = "visible";
				
				var ajaxReq = new Ajax.Request(
					argObj.ajaxUrl, {
					method: 'get',
					parameters: theAjaxParameters,
					onSuccess: function( theRequest ){
						theTarget.ajaxStatus = "success";
						theTarget.innerHTML = theRequest.responseText;
						var innerScripts = theTarget.getElementsByTagName( "SCRIPT" );
						if( innerScripts ) {
							for( var i=0; i<innerScripts.length ; i++ ) {
								eval( innerScripts[i].innerHTML );
							}
						}
						if( passedSuccessCallback ){ passedSuccessCallback() };
					},
					onFailure: function( theRequest ){
						theTarget.innerHTML = "";
						if( !disableShowError ){
							RhapsodyUtility.Ajax.writeErrorInElement( argObj.target, theAjaxCall );
						}
					},
					onException: function( e ){
						//alert( e );
					}
				} );

				theTarget.ajaxStatus = "loading";
				
				if( argObj.timeoutMillis && !disableShowError ) {
					theTarget.theAjaxCall = theAjaxCall;
					setTimeout( "RhapsodyUtility.Ajax.tryTimeout('" + argObj.target + "')", argObj.timeoutMillis );
				}
			}
			if( theTarget.innerHTML.length > 10 && !argObj.forceReload ) {
				theTarget.style.display = "block";
				theTarget.style.visibility = "visible";
			} else theAjaxCall();
		},
		writeErrorInElement: function( elementId, theAjaxCall ) {
			var theTarget = document.getElementById(elementId);
			theTarget.ajaxStatus = "error";
			theTarget.innerHTML = "";
			var errorText = document.createTextNode( "We are sorry, there was an error retrieving your content. " );
			var errorDiv = document.createElement( "DIV" );
			var errorLink= document.createElement( "A" );
			var errorLinkText = document.createTextNode( "Click here to try again" );
			var tryAgainFunc = function(){
				theAjaxCall();
				return false;
			}
			if( errorLink.addEventListener ){
				errorLink.href = "javascript:void();";
				errorLink.addEventListener( "click", tryAgainFunc, false );
			}
			else if( errorLink.attachEvent ){
				errorLink.attachEvent( "onclick", tryAgainFunc );
				errorLink.setAttribute( "href", "javascript:void();" );
			} else return;
			errorLink.appendChild( errorLinkText );
			errorDiv.className = "ajaxError";
			errorDiv.appendChild( errorText );
			errorDiv.appendChild( errorLink );
			theTarget.appendChild( errorDiv );
		},
		getSpinnerHtml: function( message, variant ){
			var theMessage = 'Loading';
			var theImageSrc = staticPath;
			var toReturn = "";
			theImageSrc += ( variant && ( typeof variant != 'undefined' ) )? 'images\/loading_spin_' + variant + '.gif': 'images\/loading_spin_alt_grey.gif';
			if( ( message != null ) && ( typeof message != 'undefined' ) ){ theMessage = message };
			toReturn = '<div class="loadingSpin"><img src="' + theImageSrc + '" \/>';
			if( theMessage !== "" ){
				toReturn += '<br \/>' + theMessage + '...';
			}
			toReturn += '<\/div>';
			return toReturn;
		},
		tryTimeout: function( elementId ) {
			var theTarget = document.getElementById(elementId);
			var theAjaxCall = theTarget.theAjaxCall;
			if( theTarget.ajaxStatus == "loading"  ) {
				theTarget.ajaxStatus = "timeout";
				RhapsodyUtility.Ajax.writeErrorInElement( elementId, theAjaxCall );
			}
		}
	}
}

function AjaxManager() {
	this.onError = function (data){Ajax.Responders.dispatch('AjaxManagerOnError', null, null, data); };
	this.onTransportError = function (data){Ajax.Responders.dispatch('AjaxManagerOnError', null, null, data); };
	this.onContacting = function(){Ajax.Responders.dispatch('AjaxManagerOnContacting', null, null, null);};
	this.onGetRating = function(data){Ajax.Responders.dispatch('AjaxManagerOnGetRating', null, null, data);};
	this.onSetRating = function(data){Ajax.Responders.dispatch('AjaxManagerOnSetRating', null, null, data);};
	this.onGetVideoPlaylist = function(data){Ajax.Responders.dispatch('AjaxManagerOnGetVideoPlaylist', null, null, data);};
	this.onGetClipList = function(data){Ajax.Responders.dispatch('AjaxManagerOnGetClipList', null, null, data);};
	this.sendMessage = function(url, content, callback){
	this.onContacting();
	var wrappedCallback = function (requestObj, emptyData) {
		if(requestObj.status == 200){
			var text = requestObj.responseText;
			if (text.substring(0,2) == "[{"){
				var data = eval(text);
			} else {
				var data = eval('('+text+')');
			}
			if (data.hasError){
				new AjaxManager().onError(data);
			}
			callback(data);
		} else {
			var data;
			data.hasError = true;
			data.exception.message = "Bad response from ajax request. " + requestObj.status;
			new AjaxManager().onTransportError(data);
		}
	}
	new Ajax.Request(url,{
		onSuccess: wrappedCallback,
		method: 'get',
		parameters: content.toQueryString()
		});
	}
}


function getQsParam( name ) {
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

AjaxManager.prototype.getRating = function ( rcid, handler) {
	if (handler == null){
		handler = this.onGetRating;
	}
	var url = rhapsodyURL + "/webservice/json/ratings";
	var action = "get-ratings";
	var content = $H({rcid: rcid,
	    		  action: action});
	 var callback = function (data){
						if(data.hasError){
							this.onError("Whoops - " + data.exception.message + ' ' + data.exception.code);	
					    }else{
					    	handler(data);
					    }
					}
					
	this.sendMessage(url, content, callback);	
}


AjaxManager.prototype.setRating = function ( rcid, rating, handler) {
	if (handler == null){
		handler = this.onSetRating;
	}
	var url = rhapsodyURL + "/webservice/json/ratings";
	var action = "set-rating";
	var content = $H({rcid: rcid,
					  rating: rating,
	    		      action: action});
	 var callback = function (data){
						if(data.hasError){
							this.onError("Whoops - " + data.exception.message + ' ' + data.exception.code);	
					    }else{
					    	handler(data);
					    }
					}
	this.sendMessage(url, content, callback);	
}

AjaxManager.prototype.getVideoPlaylist = function ( playlistId, handler) {
	if (handler == null){
		handler = this.onGetVideoPlaylist;
	}
	var url = rhapsodyURL + "/webservice/json/video-playlist";
	var content = $H({playlistId: playlistId
					  });
	 var callback = function (data){
						if(data.hasError){
							this.onError("Whoops - " + data.exception.message + ' ' + data.exception.code);	
					    }else{
					    	handler(data);
					    }
					}
	this.sendMessage(url, content, callback);	
}

AjaxManager.prototype.getClipList = function ( clipIds, handler) {
	if (handler == null){
		handler = this.onGetClipList;
	}
	var url = rhapsodyURL + "/webservice/json/video-playlist";
	var content = $H({clipId: clipIds
					  });
	 var callback = function (data){
						if(data.hasError){
							this.onError("Whoops - " + data.exception.message + ' ' + data.exception.code);	
					    }else{
					    	handler(data);
					    }
					}
	this.sendMessage(url, content, callback);	
}

AjaxManager.prototype.getPersonalization = function ( passedGuid, passedECode, handler) {
	var url =  rhapsodyURL + "/js/personalization.json";
	var content = $H( { guid: passedGuid, ecode: passedECode } );
	var callback = function( data ){
	if(data.hasError){
			this.onError( "Whoops - " + data.exception.message + ' ' + data.exception.code );	
		} else {
			handler( data );
		}
	}
	this.sendMessage( url, content, callback );	
}

AjaxManager.prototype.getMenu = function ( passedPrefix,  handler) {
	var url = "/menu.json"
	if( rhapsodyMember.usersPartner == "verizon" ){
		var content = $H( { prefix: passedPrefix, usersPartner:rhapsodyMember.usersPartner } );
	} else {
		var content = $H( { prefix: passedPrefix } );
	}
	var callback = function( data ){
	  if(data.hasError){
			this.onError( "Whoops - " + data.exception.message + ' ' + data.exception.code );	
		} else {
			handler( data );
		}
	}
	this.sendMessage( rhapsodyURL + url, content, callback );	
}

AjaxManager.prototype.getWelcomeOverlay = function ( handler) {
  var url = "/welcomeOverlay.json";
  var content = $H({});
  var callback = function( data ){
   	if(data.hasError){
      this.onError( "Whoops - " + data.exception.message + ' ' + data.exception.code ); 
    } else {
      handler( data );
    }
  }
  this.sendMessage( rhapsodyURL + url, content, callback ); 
}

var RhapsodyAdvertisement = {
	forceAds: false,
	serveHomepageSlideshowTakeover: false,
	elementsToHideOnSlideshowTakeover: null,
	registerForAdvertisement: function( type, adDiv, adServerUrl, adParams, isHouseArt ){
		var theAdUrl = this._getAdUrl( adServerUrl, adParams );
		if( type == "block" ) return;
		if( type == "iframe" ){
			if( isHouseArt ) this.getHouseArt( adDiv, adServerUrl, isHouseArt );
			else if( RhapsodyUtility.Client.isFirefox() ) adDiv.src = theAdUrl;
			else RhapsodyUtility.addLoadEvent( function(){
				adDiv.src = theAdUrl;
			} );
			
		} else if( type == "debug" ) {
			document.write( theAdUrl );
		} else {
			if( isHouseArt ){
				this.getHouseArt( adDiv, adServerUrl, isHouseArt );
			} else {
				document.write( '<scr' + 'ipt src="' + theAdUrl + '">' );
				document.write( '<\/scr' + 'ipt>' );
			}
		}  
	},
	reloadAds: function( ids ){
		var args = arguments;
		for( var i=0; i < args.length; i++ ){
			var theAdElement = document.getElementById( args[ i ] );
			try{
				if( theAdElement && ( typeof theAdElement != 'undefined' ) && ( theAdElement.tagName.toLowerCase() == 'iframe' ) ){
					theAdElement.src = theAdElement.src.replace( /ord=[^;]*/, "ord=" + this._getOrd() );
				}
			} catch( e ){};
		}
	},
	getHouseArt: function( insertInto, houseArtUrl, isHouseArt ){
		var rndmOrd = Math.round( Math.random() * 10 );
		RhapsodyUtility.addLoadEvent( function(){
			RhapsodyUtility.Ajax.includeHtml( {
				ajaxUrl: houseArtUrl + "&rndm=" + rndmOrd,
				target: insertInto,
				forceReload: true
			} );
		} );
	},
	_getAdUrl: function( adServerUrl, adParams ){
		var theSubplan = 0;
		var theDartValuesString = "";
		try{
			theSubplan = RhapsodyPersonalization.AdvertisingValues.dartKeyValuesHash[ 'subplan' ];
		} catch(e) {}
		try{
			theDartValuesString = RhapsodyPersonalization.AdvertisingValues.dartKeyValuesString;
		} catch(e) {}
				
		var theAdUrl = adServerUrl +
			theSubplan +
			adParams +
			";" +
			theDartValuesString +
			"ord=" +
			this._getOrd() +
			";";
		return theAdUrl;
	},
	_getOrd: function(){
		return Math.round( Math.random() * 10000000 );
	}
}

function openPlayer(id,type,title,page,pageRegion,guid,origin) {
	RhapsodyPlayer.playRcid(id);
}

function openPlayerWindow(id, type, title, remote, page, pageRegion, guid, origin) {
       try {
	       if (!rhapPlayer || rhapPlayer.closed) {
				openThis(id, type, title, remote, page, pageRegion, guid, origin)
	
			} else {
				rhapPlayer.getMetaData(type,id,title,remote);
				rhapPlayer.focus();
			}
		   
	  } catch (e) {
	  	openThis(id, type, title, remote, page, pageRegion, guid, origin);
	  }
		  	
}

function openPlayerFromRhaplink(origin, id, type, title, remote, page, pageRegion, guid) {
	//Temp - fix the jill code on the rhaplink landing page
	var playerLocation = 'http://www.rhapsody.com/player';
	var successfulOpen = false;
	wname="rhapPlayer";
	width=270;
	height=570;
	if (title) {
		playerLocation += "?type=" + type + "&id="+id +"&title="+title +"&remote="+remote + "&page=" + page + "&pageregion=" + pageRegion + "&guid=" + guid + "&from=" + origin;
	} else {
		playerLocation += "?type=" + type + "&id="+id +"&remote="+remote + "&page=" + page + "&pageregion=" + pageRegion + "&guid=" + guid + "&from=" + origin;
	}
	var openFunction=function(){
		if (!rhapPlayer || rhapPlayer.closed) {
			rhapPlayer =  window.open(playerLocation,wname,"width="+width+",height="+height+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,top=20,left="+openFromLeftAt+"");			
			
		} else {
			rhapPlayer.getMetaData(type,id,title,remote);
			rhapPlayer.location.setParameter('page',page);
		}
		if((rhapPlayer!=null) && (typeof rhapPlayer!="undefined")){
			if (!rhapPlayer.opener) rhapPlayer.opener = self;
			rhapPlayer.focus();
			return true;
		}
	}
	successfulOpen=openFunction();
	if(!successfulOpen){
		SimplePopUpBlockHandler.alertUser(openFunction);
	}	
}


function openWin(name,url,width,height){
	newwindow = window.open(url,name,"width="+width+",height="+height+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
	newwindow.focus();
	return newwindow;
}

/* This function does not return anything. Returning causes the parent window to refresh with the returned value.
*/
function openWin2(name,url,width,height){
	newwindow = window.open(url,name,"width="+width+",height="+height+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0");
	newwindow.focus();	
}

function openWinNoFocus(name,url,width,height){
	newwindow = window.open(url,name,"width="+width+",height="+height+",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0");
	window.focus();
	return newwindow;
}


function signOut() {
	signOutWindow = openWin("signin","/signin?signout=true",270,200);
}



/* ********* BEGIN: Radio Station List Code ********* */
var radioFilterLastSelectedIndex = 0;

function processFilterSelection( object ) {

    var genreSelection = document.radioFilter.genreId.options[document.radioFilter.genreId.selectedIndex].value;

    if( genreSelection != 'SEPARATOR' ) {
		saveFilterIndex();
		document.getElementById("updatingDiv").innerHTML = "Loading.&nbsp;&nbsp;Please wait...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
		location.href = "/radio?genreId=" + genreSelection;
	} else {
		resetFilterIndex();
	}

}

function saveFilterIndex() {
	radioFilterLastSelectedIndex = document.radioFilter.genreId.selectedIndex;
}

function resetFilterIndex() {
	document.radioFilter.genreId.selectedIndex = radioFilterLastSelectedIndex;
}
/* ********** END: Radio Station List Code ********* */


/* ********* BEGIN: Playlist Central Browse Playlists Code ********* */
  function toggleElementDisplay(elementName)
  {
    var elementObj = document.getElementById(elementName);
    if( elementObj ) {
      var currState = elementObj.style.display;
      if( currState == 'block' ) {
        elementObj.style.display = 'none';
      }
      else {
        elementObj.style.display = 'block';
      }
    }
  }

  function toggleImgState(imgID, srcRoot, altState)
  {
    var elementObj = document.getElementById(imgID);
    if( elementObj ) {
      var currState = elementObj.src;
      if( currState.indexOf(altState) > -1 ) {
        elementObj.src = staticPath + 'images/buttons/' + srcRoot + '.gif';
      }
      else {
        elementObj.src = staticPath + 'images/buttons/' + srcRoot + altState + '.gif';
      }
    }
  }
/* ********** END: Playlist Central Browse Playlists Code ********* */


function submitFormById( formId ) {
    var theForm = document.getElementById(formId);
    if ( theForm ) {
        theForm.submit();
    }
}

function doSearch( missingQueryMsg, defaultMessage ) {

    var theForm = document.getElementById('navbarSearchForm');
    var theQueryObj = document.getElementById('headerSearchQuery');
    var theQuery = document.getElementById('headerSearchQuery').value;

    // Trim spaces off end
    theQuery = trimString(theQuery);

    // Reset the query string value on the page
    theQueryObj.value = theQuery;

	var theSearchType = document.getElementById('searchtype').value;
	
    if (  ( theQuery.length > 0 ) && ( theQuery != defaultMessage ) ){
		theQuery = escape(encodeutf8(theQuery));

        document.location.href = rhapsodyURL + "/-search?query=" + theQuery + "&searchtype=" + theSearchType;
		return false;
    } else {
        alert(missingQueryMsg);
        theQueryObj.focus();
        return false;
    }
}

function encodeutf8( pstring ) {
    var lstring = pstring.replace(/\r\n/g,"\n");
    var utftext = "";

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

        var c = lstring.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;
}

function trimString(psInString) {
	var sInString = psInString.replace( /^\s+/g, "" );// strip leading
    return sInString.replace( /\s+$/g, "" );// strip trailing
}

function getSignedInStatus() {
	var userGuid = "";
	var authRefreshTime = CookieManager.getCookie("authRefreshTime");
	var isNamed = false;
	var entCode = "";
	try {
		userGuid = rhapsodyMember.getMemberAttribute("guid");
		var isAnon = rhapsodyMember.getMemberAttribute("isAnonymousUser");
		var isLoggedIn = rhapsodyMember.getMemberAttribute("isLoggedIn");
		isNamed = isLoggedIn && !isAnon;
		
		if( isNamed ) entCode = rhapsodyMember.getMemberAttribute("entitlementCode");
	} catch(e) { }
		
	var mReturn = "";
	
	if( isNamed ) {
		mReturn = authRefreshTime + "_" + userGuid + "_" + isNamed + "_" + entCode;
	}
	else {
		mReturn = authRefreshTime + "_" + "notNamed";
	}
	
	return mReturn;
}


/* default thing to do on sign in status change, can be overriden in a page */
function onSignedInStatusChange() {
	var changedInThisPage = false;
	try {
		changedInThisPage = guidWasChangedInThisPage;
	}	catch(e) { /** do nothing **/ }

	if( changedInThisPage ) {
		try {
			RhapsodyPlayer.getFlashApp("embedded").doStorePlayerState();
			return;
		}
		catch( e ) {
			// IN the case of an exception trying to call doStorePlayerState(), just refresh the page...
			onAuthenticationRefreshPage();
		}
	}
	
	// If that didn't happen on this page, just refresh it...
	onAuthenticationRefreshPage();
}

function onPlayerStateStored() {
	if( guidWasChangedInThisPage ) {
//		alert("embedded player state storing is done... reloading the page...");
		onAuthenticationRefreshPage( RhapsodyPlayer.playbackWasInterrupted() );
	}
}

function onAuthenticationRefreshPage( restoreEmbeddedPlayer ) {
	var theLocation = top.document.location.href;
	var theRand = ".rand=";
	var indexOfRand = top.document.location.href.indexOf(".rand=");
	if( indexOfRand>=0 ) {
		var theLocation = top.document.location.href.substring( 0, indexOfRand );
		var indexOfAmpersand = top.document.location.href.indexOf( "&", indexOfRand );
		if( indexOfAmpersand >= 0 ) {
			theLocation += top.document.location.href.substring(indexOfAmpersand);
		}
	}

	try {
		document.getElementById("topNavSignInOut").innerHTML = '<img src="http://static.realone.com/rotw/images/libraryloading_overwhite.gif" \/>';
	} catch(e){ }
	
	top.document.location.replace( theLocation );
}

var lastSignedInStatus = null;

function watchSignedInStatus() {
	if( !lastSignedInStatus ) {
		lastSignedInStatus = getSignedInStatus();
		setTimeout("watchSignedInStatus()",100);
		return;
	}

	if( getSignedInStatus()!=lastSignedInStatus ) {
		document.cookie = "autoReloadingTime="+(6000 + new Date().valueOf())+"; path=/; domain=.rhapsody.com;";
		setTimeout("onSignedInStatusChange()",1000);
	}
	else {
		setTimeout("watchSignedInStatus()",100);
	}
}










/**
var CURRENTMOUSEOVER_RCID = 0;
var INFOMOUSEOVER_CACHE = new Array();
var CURRENTMOUSEOVERACTION = 0;
var INFOBOXMOUSEDOVER = false;

function isValidInfoMouseoverPrefix( rcid ) {
	return rcid.indexOf("art.")==0 || rcid.indexOf("alb.")==0 || rcid.indexOf("g.")==0 || rcid.indexOf("sta.")==0 || rcid.indexOf("ply.")==0;
}

function showInfoMouseover( jsonObject, mousex, mousey ) {
	CURRENTMOUSEOVERACTION++;
	var mouseoverDiv = document.getElementById("infoMouseOverDiv");

	var offsetFromLeft = Math.max( document.body.scrollLeft, document.documentElement.scrollLeft );
	var offsetFromTop = Math.max( document.body.scrollTop, document.documentElement.scrollTop );
	if( window.pageYOffset ) offsetFromTop = Math.max( offsetFromTop, window.pageYOffset );
	var docWidth = document.documentElement.clientWidth + offsetFromLeft;
	var docHeight = document.documentElement.clientHeight + offsetFromTop;

	mouseoverDiv.innerHTML = jsonObject.html;

	if( mousex + 15 + jsonObject.width > docWidth ) {
		mouseoverDiv.style.left = (mousex - 30 - jsonObject.width) + "px";
	}
	else {
		mouseoverDiv.style.left = (mousex + 15) + "px";
	}
	
	if( mousey + jsonObject.height + offsetFromTop > docHeight ) {
		mouseoverDiv.style.top = (mousey + offsetFromTop - jsonObject.height) + "px";
	}
	else {
		mouseoverDiv.style.top = (mousey + document.documentElement.scrollTop) + "px";
	}

	mouseoverDiv.style.width = jsonObject.width + "px";
	mouseoverDiv.style.height = jsonObject.height + "px";
	mouseoverDiv.style.opacity = "0.90";
	mouseoverDiv.style.filter = "alpha(opacity=90)";
	mouseoverDiv.style.visibility = "visible";
}

function infoMouseOverAjax( rcid, mousex, mousey ) {
	if( isValidInfoMouseoverPrefix(rcid) ) {
		var mouseoverDiv = document.getElementById("infoMouseOverDiv");
		mouseoverDiv.style.visibility = "hidden";
		var ajaxReq = new Ajax.Request(
			rhapsodyURL + "/infomouseover.json", {
			parameters: "rcid="+rcid,
			method: 'get',
			onSuccess: function( theRequest ) {
				var theJsonObject = eval('('+theRequest.responseText+')');
				if( theJsonObject.rcid == CURRENTMOUSEOVER_RCID ) {
					INFOMOUSEOVER_CACHE[rcid] = theJsonObject;
					showInfoMouseover(theJsonObject, mousex, mousey);
				}
			}
		} );
	}
}

function getMousedoverRcid( element ) {
	var thercid = element.getAttribute("rcid");
	for( var i=0 ; !thercid && i<3 ; i++ ) {
		element = element.parentNode;
		if( !element ) { break; }
		try { thercid = element.getAttribute("rcid"); } catch (e) { }
	}
	return thercid;
}

function doInfoMouseOver( eventElement, mouseEvent ) {
	thercid = getMousedoverRcid(eventElement);
	if( thercid ) {
		thercid = thercid.toLowerCase();
		CURRENTMOUSEOVER_RCID = thercid;
		setTimeout( "doInfoMouseOverDelayed('" + thercid + "', "+mouseEvent.clientX+", "+mouseEvent.clientY+")", 100 );
	}
}

function doInfoMouseOverDelayed( thercid, mousex, mousey ) {
	if( CURRENTMOUSEOVER_RCID != thercid ) { return; }
	if( INFOMOUSEOVER_CACHE[thercid] ) showInfoMouseover( INFOMOUSEOVER_CACHE[thercid], mousex, mousey );
	else infoMouseOverAjax( thercid, mousex, mousey );
}

function doInfoMouseOut( eventElement ) {
	if( INFOBOXMOUSEDOVER ) return; 
	thercid = getMousedoverRcid(eventElement);
	if( thercid ) {
		setTimeout( "doInfoMouseOutDelayed('" + thercid + "', "+CURRENTMOUSEOVERACTION+")", 250 );
	}
}

function doInfoMouseOutDelayed( thercid, theaction ) {
	if( INFOBOXMOUSEDOVER ) return; 
	if( CURRENTMOUSEOVERACTION != theaction ) { return; }
	if( CURRENTMOUSEOVER_RCID != thercid ) { return; }
	CURRENTMOUSEOVER_RCID = 0;
	var mouseoverDiv = document.getElementById("infoMouseOverDiv");
	mouseoverDiv.style.visibility = "hidden";
}

function captureMouseOverFF( mouseEvent ) {
	doInfoMouseOver( mouseEvent.target, mouseEvent );
}

function captureMouseOutFF( mouseEvent ) {
	doInfoMouseOut( mouseEvent.target );
}

function captureMouseOverIE( ) {
	var mouseEvent = window.event;
	var eventElement = mouseEvent.srcElement;

	doInfoMouseOver( eventElement, mouseEvent );
}

function captureMouseOutIE( ) {
	var mouseEvent = window.event;
	var eventElement = mouseEvent.srcElement;

	doInfoMouseOut( eventElement );
}

var theUa = navigator.userAgent.toLowerCase();

if( theUa.indexOf("win")>=0 && theUa.indexOf("msie")>=0 ) {
	document.onmouseover = captureMouseOverIE; // IE
	document.onmouseout = captureMouseOutIE; // IE
}
else {
    document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
	document.onmouseover = captureMouseOverFF; // FF
	document.onmouseout = captureMouseOutFF; // FF
}

function doMousedOverInfoBox( element ) {
	INFOBOXMOUSEDOVER = true;
	element.style.opacity = "1.00";
	element.style.filter = "alpha(opacity=100)";
}

function doMousedOutInfoBox( event ) {
	INFOBOXMOUSEDOVER = false;
	var mouseoverDiv = document.getElementById("infoMouseOverDiv");
	if( !Position.within( mouseoverDiv, Event.pointerX( event ), Event.pointerY( event ) ) ) {
		mouseoverDiv.style.visibility = "hidden";
	}
}

document.write("<div id='infoMouseOverDiv' style='position:absolute; visibility:hidden; background-color:#ffffff; border:1px solid #666666; z-index:110;' onMouseOver='doMousedOverInfoBox(this)'></div>");

function doInfoMouseoverEventCapture() {
	var element = document.getElementById('infoMouseOverDiv');
	if( !element ) {setTimeout( "doInfoMouseoverEventCapture()", 500 );}
	else {
		try { Event.observe( element, 'mouseout', doMousedOutInfoBox ); } catch(e) {}
	}
}
doInfoMouseoverEventCapture();
**/


function Member(){};
Member.prototype = {
	entitlementCode: null,
	userName: "",
	guid: "",
	rhapUserId: "",
	entitlement: "",
	isLoggedIn: null,
	isAnonymousUser: null,
	isUnlimitedPlays: null,
	isPremiumUser: null,
	isRadioPremiumUser: null,
	isShowNoAds: null,
	isRhapsodyToGo: null,
	truncatedUserName: "",
	genderAsNumeric: null,
	birthYear: null,
	postalCode: null,
	initialLetter: "",
	payment: "",
	hasRhapF: null,
	rhapFVersion: null,
	isUS: null,
	usersPartner: "",
	cobrandPartner: "",
	cpath: "",
	ocode: "",
	rsrc: "",
	Browser: {
		os: ""
	},
	isCanned: null,
	objectBornOn: null,
	postalCode: "",
	
	getMemberAttribute: function( maName ){
		return this[ maName ];
	},
	setMemberAttribute: function( maName, maValue ){
		this[ maName ] = maValue;
		return maValue;
	}	
}

var RhapsodyTestAndTarget = {};

var RhapsodyTracking = {
	_accountId: null,
	_category: null,
	_pageName: null,
	_environment: null,
	_siteCode: "rotw",
	_events: [],
	
	primaryContentId: null,
	primaryContentName: null,
	artistId: null,
	artistName: null,
	albumId: null,
	albumName: null,
	
	browseResultsCount: null,
	browseQuery: null,
	defaultClientName: 'rhapf',
	secondaryClientName: 'rhape',
	tertiaryClientName: 'rhapx',
	treatSearchAsBrowse: false,
	errorType: null,
	genreName: null,
	lsrc: null,
	musicVideoId: null,
	pageId: null,
	publicationDate: null,
	_rhapsodyMember: null,
	searchCategory: null,
	searchResultsCount: null,
	searchQuery: null,
	searchType: null,
	testVariant: null,
	topLevelGenreName: null,
	
	profileFriends: null,
	profilePublicPlaylists: null,
	
	okToDebug: false,
	
	_registeredInitCallbacks: new Array(),
	
	debugElement: null,
	getAccountId: function(){
		return this._accountId;
	},
	getEnvironment: function(){
		return this._environment;
	},
	getCategory: function(){
		return this._category?this._category:"";
	},
	getPageName: function(){
		return this._pageName?this._pageName:"";
	},
	getSiteCode: function(){
		return this._siteCode?this._siteCode:"";
	},
	setAccountId: function( aid ){
		this._accountId = aid;
	},
	setEnvironment: function( env ){
		this._environment = env;
	},
	setCategory: function( cat ){
		this._category = cat;
	},
	setPageName: function( pn ){
		this._pageName = pn;
	},
	setSiteCode: function( sc ){
		this._siteCode = sc;
	},
	
	getBreadcrumbs: function(){
		var crumbs = null;
		var crumbTrail = document.getElementById( 'crumbtrail' );
		if( crumbTrail ) crumbs = crumbTrail.innerHTML;
		if( crumbs ){
			crumbs = crumbs.stripTags();
			crumbs = crumbs.replace( /&gt;/g, ' : ' );
			crumbs = crumbs.replace( /&[^;]+;/g, '' );
			crumbs = crumbs.replace( /\s+/g, ' ' );
			crumbs = crumbs.replace( /Home :/gi, ' ' );
			crumbs = crumbs.strip();
			return crumbs;
		} else return null;
	},
	getLocalSrc: function( raw ){
		var returnLsrc = this.lsrc;
		if( !raw && returnLsrc ) returnLsrc = returnLsrc.replace( /_/g, ':' );
		return returnLsrc;
	},
	setLocalSrc: function( ls ){
		this.lsrc = ls;
	},
	getLinkInternalFilters: function(){
		return "javascript:,rhapsody.com,static.";
	},
	getCustomMetric: function( cmName, castTo ){
		var cmReturn = this[ cmName ];
		if( ( cmReturn != null ) && ( castTo == 'String' ) ) cmReturn = cmReturn.toString();
		return cmReturn != null?cmReturn:"";
	},
	setCustomMetric: function( cmName, cmValue ){
		if( cmValue.strip != '' ) this[ cmName ] = cmValue;
		return cmValue;
	},
	getClientName: function(){
		var toReturn = '0';
		if( this.getRhapsodyMember() && this.defaultClientName == 'rhapf'){
			if( this.getRhapsodyMember().getMemberAttribute( "hasRhapF" ) )	toReturn = ( this.getRhapsodyMember().getMemberAttribute( "rhapFVersion" ).indexOf( 'rhapE' ) > -1 )? this.secondaryClientName: this.defaultClientName;
			else if ( this.getRhapsodyMember().getMemberAttribute( "hasRhapX" ) ) toReturn = this.tertiaryClientName;			
		} else if( this.getRhapsodyMember() && this.defaultClientName == 'dlm'){
			toReturn = this.defaultClientName;
		}
		return toReturn;
	},
	getClientVersion: function(){
		var toReturn = null;
		if( ( this.getClientName() == 'rhapf' ) || ( this.getClientName() == 'rhape' ) ){
			toReturn = ( this.getRhapsodyMember() && this.getRhapsodyMember().getMemberAttribute( "rhapFVersion" ) && this.getRhapsodyMember().getMemberAttribute( "hasRhapF" ) )?this.getRhapsodyMember().getMemberAttribute( "rhapFVersion" ):toReturn;
		} else if( this.getClientName() == 'rhapx' ){
			toReturn = ( this.getRhapsodyMember() && this.getRhapsodyMember().getMemberAttribute( "rhapXVersion" ) && this.getRhapsodyMember().getMemberAttribute( "hasRhapX" ) )?this.getRhapsodyMember().getMemberAttribute( "rhapXVersion" ):toReturn;
		} else if ( this.getClientName() == 'dlm' ) {
			toReturn = ( this.getRhapsodyMember() && this.getRhapsodyMember().getMemberAttribute( "dlmVersion" ) && this.getRhapsodyMember().getMemberAttribute( "hasDlm" ) )?this.getRhapsodyMember().getMemberAttribute( "dlmVersion" ):toReturn;
		}
		return toReturn;
	},
	getEvents: function(){
		var toReturn = "";
		for( var i=0; i < this._events.length; i++ ){
			var nextVal = this._events[ i ];
			toReturn += i > 0?"," + nextVal :nextVal;
		}
		return toReturn;
	},
	addEvent: function( ev ){
		this._events.push( ev );
	},
	getRhapsodyMember: function(){
		return this._rhapsodyMember;
	},
	setRhapsodyMember: function( rm ){
		this._rhapsodyMember = rm;
	},
	registerInitCallback: function( cb ){
		this._registeredInitCallbacks.push( cb );
	},
	executeRegisteredInitCallbacks: function(){
		var riCallbacks = this._registeredInitCallbacks;
		if( riCallbacks.length < 1 ) return;
		for( var i=0; i< riCallbacks.length; i++ ){
			riCallbacks[ i ]();
		}
	},
	getCampaignData: function(){
		var delim = ":";
		var cdString = "";
		var thePcode = ( this.getRhapsodyMember() && this.getRhapsodyMember().cobrandPartner && this.getRhapsodyMember().cobrandPartner != '' )?this.getRhapsodyMember().cobrandPartner:"RN";
		var theCpath = ( this.getRhapsodyMember() && this.getRhapsodyMember().cpath && this.getRhapsodyMember().cpath != '' )?this.getRhapsodyMember().cpath:"RN";
		var theRsrc =  ( this.getRhapsodyMember() && this.getRhapsodyMember().rsrc && this.getRhapsodyMember().rsrc != '' )?this.getRhapsodyMember().rsrc:"RN";
		if( this.getRhapsodyMember() ) cdString = thePcode + delim + theCpath + delim + theRsrc;
		return cdString;
	},
	sendPageView: function( overridesObj, optionsObj ){
		var disableCall = false;
		var persistPreviousOverrides = ( optionsObj && optionsObj.persistPreviousOverrides )? ( optionsObj && optionsObj.persistPreviousOverrides ): false;
		try{
			s = s_gi( this.getAccountId() );
		} catch( e ){ disableCall = true }
		if( !persistPreviousOverrides ) this.setDefaultConfig();
		if( !disableCall ){
			this._setOverrides( overridesObj );
			void( s.t() );
			if( this.okToDebug ){
				if( this.debugElement ) this.debug( true );
				this.debug();
			}
		}
	},
	sendLinkEvent: function( overridesObj, optionsObj, rd ){
		// if i want original data set s.linkTrackVars = ""; and s.linkTrackEvents = "";
		var disableCall = false;
		try{
			s = s_gi( this.getAccountId() );
		} catch( e ){ disableCall = true }
		var linkTypeHash = new Object();
		linkTypeHash[ 'exit' ] = 'e';
		linkTypeHash[ 'download' ] = 'd';
		linkTypeHash[ 'custom' ] = 'o';
		var linkTypeAbbrev = optionsObj.type?linkTypeHash[ optionsObj.type ]:null;
		var linkName =  optionsObj.linkName?optionsObj.linkName:null;
		var ltvString = "eVar18,eVar37";
		var moreThanOne = false;
		if( !disableCall && optionsObj && overridesObj ){
			s.eVar18 = this.getPageName();
			s.eVar37 = this.getSiteCode();
			for( var i in overridesObj ){
				s[ i ] = overridesObj[ i ];
				ltvString += "," + i;
				moreThanOne = true;
			}
			if( optionsObj.events ){
				s.linkTrackEvents = optionsObj.events;
				s.events = optionsObj.events;
				ltvString += ",events";
			}
			s.linkTrackVars = ltvString;
			 if( linkTypeAbbrev && linkName ){
				void( s.tl( this, linkTypeAbbrev, linkName ) );
			 }
		}
		if( rd ){
			setTimeout( function(){
				document.location.href = rd;
			}, 200 );
		}
	},
	_setOverrides: function( or ){
		for( var i in or ){
			s[ i ] = or[ i ];
		}
	},
	debug: function( closeDebug ){
		var timeoutTilClose = 5000;
		var omnitureImgHolder =  document.getElementById( 'omnitureCodeToPaste' );
		var omnitureImg = null;
		var debugInfo = 'Tracking Info:<br\/>' + 
			'Category: ' + this.getCategory()+ '<br\/>' + 'Page Name: ' + this.getPageName() + '<br\/>' +
			'<a href="#" onclick="RhapsodyTracking.debug( true ); return false;">close<\/a>';
		if( omnitureImgHolder && ( typeof omnitureImgHolder != 'undefined' ) ){
			omnitureImg = window[ 's_i_realnetworks' ];
		}
		if( omnitureImg && omnitureImg.src != '' ) debugInfo += "<p>sent a request to omniture<\/p>";
		else debugInfo += '<p style="color: red;">no request sent to omniture!<\/p>';
		if( !closeDebug && typeof DialogBox != 'undefined' ){
			this.debugElement = new DialogBox(
				{
					elementId: "RhapsodyTrackingDebugBox",
					width: '230px',
					height: '180px',
					htmlContent: debugInfo
				}
			);
			this.debugElement.show();
			with( this.debugElement.getHoldingElement().style ){
				backgroundColor = "#CCC";
				padding = "10px";
				overflow = "auto";
			}

			if( !RhapsodyTracking.getPageName() || !RhapsodyTracking.getCategory() ){
				timeoutTilClose = 15000;
				with( this.debugElement ){
					hide();
					setMask( true );
					getHoldingElement().style.backgroundColor = "red";
					centerInPage();
					show();
					loadContent( { htmlContent: debugInfo + '<p><b>set a category and pagename in /conf/rotw.reporting-services.xml<\/b><\/p>' } );
				}
			}
			RhapsodyUtility.setAlpha( "RhapsodyTrackingDebugBox", 80 );
			
			var omnitureDebugHolderElement = document.createElement( "DIV" );
			var omnitureDebugAnchor = document.createElement( "A" );
			var rhapsodyMemberDebugAnchor = document.createElement( "A" );
			var omnitureDebugAnchorText = document.createTextNode( "view omniture debugger" );
			var rhapsodyMemberDebugText = document.createTextNode( "view rhapsodyMember debugger" );
			omnitureDebugAnchor.appendChild( omnitureDebugAnchorText );
			rhapsodyMemberDebugAnchor.appendChild( rhapsodyMemberDebugText );
			omnitureDebugAnchor.setAttribute( "href", "javascript:RhapsodyTracking.launchOmnitureDebug();" );
			rhapsodyMemberDebugAnchor.setAttribute( "href", rhapsodyURL + "/test/rhapsodyMember.html" );
			omnitureDebugHolderElement.appendChild( omnitureDebugAnchor );
			omnitureDebugHolderElement.appendChild( document.createElement( "BR" ) );
			omnitureDebugHolderElement.appendChild( rhapsodyMemberDebugAnchor );
			this.debugElement.getHoldingElement().appendChild( omnitureDebugHolderElement );

			setTimeout( "RhapsodyTracking.debug( true )", timeoutTilClose );
		} else {
			if( RhapsodyTracking.debugElement ){
				RhapsodyTracking.debugElement.removeHoldingElement();
				if( RhapsodyTracking.debugElement.getMask() ) RhapsodyTracking.debugElement.setMask( false );
				RhapsodyTracking.debugElement = null;
			}
		}
	},
	launchOmnitureDebug: function(){
		window.open( '','stats_debugger','width=600,height=600,location=0,menubar=0,status=1,toolbar=0,resizable=1,scrollbars=1' ).document.write( '<script type="text/javascript" src="https://sitecatalyst.omniture.com/sc_tools/stats_debugger.html"><\/' + 'script>' + '<script type="text/javascript">window.focus();<\/' + 'script>' ); 
	}
}




