/* Global JavaScript File for working with jQuery library */

	$(document).ready(function() {
	// we put the event bindings in bindBehaviors so we can call it on AJAX-loaded html scopes.
	var bindBehaviors = function(scope) {
		$("button",scope).button();
		$("#accordion",scope).accordion();
		$("#tracklist",scope).buttonset();	// clicking on a tracklist element (button) modifies the player
		$("#tracklist input",scope).click(function() {
			 var songid = $(this).attr('id');
			 $.post(CI_ROOT + 'index.php/ajax/refresh_player',
					 { 'songid':songid },
					 function(data) {
						 $("#songplayer").html(data.result);
			 }, "json");
		});
	};
	// now bind the behaviors to our whole (intial) page.
	bindBehaviors();

	// behaviors we don't want to bind to AJAX sections.
	var updateCD = function() { // send the CD identifier to AJAX to update right sidebar with CD tracks
		 var cdid = $(this).attr('id');
		 $.post(CI_ROOT + 'index.php/ajax/refresh_cd_info',
				 { 'cdid':cdid },
				 function(data) {
					 $("#cd-describe").html(data.result);
					 bindBehaviors("#cd-describe"); // activate behaviors on new html
		 }, "json");
    };
	var mouseOut = function() {};

	$(".cdimage").hover(updateCD,mouseOut);

	});


