// JavaScript Document
$(document).ready(function(){
  $('#featured ul').innerfade({ animationtype: 'fade', speed: 750, timeout: 6000, type: 'random_start', containerheight: '150px' }); 	
  $("#login_acc").accordion({ active: false, autoHeight: false, navigation: true, alwaysOpen: false, animated: "slide", header: ".login_head" });
  $("#search_acc").accordion({ active: false, autoHeight: false, navigation: true, alwaysOpen: false, animated: "slide", header: ".search_head" });
  $("#basket").load("http://www.noisia.nl/store/scripts/basket.php");
  $("#player").load("http://www.noisia.nl/store/scripts/player.php");
  
  $("#notifications_close").click(function () {
	  $("#notifications").slideUp();
	  $.get("http://www.noisia.nl/scripts/hide_notifications.php");
  });
  $('input[type="text"],input[type="password"]').addClass("loginfield");
  $('input[type="text"],input[type="password"]').focus(function() {
	  $(this).removeClass("loginfield").addClass("loginfieldFocus");
	  if (this.value == this.defaultValue){ 
		  this.value = '';
	  }
	  if(this.value != this.defaultValue){
		  this.select();
	  }
  });
  $('input[type="text"],input[type="password"]').blur(function() {
	  $(this).removeClass("loginfieldFocus").addClass("loginfield");
	  if ($.trim(this.value) == ''){
		  this.value = (this.defaultValue ? this.defaultValue : '');
	  }
  });
  
  var imagezoom =
  {
	  zoomWidth: 230,
	  zoomHeight: 200,
	  xOffset: 8,
	  yOffset: 85,
	  title: false,
	  lens:true,
      showEffect:'show',
      hideEffect:'fadeout', 
      fadeoutSpeed: 'medium'
  }
  $(".jqzoom").jqzoom(imagezoom);
  
  $(".shipping").colorbox({width:"480", height:"300", iframe:true}); 

});

// player
function cueTrack(id) {
	$.post("http://www.noisia.nl/store/scripts/player.php", { cueTrack: id }, function() {
		$("#player").load("http://www.noisia.nl/store/scripts/player.php");
	});	
}

function cueRelease(id) {
	$.post("http://www.noisia.nl/store/scripts/player.php", { cueRelease: id }, function() {
		$("#player").load("http://www.noisia.nl/store/scripts/player.php");
	});	
}

function playTrack(id) {	
	$.post("http://www.noisia.nl/store/scripts/player.php", { playTrack: id }, function() {
		window.document.flashObject.gotoLast();
		$("#player").load("http://www.noisia.nl/store/scripts/player.php");
	});	
}

function playRelease(id) {
	$.post("http://www.noisia.nl/store/scripts/player.php", { playRelease: id }, function() {
		$("#player").load("http://www.noisia.nl/store/scripts/player.php");
	});	
}

function removeTrack(id) {
	$.post("http://www.noisia.nl/store/scripts/player.php", { removeTrack: id }, function() {
		$("#player").load("http://www.noisia.nl/store/scripts/player.php");
	});	
}

function bigger(){
maxplayer.style.visibility='hidden';
minplayer.style.visibility='visible';
var player=document.getElementById("flashObject"); // ID of your embed tag
player.style.width='160px';
player.style.height='334px';
var emb=document.getElementById("embflashObject");
emb.style.width='160px';
emb.style.height='334px';
}
function smaller(){
maxplayer.style.visibility='visible';
minplayer.style.visibility='hidden';
var player=document.getElementById("flashObject"); // ID of your embed tag
player.style.width='160px';
player.style.height='135px';
var emb=document.getElementById("embflashObject");
emb.style.width='160px';
emb.style.height='135px';
}

// basket
function addTrackToBasket(id) {
	$.post("http://www.noisia.nl/store/scripts/basket.php", { addTrack: id } );
	$("#basket").load("http://www.noisia.nl/store/scripts/basket.php", function() {
    	$("#basket_items").show("slow", function() {
			$("#item_t_"+id).effect("highlight", {}, 2000);
		});
  	});
}

function addReleaseToBasket(id) {
	$.post("http://www.noisia.nl/store/scripts/basket.php", { addRelease: id } );
	$("#basket").load("http://www.noisia.nl/store/scripts/basket.php", function() {
    	$("#basket_items").show("slow", function() {
			$("#item_r_"+id).effect("highlight", {}, 2000);
		});
  	});
}

function addHardwareReleaseToBasket(id) {
	$.post("http://www.noisia.nl/store/scripts/basket.php", { addHardwareRelease: id },
	function(data){
		alert(data);
		$(".buy").bar({
                color 			 : '#1E90FF',
                background_color : '#FFFFFF',
                removebutton     : false,
                message			 : 'Your profile customization has been saved!',
                time			 : 4000
            });
		$("#basket").load("http://www.noisia.nl/store/scripts/basket.php");
	});
}

function addProductToBasket(id) {
	$.post("http://www.noisia.nl/store/scripts/basket.php", { addProduct: id },
	function(data){
		alert(data);
		$(".buy").bar({
                color 			 : '#1E90FF',
                background_color : '#FFFFFF',
                removebutton     : false,
                message			 : 'Your profile customization has been saved!',
                time			 : 4000
            });
		$("#basket").load("http://www.noisia.nl/store/scripts/basket.php");
	});
}

/* function addProductToBasket(id) {
	$.post("http://www.noisia.nl/store/scripts/basket.php", { addProduct: id } );
	$("#basket").load("http://www.noisia.nl/store/scripts/basket.php", function() {
    	$("#basket_items").show("slow", function() {
			$("#item_p_"+id).effect("highlight", {}, 2000);
		});
  	});
}
*/

function removeTrackFromBasket(id) {
	$.post("http://www.noisia.nl/store/scripts/basket.php", { removeTrack: id } );
	$("#item_t_"+id).hide("slow", function() {
	  $("#basket").load("http://www.noisia.nl/store/scripts/basket.php", function() {
		  $("#basket_items").show();
	  });
	});
}

function removeReleaseFromBasket(id) {
	$.post("http://www.noisia.nl/store/scripts/basket.php", { removeRelease: id } );
	$("#item_r_"+id).hide("slow", function() {
	  $("#basket").load("http://www.noisia.nl/store/scripts/basket.php", function() {
		  $("#basket_items").show();
	  });
	});
}
  
function removeProductFromBasket(id) {
	$.post("http://www.noisia.nl/store/scripts/basket.php", { removeProduct: id } );
	$("#item_p_"+id).hide("slow", function() {
	  $("#basket").load("http://www.noisia.nl/store/scripts/basket.php", function() {
		  $("#basket_items").show();
	  });
	});
}
