jQuery.noConflict(); 
(function($) {

$(function(){

  if ($('#item').length) { // implies *not* zero
    var item = document.getElementById("item").value;
  } else {
    var item = null;
  }
  
var succes = document.getElementById("succes_var").value;
var saved = document.getElementById("saved_var").value;
var added_fav = document.getElementById("added_fav_var").value;
var removed_fav = document.getElementById("removed_fav_var").value;
var featured = document.getElementById("featured_var").value;
var not_featured = document.getElementById("not_featured_var").value;
var rated = document.getElementById("rated_var").value;
var subscribed = document.getElementById("subscribed_var").value;
var unsubscribed = document.getElementById("unsubscribed_var").value;
var submitted = document.getElementById("submitted_var").value;
var removed = document.getElementById("removed_var").value;
var playlist_created = document.getElementById("playlist_created_var").value;
var album_created = document.getElementById("album_created_var").value;
var edited = document.getElementById("edited_var").value;
var reported = document.getElementById("reported_var").value;
var added_to_playlist = document.getElementById("added_to_playlist_var").value;
var added_to_profile = document.getElementById("added_to_profile_var").value;
var no_artist_var = document.getElementById("no_artist_var").value;
var no_title_var = document.getElementById("no_title_var").value;
var no_genre_var = document.getElementById("no_genre_var").value;
var no_file_var = document.getElementById("no_file_var").value;
var no_description_var = document.getElementById("no_description_var").value;
var no_tags_var = document.getElementById("no_tags_var").value;

$('.add_favorite_jsmusic').live('click', function() {
    var parent = $(this);
    parent.html("<img src=components/com_jsmusic/images/spinner.gif>");    
	$.ajax({
		type: "POST",
		data: "action=add_favorite_jsmusic&item="+item+"&id="+ $(this).attr('id'),
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			parent.html(msg);
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+added_fav+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);		
						return false;
    }
  });
  $(this).removeClass("add_favorite_jsmusic").addClass("remove_favorite_jsmusic");
});

$('.remove_favorite_jsmusic').live('click', function() {
    var parent = $(this);
    parent.html("<img src=components/com_jsmusic/images/spinner.gif>");    
	$.ajax({
		type: "POST",
		data: "action=remove_favorite_jsmusic&item="+item+"&id="+ $(this).attr('id'),
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			parent.html(msg);
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+removed_fav+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);		
						return false;
    }
  });
  $(this).removeClass("remove_favorite_jsmusic").addClass("add_favorite_jsmusic");
});


$('.make_featured_jsmusic').live('click', function() {
    var parent = $(this);
    parent.html("<img src=components/com_jsmusic/images/spinner.gif>");    
	$.ajax({
		type: "POST",
		data: "action=make_featured_jsmusic&item="+item+"&id="+ $(this).attr('id'),
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			parent.html(msg);
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+featured+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);						
						return false;
    }
  });
  $(this).removeClass("make_featured_jsmusic").addClass("remove_featured_jsmusic");
});

$('.remove_featured_jsmusic').live('click', function() {
    var parent = $(this);
    parent.html("<img src=components/com_jsmusic/images/spinner.gif>");    
	$.ajax({
		type: "POST",
		data: "action=remove_featured_jsmusic&item="+item+"&id="+ $(this).attr('id'),
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			parent.html(msg);
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+not_featured+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);					
						return false;	
    }
  });
  $(this).removeClass("remove_featured_jsmusic").addClass("make_featured_jsmusic");
});

$(".vote_up_jsmusic").click(function(){
    the_id = $(this).attr('id');
	$(this).parent().html("<img src=components/com_jsmusic/images/spinner.gif>");
	$("span#votes_count_jsmusic"+the_id).fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=vote_up_jsmusic&item="+item+"&id=" +$(this).attr("id"),
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			$("span#votes_count_jsmusic"+the_id).html(msg);
			$("span#votes_count_jsmusic"+the_id).fadeIn();
			$("span#vote_buttons_jsmusic"+the_id).remove();
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+rated+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
		}
	});
});	
						
$(".vote_down_jsmusic").click(function(){
    the_id = $(this).attr('id');
	$(this).parent().html("<img src=components/com_jsmusic/images/spinner.gif>");
	$("span#votes_count_jsmusic"+the_id).fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=vote_down_jsmusic&item="+item+"&id=" +$(this).attr("id"),
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			$("span#votes_count_jsmusic"+the_id).html(msg);
			$("span#votes_count_jsmusic"+the_id).fadeIn();
			$("span#vote_buttons_jsmusic"+the_id).remove();
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+rated+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
		}
	});
});	

$(".subscribe_btn_jsmusic").click(function(){
    var userid = document.getElementById("userid").value;
    var parent = $(this); 
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=subscribe_jsmusic&userid="+ userid,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
			parent.fadeIn("fast");
			$.fn.colorbox.close();
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+subscribed+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
});
	
$(".unsubscribe_btn_jsmusic").click(function(){
    var userid = document.getElementById("userid").value;
    var parent = $(this); 
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=unsubscribe_jsmusic&userid=" + userid,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
			parent.fadeIn("fast");
			$.fn.colorbox.close();
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+unsubscribed+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
});	

