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

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


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


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

			// artist website
			if (jsonData.speaker_detail.speaker_website != '')
			{
				htmlContent += "<li><a href=\"" + jsonData.speaker_detail.speaker_website + "\" title=\"Visit Speaker's Website\"><img src=\"" + jsonData.speaker_detail.workspace + "/assets/images/social_icons/website_16.png\" /></a></li>";
			}
			
			// artist youtube
			if (jsonData.speaker_detail.speaker_facebook != '')
			{
				htmlContent += "<li><a href=\"" + jsonData.speaker_detail.speaker_facebook + "\" title=\"Visit Speaker's Facebook\"><img src=\"" + jsonData.speaker_detail.workspace + "/assets/images/social_icons/facebook_16.png\" /></a></li>";
			}
			
			// artist myspace
			if (jsonData.speaker_detail.speaker_myspace != '')
			{
				htmlContent += "<li><a href=\"" + jsonData.speaker_detail.speaker_myspace + "\" title=\"Visit Speaker's MySpace\"><img src=\"" + jsonData.speaker_detail.workspace + "/assets/images/social_icons/myspace_16.png\" /></a></li>";
			}
			
			htmlContent += "</ul>";
			
			// the artist bio
			htmlContent += "<div class=\"speaker_bio\">";
			htmlContent += jsonData.speaker_detail.speaker_biography;
			htmlContent += "</div>";

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


