$(document).ready(function() {
  $('.fancybox').click(function(e) {
    e.preventDefault();
    
    var galleryName = $(this).data('gallery');
    var num = 1;
    var list = [];
    
    switch(galleryName) {
      case 'insert-name-here':
        num = 1;
        break;
      case 'city-info-panel':
      case 'taxi-top-side':
      case 'airport-banner':
      case 'airport-digital':
        num = 2;
        break;
      case 'bus-full-wrap':
      case 'bus-king-headliner':
      case 'bus-kong':
      case 'bus-queen':
      case 'bench1':
      case 'bench2':
      case 'bus-michelangelo':
      case 'bus-take-one':
      case 'street-kiosk':
      case 'mall-elevator':
      case 'mall-banner':
      case 'mall-dio':
      case 'mall-table':
      case '30-sheet':
      case '8-sheet':
      case 'bulletin':
      case 'taxi-top':
      case 'taxi-full-wrap':
      case 'subway-dio':
      case 'subway-2-sht':
      case 'telephone-kiosk':
      case 'train-2-sht':
      case 'train-dio':
      case 'airport-baggage-dio':
      case 'gas-pump-top-digital':
        num = 3;
        break;
      case 'airport-gate-dio':
      case 'bus-king-kong':
      case 'bus-stop-wrap':
      case 'gas-pump-top':
        num = 4;
        break;
      case 'bus-king':
      case 'bus-tail':
      case 'bus-int-top':
      case 'bus-int-front':
      case 'airport':
      case 'bus':
      case 'bus-bus-stop':
      case 'bus-full-back':
      case 'bus-stop':
      case 'digital':
      case 'subway':
      case 'train':
      case 'bus-exterior':
      case 'bus-interior':
      case 'subway-int-horiz':
      case 'subway-int-vert':
      case 'train-int-horiz':
      case 'train-int-vert':
      case 'mobile':
      case 'taxi-trunk':
        num = 5;
        break;
          }
    
    for(var i = 1; i <= num; i++) {
      list.push({'href': '/images/' + galleryName + '-' + i + '-500x375.jpg'});
    }
    
    $.fancybox(list);
  });
  
  $('table.alt-rows').each(function() {
    altRows($('thead', this), 'tr', true);
    altRows($('tbody', this), 'tr', false);
  });
});

function altRows(selector, subselector, start) {
  var addClass = 'dark';
  
  if (typeof (subselector) == 'undefined') {
    $(selector).each(function () {
      if ($(selector).index(this) % 2 === 0) {
        $(this).addClass(addClass);
      }
    });
  }
  else {
    $(selector).each(function () {
      var altcntr = 0;
      
      $(subselector, this).each(function () {
        if(altcntr == 0) {
          if(start) {
            $(this).addClass(addClass);
          }
          
          altcntr++;
        }
        else {
          if(!start) {
            $(this).addClass(addClass);
          }
          
          altcntr = 0;
        }
        
        $('td', this).each(function() {
          var rs = $(this).attr('rowSpan');
          if(rs > 1) { $(this).addClass('white'); }
        });
      });
    });
  }
}

$(document).ready(function() {
	$('div.nav2 a, nav a').each(function() {
		if(location.pathname == $(this).attr('href')) {
			$(this).addClass('active');
		}
	});
});

/*Instructions at www.randomsnippets.com/2008/02/12/how-to-hide-and-show-your-div/*/
function toggle() {
	var ele = document.getElementById("toggleText");
	var text = document.getElementById("displayText");
	if(ele.style.display == "block") {
    		ele.style.display = "none";
		text.innerHTML = "Back to reading more.";
  	}
	else {
		ele.style.display = "block";
		text.innerHTML = "Read less.";
	}
}


