// Sitewide scripts using jquery
//place this at the bottom of other script includes to activate jquery plugins

$(document).ready(function(){ 
// Art and artist rotators
	$("#artist_rotate").innerfade({
		speed: 1000,
		timeout: 5000,
		type: "random",
		containerheight: '150px'
	});
	$("#art_rotate").innerfade({
		speed: 1000,
		timeout: 5000,
		containerheight: '700px'
	});
	$("#presenting").innerfade({
		speed: 1000,
		timeout: 5000,
		containerheight: '100px'
	});
	
//highlight navigation link of selected page
	var path = location.pathname.substring(1); //substring number is the number of characters to leave out from the beginning
	if (path) {
		/*$("#navigation a[href*=" + path + "]").each(function() {
			var src = $(this).children("img").attr("src");
			var new_src = src.replace(/\.(\w+(\?[^$]*)?)$/, '_over.$1');
			$(this).children("img").attr("src", new_src);
		});*/
		$("#navigation a[href*=" + path + "]").addClass("active");
	}

//create rollover images and prelode by passing "true"
	$('img.rollover').rollover(true);
	
//back in history button
	$('a.btn_back').click(function() {
		history.go(-1);
		return false;
	});
	
//Print Page
	$("a.btn_print").click(function() {
		javascript:print(document);
		return false;
	});

//Large Map window
	$("a.map_window").click(function() {
		window.open(this.href, 'Map', 'width=550,height=450,scrollbars=1,resizable=1,status=0,toolbar=0');
		return false;
	});


// colorbox photo gallery
	function tour_slideshow(selector, start) {
		if (start != true) {
			start = false;
			slidestart = false;
		} else {
			slidestart = true;
		}
		
		$(selector).colorbox({
			open: start,
			slideshow: true,
			slideshowAuto: slidestart,
			slideshowSpeed:	5000,
			onOpen:function(){ $('embed, object, select').css({'visibility' : 'hidden'}); },
			onCleanup:function(){ $('embed, object, select').css({'visibility' : 'visible'}); }
		});
	};
	tour_slideshow(".gallery a");

//start tour slideshow
	$('.btn_tour-slideshow').click(function() {
		tour_slideshow($(this).attr("href") + " a", true);
		return false;
	});

	
	
});
