/* window.addEvent('domready', function() {
	correctPNG();
});
*/

// var mySmoothScroll = new Fx.Scroll();
// new Fx.SmoothScroll({ duration:500 }, window);

/*
if ($defined($('sendPassword'))) {
	$$('.sendPasswordButton').addEvent('click', function() {
		
		$$('.emailNotValid').setStyle('display', 'none');
		$$('.emailNotFound').setStyle('display', 'none');
		$$('.emailSent').setStyle('display', 'none');
		
		sEmail = $('sendPassword').getProperty('value').trim();
		new Ajax('/index.php?sendPassword=' + sEmail, {method: 'get', onComplete: function (sResult) {
			oResult = Json.evaluate(sResult);
			if (oResult.emailNotValid == true) {
				$$('.emailNotValid').setStyle('display', 'block');
			} else if (oResult.emailNotFound == true) {
				$$('.emailNotFound').setStyle('display', 'block');
			} else if (oResult.emailSent == true) {
				$$('.emailSent').setStyle('display', 'block');
			}
		}}).request();
	});
};
*/

if ($defined($('suggestionForm'))) {
	$$('.okbutton3 a').addEvent('click', function() {
		$('suggestionForm').submit();
	});
}

if ($defined($('loginEmail'))) {
	$$('.okbutton a').addEvent('click', function() {
		$('loginForm').submit();
	});
	$$('.signupbutton a').addEvent('click', function() {
		$('loginForm').submit();
	});
	$$('.singupregisterbutton a').addEvent('click', function() {
		$('loginForm').submit();
	});
	$$('.sendpasswordbutton a').addEvent('click', function() {
		$('loginForm').submit();
	});	
	
}

if ($defined($('headphonesIn'))) {
	window.addEvent('domready', function() {  
		$('headphonesIn').setStyle('opacity', 0);
	});
	$('searchInput').addEvent('focus', function() {
		/*
		if ($('headphonesIn').fx) $('headphonesIn').fx.stop();
		$('headphonesIn').fx = $('headphonesIn').effect('opacity', {duration: 500}).start(1);
		*/
		$('headphonesIn').fade('in'); 
	});
	$('searchInput').addEvent('blur', function() {
		$('headphonesIn').fade('out');
		/*
		if ($('headphonesIn').fx) $('headphonesIn').fx.stop();
		$('headphonesIn').fx = $('headphonesIn').effect('opacity', {duration: 500}).start(0);
		*/
	});
}

if ($defined($$('.artistcardButDelete'))) {
	$$('.artistcardButDelete').addEvent('click', function() {
		// send an Json query to remove the artist from the cookie
		var jsonRequest = new Request.JSON({url: '/index.php?removeArtist=' + this.getProperty('rel')}).get();
		
		// get containing 'artistcard' div 
		oContainDiv = this.getParent().getParent().getParent();
		
		var myFx = new Fx.Tween(oContainDiv, {property: 'opacity'});
		
		myFx.start(1,0).chain(
			function() {
		
				// get all remaining cards and place them in aTotalCards
				var aTotalCards = new Array;
				var aLeftCards = $$('#leftcolomn .artistcard');
				var aRightCards = $$('#rightcolomn .artistcard');
				var iCardCounter = 0;
				
				aLeftCards.each(function(item, index) {
					if ($defined(aLeftCards[index])) aTotalCards.include(aLeftCards[index]);
					if ($defined(aRightCards[index])) aTotalCards.include(aRightCards[index]);
				});
				
				// now that the cards are stored in aTotalCards - remove their elements from the page
				$$('.artistcard').each (function(item, index) {
					item.dispose();
				})
				
				// loop through aTotalCards and place cards in either left or right column
				aTotalCards.each(function (item, index) {
					if (item != oContainDiv) { // skip the div we've just removed
						iCardCounter++;
						if (iCardCounter % 2) {
							item.inject($('leftcolomn'));
						} else {
							item.inject($('rightcolomn'));
						}
					}
				});
			});
	});
}

