// JavaScript Document
$().ready(function() {  
	// General Scripts for Product Dialog
	$('.productDialog').hide();
	$('.watchVideo').click(function(){
      	$('#video-dialog').show();
      });
	$('#videoClose').click(function(){
      	$('#video-dialog').hide();
      });
	$(".productDialog").draggable({ handle: 'h5', containment: 'body', stack: { group: '.productDialog', min: 99999 } });
	
	// Product 1
	  $(".product1open").bind("click", function(e){
		  var largestZ = 99999; // this is the min z-index you would want to apply to the draggable
		  $(".productDialog").each(function(i) {
			  var currentZ = parseFloat($(this).css("zIndex"));
			  largestZ = currentZ > largestZ ? currentZ : largestZ;
		  });
		  $('.product1dialog').show(50);
		  $(".product1dialog").css("z-index", largestZ + 1);
	  });
	  $('.product1close').click(function(){
      		$('.product1dialog').hide();
      });
	  
	// Product 2
	  $(".product2open").bind("click", function(e){
		  var largestZ = 11; // this is the min z-index you would want to apply to the draggable
		  $(".productDialog").each(function(i) {
			  var currentZ = parseFloat($(this).css("zIndex"));
			  largestZ = currentZ > largestZ ? currentZ : largestZ;
		  });
		  $('.product2dialog').show();
		  $(".product2dialog").css("z-index", largestZ + 1);
	  });
	  $('.product2close').click(function(){
      		$('.product2dialog').hide();
      });
	  
	  // Product 3
	  $(".product3open").bind("click", function(e){
		  var largestZ = 11; // this is the min z-index you would want to apply to the draggable
		  $(".productDialog").each(function(i) {
			  var currentZ = parseFloat($(this).css("zIndex"));
			  largestZ = currentZ > largestZ ? currentZ : largestZ;
		  });
		  $('.product3dialog').show();
		  $(".product3dialog").css("z-index", largestZ + 1);
	  });
	  $('.product3close').click(function(){
      		$('.product3dialog').hide();
      });
	  
	  // Product 4
	  $(".product4open").bind("click", function(e){
		  var largestZ = 11; // this is the min z-index you would want to apply to the draggable
		  $(".productDialog").each(function(i) {
			  var currentZ = parseFloat($(this).css("zIndex"));
			  largestZ = currentZ > largestZ ? currentZ : largestZ;
		  });
		  $('.product4dialog').show();
		  $(".product4dialog").css("z-index", largestZ + 1);
	  });
	  $('.product4close').click(function(){
      		$('.product4dialog').hide();
      });
	  
	  // Product 5
	  $(".product5open").bind("click", function(e){
		  var largestZ = 11; // this is the min z-index you would want to apply to the draggable
		  $(".productDialog").each(function(i) {
			  var currentZ = parseFloat($(this).css("zIndex"));
			  largestZ = currentZ > largestZ ? currentZ : largestZ;
		  });
		  $('.product5dialog').show();
		  $(".product5dialog").css("z-index", largestZ + 1);
	  });
	  $('.product5close').click(function(){
      		$('.product5dialog').hide();
      });
	  
	  // Product 6
	  $(".product6open").bind("click", function(e){
		  var largestZ = 11; // this is the min z-index you would want to apply to the draggable
		  $(".productDialog").each(function(i) {
			  var currentZ = parseFloat($(this).css("zIndex"));
			  largestZ = currentZ > largestZ ? currentZ : largestZ;
		  });
		  $('.product6dialog').show();
		  $(".product6dialog").css("z-index", largestZ + 1);
	  });
	  $('.product6close').click(function(){
      		$('.product6dialog').hide();
      });
	  
	  // Product 7
	  $(".product7open").bind("click", function(e){
		  var largestZ = 11; // this is the min z-index you would want to apply to the draggable
		  $(".productDialog").each(function(i) {
			  var currentZ = parseFloat($(this).css("zIndex"));
			  largestZ = currentZ > largestZ ? currentZ : largestZ;
		  });
		  $('.product7dialog').show();
		  $(".product7dialog").css("z-index", largestZ + 1);
	  });
	  $('.product7close').click(function(){
      		$('.product7dialog').hide();
      });
	  
	  // Product 8
	  $(".product8open").bind("click", function(e){
		  var largestZ = 11; // this is the min z-index you would want to apply to the draggable
		  $(".productDialog").each(function(i) {
			  var currentZ = parseFloat($(this).css("zIndex"));
			  largestZ = currentZ > largestZ ? currentZ : largestZ;
		  });
		  $('.product8dialog').show();
		  $(".product8dialog").css("z-index", largestZ + 1);
	  });
	  $('.product8close').click(function(){
      		$('.product8dialog').hide();
      });
	  
	  // Product 9
	  $(".product9open").bind("click", function(e){
		  var largestZ = 11; // this is the min z-index you would want to apply to the draggable
		  $(".productDialog").each(function(i) {
			  var currentZ = parseFloat($(this).css("zIndex"));
			  largestZ = currentZ > largestZ ? currentZ : largestZ;
		  });
		  $('.product9dialog').show();
		  $(".product9dialog").css("z-index", largestZ + 1);
	  });
	  $('.product9close').click(function(){
      		$('.product9dialog').hide();
      });
	  
	  // Product 10
	  $(".product10open").bind("click", function(e){
		  var largestZ = 11; // this is the min z-index you would want to apply to the draggable
		  $(".productDialog").each(function(i) {
			  var currentZ = parseFloat($(this).css("zIndex"));
			  largestZ = currentZ > largestZ ? currentZ : largestZ;
		  });
		  $('.product10dialog').show();
		  $(".product10dialog").css("z-index", largestZ + 1);
	  });
	  $('.product10close').click(function(){
      		$('.product10dialog').hide();
      });

});