$(".submit_comment_jsmusic").click(function() {
    var element = $(this);
    var id = element.attr("id");  
    var comment = $("#comment_jsmusic").val();
    var dataString = 'action=submit_comment_jsmusic&item='+ item +'&id='+ id + '&comment='+ comment;	
	if(comment=='') { alert('JSM_PLEASE_WRITE_SOMETHING');  
	} else {
	$(".no_comments_jsmusic").hide();
	$("#flash_jsmusic").show();
	$("#flash_jsmusic").fadeIn(400).html("<img src=components/com_jsmusic/images/spinner.gif>");
  $(".comments_textarea_box_jsmusic").fadeOut("slow");
  $.ajax({
		type: "POST",
		url: "index.php?option=com_jsmusic&view=song&format=raw",
    data: dataString,
    cache: false,
    success: function(html){
  $("#comments_box_jsmusic").append(html).fadeIn("slow");
    document.getElementById('comment_jsmusic').value='';
  $("#flash_jsmusic").hide();
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+submitted+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
  }
  return false;
});

$(".remove_comment_jsmusic").click(function(){
    var element = $(this);
    var id = element.attr("id");
    var parent = $(this);
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=remove_comment_jsmusic&item="+item+"&id=" + id,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			parent.html(msg);
			parent.fadeIn("fast");
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+removed+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
});		

$(".submit_reply_jsmusic").click(function(){
    var element = $(this);
    var id = element.attr("id");
    var reply = $("#reply_jsmusic"+id).val();
    var dataString = 'action=submit_reply_jsmusic&reply='+ reply + '&id=' + id;
	if(reply=='') { alert('JSM_PLEASE_WRITE_SOMETHING');  
  } else {
  $("#flash_jsmusic"+id).show();
  $("#flash_jsmusic"+id).fadeIn(400).html("<img src=components/com_jsmusic/images/spinner.gif>");
  $.ajax({
    type: "POST",
    url: "index.php?option=com_jsmusic&view=song&format=raw",
    data: dataString,
    cache: false,
    success: function(html){
  $("#loadplace_jsmusic"+id).append(html);
    document.getElementById('reply_jsmusic'+id).value='';
  $("#flash_jsmusic"+id).hide();
  $("#slidepanel_jsmusic"+id).fadeOut(100);
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+submitted+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
  }
  return false;
});

$(".remove_reply_jsmusic").click(function(){
    var element = $(this);
    var id = element.attr("id");
    var parent = $(this);
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=remove_reply_jsmusic&id=" + id,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			parent.html(msg);
			parent.fadeIn("fast");
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+removed+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
});	

$(".new_playlist_jsmusic").click(function() {
    var element = $(this);
    var playlist_name = document.getElementById("playlist_name_jsmusic").value;
    var id = element.attr("id");
    var dataString = 'action=new_playlist_jsmusic&playlist_name='+ playlist_name + '&id='+ id;	
	if(playlist_name=='') { alert("Please enter a name for the playlist"); }
    else {
	$("#flash_jsmusic").show();
	$("#flash_jsmusic").fadeIn(400).html("<img src=components/com_jsmusic/images/spinner.gif>");
	$.ajax({
    type: "POST",
    url: "index.php?option=com_jsmusic&view=song&format=raw",
    data: dataString,
    cache: false,
    success: function(html){ 
  $(".playlists").append(html).fadeIn("slow");
    document.getElementById('playlist_name_jsmusic').value='';
  $("#flash_jsmusic").hide();
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+playlist_created+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;  
    }
  });
  }
return false;
});

$(".delete_playlist_jsmusic").click(function(){
  var parent = $(this);
    parent.html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=delete_playlist_jsmusic&id="+ $(this).attr("id"),
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			parent.html(msg);
			parent.fadeIn("fast");
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+removed+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
});

$(".remove_song_from_playlist_jsmusic").click(function(){
  var song_id = document.getElementById("song_id").value;
  var parent = $(this);
    parent.html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=remove_song_from_playlist_jsmusic&id="+ $(this).attr("id") + "&song_id=" + song_id,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			parent.html(msg);
			parent.fadeIn("fast");
			$(".recordsArray_"+song_id).fadeOut(300);
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+removed+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
});

$("#sortable_playlist_jsmusic").sortable({ opacity: 0.6, cursor: 'move', update: function() {
  var order = $(this).sortable("serialize") + '&action=sort_playlist_jsmusic'; 
  $.post("index.php?option=com_jsmusic&view=song&format=raw", order, function(theResponse){
  $("#contentRight_jsmusic").html(theResponse);
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+submitted+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);		
						return false;				
			}); 															 
		}								  
});

$("#jquery_jplayer_1").bind($.jPlayer.event.timeupdate, function(event) { // Add a listener to report the time play began
  $(".jp-time-left").text($.jPlayer.convertTime(event.jPlayer.status.duration - event.jPlayer.status.currentTime));
});

$("#jquery_jplayer_1").bind($.jPlayer.event.volumechange, function(event) { // Add a listener to report the time volume changes
  var volume = event.jPlayer.status.volume;
	$.ajax({
		type: "POST",
		data: "action=change_volume&volume=" +volume,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
  });  
});

$(".jp-repeat").click(function() {
  $("#jquery_jplayer_1").bind($.jPlayer.event.ended + ".repeat", function() {
    $(this).jPlayer("play");
  });
  $(this).hide();
  $(".jp-unrepeat").show();

  return false;
});

$(".jp-unrepeat").click(function() {
  $("#jquery_jplayer_1").unbind(".repeat");
  $("#jquery_jplayer_1").bind($.jPlayer.event.ended, function() {
    audioPlaylist.playlistNext();
  });
  $(this).hide();
  $(".jp-repeat").show();

  return false;
}).hide();

$(".jp-track-title").css('text-align','center');

$(".edit_song_jsmusic").click(function(){
    var element = $(this);
    var id = element.attr("id");
    var title_jsmusic = document.getElementById("title_jsmusic").value;
    var genreid_jsmusic = document.getElementById("genreid_jsmusic").value;
    var albumid_jsmusic = document.getElementById("albumid_jsmusic").value;
    var description_jsmusic = document.getElementById("description_jsmusic").value;
    var lyrics_jsmusic = document.getElementById("lyrics_jsmusic").value;
    var tags_jsmusic = document.getElementById("tags_jsmusic").value;
    var allow_rating_jsmusic = document.getElementById("allow_rating_jsmusic").value;
    var allow_comments_jsmusic = document.getElementById("allow_comments_jsmusic").value;
    var allow_embed_jsmusic = document.getElementById("allow_embed_jsmusic").value;
    var allow_download_jsmusic = document.getElementById("allow_download_jsmusic").value;
    var parent = $(this); 
	if(title_jsmusic=='')  { alert(no_title_var);  
	} else if (genreid_jsmusic=='0')  { alert(no_genre_var);  
	} else if (description_jsmusic=='')  { alert(no_description_var);  
	} else if (tags_jsmusic=='')  { alert(no_tags_var);  
      } else {
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=edit_song_jsmusic&id=" + id + "&title_jsmusic=" + title_jsmusic + "&genreid_jsmusic=" + genreid_jsmusic + "&albumid_jsmusic=" + albumid_jsmusic + "&description_jsmusic=" + description_jsmusic + "&lyrics_jsmusic=" + lyrics_jsmusic + "&tags_jsmusic=" + tags_jsmusic + "&allow_rating_jsmusic=" + allow_rating_jsmusic + "&allow_comments_jsmusic=" + allow_comments_jsmusic + "&allow_embed_jsmusic=" + allow_embed_jsmusic + "&allow_download_jsmusic=" + allow_download_jsmusic,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
			parent.fadeIn("fast");
			$.fn.colorbox.close();
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+edited+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
  }
});


$(".report_jsmusic").click(function(){
    var report_message = document.getElementById("report_message").value;
    var parent = $(this); 
	if(report_message=='')  { alert("JSM_WHY_ARE_YOU_REPORTING_THIS");  
	} else {
    parent.html("<img src=components/com_jsmusic/images/spinner.gif>");    
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=report_jsmusic&item="+ item +"&id=" + $(this).attr('id') + "&report_message=" + report_message,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
			$.fn.colorbox.close();
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+reported+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';

						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);				
						return false;
    }
  });
  }
});	

$(".remove_report").click(function(){
    var parent = $(this); 
    parent.html("<img src=components/com_jsmusic/images/spinner.gif>");    
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=remove_report&id=" + $(this).attr('id'),
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
      parent.fadeIn("fast");
    }
  });
});	