if ($defined($$('.artistcardButShowAlbums'))) {
	$$('.artistcardButShowAlbums').addEvent('click', function() {
		// get containing 'artistcard' div
		oContainDiv = this.getParent().getParent().getParent();
		// get the albums container div
		oAlbumsContainerDiv = oContainDiv.getElement('.artistAlbumsContainer');
		// get the albums div
		oAlbumsDiv = oAlbumsContainerDiv.getElement('.albums');
		// get the hidden input field which contains the album type
		oAlbumsContainerDiv.getElement('.albumTypes');
		// show the "filter" buttons
		oAlbumsContainerDiv.getElement('.filters').setStyle('display', 'block');
		// display or hide the albums container div
		if (oAlbumsContainerDiv.getProperty('value') != 'albums') {
			oAlbumsContainerDiv.setStyle('display', 'none');
		}
		if (oAlbumsContainerDiv.getStyle('display') == 'block' && oAlbumsContainerDiv.getProperty('value') == 'albums') { // (normal) albums are being shown
			// update the show/hide button
			oContainDiv.getElement('.artistcardButShowAlbums .button').setProperty('src', '/templates/images/general/expand.png');
			oContainDiv.getElement('.option.artistcardButShowAlbums').set('text', ARTISTS_SHOW_ALBUMS);
			oAlbumsContainerDiv.setStyle('display', 'none');
		} else if(oAlbumsDiv.getChildren() == false || oAlbumsContainerDiv.getProperty('value') != 'albums') { // no (normal) albums yet
			// set all radio buttons in oAlbumsContainerDiv to their own unique name
			var curDate = new Date();
			var curTimeStap = curDate.getTime();
			oAlbumsContainerDiv.getElements('.albumType').setProperty('name', "radio_" + curTimeStap);
			oAlbumsContainerDiv.getElements('.albumType').removeEvents('click');
			oAlbumsContainerDiv.getElements('.albumType').addEvent('click', function() {
				// get containing 'artistcard' div
				oContainDiv = this.getParent().getParent().getParent().getParent();
				// set the value of hidden field "albumType" to that of the clicked albumtype-button, so when the "show albums" button is clicked, it will show this type of albums
				oContainDiv.getElement('.chosenAlbumType').setProperty('value', this.getProperty('value'));
				// get the albums container div
				oAlbumsContainerDiv = oContainDiv.getElement('.artistAlbumsContainer');
				// get the albums div
				oAlbumsDiv = oAlbumsContainerDiv.getElement('.albums');
				oAlbumsDiv.setStyle('display', 'none');
				prepareInsertArtistAlbums(oContainDiv, oAlbumsDiv, this.getProperty('value'));
			});
			
			// display the div with the "loading..." gif
			oContainDiv.getElement('.albumLoading').setStyle('display', 'block');
			// send an Json query to get the artist's albums
			var albumType = oContainDiv.getElement('.chosenAlbumType').getProperty('value'); // 'albums' radio button is checked by default
			prepareInsertArtistAlbums(oContainDiv, oAlbumsDiv, albumType);
			
		} else { // albums already loaded
			// update the show/hide button
			oContainDiv.getElement('.artistcardButShowAlbums .button').setProperty('src', '/templates/images/general/contract.png');
			oContainDiv.getElement('.option.artistcardButShowAlbums').set('text', ARTISTS_HIDE_ALBUMS);
			// display the artist albums
			oAlbumsContainerDiv.setStyle('display', 'block');
		}
		// set the hidden input field which contains the album type to "albums"
		oAlbumsContainerDiv.setProperty('value', 'albums');
	});
}

if ($defined($$('.artistcardBut	'))) {
	$$('.artistcardButRecent').addEvent('click', function() {
		// get containing 'artistcard' div
		oContainDiv = this.getParent().getParent().getParent();
		// get the albums container div
		oAlbumsContainerDiv = oContainDiv.getElement('.artistAlbumsContainer');
		// get the albums div
		oAlbumsDiv = oAlbumsContainerDiv.getElement('.albums');
		// get the hidden input field which contains the album type
		oAlbumsContainerDiv.getElement('.albumTypes');
		// update the show/hide button for "show albums"
		oContainDiv.getElement('.artistcardButShowAlbums .button').setProperty('src', '/templates/images/general/expand.png');
		oContainDiv.getElement('.option.artistcardButShowAlbums').set('text', 'show albums');
		// hide the "filter" buttons
		oAlbumsContainerDiv.getElement('.filters').setStyle('display', 'none');
		// display or hide the albums container div
		if (oAlbumsContainerDiv.getProperty('value') != 'recent') {
			oAlbumsContainerDiv.setStyle('display', 'none');
		}
		if (oAlbumsContainerDiv.getStyle('display') == 'block' && oAlbumsContainerDiv.getProperty('value') == 'recent') { // recent albums are being shown
			oAlbumsContainerDiv.setStyle('display', 'none');
		} else if(oAlbumsDiv.getChildren() == false || oAlbumsContainerDiv.getProperty('value') != 'recent') { // no (recent) albums yet
			// display the div with the "loading..." gif
			oContainDiv.getElement('.albumLoading').setStyle('display', 'block');
			// send an Json query to get the artist's albums
			prepareInsertArtistAlbumsRecent(oContainDiv, oAlbumsDiv, 'albums'); // 'albums' radio button is checked by default
		} else { // albums already loaded
			// display the artist albums
			oAlbumsContainerDiv.setStyle('display', 'block');
		}
		// set the hidden input field which contains the album type to "recent"
		oAlbumsContainerDiv.setProperty('value', 'recent');
	});
}

