/*
For Home, Overview pages
Uses jquery and jquery.tools
Michael Huang. 
*/
$().ready(function(){

	/********** slideshow **************/
	var scroll = $("div.slideshow").scrollable({
		size: 1,
		items: '.deck',
		interval: 4000,
		speed: 1900,
		loop: true
	});
	/*
	Stop 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;
		}
	});
	/*
	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; }); 
});