$(".remove_playlist_report").click(function(){
    var parent = $(this); 
    parent.html("<img src=components/com_jsmusic/images/spinner.gif>");    
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=remove_playlist_report&id=" + $(this).attr('id'),
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
      parent.fadeIn("fast");
    }
  });
});	

$(".remove_artist_report").click(function(){
    var parent = $(this); 
    parent.html("<img src=components/com_jsmusic/images/spinner.gif>");    
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=remove_artist_report&id=" + $(this).attr('id'),
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
      parent.fadeIn("fast");
    }
  });
});	

$(".remove_album_report").click(function(){
    var parent = $(this); 
    parent.html("<img src=components/com_jsmusic/images/spinner.gif>");    
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=remove_album_report&id=" + $(this).attr('id'),
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
      parent.fadeIn("fast");
    }
  });
});	

$(".solve_report").click(function(){
    var parent = $(this); 
    parent.html("<img src=components/com_jsmusic/images/spinner.gif>");    
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=solve_report&id=" + $(this).attr('id'),
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
      parent.fadeIn("fast");
    }
  });
});	

$(".solve_playlist_report").click(function(){
    var parent = $(this); 
    parent.html("<img src=components/com_jsmusic/images/spinner.gif>");    
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=solve_playlist_report&id=" + $(this).attr('id'),
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
      parent.fadeIn("fast");
    }
  });
});	

$(".solve_artist_report").click(function(){
    var parent = $(this); 
    parent.html("<img src=components/com_jsmusic/images/spinner.gif>");    
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=solve_artist_report&id=" + $(this).attr('id'),
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
      parent.fadeIn("fast");
    }
  });
});	

$(".solve_album_report").click(function(){
    var parent = $(this); 
    parent.html("<img src=components/com_jsmusic/images/spinner.gif>");    
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=solve_album_report&id=" + $(this).attr('id'),
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
      parent.fadeIn("fast");
    }
  });
});	

$(".new_album_jsmusic").click(function(){
    var artist_id = document.getElementById("album_artist_jsmusic").value;
    var name = document.getElementById("album_name_jsmusic").value;
    var year = document.getElementById("album_year_jsmusic").value;
    var parent = $(this); 
	if(name=='' || year=='')  { alert("Please fill all the fields");  }
    else  {
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=new_album_jsmusic&artist_id=" + artist_id + "&name=" + name + "&year=" + year,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
			$.fn.colorbox.close();
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+album_created+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
      $('#albumid_jsmusic_box').load("index.php?option=com_jsmusic&view=song&format=raw", {action: 'load_albums'});						
						return false;
    }
  });
  }
});	

$(".edit_album_jsmusic").click(function(){
    var artist_id = document.getElementById("album_artist_jsmusic").value;
    var name = document.getElementById("album_name_jsmusic").value;
    var year = document.getElementById("album_year_jsmusic").value;
    var parent = $(this); 
	if(name=='' || year=='')  { alert("Please fill all the fields");  }
    else  {
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=edit_album_jsmusic&id="+ $(this).attr('id') + "&artist_id=" + artist_id + "&name=" + name + "&year=" + year,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
			$.fn.colorbox.close();
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+saved+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						return false;
    }
  });
  }
});	

$("#albumid_jsmusic").change(function() {
  var val = $(this).val();
    if(val=='new_album_jsmusic')  { 
      $(".newalbum_jsmusic").click();
    }
});

$("#embed_skin_jsmusic").change(function() {
  var myText = $('#share_code_jsmusic');
  myText.val( myText.val().replace('simplicia',$(this).val()) );
}).change(function() {
  var myText = $('#share_code_jsmusic');
  myText.val( myText.val().replace('zen',$(this).val()) );
});