if ($defined($$('.option.whishlist'))) {
	$$('.option.whishlist').addEvent('click', function() {
		oContainDiv = this.getParent();
		
		var jsonRequest = new Request.JSON({url: '/index.php?addToWhishlist=' + this.getProperty('rel'), onComplete: function(sResult) {
			oResult = sResult;
			if (oResult.removed == true) {
				oContainDiv.remove();
			}
		}}).get();
	});
}

if ($defined($$('.option.notify'))) {
	$$('.option.notify').addEvent('click', function() {
		$$('.okbutton').setStyle('display', 'block');
	});
}

if ($defined($$('.option.notify.submit'))) {
	$$('.option.notify.submit').addEvent('click', function() {
		$('form_notify').submit();
	});
}

if ($defined($$('.option.notifyAlbumType.submit'))) {
	$$('.option.notifyAlbumType.submit').addEvent('click', function() {
		$('form_notify_albumType').submit();
	});
}

if ($defined($$('.option.addLastFmArtists.submit'))) {
	$$('.option.addLastFmArtists.submit').addEvent('click', function() {
		$('form_add_lastFM_artists').submit();
	});
}

if ($defined($$('.option.addLastFmArtistsDropdown.submit'))) {
	$$('.option.addLastFmArtistsDropdown.submit').addEvent('click', function() {
		$('form_add_lastFM_artists_dropdown').submit();
	});
}

if ($defined($$('.option.updatePassword.submit'))) {
	$$('.option.updatePassword.submit').addEvent('click', function() {
		$('form_update_password').submit();
	});
}

if ($defined($$('.option.createLinkToArtist.submit'))) {
	$$('.option.createLinkToArtist.submit').addEvent('click', function() {
		$('form_create_link_to_artist').submit();
	});
}


if ($defined($$('.option.whishlist'))) {
	$$('.option.whishlist').addEvent('click', function() {
		oContainDiv = this.getParent();
		var jsonRequest = new Request.JSON({url: '/index.php?addToWhishlist=' + this.getProperty('rel'), onComplete: function(sResult) {
			oResult = sResult;
			if (oResult.removed == true) {
				oContainDiv.remove();
			}
		}}).get();
	});
}


