$(document).ready(function(){
	$("#what-is-fitdeck").hover(function () {
	      if ($("#what-is-fitdeck-expandable").is(":hidden")) {
	        $("#what-is-fitdeck-expandable").show("slow");
	      } else {
	        $("#what-is-fitdeck-expandable").slideUp();
	      }
	});

	$("#what-is-fitdeck-expandable").hide();
});

jQuery(document).ready(function(){








		//Create a lightbox content container
		//Target the lightbox-container-content div to hold your content.
		$('body').append('<div id="popup-container" class="jqmDialog"></div>');
		$('#popup-container').jqm({modal: false,
			onShow: function(hash) {

				//PNG-24 for IE6  supersleight required for buttons in popup.
				//Does not cascade into popup without this.
				//$(hash.w).find('.btn, button').supersleight();
				//$('.PNG24').supersleight({backgrounds: false});
				$(hash.w).show();
			},
			onHide: function(hash) {

				hash.w.fadeOut('1000',function(){

					hash.c.trigger = null;
					hash.c.ajax = null;
					hash.c.target = null;

					var classes = $(hash.w).attr('class');
					var resetclasses = '';
					var classesarray = classes.split(' ');
					$.each(classesarray,
							function( idx, val ) {
								if (val.indexOf('jqm') == 0) {
									var sp = '';
									if (idx > 0) {sp = ' ' + val;}
									else {sp = val;}
									resetclasses += sp;
								}
							}
					);
					$(hash.w).attr( {'class' : resetclasses} );

					hash.o.remove();

          //window location parts
          function pathSplitter($part) {
            pathArray = window.location.pathname.split( '/' );
            return pathArray[$part];
          }

          //address changes
           currentCat = pathSplitter(1);
           currentTitle = $('title').html();
             if ( history.pushState ) {
                  //alert('test');
                  history.pushState( '', '', '/' + currentCat + '/' );
              }
              else {
                  catURL='/' + currentCat + '/';
                  currentURL=window.location.pathname;
                  if(catURL!=currentURL){
                    //alert(currentURL+' != '+catURL);
                    window.location=catURL;
                  }
              }
            $('title').html('FitDeck '+catTitle+' | FitDeck Exercise Playing Cards');

				});
			}
		}).draggable({ handle: '.jqDrag', opacity: 0.5 });



			//product popup.
			$('.trigger-product-popup').click(
					function(event) {


            thisURL=this.href;


						$.get(this.href+'modal/', function(data) {
							$('#popup-container').addClass('product-popup');




							$('#popup-container').html(data);
							$('title').html(newTitle);




							$.swapImage(".swapImage");

							//window location parts
              function pathSplitter($part) {
                pathArray = window.location.pathname.split( '/' );
                return pathArray[$part];
              }

              //address changes
               currentCat = pathSplitter(1);
               currentTitle = $('title').html();
                 if ( history.pushState ) {
                      //alert(thisURL);
                      history.pushState( '', '', thisURL );
                  }
                  else {

                  }

							$('#popup-container').jqmShow();

						});



						event.preventDefault();



					});
			//product popup.
			$('.product-popup-onload').ready(
					function(event) {


						var url = $("body").attr("rel");

						if(url!=undefined) {

						$.get(url+'modal/', function(data) {
							$('#popup-container').addClass('product-popup');



							$('#popup-container').html(data);




							$.swapImage(".swapImage");

							$('#popup-container').jqmShow();





						});

						}

						//event.preventDefault();
					}
			);


/*
	  //Get our elements for faster access and set overlay width
	  var div = $('div.logo-cards-outer'),
	               ul = $('ul.logo-cards'),
	               // unordered list's left margin
	               ulPadding = 0;

	  //Get menu width
	  var divWidth = div.width();

	  //Remove scrollbars
	  div.css({overflow: 'hidden'});

	  //Find last image container
	  var lastLi = ul.find('li:last-child');

	  //When user move mouse over menu
	  div.mousemove(function(e){

	    //As images are loaded ul width increases,
	    //so we recalculate it each time
	    var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;

	    var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
	    div.scrollLeft(left);
	  });

	*/

/*********************
** JQDOCK SETUPS... **
*********************/
    //make images that are not enclosed in anchors clickable...
    //(some will simply reload the current page, but then some of the links will do that anyway, so...)
    //$('div.demo>img').each(function(i){
        //$(this).one('click', function(){ location.href = 'index.php?dt='+(i%5); return false; });
     // });
    //apply jqDock to each of the demo menus, setting varying options for each one...
    /*$('div.demo').each(function(i){ //opts updated so as not to use null as 'don't override default' - jQuery v1.2.5 changed extend() to not ignore nulls!
        var opts = { align:        [ 'bottom', 'right', 'top' , 'middle', 'left', 'center' ][i] || 'bottom' //default
                   , size:         [  48     ,  48    ,  48   ,  48     ,  36   ,  60      ][i] || 36       //default
                   , distance:     [  60     ,  60    ,  60   ,  60     ,  48   ,  80      ][i] || 54       //default
                   , coefficient : [  1.5    ,  1.5   ,  1.5  ,  1      ,  1.5  ,  1.5     ][i] || 1.5      //default
                   , labels:       [  true   ,  'mc'  ,  true ,  'br'   ,  true ,  false   ][i] || false    //default
                   , duration:     500 //default
                     //for menu1 and menu7, set a function to use the 'alt' attribute if present, else construct a PNG path from the 'src'...
                   , source:       (i==0 || i==6) ? function(i){ return (this.alt) ? false : this.src.replace(/(jpg|gif)$/,'png'); } : false //default
                   };
        $(this).jqDock(opts);
      });*/
    //handle clicking label for images within links :
    //if labels are enabled, and you have images within links, clicking on the label
    //will do nothing!
    //in order to get the link to activate you will need to provide some sort of click
    //handler on the image (which jqDock will trigger) - if there is not one already?
    //for example, on everything except #menu1, I will apply the following click handler
    //to all my images-within-links...
    //(ie. clicking a label on an image-within-a-link on #menu1 will still do nothing!)

	var opts =
		  // horizontal Dock with images expanding downwards in the vertical axis...
		{
		  align: 'bottom'
		  // set the maximum minor axis (vertical) image dimension to 48px
		 , size: 95
		 , distance: 75
		 , coefficient: 1.0
		 , labels: false
		 , duration:250

		  // swap 101 for 150 for the larger image...
		, source: function(){ return this.src.replace('101high.jpg','150high.png'); }
		};

  var sports_opts =
      // horizontal Dock with images expanding downwards in the vertical axis...
    {
      align: 'bottom'
      // set the maximum minor axis (vertical) image dimension to 48px
     , size: 106
     , distance: 75
     , coefficient: 1.0
     , labels: false
     , duration:250

      // swap 101 for 150 for the larger image...
    , source: function(){ return this.src.replace('101high.jpg','150high.png'); }
    };

	jQuery('div.logo-cards').not('.sports div.logo-cards').jqDock(opts);

  jQuery('.sports div.logo-cards').jqDock(sports_opts);




});

/*$(function(){

//Get our elements for faster access and set overlay width
var div = $('div.logo-cards'),
             ul = $('div.jqDock'),
             // unordered list's left margin
             ulPadding = 0;

//Get menu width
var divWidth = div.width();

//Remove scrollbars
div.css({overflow: 'hidden'});

//Find last image container
var lastLi = ul.find('li:last-child');

//When user move mouse over menu
div.mousemove(function(e){

  //Fixing ulWidth variable since div will stay the same
  var ulWidth = 100;

  var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
  div.scrollLeft(left);
});
});  */







$('.subnav-box').supersleight();
$('.subnav').supersleight();
$('.subnav_bottom').supersleight();

