// This is the default Blueprint javascript lib for this site.

function initPage() {
  // initMasonry();
  if (typeof window.location.hash == "string" && window.location.hash) {
    var klass = window.location.hash.replace(/^#/, '');
    setTagClass(klass);
  }
  // $("#tagNav a").click(clickTagNav);
}

function setupSlideshow(pageId) {
  $('#slideshow' + pageId).cycle({
    fx:       'scrollLeft',
    speed:    'fast',
    delay:    -50000000000,
    next:     '#next' + pageId,
    prev:     '#prev' + pageId 
  });
  
  $('#next' + pageId).click(function() { 
      $('#slideshow' + pageId).cycle('pause'); 
  });
  
  $('#prev' + pageId).click(function() { 
      $('#slideshow' + pageId).cycle('pause'); 
  });
}

var hide_menu = function(target) { $(target).fadeOut(150);};

function setup_submenu(trigger, target) {
  $(trigger).click(
    function() {
      $('.popUpMenu:not('+ target +')').hide();
      $(target).stop(true, true).toggle();      
      $(target + ' .closeBox').click(
        function() {
        hide_menu(target);
      });
    },
    function() {
    }
  );
}


// function initMasonry() {
//   $('#folio').masonry({ singleMode: true, itemSelector: '.post' });
// }


// function setTagClass(klass) {
//   $("#folio div.box").filter("." + klass).fadeTo("fast", 0);
//   $("#folio div.box").not("." + klass).fadeTo("fast", 1.0);
// }
// 
// 
// function clickTagNav(evt) {
//   var klass = $(this).attr("id");
//   setTagClass(klass);
// }

// function setupSlideshow() {
//   $('#slideshow').cycle({
//     fx:       'scrollLeft',
//     speed:    'fast',
//     delay:    -50000000000,
//     next:     '#next',
//     prev:     '#prev'
//   });
//   
//   $('#next').click(function() { 
//       $('#slideshow').cycle('pause'); 
//   });
//   
//   $('#prev').click(function() { 
//       $('#slideshow').cycle('pause'); 
//   });
//   
// }




function setupArtistGallery() {
  $('#gallery').cycle({
    fx:       'scrollLeft',
    speed:    'fast',
    delay:    -50000000000,
    next:     '#next',
    prev:     '#prev',
   pager:    '#thumbnails',

   // callback fn that creates a thumbnail to use as pager anchor 
   pagerAnchorBuilder: function(idx, slide) { 
     return '<li><a href="#"><img src="' + jQuery(slide).children("a").eq(0).children("img").eq(0).attr("src") + '" width="47" height="47" /></a></li>'; 
   }
  });
  
  $('#next').click(function() { 
      $('#gallery').cycle('pause'); 
  });
  
  $('#prev').click(function() { 
      $('#gallery').cycle('pause'); 
  });
  
}

function setupCaseStudy() {
  $('#gallery').cycle({
    fx:       'scrollLeft',
    speed:    'fast',
    delay:    -50000000000,
    next:     '#next',
    prev:     '#prev',
		pager: 		'#thumbnails',

	  // callback fn that creates a thumbnail to use as pager anchor 
	  pagerAnchorBuilder: function(idx, slide) { 
	    return '<li><a href="#">'+ (idx+1) +'</a></li>'; 
	  }
  });
  
  $('#next').click(function() { 
      $('#gallery').cycle('pause'); 
  });
  
  $('#prev').click(function() { 
      $('#gallery').cycle('pause'); 
  });
  
}

// function setupNewSlideshow() {
//    $('#showImage').click(function() {
//      $('#artistsWall').slideToggle('fast', function() {
//        // Animation complete.
//      });
//    });
// }


$(window).bind('load', initPage);