$('.add_song_to_playlist_jsmusic').live('click', function() {
    var element = $(this);
    var playlist_id = element.attr("playlist_id");
    var id = element.attr("id");
    var parent = $(this);
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");  
	$.ajax({
		type: "POST",
		data: "action=add_song_to_playlist_jsmusic&id=" + id + "&playlist_id=" + playlist_id,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg)  {
			parent.html(msg);
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+added_to_playlist+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
  $(this).removeClass("add_song_to_playlist_jsmusic");  
});

$(".add_to_profile_btn_jsmusic").click(function(){
    var element = $(this);
    var id = element.attr("id");
    var parent = $(this); 
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=recommend_song_jsmusic&id=" + id,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
			parent.fadeIn("fast");
			$.fn.colorbox.close();
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+added_to_profile+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
});		

$(".remove_from_profile_btn_jsmusic").click(function(){
    var element = $(this);
    var id = element.attr("id");
    var parent = $(this); 
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=reset_recommended_song_jsmusic&id=" + id,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
      parent.html(msg);
			parent.fadeIn("fast");
			$.fn.colorbox.close();
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+removed+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
});		

$(".album_remove_cover_jsmusic").click(function(){
    var element = $(this);
    var id = element.attr("id");
    var parent = $(this);
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=album_remove_cover_jsmusic&id=" + id,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			parent.html(msg);
			parent.fadeIn("fast");
      $("#album_cover_image_jsmusic").fadeOut(500);      
      $("#default_cover_image_jsmusic").fadeIn(500);      
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+removed+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
});

$(".delete_song_jsmusic").click(function(){
    var element = $(this);
    var id = element.attr("id");
    var parent = $(this);
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=delete_song_jsmusic&id="+ id,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			parent.html(msg);
			parent.fadeIn("fast");
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+removed+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
});

$(".remove_album").click(function(){
    var element = $(this);
    var id = element.attr("id");
    var parent = $(this);
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=remove_album&id="+ id,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			parent.html(msg);
			parent.fadeIn("fast");
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+removed+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
});

$(".remove_artist").click(function(){
    var element = $(this);
    var id = element.attr("id");
    var parent = $(this);
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=remove_artist&id="+ id,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			parent.html(msg);
			parent.fadeIn("fast");
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+removed+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
});

$(".new_genre").click(function(){
    var new_genre_name = document.getElementById("new_genre_name").value;
    var parent = $(this);
	if(new_genre_name=='') { alert("Please enter a name");
  } else {    
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=new_genre&new_genre_name="+ new_genre_name,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			parent.html(msg);
			parent.fadeIn("fast");						
    }
  });}
});

$(".remove_genre").click(function(){
    var element = $(this);
    var id = element.attr("id");
    var parent = $(this);
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=remove_genre&id="+ id,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			parent.html(msg);
			parent.fadeIn("fast");
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+removed+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
});

$(".remove_genre").click(function(){
    var element = $(this);
    var id = element.attr("id");
    var parent = $(this);
	$(this).html("<img src=components/com_jsmusic/images/spinner.gif>");
    parent.fadeOut("fast");
	$.ajax({
		type: "POST",
		data: "action=remove_genre&id="+ id,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
			parent.html(msg);
			parent.fadeIn("fast");
						var notice = '<div class="notice_jsmusic">'
								  + '<div class="notice-body_jsmusic">' 
									  + '<div class="succes_jsmusic"></div>'
									  + '<h3>'+succes+'</h3>'
									  + '<p>'+removed+'</p>'
								  + '</div>'
								  + '<div class="notice-bottom_jsmusic">'
								  + '</div>'
							  + '</div>';
							  
						$( notice ).purr(
							{
								usingTransparentPNG: true
							}
						);
						
						return false;
    }
  });
});

/* reply slideout */
$("reply_button_jsmusic").click(function () {
  var element = $(this);
  var I = element.attr("id");
  $("#slidepanel_jsmusic"+I).slideToggle("slow");
});

$("#report_message").keyup(function()
{
var box=$(this).val();
var main = box.length *100;
var value= (main / 200);
var count= 200 - box.length;

if(box.length <= 200)
{
$('#count_jsmusic').html(count);
}
else
{
// do nothing
}
return false;
});


jQuery.fn.DefaultValue = function(text){
    return this.each(function(){
		//Make sure we're dealing with text-based form fields
		if(this.type != 'text' && this.type != 'password' && this.type != 'textarea')
			return;
		
		//Store field reference
		var fld_current=this;
		
		//Set value initially if none are specified
        if(this.value=='') {
			this.value=text;
		} else {
			//Other value exists - ignore
			return;
		}
		
		//Remove values on focus
		$(this).focus(function() {
			if(this.value==text || this.value=='')
				this.value='';
		});
		
		//Place values back on blur
		$(this).blur(function() {
			if(this.value==text || this.value=='')
				this.value=text;
		});
		
		//Capture parent form submission
		//Remove field values that are still default
		$(this).parents("form").each(function() {
			//Bind parent form submit
			$(this).submit(function() {
				if(fld_current.value==text) {
					fld_current.value='';
				}
			});
		});
    });
};

	var config = {
		type		: item,
	}
	
	// The small arrow that marks the active search icon:
	var arrow = $('<span>',{className:'arrow'}).appendTo('ul.icons');
	
	$('ul.icons li').click(function(){
		var el = $(this);
		
		if(el.hasClass('active')){
			// The icon is already active, exit
			return false;
		}
		
		el.siblings().removeClass('active');
		el.addClass('active');
		
		// Move the arrow below this icon
		arrow.stop().animate({
			left		: el.position().left,
			marginLeft	: (el.width()/2)-4
		});
		
		// Set the search type
		config.type = el.attr('data-searchType');
		$("#search_results_acylo").empty();
		$('#more').fadeOut();
	});
		
	// Marking the web search icon as active:
	$('li.'+config.type+'').click();
	
	// Focusing the input text box:
	$('#s').focus();

