try{
//FF Prototype for IE's contains() method//
HTMLElement.prototype.contains = function(node) {
	if (node == null)
		return false;
	if (node == this)
		return true;
	else
		return this.contains(node.parentNode);
}
}catch(E){ /*IE*/ }
//
//Detect IE5.5+
var isIE = false;
var ieVersion = 0

if (navigator.appVersion.indexOf("MSIE")!=-1){
temp=navigator.appVersion.split("MSIE")
ieVersion=parseFloat(temp[1])
}

if (ieVersion >= 5.5 ) //NON IE browser will return 0
	isIE = true;

var _displayTimer = false;
	
var fp;
//var _currentArtists = 'artistsPop';
//var _currentArtistsString = 'Pop';
var _isShowing = false;
var _timer;
var _timeout = 300;
var _ply = new Image();
	_ply.src = 'http://cdn.finetune.com/images/hp/ft_play.png';
	  
function fadeIn( type, index,  display, parent, flashplayerref, userguid) {
	fp = flashplayerref;
	_timer = setTimeout('doFadeIn(\''+type+'\',\''+index+'\', \''+display+'\', \''+parent+'\',\''+userguid+'\');', _timeout);
}

function doFadeIn( type, index,  display, parent, userguid ){
	if( type == 'artist' ){
		switch( _currentArtists ){

				case 'artistsPop' : {
					document.getElementById( display ).innerHTML = '<div id="curr'+display+'" class="fadeInText"><div class="featuredArtistTitle">' + selectedPop[index]['artistName'] + '</div><br /><div class="featuredArtistBio">'+selectedPop[index]['bio'] + '</div></div>';
					break;
				}
				case 'artistsRock' : {
					document.getElementById( display ).innerHTML = '<div id="curr'+display+'" class="fadeInText"><div class="featuredArtistTitle">' + selectedRock[index]['artistName'] + '</div><br /><div class="featuredArtistBio">'+selectedRock[index]['bio'] + '</div></div>';
					break;
				}
				case 'artistsAlt' : {
					document.getElementById( display ).innerHTML = '<div id="curr'+display+'" class="fadeInText"><div class="featuredArtistTitle">' + selectedAlt[index]['artistName'] + '</div><br /><div class="featuredArtistBio">'+selectedAlt[index]['bio'] + '</div></div>';
					break;
				}
				case 'artistsHipHop' : {
					document.getElementById( display ).innerHTML = '<div id="curr'+display+'" class="fadeInText"><div class="featuredArtistTitle">' + selectedHipHop[index]['artistName'] + '</div><br /><div class="featuredArtistBio">'+selectedHipHop[index]['bio'] + '</div></div>';
					break;
				}
				case 'artistsJazz' : {
					document.getElementById( display ).innerHTML = '<div id="curr'+display+'" class="fadeInText"><div class="featuredArtistTitle">' + selectedJazz[index]['artistName'] + '</div><br /><div class="featuredArtistBio">'+selectedJazz[index]['bio'] + '</div></div>';
					break;
				}
				case 'artistsRandb' : {
					document.getElementById( display ).innerHTML = '<div id="curr'+display+'" class="fadeInText"><div class="featuredArtistTitle">' + selectedRandB[index]['artistName'] + '</div><br /><div class="featuredArtistBio">'+selectedRandB[index]['bio'] + '</div></div>';
					break;
				}
				case 'artistsCountry' : {
					document.getElementById( display ).innerHTML = '<div id="curr'+display+'" class="fadeInText"><div class="featuredArtistTitle">' + selectedCountry[index]['artistName'] + '</div><br /><div class="featuredArtistBio">'+selectedCountry[index]['bio'] + '</div></div>';
					break;
				}

			}
		}else{
			document.getElementById( display ).innerHTML = '<div id="curr'+display+'"><div class="featuredArtistTitle">'+ selectedPlaylists[index][1] +'</div><div class="featuredArtistBio">'+  selectedPlaylists[index][3] +' </div><br /></div>';
		}
	
	createPlayButton( type, index, display, parent, userguid );
	Effect.Appear( display );
//	Effect.Fade( display + 'Default' );
	_isShowing = true;
}	

function cancel(display){
	clearTimeout(_timer);

}

function startDisplayTimer(){
	if( !_displayTimer ){
		//alert('initialized');
		_displayTimer = setInterval('checkDefaultStates();', 200);
	}
}

