﻿      function imgClickHandler()
      {
         $(".StoneBox img").click( function() {       
            if ($(this).siblings('input').attr('checked') === true)
               $(this).siblings('input').attr('checked', false);
            else
               $(this).siblings('input').attr('checked', true);
            //updateCount();
         });
         
         $(".ColorBox div").click( function() {       
            if ($(this).siblings('input').attr('checked') === true)
               $(this).siblings('input').attr('checked', false);
            else
               $(this).siblings('input').attr('checked', true);
            //updateCount();
         });
         
         $("#BBOnly").click( function() {
           $("#BBOnlyBott").attr('checked', this.checked);
         });
         
         $("#BBOnlyBott").click( function() {
           $("#BBOnly").attr('checked', this.checked);
         });
         
      }

/*      function CheckBoxClickHandler()
      {
         $("input[type=checkbox]").change( function() {
            updateCount();
           });
      }
      
	   function updateCount()
	   {
	      var cList = GetColorList();
	      var sList = GetShapeList();
	      var tList = GetTypeList();

         var parmString = "{'cList':'" + cList + "','sList':'" + sList + "','tList':'" + tList + "'}";
         
         $.diamondAjax({           
          type: "POST",
          url: "/products/gemstones.aspx/GetStoneCount",          
          data: parmString,
          contentType: "application/json; charset=utf-8",
          dataType: "json",          
          //error: function(req, msg, err) { ShowError(req, msg, err);}, 
          success: function(msg) {
             $('#cntStones').html(msg.d);
          }
        });
	      
	   }
	   
      function ShowError(req, msg, err)
      {
         alert(req.responseText);         
      }*/

      function select_stone(id) {
         if ($('#' + id).attr('checked') === true)
            $('#' + id).attr('checked', false);	   
         else
            $('#' + id).attr('checked', true);	   
      } 
	   
	   function SubmitPage()
	   {
	      var cList = GetColorList();
	      var sList = GetShapeList();
	      var tList = GetTypeList();
   
         var redir = "/products/listing_gems.aspx?cid=3478";
         
         if (cList.length > 0) 
            redir = redir + "&colorfamily=" + cList;
            	    
         if (sList.length > 0) 
            redir = redir + "&stoneshape=" + sList;
                     
         if (tList.length > 0)
            redir = redir + "&intcatpath=" + tList;
            
         if ($('#BBOnly').attr('checked') === true || $('#BBOnlyBott').attr('checked') === true)
            redir = redir + "&serialized=BlackBox";
            
         window.location = redir;
	   }   
	   function GetColorList()
	   {	
     	   var colorlist = [];
    	   var CheckBoxIDs = $('.ColorCheck');
         for(var n = 0; n < CheckBoxIDs.length; ++n){            
            if (CheckBoxIDs[n].checked === true){                       	            
   	         colorlist.push(CheckBoxIDs[n].id);
            }
         }
         return colorlist.join(',');
      }
      
      function GetShapeList()
    	{    	
    	   var CheckBoxIDs = $('.StoneCheck');
   	   var shapelist = [];
    	   var tmpshape;
    	   var shape;
    	   for (var i = 0;i < CheckBoxIDs.length; i++) {
    	         if (CheckBoxIDs[i].checked === true){
    	            tmpshape = CheckBoxIDs[i].id;
    	            switch(tmpshape)
    	            {
    	               case "AntiqueSquare":
    	                  shape = "Antique Square";
    	                  break;
    	               case "StraightBaguette":
    	                  shape = "Straight Baguette";
    	                  break;
    	               case "TaperedBaguette":
    	                  shape = "Tapered Baguette";
    	                  break;    	                  
    	               case "Pear":
                        shape = "Pear Shape";
                        break;
                     case "Heart":
                        shape = "Heart Shape";
                        break;
                     case "Emerald":
                        shape = "Emerald, Emerald/Octagon";
                        break;
                     case "Princess":
                        shape = "Square";
                        break;
                     case "AntiqueCushion":
                        shape = "Antique Cushion";
                        break;
                     case "other":
                        shape = "Asscher,Barrel,Chevron,Fan,Flanders,Kite,Lozenge,Onion,Radiant,Shell,Half Moon,Octagon,Briolette";
                        break;
                     default:
                        shape = tmpshape;
                  }
  	               shapelist.push(shape);
    	         }
    	      }    	      
    	   return shapelist.join(',');    	   
    	}
	   
	   function GetTypeList()
	   {
    	   var typelist = [];
    	   var CheckBoxIDs = $('.TypeCheck');
         for(var n = 0; n < CheckBoxIDs.length; ++n){            
            if (CheckBoxIDs[n].checked === true){      
               typelist.push(CheckBoxIDs[n].value + '|' + CheckBoxIDs[n].id.replace(/^chk/, '').replace(/\_/g,' '));        // If you change the IDEncoding of the stonetype change it here to 
               /*if (CheckBoxIDs[n].id == 'Pearl')
                  typelist.push('Pearl,Pearls');
               else             	            
                  typelist.push(CheckBoxIDs[n].id); */
            }
         }
         return typelist.join(',');
	   }
	   
	   function SearchSN()
	   {
	      var sn = $('#serialnumber').val();
	      if (sn.length > 0) 
	         window.location = "/products/largegemstonedetails.aspx?sn=" + sn;
	      else
	         alert('Please enter a serial number');
	   }

     function Reset()
     {
        var ChkBoxIDs = $('input[type=checkbox]');
        for (var i = 0;i < ChkBoxIDs.length; i++) {
    	      ChkBoxIDs[i].checked = false;
        }
        //updateCount();
     }