$("#search_input_jsmusic").keypress(function(e){
  if(e.which==13) $("#search_jsmusic").click();
});

   $("#search_results_acylo").hide();

$('#close_results_acylo').click(function(){
  $("#search_results_acylo").empty();
  $("#search_results_acylo").fadeOut("slow");
	$("#main_acylo").fadeIn("slow");
  $(this).hide();
  document.getElementById('search_input_jsmusic').value='';
});

$('#search_albums').click(function(){
  var search_input_jsmusic = document.getElementById("search_input_jsmusic").value;
  if(search_input_jsmusic !=='') $("#search_jsmusic").click();
});
$('#search_artists').click(function(){
  var search_input_jsmusic = document.getElementById("search_input_jsmusic").value;
  if(search_input_jsmusic !=='') $("#search_jsmusic").click();
});
$('#search_songs').click(function(){
  var search_input_jsmusic = document.getElementById("search_input_jsmusic").value;
  if(search_input_jsmusic !=='') $("#search_jsmusic").click();
});
$('#search_playlists').click(function(){
  var search_input_jsmusic = document.getElementById("search_input_jsmusic").value;
  if(search_input_jsmusic !=='') $("#search_jsmusic").click();
});

$('#search_jsmusic').click(function(){
	
	$("#search_results_acylo").empty();
  var search_term = $("#search_input_jsmusic").val();
  if(search_term =='') { //do nothing
  }else{
	$("#main_acylo").hide();
  var type = config.type;
  $("#search_flash_jsmusic").fadeIn(400).html("<img src=components/com_jsmusic/images/spinner.gif>");
if(type == "albums"){
	$.ajax({
		type: "POST",
		data: "action=search_jsmusic&item=albums&search_term=" +search_term,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
  $("#search_results_acylo").html(msg).fadeIn("slow");
  $("#close_results_acylo").show();
  $("#search_flash_jsmusic").hide();
    }
  });
} else if(type == "artists"){
	$.ajax({
		type: "POST",
		data: "action=search_jsmusic&item=artists&search_term=" +search_term,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
  $("#search_results_acylo").html(msg).fadeIn("slow");
  $("#close_results_acylo").show();
  $("#search_flash_jsmusic").hide();
    }
  });
} else if(type == "songs"){
	$.ajax({
		type: "POST",
		data: "action=search_jsmusic&item=songs&search_term=" +search_term,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
  $("#search_results_acylo").html(msg).fadeIn("slow");
  $("#close_results_acylo").show();
  $("#search_flash_jsmusic").hide();
    }
  });
} else if(type == "playlists"){
	$.ajax({
		type: "POST",
		data: "action=search_jsmusic&item=playlists&search_term=" +search_term,
		url: "index.php?option=com_jsmusic&view=song&format=raw",
		success: function(msg) {
  $("#search_results_acylo").html(msg).fadeIn("slow");
  $("#close_results_acylo").show();
  $("#search_flash_jsmusic").hide();
    }
  });
}
  }
		return false;
});


$(".jsmusic_hasTip").tipTip({maxWidth: "300px"});

$(".reply_button_jsmusic").click(function(){
  var element = $(this);
  var I = element.attr("id");
  $("#slidepanel_jsmusic"+I).slideToggle(300);
  $(this).toggleClass("active"); 
  return false;
});

  $(".report_box_open_jsmusic").colorbox({width:"500px", height:"auto",maxHeight:"700px", inline:true, href:"#report_box_jsmusic"});
  $(".playlist_jsmusic").colorbox({width:"500px", height:"auto",maxHeight:"700px", inline:true, href:"#playlist_box_jsmusic"});
  $(".editsong_jsmusic").colorbox({width:"550px", height:"auto",maxHeight:"700px", inline:true, href:"#edit_song_box_jsmusic"});
  $(".newalbum_jsmusic").colorbox({width:"550px", height:"auto",maxHeight:"700px", inline:true, href:"#new_album_box_jsmusic"});
  $(".deletesong_jsmusic").colorbox({width:"500px", height:"auto",maxHeight:"700px", inline:true, href:"#delete_song_box_jsmusic"});
  $(".share_jsmusic").colorbox({width:"570px", height:"auto",maxHeight:"700px", inline:true, href:"#share_box_jsmusic"});
  $("#share_song_jsmusic").colorbox({width:"570px", height:"auto",maxHeight:"700px", inline:true, href:"#share_song_box_jsmusic"});
  $(".notloggedin_jsmusic").colorbox({width:"500px", height:"auto",maxHeight:"700px", inline:true, href:"#not_logged_in_box_jsmusic"});
  $(".editplaylist_jsmusic").colorbox({width:"700px", height:"auto",maxHeight:"700px", inline:true, href:"#edit_playlist_box_jsmusic"});
  $(".deleteplaylist_jsmusic").colorbox({width:"550px", height:"auto",maxHeight:"700px", inline:true, href:"#delete_playlist_box_jsmusic"});
  $(".editalbum_jsmusic").colorbox({width:"550px", height:"auto",maxHeight:"700px", inline:true, href:"#edit_album_box_jsmusic"});
  $(".deletealbum_jsmusic").colorbox({width:"550px", height:"auto",maxHeight:"700px", inline:true, href:"#delete_album_box_jsmusic"});  
  $(".album_change_cover_jsmusic").colorbox({width:"570px", height:"auto",maxHeight:"700px", inline:true, href:"#change_cover_box_jsmusic"});
  $(".agree_terms_jsmusic").colorbox({width:"650px", height:"auto",maxHeight:"700px", inline:true, href:"#terms_box_jsmusic"});
  $(".edit_portlets").colorbox({width:"800px", height:"auto",maxHeight:"700px", inline:true, href:"#edit_portlets_box_jsmusic"});

	$("div#songs_list_jsmusic").quickPager({pageSize:10}); 