function checkDefaultStates(){
/*
	if( !_isShowing && document.getElementById('artistDataDefault') && document.getElementById('playlistDataDefault')){
		if( document.getElementById('artistDataDefault').style.display == 'none' )
			Effect.Appear('artistDataDefault')
	//	if( document.getElementById('playlistDataDefault').style.display == 'none' )
		//	Effect.Appear('playlistDataDefault')
	}a  */
}


function fadeOut( display, obj, event ) {
	if( document.getElementById('featuredPlayButton') ){
		if (!obj.contains(event.relatedTarget || event.toElement)) {
			Effect.Appear( display+'Default' );
			Effect.Fade( display );
			new Effect.Fade('featuredPlayButton', { afterFinish: function(){ _isShowing = false; } } );
		}
	}
	
}

function createPlayButton( type, index, display, parent, flashplayerref, userguid ){
	
	if( document.getElementById('featuredPlayButton') )
		document.getElementById('featuredPlayButton').parentNode.removeChild(document.getElementById('featuredPlayButton'));
				
	var playButton = document.createElement('div');
		  playButton.className = "play";
		  playButton.id = "featuredPlayButton";
		  playButton.style.cssText = "display:none;";

	var inner = document.createElement('div');
		  inner.style.cssText = 'position: absolute; top: 12px; left: 12px;';
	
	var a = document.createElement('a');
		  a.href = "#";
		
		if( type == 'artist' ){
			switch( _currentArtists ){
				case 'artistsPop' : {
					a.onclick = function(){  fp.loadPlaylist(type.charAt(0)+selectedPop[index]['artistId'], userguid, '');  window.parent.gotoArtist(selectedPop[index]['artistId']); return false;  }; break;
				}
				case 'artistsRock' : {
					a.onclick = function(){  fp.loadPlaylist(type.charAt(0)+selectedRock[index]['artistId'], userguid, '');  window.parent.gotoArtist(selectedRock[index]['artistId']); return false;  }; break;
				}
				case 'artistsAlt' : {
					a.onclick = function(){  fp.loadPlaylist(type.charAt(0)+selectedAlt[index]['artistId'], userguid, '');  window.parent.gotoArtist(selectedAlt[index]['artistId']); return false;  }; break;
				}
				case 'artistsHipHop' : {
					a.onclick = function(){  fp.loadPlaylist(type.charAt(0)+selectedHipHop[index]['artistId'], userguid, ''); window.parent.gotoArtist(selectedHipHop[index]['artistId']);  return false;  }; break;
				}
				case 'artistsJazz' : {
					a.onclick = function(){  fp.loadPlaylist(type.charAt(0)+selectedJazz[index]['artistId'], userguid, ''); window.parent.gotoArtist(selectedJazz[index]['artistId']);  return false;  }; break;
				}
				case 'artistsRandb' : {
					a.onclick = function(){  fp.loadPlaylist(type.charAt(0)+selectedRandB[index]['artistId'], userguid, ''); window.parent.gotoArtist(selectedRandB[index]['artistId']); return false;  }; break;
				}
				case 'artistsCountry' : {
					a.onclick = function(){  fp.loadPlaylist(type.charAt(0)+selectedCountry[index]['artistId'], userguid, ''); window.parent.gotoArtist(selectedCountry[index]['artistId']);  return false;  }; break;
				}
			}
			
			if (top.user.isReg != 'Y') { 
					a.onclick = function(){ top.setContentFrame("content/reg_catch.php");
					return; };
			}
		
		} else {
			a.onclick = function(){ window.parent.gotoAlbum(selectedPlaylists[index][2]); return false; };
		}
		

		
	var graphic = document.createElement('img');
		 graphic.style.cssText = '';
		
		 if( isIE ){
			graphic.src = 'http://cdn.finetune.com/images/1by1.gif';
			graphic.style.cssText += 'width: 30px; height: 31px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+_ply.src+'\', sizingMethod=\'scale\'); behavior: url(\'pngbehavior.htc\'); }';
			if( type == 'artist' ){
				a.appendChild(graphic);
				inner.appendChild(a);
				playButton.appendChild(inner);
				document.getElementById(parent).appendChild( playButton );
			}else{
				a.appendChild(playButton);
				document.getElementById(parent).appendChild( a );
			}
		 }else{
			graphic.src = _ply.src;
			if( type == 'artist' ){
				inner.appendChild(graphic);
				playButton.appendChild(inner);
			}
			a.appendChild(playButton);
			document.getElementById(parent).appendChild( a );
		 }
		
		
		Effect.Appear( 'featuredPlayButton' );

}

