$(document).ready(function(){

  // animated link anchors
  var anchor = new String(window.location);
  if(anchor.indexOf('#')) {
		var $target = $(window.location.hash), target = window.location.hash;
		if (target) {
			var targetOffset = $target.offset().top;
			$('html').animate({scrollTop: targetOffset}, 400, function() {
				location.hash = target;
			});
		}
	}

	$('a[href*=#]').each(function() {
		if ( location.hostname == this.hostname || !this.hostname && this.hash.replace(/#/,'') ) {
			var $target = $(this.hash), target = this.hash;
			if (target) {
				var targetOffset = $target.offset().top;
				$(this).click(function(event) {
					event.preventDefault();
					$('html').animate({scrollTop: targetOffset}, 400, function() {
						location.hash = target;
					});
				});
			}
		}
	}); 
	
	//$(".galImage").lightBox();
	
	$(".galImage, .imageIndex").colorbox({
		title: function(){ return $(this).attr('title'); },
		maxWidth: '100%',
		maxHeight: '100%',
		scalePhotos: true,
		photo: true,
		rel: "gallery",
		current: function() {
			var url = $(this).attr('href');
    	return '<a href="'+url+'" target="_blank"><img src="/img/colorbox/zoom.png" alt="" /></a>';
		}
	});
	
	$(".galleryList .list .showImage").live("click", function() {
		$(".galleryList .imageIndex").attr("href", $(this).attr("href"));
		$(".galleryList .imageIndex img").attr("src", $("img", this).attr("src"));
		$(".galleryList .imageIndex").attr("title", $(this).attr("rel"));
		if($(this).attr("rel") != "") $(".galleryList .left").fadeIn(500); else $(".galleryList .left").fadeOut();
		$(".galleryList .left span").text($(this).attr("rel"));
		return false;
	})
	
});

