	var current_song = '';
	var current_song_name = '';
	
	songs_folder = "songs/";
	
	$(document).ready(function(){
		stripe_songs();

		$("#submit_upload_form").click(function(){
			title = $("#song_title").val();
			songfile = $("#filedata").val().length;
			

			
			artist = $("#song_artist").val();
			if(songfile==0 || title.length==0 || artist.length==0){ alert("You need to fill out everything!"); return;}
			else{ 
				
				//upload_songs, song_player, browse_songs
				
				$("#wait").fadeIn("slow");
				$("#song_player").html('');
			
				
				fadespeed = "slow";
				fadepoint = 0.33;
				$("#upload_song").fadeTo(fadespeed, fadepoint);
				$("#song_player").fadeTo(fadespeed, fadepoint);
				$("#browse_songs").fadeTo(fadespeed, fadepoint);
								
				$("a").click(function(){
					if($(this).attr("id")!=="link_allowed"){
						$(this).css("cursor","arrow");
						return false;
					}
				});
				
				$("#upload_form").submit();
			}
			
			
		});
	});
	
	function stripe_songs(){
		$(".song_link:odd").css("background","url('images/green_grad.gif') repeat-x #CCEECC");
	}
	
	function play_song(file, simple_name){
		current_song = file;
		current_song_name = simple_name;
		
		document.title=current_song_name+" @ Wavia";
		
		$("#song_player").fadeOut("slow").fadeIn("slow");

		file = songs_folder+(file);
		$("#s_title").html("<b>Now playing:</b> "+simple_name);
		 $.ajax({
  			 type: "POST",
  			 url: "songdata.php",
  			 data: "file="+file,
		   success: function(data){
		   
   			  $("#s_file").html(data);
   			}
 		 });

	}
	
	function song_sort(method){
		$("#songs_wrapper").hide("slow").html('').show("slow");
	   $.ajax({
  			 type: "GET",
  			 url: "get_songs.php",
  			 data: "sort="+method,
		   success: function(data){
   			  $("#songs_wrapper").html(data);
   			   stripe_songs();
   			}
 		 });
 		 
 		
	}