function prepareInsertArtistAlbums(oContainDiv, oAlbumsDiv, albumType) {
	// hide the no-albums div
	oContainDiv.getElement('.albumNoAlbums').setStyle('display', 'none');
	oContainDiv.getElement('.albumNoAlbumsRecent').setStyle('display', 'none');
	// display the div with the "loading..." gif
	oContainDiv.getElement('.albumLoading').setStyle('display', 'block');
	// send an Json query to get the artist's albums
	var jsonRequest = new Request.JSON({url: '/index.php?getArtistAlbums=' + oContainDiv.getElement('.artistcardButShowAlbums').getProperty('rel') + '&albumType=' + albumType, onComplete: function(sResult) {
		oAlbumsDiv.empty();
		oAlbums = sResult;
		// hide the div with the "loading..." gif
		oContainDiv.getElement('.albumLoading').setStyle('display', 'none');
		
		if ($defined(oAlbums.noAlbums)) {
			// display the no-albums div
			// oContainDiv.getElement('.albumNoAlbums').fade('in');
			oContainDiv.getElement('.albumNoAlbums').setStyle('display', 'block');
			// display the artist albums
			oAlbumsDiv.setStyle('display', 'none');
		} else if ($defined(oAlbums.aAlbum)) {
			
			oAlbums.aAlbum.each(function(aAlbum, index){
				iId					= aAlbum['id'];
				sAlbumName			= Utf8.decode(aAlbum['album']);
				sFirstReleaseDate	= aAlbum['firstreleasedate'];
				sThumbUrl			= aAlbum['thumb'];
				sWhishlist			= aAlbum['whishlist'];
				sAsin				= aAlbum['asin'];
				
				if (sFirstReleaseDate == false) sFirstReleaseDate = '';
				
				// get the albums template
				oArtistAlbumTemplate = $('artistalbum-hidden').clone();
				// insert the albumname
				oArtistAlbumTemplate.getElement('.albumName').appendText(sAlbumName);
				// insert the release date
				oArtistAlbumTemplate.getElement('.releaseDate').appendText(sFirstReleaseDate);
				// insert the link to order at iTunes
				oArtistAlbumTemplate.getElement('.orderItunes').setProperty('href', oArtistAlbumTemplate.getElement('.orderItunes').getProperty('href')+iId);
				
				if ($defined(sAsin) == false || sAsin.length == 0) {
					oArtistAlbumTemplate.getElement('.orderAmazon').setStyle('display', 'none');
				} else {
					oArtistAlbumTemplate.getElement('.orderAmazon').setProperty('href', oArtistAlbumTemplate.getElement('.orderAmazon').getProperty('href')+iId);
				}
				
				// insert the link to order at Zanox
				
				if ($defined(oArtistAlbumTemplate.getElement('.orderZanox'))) {
					oArtistAlbumTemplate.getElement('.orderZanox').setProperty('href', oArtistAlbumTemplate.getElement('.orderZanox').getProperty('href')+iId);
				}
				
				
				// insert the thumbnail
				oArtistAlbumTemplate.getElement('.albumThumb').setProperty('src', sThumbUrl);
				oArtistAlbumTemplate.getElement('.albumThumb').setProperty('id', 'thumb'+iId);
				if (sThumbUrl == '') {
					oArtistAlbumTemplate.getElement('.albumThumb').setProperty('src', '/templates/images/general/coverload.gif');
					// there is no thumb (yet) - get it from Last.fm
					var jsonRequest = new Request.JSON({url: '/index.php?getArtistAlbumThumb=' + iId, onComplete: function(sResult) {
						oThumb = sResult;
						if ($defined(oThumb.thumb) && oThumb.thumb != '') {
							$('thumb'+oThumb.id).setProperty('src', oThumb.thumb);
						} else {
							$('thumb'+oThumb.id).setProperty('src', '/templates/images/general/nocover.png');
						}
					}}).get();
				}
				// 
				// set the rel tags for the "show artist" and "add to cart" buttons
				oArtistAlbumTemplate.getElements('.showTracks').setProperty('rel', iId);
				oArtistAlbumTemplate.getElements('.addToWhishlist').setProperty('rel', iId);
				
				oArtistAlbumTemplate.getElements('.option.addToWhishlist').set('text', sWhishlist)
				
				oArtistAlbumTemplate.getElements('.showTracks').addEvent('click', function() {
					showTracks(this, this.getProperty('rel'));
				});
				
				oArtistAlbumTemplate.getElements('.addToWhishlist').addEvent('click', function() {
					addToWhishlist(this, this.getProperty('rel'));
				});
				
				// insert the album
				oArtistAlbumTemplate.inject(oAlbumsDiv);
			});
			oAlbumsDiv.getElements('.artistalbum-hidden').each(function(item) {
				item.setStyle('display', 'block');
			});
			// display the artist albums
			oAlbumsDiv.setStyle('display', 'block');
		}
		oAlbumsContainerDiv.setStyle('display', 'block');
		// update the show/hide button
		oContainDiv.getElement('.artistcardButShowAlbums .button').setProperty('src', '/templates/images/general/contract.png');
		oContainDiv.getElement('.option.artistcardButShowAlbums').set('text', ARTISTS_HIDE_ALBUMS);
	}}).get();
}

