$(document).ready(function() {
	/*
	$("#galleriesMenu ul li a").click(function() {
		$("#galleriesMenu ul li a").removeClass('active');										  
		$(this).addClass('active');										  
		var loadPath = $(this).attr('href');
		$.ajax({
		  url: loadPath,
		  cache: false,
		  success: function(theHTML){
			$("#galleryResultsBox").html(theHTML);
		  }
		});

		return false;
	});
	
	$("##gallerySlider a").click(function () {
		var srcPath =$(this).attr('href');
		$("#galleryLargeImg").attr('src', srcPath);
		return false;
	});*/
	
	//$('ul.lightbox a').lightBox();
	
	$(".accordion").click(function(){
		$(this).siblings('div').slideUp()
		
	});	
	$(".toggleNextDiv").click(function(){
		if ($(this).next('div').css("display") == "none") { 
			$(this).children('span').removeClass('ui-icon-circle-plus').addClass('ui-icon-circle-minus');	
		} else {
			$(this).children('span').removeClass('ui-icon-circle-minus').addClass('ui-icon-circle-plus');	
		}
		$(this).next('div').slideToggle();
		
	});
	
	
	// check if page has a gallery before initing
	var imgGallery = $("ul.overlayGallery a").size(); 
 
	if (imgGallery) { 
		$("ul.overlayGallery a").overlay({
			 target: '#gallery',
			 expose: '#000'
		}).gallery({ speed: 100, template : '${title}' });
	}
	
	$("a[rel]").overlay({
		expose: '#000',
		onBeforeLoad: function() { 
			// grab wrapper element inside content 
			var wrap = this.getContent().find(".contentWrap"); 
 
			// load the page specified in the trigger 
			wrap.load(this.getTrigger().attr("href")); 
		} 
 
	}); 

	/*<!-- set the interval for refreshing, default set to 6.5 seconds -->
	var int = setInterval("refreshHomeSlide()", 15000);*/
	$("#nextRandPic").live('click', function() {
		refreshHomeSlide();								 
	});
});

function refreshHomeSlide() {

	$.ajax({
	   	type: "GET",
	   	url: "overlays/public/home/randomNewPic.cfm",
	   	dataType: "html",
		success: function(htmlResult){
			$('#homeFeature').html(htmlResult);
		}
	});
		

}; 