 function buildGridPage() {
     var maxShowingImage = 0;
     var gridClickCt = 0;
     var numberOfBoxes = $('.grid-box').length;
     var gridSliderHeight = (numberOfBoxes/3)*152;
     
     var visibleGridRows = 0;
     var wHeight = windowHt();
     var showingImage = 0;
     
     $('#gridset .grid-box').each(function (index) {
     	$(this).addClass('GridBoxer'+index).hide();
     
     });
     
     
     $('body, #footer').css('background-color', '#1D2122');
     $('#background').fadeIn();
    // setGridSetHeight(wHeight);
     $('.content-holder').attr('id', '');
     $('.content-holder').attr('id', 'grid-page');
     var gPageH = $('.content-holder').height();
     $('.content-holder').css({
        // height: '2900px'
     });
     $('#gridset .grid-box').each(function (index) {
         $(this).addClass('sort');
         var newRGB = Math.floor(Math.random() * 100);
         $(this).css('background-color', 'rgb(' + newRGB + ',' + newRGB + ',' + newRGB + ')')
     });


          setTimeout(function() {
          	 addBoxes(0,8);
          }, 2000); 

     var absNum = function (n) {
             roundedNum = Math.floor(n);
             return roundedNum;
         }

     function setGridSetHeight(wHt) {
      /*
   if (wHt >= 0 && wHt <= 720) {
             var gsHt = 152;
             visibleGridRows = 1;
	       //  setTimeout(function () {
	         	addBoxes(0,2);
	       //  }, 3000);
             
             
         } else if (wHt >= 751 && wHt <= 873) {
             var gsHt = 304;
             visibleGridRows = 2;
	      //   setTimeout(function () {
	         	addBoxes(0,5);
	      //   }, 3000);
         
         } else
*/ if (wHt >= 300) {
             var gsHt = 456;
             visibleGridRows = 3;
	      //   setTimeout(function () {
	         	addBoxes(0,8);
	      //   }, 3000);
         }
		//isDivHidden();
         $('#gridset, #grid-mask').css('height', (gsHt) + 'px');
          gridClickCt = visibleGridRows;
          //$('#info').append(gridClickCt+'<br>');
         //$('#info').html((wHt) + 'px');
     }
     $('.grid-arrow').click(function () {
     	$(this).hide();
/*
         var thisArrowDirection = $(this).attr('id');
         if (thisArrowDirection == 'down-arrow') {
             var gsAnimateDirection = '-=152';
*/
             gridClickCt++;
/*
         } else {
             var gsAnimateDirection = '+=152';
             gridClickCt--;
         }
*/
         $('#grid-slider').animate({
            // top: gsAnimateDirection
         }, 500, "easeInQuint", function () {
         });
               addScrollerBoxes(gridClickCt);
     });  
     
           function addScrollerBoxes(gCt) {
           	   var scrollCount = 0;
     		   var currentGSHeight = windowHt();
     		   var addCounter = 1;
     		   $('.grid-box').each(function(index){
     		   		if ($(this).css('display') != 'none'){
     		   			scrollCount++
     		   		}
     		   });
     		   
               var sid = setTimeout(showScrollerBoxes, 200);
               
               function showScrollerBoxes() {
               		
                       	
	                       		 $('.GridBoxer' + scrollCount).fadeIn(500, function(){
	                       			$(this).find('.grid-pic').delay(1000).fadeIn(500);
	                       		});
	                       	
                       	
                      
                       
                       sid = setTimeout(showScrollerBoxes, 200);
                       if (addCounter == 3) {
                             abortScrollerBoxesTimer();
                       }
                       
                       scrollCount++;
                       addCounter++;
                       
                }
      
               function abortScrollerBoxesTimer() {
                       clearTimeout(sid);
                       var maxClicks = (numberOfBoxes / 3)-3;
				         if (gCt >= maxClicks) {
				             $('#down-arrow').hide();
				         } else {
				             $('#down-arrow').delay(1000).fadeIn();
				         }         
                       scrollToBottom();
               }       

       }  
     
     
     
        function addBoxes(currentBackIngBox,maxGridBoxes) {

     		   var currentGSHeight = windowHt();
     		  // $('#info').html(currentGSHeight);
     		   
               var gid = setTimeout(showGridBox, 200);
               function showGridBox() {
               		
                       $('.GridBoxer' + currentBackIngBox).each(function() {
                       		if ($(this).css('display') == 'none'){
	                       		$(this).fadeIn(500, function(){
	                       			$(this).find('.grid-pic').delay(1000).fadeIn(500);
	                       		});
	                       	}
                       	});
                      
                       
                       gid = setTimeout(showGridBox, 200);
                       if (currentBackIngBox == maxGridBoxes) {
                             abortBoxTimer();
                       }
                       currentBackIngBox++;
                       
                }
      
               function abortBoxTimer() {
                       clearTimeout(gid);
                       $('#down-arrow').delay(2000).fadeIn();
                       
               }       

       }
       
       $('.title').click(function(){
       	scrollToBottom();
       });
       function scrollToBottom(){
       //window.scrollTo(0, document.body.scrollHeight);
       $('html, body').animate({ 
		   scrollTop: $(document).height()-$(window).height()}, 
		   1000, 
		   "easeInQuint"
		);
       
       }	
       
       
       $('#search-right .icon').hover(
		  function () {
		  	$('#search-right .icon').find('span').hide();
		    $(this).find('span').fadeIn();
		  }, 
		  function () {
		    	$('#search-right .icon').find('span').hide();
		  }
		);
       
       
       
       
          $('#search-right .icon').click(function () {
                  var proType = $(this).attr('id');
                  
                  if (proType != 'all'){
                  
                  $('#search-right .icon').addClass('off').removeClass('on');
                  $(this).removeClass('off').addClass('on');
                  $('#gridset').fadeOut('slow', function () {
                          $('.grid-box').hide();
                          $('.grid-box').each(function (index) {
                              //    $(this).removeClass('sort');
                                  $('.' + proType + '').show().find('img').fadeIn(); //.addClass('sort');
                                  
                          });
                          $('#gridset').fadeIn('slow');
                  });
                  
                  } else {
                  
                  $('#search-right .icon').addClass('off').removeClass('on');
                  $(this).removeClass('off').addClass('on');
                  $('#gridset').fadeOut('slow', function () {
                          $('.grid-box').each(function (index) {
                                  $(this).show().find('img').fadeIn(); 
                                  
                          });
                          $('#gridset').fadeIn('slow');
                  });
                  
                  
                  
                  }
          });
          
          
/*
          $('#hide-categories, #show-categories').click(function () {
              //    $('#show-categories').toggle();
            //      $('#hide-categories').toggle();
                  $('#search-bottom').slideToggle({
                          duration: 500,
                          queue: false,
                          complete: function () {
                                  var toggleOff = $('#show-categories').is(':visible');
                                  $('.grid-box').each(function (index) {
                                          $(this).show().addClass('sort');
                                  });
                                  $('#search-type').find('span').html('');
                               //   alignBoxes();
                          }
                  });
          });       
       
*/
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
 } 