function prepareInsertArtistAlbumsRecent(oContainDiv, oAlbumsDiv, albumType) {
	// hide the no-albums div
	oContainDiv.getElement('.albumNoAlbums').setStyle('display', 'none');
	oContainDiv.getElement('.albumNoAlbumsRecent').setStyle('display', 'none');
	// display the div with the "loading..." gif
	oContainDiv.getElement('.albumLoading').setStyle('display', 'block');
	// send an Json query to get the artist's albums
	var jsonRequest = new Request.JSON({url: '/index.php?getArtistAlbumsRecent=' + oContainDiv.getElement('.artistcardButShowAlbums').getProperty('rel'), onComplete: function(sResult) {
		oAlbumsDiv.empty();
		oAlbums = sResult;
		// hide the div with the "loading..." gif
		oContainDiv.getElement('.albumLoading').setStyle('display', 'none');
		
		if ($defined(oAlbums.noAlbums)) {
			// display the no-albums div
			// oContainDiv.getElement('.albumNoAlbumsRecent').fade('in');
			oContainDiv.getElement('.albumNoAlbumsRecent').setStyle('display', 'block');
			
		} else if ($defined(oAlbums.aAlbum)) {
			
			oAlbums.aAlbum.each(function(aAlbum, index){
				iId					= aAlbum['id'];
				sAlbumName			= aAlbum['album'];
				sFirstReleaseDate	= aAlbum['firstreleasedate'];
				sThumbUrl			= aAlbum['thumb'];
				sWhishlist			= aAlbum['whishlist'];
				
				// get the albums template
				oArtistAlbumTemplate = $('artistalbum-hidden').clone();
				// insert the albumname
				oArtistAlbumTemplate.getElement('.albumName').appendText(sAlbumName);
				// insert the releasedate
				oArtistAlbumTemplate.getElement('.releaseDate').appendText(sFirstReleaseDate);
				// insert the link to order at iTunes
				oArtistAlbumTemplate.getElement('.orderItunes').setProperty('href', oArtistAlbumTemplate.getElement('.orderItunes').getProperty('href')+iId);
				// insert the thumbnail
				oArtistAlbumTemplate.getElement('.albumThumb').setProperty('src', sThumbUrl);
				oArtistAlbumTemplate.getElement('.albumThumb').setProperty('id', 'thumb'+iId);
				if (sThumbUrl == '') {
					oArtistAlbumTemplate.getElement('.albumThumb').setProperty('src', '/templates/images/general/coverload.gif');
					// there is no thumb (yet) - get it from Last.fm
					var jsonRequest = new Request.JSON({url: '/index.php?getArtistAlbumThumb=' + iId, onComplete: function(sResult) {
						oThumb = Json.evaluate(sResult);
						if ($defined(oThumb.thumb) && oThumb.thumb != '') {
							$('thumb'+oThumb.id).setProperty('src', oThumb.thumb);
						} else {
							$('thumb'+oThumb.id).setProperty('src', '/templates/images/general/nocover.png');
						}
					}}).get();
				}
				// 
				// set the rel tags for the "show artist" and "add to cart" buttons
				oArtistAlbumTemplate.getElements('.showTracks').setProperty('rel', iId);
				oArtistAlbumTemplate.getElements('.addToWhishlist').setProperty('rel', iId);
				
				oArtistAlbumTemplate.getElements('.option.addToWhishlist').set('text', sWhishlist)
				
				oArtistAlbumTemplate.getElements('.showTracks').addEvent('click', function() {
					showTracks(this, this.getProperty('rel'));
				});
				
				oArtistAlbumTemplate.getElements('.addToWhishlist').addEvent('click', function() {
					addToWhishlist(this, this.getProperty('rel'));
				});
				
				// insert the album
				oArtistAlbumTemplate.inject(oAlbumsDiv);
			});
			oAlbumsDiv.getElements('.artistalbum-hidden').each(function(item) {
				item.setStyle('display', 'block');
			});
			// display the artist albums
			oAlbumsDiv.setStyle('display', 'block');
			oAlbumsContainerDiv.setStyle('display', 'block');
		}
	}}).get();
}


