/**
 * artists.js - artists specific javascript
 *
*/

/**
 * resizes the tabs on-screen
 *
 * @return void
 * @author Tim Cromwell
 **/
$(document).ready(function () 
{
    resizeTabs("#artist_tabs");
});



/**
 * skips to a genre on-screen
 *
 * @param element element contains the value to skip to
 * @return void
 * @author Tim Cromwell
 **/
function skipToGenre(element)
{
	window.location.hash = element.value;
}


/**
 * ascertains details for the provided artist and displays the information in a modal window
 *
 * @return void
 * @param int artistID the artist id
 * @author Tim Cromwell
 **/
function displayArtist(artistID)
{
	// get the artist details via ajax
	$.get("/ajax-data/?artist-id=" + artistID, 
		function(data) 
		{
			var jsonData = eval('(' + data.replace(/\n/g, '') + ')');
						
			// create the html content
			var htmlContent = "<h2 class=\"modal_title\">" + jsonData.artist_detail.artist_name + "</h2>";
			
			// if there is an image, output it
			if (jsonData.artist_detail.artist_large_photo.photo_filename != '')
			{
				var photoSrc = jsonData.artist_detail.workspace + jsonData.artist_detail.artist_large_photo.photo_path + "/" + jsonData.artist_detail.artist_large_photo.photo_filename;
				htmlContent += "<img class=\"artist_img\" src=\"" + photoSrc + "\" />";
			}
			
			// output the artist details
			htmlContent += "<ul class=\"artist_links\">";

			// artist website
			if (jsonData.artist_detail.artist_website != '')
			{
				htmlContent += "<li><a href=\"" + jsonData.artist_detail.artist_website + "\" title=\"Visit Artist's Website\"><img src=\"" + jsonData.artist_detail.workspace + "/assets/images/social_icons/website_16.png\" /></a></li>";
			}
			
			// artist youtube
			if (jsonData.artist_detail.artist_youtube != '')
			{
				htmlContent += "<li><a href=\"" + jsonData.artist_detail.artist_youtube + "\" title=\"Visit Artist's Youtube\"><img src=\"" + jsonData.artist_detail.workspace + "/assets/images/social_icons/youtube_16.png\" /></a></li>";
			}
			
			// artist myspace
			if (jsonData.artist_detail.artist_myspace != '')
			{
				htmlContent += "<li><a href=\"" + jsonData.artist_detail.artist_myspace + "\" title=\"Visit Artist's MySpace\"><img src=\"" + jsonData.artist_detail.workspace + "/assets/images/social_icons/myspace_16.png\" /></a></li>";
			}
			
			htmlContent += "</ul>";
			
			// the artist bio
			htmlContent += "<div class=\"artist_bio\">";
			htmlContent += jsonData.artist_detail.artist_biography;
			htmlContent += "</div>";

			// insert the content into the popup
			$('div#modal_window_dynamic_content').html(htmlContent);
			
			// display the popup
			showModalWindow();
		}
	);
}


