/** ********** Start of Diogenes dependencies ******************************** */

if (typeof diogenesServer == 'undefined')
	diogenesServer = "http://www.mtvmusicmeter.com";

document
		.write('<link href="'
				+ diogenesServer
				+ '/sitewide/css/meter/diogenes.css" rel="stylesheet" type="text/css" />');
document
		.write('<link href="'
				+ diogenesServer
				+ '/sitewide/css/meter/jquery.autocomplete.css" rel="stylesheet" type="text/css" />');

if (typeof jQuery == 'undefined') { // some modules needs jquery and search bar
									// needs jquery
	document.write('<script type="text/javascript" src="' + diogenesServer
			+ '/sitewide/js/jquery/jquery.js"></script>');

} else {

	var $ = jQuery.noConflict();
}

if (typeof jQuery.ui == 'undefined') { // needs jquery ui autocomplete for
										// search bar
	document.write('<script type="text/javascript" src="' + diogenesServer
			+ '/sitewide/js/jqueryAux/"></script>');
}

/** * Include jPlayer library for audio tab ** */
document.write('<script type="text/javascript" src="' + diogenesServer
		+ '/sitewide/js/jQuery.jPlayer.1.1.1/jquery.jplayer.min.js"></script>');

/** * Include Zero Clipboard library for copy to clipboard functions ** */
document.write('<script type="text/javascript" src="' + diogenesServer
		+ '/sitewide/js/zeroclipboard/ZeroClipboard.js"></script>');

/** * Playlist code ** */
if (typeof MTVN_PL == 'undefined') {
	document
			.write('<script type="text/javascript" src="http://playlists.mtvnservices.com/client/1.0.3/js/dependencies.js?lang=en" id="MTVN_PL-dependencies"></script>');
	document
			.write('<script type="text/javascript" src="http://playlists.mtvnservices.com/client/1.0.3/js/core.js" id="MTVN_PL-core"></script>');

	document.write('<script type="text/javascript" src="' + diogenesServer
			+ '/sitewide/js/meter/playlistOverloads.js"></script>');

	// this should be the last to overwrite default playlist.css styles
	document
			.write('<link href="'
					+ diogenesServer
					+ '/sitewide/css/meter/playlistOverrides.css" rel="stylesheet" type="text/css" />');
}

/** ********** End of Diogenes dependencies ********************************** */

/** * Initialize Zero Clipboard ** */
$J(document).ready(
		function() {
			ZeroClipboard.setMoviePath(diogenesServer
					+ '/sitewide/js/zeroclipboard/ZeroClipboard.swf');
		});

// Audio source switch: either loads Rhapsody feed, or Echonest
var isRhap = true;

Logger = {
	expanded : false,
	log : function(txt) {
		loggerDiv.innerHTML = loggerDiv.innerHTML + txt + "<br>";
	},
	toggle : function() {
		if (!Logger.expanded) {
			Logger.div.style.height = "150px";
			Logger.div.style.width = "300px";
			Logger.expanded = true;
		} else {
			Logger.div.style.height = "3px";
			Logger.div.style.width = "300px";
			Logger.expanded = false;
		}
	},
	div : {}
}