$("#agree_terms_check_jsmusic").click(function () {
if ($('#agree_terms_check_jsmusic:checked').val() !== undefined) {
$("#otherInput").slideDown('fast');
} else {
$("#otherInput").slideUp('fast');
}
}); 

$('#album_cover_jsmusic').hover(function(){
  $(".album_cover_hover_jsmusic", this).stop().animate({top:'0'},{queue:false,duration:160});
 }, function() {
  $(".album_cover_hover_jsmusic", this).stop().animate({top:'-100px'},{queue:false,duration:160});
});


//Set default open/close settings
$('.acc_container_jsmusic').hide(); //Hide/close all containers
//$('.acc_trigger_jsmusic:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container
 
//On Click
$('.acc_trigger_jsmusic').click(function(){
	if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
		$('.acc_trigger_jsmusic').removeClass('active').next().slideUp(); //Remove all .acc_trigger_jsmusic classes and slide up the immediate next container
		$(this).toggleClass('active').next().slideDown(); //Add .acc_trigger_jsmusic class to clicked trigger and slide down the immediate next container
	} else {
		$('.acc_trigger_jsmusic').removeClass('active').next().slideUp(); //Remove all .acc_trigger_jsmusic classes and slide up the immediate next container	
	}
	return false; //Prevent the browser jump to the link anchor
});

//Set default open/close settings
$('.acc_sub_container_jsmusic').hide(); //Hide/close all containers
 
//On Click
$('.acc_sub_trigger_jsmusic').click(function(){
	if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
		$('.acc_sub_trigger_jsmusic').removeClass('active').next().slideUp(); //Remove all .acc_trigger_jsmusic classes and slide up the immediate next container
		$(this).toggleClass('active').next().slideDown(); //Add .acc_trigger_jsmusic class to clicked trigger and slide down the immediate next container
	} else {
		$('.acc_sub_trigger_jsmusic').removeClass('active').next().slideUp(); //Remove all .acc_trigger_jsmusic classes and slide up the immediate next container	
	}
	return false; //Prevent the browser jump to the link anchor
});

$('.input_jsmusic').click(function(){
    $(this).focus();
    $(this).select();
});

/** ajaxupload **/
/**
 * Ajax upload
 * Project page - http://valums.com/ajax-upload/
 * Copyright (c) 2008 Andris Valums, http://valums.com
 * Licensed under the MIT license (http://valums.com/mit-license/)
 * Version 3.6 (26.06.2009)
 */

/**
 * Changes from the previous version:
 * 1. Fixed minor bug where click outside the button
 * would open the file browse window
 * 
 * For the full changelog please visit: 
 * http://valums.com/ajax-upload-changelog/
 */

