//Script.js

$(document).ready(function() {
	//----------------------------------------------- Document Ready : begin
	$("#gallery-scroll").scrollable({circular: true}).navigator();
	
	var shadowbox_conf = {
		animate: true,
		animateFade: true,
		animSequence: "sync",
		modal: false,
		showOverlay: true,
		overlayColor: "#000",
		overlayOpacity: "0.8",
		flashBgColor: "#000000",
		autoplayMovies: true,
		showMovieControls: true,
		slideshowDelay: "3",
		resizeDuration: "0.35",
		fadeDuration: "0.35",
		displayNav: true,
		continuous: true,
		displayCounter: true,
		counterType: "default",
		counterLimit: "10",
		viewportPadding: "20",
		handleOversize: "resize",
		handleUnsupported: "link",
		autoDimensions: false,
		initialHeight: "160",
		initialWidth: "320",
		enableKeys: true,
		skipSetup: false,
		useSizzle: false,
		flashParams: {bgcolor:"#000000", allowFullScreen:true},
		flashVars: {},
		flashVersion: "9.0.0"
	};
	Shadowbox.init(shadowbox_conf);
		
	$('#nav li:first-child').addClass('nav-first');
        $('#nav li:last-child').addClass('nav-last');
	$('ul.list-links li:nth-child(2n+2)').addClass('list-links-pair');
	$('.grid-holder .grid:nth-child(3n+3)').addClass('grid-last');
	$('#accordion ul:first').addClass('list-first');
	$('ul.gallery li:nth-child(4n+4)').addClass('img-right');
  	$('.gallery-nav').hAlign();
	
	

	$(".slidetabs").tabs(".images > div.pane", {
		effect : 'fade',
		fadeOutSpeed : "slow",
		rotate : true
	}).slideshow({
		autoplay : true,
		autopause : true,
		interval : 5000,
		clickable : false
	});

	$("#accordion").tabs("#accordion ul", {
		tabs : 'h6',
		effect : 'slide',
		initialIndex : null
	});

	//equalHeight($(".equal-height"));
	
	
	$(".grid, .info-img").click(function(event){
		event.preventDefault();
		window.location=$(this).find("a").attr("href");
	});
	
	

	//----------------------------------------------- Document Ready : end
});

$(window).load(function() {
	if($(".slidetabs").length > 0) {
		$(window).focus(function() {
			$(".slidetabs").data("slideshow").play();
		});

		$(window).blur(function() {
			$(".slidetabs").data("slideshow").stop();
		});
	}
});
/*function equalHeight(group) {
	var tallest = 0;
	group.each(function() {
		var thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}
*/
	$.fn.hAlign = function() {
		return this.each(function(i){
		var ah = $(this).width();
		var ph = $(this).parent().width();
		var mh = ((ph - ah) / 2);
		$(this).css('margin-left', mh);
		});
	};
        



