 $(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').hide();
	$('#image_0').slideDown();
	var pos = 0;
	var image_count = $('.product_images').size();	
	if (image_count < 2) {  $("#pagination").animate({"top": "-=50px"}, 500, "easeInExpo"); }
 
   $('.thumbnails').click(function(){
    $('.product_images').hide();         
      
       var re = /([_\-\w]+$)/i;
            var target = $('thumbnail_' + re.exec(this.id)[1]);
            var target = $('#image_'+this.id.split('thumbnail_')[1]);
            
      		target.show('slow');
   });
   
     // pagination swap 


pos = 0;

   $('.forward').click(function(){
    			
    			if (image_count > pos+1) {
    					
						var target = '#image_'+pos;
						$(target).slideUp(500, "easeOutExpo");
						pos++;
						var target = '#image_'+pos;
						$(target).slideDown(350, "easeInExpo");
						$("#image_position").html(eval(pos+1) + " / " + image_count);
				}		
      		return false;
   });
   
   $('.back').click(function(){
   				
   				if (pos > 0) {
    				    var target = '#image_'+pos;
						$(target).slideUp(500, "easeOutExpo");
						pos--;
						var target = '#image_'+pos;
						$(target).slideDown(350, "easeInExpo");
						$("#image_position").html(eval(pos+1) + " / " + image_count);
				}		
			return false;			
   });


    
   // 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;
		}
	