// remap jQuery to $
(function($){})(window.jQuery);


/* trigger when page is ready */
$(document).ready(function (){

	// your functions go here
	
	if($('#content.home .gallery').length) {
  	$('#content.home .gallery').cycle({
  	  fx:     'scrollLeft',
  	  slideExpr: 'img'
  	});
  }
	
	// add a links list
	if($('#content.our-work .gallery').length) {
	  
  	$('#content.our-work .gallery').each(function(index){
  	  $(this).after('<ol id="gallery-links-'+index+'" class="gallery-links"/>');
  	  
  	  $(this).cycle({
    	  fx:     'scrollHorz',
    	  slideExpr: 'img',
    	  pager:   '#gallery-links-'+index,
        timeout: 0,
    	  pagerAnchorBuilder: pagerFactory,
    	  activePagerClass: 'active-slide'
    	});
  	  
  	//  $(this).children('dl').each(function(img){
  	//    $('.gallery-links-'+index).append('<li id="gallery-'+index+'-slide-'+img+'">'+(img+1)+'</li>');
  	//    $('.gallery-links-'+index).delegate('li', 'click', showSlide);
  	//  });
  	})
  	
  	/*
  	$('#content.our-work .gallery').cycle({
  	  fx:     'scrollLeft',
  	  slideExpr: 'img',
  	  pager:   '.gallery-links',
      timeout: 0,
  	  pagerAnchorBuilder: pagerFactory
  	});
  	*/
  }
  
  function pagerFactory(idx, slide) {
    return '<li><a href="#">'+(idx+1)+'</a></li>';
  }
	
	//$('#content.our-work .gallery').after('<ol class="gallery-links"/>');
	
	//$('#content.our-work .gallery').children('img').each(function(index){
	//  $('.gallery-links').append('<li/>');
	//});

});


/* optional triggers

$(window).load(function() {
	
});

$(window).resize(function() {
	
});

*/