function switchArtistCategory( type ){
	if( 'artists' + type != _currentArtists ){
		artCat = type.toLowerCase();
		dotCat = artCat;
		var popGDot = "off";
		var rockGDot = "off";
		var altGDot = "off";
		var countryGDot = "off";
		var hiphopGDot = "off";
		var jazzGDot = "off";
		var rbGDot = "off";

		if (artCat == "alt") {
			artCat = "alternative";
			dotCat = "alternative";
			altGDot = "on";
		}
		if (artCat == "randb") {
			artCat = "r & b / soul";
			dotCat = "rb";
			rbGDot = "on";
		}
		if (artCat == "hiphop") {
			artCat = "hip hop / rap";
			dotCat = "hiphop";
			hiphopGDot = "on";
		}
		switch (artCat) {
			case "rock" :
			 rockGDot = "on";
			 break;
			case "pop" :
			 popGDot = "on";
			 break;
			case "country" :
			 countryGDot = "on";
			 break;
			case "jazz" :
			 jazzGDot = "on";
			break;
			default:
			 break;
		}
		document.getElementById("popGDot").style.background= "url('/images/genre_" + popGDot + ".png') no-repeat";
		document.getElementById("rockGDot").style.background= "url('/images/genre_" + rockGDot + ".png') no-repeat";
		document.getElementById("altGDot").style.background= "url('/images/genre_" + altGDot + ".png') no-repeat";
		document.getElementById("countryGDot").style.background= "url('/images/genre_" + countryGDot + ".png') no-repeat";
		document.getElementById("hiphopGDot").style.background= "url('/images/genre_" + hiphopGDot + ".png') no-repeat";
		document.getElementById("jazzGDot").style.background= "url('/images/genre_" + jazzGDot + ".png') no-repeat";
		document.getElementById("rbGDot").style.background= "url('/images/genre_" + rbGDot + ".png') no-repeat";

		aId = dotCat + "Dot";
		selectLink( type );
		document.getElementById("artTitle").innerHTML="featured " + artCat;
		//document.getElementById("genreDots").innerHTML="<img src=\"/images/genre_" + dotCat + ".png\">";
		




	
		 document.getElementById("popDot").style.visibility = "hidden";
 		 document.getElementById("hiphopDot").style.visibility = "hidden";
		 document.getElementById("rockDot").style.visibility = "hidden";
		 document.getElementById("alternativeDot").style.visibility = "hidden";
		 document.getElementById("jazzDot").style.visibility = "hidden";
		 document.getElementById("rbDot").style.visibility = "hidden";
		 document.getElementById("countryDot").style.visibility = "hidden";

		document.getElementById(aId).style.visibility = "visible";		


		Effect.Appear('artists'+type);
		Effect.Fade(_currentArtists);
		_currentArtists = 'artists' + type;
	
	}
	return false;
}

function selectLink( link ){
	var previous = _currentArtists.replace('artists', '');
	var previousStr = '';
	var linkStr = '';
	
	switch( link ){
		case 'Randb': linkStr = 'R & B / SOUL'; break;
		case 'Alt':	linkStr = 'ALTERNATIVE'; break;
		case 'HipHop': linkStr = 'HIP HOP / RAP'; break;
		default: linkStr = link; break;
	}
	switch( previous ){
		case 'Randb': previousStr = 'R & B / SOUL'; break;
		case 'Alt':	previousStr = 'ALTERNATIVE'; break;
		case 'HipHop': previousStr = 'HIP HOP / RAP'; break;
		default: previousStr = previous; break;
	}
	
		
	document.getElementById(link+'Link').innerHTML = '<span class="selectedWhite" style="font-size: .7em;">'+linkStr.toUpperCase()+'</span>';
	
	document.getElementById(previous+'Link').innerHTML = '<a class="smallBlueLink" href="#" onClick="switchArtistCategory(\''+previous+'\'); return false;">'+previousStr.toUpperCase()+'</a>';

	
	return false;
}

