
jQuery.noConflict();
			(function($) { 
$(document).ready(function() {
  
  // vars
  var useLightbox229   = 1;
  var largectrls229    = 0;
  var showTitle = 1;
  //var timeout       = '4000';

  // slideshow container
  var $ss229  = $('#slideshow229');
  
  // add interface prev|next
  if (largectrls229) {
    $ss229.before('<a class="csc-ctrl csc-btn csc-prev" href="">prev</a><a class="csc-ctrl csc-btn csc-next" href="">next</a>');
  } else {
    $ss229.before('<a class="csc-ctrl csc-btn csc-prev hidden" href="">prev</a><a class="csc-ctrl csc-btn csc-next hidden" href="">next</a>');
  }
 
  // add interface lightbox
  if (largectrls229 && !useLightbox229) {
    $ss229.before('<a class="csc-ctrl csc-play no-box" href="">play</a>');
  }

  // add interface play|pause & lightbox
  if (largectrls229 && useLightbox229) {
    $ss229.before('<a class="csc-ctrl csc-play" href="">play</a>');
    $ss229.before('<a rel="lightbox229" class="csc-ctrl csc-btn csc-box" id="csc-lightbox-229" href="">box</a>');
  }

  // remove single image from container
  $ss229.empty();

  // build playlist from #nav ul li a
  $('#nav229 a').each(function(index) {
    
    // vars & objs
    var ltbox = $(this).attr('rel');
    var href = $(this).attr('href');
    var title = $(this).attr('title');
    if (title) {
      var caption = title;
      title = ' title="'+title+'"';
    }
    var imageHeight = '';
    imageHeight = $('#slideshow229').height();
    var rel = '';
    //var img = new Image();

    // get img attr
    //$(img).attr('src', ltbox);
	//$(img).load(function() {
    //	imageHeight = $(this).attr('height');
    //
	//});
    
    //$(img).attr('src', ltbox);
    //imageHeight = $(img).attr('height');
    //imageWidth = $(img).attr('width');

    // check for urls
     if (href.substr(-3)!= 'jpg') {
       rel = '';
     } else {
      rel = ' rel="lightbox229"';
     };

    // enable <a>-wrapping for lightbox
    if (useLightbox229) {
    	if (showTitle) {
      $ss229.append('<div style="width:100%; height:'+imageHeight+'px;"><a href="'+this.href+'"'+rel+''+title+'><img src="'+ltbox+'" /></a><p class="caption" style="position:absolute; bottom:0;">'+caption+'</p></div>');
    	} else {
      $ss229.append('<div style="width:100%; height:'+imageHeight+'px;"><a href="'+this.href+'"'+rel+''+title+'><img src="'+ltbox+'" /></a></div>');
        }
    } else {
		if (showTitle) {
      $ss229.append('<div style="width:100%; height:'+imageHeight+'px;"><img src="'+ltbox+'" /><p class="caption">'+caption+'</p></div>');
    	} else {
      $ss229.append('<div style="width:100%; height:'+imageHeight+'px;"><img src="'+ltbox+'" /></div>');
      }
    }
  
  });

  // configure play/pause btn
  $('.csc-play').click(function() {
      $(this).toggleClass('csc-paused');
      $('.csc-btn').toggleClass('hidden');
      $ss229.cycle('toggle');
      return false;
  }).hover(function () {
      $ss229.cycle('pause');
      $(this).removeClass('csc-paused');
      $('.csc-btn').removeClass('hidden');
  });;

  // configure the slideshow 
  $ss229.cycle({
    height            : 233,
    //fit               : 1,
    //pagerEvent        : 'mouseover',
    pauseOnPagerHover : 1,
    //containerResize     : 0,
    timeout           : 4000,
    speed             : 'slow',
    pause             : 1, 
    next              : '.csc-next',
    prev              : '.csc-prev',
    manualTrump       : true,
    pager             : '#nav229',
    pagerAnchorBuilder: function(idx, slide) { 
        return '#nav229 li:eq(' + idx + ') a';
    },
    after             : function (curr,next,opts) {
        $('#csc-lightbox-229').attr('alt', opts.currSlide);
    }
  }).cycle('resume');

  // add keyboard functionality
  $(document).keydown(function(e){
    //alert (e.which);
    if(e.which == 37 || e.which == 80){ $('.csc-prev').click();}
    else if(e.which == 39 || e.which == 78){ $('.csc-next').click();}
    else if(e.which == 32){ $('.csc-play').click();}
    else return;
  });
  
  // init lightbox
  $lbox229 = $( '#slideshow229 a[rel="lightbox229"]').fancybox({
      cyclic          : 0,
      transitionIn    : 'elastic',
      transitionOut   : 'elastic',
      changeFade      : 0,
      overlayOpacity  : 0.9,
      overlayColor    : '#000',
      swf             : {
  			wmode : 'transparent',
  			allowfullscreen : 'true'
  		},
  		titleShow: 1,
    	//showCloseButton	: false,
    	titlePosition 		: 'inside',
    	//titleFormat		: formatTitle,
    	onComplete	:	function() {
    		$("#fancybox-wrap").hover(function() {
    			$("#fancybox-title").show();
    		}, function() {
    			$("#fancybox-title").hide();
    		});
    	}

  });
  
  // bind lightbox-click to #box-btn
  $("a#csc-lightbox-229").click(function(){
//    $("#slideshow229 a").eq($(this).attr('alt')).trigger('click');
    $lbox229.eq($(this).attr('alt')).trigger('click');
    $ss229.cycle('pause');
    $('.csc-play').removeClass('csc-paused');
    return false;
  });
  
});})(jQuery);

/*
  $("#slideshow229 img").slimbox({}, function(el){
    return [el.alt];
  });
*/