function showTracks (el, albumId) {
	oArtistAlbumTemplate = el.getParent().getParent().getParent().getParent().getParent();
	oTracksContainer = oArtistAlbumTemplate.getElement('.tracksContainer');
	
	if (oTracksContainer.getStyle('display') == 'block') { // tracks are being shown
		// update the show/hide button
		oArtistAlbumTemplate.getElement('.showTracks .button').setProperty('src', '/templates/images/general/expand.png');
		oArtistAlbumTemplate.getElement('.option.showTracks').set('text', ARTISTS_SHOW_TRACKS);
		// display the tracks
		oTracksContainer.setStyle('display', 'none');
	} else if(oTracksContainer.getChildren() == false) { // no tracks yet
		var jsonRequest = new Request.JSON({url: '/index.php?getArtistTracks=' + albumId, onComplete: function(sResult) {
			
			// oTracks = Json.evaluate(sResult);
			oTracks = sResult;
			// oTracksContainer.empty();
			
			if ($defined(oTracks.noTracks)) {
		
				// no tracks found
			} else {
				// loop thrugh the tracks
				oTracks.aTrack.each(function(aTrack, index) {
					// get the tracks template
					oArtistTrackTemplate = $('artisttrack-hidden').clone();
					oArtistTrackTemplate.getElement('.tracknumber').set('text', aTrack['number']);
					oArtistTrackTemplate.getElement('.track').set('text', Utf8.decode(aTrack['name']));
					oArtistTrackTemplate.getElement('.duration').set('text', aTrack['duration']);
					oArtistTrackTemplate.inject(oTracksContainer);
					oArtistTrackTemplate.getElement('.control .play').setProperty('rel', aTrack['id']);
				});
				
				var jsonRequest = new Request.JSON({url: '/index.php?iTunesAlbum=' + oTracks.albumId, onComplete: function(sResult) {
					// oAlbum = Json.evaluate(sResult);
					oAlbum = sResult;
					if (oAlbum.albumFound == false) {
						oTracksContainer.getElements('.control .play').setStyle('display', 'none');
					} else {
						oTracksContainer.getElements('.control .play').setStyle('display', 'inline');
			
						oTracksContainer.getElements('.control .play').addEvent('click', function() {
							if (haveqt == false) {
								// the browser supports quicktime
								alert('Your browser needs to support Quicktime to play track samples.\n\nPlease go to http://www.quicktime.com.');
								return false;
							}
							// set all other active "stop" buttons to "play"
							document.getElements('.control .stop').each(function(el) {
								if (el.getStyle('display') == 'inline') {
									el.setStyle('display', 'none');
									oContainCell = el.getParent();
									oContainCell.getElement('.play').setStyle('display', 'inline');
								}
							});
							// set all other active "loading" buttons to "play"
							document.getElements('.control .loading').each(function(el) {
								if (el.getStyle('display') == 'inline') {
									el.setStyle('display', 'none');
									oContainCell = el.getParent();
									oContainCell.getElement('.play').setStyle('display', 'inline');
								}
							});
						
							oContainCell = this.getParent();
							this.setStyle('display', 'none');
							oContainCell.getElement('.loading').setStyle('display', 'inline');
							
							var jsonRequest = new Request.JSON({url: '/index.php?trackMp3=' + this.getProperty('rel'), onComplete: function(sResult) {
								oResult = sResult;
								oContainCell.getElement('.loading').setStyle('display', 'none');
								if (oResult.mp3Found == false) {
									oContainCell.getElement('.noMp3Found').setStyle('display', 'inline');	
								} else {
									document.movie1.SetURL(oResult.mp3Url);
									// document.movie1.Play();
									
									oContainCell.getElement('.stop').setStyle('display', 'inline');
									oContainCell.getElement('.stop').addEvent('click', function() {
										stopMovie();
										oContainCell.getElement('.stop').setStyle('display', 'none');
										oContainCell.getElement('.play').setStyle('display', 'inline');
									});
									
								}
							}}).get();
						});
				}}}).get();
			}
			// update the show/hide button
			oArtistAlbumTemplate.getElement('.showTracks .button').setProperty('src', '/templates/images/general/contract.png');
			oArtistAlbumTemplate.getElement('.option.showTracks').set('text', ARTISTS_HIDE_TRACKS);
			// show the tracks
			oTracksContainer.setStyle('display', 'block');
		}}).get();	
	} else { // tracks already loaded
		// update the show/hide button
		oArtistAlbumTemplate.getElement('.showTracks .button').setProperty('src', '/templates/images/general/contract.png');
		oArtistAlbumTemplate.getElement('.option.showTracks').set('text', ARTISTS_HIDE_TRACKS);
		oTracksContainer.setStyle('display', 'block');
	}	
}

function addToWhishlist(el, albumId) {
	oAlbumInfo = el.getParent();
	var jsonRequest = new Request.JSON({url: '/index.php?addToWhishlist=' + albumId}).get();
}

function addedToWhishlist(sResult) {
	oResult = Json.evaluate(sResult);
	
	oImg = oAlbumInfo.getElement('.image.addToWhishlist img');
	oLink = oAlbumInfo.getElement('.option.addToWhishlist');
	
	oLink.set('text', oResult.linkText);
	
}


function unhide(divId) {
	if ($(divId).getStyle('display') != 'block') {
		$(divId).setStyle('display', 'block');
	} else {
		$(divId).setStyle('display', 'none');
	}
}

function stopMovie()
{
	document.movie1.Stop();
}

/**
*
*  UTF-8 data encode / decode
*  http://www.webtoolkit.info/
*
**/


var Utf8 = {
 
	// public method for url encoding
	encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	// public method for url decoding
	decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}