/*
For Home, Overview pages
Uses jquery and jquery.tools
Michael Huang. 
*/
$().ready(function(){
	/********** tooltips **************/
	$(".tt-trigger").tooltip({
		position: "top center",
		relative: true
	});

	/********** slideshow **************/
	window.slideshow_api = $("div.slideshow")
		.scrollable({
			size: 1,
			items: '.deck',
			keyboard: false
		})
		.circular()
		.navigator()
		.autoscroll({
			interval: 8000,
			api: true
		});
	/*
	Pause slideshow if buttons are clicked
	*/
	$(".deck_navi a").bind('click', function(e) {
		/*var slideshow = $(this).parent().siblings('div.slideshow');
		if (slideshow.scrollable) {
			slideshow.scrollable().getConf().interval = 0;
		}*/
		slideshow_api.pause();
	});
	/*
	Tie all elements on slides to the slide img for clicks
	*/
	$(".deck .slide *").click(function (e) {
		// if the element is not a link, then tie it to the slide img
		if (!(this.tagName.toLowerCase() == 'a')) {
			//console.log($(this).closest('.slide').find('a'));
			// find the link of the slide img and click it
			$(this).closest('.slide').find('a').click();
		}
		e.stopPropagation();
	});
	/* set up clicking of links as per http://groups.google.com/group/jquery-dev/browse_thread/thread/b003dfcb30600fb2/5ef2a28f3aa2beb1?#5ef2a28f3aa2beb1 */
	$('.slide a').bind('click', function(event) { window.location = this.href; }); 
});