(function(){
	
var d = document, w = window;

/**
 * Get element by id
 */	
function get(element){
	if (typeof element == "string")
		element = d.getElementById(element);
	return element;
}

/**
 * Attaches event to a dom element
 */
function addEvent(el, type, fn){
	if (w.addEventListener){
		el.addEventListener(type, fn, false);
	} else if (w.attachEvent){
		var f = function(){
		  fn.call(el, w.event);
		};			
		el.attachEvent('on' + type, f)
	}
}


/**
 * Creates and returns element from html chunk
 */
var toElement = function(){
	var div = d.createElement('div');
	return function(html){
		div.innerHTML = html;
		var el = div.childNodes[0];
		div.removeChild(el);
		return el;
	}
}();

function hasClass(ele,cls){
	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function addClass(ele,cls) {
	if (!hasClass(ele,cls)) ele.className += " "+cls;
}
function removeClass(ele,cls) {
	var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
	ele.className=ele.className.replace(reg,' ');
}

// getOffset function copied from jQuery lib (http://jquery.com/)
if (document.documentElement["getBoundingClientRect"]){
	// Get Offset using getBoundingClientRect
	// http://ejohn.org/blog/getboundingclientrect-is-awesome/
	var getOffset = function(el){
		var box = el.getBoundingClientRect(),
		doc = el.ownerDocument,
		body = doc.body,
		docElem = doc.documentElement,
		
		// for ie 
		clientTop = docElem.clientTop || body.clientTop || 0,
		clientLeft = docElem.clientLeft || body.clientLeft || 0,
		
		// In Internet Explorer 7 getBoundingClientRect property is treated as physical,
		// while others are logical. Make all logical, like in IE8.
		
		
		zoom = 1;
		if (body.getBoundingClientRect) {
			var bound = body.getBoundingClientRect();
			zoom = (bound.right - bound.left)/body.clientWidth;
		}
		if (zoom > 1){
			clientTop = 0;
			clientLeft = 0;
		}
		var top = box.top/zoom + (window.pageYOffset || docElem && docElem.scrollTop/zoom || body.scrollTop/zoom) - clientTop,
		left = box.left/zoom + (window.pageXOffset|| docElem && docElem.scrollLeft/zoom || body.scrollLeft/zoom) - clientLeft;
				
		return {
			top: top,
			left: left
		};
	}
	
} else {
	// Get offset adding all offsets 
	var getOffset = function(el){
		if (w.jQuery){
			return jQuery(el).offset();
		}		
			
		var top = 0, left = 0;
		do {
			top += el.offsetTop || 0;
			left += el.offsetLeft || 0;
		}
		while (el = el.offsetParent);
		
		return {
			left: left,
			top: top
		};
	}
}

function getBox(el){
	var left, right, top, bottom;	
	var offset = getOffset(el);
	left = offset.left;
	top = offset.top;
						
	right = left + el.offsetWidth;
	bottom = top + el.offsetHeight;		
		
	return {
		left: left,
		right: right,
		top: top,
		bottom: bottom
	};
}

/**
 * Crossbrowser mouse coordinates
 */
function getMouseCoords(e){		
	// pageX/Y is not supported in IE
	// http://www.quirksmode.org/dom/w3c_cssom.html			
	if (!e.pageX && e.clientX){
		// In Internet Explorer 7 some properties (mouse coordinates) are treated as physical,
		// while others are logical (offset).
		var zoom = 1;	
		var body = document.body;
		
		if (body.getBoundingClientRect) {
			var bound = body.getBoundingClientRect();
			zoom = (bound.right - bound.left)/body.clientWidth;
		}

		return {
			x: e.clientX / zoom + d.body.scrollLeft + d.documentElement.scrollLeft,
			y: e.clientY / zoom + d.body.scrollTop + d.documentElement.scrollTop
		};
	}
	
	return {
		x: e.pageX,
		y: e.pageY
	};		

}
/**
 * Function generates unique id
 */		
var getUID = function(){
	var id = 0;
	return function(){
		return 'ValumsAjaxUpload' + id++;
	}
}();

function fileFromPath(file){
	return file.replace(/.*(\/|\\)/, "");			
}

function getExt(file){
	return (/[.]/.exec(file)) ? /[^.]+$/.exec(file.toLowerCase()) : '';
}			

// Please use AjaxUpload , Ajax_upload will be removed in the next version
Ajax_upload = AjaxUpload = function(button, options){
	if (button.jquery){
		// jquery object was passed
		button = button[0];
	} else if (typeof button == "string" && /^#.*/.test(button)){					
		button = button.slice(1);				
	}
	button = get(button);	
	
	this._input = null;
	this._button = button;
	this._disabled = false;
	this._submitting = false;
	// Variable changes to true if the button was clicked
	// 3 seconds ago (requred to fix Safari on Mac error)
	this._justClicked = false;
	this._parentDialog = d.body;
	
	if (window.jQuery && jQuery.ui && jQuery.ui.dialog){
		var parentDialog = jQuery(this._button).parents('.ui-dialog');
		if (parentDialog.length){
			this._parentDialog = parentDialog[0];
		}
	}			
					
	this._settings = {
		// Location of the server-side upload script
		action: 'upload.php',			
		// File upload name
		name: 'userfile',
		// Additional data to send
		data: {},
		// Submit file as soon as it's selected
		autoSubmit: true,
		// The type of data that you're expecting back from the server.
		// Html and xml are detected automatically.
		// Only useful when you are using json data as a response.
		// Set to "json" in that case. 
		responseType: false,
		// When user selects a file, useful with autoSubmit disabled			
		onChange: function(file, extension){},					
		// Callback to fire before file is uploaded
		// You can return false to cancel upload
		onSubmit: function(file, extension){},
		// Fired when file upload is completed
		// WARNING! DO NOT USE "FALSE" STRING AS A RESPONSE!
		onComplete: function(file, response) {}
	};

	// Merge the users options with our defaults
	for (var i in options) {
		this._settings[i] = options[i];
	}
	
	this._createInput();
	this._rerouteClicks();
}
			
// assigning methods to our class
AjaxUpload.prototype = {
	setData : function(data){
		this._settings.data = data;
	},
	disable : function(){
		this._disabled = true;
	},
	enable : function(){
		this._disabled = false;
	},
	// removes ajaxupload
	destroy : function(){
		if(this._input){
			if(this._input.parentNode){
				this._input.parentNode.removeChild(this._input);
			}
			this._input = null;
		}
	},				
	/**
	 * Creates invisible file input above the button 
	 */
	_createInput : function(){
		var self = this;
		var input = d.createElement("input");
		input.setAttribute('type', 'file');
		input.setAttribute('name', this._settings.name);
		var styles = {
			'position' : 'absolute'
			,'margin': '-5px 0 0 -175px'
			,'padding': 0
			,'width': '220px'
			,'height': '30px'
			,'fontSize': '14px'								
			,'opacity': 0
			,'cursor': 'pointer'
			,'display' : 'none'
			,'zIndex' :  2147483583 //Max zIndex supported by Opera 9.0-9.2x 
			// Strange, I expected 2147483647					
		};
		for (var i in styles){
			input.style[i] = styles[i];
		}
		
		// Make sure that element opacity exists
		// (IE uses filter instead)
		if ( ! (input.style.opacity === "0")){
			input.style.filter = "alpha(opacity=0)";
		}
							
		this._parentDialog.appendChild(input);

		addEvent(input, 'change', function(){
			// get filename from input
			var file = fileFromPath(this.value);	
			if(self._settings.onChange.call(self, file, getExt(file)) == false ){
				return;				
			}														
			// Submit form when value is changed
			if (self._settings.autoSubmit){
				self.submit();						
			}						
		});
		
		// Fixing problem with Safari
		// The problem is that if you leave input before the file select dialog opens
		// it does not upload the file.
		// As dialog opens slowly (it is a sheet dialog which takes some time to open)
		// there is some time while you can leave the button.
		// So we should not change display to none immediately
		addEvent(input, 'click', function(){
			self.justClicked = true;
			setTimeout(function(){
				// we will wait 3 seconds for dialog to open
				self.justClicked = false;
			}, 2500);			
		});		
		
		this._input = input;
	},
	_rerouteClicks : function (){
		var self = this;
	
		// IE displays 'access denied' error when using this method
		// other browsers just ignore click()
		// addEvent(this._button, 'click', function(e){
		//   self._input.click();
		// });
				
		var box, dialogOffset = {top:0, left:0}, over = false;
									
		addEvent(self._button, 'mouseover', function(e){
			if (!self._input || over) return;
			
			over = true;
			box = getBox(self._button);
					
			if (self._parentDialog != d.body){
				dialogOffset = getOffset(self._parentDialog);
			}	
		});
		
	
		// We can't use mouseout on the button,
		// because invisible input is over it
		addEvent(document, 'mousemove', function(e){
			var input = self._input;			
			if (!input || !over) return;
			
			if (self._disabled){
				removeClass(self._button, 'hover');
			//	input.style.display = 'none';
				return;
			}	
										
			var c = getMouseCoords(e);

			if ((c.x >= box.left) && (c.x <= box.right) && 
			(c.y >= box.top) && (c.y <= box.bottom)){
							
				input.style.top = c.y - dialogOffset.top + 'px';
				input.style.left = c.x - dialogOffset.left + 'px';
				input.style.display = 'block';
				addClass(self._button, 'hover');
								
			} else {		
				// mouse left the button
				over = false;
			
				var check = setInterval(function(){
					// if input was just clicked do not hide it
					// to prevent safari bug
					 
					if (self.justClicked){
						return;
					}
					
					if ( !over ){
			//			input.style.display = 'none';	
					}						
				
					clearInterval(check);
				
				}, 25);
					

				removeClass(self._button, 'hover');
			}			
		});			
			
	},
	/**
	 * Creates iframe with unique name
	 */
	_createIframe : function(){
		// unique name
		// We cannot use getTime, because it sometimes return
		// same value in safari :(
		var id = getUID();
		
		// Remove ie6 "This page contains both secure and nonsecure items" prompt 
		// http://tinyurl.com/77w9wh
		var iframe = toElement('<iframe src="javascript:false;" name="' + id + '" />');
		iframe.id = id;
		iframe.style.display = 'none';
		d.body.appendChild(iframe);			
		return iframe;						
	},
	/**
	 * Upload file without refreshing the page
	 */
	submit : function(){
		var self = this, settings = this._settings;	
					
		if (this._input.value === ''){
			// there is no file
			return;
		}
										
		// get filename from input
		var file = fileFromPath(this._input.value);			
    
		// execute user event
		if (! (settings.onSubmit.call(this, file, getExt(file)) == false)) {
			// Create new iframe for this submission
			var iframe = this._createIframe();
			
			// Do not submit if user function returns false										
			var form = this._createForm(iframe);
			form.appendChild(this._input);
			
			form.submit();
			
			d.body.removeChild(form);				
			form = null;
			this._input = null;
			
			// create new input
			this._createInput();
			
			var toDeleteFlag = false;
			
			addEvent(iframe, 'load', function(e){
					
				if (// For Safari
					iframe.src == "javascript:'%3Chtml%3E%3C/html%3E';" ||
					// For FF, IE
					iframe.src == "javascript:'<html></html>';"){						
					
					// First time around, do not delete.
					if( toDeleteFlag ){
						// Fix busy state in FF3
						setTimeout( function() {
							d.body.removeChild(iframe);
						}, 0);
					}
					return;
				}				
				
				var doc = iframe.contentDocument ? iframe.contentDocument : frames[iframe.id].document;

				// fixing Opera 9.26
				if (doc.readyState && doc.readyState != 'complete'){
					// Opera fires load event multiple times
					// Even when the DOM is not ready yet
					// this fix should not affect other browsers
					return;
				}
				
				// fixing Opera 9.64
				if (doc.body && doc.body.innerHTML == "false"){
					// In Opera 9.64 event was fired second time
					// when body.innerHTML changed from false 
					// to server response approx. after 1 sec
					return;				
				}
				
				var response;
									
				if (doc.XMLDocument){
					// response is a xml document IE property
					response = doc.XMLDocument;
				} else if (doc.body){
					// response is html document or plain text
					response = doc.body.innerHTML;
					if (settings.responseType && settings.responseType.toLowerCase() == 'json'){
						// If the document was sent as 'application/javascript' or
						// 'text/javascript', then the browser wraps the text in a <pre>
						// tag and performs html encoding on the contents.  In this case,
						// we need to pull the original text content from the text node's
						// nodeValue property to retrieve the unmangled content.
						// Note that IE6 only understands text/html
						if (doc.body.firstChild && doc.body.firstChild.nodeName.toUpperCase() == 'PRE'){
							response = doc.body.firstChild.firstChild.nodeValue;
						}
						if (response) {
							response = window["eval"]("(" + response + ")");
						} else {
							response = {};
						}
					}
				} else {
					// response is a xml document
					var response = doc;
				}
																			
				settings.onComplete.call(self, file, response);
						
				// Reload blank page, so that reloading main page
				// does not re-submit the post. Also, remember to
				// delete the frame
				toDeleteFlag = true;
				
				// Fix IE mixed content issue
				iframe.src = "javascript:'<html></html>';";		 								
			});
	
		} else {
			// clear input to allow user to select same file
			// Doesn't work in IE6
			// this._input.value = '';
			d.body.removeChild(this._input);				
			this._input = null;
			
			// create new input
			this._createInput();						
		}
	},		
	/**
	 * Creates form, that will be submitted to iframe
	 */
	_createForm : function(iframe){
		var settings = this._settings;
		
		// method, enctype must be specified here
		// because changing this attr on the fly is not allowed in IE 6/7		
		var form = toElement('<form method="post" enctype="multipart/form-data"></form>');
		form.style.display = 'none';
		form.action = settings.action;
		form.target = iframe.name;
		d.body.appendChild(form);
		
		// Create hidden input element for each data key
		for (var prop in settings.data){
			var el = d.createElement("input");
			el.type = 'hidden';
			el.name = prop;
			el.value = settings.data[prop];
			form.appendChild(el);
		}			
		return form;
	}	
};
})();



});

})(jQuery);
