 $(document).ready(function() {
 		
			window.previewPlayers = new Array();
			
		 	$("embed").each(function(i) {
		 	
				if (navigator.appName.indexOf("Microsoft") != -1) {
						window.previewPlayers[i] = window[$(this).attr("name")];
					} else {
						window.previewPlayers[i] = window.document[$(this).attr("name")];
					}
			 	});
			 	
			 $("object").each(function(i) {
		 	
				if (navigator.appName.indexOf("Microsoft") != -1) {
						window.previewPlayers[i] = window[$(this).attr("id")];
					} else {
						window.previewPlayers[i] = window.document[$(this).attr("id")];
					}
			 	});
	


  $('.mp3_show').click(function(){
	$('.mp3_preview').height(0);   

		$(this).parent().parent().children().children().height(30);
			if (isDefined(window.player_target)) { window.old_target = window.player_target; }
			
			window.player_target = $(this).attr("id").split('track_')[1];
			
			
			
			if (isDefined(window.old_target)) { stopOldPlayback(window.old_target); }
			if (isDefined(window.player_target)) { playAnMp3Preview(window.player_target); } else { alert("shit"); }
   });
   
	   $('.mp3_preview_hide').click(function(){
		  $('.mp3_preview').height(0);          	
	   });

 // small releases swap
  $('.release_detail').hide();
	$('#release_0').show();	
   $('.releases_small').mouseover(function(){
    $('.release_detail').hide();         
      
       var re = /([_\-\w]+$)/i;
            var target = $('cover_' + re.exec(this.id)[1]);
            var target = $('#release_'+this.id.split('cover_')[1]);
            
      		target.show();
   });
   
   
  // image swap 
   $('.product_images:not(:first)').hide();
	
	window.pos = 0;
	var image_count = $('.product_images').size();	
	if (image_count < 2) {  $("#pagination").animate({"top": "-=50px"}, 500, "easeInExpo"); }
    
     // pagination swap 

   $('.forward').click(function(){
    			
    			if (image_count > window.pos+1) {
    					
						var target = '#image_'+window.pos;
						$(target).slideUp(800, "easeOutExpo");
						window.pos++;
						var target = '#image_'+window.pos;
						$(target).slideDown(700, "easeInExpo");
						
						 $.ajax({
								   type: "POST",
								   url: "library/update_name.php",
								   data: "pos="+window.pos+"&id="+ window.id,
								   dataType: "html",
								   success: function(msg){
								   		$("#image_name").html(msg);
								   }
								 });
								 
								  $.ajax({
								   type: "POST",
								   url: "library/update_description.php",
								   data: "pos="+window.pos+"&id="+ window.id,
								   dataType: "html",
								   success: function(msg){
								   		$("#image_description").html(msg);
								   }
								 });
						
				}		
      		return false;
   });
   
   
   $('.number_target').click(function(){
   	
		
						var target = '#image_'+window.pos;
						$(target).slideUp(400, "easeOutCubic");
						window.pos = $('.number_target').index(this);
						var target = '#image_'+window.pos;
						$(target).slideDown(300, "easeInOutCubic");
						
							
							
		
		return false;
   
   });
   
   $('.back').click(function(){
   				
   				if (window.pos > 0) {
    				    var target = '#image_'+window.pos;
						$(target).slideUp(800, "easeOutExpo");
						window.pos--;
						var target = '#image_'+window.pos;
						$(target).slideDown(700, "easeInExpo");
							 $.ajax({
									   type: "POST",
									   url: "library/update_name.php",
									   data: "pos="+window.pos+"&id="+ window.id,
									   dataType: "html",
									   success: function(msg){
											$("#image_name").html(msg);
									   }
									 });
									 
									 	  $.ajax({
								   type: "POST",
								   url: "library/update_description.php",
								   data: "pos="+window.pos+"&id="+ window.id,
								   dataType: "html",
								   success: function(msg){
								   		$("#image_description").html(msg);
								   }
								 });
				}		
			return false;			
   });

	$('.text').focus(function(){
   			var value = $(this).attr("value"); 
   			if (value == "your email" || value == "their email") { $(this).attr("value", ""); }
		
   
   });
	
    
   // billing hide

    $('.gateway_payment').click(function(){
		  $('.payment_details').slideToggle("medium");          	
	   });
   
   	// ajax content
		 $('.menu_ajax').click(function(){   
		 	if (ajax == true) {
					//$("div#content").hide(300);  
					target = $(this).attr('id');				
										 $.ajax({
								   type: "POST",
								   url: "pages/"+$(this).attr('id')+".php",
								   data: "ajax=true",
								   dataType: "html",
								   success: function(msg){
									 $("div#content").html(msg);
	
									 $("div#content").show(200);
										
										
								   }
								 });	
								 
							
									
					return false;
					}
		   });
		   
	  // menu 
	  
	  var id_query = String(window.location);
	  
	  var querystring = id_query.split('&id=');
	
	  var id = querystring[1];
	  
		  if (id_query.indexOf("&") > -1) { $("#menu_"+id).parent().next("dd").show(); } else { $("dd:first").show(); }
	  
	  
		$("dt a.sliding_menu").click(function(){
			$("dd:visible").slideUp("medium");
			$(this).parent().next().slideDown("medium");
			return false;
		}); 
	   
   });
   
 
   
   // roster ajax
   
   function artist(id){   

					//$("div#content").hide(300); 
												 $.ajax({
								   type: "POST",
								   url: "pages/artist.php",
								   data: "ajax=true&artist="+id,
								   success: function(msg){
									 
									 $("div#content").html(msg);
									 $("div#content").show(200);
									
								   }
								 });
					 return false;
		   }  
		   
	function close_previews() {
	
		$('.mp3_preview').height(0);  
	}
	
		function playAnMp3Preview(flash_id) {
		
				var target = window.previewPlayers[flash_id];
				//var target = document.getElementById("mp32");
				target.loadMp3();
		}
		
		function stopOldPlayback(flash_id) {
				var old_target = window.previewPlayers[flash_id];
				old_target.stopMp3();
		}
		
		function isDefined(variable)
		{ value = variable || 0;
		return value;
		}
	