if (typeof console == "undefined") {
	console = {};
	console.log = Logger.log;

	var loggerDiv = document.createElement('div');

	loggerDiv.style.height = '3px';
	loggerDiv.setAttribute(((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
			: 'class'), 'logger-div');
	loggerDiv.onclick = Logger.toggle;
	Logger.div = loggerDiv;

	function appendLogger() {
		document.body.appendChild(loggerDiv);
	}
	if (window.addEventListener)
		window.addEventListener('load', appendLogger, false);
	else if (window.attachEvent)
		window.attachEvent('onload', appendLogger);
}

// construct the addThis element
function addThis(addThisTxt) {
	// create an addThis button
	var a = document.createElement('a');
	a.setAttribute('class', 'addthis_button_compact');
	a.setAttribute('id', 'addthis_button_compact');
	// a.innerHTML = '<img
	// src="http://s7.addthis.com/static/t00/logo1414.gif"/><span
	// class="addThisTxt">'+addThisTxt+'</span>';
	a.innerHTML = '<div style="float: left;"><img src="'
			+ diogenesServer
			+ '/sitewide/img/meter/footer-button-share3.gif" align="absmiddle"/></div><div class="addThisTxt">'
			+ addThisTxt + '</div>';
	document.getElementById('addthis_toolbox').appendChild(a);
}

// update the addThis button
function updateEmbedThisUrl(path) {
	a = document.getElementById('addthis_button_compact')
	a.setAttribute('addthis:url', path);
}

function redressURL(splitter) {
	// strip out the query-string variables
	if (baseURL.indexOf(splitter) > 0) {
		baseURL = baseURL.substring(0, baseURL.indexOf(splitter));
	}
}

function dioFlattenArtistNames(n) {

	var flattendArtistName = "";
	var allowableFlattenPattern = /[\w\s]/i;
	n = unescape(n);

	for ( var i = 0; i < n.length; i++) {
		var cha = n.substring(i, i + 1).toString();
		// if (cha.match(allowableFlattenPattern)) flattendArtistName +=
		// cha.toLowerCase().replace(" ","_").replace("\"","").replace("'","");
		flattendArtistName += cha.toLowerCase().replace(" ", "_").replace("\"",
				"").replace("'", "").replace("/", "_");
	}

	flattendArtistName = encodeURIComponent(flattendArtistName);

	return flattendArtistName;
}

function dioGetInternetExplorerVersion() {

	var rv = -1; // Return value assumes failure.

	if (navigator.appName == 'Microsoft Internet Explorer') {

		var ua = navigator.userAgent;

		var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");

		if (re.exec(ua) != null)

			rv = parseFloat(RegExp.$1);

	}

	return rv;

}

// some crazy ui function to lock a big of portion of the header cosmetically
// regardless how the user
// scrolls the browser window. This procs ONLY if coming in to meter page with
// an artist id
// dioLockHeader
function dioLockHeader() {
	var params = MTVM.util.parseUrlParamsToJSON();
	var wrapperId = "global-top-navigation-wrapper", contentWrapperId = "contentWrapper", dioHeaderWrapperId = "dio-header-wrapper", dioColumnClass = "dio-column", left = 0;

	if (params.exp && params.exp != "") {
		$J(document)
				.ready(
						function() {

							$('.' + dioColumnClass).css('padding-top', '38px');

							/* locking global nav */
							$('#' + wrapperId).css('position', 'fixed');
							$('#' + wrapperId).css('z-index', '1000');
							left = ($('body').width() / 2)
									- ($('#' + wrapperId).width() / 2);
							left = (left > 0) ? left : 0;

							$('#' + wrapperId).css('left', left);
							$('#' + contentWrapperId).css('padding-top',
									parseInt($('#' + wrapperId).height()));

							/* locking meter header */
							$('#' + dioHeaderWrapperId)
									.css('position', 'fixed');
							$('#' + dioHeaderWrapperId).css('z-index', '100');
							$('#' + dioHeaderWrapperId).width(930);
							$('#' + dioHeaderWrapperId).css('top',
									$('#' + wrapperId).height() - 5);

							left = ($('body').width() / 2)
									- ($('#' + dioHeaderWrapperId).width() / 2);
							left = (left > 0) ? left : 0;
							$('#' + dioHeaderWrapperId).css('left', left);
							$('#' + dioHeaderWrapperId).css('padding-top',
									'40px');
							$('#' + dioHeaderWrapperId).css('padding-bottom',
									'10px');
							$('#' + dioHeaderWrapperId).css('background-color',
									'#fff');

							$('#global-top-navigation-wrapper-bg').css(
									'display', 'block'); // show the
															// background image;

							// scroll to correct card
							// $('body').scrollTop(
							// $('#'+params.exp).position().top -
							// ($('#'+dioHeaderWrapperId).height() +
							// $('#'+wrapperId).height() + 40));

							// onresize, gotta reset the header again, mostly
							// for positioning
							// $(window).resize(function(){this();});
						});
	}
}

var Dio_IE_Ver = dioGetInternetExplorerVersion();

if (typeof Diogenes == "undefined") {
	var Diogenes = {};
}

// Widget Config parameters
if (typeof (DiogenesConfig) == 'undefined')
	DiogenesConfig = {};

// "favoritesHeaderText":'Your Favorites <span style="font-size:12px;
// font-weight: normal;">(<a href="javascript:
// dioClearFavorites();">Clear</a>)</span>',

var DiogenesConfig = {

	"siteRoot" : "musicmeter/",
	"useLauncher" : false,

	"recdListHeaderText" : "<div style=\"float: left;\">Similar</div>",
	"recdListDescText" : "You are viewing a list of artists that are similar to ",
	"recdListButtonPopupText" : "LIST SIMILAR ARTISTS",
	"wreckListHeaderText" : "<div style=\"float: left;\">Dis-similar to&nbsp;</div>",
	"wreckListDescText" : "You are viewing a list of artists that are dis-similar to ",
	"wreckListButtonPopupText" : "LIST OPPOSITE ARTISTS",
	"searchHeaderText" : "<div style=\"float: left;\"></div>",
	"searchDescText" : "Search result and similar artists.",
	"favoritesHeaderText" : 'Your Favorites',
	"favoritesDescText" : "The artists that you have favorited.",
	"favoritesButtonPopupText" : "FAVORITE",
	"favoritedAlreadyText" : "ALREADY ADDED",
	"favoritedText" : "ADDED",
	"addThisButtonPopupText" : "SHARE",

	"TabsEnabled" : {
		"Listen" : true,
		"Tweets" : false,
		"Videos" : true,
		"Photos" : true,
		"Blogs" : true,
		"Bios" : true,
		"Tour" : true,
		"Similar" : false
	},

	"Reporting" : {
		"CardOpen" : {
			"_name" : "Card Open",
			"_eVar" : "eVar10"
		},
		"TabOpen" : {
			"_name" : "TabOpen",
			"_eVar" : "eVar11"
		},
		"Share" : {
			"_name" : "Share",
			"_eVar" : "eVar12"
		},
		"Favorite" : {
			"_name" : "Favorite",
			"_eVar" : "eVar13"
		},
		"Similar" : {
			"_name" : "Similar",
			"_eVar" : "eVar15"
		}
	}
};

if (typeof (DiogenesGlobal) == 'undefined')
	DiogenesGlobal = {};
var DiogenesGlobal = {
	"cards" : [],
	"activeCard" : null
}

// Diogenes base class
Diogenes = function() {

	var version = "0.5";

	this.ECHONEST_ID_PREFIX = "music://id.echonest.com/~/AR/";
	this.ECHONEST_ID_PREFIX_MTVN = "mtv:artist:";
	this.ECHONEST_ID_PREFIX_MTVN_NUMERIC = "mtv_numeric:artist:";
	this.MTV_MGID_PREFIX = "mgid:uma:video:mtvmusic.com:";

	this.ANIMATION_DELAY = 500;

	this.TABS_HEIGHT = "33";
	this.STAGE_WIDTH = "402";
	this.STAGE_HEIGHT = "239";
	this.WRECKS_HEIGHT = "47";
	this.PLAYER_HEIGHT = "3"; // rhapsody player is moved and this div serves
								// at the bottom border of the card
	this.stageProcessingHTML = '<img src="' + diogenesServer
			+ '/sitewide/img/meter/ajax-ani-big.gif" border="0" />';

	// this.dsURL =
	// "http://services.mtvmusic-d.mtvi.com/meter/dataservices/query.jhtml"; //
	// widget dataservice url (DEV)
	// this.dsURL = ""+diogenesServer+"/meter/dataservices/query.jhtml"; //
	// widget dataservice url
	this.dsURL = "" + diogenesServer + "/sitewide/dataservices/"; // widget
																	// dataservice
																	// url

	this.artistReq = "artist"; // artist info request (value of "req" for
								// dataservice)
	this.profileReq = "profile"; // echonest profile info request (value of
									// "req" for dataservice)
	this.tweetReq = "tweets"; // tweets request (value of "req" for
								// dataservice)
	this.photoReq = "photos"; // photos request (value of "req" for
								// dataservice)
	this.videoReq = "videos"; // videos request (value of "req" for
								// dataservice)
	this.blogReq = "blogs"; // blogs request (value of "req" for dataservice)
	this.newsReq = "news"; // news request (value of "req" for dataservice)
	this.bioReq = "bios"; // bios request (value of "req" for dataservice)
	this.simReq = "similar"; // similar artists request (value of "req" for
								// dataservice)
	this.wreckdReq = "wreckd"; // wreck'd request (value of "req" for
								// dataservice)
	this.underRadarReq = "underRadar"; // under the radar/upcoming request
										// (value of "req" for dataservice)

	this.dioCards = []; // keep track of all the cards instanced.
	this.buttonPopUps = []; // keep track of all the button popups.

	this.__loadData = function(options) {
		var options = options || {};
		var url = ('url' in options) ? options.url : '';
		var ajaxType = ('ajaxType' in options) ? options.ajaxType : 'GET';
		var data = ('data' in options) ? options.data : '';
		var dataType = ('dataType' in options) ? options.dataType : 'xml';
		var timeout = ('timeout' in options) ? options.timeout : 10000;
		var successHandler = ('successHandler' in options) ? options.successHandler
				: this.___successHandler;
		var errorHandler = ('errorHandler' in options) ? options.errorHandler
				: this.___errorHandler;
		var datasource = ('datasource' in options) ? options.datasource : null;
		var jsonpCallback = ('jsonpCallback' in options) ? options.jsonpCallback
				: null;

		try {
			if (datasource != null) {
				// console.log("Using provided datasource");
				successHandler(datasource);
			} else {
				// console.log("AJAXING for data");
				$.ajax({
					url : url,
					type : ajaxType,
					data : data,
					jsonpCallback : jsonpCallback,
					dataType : dataType,
					timeout : timeout,
					error : function(hr) {
						errorHandler(hr);
					},
					success : function(data) {
						successHandler(data);
					}
				});
			}
		} catch (e) {
			// console.log("BASE widget __loadData failed: " + e);
		}
	}

	this.createClearDiv = function() {

		var clearDiv = document.createElement('div');
		clearDiv.style.clear = 'both';

		return clearDiv;
	}

	this.doAnimate = function(div, height, animate, delay) { // animation
																// method
		if (animate == null)
			animate = true;
		if (delay == null)
			delay = this.ANIMATION_DELAY;
		if (animate) {
			if (typeof jQuery == 'undefined') {

				if (height == 1)
					div.style.display = "none";
				else
					div.style.height = height + "px";

			} else {

				if (height == 1) {
					$(div).animate({
						height : height
					}, delay, 'linear', function() {
						$(this).css("display", "none");
					});
				} else {
					$(div).css("display", "block");
					$(div).animate({
						"height" : height
					}, delay);
				}

			}
		} else {
			if (height == 1)
				div.style.display = "none";
			else
				div.style.height = height + "px";
		}
	}

	this.ajaxErrors = function(err) {
		// console.log("Ajaxing Error: " + err);
		console.log(err);
	}

	this.removeAllChildren = function(domObj) {

		if (domObj.hasChildNodes()) {
			while (domObj.childNodes.length >= 1) {
				domObj.removeChild(domObj.firstChild);
			}
		}
	}

	this.truncateHTML = function(htmlString, max) {
		var truncateHTMLString = "";
		var count = 0;
		var textCountWithoutHTML = 0;
		var counting = true;
		var ellipsis = "";
		if (htmlString && max) {

			var maxCount = (htmlString.length > max) ? max : htmlString.length;

			for ( var i = 0; i < htmlString.length; i++) {
				if (count < maxCount) {
					var c = htmlString.charAt(i);
					if (c == '<') {
						counting = false;
					} else if (c == '>') {
						counting = true;
					}

					if (c != '<' && c != '>' && counting) {
						count++;
						truncateHTMLString += c;
					}
				}
				textCountWithoutHTML = i;
			}

			if ((textCountWithoutHTML + 1) > maxCount)
				ellipsis = "...";

			return truncateHTMLString + ellipsis;
		} else {
			return false;
		}
	}

	this.cancelEvent = function(e) {
		e = e ? e : window.event;
		if (e.stopPropagation)
			e.stopPropagation();
		if (e.preventDefault)
			e.preventDefault();
		e.cancelBubble = true;
		e.cancel = true;
		e.returnValue = false;
		return false;
	}

	// show pop up function, uses jquery functions
	this.hidePopup = function() {
		var buttonPopUps = this.buttonPopUps;
		for ( var i = 0; i < buttonPopUps.length; i++) {
			$(buttonPopUps[i].obj).hide();
		}
	}

	this.showPopup = function(id, launcherObj, popupText, style) {
		var poppingUp = false;
		var alreadyExists = false;
		var buttonPopUps = this.buttonPopUps;

		if (id == null || launcherObj == null) {
			poppingUp = false;
		} else {
			if (popupText == null) {
				popupText = 'POP UP';
			}
			if (style == null)
				style = 'blueBubble'; // default popup style
			for ( var i = 0; i < buttonPopUps.length; i++) {
				if (buttonPopUps[i].id == id)
					alreadyExists = true;
			}
			if (!alreadyExists) {
				switch (style) {
				case "blueBubble":
					try {
						for ( var i = 0; i < buttonPopUps.length; i++) {
							$(buttonPopUps[i].obj).hide();
						}

						var launcherJ = $(launcherObj);
						var launcherPos = launcherJ.position();

						var popupContainer = document.createElement('div');
						popupContainer
								.setAttribute(
										((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
												: 'class'),
										'dio-card-wrecks-buttons-popup');
						popupContainer.innerHTML = '';

						var popupTextBubble = document.createElement('div');
						popupTextBubble
								.setAttribute(
										((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
												: 'class'),
										'buttons-popup-container');
						popupTextBubble.innerHTML = '';

						var popupTextBubbleLeft = document.createElement('div');
						popupTextBubbleLeft
								.setAttribute(
										((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
												: 'class'),
										'buttons-popup-container-left');
						popupTextBubbleLeft.innerHTML = '<img src="'
								+ diogenesServer
								+ '/sitewide/img/meter/spacer.gif" border="0" width="1" height="1">';
						var popupTextBubbleMiddle = document
								.createElement('div');
						popupTextBubbleMiddle
								.setAttribute(
										((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
												: 'class'),
										'buttons-popup-container-text');
						popupTextBubbleMiddle.innerHTML = popupText;
						var popupTextBubbleRight = document
								.createElement('div');
						popupTextBubbleRight
								.setAttribute(
										((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
												: 'class'),
										'buttons-popup-container-right');
						popupTextBubbleRight.innerHTML = '<img src="'
								+ diogenesServer
								+ '/sitewide/img/meter/spacer.gif" border="0" width="1" height="1">';
						var popupTextBubbleClear = document
								.createElement('div');
						popupTextBubbleClear.style.clear = 'both';

						var popupPointerContainer = document
								.createElement('div');
						popupPointerContainer
								.setAttribute(
										((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
												: 'class'),
										'buttons-popup-pointer-container');
						popupPointerContainer.innerHTML = '';

						var popupPointer = document.createElement('div');
						popupPointer
								.setAttribute(
										((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
												: 'class'),
										'buttons-popup-pointer');
						popupPointer.innerHTML = '<img src="'
								+ diogenesServer
								+ '/sitewide/img/meter/spacer.gif" border="0" width="1" height="1">';

						popupContainer.appendChild(popupTextBubble);
						popupTextBubble.appendChild(popupTextBubbleLeft);
						popupTextBubble.appendChild(popupTextBubbleMiddle);
						popupTextBubble.appendChild(popupTextBubbleRight);
						popupTextBubble.appendChild(popupTextBubbleClear);
						popupPointerContainer.appendChild(popupPointer);
						popupContainer.appendChild(popupPointerContainer);

						launcherObj.appendChild(popupContainer);
						var popupContainerJ = $(popupContainer);
						var popupPointerContainerJ = $(popupPointerContainer);
						popupContainerJ.show();
						var popupHalf = Math.round(popupContainerJ.width() / 2);
						var launcherHalf = Math.round(launcherJ.width() / 2);
						var popupNewLeft = launcherPos.left + launcherHalf
								- popupHalf;
						popupContainerJ.css('top', launcherPos.top - 3);
						popupContainerJ.css('left', popupNewLeft);

						var popupTextBubbleWidth = $(popupTextBubble).width(); // get
																				// the
																				// width
																				// of
																				// text
																				// bubble
						popupPointerContainerJ.css('width',
								popupTextBubbleWidth + 'px'); // set the
																// container for
																// the pointer
																// so pointer
																// would be
																// centered to
																// text bubble
						// console.log(popupTextBubbleWidth);

						this.buttonPopUps.push({
							'id' : id,
							'obj' : popupContainer,
							'textObj' : popupTextBubbleMiddle,
							'width' : popupTextBubbleWidth
						});

						poppingUp = true;
					} catch (e) {
						// console.log(e);
						poppingUp = false;
					}
					break;
				case "other":

					break;
				}
			} else {
				// popup already exists, just show
				for ( var i = 0; i < buttonPopUps.length; i++) {
					if (buttonPopUps[i].id == id) {
						$(buttonPopUps[i].obj).show();
						poppingUp = true;
					}
				}
			}
		}
		// console.log(buttonPopUps.length);
		return poppingUp;
	}
}

Diogenes.Card = function(divId, artistId, options) {

	var ptr = this; // self pointer
	var enabledTabs = ('enableTabs' in options) ? options.enableTabs
			: DiogenesConfig.TabsEnabled;
	var pulltab_down = '<img src="/sitewide/img/meter/card-bottom-pulltab.gif" width="426" height="16" border="0"/>';
	var pulltab_up = '<img src="/sitewide/img/meter/card-bottom-pulltab-expanded.gif" width="426" height="16" border="0"/>';

	this.cStyle = ('style' in options) ? options.style : "full"; // card
																	// style
	this.collapsible = ('collapsible' in options) ? options.collapsible : true; // if
																				// card
																				// is
																				// clickable
																				// to
																				// collapse/expand
	this.divId = divId; // div container to append everything to
	this.artistId = artistId; // echonest id or artist alias
	this.echoId = ('echoId' in options) ? options.echoId : ""; // to store
																// echonest id
																// if provided
	if (this.echoId == "" && !this.mtvnUniverse && !this.numericId)
		this.echoId = artistId;
	this.rhapId = ""; // rhapsody artist id
	this.mtvnUniverse = ('mtvn' in options) ? options.mtvn : false; // IF
																	// artistId
																	// is an
																	// artist
																	// alias
	this.numericId = ('numericId' in options) ? options.numericId : false; // IF
																			// mtv
																			// artist
																			// id
																			// is
																			// the
																			// numeric
																			// id
	this.artistMtvnId = ('artistMtvnId' in options) ? options.artistMtvnId : ""; // artist
																					// numerical
																					// id
	this.artistName = ('artistName' in options) ? options.artistName : ""; // get
																			// artist
																			// name
																			// if
																			// echonest
																			// artist
	this.echoProfileObj = null;
	this.artistUmaId = ""; // The artist id (if not provided) from mtvn
							// dataservice if it's mtvn universe artist
	this.rank = ('rank' in options) ? options.rank : 0; // rank number on the
														// card
	this.datasource = ('datasource' in options) ? options.datasource : null;
	this.thumbDatasource = ('thumbDatasource' in options) ? options.thumbDatasource
			: [];
	this.expanded = false; // status of the card
	this.initiated = false; // if the card contents has been loaded once already
	this.loaded = false; // if the card has been created
	this.showName = ('showName' in options) ? options.showName : true; // name
																		// shows
																		// on
																		// card
	this.simLinkReferrer = ('simLinkReferrer' in options) ? options.simLinkReferrer
			: ''; // referrer to be attached after similar link

	this.jqueryAutocomplete = null; // pointer to jquery autocomplete

	this.externalEmbeds = null; // object for externally programmed embeds, if
								// programmed it will get picked up by tab quick
								// check

	this.cardWidth = ('cardwidth' in options) ? options.cardwidth : 800;
	this.cardHeight = ('cardheight' in options) ? options.cardheight : 80;
	this.rows = ('rows' in options) ? options.rows : 10;

	this.requestType = ('requestType' in options) ? options.requestType : "";
	this.returnType = ('returnType' in options) ? options.returnType : "xml";

	this.tabs = new Array();
	this.activeTab = null;
	this.tabsChecked = false;

	this.enableShare = ('share' in options) ? options.share : true;
	this.enableFav = ('fav' in options) ? options.fav : true;
	this.enableSimilar = ('sim' in options) ? options.sim : true;
	this.enableSearch = ('search' in options) ? options.search : false;
	this.enableEmbed = ('embed' in options) ? options.embed : true;

	this.listen = ('listen' in options) ? options.listen : {
		name : 'Listen',
		enabled : enabledTabs.Listen,
		module : null
	};
	// if (this.listen.enabled) this.tabs.push(this.listen);

	this.tweet = ('tweet' in options) ? options.tweet : {
		name : 'Tweets',
		enabled : enabledTabs.Tweets,
		module : null
	};
	this.tour = ('tour' in options) ? options.tour : {
		name : 'Tour',
		enabled : enabledTabs.Tour,
		module : null
	};
	// if (this.tweet.enabled) this.tabs.push(this.tweet);

	this.videos = ('videos' in options) ? options.videos : {
		name : 'Videos',
		enabled : enabledTabs.Videos,
		module : null
	};
	// if (this.videos.enabled && this.mtvnUniverse)
	// this.tabs.push(this.videos);

	this.photos = ('photos' in options) ? options.photos : {
		name : 'Photos',
		enabled : enabledTabs.Photos,
		module : null
	};
	// if (this.photos.enabled && this.mtvnUniverse)
	// this.tabs.push(this.photos);

	this.blog = ('blog' in options) ? options.blog : {
		name : 'Blogs',
		enabled : enabledTabs.Blogs,
		module : null
	};
	// if (this.blog.enabled) this.tabs.push(this.blog);

	this.bio = ('bio' in options) ? options.bio : {
		name : 'Bios',
		enabled : enabledTabs.Bios,
		module : null
	};
	// if (this.bio.enabled) this.tabs.push(this.bio);

	this.sim = ('sim' in options) ? options.sim : {
		name : 'Similar',
		enabled : enabledTabs.Similar,
		module : null
	};
	// if (this.sim.enabled) this.tabs.push(this.sim);

	this.card = document.createElement('div');
	this.card.setAttribute(((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
			: 'class'), 'dio-card');
	if (this.cStyle == 'embed')
		this.card.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card dio-card-embed');
	this.card.setAttribute('id', 'dio-card-id-' + this.artistId);

	this.card_pulltab = card_pulltab = document.createElement('div');
	this.card_pulltab.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-bottom-pulltabs');
	this.card_pulltab.innerHTML = pulltab_down;

	this.wrecksButtonLink = null;
	this.recdButtonLink = null;
	this.cardBottomLink = null;

	this.cardThumbDOMObj = null;
	this.cardInfoDOMObj = null;
	this.cardRankDOMObj = null;
	this.cardDebugDiv = null;

	this.familiarityScoreDomObj = null;

	this.stageLoadingDiv = document.createElement('div');
	this.stageLoadingDiv.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-stage-loading');
	this.stageLoadingDiv.innerHTML = this.stageProcessingHTML;

	this.stage = document.createElement('div');
	this.stage.setAttribute(((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
			: 'class'), 'dio-card-stage');
	this.buttons = document.createElement('div');
	this.buttons.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-buttons');
	this.wrecks = document.createElement('div');
	this.wrecks.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks');

	/* create rec'd and wreck'd section */
	var mtvUrlParam = (this.mtvnUniverse) ? '?mtv=yes&mtvnumeric=yes' : '';
	// mtvUrlParam += (this.numericId) ? '&mtvnumeric=yes' : '';

	// this.wrecks.innerHTML = '<div class="dio-card-wrecks-divider"><img
	// src="'+diogenesServer+'/sitewide/img/meter/spacer.gif" border="0"
	// width="1" height="1"></div>';
	// this.wrecks.innerHTML += '<div class="dio-card-wrecks-button-wreckd"><a
	// href="index.jhtml?q=wreckd&artistName='+encodeURIComponent(this.artistName)+'"><img
	// src="'+diogenesServer+'/sitewide/img/meter/button-get-wreckd.jpg"
	// border="0"></a></div>';
	// this.wrecks.innerHTML += '<div class="dio-card-wrecks-button-recd"><a
	// href="index.jhtml?q=recd&id='+this.artistId+'&artistName='+encodeURIComponent(this.artistName)+mtvUrlParam+'"><img
	// src="'+diogenesServer+'/sitewide/img/meter/button-get-recd.jpg"
	// border="0"></a></div>';
	// this.wrecks.innerHTML += '<div style="clear: both;"></div>';

	var artistLinkId = (this.artistMtvnId) ? this.artistMtvnId : this.artistId;

	var wrecksButtonsDivider = document.createElement('div');
	wrecksButtonsDivider.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-buttons-divider');
	wrecksButtonsDivider.innerHTML = '<img src="'
			+ diogenesServer
			+ '/sitewide/img/meter/spacer.gif" border="0" width="1" height="1">';
	var wrecksButtonsContainer = document.createElement('div');
	wrecksButtonsContainer.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-buttons-container');
	var wrecks_dividers = document.createElement('div');
	wrecks_dividers.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-divider');
	wrecks_dividers.innerHTML = '<img src="'
			+ diogenesServer
			+ '/sitewide/img/meter/spacer.gif" border="0" width="1" height="1">';
	var wrecks_wrecks_button = document.createElement('div');
	wrecks_wrecks_button.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-button-wreckd');
	var wrecks_wrecks_button_link = document.createElement('a');
	wrecks_wrecks_button_link.innerHTML = '<img src="' + diogenesServer
			+ '/sitewide/img/meter/footer-button-getwreck.gif" border="0">';
	// if (DiogenesConfig.useLauncher)
	// wrecks_wrecks_button_link.onclick =
	// function(){dioLaunchList({'textBody':'wreckd',
	// 'title':DiogenesConfig.wreckListHeaderText+ptr.artistName,
	// 'description':DiogenesConfig.wreckListDescText+ptr.artistName},
	// {"artistId":ptr.artistId,"artistName":ptr.artistName,"mtvn":ptr.mtvnUniverse});
	// return false;};
	// wrecks_wrecks_button_link.href =
	// ''+diogenesServer+'/meter/artist/'+dioFlattenArtistNames(ptr.artistName)+'/'+artistLinkId.toString()+'/dissimilar?artistName='+encodeURIComponent(this.artistName);
	wrecks_wrecks_button.appendChild(wrecks_wrecks_button_link);
	this.wrecksButtonLink = wrecks_wrecks_button_link;
	// wrecks_wrecks_button_link.onmouseover = function(){
	// ptr.showPopup(divId+'_wreck_popup' ,wrecks_wrecks_button,
	// DiogenesConfig.wreckListButtonPopupText)};
	// wrecks_wrecks_button_link.onmouseout = function(){ ptr.hidePopup(); }

	var wrecks_recd_button = document.createElement('div');
	wrecks_recd_button.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-button-recd');
	var wrecks_recd_button_link = document.createElement('a');
	wrecks_recd_button_link.innerHTML = '<img src="'
			+ diogenesServer
			+ '/sitewide/img/meter/footer-button-similar2.gif" border="0"><br/> Similar';
	// if (DiogenesConfig.useLauncher)
	// wrecks_recd_button_link.onclick =
	// function(){dioLaunchList({'textBody':'recd',
	// 'title':DiogenesConfig.recdListHeaderText+ptr.artistName,
	// 'description':DiogenesConfig.recdListDescText+ptr.artistName},
	// {"artistId":ptr.artistId,"artistName":ptr.artistName,"mtvn":ptr.mtvnUniverse});
	// return false;};
	// wrecks_recd_button_link.href =
	// ''+diogenesServer+'/meter/artist/'+dioFlattenArtistNames(ptr.artistName)+'/'+artistLinkId.toString()+'/similar'+mtvUrlParam;
	wrecks_recd_button.appendChild(wrecks_recd_button_link);
	this.recdButtonLink = wrecks_recd_button_link;
	// wrecks_recd_button_link.onmouseover = function(){
	// ptr.showPopup(divId+'_recd_popup' ,wrecks_recd_button,
	// DiogenesConfig.recdListButtonPopupText)};
	// wrecks_recd_button_link.onmouseout = function(){ ptr.hidePopup(); }
	var wrecks_clear_div = document.createElement('div');
	wrecks_clear_div.style.clear = 'both';

	var familiarity_score = document.createElement('div');
	familiarity_score.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-button-familiarity-score');
	this.familiarityScoreDomObj = familiarity_score;

	var addThis = document.createElement('div');
	addThis.setAttribute(((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
			: 'class'), 'dio-card-wrecks-button-addThis');

	this.addThisDomObj = addThis;

	this.embedPopUpTimer = null; // to track if an embed popup needs to close

	var embedCodePopup = document.createElement('div');
	embedCodePopup.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-button-embed-popup');
	var embedCodePopupBottomArrow = document.createElement('div');
	embedCodePopupBottomArrow.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-button-embed-popup-bottom-arrow');
	embedCodePopupBottomArrow.innerHTML = '<img src="'
			+ diogenesServer
			+ '/sitewide/img/meter/footer-button-embed-bottom-arrow.gif" border="0" />';

	var embedCodePopupForm = document.createElement('form');
	var embedCodePopupInput = document.createElement('input');
	embedCodePopupInput.setAttribute('id', 'dio-card-id-' + this.echoId
			+ '-embed-input');
	embedCodePopup.appendChild(embedCodePopupForm);
	embedCodePopup.appendChild(embedCodePopupBottomArrow);

	var embedCodePopupCopyButton = document.createElement('div');
	embedCodePopupCopyButton.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-button-embed-popup-copybutton');
	embedCodePopupCopyButton.setAttribute('id', 'dio-card-id-' + this.echoId
			+ '-embed-copybutton');
	embedCodePopupCopyButton.onmouseover = function() {
		this.style.cursor = 'pointer';
	}
	embedCodePopupCopyButton.onmouseout = function() {
		this.style.cursor = 'default';
	}
	// embedCodePopupCopyButton.onclick = function(){ ptr.copyEmbedCode(); };
	embedCodePopupCopyButton.innerHTML = '<img src="' + diogenesServer
			+ '/sitewide/img/meter/footer-button-embed-copy.gif" border="0" />';
	embedCodePopupInput.value = '<iframe name="mtvMusicMeterCardIframe" width="100%" height="435" src="http://www.mtvmusicmeter.com/card/'
			+ this.echoId
			+ '" frameborder="0" scrolling="no" type="text/html"></iframe>';

	embedCodePopupForm.appendChild(embedCodePopupCopyButton);
	embedCodePopupForm.appendChild(embedCodePopupInput);
	this.embedCodePopupCopyButton = embedCodePopupCopyButton;
	this.embedCodePopupObj = embedCodePopup;
	this.embedCodePopupInput = embedCodePopupInput;

	/* attaching zero clipboard to the copy button */
	this.zeroClip = new ZeroClipboard.Client();
	this.zeroClip.setText('');
	this.zeroClip.addEventListener('mouseDown', function() {
		ptr.zeroClip.setText(ptr.embedCodePopupInput.value);
		ptr.copyEmbedCode();
	});
	/* end of zero clipboard code */

	var embedCodePopupButton = document.createElement('div');
	embedCodePopupButton.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-button-embed-popupbutton');
	var embedCodePopupButtonDiv = document.createElement('div');
	embedCodePopupButtonDiv.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-button-embed-popupbutton-container');
	var embedCodePopupButtonLink = document.createElement('a');
	embedCodePopupButtonLink.onclick = function() {
		ptr.hideEmbedPopup()
	};
	embedCodePopupButtonLink.onmouseover = function() {
		this.style.cursor = 'pointer';
	}
	embedCodePopupButtonLink.onmouseout = function() {
		this.style.cursor = 'default';
	}
	embedCodePopupButtonLink.innerHTML = '<img src="'
			+ diogenesServer
			+ '/sitewide/img/meter/footer-button-embed-hl.gif" border="0" /><br/>Embed';
	embedCodePopupButtonDiv.appendChild(embedCodePopupButtonLink);
	embedCodePopupButton.appendChild(embedCodePopupButtonDiv);
	this.embedCodePopupButtonObj = embedCodePopupButton;

	var embedCodeButton = document.createElement('div');
	embedCodeButton.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-button-embed');
	var embedCodeButtonDiv = document.createElement('div');
	embedCodeButtonDiv.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-button-embed-container');
	var embedCodeButtonLink = document.createElement('a');
	embedCodeButtonLink.onclick = function() {
		ptr.showEmbedPopup();
		ptr.changeEmbedButtonLink('close');
	};
	embedCodeButtonLink.onmouseover = function() {
		this.style.cursor = 'pointer';
	}
	embedCodeButtonLink.onmouseout = function() {
		this.style.cursor = 'default';
	}
	embedCodeButtonLink.innerHTML = '<img src="'
			+ diogenesServer
			+ '/sitewide/img/meter/footer-button-embed2.gif" border="0" /><br/>Embed';
	embedCodeButtonDiv.appendChild(embedCodeButtonLink);
	embedCodeButton.appendChild(embedCodeButtonDiv);

	this.embedCodeButtonObj = embedCodeButton;
	this.embedCodeButtonLinkObj = embedCodeButtonLink;

	var addToFavorites = document.createElement('div');
	addToFavorites.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-button-addToFavorites');

	this.addToFavoritesDomObj = addToFavorites;

	var wrecks_text_or = document.createElement('div');
	wrecks_text_or.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-text');
	wrecks_text_or.innerHTML = ' OR ';

	var searchButton = document.createElement('div');
	searchButton.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-button-search');
	searchButton.innerHTML = '<a href="javascript:void(0)"><img src="'
			+ diogenesServer
			+ '/sitewide/img/meter/footer-button-search.gif" border="0" /><br/>Search</a>';

	this.searchButtonObj = searchButton;

	var wrecks_separator1 = document.createElement('div');
	wrecks_separator1.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-wrecks-separator');
	wrecks_separator1.innerHTML = '<img src="'
			+ diogenesServer
			+ '/sitewide/img/meter/spacer.gif" border="0" width="1" height="1">';
	var wrecks_separator2 = wrecks_separator1.cloneNode(true);
	var wrecks_separator3 = wrecks_separator1.cloneNode(true);
	var wrecks_separator4 = wrecks_separator1.cloneNode(true);

	// this.wrecks.appendChild(wrecks_dividers);
	// wrecksButtonsContainer.appendChild(wrecks_separator1);
	var wrecksButtonsContainerWidth = 0;
	if (this.enableShare) {
		wrecksButtonsContainer.appendChild(addThis);
		wrecksButtonsContainerWidth += 80;
	}
	// wrecksButtonsContainer.appendChild(wrecks_separator2);
	if (this.enableEmbed) {
		wrecksButtonsContainer.appendChild(embedCodeButton);
		// wrecksButtonsContainer.appendChild(embedCodePopupButton);
		wrecksButtonsContainer.appendChild(embedCodePopup);
		wrecksButtonsContainerWidth += 80;
	}
	if (this.enableFav) {
		wrecksButtonsContainer.appendChild(addToFavorites);
		wrecksButtonsContainerWidth += 80;
	}
	// wrecksButtonsContainer.appendChild(wrecks_separator3);
	if (this.enableSimilar) {
		wrecksButtonsContainer.appendChild(wrecks_recd_button);
		wrecksButtonsContainerWidth += 80;
	}
	// if (this.enableSearch){ wrecksButtonsContainer.appendChild(searchButton);
	// wrecksButtonsContainerWidth+=80; }
	if (document.all && (Dio_IE_Ver < 8.0)) {
		wrecksButtonsContainer.style.setAttribute('cssText', 'width:'
				+ wrecksButtonsContainerWidth + 'px;');
	} else {
		wrecksButtonsContainer.setAttribute('style', 'width:'
				+ wrecksButtonsContainerWidth + 'px;');
	}
	// wrecksButtonsContainer.appendChild(wrecks_text_or);
	// wrecksButtonsContainer.appendChild(wrecks_wrecks_button);
	// wrecksButtonsContainer.appendChild(wrecks_separator4);
	// this.wrecks.appendChild(familiarity_score);
	wrecksButtonsContainer.appendChild(wrecks_clear_div);

	this.wrecks.appendChild(wrecksButtonsDivider);
	this.wrecks.appendChild(wrecksButtonsContainer);

	/* end of rec'd/wreck'd section */

	this.player = document.createElement('div');
	this.player.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-card-player');

	this.searchBarContainer = null;
	this.expandSearchInput = function() {
		this.searchBarContainer.style.display = "block";
		var thisMeterCardSearhInput = document.getElementById('meterCardSearch'
				+ this.echoId);
		thisMeterCardSearhInput.focus();
		thisMeterCardSearhInput.onblur = function() {
			ptr.hideSearchInput();
		};
	}
	this.hideSearchInput = function() {
		this.searchBarContainer.style.display = "none";
	}

	this.createJqueryAutocomplete = function() { // create jquery
													// autocomplete for the
													// search field, requires
													// jquery.ui
		/* METER CARD TYPEAHEAD INIT */
		// console.log('#meterCardSearch'+ptr.echoId + ' = ' +
		// $J('#meterCardSearch'+ptr.echoId).length);
		if ($J('#meterCardSearch' + ptr.echoId).length) {
			$J("#meterCardSearch" + ptr.echoId)
					.autocomplete(
							{
								cacheLength : 1,
								matchSubset : false,
								selectFirst : true,
								position : {
									my : "left top",
									at : "left bottom",
									collision : "none",
									offset : "-33 0"
								},
								source : function(request, response) {
									$J
											.ajax({
												url : "http://search.mtvnservices.com/typeahead/suggest/",
												dataType : "jsonp",
												jsonpCallback : "jsonpTypeahead",
												data : {
													format : "json",
													limit : "10",
													fl : "echonest_id,echonest_artist_name",
													siteName : "solr_diogenes",
													q : request.term
												},
												success : function(data) {
													response(
															$J
																	.map(
																			data.response.docs,
																			function(
																					item) {
																				var eArtistName = item.echonest_artist_name;
																				if (eArtistName.length > 38)
																					eArtistName = eArtistName
																							.substring(
																									0,
																									37)
																							+ "...";
																				return {
																					label : eArtistName,
																					value : item.echonest_id
																				}
																			}),
															request.term); // passing
																			// in
																			// request
																			// term
												}
											});
								},
								delay : 500,
								minLength : 1,
								focus : function(event, ui) {
									// $J("#meterCardSearch").val( ui.item.label
									// );
									return false;
								},
								open : function() { // when a suggestion pops up
													// check if an enter is
													// already registered, if so
													// trigger submission
									// console.log("suggestion open")
									var self = $J(this).data("autocomplete");
									var suggestionTerm = $J(this).data(
											"menuTerm");
									var currentInputVal = $J(this).val();
									var inputSubmitted = $J(this).data(
											"submitted");
									// console.log('suggestionTerm:'+suggestionTerm);
									// console.log('currentInputVal:'+currentInputVal);
									// console.log('inputSubmitted:'+inputSubmitted);
									if (inputSubmitted) {
										if (suggestionTerm == currentInputVal) {
											self
													._trigger(
															"select",
															"click",
															{
																item : self.menu.active
																		.data("item.autocomplete")
															});
											$J(this).data("submitted", false);
										} else {
											// $J(this).data("submitted",false);
										}
									}
								},
								select : function(event, ui) {

									var self = $J(this).data("autocomplete");
									var suggestionTerm = $J(this).data(
											"menuTerm");
									var currentInputVal = $J(this).val();
									var inputSubmitted = $J(this).data(
											"submitted");
									// console.log('suggestionTerm:'+suggestionTerm);
									// console.log('currentInputVal:'+currentInputVal);
									// console.log('inputSubmitted:'+inputSubmitted);

									if (suggestionTerm == currentInputVal) { // if
																				// the
																				// autocomplete
																				// term
																				// is
																				// matching
																				// the
																				// current
																				// value
																				// in
																				// input
										if (ui.item.label) {

											// MTVM.util.launchLoadingDialog();

											// var urlSafeArtistName =
											// encodeURIComponent(ui.item.label);
											var flattendArtistName = dioFlattenArtistNames(ui.item.label);
											// console.log("redirecting " +
											// currentInputVal + " : " +
											// suggestionTerm + " : " +
											// ui.item.label);
											var serverHostName = MTVM.config.serverHostName;
											if (document.location.hostname
													.indexOf("mtvmusicmeter") > -1) {
												switch (MTVM.config.serverPlatform) {
												case "l":
													serverHostName = "http://www.mtvhive-l.mtvi.com/";
													break;
												case "d":
													serverHostName = "http://www.mtvmusicmeter-d.mtvi.com/";
													break;
												case "q":
													serverHostName = "http://www.mtvmusicmeter-q.mtvi.com/";
													break;
												default: // live
													serverHostName = "http://www.mtvmusicmeter.com/";
													break;
												}
											}

											if (DiogenesConfig != null) {
												// console.log(serverHostName)
												// parent.location.href =
												// serverHostName+DiogenesConfig.siteRoot+'artist/'
												// + flattendArtistName + '/' +
												// ui.item.value + '/';
												var searchResultNewWin = window
														.open(serverHostName
																+ DiogenesConfig.siteRoot
																+ 'artist/'
																+ flattendArtistName
																+ '/'
																+ ui.item.value
																+ '/');
											} else {
												// document.location.href =
												// serverHostName+'meter/artist/'
												// + flattendArtistName + '/' +
												// ui.item.value + '/';
												// parent.location.href =
												// serverHostName+'artist/' +
												// flattendArtistName + '/' +
												// ui.item.value + '/';
												var searchResultNewWin = window
														.open(serverHostName
																+ 'artist/'
																+ flattendArtistName
																+ '/'
																+ ui.item.value
																+ '/');
											}
										}
									}
									return false;
								}
							}).bind("keydown.autocomplete", function(event) { // binding
																				// an
																				// extra
																				// keydown
																				// event
																				// to
																				// capture
																				// the
																				// enter
																				// being
																				// pressed
						var self = $J(this).data("autocomplete");
						var inputSubmitted = $J(this).data("submitted");
						var keyCode = $J.ui.keyCode;
						switch (event.keyCode) {
						case keyCode.BACKSPACE:
							if (inputSubmitted)
								$J(this).data("submitted", false);
							break;
						case keyCode.ENTER:
						case keyCode.NUMPAD_ENTER:
						case keyCode.TAB:
							// console.log(self.menu.active.data(
							// "item.autocomplete"))
							if (!inputSubmitted)
								$J(this).data("submitted", true); // registering
																	// the
																	// submission
																	// being
																	// entered
							// console.log($J(this).data("submitted"))
							break;
						default:
							break;
						}
					})

			// Add a heading to the suggestions dropdown
			var ac_dioSearch = $J('#meterCardSearch' + ptr.echoId).data(
					"autocomplete");

			ac_dioSearch._response = function(content, term) {
				if (content.length) {
					content = this._normalize(content);
					this._suggest(content);
					this.element.data("menuTerm", term);
					this._trigger("open");
				} else {
					this._showNoResult(); // HiveMeter modification: show no
											// result dropdown
				}
				this.element.removeClass("ui-autocomplete-loading");
			}

			var ac_dioSearchMenu = ac_dioSearch.menu;
			// console.log($J(ac_dioSearchMenu))
			ac_dioSearchMenu.element.addClass("mtvmusicmeter-card-typeahead");
			ac_dioSearchMenu.options.blur = function(event, ui) { // HiveMeter
																	// modification:
																	// do not
																	// repopulate
																	// input on
																	// suggestion
																	// popping
																	// up
				// don't set the value of the text field if it's already correct
				// this prevents moving the cursor unnecessarily
				if (ac_dioSearch.menu.element.is(":visible")
						&& (ac_dioSearch.element.val() !== ac_dioSearch.term)) {
					// self.element.val( self.term );
				}
			}

			$J('#meterCardSearchSubmitButton' + ptr.echoId).mousedown(
					function(event) {
						event.stopPropagation();
						event.stopImmediatePropagation();
						event.preventDefault();
						$J('#meterCardSearch' + ptr.echoId).focus();
						var ac = $J('#meterCardSearch' + ptr.echoId).data(
								"autocomplete");
						if (ac.menu.active) {
							ac._trigger("select", "click", {
								item : ac.menu.active.data("item.autocomplete")
							});
						}
						return false;
					});
		}

		/* END OF METER CARD TYPEAHEAD INIT */
	}

	this.actionHistory = new Array();
	this.copyEmbedCode = function() {
		this.embedCodePopupCopyButton.innerHTML = '<img src="'
				+ diogenesServer
				+ '/sitewide/img/meter/footer-button-embed-copied.gif" border="0" />';
	}
	this.changeEmbedButtonLink = function(type) {
		if (type != null) {
			switch (type) {
			case 'close':
				this.embedCodeButtonLinkObj.onclick = function() {
					ptr.hideEmbedPopup();
					ptr.changeEmbedButtonLink('open');
				};

				break;
			case 'open':
				this.embedCodeButtonLinkObj.onclick = function() {
					ptr.showEmbedPopup();
					ptr.changeEmbedButtonLink('close');
				};

				break;
			}
		}
	};
	this.showEmbedPopup = function() {

		this.embedCodePopupCopyButton.innerHTML = '<img src="'
				+ diogenesServer
				+ '/sitewide/img/meter/footer-button-embed-copy.gif" border="0" />';
		if (document.all && (Dio_IE_Ver < 8.0)) {
			this.embedCodePopupButtonObj.style.setAttribute('cssText',
					'display:block;');
			this.embedCodePopupObj.style.setAttribute('cssText',
					'display:block;');
		} else {
			this.embedCodePopupButtonObj
					.setAttribute('style', 'display:block;');
			this.embedCodePopupObj.setAttribute('style', 'display:block;');
		}
		this.embedCodePopupInput.focus();
		this.embedCodePopupInput.select();

		this.zeroClip.glue('dio-card-id-' + this.echoId + '-embed-copybutton'); // gluing
																				// the
																				// zero
																				// clipboard
																				// to
																				// the
																				// copy
																				// button

		this.embedCodeButtonLinkObj.style.color = '#0195db';
	}
	this.hideEmbedPopup = function() {
		if (document.all && (Dio_IE_Ver < 8.0)) {
			this.embedCodePopupButtonObj.style.setAttribute('cssText',
					'display:none;');
			this.embedCodePopupObj.style.setAttribute('cssText',
					'display:none;');
		} else {
			this.embedCodePopupButtonObj.setAttribute('style', 'display:none;');
			this.embedCodePopupObj.setAttribute('style', 'display:none;');
		}

		this.embedCodeButtonLinkObj.style.color = '#434343';
	}

	this.listenTabRemote = function(action) { // remote control for listen tab
												// if enabled
		if (this.listen.enabled) {

			var jplayerObj = $('#dio-module-listen-jplayer' + this.divId);
			if (jplayerObj != null) {

				var audioTab = ptr.getTab("audio"); // console.log(audioTab.playButtonId);
				if (audioTab.playButtonId != null) {

					var highlightingLink = $(audioTab.songsListDOMObj).find(
							audioTab.playButtonId);

					switch (action) {
					case "play":

						if (!audioTab.userPause) {

							if (highlightingLink != null) {
								highlightingLink.removeClass('paused');
								highlightingLink.addClass('playing');
							}

							jplayerObj.jPlayer("play");
							audioTab.paused = false;
						}

						break;
					case "pause":

						if (highlightingLink != null) {
							highlightingLink.removeClass('playing');
							highlightingLink.addClass('paused');
						}

						jplayerObj.jPlayer("pause");
						audioTab.paused = true;

						break;
					}

				}
			} else {
				// jplayerObj not found
			}

		}
	}

	this.updateWrecksButtons = function() {
		// var wrecksArtistId = (ptr.artistMtvnId!='') ? ptr.artistMtvnId :
		// ptr.artistId;
		var wrecksArtistId = ptr.echoId;
		if (DiogenesConfig.useLauncher)
			this.wrecksButtonLink.onclick = function() {
				dioLaunchList({
					'textBody' : 'wreckd',
					'title' : DiogenesConfig.wreckListHeaderText
							+ ptr.artistName,
					'description' : DiogenesConfig.wreckListDescText
							+ ptr.artistName
				}, {
					"artistId" : wrecksArtistId,
					"artistName" : ptr.artistName,
					"mtvn" : ptr.mtvnUniverse
				});
				return false;
			};
		this.wrecksButtonLink.href = '' + diogenesServer + '/'
				+ DiogenesConfig.siteRoot + 'artist/'
				+ dioFlattenArtistNames(ptr.artistName) + '/' + wrecksArtistId
				+ '/dissimilar?artistName='
				+ encodeURIComponent(this.artistName);
		if (DiogenesConfig.useLauncher)
			this.recdButtonLink.onclick = function() {
				dioLaunchList({
					'textBody' : 'recd',
					'title' : DiogenesConfig.recdListHeaderText
							+ ptr.artistName,
					'description' : DiogenesConfig.recdListDescText
							+ ptr.artistName
				}, {
					"artistId" : wrecksArtistId,
					"artistName" : ptr.artistName,
					"mtvn" : ptr.mtvnUniverse
				});
				return false;
				ptr.coda2reporting({
					'name' : DiogenesConfig.Reporting.Similar._name,
					'evarName' : DiogenesConfig.Reporting.Similar._eVar,
					'evarValue' : unescape(ptr.artistName)
				});
			};
		else
			this.recdButtonLink.onclick = function() {
				ptr.coda2reporting({
					'name' : DiogenesConfig.Reporting.Similar._name,
					'evarName' : DiogenesConfig.Reporting.Similar._eVar,
					'evarValue' : unescape(ptr.artistName)
				});
			};
		// this.recdButtonLink.href =
		// ''+diogenesServer+'/'+DiogenesConfig.siteRoot+'artist/'+dioFlattenArtistNames(ptr.artistName)+'/'+wrecksArtistId+'/similar'+mtvUrlParam;
		// this.recdButtonLink.href =
		// ''+diogenesServer+'/'+DiogenesConfig.siteRoot+'artist/'+dioFlattenArtistNames(ptr.artistName)+'/'+wrecksArtistId+'/similar';
		var serverOverride = (typeof MTVM.config.meterUrl != 'undefined') ? MTVM.config.meterUrl
				: diogenesServer;
		this.recdButtonLink.href = '' + serverOverride + '/'
				+ DiogenesConfig.siteRoot + 'artist/'
				+ dioFlattenArtistNames(ptr.artistName) + '/' + wrecksArtistId
				+ '/' + ptr.simLinkReferrer;
		if (this.cStyle == "embed") {
			this.recdButtonLink.target = "_blank";
		}
	}

	this.coda2reporting = function(args) {
		if (typeof mtvn != 'undefined') {
			if (typeof mtvn.btg.Controller != 'undefined') {
				var name = ('name' in args) ? args.name : '';
				var evarName = ('evarName' in args) ? args.evarName : '';
				var evarValue = ('evarValue' in args) ? args.evarValue : '';

				if (name != '' && evarName != '' && evarValue != '') {
					var sendLinkEventPropStr = '({"linkName":"' + name
							+ '","linkType":"o","' + evarName + '":"'
							+ evarValue.replace(/"/g, '\\"') + '"})';
					var sendLinkEventPropObj = eval(sendLinkEventPropStr);
					// console.log(sendLinkEventPropObj)

					// Send a link event call
					if (typeof MTVM.config.serverPlatform != 'undefined'
							&& MTVM.config.serverPlatform != 'lo') {
						mtvn.btg.Controller.sendLinkEvent(sendLinkEventPropObj);
					}
				}
			}
		}
	}

	this.setStatus = function() {
		if (this.expanded)
			this.expanded = false;
		else
			this.expanded = true;
		// console.log(ptr.expanded);
	}

	this.getTab = function(tabName) {
		if (tabName == null)
			return false;

		for ( var i = 0; i < this.tabs.length; i++) { // loop through tabs for
														// this card
			// console.log(this.tabs[i].module.notClickedHTML)
			if (this.tabs[i].module != null
					&& this.tabs[i].module.notClickedHTML == tabName
							.toUpperCase()) { // matching tab name
				return this.tabs[i].module;
			}
		}
	}
	this.checkExternalEmbeds = function() { // checking for obj
											// 'mmVidTabProgramming' to see if
											// this artist is programmed
											// externally
		var videosTab = ptr.getTab("videos");
		var externalEmbed = false;
		if (typeof mmVidTabProgramming != 'undefined') {
			for ( var i = 0; i < mmVidTabProgramming.as.length; i++) {
				var as = mmVidTabProgramming.as[i];
				if (as.aid == this.echoId) {
					videosTab.externalEmbeds = as;
					externalEmbed = true;
					videosTab.buttonDiv.onclick = videosTab.toggle;
					videosTab.buttonDiv.setAttribute(
							((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
									: 'class'), 'dio-card-buttons-links');
				}
			}
		}
		return externalEmbed;
	}
	this.checkTabs = function(tqcObj) { // ajax handler for tab quick check
										// dataservice
		if (tqcObj != null) {

			ptr.tabsChecked = true;
			// { "tqc" : { "videos" : true , "photos" : true } }
			var videosTab = ptr.getTab("videos");
			if (videosTab != null) {
				if (!tqcObj.tqc.videos) {
					var externalEmbed = ptr.checkExternalEmbeds();
					if (!externalEmbed)
						if (videosTab)
							videosTab.disableThis();

				} else {
					videosTab.buttonDiv.onclick = videosTab.toggle;
					videosTab.buttonDiv.setAttribute(
							((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
									: 'class'), 'dio-card-buttons-links');
				}
			}
			var photosTab = ptr.getTab("photos");
			if (photosTab != null) {
				if (!tqcObj.tqc.photos) {
					if (photosTab)
						photosTab.disableThis();
				} else {
					photosTab.buttonDiv.onclick = photosTab.toggle;
					photosTab.buttonDiv.setAttribute(
							((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
									: 'class'), 'dio-card-buttons-links');
				}
			}
			var tourTab = ptr.getTab("tour");
			if(tourTab != null) {
				if (!tqcObj.tqc.tour) {
					if (tourTab)
						tourTab.disableThis();
				} else {
					tourTab.buttonDiv.onclick = tourTab.toggle;
					tourTab.buttonDiv.setAttribute(
							((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
									: 'class'), 'dio-card-buttons-links');
				}
			}
		
	}
	}
	this.checkTabsError = function(e) { // ajax error handler for tab quick
										// check dataservice
		if (e != null) {
			ptr.tabsChecked = false;
		}
	}

	this.tabsQuickCheck = function() {
		// console.log(this.tabsChecked)
		if (this.tabsChecked) {

		} else if (this.mtvnUniverse && !this.tabsChecked) {
			// var _tabQuickCheckURL = this.dsURL +
			// 'meter/tabsquickcheck/?id='+this.artistMtvnId+'&a='+this.artistId;
			var _tabQuickCheckURL = this.dsURL + 'meter/tabsquickcheck/?id='
					+ this.artistMtvnId + "&artistName=" + this.artistName;
			this.__loadData({
				url : _tabQuickCheckURL,
				data : '',
				successHandler : ptr.checkTabs,
				errorHandler : ptr.checkTabsError,
				dataType : 'json'
			});
		} else if (!this.mtvnUniverse && !this.tabsChecked) {
			var videosTab = ptr.getTab("videos");
			var externalEmbed = ptr.checkExternalEmbeds();
			if (!externalEmbed)
				if (videosTab)
					videosTab.disableThis();
		} else {
			var videosTab = this.getTab("videos");
			videosTab.disableThis();
			var photosTab = this.getTab("photos");
			photosTab.disableThis();
		}
	}

	this.expandCardHandler = function() { // to deal with the artist data when
											// expanding

		ptr.createTabs();
		ptr.tabsQuickCheck();

		ptr.initiated = true;

		// grab the hostname and construct the proper directory structure
		baseURL = "http://www.mtvmusicmeter.com/artist/";
		// redressURL('.com/');
		// baseURL += '.com/'+DiogenesConfig.siteRoot+'artist/';

		var addThisArtistID = this.echoId;
		var addThisFlattenedArtistName = dioFlattenArtistNames(ptr.artistName);

		// ptr.addThisDomObj.innerHTML ='<div id="addThisDioCard"><a
		// href="javascript:void(0)" onclick="return addthis_open(this, \'\',
		// \''+baseURL+addThisFlattenedArtistName+'/'+ addThisArtistID +'\',
		// unescape(\'Discover '+ptr.artistName.replace(/'/g,"\\'")+' on the MTV
		// Music Meter\'))"><img
		// src="'+diogenesServer+'/sitewide/img/meter/footer-button-share2.gif"><br>Share</a></div>';
		var addThisDiv = document.createElement('div');
		addThisDiv.setAttribute('id', 'addThisDioCard');
		var addThisLink = document.createElement('a');
		addThisLink.href = 'javascript:void(0)';
		addThisLink.onclick = function() {
			// report share action
			ptr.coda2reporting({
				'name' : DiogenesConfig.Reporting.Share._name,
				'evarName' : DiogenesConfig.Reporting.Share._eVar,
				'evarValue' : unescape(ptr.artistName)
			});

			return addthis_open(addThisLink, '', baseURL
					+ addThisFlattenedArtistName + '/' + addThisArtistID,
					unescape('Discover ' + ptr.artistName.replace(/'/g, "\'")
							+ ' on the MTV Music Meter'));
		};
		addThisLink.innerHTML = '<img src="' + diogenesServer
				+ '/sitewide/img/meter/footer-button-share2.gif"><br>Share';

		addThisDiv.appendChild(addThisLink);
		ptr.addThisDomObj.appendChild(addThisDiv);

		var favPopUpText = DiogenesConfig.favoritesButtonPopupText;
		var addToFavoritesMtv = (ptr.mtvnUniverse) ? 'y' : 'n';
		var addToFavoritesMtvNum = (ptr.numericId) ? 'y' : 'n';
		var favObjString = "'id':'" + ptr.artistId + "','n':'"
				+ ptr.artistName.replace(/'/g, "\\'") + "'";
		// if (addToFavoritesMtv == "y") favObjString+=
		// ",'m':'"+addToFavoritesMtv+"'";
		// if (addToFavoritesMtvNum == "y") favObjString+=
		// ",'mn':'"+addToFavoritesMtvNum+"'";
		favObjString += (addToFavoritesMtv == "y") ? ",'m':'y'" : ",'m':'n'";
		favObjString += (addToFavoritesMtvNum == "y") ? ",'mn':'"
				+ addToFavoritesMtvNum + "'" : "";
		if (typeof dioFavoritesObjArray == 'undefined') {
			// addToFavoritesLinkText = "Add to favorites";
			addToFavoritesLinkText = '<img src="'
					+ diogenesServer
					+ '/sitewide/img/meter/footer-button-favorite-off.gif" border="0">';
		} else if (dioFavoritesObjArray.length == 0) {
			// addToFavoritesLinkText = "Add to favorites";
			addToFavoritesLinkText = '<img src="'
					+ diogenesServer
					+ '/sitewide/img/meter/footer-button-favorite-off.gif" border="0">';
		} else {
			var dup = false;
			for ( var i = 0; i < dioFavoritesObjArray.length; i++) {
				if (ptr.artistId == dioFavoritesObjArray[i].id)
					dup = true;
			}
			addToFavoritesLinkText = (dup) ? '<img src="'
					+ diogenesServer
					+ '/sitewide/img/meter/footer-button-favorite.gif" border="0">'
					: '<img src="'
							+ diogenesServer
							+ '/sitewide/img/meter/footer-button-favorite-off.gif" border="0">';
			if (dup)
				favPopUpText = DiogenesConfig.favoritedAlreadyText;
		}

		// ptr.addToFavoritesDomObj.innerHTML ='<div
		// id="addToFavoritesDioCard"><a href="javascript://"
		// onclick="dioRegisterFavorites({'+favObjString+'}, this,
		// \''+divId+'\')">'+addToFavoritesLinkText+'<br/>Favorite</a></div>';
		var addToFavDiv = document.createElement('div');
		addToFavDiv.setAttribute('id', 'addToFavoritesDioCard');
		var addToFavLink = document.createElement('a');
		addToFavLink.href = 'javascript:void(0)';
		addToFavLink.onclick = function() {
			var favObj = eval('({' + favObjString + '})');
			dioRegisterFavorites(favObj, addToFavLink, divId);

			// report favorite action
			ptr.coda2reporting({
				'name' : DiogenesConfig.Reporting.Favorite._name,
				'evarName' : DiogenesConfig.Reporting.Favorite._eVar,
				'evarValue' : unescape(ptr.artistName)
			});
		};
		addToFavLink.innerHTML = addToFavoritesLinkText + '<br/>Favorite';

		addToFavDiv.appendChild(addToFavLink);
		ptr.addToFavoritesDomObj.appendChild(addToFavDiv);

		/*
		 * ptr.addToFavoritesDomObj.onmouseover = function(){
		 * ptr.showPopup(divId+'_addfav_popup' ,ptr.addToFavoritesDomObj,
		 * favPopUpText)}; ptr.addToFavoritesDomObj.onmouseout = function(){
		 * ptr.hidePopup(); } ptr.addThisDomObj.onmouseover = function(){
		 * ptr.showPopup(divId+'_addthis_popup' ,ptr.addThisDomObj,
		 * DiogenesConfig.addThisButtonPopupText)}; ptr.addThisDomObj.onmouseout =
		 * function(){ ptr.hidePopup(); }
		 */

		for ( var i = 0; i < ptr.tabs.length; i++) { // set id to the player
														// div of this card for
														// flash player
			if (ptr.tabs[i].module != null
					&& ptr.tabs[i].module.notClickedHTML == "VIDEOS") {
				if (ptr.tabs[i].module.videoPlayerContainer != null) {
					// console.log("re-attaching player div")
					ptr.tabs[i].module.videoPlayerContainer.setAttribute('id',
							'MTVN_PL-video-player');
				}
			}
		}
	}

	this.expandRequestHandler = function(data) { // to deal with the artist
													// data when expanding
		try {
			ptr.echoProfileObj = data;
			// console.log("getting echonest artist data");
			if (data.profile.mtvnAlias != '') {
				ptr.artistId = data.profile.mtvnAlias;
			}
			if (data.profile.mtvnId != '') {
				ptr.artistMtvnId = data.profile.mtvnId;
			}
			if (data.profile.rhapId != '')
				ptr.rhapId = data.profile.rhapId;
			if (data.profile.name != '')
				ptr.artistName = data.profile.name;
			ptr.echoId = data.profile.echoNestId;

			if (data.profile.mtvnAlias != '') {
				ptr.mtvnUniverse = true;
			}
			if (ptr.artistMtvnId != '' && data.profile.mtvnAlias != '') {
				ptr.numericId = true;
			}
			if (ptr.artistMtvnId != '' && data.profile.mtvnAlias == '') {
				ptr.mtvnUniverse = true;
				ptr.numericId = true;
			}

			ptr.prepareTabs();
			ptr.updateWrecksButtons(); // enabling wrecks buttons

			ptr.expandCardHandler();
		} catch (e) {
			// console.log(e.name);
			// console.log(e.message);
		}
	}

	this.expand = function() {
		// reporting card opening event
		this.coda2reporting({
			'name' : DiogenesConfig.Reporting.CardOpen._name,
			'evarName' : DiogenesConfig.Reporting.CardOpen._eVar,
			'evarValue' : unescape(ptr.artistName)
		});

		// console.log("Expanding card "+ptr.artistId);

		// closing all cards.
		for ( var i = 0; i < this.dioCards.length; i++) {
			if (this.dioCards[i].expanded
					&& this.dioCards[i].divId != this.divId
					&& this.dioCards[i].cStyle == "full" && this.collapsible)
				this.dioCards[i].collapse();
		}

		if (!this.initiated) {

			if (this.echoProfileObj == null) {

				this.stage.appendChild(this.stageLoadingDiv);
				this.showLoading();

				var _echoProfileURL = this.dsURL + 'meter/echoprofile/?id='
						+ this.artistId;
				if (this.mtvnUniverse && this.numericId) {
					_echoProfileURL = this.dsURL + 'meter/echoprofile/?id='
							+ this.artistMtvnId + '&mtv=yes&mtvnumeric=yes';
				} else if (this.mtvnUniverse) {
					_echoProfileURL = this.dsURL + 'meter/echoprofile/?id='
							+ this.artistId + '&mtv=yes';
				}

				this.__loadData({
					url : _echoProfileURL,
					data : '',
					successHandler : this.expandRequestHandler,
					errorHandler : this.ajaxErrors,
					dataType : 'json'
				});

			} else {
				this.expandCardHandler();
			}
		} else {
			this.tabsQuickCheck();
		}

		ptr.doAnimate(ptr.buttons, ptr.TABS_HEIGHT, true);
		ptr.doAnimate(ptr.stage, ptr.STAGE_HEIGHT, true);
		ptr.doAnimate(ptr.wrecks, ptr.WRECKS_HEIGHT, true);
		ptr.doAnimate(ptr.player, ptr.PLAYER_HEIGHT, true);

		ptr.setStatus();

		this.card_pulltab.innerHTML = pulltab_up;

		DiogenesGlobal.activeCard = ptr;

		if (this.enableSearch)
			this.createJqueryAutocomplete();
	}

	this.collapse = function() {
		// console.log("Collapsing card "+ptr.artistId);

		this.hideEmbedPopup();

		for ( var i = 0; i < this.tabs.length; i++) { // remove id to the
														// player div of this
														// card for flash player
			if (this.tabs[i].module != null) {
				if (this.tabs[i].module.notClickedHTML == "VIDEOS") {
					if (this.tabs[i].module.videoPlayerContainer != null) {
						// console.log("re-attaching player div")
						this.tabs[i].module.videoPlayerContainer
								.removeAttribute('id');
						// MTVN_PL.PlaylistManager._widgetRegistry[divId]
					}
				}

				// reset audio tab flash player
				if (this.tabs[i].module.notClickedHTML == "AUDIO"
						&& this.tabs[i].module.initialized) {
					var jplayerObj = $('#dio-module-listen-jplayer'
							+ this.divId);
					if (jplayerObj != null) {
						jplayerObj.jPlayer("pause");

						this.tabs[i].module.paused = true;
						this.tabs[i].module.userPause = true;

						/*
						 * if (this.tabs[i].module.playButtonId != null){ var
						 * highlightingLink =
						 * $(this.tabs[i].module.songsListDOMObj).find(this.tabs[i].module.playButtonId);
						 * if (highlightingLink!=null){
						 * highlightingLink.removeClass('playing');
						 * highlightingLink.addClass('paused'); } }
						 */
						this.tabs[i].module.resetAllPlayButtons();
						this.tabs[i].module.currentPlayingIndex = null;
					}
				}
			}
		}

		ptr.doAnimate(ptr.buttons, 1, true);
		ptr.doAnimate(ptr.stage, 1, true);
		ptr.doAnimate(ptr.wrecks, 1, true);
		ptr.doAnimate(ptr.player, 1, true);

		ptr.setStatus();

		this.card_pulltab.innerHTML = pulltab_down;

		try {
			MTVN_PL.VideoHelper.player.pause(); // pausing video player

		} catch (e) {
		}

	}

	this.toggle = function() {
		if (ptr.expanded)
			ptr.collapse();
		else
			ptr.expand();
	}

	this.stageHideAll = function() {

		this.hideEmbedPopup();

		this.stageLoadingDiv.style.display = "none";

		for ( var i = 0; i < this.tabs.length; i++) { // set all tabs display
														// to false

			// reset audio tab flash player
			if (this.tabs[i].module != null
					&& this.tabs[i].module.notClickedHTML == "AUDIO"
					&& this.tabs[i].module.initialized) {
				/*
				 * var jplayerObj = $('#dio-module-listen-jplayer'+this.divId);
				 * if (jplayerObj!=null){ jplayerObj.jPlayer( "pause" );
				 * 
				 * this.tabs[i].module.paused = true;
				 * this.tabs[i].module.resetAllPlayButtons();
				 * this.tabs[i].module.currentPlayingIndex = null; }
				 */
			}

			// leave video tab visible for continuous playing else hide
			// if (this.tabs[i].module.notClickedHTML != "VIDEOS")
			// leave audio tab visible for continuous playing else hide
			if (this.tabs[i].module.notClickedHTML != "AUDIO")
				this.tabs[i].module.contentObj.style.display = "none";

		}

		try {
			MTVN_PL.VideoHelper.player.pause(); // pausing video player
		} catch (e) {
		}
	}

	this.stageShow = function(mid) {
		this.tabs[mid].module.contentObj.style.display = "block";
	}

	this.showLoading = function() {
		this.stageLoadingDiv.style.display = "block";
	}

	this.prepareTabs = function() {
		this.tabs = new Array();
		;
		if (this.listen.enabled)
			this.tabs.push(this.listen);
		// if (this.videos.enabled && this.mtvnUniverse)
		// this.tabs.push(this.videos);
		// if (this.photos.enabled && this.mtvnUniverse)
		// this.tabs.push(this.photos);
		if (this.videos.enabled)
			this.tabs.push(this.videos);
		if (this.photos.enabled)
			this.tabs.push(this.photos);
		if (this.tour.enabled)
			this.tabs.push(this.tour);
		if (this.tweet.enabled)
			this.tabs.push(this.tweet);
		if (this.blog.enabled)
			this.tabs.push(this.blog);
		if (this.bio.enabled)
			this.tabs.push(this.bio);
		if (this.sim.enabled)
			this.tabs.push(this.sim);
		
	}
	this.showTabs = function(tab) {

		if (tab == "reset") {
			// clear the buttons and stage area
			this.removeAllChildren(this.buttons);
			this.removeAllChildren(this.stage);

			// append the loading div
			this.stage.appendChild(this.stageLoadingDiv);
			// this.stageLoadingDiv.style.top = "0";
			// this.stageLoadingDiv.style.left = "0";
			// this.stageLoadingDiv.style.position = "relative";
			this.stageLoadingDiv.style.display = "none";

		}

		for ( var i = 0; i < this.tabs.length; i++) { // set all tabs clicked
														// to false

			if (tab == "reset") {

				var divider = document.createElement("span");
				divider.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-card-buttons-links');
				divider.innerHTML = "|";

				// if (i!=0) this.buttons.appendChild(divider); // draw divider
				this.buttons.appendChild(this.tabs[i].module.buttonDiv); // redraw
																			// tabs
				// console.log("drawing "+ this.tabs[i].module.buttonDiv);

				// append all content objects to the stage and set positioning
				// to relative to the container and hide
				this.stage.appendChild(this.tabs[i].module.contentObj);
				// this.tabs[i].module.contentObj.style.top = "0px";
				// this.tabs[i].module.contentObj.style.left = "0px";
				// this.tabs[i].module.contentObj.style.position = "relative";
				this.tabs[i].module.contentObj.style.display = "none";
			}
		}

		if (tab == "reset") {
			this.tabs[0].module.clicked = true; // set first tab to be clicked
												// and loaded into stage
			this.activeTab = this.tabs[0];
		} else {
			this.tabs[tab].module.clicked = true;
			this.activeTab = this.tabs[tab];
		}

		for ( var i = 0; i < this.tabs.length; i++) {
			/*
			 * console.log(i) console.log(this.tabs[i].module.notClickedHTML)
			 * console.log(this.tabs[i].module.clicked)
			 */
			if (this.tabs[i].module.clicked)
				this.tabs[i].module.opening();
		}

		var buttons_divider = document.createElement('div');
		buttons_divider.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card-wrecks-divider');
		buttons_divider.innerHTML = '<img src="'
				+ diogenesServer
				+ '/sitewide/img/meter/spacer.gif" border="0" width="1" height="1">';
		// this.buttons.appendChild(buttons_divider);
	}

	this.createTabs = function() {
		var tabsContainer = this.buttons;
		var tabs = this.tabs;
		for ( var i = 0; i < tabs.length; i++) {
			if (tabs[i].enabled) {
				// console.log("tab " + tabs[i].name + " = " + tabs[i].enabled);
				if (tabs[i].module == null) {
					// attempt load default tabs
					switch (tabs[i].name) {
					case "Bios":
						tabs[i].module = new Diogenes.Modules.Bios({
							cardObj : ptr,
							mid : i,
							dsURL : this.dsURL,
							params : 'id=blah',
							type : 'xml',
							targetDiv : this.buttons
						});
						break;
					case "Photos":
						tabs[i].module = new Diogenes.Modules.Photos({
							cardObj : ptr,
							mid : i,
							dsURL : this.dsURL,
							params : 'id=blah',
							type : 'xml',
							targetDiv : this.buttons
						});
						break;
					case "Listen":
						tabs[i].module = new Diogenes.Modules.Listen({
							cardObj : ptr,
							mid : i,
							targetDiv : this.buttons
						});
						break;
					case "Videos":
						tabs[i].module = new Diogenes.Modules.Videos({
							cardObj : ptr,
							mid : i,
							dsURL : this.dsURL,
							params : 'id=blah',
							type : 'json',
							targetDiv : this.buttons
						});
						break;
					case "Blogs":
						tabs[i].module = new Diogenes.Modules.Blogs({
							cardObj : ptr,
							mid : i,
							dsURL : this.dsURL,
							params : 'id=blah',
							type : 'xml',
							targetDiv : this.buttons
						});
						break;
					case "Tweets":
						tabs[i].module = new Diogenes.Modules.Tweets({
							cardObj : ptr,
							mid : i,
							dsURL : this.dsURL,
							refresh : true,
							params : 'id=blah',
							type : 'xml',
							targetDiv : this.buttons
						});
						break;
					case "Tour":
						tabs[i].module = new Diogenes.Modules.Tour({
							cardObj : ptr,
							mid : i,
							dsURL : this.dsURL,
							refresh : true,
							params : 'id=blah',
							type : 'json',
							targetDiv : this.buttons
						});
						break;	
					case "Similar":
						tabs[i].module = new Diogenes.Modules.Similar({
							cardObj : ptr,
							mid : i,
							dsURL : this.dsURL,
							params : 'id=blah',
							type : 'xml',
							targetDiv : this.buttons
						});
						break;
					}

				}

			}
		}

		this.showTabs('reset');

		// this.buttons.innerHTML = '<a href="javascript:void(0);" onclick=""
		// class="dio-card-buttons-tweets">TWEETS</a><a
		// href="javascript:void(0);" onclick=""
		// class="dio-card-buttons-blogs">BLOGS</a><a href="javascript:void(0);"
		// onclick="" class="dio-card-buttons-bios">BIOS</a><a
		// href="javascript:void(0);" onclick=""
		// class="dio-card-buttons-similar">SIMILAR</a>';

	}

	this.drawCardWithEchoProfile = function(data) { // Populate card info with
													// echonest Profile data
		ptr.echoProfileObj = data;
		// console.log("drawing card with echonest data");
		var familiarityScore = data.profile.familiarity;

		try {
			if (data.profile.mtvnAlias != '')
				ptr.artistId = data.profile.mtvnAlias;
			if (data.profile.mtvnId != '')
				ptr.artistMtvnId = data.profile.mtvnId;
			if (data.profile.rhapId != '')
				ptr.rhapId = data.profile.rhapId;
			if (artistMTVNName != '')
				ptr.artistName = data.profile.name;
			ptr.echoId = data.profile.echoNestId;

			var artistMTVNName = data.profile.name;
			var serverOverride = (typeof MTVM.config.meterUrl != 'undefined') ? MTVM.config.meterUrl
					: diogenesServer;
			var recsButtonLink = '' + serverOverride + '/'
					+ DiogenesConfig.siteRoot + 'artist/'
					+ dioFlattenArtistNames(artistMTVNName) + '/';
			// var recsButtonLinkId = ptr.artistId;
			var recsButtonLinkId = ptr.echoId;
			// var recsButtonLinkParams = '/similar';
			var recsButtonLinkParams = '/';

			if (data.profile.mtvnAlias != '') {
				ptr.mtvnUniverse = true;
				// recsButtonLinkId = ptr.artistId;
				// recsButtonLinkParams += '?mtv=yes';
			}
			if (ptr.artistMtvnId != '' && data.profile.mtvnAlias != '') {
				ptr.numericId = true;
				// recsButtonLinkId = ptr.artistMtvnId;
				// recsButtonLinkParams += '&mtvnumeric=yes';
			}
			if (ptr.artistMtvnId != '' && data.profile.mtvnAlias == '') {
				ptr.mtvnUniverse = true;
				ptr.numericId = true;
				// recsButtonLinkId = ptr.artistMtvnId;
				// recsButtonLinkParams += '?mtv=yes&mtvnumeric=yes';
			}

			ptr.prepareTabs();
			ptr.updateWrecksButtons(); // enabling wrecks buttons

			// ptr.cardThumbDOMObj.innerHTML = '<img
			// src="http://mtvmusic.mtvnimages.com/uri/mgid:uma:artist:mtvmusic.com:'+ptr.artistId+'?width=426&amp;height=105&amp;crop=true"
			// border="0"/>';
			// ptr.cardThumbDOMObj.innerHTML = '<img
			// src="http://mtvhive.mtvnimages.com/uri/mgid:uma:artist:mtvmusic.com:'+ptr.artistMtvnId+'?width=426&amp;height=105&amp;crop=true"
			// border="0"/>';
			if (ptr.thumbDatasource.length > 0) {
				ptr.getCardThumbsFromDataSource();
			} else {
				ptr.getCardThumbs();
			}
			if (ptr.cStyle != 'artist' && ptr.showName)
				ptr.cardInfoDOMObj.innerHTML = unescape(artistMTVNName);
			ptr.artistName = artistMTVNName;
			// console.log('draw card with echo profile artist name:
			// '+artistMTVNName);
			// ptr.wrecksButtonLink.href =
			// ''+diogenesServer+'/meter/artist/'+dioFlattenArtistNames(artistMTVNName)+'/'+ptr.artistMtvnId+'/dissimilar?artistName='+encodeURIComponent(artistMTVNName);
			ptr.recdButtonLink.onclick = function() {
				ptr.coda2reporting({
					'name' : DiogenesConfig.Reporting.Similar._name,
					'evarName' : DiogenesConfig.Reporting.Similar._eVar,
					'evarValue' : unescape(ptr.artistName)
				});
			}
			ptr.recdButtonLink.href = recsButtonLink + recsButtonLinkId
					+ recsButtonLinkParams + ptr.simLinkReferrer;
			if (ptr.cStyle == "embed") {
				ptr.recdButtonLink.target = "_blank";
			}

			ptr.cardBottomLink.href = recsButtonLink + recsButtonLinkId;
			ptr.cardBottomLink.target = "_blank";
			ptr.cardBottomLink.innerHTML = artistMTVNName;

			if (DiogenesConfig.useLauncher) {
				// ptr.wrecksButtonLink.onclick =
				// function(){dioLaunchList({'textBody':'wreckd',
				// 'title':DiogenesConfig.wreckListHeaderText+artistMTVNName,
				// 'description':DiogenesConfig.wreckListDescText+artistMTVNName},
				// {"artistId":ptr.artistId,"artistName":artistMTVNName,"mtvn":true});
				// return false;};
				// ptr.recdButtonLink.onclick =
				// function(){dioLaunchList({'textBody':'recd',
				// 'title':DiogenesConfig.recdListHeaderText+artistMTVNName,
				// 'description':DiogenesConfig.recdListDescText+artistMTVNName},
				// {"artistId":ptr.artistId,"artistName":artistMTVNName,"mtvn":true});
				// return false;};
			}
		} catch (e) {
			// console.log("Diogenes.Card widget: drawCardWithEchoProfile failed
			// " + e);
		}
	}

	this.createCard = function() {
		// build card
		var card = this.card;

		var card_div_root = document.getElementById(this.divId);
		var card_container = document.createElement('div');
		card_container.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card-container');

		var card_debug_div = document.createElement('div');
		card_debug_div.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card-debug-div');

		var card_tabs = this.buttons;
		var card_thumb = document.createElement('div');
		card_thumb.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card-thumbs');
		card_thumb.innerHTML = "";
		var card_info_container = document.createElement('div');
		card_info_container.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card-info-container');
		var card_info = document.createElement('div');
		card_info.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card-info');
		var card_rank_bg = document.createElement('div');
		card_rank_bg.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card-rank-bg');
		card_rank_bg.innerHTML = '<img src="'
				+ diogenesServer
				+ '/sitewide/img/meter/spacer.gif" border="0" width="1" height="1">';

		var card_rank = document.createElement('div');
		card_rank.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card-rank');
		if (this.rank < 10)
			card_rank.innerHTML = '0' + this.rank;
		else
			card_rank.innerHTML = this.rank;
		if (this.rank >= 100) {
			card_rank.setAttribute('style',
					'letter-spacing: -8px; padding: 0; margin-left: -8px;');
			card_rank.style.letterSpacing = '-8px';
			card_rank.style.padding = '0';
			card_rank.style.marginLeft = '-8px';
		}
		var clear1 = this.createClearDiv();
		var clear2 = this.createClearDiv();

		/*
		 * commenting to incorporate the temporary image picker if
		 * (this.mtvnUniverse && this.artistMtvnId=="") card_thumb.innerHTML = '<div
		 * style="width:426px; height: 105px;"><img
		 * src="'+diogenesServer+'/sitewide/img/meter/ajax-ani-big.gif"
		 * border="0" style="margin 0 auto;" /></div>'; else if
		 * (this.artistMtvnId!="") card_thumb.innerHTML = '<img
		 * src="http://mtvhive.mtvnimages.com/uri/mgid:uma:artist:mtvmusic.com:'+this.artistMtvnId+'?width=426&amp;height=105&amp;crop=true"
		 * border="0"/>'; else card_thumb.innerHTML = '<img
		 * src="http://mtvhive.mtvnimages.com/uri/mgid:uma:video:mtvmusic.com:476808?width=426&amp;height=105&amp;crop=true"
		 * border="0"/>';
		 */

		card_info.innerHTML = unescape(this.artistName);

		this.cardThumbDOMObj = card_thumb;
		if (this.cStyle != 'artist')
			this.cardInfoDOMObj = card_info;
		this.cardRankDOMObj = card_rank;
		this.cardDebugDiv = card_debug_div;

		if (this.enableSearch) {
			var searchBarLauncher = document.createElement('div');
			searchBarLauncher.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-card-search-bar-launcher');

			var searchBarLauncherLink = document.createElement('a');
			// searchBarLauncherLink.innerHTML = '<img
			// src="'+diogenesServer+'/sitewide/img/meter/header-button-search.gif"
			// border="0" />';
			var searchBarLauncherLinkImg = document.createElement('img');
			searchBarLauncherLinkImg.setAttribute('border', '0');
			searchBarLauncherLinkImg.setAttribute('src', diogenesServer
					+ '/sitewide/img/meter/header-button-search.gif');
			searchBarLauncherLink.appendChild(searchBarLauncherLinkImg);
			searchBarLauncherLink.href = 'javascript: void(0);';
			searchBarLauncherLink.onclick = function() {
				ptr.expandSearchInput();
			};

			searchBarLauncher.appendChild(searchBarLauncherLink);

			searchBarLauncher.onmouseover = function() {
				searchBarLauncherLinkImg.setAttribute('src', diogenesServer
						+ '/sitewide/img/meter/header-button-search-hl.gif');
			}
			searchBarLauncher.onmouseout = function() {
				searchBarLauncherLinkImg.setAttribute('src', diogenesServer
						+ '/sitewide/img/meter/header-button-search.gif');
			}

			var searchBarContainer = document.createElement('div');
			searchBarContainer.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-card-search-bar-container');
			searchBarContainer.innerHTML = '<div class="barLeft"></div>';
			searchBarContainer.innerHTML += '<input id="meterCardSearch'
					+ this.echoId
					+ '" class="dio-card-search-bar-input-small" type="text" name="term" value=""/>';
			searchBarContainer.innerHTML += '<div class="barRight"><a style="padding: 0;" id="#meterCardSearchSubmitButton'
					+ this.echoId
					+ '" onclick="return false;" href="javascript: void(0);" class="">'
					+ '<img style="padding: 0;" src="'
					+ diogenesServer
					+ '/sitewide/img/meter/meter-card-search-input-go2.gif" id="meterCardSearchSubmitButton'
					+ ptr.echoId
					+ '" border="0" />'
					+ '</a></div><div style="clear: both;"></div>';

			this.searchBarContainer = searchBarContainer;
			// this.wrecks.appendChild(searchBarContainer);
		}

		if (this.cStyle == 'embed') {
			card_container.appendChild(card_info);
			if (this.enableSearch) {
				card_container.appendChild(searchBarLauncher);
				card_container.appendChild(searchBarContainer);
			}
			card_container.appendChild(clear2);
		} else {
			card_container.appendChild(card_thumb);
			card_container.appendChild(card_info_container);
			card_info_container.appendChild(card_info);
			if (this.rank != 0) {
				card_info_container.appendChild(card_rank_bg);
				card_info_container.appendChild(card_rank);
			}
			card_info_container.appendChild(clear1);
			card_container.appendChild(clear2);
		}
		if (this.cStyle == "artist" || !this.collapsible) {
			card_container.onmouseover = function() {
				this.style.cursor = 'default';
			}
			card_container.onmouseout = function() {
			}
		} else {
			card_container.onmouseover = function() {
				this.style.cursor = 'pointer';
				// this.setAttribute(((document.all&&(Dio_IE_Ver<8.0)) ?
				// 'className' : 'class'),'dio-card-container-onmouseover');
				// ptr.cardInfoDOMObj.setAttribute(((document.all&&(Dio_IE_Ver<8.0))
				// ? 'className' : 'class'),'dio-card-info-onmouseover');
				// ptr.cardRankDOMObj.setAttribute(((document.all&&(Dio_IE_Ver<8.0))
				// ? 'className' : 'class'),'dio-card-rank-onmouseover');
			}
			card_container.onmouseout = function() {
				// this.setAttribute(((document.all&&(Dio_IE_Ver<8.0)) ?
				// 'className' : 'class'),'dio-card-container');
				// ptr.cardInfoDOMObj.setAttribute(((document.all&&(Dio_IE_Ver<8.0))
				// ? 'className' : 'class'),'dio-card-info');
				// ptr.cardRankDOMObj.setAttribute(((document.all&&(Dio_IE_Ver<8.0))
				// ? 'className' : 'class'),'dio-card-rank');
			}
			card_container.onclick = this.toggle;
		}

		var card_stage = this.stage;
		var card_wrecks = this.wrecks; // rec'ed/wrecked buttons div
		var card_player = this.player;
		var clear2 = this.createClearDiv();

		this.removeAllChildren(card_div_root);

		var card_pulltab = this.card_pulltab;
		card_pulltab.onmouseover = function() {
			this.style.cursor = 'pointer';
		}
		card_pulltab.onmouseout = function() {
		}
		card_pulltab.onclick = this.toggle;

		card_div_root.appendChild(card);
		if (this.cStyle == "artist" || !this.collapsible) {
			var card_bottom_border = card_pulltab = document
					.createElement('div');
			card_bottom_border.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-card-bottom-border');
			card_div_root.appendChild(card_bottom_border);
		} else {
			card_div_root.appendChild(card_pulltab);
		}
		if (this.cStyle == "embed") {
			var card_bottom_link_div = card_pulltab = document
					.createElement('div');
			card_bottom_link_div.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-card-bottom-link-div');
			var card_bottom_link = card_pulltab = document.createElement('a');
			card_bottom_link.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-card-bottom-link');

			card_bottom_link_div.appendChild(card_bottom_link);
			card_div_root.appendChild(card_bottom_link_div);
			this.cardBottomLink = card_bottom_link;
		}
		card.appendChild(card_debug_div);
		card.appendChild(card_container);
		card.appendChild(card_tabs);
		card.appendChild(card_stage);
		card.appendChild(card_wrecks);
		card.appendChild(card_player);
		card.appendChild(clear2);

		var numbersPattern = /[0-9]+/i;

		if (this.mtvnUniverse && this.numericId && this.artistName == "") { // get
																			// artist
																			// info
																			// from
																			// echonest
																			// profile
																			// using
																			// mtv
																			// numeric
																			// id
			var _params = '';
			var _dsURL = this.dsURL + 'meter/echoprofile/?id=' + this.artistId
					+ '&mtv=yes&mtvnumeric=yes';
			this.__loadData({
				url : _dsURL,
				data : _params,
				successHandler : this.drawCardWithEchoProfile,
				errorHandler : this.ajaxErrors,
				dataType : 'json'
			});
		} else if (this.mtvnUniverse
				&& (this.artistMtvnId == "" || this.artistName == "")) { // get
																			// artist
																			// info
																			// to
																			// fill
																			// the
																			// card
			var _params = '';
			var _dsURL = this.dsURL + 'meter/echoprofile/?id=' + this.artistId
					+ '&mtv=yes';
			this.__loadData({
				url : _dsURL,
				data : _params,
				successHandler : this.drawCardWithEchoProfile,
				errorHandler : this.ajaxErrors,
				dataType : 'json'
			});
		} else if (this.artistName == "") { // get artist info with echonest to
											// get artist name
			var _params = '';
			var _dsURL = this.dsURL + 'meter/echoprofile/?id=' + this.artistId;
			this.__loadData({
				url : _dsURL,
				data : _params,
				successHandler : this.drawCardWithEchoProfile,
				errorHandler : this.ajaxErrors,
				dataType : 'json'
			});
		} else if (this.mtvnUniverse && this.numericId
				&& this.artistId.match(numbersPattern)) { // the card id is
															// not a mtv alias,
															// get from echonest
			var _params = '';
			var _dsURL = this.dsURL + 'meter/echoprofile/?id=' + this.artistId
					+ '&mtv=yes&mtvnumeric=yes';
			this.__loadData({
				url : _dsURL,
				data : _params,
				successHandler : this.drawCardWithEchoProfile,
				errorHandler : this.ajaxErrors,
				dataType : 'json'
			});
		} else {
			if (this.thumbDatasource.length > 0) {
				this.getCardThumbsFromDataSource();
			} else {
				this.getCardThumbs();
			}
		}

		this.loaded = true;
	}

	this.getRandomDefaultThumb = function() { // generate random thumbnail
												// image url
		var randomDefaultThumbDir = diogenesServer
				+ '/sitewide/img/meter/cardThumbRands/';
		var randomDefaultThumbUrl = '';
		var randNum = parseInt(Math.random() * 33);
		if (randNum == 0 || isNaN(randNum)) {
			randNum = 1;
		}
		randomDefaultThumbUrl = randomDefaultThumbDir + 'randoms-' + randNum + '.jpg';
		return randomDefaultThumbUrl;
	}
	this.populateCardThumbRandom = function() {
		var thumbAdded = 0;
		var card_thumbnails = '';
		while (thumbAdded < 3) {
			card_thumbnails += '<img src="' + this.getRandomDefaultThumb()
					+ '" alt="" height="86" width="142" border="0">';
			thumbAdded++;
		}
		ptr.cardThumbDOMObj.innerHTML = card_thumbnails;
	}
	this.getCardThumbsFromDataSource = function() {
		var card_thumbnails = "";

		if (this.thumbDatasource.length >= 3) {
			for ( var i = 0; i < 3; i++) {
				card_thumbnails += '<img src="' + this.thumbDatasource[i].url
						+ '" alt="" height="86" width="142" border="0">';
			}
			ptr.cardThumbDOMObj.innerHTML = card_thumbnails;
		} else {
			ptr.populateCardThumbRandom();
		}
	}
	this.populateCardThumbsError = function(e) {
		ptr.populateCardThumbRandom();
	}
	this.populateCardThumbs = function(data) {
		ptr.cardDebugDiv.innerHTML = "<div>artistId: " + ptr.artistId
				+ "</div> <div>artistMtvnId: " + ptr.artistMtvnId
				+ "</div> <div>artistName: " + ptr.artistName + "</div>";
		var resultArray = data.artists[0].images;
		var thumbAdded = 0;

		if (resultArray != null && resultArray.length > 0) { // client side
																// request
																// successful,
																// process json
			var card_thumbnails = "";
			for ( var i = 0; i < 3; i++) {
				card_thumbnails += '<img src="' + resultArray[i].url
						+ '" alt="" height="86" width="142" border="0">';
			}

			ptr.cardThumbDOMObj.innerHTML = card_thumbnails;

		} else { // fails, use random images
			// console.log(resultArray)
			ptr.populateCardThumbRandom();
			ptr.cardDebugDiv.innerHTML += "<div>error: resultArray empty</div>";
		}
	}
	this.getCardThumbs = function() {

		if (this.artistMtvnId != "") {
			// console.log('Getting images for '+this.artistName+', mtvn
			// id:'+this.artistMtvnId)
			// temporary solution
			var getCardThumbsUrl = 'http://services.mtvmusic.com/sitewide/dataservices/hive-meter-image-feed/?ids='
					+ this.artistMtvnId;
			ptr.__loadData({
				url : getCardThumbsUrl,
				data : '',
				successHandler : this.populateCardThumbs,
				errorHandler : this.populateCardThumbsError,
				dataType : 'jsonp',
				jsonpCallback : 'jsonp' + this.artistMtvnId
			});

			/*
			 * $.getJSON('http://services.mtvmusic.com/sitewide/dataservices/hive-meter-image-feed/?ids='+ptr.artistMtvnId+'&callback=jsonp'+this.artistMtvnId,
			 * function(data) {
			 * //$.getJSON('http://services.mtvmusic.com/sitewide/diogenes/dataservices/image-selector/?id='+this.artistMtvnId+'&w=142&h=86&callback=?',
			 * function(data) { //console.log(data) ptr.cardDebugDiv.innerHTML = "<div>artistId:
			 * "+ptr.artistId+"</div> <div>artistMtvnId: "+ptr.artistMtvnId+"</div>
			 * <div>artistName: "+ptr.artistName+"</div>"; var resultArray =
			 * data.artists[0].images; var thumbAdded = 0;
			 * 
			 * if (resultArray != null && resultArray.length > 0){ // client
			 * side request successful, process json var card_thumbnails = "";
			 * for (var i=0; i < 3; i++){ card_thumbnails += '<img
			 * src="'+resultArray[i].url+'" alt="" height="86" width="142"
			 * border="0">'; }
			 * 
			 * ptr.cardThumbDOMObj.innerHTML = card_thumbnails;
			 *  } else { // fails, use random images //console.log(resultArray)
			 * ptr.populateCardThumbRandom(); ptr.cardDebugDiv.innerHTML += "<div>error:
			 * resultArray empty</div>"; } });
			 */

		} else {
			// populate card thumbnails with randoms
			// ptr.cardDebugDiv.innerHTML += "<div>error: no mtvnId</div>";
			this.populateCardThumbRandom();
		}
	}

	this.getArtistInfo = function(data) {
		try {
			var artistMTVNID = $(data).find("id").text();
			var artistMTVNName = $(data).find("name").text();
			ptr.cardThumbDOMObj.innerHTML = '<img src="http://mtvhive.mtvnimages.com/uri/mgid:uma:artist:mtvmusic.com:'
					+ artistMTVNID
					+ '?width=426&amp;height=105&amp;crop=true" border="0"/>';
			if (ptr.cStyle != 'artist')
				ptr.cardInfoDOMObj.innerHTML = unescape(artistMTVNName)
						.toUpperCase();
			ptr.artistName = artistMTVNName;
			// console.log('get artist info: '+artistMTVNName);
			// ptr.wrecksButtonLink.href =
			// ''+diogenesServer+'index.jhtml?q=wreckd&artistName='+encodeURIComponent(artistMTVNName);
			ptr.wrecksButtonLink.href = '' + diogenesServer + '/'
					+ DiogenesConfig.siteRoot + 'artist/'
					+ dioFlattenArtistNames(artistMTVNName) + '/'
					+ artistMTVNID + '/dissimilar?artistName='
					+ encodeURIComponent(artistMTVNName) + ptr.simLinkReferrer;
			// ptr.recdButtonLink.href =
			// ''+diogenesServer+'index.jhtml?q=recd&id='+artistMTVNID+'&artistName='+encodeURIComponent(artistMTVNName)+'&mtv=yes';
			// ptr.recdButtonLink.href =
			// ''+diogenesServer+'/'+DiogenesConfig.siteRoot+'artist/'+dioFlattenArtistNames(artistMTVNName)+'/'+artistMTVNID+'/similar'+'?mtv=yes';
			ptr.recdButtonLink.href = '' + diogenesServer + '/'
					+ DiogenesConfig.siteRoot + 'artist/'
					+ dioFlattenArtistNames(artistMTVNName) + '/'
					+ artistMTVNID + '/' + ptr.simLinkReferrer;
			if (DiogenesConfig.useLauncher) {
				ptr.wrecksButtonLink.onclick = function() {
					dioLaunchList({
						'textBody' : 'wreckd',
						'title' : DiogenesConfig.wreckListHeaderText
								+ artistMTVNName,
						'description' : DiogenesConfig.wreckListDescText
								+ artistMTVNName
					}, {
						"artistId" : artistMTVNID,
						"artistName" : artistMTVNName,
						"mtvn" : true
					});
					return false;
				};
				ptr.recdButtonLink.onclick = function() {
					dioLaunchList({
						'textBody' : 'recd',
						'title' : DiogenesConfig.recdListHeaderText
								+ artistMTVNName,
						'description' : DiogenesConfig.recdListDescText
								+ artistMTVNName
					}, {
						"artistId" : artistMTVNID,
						"artistName" : artistMTVNName,
						"mtvn" : true
					});
					return false;
				};
			}
		} catch (e) {
			// console.log("Diogenes.Card widget: processing data failed " + e);
		}
	}

	this.getTabs = function(data) {
	}

	this.load = function(url, params) {

		this.prepareTabs(); // enabling tabs depending on mtvUniverse
		this.updateWrecksButtons(); // enabling wrecks buttons

		if (divId && artistId) {

			this.createCard();

			this.dioCards.push(ptr); // save this instance of card into the
										// collective array

		} else {
			// console.log("requires 2 params, div container id and artist id to
			// generate card");
		}

	}

	this.load();

	this.version = function() {
		document.write(this.version);
	}

}
Diogenes.Card.prototype = new Diogenes();

Diogenes.Modules = function() {
}
Diogenes.Modules.prototype = new Diogenes();

Diogenes.Modules.Bios = function(options) {
	if (options == null)
		options = {};
	var ptr = this;
	this.initialized = false;
	this.refresh = ('refresh' in options) ? options.refresh : false;
	this.cardObj = ('cardObj' in options) ? options.cardObj : null;
	this.mid = ('mid' in options) ? options.mid : null;
	this.notClickedHTML = "BIO";
	this.clicked = false;
	this.clickedHTML = "<strong>BIO</strong>";
	this.buttonDiv = document.createElement('span');
	this.contentObj = document.createElement('div');
	this.contentObj.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-module-bios');
	this.dsURL = ('dsURL' in options) ? options.dsURL : '';
	this.id = ('id' in options) ? options.id : '';
	this.params = ('params' in options) ? options.params : '';
	this.type = ('type' in options) ? options.type : 'xml';
	this.targetDiv = ('targetDiv' in options) ? options.targetDiv : null;

	this.scrollTimer = 0;
	this.scrollSpeed = 20;
	this.scrollInterval = 30;
	this.bioBody = null;
	this.bioBodyText = null;

	this.buildButton = function() {
		this.buttonDiv.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card-buttons-links');
		this.buttonDiv.innerHTML = this.notClickedHTML;
		this.buttonDiv.onmouseover = function() {
			this.style.cursor = 'pointer';
		}
		this.buttonDiv.onclick = this.toggle;
	}

	this.opening = function() {
		this.cardObj.activeTab.module.clicked = false;
		this.cardObj.activeTab.module.buttonDiv.innerHTML = this.cardObj.activeTab.module.notClickedHTML;
		this.cardObj.activeTab = null;
		this.buttonDiv.innerHTML = this.clickedHTML;
		this.clicked = true;
		this.cardObj.activeTab = this.cardObj.tabs[this.mid];
		this.loadInStage();

		this.cardObj.listenTabRemote('play');
	}

	this.closing = function() {
		this.buttonDiv.innerHTML = this.notClickedHTML;
		this.clicked = false;

	}

	this.toggle = function() { // clicking action
		if (ptr.clicked) {
			// ptr.closing();
		} else {

			// clicked on, send reporting call
			// ptr.cardObj.coda2reporting({'name':'Bio', 'evarName':
			// DiogenesConfig.Reporting.TabOpen._eVar,
			// 'evarValue':unescape(ptr.cardObj.artistName)});
			ptr.cardObj.coda2reporting({
				'name' : 'Tab Open',
				'evarName' : DiogenesConfig.Reporting.TabOpen._eVar,
				'evarValue' : 'Bio'
			});

			ptr.opening();
		}
	}

	this.stageScrollUp = function(step) {
		var bodyYPos = parseInt(this.bioBodyText.style.marginTop);

		if (bodyYPos < 0)
			this.bioBodyText.style.marginTop = (bodyYPos + this.scrollSpeed)
					+ "px";

		if (step == "step") {
		} else
			this.scrollTimer = setTimeout(this.cardObj.divId + ".tabs["
					+ this.mid + "].module.stageScrollUp()",
					this.scrollInterval);
	}

	this.stageScrollDown = function(step) {
		var bodyYPos = parseInt(this.bioBodyText.style.marginTop);

		if (this.bioBody.scrollHeight > this.bioBody.offsetHeight)
			this.bioBodyText.style.marginTop = (bodyYPos - this.scrollSpeed)
					+ "px";

		if (step == "step") {
		} else
			this.scrollTimer = setTimeout(this.cardObj.divId + ".tabs["
					+ this.mid + "].module.stageScrollDown()",
					this.scrollInterval);
	}

	this.stageWheelScroll = function(event) {
		var delta = 0;
		if (!event)
			event = window.event;
		// normalize the delta
		if (event.wheelDelta) { // IE & Opera
			delta = event.wheelDelta / 120;
		} else if (event.detail) { // W3C
			delta = -event.detail / 3;
		}
		// console.log(delta);

		if (delta > 0)
			ptr.stageScrollUp("step");
		else
			ptr.stageScrollDown("step");

		return ptr.cancelEvent(event);
	}

	this.clearTimer = function(obj) {
		var timer = this.scrollTimer;
		clearTimeout(timer);
	}

	this.getArtistEchoId = function(res) { // used to get the echonest id for
											// the artist if the card was
											// generated without one
											// *DEPRECATED*
		try {
			var echoId = '';
			if (res.profile.echoNestId != '') {
				echoId = res.profile.echoNestId;
				ptr.cardObj.echoId = echoId;
			}
			var _params = '';
			if (echoId != "") {
				var _dsURL = ptr.dsURL + 'meter/bios/?id=' + echoId;
				ptr.__loadData({
					url : _dsURL,
					data : _params,
					successHandler : ptr.processStage,
					errorHandler : ptr.ajaxErrors,
					dataType : 'json'
				});
			} else {
				// handle no echoId case
			}
		} catch (e) {
			// console.log("Diogenes.Card bio tab: getArtistEchoId failed " +
			// e);
		}
	}

	this.processStage = function(res) {
		ptr.initialized = true;

		if (res) {
			var found = false;
			var bioSource = "";
			var bioHeader = document.createElement("div");
			bioHeader.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-bios-header');
			bioHeader.innerHTML = ptr.cardObj.artistName + " - Biography";
			var bioBody = document.createElement("div");
			bioBody.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-bios-body');
			ptr.bioBody = bioBody;
			if (window.addEventListener) {
				ptr.contentObj.addEventListener('DOMMouseScroll',
						ptr.stageWheelScroll, false);
				ptr.contentObj.addEventListener('mousewheel',
						ptr.stageWheelScroll, false);
			} else {
				ptr.contentObj.onmousewheel = ptr.stageWheelScroll;
			}
			var bioBodyText = document.createElement("div");
			bioBodyText.style.marginTop = "0px";
			ptr.bioBodyText = bioBodyText;

			var bioScroller = document.createElement("div");
			bioScroller.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-bios-scroller');
			var bioScrollerUp = document.createElement("div");
			bioScrollerUp.style.marginBottom = "220px";
			bioScrollerUp.innerHTML = '<img src="'
					+ diogenesServer
					+ '/sitewide/img/meter/button-scroller-up.gif" border="0" />';
			var bioScrollerDown = document.createElement("div");
			bioScrollerDown.innerHTML = '<img src="'
					+ diogenesServer
					+ '/sitewide/img/meter/button-scroller-down.gif" border="0" />';
			bioScroller.appendChild(bioScrollerUp);
			bioScroller.appendChild(bioScrollerDown);
			bioScrollerUp.onmousedown = function() {
				ptr.stageScrollUp()
			};
			bioScrollerUp.onmouseup = function() {
				ptr.clearTimer()
			};
			bioScrollerUp.onmouseout = function() {
				ptr.clearTimer()
			};
			bioScrollerDown.onmousedown = function() {
				ptr.stageScrollDown()
			};
			bioScrollerDown.onmouseup = function() {
				ptr.clearTimer()
			};
			bioScrollerDown.onmouseout = function() {
				ptr.clearTimer()
			};

			/* Handler if getting biography directly from dextr */

			if (res.bio != null && res.bio != "") {
				var attrb = res.attribution;
				var site = res.site;
				var url = res.url;
				var text = res.bio;
				text = text.replace(/href=/gi, 'target="_blank" href='); // adding
																			// target="_blank"
																			// to
																			// hrefs
				bioBodyText.innerHTML = text;
				bioSource = 'amg';
				if (site == 'wikipedia') {
					bioBodyText.innerHTML += '<div style="font-size: 12px;"><br/>Source: <a href="'
							+ url
							+ '" target="_blank" style="font-size: 12px;">Wikpedia</a><br/>Text from this biography licensed under <a href="http://creativecommons.org/licenses/by-sa/3.0/" target="_blank" style="font-size: 12px;">creative commons license</a>.<br/><br/></div>';
					bioSource = 'wikipedia';
				}
				found = true;
			}

			/*
			 * if (res.dextrAMGBio!= null &&
			 * res.dextrAMGBio.profile.amgbiography!= ""){ var text =
			 * res.dextrAMGBio.profile.amgbiography; text =
			 * text.replace(/href=/gi, 'target="_blank" href='); // adding
			 * target="_blank" to hrefs bioBodyText.innerHTML = text; found =
			 * true; bioSource = 'amg'; }
			 * 
			 * var echoBios = res.echonestBio.bios;
			 * 
			 * $(echoBios).each(function(){ // look for wikipedia (first) entry
			 * var url = this.url; var text = this.text; text =
			 * text.replace(/href=/gi, 'target="_blank" href='); // adding
			 * target="_blank" to hrefs if (url.search(/wikipedia.org/i)>0 &&
			 * !found){ bioBodyText.innerHTML = text; bioBodyText.innerHTML += '<div
			 * style="font-size: 12px;"><br/>Source: <a href="'+url+'"
			 * target="_blank" style="font-size: 12px;">Wikpedia</a><br/>Text
			 * from this biography licensed under <a
			 * href="http://creativecommons.org/licenses/by-sa/3.0/"
			 * target="_blank" style="font-size: 12px;">creative commons license</a>.<br/><br/></div>';
			 * found = true; bioSource = 'wiki'; } });
			 * $(echoBios).each(function(){ // look for mtvmusic (first) entry
			 * var url = this.url; var text = this.text; text =
			 * text.replace(/href=/gi, 'target="_blank" href='); // adding
			 * target="_blank" to hrefs if (url.search(/mtvmusic.com/i)>0 &&
			 * !found){ bioBodyText.innerHTML = text; found = true; bioSource =
			 * 'mtvmusic'; } });
			 */

			if (bioBodyText.innerHTML == "")
				bioBodyText.innerHTML = "NO BIO FOUND"
			bioBody.appendChild(bioBodyText);

			// ptr.contentObj.appendChild(bioHeader);
			ptr.contentObj.appendChild(bioBody);
			ptr.contentObj.appendChild(bioScroller);

			// ptr.removeAllChildren(ptr.cardObj.stage);
			// ptr.cardObj.stage.appendChild(ptr.contentObj);
			ptr.cardObj.stageHideAll();
			ptr.cardObj.stageShow(ptr.mid);

			if (ptr.cardObj.activeTab.module.mid != ptr.mid) { // if tab was
																// clicked
																// before ajax
																// is complete
				ptr.opening();
			}
		}
	}

	this.loadInStage = function() {
		this.cardObj.stageHideAll();
		this.cardObj.showLoading();

		if (!this.initialized || this.refresh) {
			// not initialized, ajax to get data and load stage
			this.removeAllChildren(this.contentObj);

			/*
			 * requests if getting biography directly from dextr if
			 * (this.cardObj.echoId != ""){ var _params = ''; var _dsURL =
			 * this.dsURL + 'meter/bios/?id='+this.cardObj.echoId;
			 * this.__loadData({url:_dsURL,data:_params,successHandler:this.processStage,errorHandler:this.ajaxErrors,
			 * dataType:'json'}); }else{ var _params = ''; var _dsURL =
			 * this.dsURL +
			 * 'meter/echoprofile/?id='+this.cardObj.artistId+'&mtv=yes';
			 * this.__loadData({url:_dsURL,data:_params,successHandler:this.getArtistEchoId,errorHandler:this.ajaxErrors,
			 * dataType:'json'}); }
			 */

			var _params = '';
			var _dsURL = this.dsURL + 'meter/bios/?id=' + this.cardObj.echoId;
			// if (this.cardObj.mtvnUniverse) _params += "mtv=yes";
			this.__loadData({
				url : _dsURL,
				data : _params,
				successHandler : this.processStage,
				errorHandler : this.ajaxErrors,
				dataType : 'json'
			})

		} else {
			// just load stage with the content
			// this.removeAllChildren(this.cardObj.stage);
			// this.cardObj.stage.appendChild(this.contentObj);
			this.cardObj.stageHideAll();
			this.cardObj.stageShow(this.mid);
		}
	}

	if (this.targetDiv) {
		// console.log("Initializing Bios tab module");
		this.buildButton();
	}
}

Diogenes.Modules.Bios.prototype = new Diogenes();

Diogenes.Modules.Photos = function(options) {
	if (options == null)
		options = {};
	var ptr = this;
	this.photoBodyWidth = 400;
	this.photoBodyHeight = 230;
	this.thumbWidth = 78;
	this.thumbHeight = 43;
	this.initialized = false;
	this.refresh = ('refresh' in options) ? options.refresh : false;
	this.cardObj = ('cardObj' in options) ? options.cardObj : null;
	this.mid = ('mid' in options) ? options.mid : null;
	this.notClickedHTML = "PHOTOS";
	this.clicked = false;
	this.clickedHTML = "<strong>PHOTOS</strong>";
	this.buttonDiv = document.createElement('span');
	this.contentObj = document.createElement('div');
	this.contentObj.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-module-photos');
	this.dsURL = ('dsURL' in options) ? options.dsURL : '';
	this.id = ('id' in options) ? options.id : '';
	this.params = ('params' in options) ? options.params : '';
	this.type = ('type' in options) ? options.type : 'xml';
	this.targetDiv = ('targetDiv' in options) ? options.targetDiv : null;

	this.scrollTimer = 0;
	this.scrollSpeed = 20;
	this.scrollInterval = 30;
	this.photoHeader = null;
	this.photoBody = null;
	this.thumbList = null;
	this.scrollerUp = null;
	this.scrollerDown = null;
	this.scrollerLeft = null;
	this.scrollerRight = null;

	this.photos = [];
	this.shownIndex = 0;

	this.buildButton = function() {
		this.buttonDiv.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card-buttons-links hidden');
		this.buttonDiv.innerHTML = this.notClickedHTML;
		this.buttonDiv.onmouseover = function() {
			this.style.cursor = 'pointer';
		}
		// this.buttonDiv.onclick = this.toggle;
	}

	this.opening = function() {
		this.cardObj.activeTab.module.clicked = false;
		this.cardObj.activeTab.module.buttonDiv.innerHTML = this.cardObj.activeTab.module.notClickedHTML;
		this.cardObj.activeTab = null;
		this.buttonDiv.innerHTML = this.clickedHTML;
		this.clicked = true;
		this.cardObj.activeTab = this.cardObj.tabs[this.mid];
		this.loadInStage();

		this.cardObj.listenTabRemote('play');
	}

	this.closing = function() {
		this.buttonDiv.innerHTML = this.notClickedHTML;
		this.clicked = false;

	}

	this.toggle = function() { // clicking action
		if (ptr.clicked) {
			// ptr.closing();
		} else {

			// clicked on, send reporting call
			// ptr.cardObj.coda2reporting({'name':'Photos', 'evarName':
			// DiogenesConfig.Reporting.TabOpen._eVar,
			// 'evarValue':unescape(ptr.cardObj.artistName)});
			ptr.cardObj.coda2reporting({
				'name' : 'Tab Open',
				'evarName' : DiogenesConfig.Reporting.TabOpen._eVar,
				'evarValue' : 'Photos'
			});

			ptr.opening();
		}
	}

	this.stageScrollUp = function(step) {
		var bodyYPos = parseInt(this.thumbList.style.marginTop);

		if (bodyYPos < 0)
			this.thumbList.style.marginTop = (bodyYPos + this.scrollSpeed)
					+ "px";

		if (step == "step") {
		} else
			this.scrollTimer = setTimeout(this.cardObj.divId + ".tabs["
					+ this.mid + "].module.stageScrollUp()",
					this.scrollInterval);

		this.refreshScrollerButtons();
	}

	this.stageScrollDown = function(step) {
		var bodyYPos = parseInt(this.thumbList.style.marginTop);

		if (this.photoCarousel.scrollHeight > this.photoCarousel.offsetHeight)
			this.thumbList.style.marginTop = (bodyYPos - this.scrollSpeed)
					+ "px";

		if (step == "step") {
		} else
			this.scrollTimer = setTimeout(this.cardObj.divId + ".tabs["
					+ this.mid + "].module.stageScrollDown()",
					this.scrollInterval);

		this.refreshScrollerButtons();
	}

	this.stageWheelScroll = function(event) {
		var delta = 0;
		if (!event)
			event = window.event;
		// normalize the delta
		if (event.wheelDelta) { // IE & Opera
			delta = event.wheelDelta / 120;
		} else if (event.detail) { // W3C
			delta = -event.detail / 3;
		}
		// console.log(delta);

		if (delta > 0)
			ptr.stageScrollUp("step");
		else
			ptr.stageScrollDown("step");

		return ptr.cancelEvent(event);
	}

	this.clearTimer = function(obj) {
		var timer = this.scrollTimer;
		clearTimeout(timer);
	}

	this.disableThis = function() {
		// this.buttonDiv.setAttribute(((document.all&&(Dio_IE_Ver<8.0)) ?
		// 'className' : 'class'),'dio-card-buttons-links
		// dio-card-buttons-links-disable');
		this.buttonDiv.onmouseover = function() {
			this.style.cursor = 'default';
		}
		this.buttonDiv.onclick = null;
	}

	this.loadPhoto = function(url, w, h, idx) {
		// console.log(url);
		// console.log(idx);
		w = parseInt(w);
		h = parseInt(h);

		var marginTop = 0;
		var adjustedHeight = this.photoBodyHeight;
		adjustedHeight = (h >= this.photoBodyHeight) ? this.photoBodyHeight : h;
		if (adjustedHeight < this.photoBodyHeight)
			marginTop = parseInt((this.photoBodyHeight - adjustedHeight) / 2);
		if (marginTop > 0)
			marginTop += "px";

		this.photoBody.innerHTML = '<img src="' + url
				+ '" border="0" style="margin-top:' + marginTop + ';" />';

		this.shownIndex = idx;
		this.refreshNextPrevButtons();

	}

	this.loadPhoto_DEPRECATED = function(url, w, h, idx) { // DEPRECATED, used
															// for older
															// apiServlet based
															// photo/potrait
															// access
		// console.log(url);
		// console.log(idx);
		w = parseInt(w);
		h = parseInt(h);
		if (w != 'NaN' && h != 'NaN') {
			var marginTop = 0;
			var adjustedHeight = this.photoBodyHeight;
			// adjustedHeight = parseInt((this.photoBodyWidth / w) * h);
			adjustedHeight = (h >= this.photoBodyHeight) ? this.photoBodyHeight
					: h;
			// console.log(adjustedHeight);
			if (adjustedHeight < this.photoBodyHeight)
				marginTop = parseInt((this.photoBodyHeight - adjustedHeight) / 2);
			// console.log(marginTop);
			if (marginTop > 0)
				marginTop += "px";
			if (url != "") {
				/*
				 * if ((w=="" && h=="") || (w >= h)) this.photoBody.innerHTML = '<img
				 * src="'+url+'" border="0" width="'+this.photoBodyWidth+'"
				 * style="margin-top:'+marginTop+';" />'; else if (h > w)
				 * this.photoBody.innerHTML = '<img src="'+url+'" border="0"
				 * height="'+this.photoBodyHeight+'"
				 * style="margin-top:'+marginTop+';" />';
				 */
				if (w >= this.photoBodyWidth)
					this.photoBody.innerHTML = '<img src="' + url
							+ '" border="0" width="' + this.photoBodyWidth
							+ '" style="margin-top:' + marginTop + ';" />';
				else if (h >= this.photoBodyHeight)
					this.photoBody.innerHTML = '<img src="' + url
							+ '" border="0" height="' + this.photoBodyHeight
							+ '" style="margin-top:' + marginTop + ';" />';
				else
					this.photoBody.innerHTML = '<img src="' + url
							+ '" border="0" style="margin-top:' + marginTop
							+ ';" />';
				// set shown index to this picture
				this.shownIndex = idx;
				this.refreshNextPrevButtons();
			}
		}
	}

	this.nextPicture = function() {
		var shownIndex = this.shownIndex;
		var photos = this.photos;
		shownIndex++;
		if (shownIndex < photos.length) {
			this.shownIndex = shownIndex;
			this.loadPhoto(photos[shownIndex].url, photos[shownIndex].w,
					photos[shownIndex].h, shownIndex);
			this.refreshNextPrevButtons();
		}
	}
	this.prevPicture = function() {
		var shownIndex = this.shownIndex;
		var photos = this.photos;
		shownIndex--;
		if (shownIndex >= 0) {
			this.shownIndex = shownIndex;
			this.loadPhoto(photos[shownIndex].url, photos[shownIndex].w,
					photos[shownIndex].h, shownIndex);
			this.refreshNextPrevButtons();
		}
	}

	this.refreshNextPrevButtons = function() {
		var shownIndex = this.shownIndex;
		var photos = this.photos;
		if (shownIndex + 1 < photos.length) {
			this.scrollerRight.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-photos-buttons-next-on');
		} else {
			this.scrollerRight.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-photos-buttons-next');
		}
		if (shownIndex > 0) {
			this.scrollerLeft
					.setAttribute(
							((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
									: 'class'),
							'dio-module-photos-buttons-previous-on');
		} else {
			this.scrollerLeft.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-photos-buttons-previous');
		}
	}

	this.refreshScrollerButtons = function() {
		var bodyYPos = parseInt(this.thumbList.style.marginTop);

		if (bodyYPos < 0) {
			this.scrollerUp.innerHTML = '<img src="'
					+ diogenesServer
					+ '/sitewide/img/meter/card-tab-scroller-button-up-on.gif" border=0 />';
		} else {
			this.scrollerUp.innerHTML = '<img src="'
					+ diogenesServer
					+ '/sitewide/img/meter/card-tab-scroller-button-up-off.gif" border=0 />';
		}

		if (this.photoCarousel.scrollHeight > this.photoCarousel.offsetHeight) {
			this.scrollerDown.innerHTML = '<img src="'
					+ diogenesServer
					+ '/sitewide/img/meter/card-tab-scroller-button-down-on.gif" border=0 />';
		} else {
			this.scrollerDown.innerHTML = '<img src="'
					+ diogenesServer
					+ '/sitewide/img/meter/card-tab-scroller-button-down-off.gif" border=0 />';
		}
	}

	this.processStage = function(res) {
		ptr.initialized = true;

		if (res) {
			var photoHeader = document.createElement("div");
			photoHeader.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-photos-header');
			ptr.photoHeader = photoHeader;

			var photoBody = document.createElement("div");
			photoBody.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-photos-body');
			ptr.photoBody = photoBody;
			photoBody.onmousedown = function() {
				ptr.nextPicture()
			};
			photoBody.onmouseover = function() {
				this.style.cursor = 'pointer';
			};
			photoBody.onmouseout = function() {
			};

			var photoCarouselContainer = document.createElement("div");
			photoCarouselContainer.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-photos-carousel-container');
			if (window.addEventListener) {
				photoCarouselContainer.addEventListener('DOMMouseScroll',
						ptr.stageWheelScroll, false);
				photoCarouselContainer.addEventListener('mousewheel',
						ptr.stageWheelScroll, false);
			} else {
				photoCarouselContainer.onmousewheel = ptr.stageWheelScroll;
			}
			var photoCarousel = document.createElement("div");
			photoCarousel.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-photos-carousel');
			ptr.photoCarousel = photoCarousel;

			var photoScrollerUp = document.createElement("div");
			photoScrollerUp.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-photos-scroller-up');
			photoScrollerUp.innerHTML = '<img src="'
					+ diogenesServer
					+ '/sitewide/img/meter/card-tab-scroller-button-up-off.gif" border="0" />';
			var photoScrollerDown = document.createElement("div");
			photoScrollerDown.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-photos-scroller-down');
			photoScrollerDown.innerHTML = '<img src="'
					+ diogenesServer
					+ '/sitewide/img/meter/card-tab-scroller-button-down-off.gif" border="0" />';
			photoScrollerUp.onmousedown = function() {
				ptr.stageScrollUp()
			};
			photoScrollerUp.onmouseup = function() {
				ptr.clearTimer()
			};
			photoScrollerUp.onmouseout = function() {
				ptr.clearTimer()
			};
			photoScrollerUp.onmouseover = function() {
				this.style.cursor = 'pointer';
			};
			photoScrollerDown.onmousedown = function() {
				ptr.stageScrollDown()
			};
			photoScrollerDown.onmouseup = function() {
				ptr.clearTimer()
			};
			photoScrollerDown.onmouseout = function() {
				ptr.clearTimer()
			};
			photoScrollerDown.onmouseover = function() {
				this.style.cursor = 'pointer';
			};
			ptr.scrollerUp = photoScrollerUp;
			ptr.scrollerDown = photoScrollerDown;

			var photoNextPreviousContainer = document.createElement("div");
			photoNextPreviousContainer.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-photos-buttons');
			var photoNextPreviousButtonsContainer = document
					.createElement("div");
			photoNextPreviousButtonsContainer.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-photos-buttons-container');
			var photoNextButton = document.createElement("div");
			photoNextButton.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-photos-buttons-next');
			photoNextButton.innerHTML = '<span>NEXT</span>';
			var photoButtonDivider = document.createElement("div");
			photoButtonDivider.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-photos-buttons-divider');
			photoButtonDivider.innerHTML = '<img src="'
					+ diogenesServer
					+ '/sitewide/img/meter/spacer.gif" border="0" width="1" height="1">';
			var photoPreviousButton = document.createElement("div");
			photoPreviousButton.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-photos-buttons-previous');
			photoPreviousButton.innerHTML = '<span>PREV</span>';
			ptr.scrollerLeft = photoPreviousButton;
			photoPreviousButton.onmousedown = function() {
				ptr.prevPicture()
			};
			photoPreviousButton.onmouseover = function() {
				this.style.cursor = 'pointer';
			};
			photoPreviousButton.onmouseout = function() {
			};
			ptr.scrollerRight = photoNextButton;
			photoNextButton.onmousedown = function() {
				ptr.nextPicture()
			};
			photoNextButton.onmouseover = function() {
				this.style.cursor = 'pointer';
			};
			photoNextButton.onmouseout = function() {
			};

			var thumbList = document.createElement("div");
			thumbList.style.marginTop = "0px";
			ptr.thumbList = thumbList;

			var firstPhoto = "";
			var firstPhotoW = "";
			var firstPhotoH = "";

			var portraits = res.portraits;
			var images = res.images;
			var thumbTop = 0;
			var thumbIndex = 0;

			/*
			 * $(portraits).each(function(){ var idx = thumbIndex; var id =
			 * this.imageId; var w = this.width; var h = this.height; var url =
			 * this.url; var rank = this.rank;
			 * 
			 * if (typeof url != 'null' && w > 140){ var thumbDiv =
			 * document.createElement("div");
			 * thumbDiv.setAttribute(((document.all&&(Dio_IE_Ver<8.0)) ?
			 * 'className' : 'class'),'dio-module-photos-carousel-thumbs');
			 * thumbDiv.innerHTML = '<img title="" alt="" src="'+url+'"
			 * border="0" width="'+ptr.thumbWidth+'"
			 * height="'+ptr.thumbHeight+'">'; thumbDiv.onmouseover =
			 * function(){this.style.cursor = 'pointer';} thumbDiv.onclick =
			 * function(){ptr.loadPhoto(url, w, h, idx)};
			 * thumbList.appendChild(thumbDiv); ptr.photos.push({'url':url,
			 * 'id':id, 'w':w, 'h':h, 'caption':'', 'credit':'',
			 * 'index':thumbIndex, 'tTop':thumbTop}); thumbTop +=
			 * ptr.thumbHeight; thumbIndex++;
			 * 
			 * if (firstPhoto==""){ firstPhoto = url; firstPhotoW = w;
			 * firstPhotoH = h; } } });
			 * 
			 * $(images).each(function(){ var idx = thumbIndex; var id =
			 * this.imageId; var w = this.width; var h = this.height; var url =
			 * this.url; var credit = this.credit; var caption = this.caption;
			 * 
			 * if (typeof url != 'null' && w > 140){ var thumbDiv =
			 * document.createElement("div");
			 * thumbDiv.setAttribute(((document.all&&(Dio_IE_Ver<8.0)) ?
			 * 'className' : 'class'),'dio-module-photos-carousel-thumbs');
			 * thumbDiv.innerHTML = '<img title="'+caption.replace('"','\"')+'"
			 * alt="'+caption.replace('"','\"')+'" src="'+url+'" border="0"
			 * width="'+ptr.thumbWidth+'" height="'+ptr.thumbHeight+'">';
			 * thumbDiv.onmouseover = function(){this.style.cursor = 'pointer';}
			 * thumbDiv.onclick = function(){ptr.loadPhoto(url, w, h, idx)};
			 * thumbList.appendChild(thumbDiv); ptr.photos.push({'url':url,
			 * 'id':id, 'w':w, 'h':h, 'caption':caption, 'credit':credit,
			 * 'index':thumbIndex, 'tTop':thumbTop}); thumbTop +=
			 * ptr.thumbHeight; thumbIndex++;
			 * 
			 * if (firstPhoto==""){ firstPhoto = url; firstPhotoW = w;
			 * firstPhotoH = h; } } });
			 */

			$(images)
					.each(
							function() {
								var idx = thumbIndex;
								var url = this.url;
								var w = this.width;
								var h = this.height;

								if (typeof url != 'null') {
									var thumbDiv = document
											.createElement("div");
									thumbDiv
											.setAttribute(
													((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
															: 'class'),
													'dio-module-photos-carousel-thumbs');
									thumbDiv.innerHTML = '<img title="" alt="" src="'
											+ url + '" border="0">';
									thumbDiv.onmouseover = function() {
										this.style.cursor = 'pointer';
									}
									thumbDiv.onclick = function() {
										ptr.loadPhoto(url, w, h, idx)
									};
									thumbList.appendChild(thumbDiv);
									ptr.photos.push({
										'url' : url,
										'w' : w,
										'h' : h,
										'index' : thumbIndex,
										'tTop' : thumbTop
									});
									thumbTop += ptr.thumbHeight;
									thumbIndex++;

									if (firstPhoto == "") {
										firstPhoto = url;
										firstPhotoW = w;
										firstPhotoH = h;
									}
								}
							});

			photoCarousel.appendChild(thumbList);

			// photoHeader.innerHTML = 'Now Viewing: <span
			// class="dio-photos-tab-artist-name">'+unescape(ptr.cardObj.artistName)+'</span><div
			// class="header-divider"><img
			// src="'+diogenesServer+'/sitewide/img/meter/spacer.gif" border="0"
			// width="1" height="1"></div>';

			photoCarouselContainer.appendChild(photoScrollerUp);
			photoCarouselContainer.appendChild(photoCarousel);
			photoCarouselContainer.appendChild(photoScrollerDown);
			// ptr.contentObj.appendChild(photoHeader);
			ptr.contentObj.appendChild(photoBody);
			// ptr.contentObj.appendChild(photoCarouselContainer);
			ptr.contentObj.appendChild(photoNextPreviousContainer);
			photoNextPreviousContainer
					.appendChild(photoNextPreviousButtonsContainer);
			photoNextPreviousButtonsContainer.appendChild(photoPreviousButton);
			photoNextPreviousButtonsContainer.appendChild(photoButtonDivider);
			photoNextPreviousButtonsContainer.appendChild(photoNextButton);

			if (thumbList.innerHTML == "")
				ptr.contentObj.innerHTML = "NO PHOTOS FOUND"
			else
				ptr.loadPhoto(firstPhoto, firstPhotoW, firstPhotoH, 0);

			// ptr.refreshNextPrevButtons();

			ptr.cardObj.stageHideAll();
			ptr.cardObj.stageShow(ptr.mid);

			ptr.refreshScrollerButtons();

			if (ptr.cardObj.activeTab.module.mid != ptr.mid) { // if tab was
																// clicked
																// before ajax
																// is complete
				ptr.opening();
			}
		}
	}
	this.printAjaxErrors = function(err) {

		ptr.cardObj.stageHideAll();
		ptr.cardObj.stageShow(ptr.mid);

		// console.log(err);
		ptr.contentObj.innerHTML = err.statusText;

		if (ptr.cardObj.activeTab.module.mid != ptr.mid) { // if tab was
															// clicked before
															// ajax is complete
			ptr.opening();
		}
	}
	this.loadInStage = function() {
		this.cardObj.stageHideAll();
		this.cardObj.showLoading();

		var _params = '';
		var _dsURL = this.dsURL + 'meter/photos/?id='
				+ this.cardObj.artistMtvnId;
		// if (this.cardObj.mtvnUniverse) _params += "mtv=yes";

		if (!this.initialized || this.refresh) {
			// not initialized, ajax to get data and load stage
			this.removeAllChildren(this.contentObj);
			this.__loadData({
				url : _dsURL,
				data : _params,
				successHandler : this.processStage,
				errorHandler : this.printAjaxErrors,
				dataType : 'json'
			})
		} else {
			// just load stage with the content
			// this.removeAllChildren(this.cardObj.stage);
			// this.cardObj.stage.appendChild(this.contentObj);
			this.cardObj.stageHideAll();
			this.cardObj.stageShow(this.mid);
		}
	}

	if (this.targetDiv) {
		// console.log("Initializing Photos tab module");
		this.buildButton();
	}
}

Diogenes.Modules.Photos.prototype = new Diogenes();

Diogenes.Modules.Listen = function(options) { // using lala embed for music
												// listening
	if (options == null)
		options = {};
	var ptr = this;
	this.initialized = false;
	this.refresh = ('refresh' in options) ? options.refresh : false;
	this.cardObj = ('cardObj' in options) ? options.cardObj : null;
	this.mid = ('mid' in options) ? options.mid : null;
	this.notClickedHTML = "AUDIO";
	this.clicked = false;
	this.clickedHTML = "<strong>AUDIO</strong>";
	this.buttonDiv = document.createElement('span');
	this.contentObj = document.createElement('div');
	this.contentObj.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-module-listen');
	this.id = ('id' in options) ? options.id : '';

	this.targetDiv = ('targetDiv' in options) ? options.targetDiv : null;
	this.songsListDOMObj = null;
	this.songsListContainerDOMObj = null;
	this.playerDiv = null;
	this.player = null;
	this.audioBodyHeaderTitle = null;
	this.songs = [];
	this.currentPlayingIndex = null;
	this.paused = true;
	this.userPause = false;

	this.sampleLength = 30;
	this.scrollTimer = 0;
	this.scrollSpeed = 20;
	this.scrollInterval = 30;
	this.playButtonId = null;
	this.prevPlayButtonId = null;

	this.pcode = "mtvhive";
	this.ocode = "mtvhive";
	this.cpath = "mtvweb";
	this.rsrc = "mtvhive";

	this.buildButton = function() {
		this.buttonDiv.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card-buttons-links hidden');
		this.buttonDiv.innerHTML = this.notClickedHTML;
		this.buttonDiv.onmouseover = function() {
			this.style.cursor = 'pointer';
		}
		// this.buttonDiv.onclick = this.toggle;
	}

	this.opening = function() {
		this.cardObj.activeTab.module.clicked = false;
		this.cardObj.activeTab.module.buttonDiv.innerHTML = this.cardObj.activeTab.module.notClickedHTML;
		this.cardObj.activeTab = null;
		this.buttonDiv.innerHTML = this.clickedHTML;
		this.clicked = true;
		this.cardObj.activeTab = this.cardObj.tabs[this.mid];
		this.loadInStage();

		this.cardObj.listenTabRemote('play');
	}

	this.closing = function() {
		this.buttonDiv.innerHTML = this.notClickedHTML;
		this.clicked = false;

	}

	this.toggle = function() { // clicking action
		if (ptr.clicked) {
			// ptr.closing();
		} else {

			// clicked on, send reporting call
			// ptr.cardObj.coda2reporting({'name':'Audio', 'evarName':
			// DiogenesConfig.Reporting.TabOpen._eVar,
			// 'evarValue':unescape(ptr.cardObj.artistName)});
			ptr.cardObj.coda2reporting({
				'name' : 'Tab Open',
				'evarName' : DiogenesConfig.Reporting.TabOpen._eVar,
				'evarValue' : 'Audio'
			});

			ptr.opening();
		}
	}

	this.stageScrollUp = function(step) {
		var bodyYPos = parseInt(this.songsListDOMObj.style.marginTop);

		if (bodyYPos < 0)
			this.songsListDOMObj.style.marginTop = (bodyYPos + this.scrollSpeed)
					+ "px";

		if (step == "step") {
		} else
			this.scrollTimer = setTimeout(this.cardObj.divId + ".tabs["
					+ this.mid + "].module.stageScrollUp()",
					this.scrollInterval);
	}

	this.stageScrollDown = function(step) {
		var bodyYPos = parseInt(this.songsListDOMObj.style.marginTop);

		if (this.songsListContainerDOMObj.scrollHeight > this.songsListContainerDOMObj.offsetHeight)
			this.songsListDOMObj.style.marginTop = (bodyYPos - this.scrollSpeed)
					+ "px";

		if (step == "step") {
		} else
			this.scrollTimer = setTimeout(this.cardObj.divId + ".tabs["
					+ this.mid + "].module.stageScrollDown()",
					this.scrollInterval);
	}

	this.stageScrollDownAuto = function(step) {
		var bodyYPos = parseInt(this.songsListDOMObj.style.marginTop);

		this.songsListDOMObj.style.marginTop = (bodyYPos - step) + "px";

	}

	this.stageWheelScroll = function(event) {
		var delta = 0;
		if (!event)
			event = window.event;
		// normalize the delta
		if (event.wheelDelta) { // IE & Opera
			delta = event.wheelDelta / 120;
		} else if (event.detail) { // W3C
			delta = -event.detail / 3;
		}
		// console.log(delta);

		if (delta > 0)
			ptr.stageScrollUp("step");
		else
			ptr.stageScrollDown("step");

		return ptr.cancelEvent(event);
	}

	this.clearTimer = function(obj) {
		var timer = this.scrollTimer;
		clearTimeout(timer);
	}

	this.disableThis = function() {
		// console.log("disabling listen tab");
		// this.buttonDiv.setAttribute(((document.all&&(Dio_IE_Ver<8.0)) ?
		// 'className' : 'class'),'dio-card-buttons-links
		// dio-card-buttons-links-disable');
		this.buttonDiv.onmouseover = function() {
			this.style.cursor = 'default';
		}
		this.buttonDiv.onclick = null;

		this.contentObj.style.display = "none";

		var BiosTab = this.cardObj.getTab("bio");
		if (!BiosTab.initialized) {
			if (this.cardObj.rhapId != "") // rhapsody id present, tabs will be
											// complete by the time the card
											// will switch tweets tab so use
											// .toggle
				BiosTab.toggle();
			else
				// no rhapsody id so tabs will still be generating when this
				// method is called so just set tweets tab clicked = true.
				BiosTab.clicked = true;
		}

	}

	this.processRhapsodyData = function(res) {
		ptr.initialized = true;

		if (res) {

			var docs = res.tracks;
			var audioPieces = new Array();
			ptr.songs = audioPieces;

			if (typeof docs != 'undefined') {
				var docIndex = 0;
				for ( var i = 0; i < docs.length; i++) {
					if (audioPieces.length < 25) {
						if (docs[i].previewURL.indexOf(".mp3") > -1) {
							audioPieces.push({
								"idx" : docIndex,
								"obj" : docs[i]
							});
							docIndex++;
						}
					}
				}
			}

			var audioBody = document.createElement("div");
			// audioBody.setAttribute(((document.all&&(Dio_IE_Ver<8.0)) ?
			// 'className' : 'class'),'dio-module-listen');

			if (audioPieces.length > 0) { // IF THERE ARE MP3s OR SONGS

				var audioBodyHeaderContainer = document.createElement("div");
				audioBodyHeaderContainer.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'),
						'dio-module-listen-header-container');
				var audioBodyHeader = document.createElement("span");
				audioBodyHeader.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-listen-header');
				// audioBodyHeader.innerHTML = 'Audio powered by <img
				// src="/sitewide/img/meter/rhapLogo.gif" height="18"
				// width="88"/> <br/> All the music you want, just 10 bucks a
				// month. <a href="http://www.rhapsody.com/signup">Try it
				// free</a> <div
				// class="dio-module-listen-header-playAllSamples"><img
				// src="/sitewide/img/meter/playAllSamples.gif"/></div>';
				audioBodyHeader.innerHTML = '<span>Audio powered by <img align="absmiddle" src="/sitewide/img/meter/rhapLogo.gif" height="18" width="88"/> <br/> All the music you want, just 10 bucks a month. <a href="http://www.rhapsody.com/signup?pcode=mtvhive&ocode=mtvhive&cpath=mtvweb&rsrc=metertrial_gen" target="_blank">Try it free</a></span>';
				var audioBodyHeaderTitle = document.createElement("span");
				audioBodyHeaderTitle.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-listen-header-title');
				ptr.audioBodyHeaderTitle = audioBodyHeaderTitle;
				var audioBodyHeaderDivider = document.createElement("div");
				audioBodyHeaderDivider.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'header-divider');
				audioBodyHeaderDivider.innerHTML = '<img src="'
						+ diogenesServer
						+ '/sitewide/img/meter/spacer.gif" border="0" width="1" height="1">';

				audioBodyHeaderContainer.appendChild(audioBodyHeader);
				audioBodyHeaderContainer.appendChild(audioBodyHeaderTitle);
				// audioBodyHeaderContainer.appendChild(audioBodyHeaderDivider);

				var jPlayerDiv = document.createElement("div");
				jPlayerDiv.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-listen-jplayer');
				jPlayerDiv.setAttribute('id', 'dio-module-listen-jplayer'
						+ ptr.cardObj.divId);
				ptr.playerDiv = jPlayerDiv;

				var songListContainer = document.createElement("div");
				songListContainer.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-listen-body');
				ptr.songsListContainerDOMObj = songListContainer;
				if (window.addEventListener) {
					ptr.contentObj.addEventListener('DOMMouseScroll',
							ptr.stageWheelScroll, false);
					ptr.contentObj.addEventListener('mousewheel',
							ptr.stageWheelScroll, false);
				} else {
					ptr.contentObj.onmousewheel = ptr.stageWheelScroll;
				}

				var songListUL = document.createElement("ul");
				songListUL.style.marginTop = "0px";
				// songListUL.setAttribute(((document.all&&(Dio_IE_Ver<8.0)) ?
				// 'className' : 'class'),'dio-module-listen-body');
				ptr.songsListDOMObj = songListUL;
				songListContainer.appendChild(songListUL);

				var audioScroller = document.createElement("div");
				audioScroller.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-listen-scroller');
				var audioScrollerUp = document.createElement("div");
				audioScrollerUp.style.marginBottom = "200px";
				audioScrollerUp.innerHTML = '<img src="'
						+ diogenesServer
						+ '/sitewide/img/meter/button-scroller-up.gif" border="0" />';
				var audioScrollerDown = document.createElement("div");
				audioScrollerDown.innerHTML = '<img src="'
						+ diogenesServer
						+ '/sitewide/img/meter/button-scroller-down.gif" border="0" />';
				audioScroller.appendChild(audioScrollerUp);
				audioScroller.appendChild(audioScrollerDown);
				audioScrollerUp.onmousedown = function() {
					ptr.stageScrollUp()
				};
				audioScrollerUp.onmouseup = function() {
					ptr.clearTimer()
				};
				audioScrollerUp.onmouseout = function() {
					ptr.clearTimer()
				};
				audioScrollerDown.onmousedown = function() {
					ptr.stageScrollDown()
				};
				audioScrollerDown.onmouseup = function() {
					ptr.clearTimer()
				};
				audioScrollerDown.onmouseout = function() {
					ptr.clearTimer()
				};

				audioBody.appendChild(audioBodyHeaderContainer);
				audioBody.appendChild(songListContainer);
				audioBody.appendChild(audioScroller);
				audioBody.appendChild(jPlayerDiv);

				$(audioPieces)
						.each(
								function() {
									var songIndex = this.idx;
									songListLI = document.createElement("li");
									songListLI
											.setAttribute('id',
													'dio-module-listen-songlist-'
															+ ptr.cardObj.divId
															+ '-songIndex-'
															+ songIndex);
									var songLinkButton = document
											.createElement("div");
									songLinkButton
											.setAttribute(
													((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
															: 'class'),
													'dio-module-listen-songlist-button');
									songLinkButton.innerHTML = '<img src="'
											+ diogenesServer
											+ '/sitewide/img/meter/spacer.gif" border="0" width="7" height="1"><span class="dio-module-listen-time">:'
											+ ptr.sampleLength + '</span>';

									var songLinkBuyButton = document
											.createElement("div");
									songLinkBuyButton
											.setAttribute(
													((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
															: 'class'),
													'dio-module-listen-songlist-buybutton');
									songLinkBuyButton.innerHTML = '<img src="'
											+ diogenesServer
											+ '/sitewide/img/meter/spacer.gif" border="0" width="62" height="19">';

									var songLink = document
											.createElement("div");
									songLink
											.setAttribute(
													((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
															: 'class'),
													'dio-module-listen-songlist-title');
									// songLink.onmouseover =
									// function(){this.style.cursor =
									// 'pointer';}
									// songLink.onclick = function(){
									// ptr.playSong(songIndex); }
									songLink.innerHTML = this.obj.name.length > 30 ? this.obj.name
											.substr(0, 30)
											+ "..."
											: this.obj.name;
									// $(songLink).bind('click',function(){
									// ptr.playSong(songIndex); });
									songListLI.onmouseover = function() {
										this.style.cursor = 'pointer';
									}
									$(songListLI).bind('click', function() {
										ptr.userPause = false;
										ptr.playSong(songIndex);
									});
									/*
									 * $(songLinkBuyButton).bind('mouseover',
									 * function(e){ptr.highlightBuyButton(e,
									 * 'over');});
									 * $(songLinkBuyButton).bind('mouseout',
									 * function(e){ptr.highlightBuyButton(e,
									 * 'out');});
									 */

									var buyLink = 'http://mp3.rhapsody.com/goto?rcid='
											+ this.obj.trackId
											+ '&addToCart='
											+ this.obj.trackId
											+ '&pcode='
											+ ptr.pcode
											+ '&ocode='
											+ ptr.ocode
											+ '&cpath='
											+ ptr.cpath
											+ '&rsrc='
											+ ptr.rsrc;
									$(songLinkBuyButton).bind('click',
											function(e) {
												window.open(buyLink);
												return false;
											});

									var cleardiv = ptr.createClearDiv();

									songListLI.appendChild(songLinkBuyButton);
									songListLI.appendChild(songLinkButton);
									songListLI.appendChild(songLink);
									songListLI.appendChild(cleardiv);
									songListUL.appendChild(songListLI);

								});

				ptr.buttonDiv.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-card-buttons-links');
				ptr.buttonDiv.onclick = ptr.toggle;

			} else { // NO AUDIO SAMPLES TO SHOW
				// audioBody.innerHTML="NO SAMPLES FOUND";

				ptr.disableThis();
			}

			ptr.contentObj.appendChild(audioBody);

			ptr.cardObj.stageHideAll();
			ptr.cardObj.stageShow(ptr.mid);

			$('#dio-module-listen-jplayer' + ptr.cardObj.divId)
					.jPlayer(
							{
								ready : function() {

								},
								swfPath : diogenesServer
										+ "/sitewide/js/jQuery.jPlayer.1.1.1",
								volume : 80,
								timeupdate : function(e) {
									if (!ptr.paused) {
										var status = e.jPlayer.status;
										var currentTime = status.currentTime
										var duration = status.duration;
										var currentPercentRelative = status.currentPercentRelative;
										if ((100 - currentPercentRelative) != 100) {
											var time = (Math.floor(duration
													- currentTime));
											if ((String(time)).length == 1) {
												time = ":0" + time;
											} else {
												time = ":" + time;
											}
											$(
													ptr.playButtonId
															+ ' .dio-module-listen-songlist-button .dio-module-listen-time')
													.text(time);
										}
									}
								},
								ended : function(e) {
									var duration = e.jPlayer.status.duration;
									// reset time
									$(
											ptr.playButtonId
													+ ' .dio-module-listen-songlist-button .dio-module-listen-time')
											.text(":" + (Math.round(duration)));
									ptr.playNext();
								},
								stop : function(e) {
									var duration = e.jPlayer.status.duration;
									// reset time
									$(
											ptr.playButtonId
													+ ' .dio-module-listen-songlist-button .dio-module-listen-time')
											.text(":" + (Math.round(duration)));
								}
							})

			/*
			 * .jPlayer("onProgressChange", function(loadPercent,
			 * playedPercentRelative, playedPercentAbsolute, playedTime,
			 * totalTime) { if((100-playedPercentRelative) != 100){ var time =
			 * (Math.floor((totalTime-playedTime)/1000));
			 * if((String(time)).length == 1){time =
			 * ":0"+time;}else{time=":"+time;} $(ptr.playButtonId+'
			 * .dio-module-listen-songlist-button
			 * .dio-module-listen-time').text(time); } })
			 * .jPlayer("onSoundComplete", function() { //reset time
			 * $(ptr.playButtonId+' .dio-module-listen-songlist-button
			 * .dio-module-listen-time').text(":"+(Math.round($('#dio-module-listen-jplayer'+ptr.cardObj.divId).data("jPlayer.config").diag.totalTime/1000)));
			 * ptr.playNext(); }) .jPlayer("stop", function() { //reset time
			 * 
			 * $(ptr.playButtonId+' .dio-module-listen-songlist-button
			 * .dio-module-listen-time').text(":"+(Math.round($('#dio-module-listen-jplayer'+ptr.cardObj.divId).data("jPlayer.config").diag.totalTime/1000)));
			 * 
			 * });
			 */
			$(
					'#' + ptr.cardObj.card.id
							+ ' .dio-module-listen-header-playAllSamples img')
					.bind('click', function() {
						ptr.playSong(0);
					});
		}
	}

	this.processStage = function(res) {
		ptr.initialized = true;

		if (res) {

			var docs = res.tracks;
			var audioPieces = new Array();
			ptr.songs = audioPieces;

			if (typeof docs != 'undefined') {
				var docIndex = 0;
				for ( var i = 0; i < docs.length; i++) {

					if (docs[i].url.indexOf(".mp3") > -1) {
						audioPieces.push({
							"idx" : docIndex,
							"obj" : docs[i]
						});
						docIndex++;
					}
				}
			}

			var audioBody = document.createElement("div");
			// audioBody.setAttribute(((document.all&&(Dio_IE_Ver<8.0)) ?
			// 'className' : 'class'),'dio-module-listen');

			if (audioPieces.length > 0) { // IF THERE ARE MP3s OR SONGS

				var audioBodyHeaderContainer = document.createElement("div");
				audioBodyHeaderContainer.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'),
						'dio-module-listen-header-container');
				var audioBodyHeader = document.createElement("span");
				audioBodyHeader.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-listen-header');
				audioBodyHeader.innerHTML = 'Audio powered by <img src="/sitewide/img/meter/rhapLogo.gif" height="18" width="88"/> – all the music you want, just 10 bucks a month. <a href="">Try it free</a> <img src="/sitewide/img/meter/playAllSamples.gif" id="dio-module-listen-header-playAllSamples"/>';
				var audioBodyHeaderTitle = document.createElement("span");
				audioBodyHeaderTitle.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-listen-header-title');
				ptr.audioBodyHeaderTitle = audioBodyHeaderTitle;
				var audioBodyHeaderDivider = document.createElement("div");
				audioBodyHeaderDivider.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'header-divider');
				audioBodyHeaderDivider.innerHTML = '<img src="'
						+ diogenesServer
						+ '/sitewide/img/meter/spacer.gif" border="0" width="1" height="1">';

				audioBodyHeaderContainer.appendChild(audioBodyHeader);
				audioBodyHeaderContainer.appendChild(audioBodyHeaderTitle);
				audioBodyHeaderContainer.appendChild(audioBodyHeaderDivider);

				var jPlayerDiv = document.createElement("div");
				jPlayerDiv.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-listen-jplayer');
				jPlayerDiv.setAttribute('id', 'dio-module-listen-jplayer'
						+ ptr.cardObj.divId);
				ptr.playerDiv = jPlayerDiv;

				var songListContainer = document.createElement("div");
				songListContainer.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-listen-body');
				ptr.songsListContainerDOMObj = songListContainer;
				if (window.addEventListener) {
					ptr.contentObj.addEventListener('DOMMouseScroll',
							ptr.stageWheelScroll, false);
					ptr.contentObj.addEventListener('mousewheel',
							ptr.stageWheelScroll, false);
				} else {
					ptr.contentObj.onmousewheel = ptr.stageWheelScroll;
				}

				var songListUL = document.createElement("ul");
				songListUL.style.marginTop = "0px";
				// songListUL.setAttribute(((document.all&&(Dio_IE_Ver<8.0)) ?
				// 'className' : 'class'),'dio-module-listen-body');
				ptr.songsListDOMObj = songListUL;
				songListContainer.appendChild(songListUL);

				var audioScroller = document.createElement("div");
				audioScroller.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-listen-scroller');
				var audioScrollerUp = document.createElement("div");
				audioScrollerUp.style.marginBottom = "165px";
				audioScrollerUp.innerHTML = '<img src="'
						+ diogenesServer
						+ '/sitewide/img/meter/button-scroller-up.gif" border="0" />';
				var audioScrollerDown = document.createElement("div");
				audioScrollerDown.innerHTML = '<img src="'
						+ diogenesServer
						+ '/sitewide/img/meter/button-scroller-down.gif" border="0" />';
				audioScroller.appendChild(audioScrollerUp);
				audioScroller.appendChild(audioScrollerDown);
				audioScrollerUp.onmousedown = function() {
					ptr.stageScrollUp()
				};
				audioScrollerUp.onmouseup = function() {
					ptr.clearTimer()
				};
				audioScrollerUp.onmouseout = function() {
					ptr.clearTimer()
				};
				audioScrollerDown.onmousedown = function() {
					ptr.stageScrollDown()
				};
				audioScrollerDown.onmouseup = function() {
					ptr.clearTimer()
				};
				audioScrollerDown.onmouseout = function() {
					ptr.clearTimer()
				};

				audioBody.appendChild(audioBodyHeaderContainer);
				audioBody.appendChild(songListContainer);
				audioBody.appendChild(audioScroller);
				audioBody.appendChild(jPlayerDiv);

				$(audioPieces)
						.each(
								function() {
									var songIndex = this.idx;
									songListLI = document.createElement("li");
									songListLI
											.setAttribute('id',
													'dio-module-listen-songlist-'
															+ ptr.cardObj.divId
															+ '-songIndex-'
															+ songIndex);
									var songLinkButton = document
											.createElement("div");
									songLinkButton
											.setAttribute(
													((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
															: 'class'),
													'dio-module-listen-songlist-button');
									songLinkButton.innerHTML = '<img src="'
											+ diogenesServer
											+ '/sitewide/img/meter/spacer.gif" border="0" width="7" height="1"><span class="dio-module-listen-time">:'
											+ ptr.sampleLength + '</span>';
									var songLink = document
											.createElement("div");
									songLink
											.setAttribute(
													((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
															: 'class'),
													'dio-module-listen-songlist-title');
									// songLink.onmouseover =
									// function(){this.style.cursor =
									// 'pointer';}
									// songLink.onclick = function(){
									// ptr.playSong(songIndex); }
									songLink.innerHTML = this.obj.title;
									// $(songLink).bind('click',function(){
									// ptr.playSong(songIndex); });
									songListLI.onmouseover = function() {
										this.style.cursor = 'pointer';
									}
									$(songListLI).bind('click', function() {
										ptr.playSong(songIndex);
									});

									var cleardiv = ptr.createClearDiv();

									songListLI.appendChild(songLinkButton);
									songListLI.appendChild(songLink);
									songListLI.appendChild(cleardiv);
									songListUL.appendChild(songListLI);
								});

			} else { // NO AUDIO SAMPLES TO SHOW
				// audioBody.innerHTML="NO SAMPLES FOUND";

				ptr.disableThis();
			}

			ptr.contentObj.appendChild(audioBody);

			ptr.cardObj.stageHideAll();
			ptr.cardObj.stageShow(ptr.mid);

			$('#dio-module-listen-jplayer' + ptr.cardObj.divId).jPlayer({
				ready : function() {

				},
				swfPath : diogenesServer + "/sitewide/js/jQuery.jPlayer.1.1.1",
				volume : 80
			}).jPlayer(
					"onProgressChange",
					function(loadPercent, playedPercentRelative,
							playedPercentAbsolute, playedTime, totalTime) {
						// console.log(playedTime)
						var currentVolume = this.element.jPlayer("getData",
								"volume");
						// console.log(currentVolume);

						/*
						 * if (playedTime <= 30000 ){ // var minVol = 0;
						 * this.element.jPlayer( "volume", 50); } if (playedTime >
						 * 30000 && playedTime <= 34000){ //fading in var
						 * fadingIn = currentVolume + 3; this.element.jPlayer(
						 * "volume", fadingIn); }
						 */
						if (playedTime > 56000 && playedTime <= 60000) { // fading
																			// out
							var fadingOut = currentVolume - 3;
							this.element.jPlayer("volume", fadingOut);
						}
						if (playedTime > 60000) { // skip to next
							ptr.playNext();
						}
					});

			if (ptr.cardObj.activeTab.module.mid != ptr.mid) { // if tab was
																// clicked
																// before ajax
																// is complete
				ptr.opening();
			}
			$(
					'#' + ptr.cardObj.card.id
							+ ' .dio-module-listen-header-playAllSamples img')
					.bind('click', function() {
						ptr.playSong(0);
					});
		}
	}

	this.resetAllPlayButtons = function() {
		// clear highlight states
		$(ptr.songsListDOMObj).find("li").each(
				function() {
					// $(ptr.playButtonId+' .dio-module-listen-songlist-button
					// .dio-module-listen-time').text(":"+ptr.sampleLength);
					$(this).find('.dio-module-listen-songlist-button').find(
							'.dio-module-listen-time').text(
							":" + ptr.sampleLength);
					$(this).removeClass('paused');
					$(this).removeClass('playing');
				});

		if (this.audioBodyHeaderTitle != null)
			this.audioBodyHeaderTitle.innerHTML = "";
	}

	this.highlightBuyButton = function(e, state) {
		if (state == "over") {
			$(e.currentTarget).addClass('over');
		} else {
			$(e.currentTarget).removeClass('over');
		}
	}

	this.playSong = function(index) {
		// console.log(index)
		var playButtonId = '#dio-module-listen-songlist-' + ptr.cardObj.divId
				+ '-songIndex-' + index;
		this.playButtonId = playButtonId;

		if (this.prevPlayButtonId != this.playButtonId) {
			$(
					ptr.prevPlayButtonId
							+ ' .dio-module-listen-songlist-button .dio-module-listen-time')
					.text(":" + ptr.sampleLength);
		}
		this.prevPlayButtonId = playButtonId;

		var playerId = '#dio-module-listen-jplayer' + ptr.cardObj.divId;

		if (index != this.currentPlayingIndex) {

			this.resetAllPlayButtons();
			// $(playerId).jPlayer( "stop"); redundant, crashes chrome
			$(playerId).jPlayer("volume", 80);

			// highlight this button
			var highlightingLink = $(ptr.songsListDOMObj).find(playButtonId);
			if (highlightingLink != null) {
				highlightingLink.addClass('playing');
			}

			// for scrolling to next active song if it's out of visible range
			var activeSongTop = highlightingLink.position().top;
			var activeSongHeight = highlightingLink.height();
			var activeSongBottom = activeSongTop + activeSongHeight;
			// console.log(activeSongTop);console.log(activeSongHeight);console.log(activeSongBottom);
			var divTop = $(ptr.songsListContainerDOMObj).position().top;
			var divHeight = $(ptr.songsListContainerDOMObj).height();
			var divBottom = divTop + divHeight;
			// console.log(divTop);console.log(divHeight);console.log(divBottom);
			// var wrecksHeight = $(ptr.cardObj.wrecks).height();
			var nextSongHeight = highlightingLink.next().height();

			if (activeSongBottom >= divBottom) {
				ptr.stageScrollDownAuto(activeSongHeight);
			}
			// end of scrolling to next song

			/*
			 * var activeSongTop = $('div.dio-module-listen-body
			 * li.playing').position().top; var activeSongHeight =
			 * $('div.dio-module-listen-body li.playing').height(); var
			 * activeSongBottom = activeSongTop + activeSongHeight;
			 * 
			 * var divTop = $('div.dio-module-listen-body').position().top; var
			 * divHeight = $('div.dio-module-listen-body').height(); var
			 * divBottom = divTop + divHeight;
			 * 
			 * var wrecksHeight = $('div.dio-card-wrecks').height(); var
			 * nextSongHeight = $('div.dio-module-listen-body
			 * li.playing').next().height()
			 * 
			 * if (activeSongBottom >= (divBottom - wrecksHeight) ) {
			 * ptr.stageScrollDownAuto(nextSongHeight); }
			 */

			if (index < this.songs.length && index >= 0) {

				if (isRhap) {
					// console.log(ptr.songs[index].obj.previewURL)
					$(playerId).jPlayer("setMedia", {
						"mp3" : ptr.songs[index].obj.previewURL
					});
				} else {
					// console.log(ptr.songs[index].obj.url)
					// $(playerId).jPlayer( "setFile", ptr.songs[index].obj.url
					// );
					$(playerId).jPlayer("setMedia", {
						"mp3" : ptr.songs[index].obj.url
					});
					$(playerId).jPlayer("playHead", 30000);
				}

				$(playerId).jPlayer("play");

				if (isRhap) {
					this.audioBodyHeaderTitle.innerHTML = ptr.songs[index].obj.name;
				} else {
					this.audioBodyHeaderTitle.innerHTML = ptr.songs[index].obj.title;
				}

				this.currentPlayingIndex = index;
				this.paused = false;
			}
		} else if (index == this.currentPlayingIndex && !this.paused) {
			var highlightingLink = $(ptr.songsListDOMObj).find(playButtonId);
			if (highlightingLink != null) {
				highlightingLink.removeClass('playing');
				highlightingLink.addClass('paused');
			}

			$(playerId).jPlayer("pause");
			this.paused = true;
			this.userPause = true;
		} else if (index == this.currentPlayingIndex && this.paused) {
			// highlight this button
			var highlightingLink = $(ptr.songsListDOMObj).find(playButtonId);
			if (highlightingLink != null) {
				highlightingLink.removeClass('paused');
				highlightingLink.addClass('playing');
			}

			$(playerId).jPlayer("play");
			this.paused = false;
		}
	}

	this.playNext = function() {
		var nextSongIndex = this.currentPlayingIndex + 1;
		this.playSong(nextSongIndex);
	}
	this.playPrevious = function() {
		var prevSongIndex = this.currentPlayingIndex - 1;
		this.playSong(prevSongIndex);
	}

	this.getRhapId = function(data) { // get the rhapsody artist id from
										// echonest *DEPRECATED*
		ptr.initialized = true;

		ptr.cardObj.echoProfileObj = data;

		try {
			if (data.profile.rhapId != '') {
				ptr.cardObj.rhapId = data.profile.rhapId;
				ptr.getTrackList();
			} else {
				ptr.removeAllChildren(ptr.contentObj);
				ptr.cardObj.stageHideAll();
				ptr.cardObj.stageShow(ptr.mid);

				var audioBody = document.createElement("div");
				audioBody.innerHTML = "NO ID MAPPING FOUND";
				ptr.contentObj.appendChild(audioBody);

				ptr.disableThis();
			}
		} catch (e) {
			// console.log("Diogenes.Card LISTEN TAB: getRhapId failed " + e);
		}
	}
	this.getTrackList = function() {

		if (isRhap) {
			var _dsURL = this.dsURL + 'meter/rhap/?id=' + this.cardObj.rhapId;
		} else {
			var _dsURL = this.dsURL + 'meter/audio/?id='
					+ this.cardObj.artistId;
		}

		var _params = '';
		// console.log(ptr.cardObj.artistId)
		if (this.cardObj.mtvnUniverse)
			_params += "mtv=yes";

		// not initialized, ajax to get data and load stage
		this.removeAllChildren(this.contentObj);

		if (isRhap) {
			this.__loadData({
				url : _dsURL,
				data : '',
				successHandler : this.processRhapsodyData,
				errorHandler : this.ajaxErrors,
				dataType : 'json'
			})
		} else {
			this.__loadData({
				url : _dsURL,
				data : _params,
				successHandler : this.processStage,
				errorHandler : this.ajaxErrors,
				dataType : 'json'
			})
		}

	}
	this.loadInStage = function() {

		this.cardObj.stageHideAll();
		this.cardObj.showLoading();

		if (!this.initialized || this.refresh) {
			if (this.cardObj.rhapId == "") {
				this.removeAllChildren(this.contentObj);
				this.cardObj.stageHideAll();
				this.cardObj.stageShow(this.mid);

				var audioBody = document.createElement("div");
				audioBody.innerHTML = "NO ID MAPPING FOUND";
				this.contentObj.appendChild(audioBody);

				this.disableThis();

			} else {
				this.getTrackList();
			}
		} else {
			// just hide all stages then show the clicked stage
			this.cardObj.stageHideAll();
			this.cardObj.stageShow(this.mid);
		}
	}

	if (this.targetDiv) {
		// console.log("Initializing Listen tab module");
		this.buildButton();
	}
}

Diogenes.Modules.Listen.prototype = new Diogenes();

Diogenes.Modules.Videos = function(options) {
	if (options == null)
		options = {};
	var ptr = this;
	this.initialized = false;
	this.refresh = ('refresh' in options) ? options.refresh : false;
	this.cardObj = ('cardObj' in options) ? options.cardObj : null;
	this.mid = ('mid' in options) ? options.mid : null;
	this.notClickedHTML = "VIDEOS";
	this.clicked = false;
	this.clickedHTML = "<strong>VIDEOS</strong>";
	this.buttonDiv = document.createElement('span');
	this.contentObj = document.createElement('div');
	this.contentObj.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-module-videos');
	this.dsURL = ('dsURL' in options) ? options.dsURL : '';
	this.id = ('id' in options) ? options.id : '';
	this.params = ('params' in options) ? options.params : '';
	this.type = ('type' in options) ? options.type : 'xml';
	this.targetDiv = ('targetDiv' in options) ? options.targetDiv : null;

	this.scrollTimer = 0;
	this.scrollSpeed = 15;
	this.scrollInterval = 30;
	this.videoBody = null;
	this.videoPlayerContainer = null;
	this.videoCarousel = null;
	this.videoBodyPlaylist = null;
	this.scrollerUp = null;
	this.scrollerDown = null;

	this.buildButton = function() {
		this.buttonDiv.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card-buttons-links hidden');
		this.buttonDiv.innerHTML = this.notClickedHTML;
		this.buttonDiv.onmouseover = function() {
			this.style.cursor = 'pointer';
		}
		// this.buttonDiv.onclick = this.toggle;
	}

	this.opening = function() {
		this.cardObj.activeTab.module.clicked = false;
		this.cardObj.activeTab.module.buttonDiv.innerHTML = this.cardObj.activeTab.module.notClickedHTML;
		this.cardObj.activeTab = null;
		this.buttonDiv.innerHTML = this.clickedHTML;
		this.clicked = true;
		this.cardObj.activeTab = this.cardObj.tabs[this.mid];
		this.loadInStage();

		this.cardObj.listenTabRemote('pause');
	}

	this.closing = function() {
		this.buttonDiv.innerHTML = this.notClickedHTML;
		this.clicked = false;

	}

	this.toggle = function() { // clicking action
		if (ptr.clicked) {
			// ptr.closing();
		} else {

			// clicked on, send reporting call
			// ptr.cardObj.coda2reporting({'name':'Videos', 'evarName':
			// DiogenesConfig.Reporting.TabOpen._eVar,
			// 'evarValue':unescape(ptr.cardObj.artistName)});
			ptr.cardObj.coda2reporting({
				'name' : 'Tab Open',
				'evarName' : DiogenesConfig.Reporting.TabOpen._eVar,
				'evarValue' : 'Videos'
			});

			ptr.opening();
		}
	}

	this.stageScrollUp = function(step) {
		var bodyYPos = parseInt(this.videoBodyPlaylist.style.marginTop);

		if (bodyYPos < 0)
			this.videoBodyPlaylist.style.marginTop = (bodyYPos + this.scrollSpeed)
					+ "px";

		if (step == "step") {
		} else
			this.scrollTimer = setTimeout(this.cardObj.divId + ".tabs["
					+ this.mid + "].module.stageScrollUp()",
					this.scrollInterval);

		this.refreshScrollerButtons();
	}

	this.stageScrollDown = function(step) {
		var bodyYPos = parseInt(this.videoBodyPlaylist.style.marginTop);
		/*
		 * console.log(ptr.videoBodyPlaylist.style.marginTop);
		 * console.log(ptr.videoCarousel.scrollHeight);
		 * console.log(ptr.videoCarousel.offsetHeight);
		 */
		if (this.videoCarousel.scrollHeight > this.videoCarousel.offsetHeight)
			this.videoBodyPlaylist.style.marginTop = (bodyYPos - this.scrollSpeed)
					+ "px";

		if (step == "step") {
		} else
			this.scrollTimer = setTimeout(this.cardObj.divId + ".tabs["
					+ this.mid + "].module.stageScrollDown()",
					this.scrollInterval);

		this.refreshScrollerButtons();
	}

	this.stageWheelScroll = function(event) {
		var delta = 0;
		if (!event)
			event = window.event;
		// normalize the delta
		if (event.wheelDelta) { // IE & Opera
			delta = event.wheelDelta / 120;
		} else if (event.detail) { // W3C
			delta = -event.detail / 3;
		}
		// console.log(delta);

		if (delta > 0)
			ptr.stageScrollUp("step");
		else
			ptr.stageScrollDown("step");

		return ptr.cancelEvent(event);
	}

	this.refreshScrollerButtons = function() {
		if (this.videoBodyPlaylist != null) {
			var bodyYPos = parseInt(this.videoBodyPlaylist.style.marginTop);

			if (bodyYPos < 0) {
				this.scrollerUp.innerHTML = '<img src="'
						+ diogenesServer
						+ '/sitewide/img/meter/card-tab-scroller-button-up-on.gif" border=0 />';
			} else {
				this.scrollerUp.innerHTML = '<img src="'
						+ diogenesServer
						+ '/sitewide/img/meter/card-tab-scroller-button-up-off.gif" border=0 />';
			}

			if (this.videoCarousel.scrollHeight > this.videoCarousel.offsetHeight) {
				this.scrollerDown.innerHTML = '<img src="'
						+ diogenesServer
						+ '/sitewide/img/meter/card-tab-scroller-button-down-on.gif" border=0 />';
			} else {
				this.scrollerDown.innerHTML = '<img src="'
						+ diogenesServer
						+ '/sitewide/img/meter/card-tab-scroller-button-down-off.gif" border=0 />';
			}
		}
	}

	this.clearTimer = function(obj) {
		var timer = this.scrollTimer;
		clearTimeout(timer);
	}

	this.disableThis = function() {
		// this.buttonDiv.setAttribute(((document.all&&(Dio_IE_Ver<8.0)) ?
		// 'className' : 'class'),'dio-card-buttons-links
		// dio-card-buttons-links-disable');
		this.buttonDiv.onmouseover = function() {
			this.style.cursor = 'default';
		}
		this.buttonDiv.onclick = null;
	}

	this.embedYouTubePlayer = function(cardId, ytVidId) {
		var ytVideoSo = new SWFObject("http://www.youtube.com/v/" + ytVidId
				+ "?enablejsapi=1&playerapiid=ytplayer&autoplay=1", cardId
				+ "-ytplayer", 404, 270, "0", "#000000");
		ytVideoSo.useExpressInstall('/sitewide/flash/expressInstall.swf');
		ytVideoSo.addParam("wmode", "transparent");
		ytVideoSo.addParam("allowFullscreen", "true");
		ytVideoSo.addParam("autoPlay", "true");
		ytVideoSo.addParam("allowScriptAccess", "always");
		ytVideoSo.write(cardId + "-ytapiplayer");

		// var params = { allowScriptAccess: "always" };
		// var atts = { id: cardId + "-ytplayer" };
		// swfobject.embedSWF("http://www.youtube.com/v/"+ ytVidId
		// +"?enablejsapi=1&playerapiid=ytplayer", cardId + "-ytapiplayer",
		// "300", "225", "8", null, null, params, atts);
	}

	this.populateExternalEmbeds = function() {

		var cardId = this.cardObj.echoId;
		// console.log(this.externalEmbeds)
		if (typeof mmVidTabProgramming != 'undefined') {
			if (this.externalEmbeds != null) {

				var ytVideoContainer = document.createElement("div");
				ytVideoContainer.innerHTML = "You need Flash player 8+ and JavaScript enabled to view this video.";
				ytVideoContainer.setAttribute('id', cardId + '-ytapiplayer');

				var vEmbedObj = this.externalEmbeds.vs[0];
				var vEmbedVidId = this.externalEmbeds.vs[0].vurl;

				this.videoBody.appendChild(ytVideoContainer);

				this.embedYouTubePlayer(cardId, vEmbedVidId);
			} else {
				return false;
			}
		} else {
			return false;
		}

		return true;
	}

	this.processStage = function(res) {
		ptr.initialized = true;

		if (res) {
			var found = false;

			var docs = res.videos;
			var videoMGIDs = new Array();

			for ( var i = 0; i < docs.length; i++) {

				var vId = ('id' in docs[i]) ? docs[i].id : "";
				var vTitle = ('title_t' in docs[i]) ? docs[i].title_t : "";
				var vArtist = ('artist_t' in docs[i]) ? docs[i].artist_t : "";
				var vType = ('videoTypeGrouping_facet' in docs[i]) ? docs[i].videoTypeGrouping_facet
						: "";

				if (vId != ""
						&& (vType == "music_video" || vType == "live_performance")) {
					if (vType == "music_video")
						videoMGIDs.splice(0, 0, ptr.MTV_MGID_PREFIX + vId); // putting
																			// music
																			// videos
																			// before
																			// live
																			// perf
					else
						videoMGIDs.push(ptr.MTV_MGID_PREFIX + vId);
				}
			}

			if (videoMGIDs.length > 0) { // IF THERE ARE VIDEOS

				var videoBody = ptr.videoBody;

				var videoBodyHeaderContainer = document.createElement("div");
				videoBodyHeaderContainer.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'),
						'dio-module-videos-video-header-container');
				var videoBodyHeader = document.createElement("span");
				videoBodyHeader.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-videos-video-header');
				videoBodyHeader.innerHTML = 'Now Playing: ';
				var videoBodyHeaderTitle = document.createElement("span");
				videoBodyHeaderTitle.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'),
						'dio-module-videos-video-header-title');
				ptr.videoBodyHeaderTitle = videoBodyHeaderTitle;
				var videoBodyHeaderDivider = document.createElement("div");
				videoBodyHeaderDivider.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'header-divider');
				videoBodyHeaderDivider.innerHTML = '<img src="'
						+ diogenesServer
						+ '/sitewide/img/meter/spacer.gif" border="0" width="1" height="1">';

				/*
				 * commented 9/30/2010
				 * videoBodyHeaderContainer.appendChild(videoBodyHeader);
				 * videoBodyHeaderContainer.appendChild(videoBodyHeaderTitle);
				 * videoBodyHeaderContainer.appendChild(videoBodyHeaderDivider);
				 */

				var videoBodyVideoPlayer = document.createElement("div");
				videoBodyVideoPlayer.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-videos-video-player');
				videoBodyVideoPlayer.setAttribute('id', 'MTVN_PL-video-player');
				ptr.videoPlayerContainer = videoBodyVideoPlayer;

				videoBodyVideoPlayer.innerHTML = '<object height="225" width="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="player1">'
						+ '<embed height="225" width="300"'
						+ 'type="application/x-shockwave-flash""/>'
						+ '</object>';

				var videoBodyPlaylist = document.createElement("div");
				videoBodyPlaylist.style.marginTop = "0px";
				ptr.videoBodyPlaylist = videoBodyPlaylist;
				var videoPlaylist = document.createElement("div");
				videoPlaylist.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-videos-playlist');
				if (window.addEventListener) {
					videoPlaylist.addEventListener('DOMMouseScroll',
							ptr.stageWheelScroll, false);
					videoPlaylist.addEventListener('mousewheel',
							ptr.stageWheelScroll, false);
				} else {
					videoPlaylist.onmousewheel = ptr.stageWheelScroll;
				}

				var videoCarousel = document.createElement("div");
				videoCarousel.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-videos-carousel');
				ptr.videoCarousel = videoCarousel;

				var videoScrollerUp = document.createElement("div");
				videoScrollerUp.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-videos-scroller-up');
				videoScrollerUp.innerHTML = '<img src="'
						+ diogenesServer
						+ '/sitewide/img/meter/card-tab-scroller-button-up-off.gif" border="0" />';
				var videoScrollerDown = document.createElement("div");
				videoScrollerDown.setAttribute(
						((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
								: 'class'), 'dio-module-videos-scroller-down');
				videoScrollerDown.innerHTML = '<img src="'
						+ diogenesServer
						+ '/sitewide/img/meter/card-tab-scroller-button-down-off.gif" border="0" />';
				videoScrollerUp.onmousedown = function() {
					ptr.stageScrollUp()
				};
				videoScrollerUp.onmouseup = function() {
					ptr.clearTimer()
				};
				videoScrollerUp.onmouseout = function() {
					ptr.clearTimer()
				};
				videoScrollerUp.onmouseover = function() {
					this.style.cursor = 'pointer';
				};
				videoScrollerDown.onmousedown = function() {
					ptr.stageScrollDown()
				};
				videoScrollerDown.onmouseup = function() {
					ptr.clearTimer()
				};
				videoScrollerDown.onmouseout = function() {
					ptr.clearTimer()
				};
				videoScrollerDown.onmouseover = function() {
					this.style.cursor = 'pointer';
				};
				ptr.scrollerUp = videoScrollerUp;
				ptr.scrollerDown = videoScrollerDown;

				videoCarousel.appendChild(videoBodyPlaylist);
				videoPlaylist.appendChild(videoScrollerUp);
				videoPlaylist.appendChild(videoCarousel);
				videoPlaylist.appendChild(videoScrollerDown);
				videoBody.appendChild(videoBodyHeaderContainer);
				videoBody.appendChild(videoBodyVideoPlayer);
				videoBody.appendChild(videoPlaylist);

				if (typeof MTVN_PL != 'null') {
					var transientParams = new MTVN_PL.TransientParamsDO();

					transientParams.contentURI = ptr.cardObj.divId;
					transientParams.listName = ptr.cardObj.artistName
							+ "'s Videos";

					transientParams.itemIDs = videoMGIDs;

					// videoBodyVideoPlayer.innerHTML =
					// MTVN_PL.VideoHelper.placeVideo();
					videoBodyPlaylist.innerHTML = MTVN_PL.PlaylistManager
							.placeTransientList(transientParams,
									MTVN_PL.PlaybackPlaylist, true);

				} else {
					contentObj.innerHTML = "No playlisting service found, please include the playlisting service scripts."
				}

			} else { // NO VIDEOS TO SHOW
				var externalEmbeds = ptr.populateExternalEmbeds();
				if (!externalEmbeds)
					ptr.videoBody.innerHTML = "NO VIDEOS FOUND";
			}

			ptr.cardObj.stageHideAll();
			ptr.cardObj.stageShow(ptr.mid);

			ptr.refreshScrollerButtons();

			if (ptr.cardObj.activeTab.module.mid != ptr.mid) { // if tab was
																// clicked
																// before ajax
																// is complete
				ptr.opening();
			}
		}
	}
	this.printAjaxErrors = function(err) {

		ptr.cardObj.stageHideAll();
		ptr.cardObj.stageShow(ptr.mid);

		// console.log(err.statusText);
		// ptr.contentObj.innerHTML = err.statusText + '<br/><br/>' +
		// err.responseText;

		var externalEmbeds = ptr.populateExternalEmbeds();
		if (!externalEmbeds)
			ptr.contentObj.innerHTML = err.statusText;

		if (ptr.cardObj.activeTab.module.mid != ptr.mid) { // if tab was
															// clicked before
															// ajax is complete
			ptr.opening();
		}
	}
	this.loadInStage = function() {
		this.cardObj.stageHideAll();
		this.cardObj.showLoading();

		var _params = '';
		var _dsURL = this.dsURL + 'meter/videos/?id='
				+ this.cardObj.artistMtvnId;

		if (!this.initialized || this.refresh) {
			// not initialized, ajax to get data and load stage
			this.removeAllChildren(this.contentObj);

			var videoHeader = document.createElement("div");
			videoHeader.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-videos-header');
			videoHeader.innerHTML = ptr.cardObj.artistName + " Videos";
			var videoBody = document.createElement("div");
			videoBody.setAttribute(
					((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
							: 'class'), 'dio-module-videos-body');
			this.videoBody = videoBody;

			this.contentObj.innerHTML = '';
			this.contentObj.appendChild(videoBody);

			if (this.cardObj.artistMtvnId == "") {
				var externalEmbeds = this.populateExternalEmbeds();
				if (!externalEmbeds)
					ptr.videoBody.innerHTML = "NO VIDEOS FOUND";

				this.cardObj.stageHideAll();
				this.cardObj.stageShow(this.mid);

				this.refreshScrollerButtons();

			} else {
				this.__loadData({
					url : _dsURL,
					data : _params,
					successHandler : this.processStage,
					errorHandler : this.printAjaxErrors,
					dataType : 'json'
				});
			}
		} else {
			// just hide all stages then show the clicked stage
			this.cardObj.stageHideAll();
			this.cardObj.stageShow(this.mid);
		}
	}

	if (this.targetDiv) {
		// console.log("Initializing Videos tab module");
		this.buildButton();
	}
}

Diogenes.Modules.Videos.prototype = new Diogenes();

Diogenes.Modules.Blogs = function(options) {
	var m_names = new Array("January", "February", "March", "April", "May",
			"June", "July", "August", "September", "October", "November",
			"December");
	if (options == null)
		options = {};
	var ptr = this;
	this.initialized = false;
	this.refresh = ('refresh' in options) ? options.refresh : false;
	this.cardObj = ('cardObj' in options) ? options.cardObj : null;
	this.mid = ('mid' in options) ? options.mid : null;
	this.notClickedHTML = "NEWS";
	this.clicked = false;
	this.clickedHTML = "<strong>NEWS</strong>";
	this.buttonDiv = document.createElement('span');
	this.contentObj = document.createElement('div');
	this.contentObj.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-module-blogs');
	this.dsURL = ('dsURL' in options) ? options.dsURL : '';
	this.id = ('id' in options) ? options.id : '';
	this.params = ('params' in options) ? options.params : '';
	this.type = ('type' in options) ? options.type : 'xml';
	this.targetDiv = ('targetDiv' in options) ? options.targetDiv : null;

	this.scrollTimer = 0;
	this.scrollSpeed = 15;
	this.scrollInterval = 30;
	this.blogBodyList = null;

	this.buildButton = function() {
		this.buttonDiv.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card-buttons-links');
		this.buttonDiv.innerHTML = this.notClickedHTML;
		this.buttonDiv.onmouseover = function() {
			this.style.cursor = 'pointer';
		}
		this.buttonDiv.onclick = this.toggle;
	}

	this.opening = function() {
		this.cardObj.activeTab.module.clicked = false;
		this.cardObj.activeTab.module.buttonDiv.innerHTML = this.cardObj.activeTab.module.notClickedHTML;
		this.cardObj.activeTab = null;
		this.buttonDiv.innerHTML = this.clickedHTML;
		this.clicked = true;
		this.cardObj.activeTab = this.cardObj.tabs[this.mid];
		this.loadInStage();

		this.cardObj.listenTabRemote('play');
	}

	this.closing = function() {
		this.buttonDiv.innerHTML = this.notClickedHTML;
		this.clicked = false;
	}

	this.toggle = function() { // clicking action
		if (ptr.clicked) {
			// ptr.closing();
		} else {

			// clicked on, send reporting call
			// ptr.cardObj.coda2reporting({'name':'News', 'evarName':
			// DiogenesConfig.Reporting.TabOpen._eVar,
			// 'evarValue':unescape(ptr.cardObj.artistName)});
			ptr.cardObj.coda2reporting({
				'name' : 'Tab Open',
				'evarName' : DiogenesConfig.Reporting.TabOpen._eVar,
				'evarValue' : 'News'
			});

			ptr.opening();
		}
	}

	this.stageScrollUp = function(step) {
		var bodyYPos = parseInt(this.blogBodyList.style.marginTop);

		if (bodyYPos < 0)
			this.blogBodyList.style.marginTop = (bodyYPos + this.scrollSpeed)
					+ "px";

		if (step == "step") {
		} else
			this.scrollTimer = setTimeout(this.cardObj.divId + ".tabs["
					+ this.mid + "].module.stageScrollUp()",
					this.scrollInterval);
	}

	this.stageScrollDown = function(step) {
		var bodyYPos = parseInt(this.blogBodyList.style.marginTop);

		var ss = this.scrollSpeed;
		var sh = this.contentObj.scrollHeight;
		var oh = this.contentObj.offsetHeight;
		// alert(sh);
		// alert(oh);
		// console.log(bodyYPos)
		// console.log(ss)
		// console.log(sh)
		// console.log(oh)

		// console.log(blogBodyListHeight+bodyYPos);

		var blogBodyListHeight = this.blogBodyList.scrollHeight;

		// if (this.contentObj.scrollHeight > this.contentObj.offsetHeight)
		// this.blogBodyList.style.marginTop = (bodyYPos - this.scrollSpeed) +
		// "px";
		if ((blogBodyListHeight + bodyYPos) > this.contentObj.offsetHeight)
			this.blogBodyList.style.marginTop = (bodyYPos - this.scrollSpeed)
					+ "px";

		if (step == "step") {
		} else
			this.scrollTimer = setTimeout(this.cardObj.divId + ".tabs["
					+ this.mid + "].module.stageScrollDown()",
					this.scrollInterval);
	}

	this.stageWheelScroll = function(event) {
		var delta = 0;
		if (!event)
			event = window.event;
		// normalize the delta
		if (event.wheelDelta) { // IE & Opera
			delta = event.wheelDelta / 120;
		} else if (event.detail) { // W3C
			delta = -event.detail / 3;
		}
		// console.log(delta);

		if (delta > 0)
			ptr.stageScrollUp("step");
		else
			ptr.stageScrollDown("step");

		return ptr.cancelEvent(event);
	}

	this.clearTimer = function(obj) {
		var timer = this.scrollTimer;
		clearTimeout(timer);
	}

	this.processStage = function(data) {
		ptr.initialized = true;

		var position = 0;

		var blogHeader = document.createElement("div");
		blogHeader.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-module-blogs-header');
		blogHeader.innerHTML = ptr.cardObj.artistName + " - Biography";
		var blogBody = document.createElement("div");
		blogBody.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-module-blogs-body');
		if (window.addEventListener) {
			ptr.contentObj.addEventListener('DOMMouseScroll',
					ptr.stageWheelScroll, false);
			ptr.contentObj.addEventListener('mousewheel', ptr.stageWheelScroll,
					false);
		} else {
			ptr.contentObj.onmousewheel = ptr.stageWheelScroll;
		}
		var blogBodyList = document.createElement("div");
		// blogBodyList.setAttribute(((document.all&&(Dio_IE_Ver<8.0)) ?
		// 'className' : 'class'),'dio-module-blogs-list');
		blogBodyList.style.marginTop = "0px";
		ptr.blogBodyList = blogBodyList;

		var blogColumn = document.createElement("div");
		blogColumn.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-module-blogs-column');
		var newsColumn = document.createElement("div");
		newsColumn.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-module-blogs-column');

		var blogScroller = document.createElement("div");
		blogScroller.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-module-blogs-scroller');
		var blogScrollerUp = document.createElement("div");
		blogScrollerUp.style.marginBottom = "210px";
		// blogScrollerUp.style.marginTop = "27px";
		blogScrollerUp.innerHTML = '<img src="' + diogenesServer
				+ '/sitewide/img/meter/button-scroller-up.gif" border="0" />';
		var blogScrollerDown = document.createElement("div");
		blogScrollerDown.innerHTML = '<img src="' + diogenesServer
				+ '/sitewide/img/meter/button-scroller-down.gif" border="0" />';
		blogScroller.appendChild(blogScrollerUp);
		blogScroller.appendChild(blogScrollerDown);
		blogScrollerUp.onmousedown = function() {
			ptr.stageScrollUp()
		};
		blogScrollerUp.onmouseup = function() {
			ptr.clearTimer()
		};
		blogScrollerUp.onmouseout = function() {
			ptr.clearTimer()
		};
		blogScrollerDown.onmousedown = function() {
			ptr.stageScrollDown()
		};
		blogScrollerDown.onmouseup = function() {
			ptr.clearTimer()
		}
		blogScrollerDown.onmouseout = function() {
			ptr.clearTimer()
		};

		position = 0;
		var newsColumnHeader = document.createElement('div');
		newsColumnHeader.innerHTML = '<div class="dio-module-blogs-column-header">News</div><div class="dio-module-blogs-divider"><img src="'
				+ diogenesServer
				+ '/sitewide/img/meter/spacer.gif" height="1" width="1" border="0" /></div>';

		$(data.news)
				.each(
						function() {

							var url = this.url;
							var url_regExp = /^((\w+):\/\/\/?)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#;\|]+)?([;\|])?([^\?#]+)?\??([^#]+)?#?(\w*)/;
							var parsedUrl = url_regExp.exec(url);
							var news_source = (typeof (parsedUrl[6]) == 'undefined') ? ""
									: parsedUrl[6];
							news_source = (news_source.indexOf("www.") == 0) ? news_source
									.substring(4, news_source.length)
									: news_source;
							var name = this.name;
							if (name == "")
								name = "Blog Title Missing";
							// name = ptr.truncateHTML(name, 33);
							var summary = this.summary;
							summary = summary.replace(/href=/gi,
									'target="_blank" href='); // adding
																// target="_blank"
																// to hrefs
							summary = ptr.truncateHTML(summary, 150);
							var date = this.date_posted;

							var blogEntryDiv = document.createElement("div");
							blogEntryDiv
									.setAttribute(
											((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
													: 'class'),
											'dio-module-blogs-entry');

							var nameDiv = document.createElement('div');
							nameDiv
									.setAttribute(
											((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
													: 'class'),
											'dio-module-blogs-title');
							nameDiv.innerHTML = '<a href="' + url
									+ '" target="_blank">' + name + '</a>';
							var dateDiv = document.createElement('div');
							var oNewsDate = new Date(date);
							var news_date = oNewsDate.getDate();
							var news_month = oNewsDate.getMonth();
							var news_year = oNewsDate.getFullYear();
							// dateDiv.innerHTML = '<div
							// class="dio-module-blogs-date"><a href="'+ url +'"
							// target="_blank">'+ news_source +'</a> | '+
							// m_names[news_month] + ' ' + news_date + ', ' +
							// news_year+'</div>';
							dateDiv.innerHTML = '<div class="dio-module-blogs-date">'
									+ news_source
									+ ' | '
									+ m_names[news_month]
									+ ' '
									+ news_date
									+ ', '
									+ news_year
									+ '</div>';
							var summaryDiv = document.createElement('div');
							summaryDiv.innerHTML = '<div class="dio-module-blogs-summary">'
									+ summary + '</div>';
							var divider = document.createElement('div');
							divider.innerHTML = '<div class="dio-module-blogs-divider"><img src="'
									+ diogenesServer
									+ '/sitewide/img/meter/spacer.gif" height="1" width="1" border="0" /></div>';

							blogEntryDiv.onmouseover = function() {
								// blogEntryDiv.setAttribute(((document.all&&(Dio_IE_Ver<8.0))
								// ? 'className' :
								// 'class'),'dio-module-blogs-entry-mouseover');
								// nameDiv.setAttribute(((document.all&&(Dio_IE_Ver<8.0))
								// ? 'className' :
								// 'class'),'dio-module-blogs-title-mouseover');
							}
							blogEntryDiv.onmouseout = function() {
								// blogEntryDiv.setAttribute(((document.all&&(Dio_IE_Ver<8.0))
								// ? 'className' :
								// 'class'),'dio-module-blogs-entry');
								// nameDiv.setAttribute(((document.all&&(Dio_IE_Ver<8.0))
								// ? 'className' :
								// 'class'),'dio-module-blogs-title');
							}

							// if (position!=0)
							// blogBodyList.appendChild(divider);
							if (position != 0)
								newsColumn.appendChild(divider);
							blogEntryDiv.appendChild(nameDiv);
							blogEntryDiv.appendChild(dateDiv);
							blogEntryDiv.appendChild(summaryDiv);
							// blogBodyList.appendChild(blogEntryDiv);
							newsColumn.appendChild(blogEntryDiv);

							position++;
						});

		var cleardiv = ptr.createClearDiv();

		blogBodyList.appendChild(newsColumn);
		var cleardiv2 = ptr.createClearDiv();
		blogBodyList.appendChild(cleardiv2);

		blogBody.appendChild(blogBodyList);
		blogBody.appendChild(cleardiv);

		ptr.contentObj.appendChild(blogBody);
		ptr.contentObj.appendChild(blogScroller);

		if (data.news.length == 0)
			newsColumn.innerHTML = "NO NEWS FOUND";

		// ptr.removeAllChildren(ptr.cardObj.stage);
		// ptr.cardObj.stage.appendChild(ptr.contentObj);
		ptr.cardObj.stageHideAll();
		ptr.cardObj.stageShow(ptr.mid);

		if (ptr.cardObj.activeTab.module.mid != ptr.mid) { // if tab was
															// clicked before
															// ajax is complete
			ptr.opening();
		}

	}

	this.loadInStage = function() {
		this.cardObj.stageHideAll();
		this.cardObj.showLoading();

		var _params = '';
		// var _dsURL = this.dsURL + 'meter/news/?id='+this.cardObj.artistId;
		// if (this.cardObj.mtvnUniverse) _params += "mtv=yes";
		var _dsURL = this.dsURL + 'meter/news/?id=' + this.cardObj.echoId;

		if (!this.initialized || this.refresh) {
			// not initialized, ajax to get data and load stage
			this.removeAllChildren(this.contentObj);
			this.__loadData({
				url : _dsURL,
				data : _params,
				successHandler : this.processStage,
				errorHandler : this.ajaxErrors,
				dataType : 'json'
			})
		} else {
			// just load stage with the content
			// this.removeAllChildren(this.cardObj.stage);
			// this.cardObj.stage.appendChild(this.contentObj);
			this.cardObj.stageHideAll();
			this.cardObj.stageShow(this.mid);
		}
	}

	if (this.targetDiv) {
		// console.log("Initializing Blogs tab module");
		this.buildButton();
	}
}

Diogenes.Modules.Blogs.prototype = new Diogenes();

/* tours module */
Diogenes.Modules.Tour = function(options) {
	if (options == null)
		options = {};
	var ptr = this;
	this.initialized = false;
	this.refresh = ('refresh' in options) ? options.refresh : false;
	this.cardObj = ('cardObj' in options) ? options.cardObj : null;
	this.mid = ('mid' in options) ? options.mid : null;
	this.notClickedHTML = "TOUR";
	this.clicked = false;
	this.clickedHTML = "<strong>TOUR</strong>";
	this.buttonDiv = document.createElement('span');
	this.contentObj = document.createElement('div');
	this.contentObj.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-module-tweets');
	this.dsURL = ('dsURL' in options) ? options.dsURL : '';
	this.id = ('id' in options) ? options.id : '';
	this.params = ('params' in options) ? options.params : '';
	this.type = ('type' in options) ? options.type : 'json';
	this.targetDiv = ('targetDiv' in options) ? options.targetDiv : null;

	this.scrollTimer = 0;
	this.scrollSpeed = 15;
	this.scrollInterval = 30;
	this.tourBodyList = null;
	this.tourListContainer = null;

	this.buildButton = function() {
		// console.log("build button");
		this.buttonDiv.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card-buttons-links hidden');
		this.buttonDiv.innerHTML = this.notClickedHTML;
		this.buttonDiv.onmouseover = function() {
			this.style.cursor = 'pointer';
		}
		this.buttonDiv.onclick = this.toggle;
	}

	this.opening = function() {
		this.cardObj.activeTab.module.clicked = false;
		this.cardObj.activeTab.module.buttonDiv.innerHTML = this.cardObj.activeTab.module.notClickedHTML;
		this.cardObj.activeTab = null;
		this.buttonDiv.innerHTML = this.clickedHTML;
		this.clicked = true;
		this.cardObj.activeTab = this.cardObj.tabs[this.mid];
		this.loadInStage();
		this.cardObj.listenTabRemote('play');
	}

	this.closing = function() {
		this.buttonDiv.innerHTML = this.notClickedHTML;
		this.clicked = false;
	}

	this.toggle = function() { // clicking action
		if (ptr.clicked) {
			// ptr.closing();
		} else {

			// clicked on, send reporting call
			// ptr.cardObj.coda2reporting({'name':'Tweets', 'evarName':
			// DiogenesConfig.Reporting.TabOpen._eVar,
			// 'evarValue':unescape(ptr.cardObj.artistName)});
			ptr.cardObj.coda2reporting({
				'name' : 'Tab Open',
				'evarName' : DiogenesConfig.Reporting.TabOpen._eVar,
				'evarValue' : 'Tour'
			});

			ptr.opening();
		}
	}

	this.stageScrollUp = function(step) {
		var bodyYPos = parseInt(this.tourBodyList.style.marginTop);

		if (bodyYPos < 0)
			this.tourBodyList.style.marginTop = (bodyYPos + this.scrollSpeed)
					+ "px";

		if (step == "step") {
		} else
			this.scrollTimer = setTimeout(this.cardObj.divId + ".tabs["
					+ this.mid + "].module.stageScrollUp()",
					this.scrollInterval);
	}

	this.stageScrollDown = function(step) {
		var bodyYPos = parseInt(this.tourBodyList.style.marginTop);

		if (this.tourListContainer.scrollHeight > this.tourListContainer.offsetHeight)
			this.tourBodyList.style.marginTop = (bodyYPos - this.scrollSpeed)
					+ "px";

		if (step == "step") {
		} else
			this.scrollTimer = setTimeout(this.cardObj.divId + ".tabs["
					+ this.mid + "].module.stageScrollDown()",
					this.scrollInterval);
	}

	this.stageWheelScroll = function(event) {
		var delta = 0;
		if (!event)
			event = window.event;
		// normalize the delta
		if (event.wheelDelta) { // IE & Opera
			delta = event.wheelDelta / 120;
		} else if (event.detail) { // W3C
			delta = -event.detail / 3;
		}

		if (delta > 0)
			ptr.stageScrollUp("step");
		else
			ptr.stageScrollDown("step");

		return ptr.cancelEvent(event);
	}

	this.printAjaxErrors = function(err) {
		ptr.cardObj.stageHideAll();
		ptr.cardObj.stageShow(ptr.mid);
		ptr.contentObj.innerHTML = err.statusText;
		ptr.contentObj.innerHTML += "<br/>Possibly rate limited";

		if (ptr.cardObj.activeTab.module.mid != ptr.mid) { // if tab was
															// clicked before
															// ajax is complete
			// ptr.opening();
		}
	}

	this.clearTimer = function(obj) {
		var timer = this.scrollTimer;
		clearTimeout(timer);
	}
	this.processStageJSON = function(json) {
		var position = 0;
		var tourHeader = document.createElement("div");
		tourHeader.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-module-tour-header');
		tourHeader.innerHTML = '<img src="' + diogenesServer
				+ '/sitewide/img/meter/songkick.png" border=0 >';
		var tourBody = document.createElement("div");
		tourBody.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-module-tour-body');
		if (window.addEventListener) {
			ptr.contentObj.addEventListener('DOMMouseScroll',
					ptr.stageWheelScroll, false);
			ptr.contentObj.addEventListener('mousewheel', ptr.stageWheelScroll,
					false);
		} else {
			ptr.contentObj.onmousewheel = ptr.stageWheelScroll;
		}
		ptr.tourListContainer = tourBody;
		var tourBodyList = document.createElement("div");
		tourBodyList.style.marginTop = "0px";
		ptr.tourBodyList = tourBodyList;

		var tourScroller = document.createElement("div");
		tourScroller.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-module-tweets-scroller');
		var tweetScrollerUp = document.createElement("div");
		tweetScrollerUp.style.marginBottom = "202px";
		tweetScrollerUp.innerHTML = '<img src="' + diogenesServer
				+ '/sitewide/img/meter/button-scroller-up.gif" border="0" />';
		var tweetScrollerDown = document.createElement("div");
		tweetScrollerDown.innerHTML = '<img src="' + diogenesServer
				+ '/sitewide/img/meter/button-scroller-down.gif" border="0" />';
		tourScroller.appendChild(tweetScrollerUp);
		tourScroller.appendChild(tweetScrollerDown);
		tweetScrollerUp.onmousedown = function() {
			ptr.stageScrollUp()
		};
		tweetScrollerUp.onmouseup = function() {
			ptr.clearTimer()
		};
		tweetScrollerUp.onmouseout = function() {
			ptr.clearTimer()
		};
		tweetScrollerDown.onmousedown = function() {
			ptr.stageScrollDown()
		};
		tweetScrollerDown.onmouseup = function() {
			ptr.clearTimer()
		};
		tweetScrollerDown.onmouseout = function() {
			ptr.clearTimer()
		};
		var cleardiv = ptr.createClearDiv();
		
		
		$(json.resultsPage.results.event)
				.each(
						function() {
				
							/*tour row */
							var tourRow = document.createElement("div");
							tourRow.setAttribute(
											((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
													: 'class'),
											'dio-module-tour-row');
							/* tour left container */
							var left = document.createElement('div');
							var dateC = document.createElement('h5');
							left.setAttribute(
											((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
													: 'class'),
											'dio-module-tour-row-left');
							var dateParts = this.start.date.split(/-/);
							var eventDate = new Date(dateParts[0],parseInt( dateParts[1], 10) -1,dateParts[2]);
							var weekday = new Array(7);
							weekday[0]="Sun";
							weekday[1]="Mon";
							weekday[2]="Tue";
							weekday[3]="Wed";
							weekday[4]="Thu";
							weekday[5]="Fri";
							weekday[6]="Sat";
							dateC.innerHTML = weekday[eventDate.getDay()] + ". " + (eventDate.getMonth() + 1) + "/" + (eventDate.getDay() + 1) + "/" + eventDate.getFullYear().toString().substr(2,4);
							left.appendChild(dateC);
							
							/*--------------------------------------------------------------------*/
							/*tour mid container */
							var mid = document.createElement('div');
							mid.setAttribute(
											((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
													: 'class'),
											'dio-module-tour-row-mid');
							var midTitle = document.createElement("h5"); 
							
							if (this.displayName.length > 28) {
								midTitle.innerHTML = this.displayName.substring(0, 28) + "...";
							}	else {
								midTitle.innerHTML = this.displayName
							}						
							
							var midPlace = document.createElement("p");
							midPlace.innerHTML = this.location.city;
							/*--------------------------------------------------------------------*/
							mid.appendChild(midTitle);
							mid.appendChild(midPlace);
							
							/* tour right container */
							var right = document.createElement('div');
							right.setAttribute(
											((document.all && (Dio_IE_Ver < 8.0)) ? 'className'
													: 'class'),
											'dio-module-tour-row-right');
							var buyTourTicket = document.createElement("a");
							buyTourTicket.setAttribute("href", this.uri);
							buyTourTicket.setAttribute("target", "_blank");
							buyTourTicket.setAttribute("class", "button blue");
							buyTourTicket.innerHTML = '<img src="' + diogenesServer	+ '/sitewide/img/meter/buy.gif" title="buy" alt="Buy" />';
							right.appendChild(buyTourTicket);
							/*--------------------------------------------------------------------*/
							tourRow.appendChild(left);
							tourRow.appendChild(mid);
							tourRow.appendChild(right);
							
							tourBodyList.appendChild(tourRow);

							position++;
						});

		if(typeof(json.resultsPage.results.event) == "undefined")
		{
			tourBodyList.innerHTML = "<p>There are currently no tour dates scheduled. Check back soon.</p>";
		}
			
		tourBody.appendChild(tourBodyList);
		tourBody.appendChild(cleardiv);

		ptr.contentObj.appendChild(tourHeader);
		ptr.contentObj.appendChild(tourBody);
		ptr.contentObj.appendChild(tourScroller);

		ptr.cardObj.stageHideAll();
		ptr.cardObj.stageShow(ptr.mid);

		if (ptr.cardObj.activeTab.module.mid != ptr.mid) { // if tab was
															// clicked before
															// ajax is complete
			ptr.opening();
		}

	}
	
	this.disableThis = function() {
		this.buttonDiv.style.display = 'none';

		this.buttonDiv.onclick = null;

		this.contentObj.style.display = "none";

		/*var BiosTab = this.cardObj.getTab("bio");
		if (!BiosTab.initialized) {
			if (this.cardObj.rhapId != "") // rhapsody id present, tabs will be
											// complete by the time the card
											// will switch tweets tab so use
											// .toggle
				BiosTab.toggle();
			else
				// no rhapsody id so tabs will still be generating when this
				// method is called so just set tweets tab clicked = true.
				BiosTab.clicked = true;
		}*/

	}

	this.loadInStage = function() {
		this.cardObj.stageHideAll();
		this.cardObj.showLoading();

		var aName = escape(this.cardObj.artistName.replace('%24', 's'));
		// aName = encodeURIComponent(aName); // already escaped

		var _params = '';
		var _dsURL = ptr.dsURL + 'feedproxy/?type=tweetSearch&q='
				+ escape(escape('"' + aName + '"'));

		if (!this.initialized || this.refresh) {
			// not initialized, ajax to get data and load stage
			this.removeAllChildren(this.contentObj);
			this.initialized = true;
			/* ### START get twitter keyword overrides ### */
			$
					.getJSON(
							'http://api.songkick.com/api/3.0/search/artists.json?query='+aName+'&apikey=fnoPBgBjBbi1f2jL&jsoncallback=?',
							function(data) {
								if(typeof(data.resultsPage.results.artist) == 'undefined') {
									ptr.processStageJSON(data);	
									return false;
								}
								artistId = data.resultsPage.results.artist[0].id;
								
								$.getJSON(
												'http://api.songkick.com/api/3.0/artists/'+artistId+'/calendar.json?apikey=fnoPBgBjBbi1f2jL'
														+ '&jsoncallback=?',
												function(data) {
													ptr.processStageJSON(data);										
												});

							});
		} else {
			this.cardObj.stageHideAll();
			this.cardObj.stageShow(this.mid);
		}
	}

	if (this.targetDiv) {
		this.buildButton();
	}
}

Diogenes.Modules.Tour.prototype = new Diogenes();

/* end tours module */
Diogenes.Modules.Similar = function(options) {
	if (options == null)
		options = {};
	var ptr = this;
	this.initialized = false;
	this.refresh = ('refresh' in options) ? options.refresh : false;
	this.cardObj = ('cardObj' in options) ? options.cardObj : null;
	this.mid = ('mid' in options) ? options.mid : null;
	this.notClickedHTML = "SIMILAR";
	this.clicked = false;
	this.clickedHTML = "<strong>SIMILAR</strong>";
	this.buttonDiv = document.createElement('span');
	this.contentObj = document.createElement('div');
	this.contentObj.setAttribute(
			((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
			'dio-module-similar');
	this.dsURL = ('dsURL' in options) ? options.dsURL : '';
	this.id = ('id' in options) ? options.id : '';
	this.params = ('params' in options) ? options.params : '';
	this.type = ('type' in options) ? options.type : 'xml';
	this.targetDiv = ('targetDiv' in options) ? options.targetDiv : null;

	this.buildButton = function() {
		this.buttonDiv.setAttribute(
				((document.all && (Dio_IE_Ver < 8.0)) ? 'className' : 'class'),
				'dio-card-buttons-links');
		this.buttonDiv.innerHTML = this.notClickedHTML;
		this.buttonDiv.onmouseover = function() {
			this.style.cursor = 'pointer';
		}
		this.buttonDiv.onclick = this.toggle;
	}

	this.opening = function() {
		this.cardObj.activeTab.module.clicked = false;
		this.cardObj.activeTab.module.buttonDiv.innerHTML = this.cardObj.activeTab.module.notClickedHTML;
		this.cardObj.activeTab = null;
		this.buttonDiv.innerHTML = this.clickedHTML;
		this.clicked = true;
		this.cardObj.activeTab = this.cardObj.tabs[this.mid];
		this.loadInStage();

		this.cardObj.listenTabRemote('play');
	}

	this.closing = function() {
		this.buttonDiv.innerHTML = this.notClickedHTML;
		this.clicked = false;
	}

	this.toggle = function() { // clicking action
		if (ptr.clicked) {
			// ptr.closing();
		} else {
			ptr.opening();
		}
	}

	this.processStage = function(xml) {
		ptr.initialized = true;

		// Jquery xml processing :(
		var res = $(xml).find("similar");

		$(xml).find("error").each(function() {
			ptr.initialized = false;
		});

		if (res) {
			var position = 0;
			res
					.find("artist")
					.each(
							function() {
								var found = false;
								var id = $(this).find("id").text();
								id = id.replace(ptr.ECHONEST_ID_PREFIX, "");
								var name = $(this).find("name").text();
								var rank = $(this).find("rank").text();

								var nameDiv = document.createElement('div');
								nameDiv.innerHTML = '<div class="dio-module-similar-title"><a href="'
										+ id
										+ '" target="_blank">'
										+ name
										+ '</a> RANK: ' + rank + '</div>';
								var divider = document.createElement('hr');

								if (position != 0)
									ptr.contentObj.appendChild(divider);
								ptr.contentObj.appendChild(nameDiv);

								position++;
							});

			// ptr.removeAllChildren(ptr.cardObj.stage);
			// ptr.cardObj.stage.appendChild(ptr.contentObj);
			ptr.cardObj.stageHideAll();
			ptr.cardObj.stageShow(ptr.mid);

			if (ptr.cardObj.activeTab.module.mid != ptr.mid) { // if tab was
																// clicked
																// before ajax
																// is complete
				ptr.opening();
			}
		}
	}

	this.loadInStage = function() {
		this.cardObj.stageHideAll();
		this.cardObj.showLoading();

		var _params = "type=" + this.type + "&req=" + this.simReq + "&id="
				+ this.cardObj.artistId;

		if (!this.initialized || this.refresh) {
			// not initialized, ajax to get data and load stage
			this.__loadData({
				url : this.dsURL,
				data : _params,
				successHandler : this.processStage,
				errorHandler : this.ajaxErrors,
				dataType : this.type
			})
		} else {
			// just load stage with the content
			// this.removeAllChildren(this.cardObj.stage);
			// this.cardObj.stage.appendChild(this.contentObj);
			this.cardObj.stageHideAll();
			this.cardObj.stageShow(this.mid);
		}
	}

	if (this.targetDiv) {
		this.buildButton();
	}
}

Diogenes.Modules.Similar.prototype = new Diogenes();

