jQuery.noConflict();
var current_photo_num = 1;
var intervalID;


function nextPhoto() {
	// default to the first edition
	var next_num = 1;
	// get child count
	var children_count = jQuery("#gallery_nav").children().size(); 
	// if current_photo_num is less than to the number of children
	if (current_photo_num < children_count){
		next_num = jQuery("#gallery_nav_button" + current_photo_num).next().attr("id").replace(/gallery_nav_button/,"");		
	}
	clickAction(next_num);
}

function previousPhoto() {
	// get child count
	var children_count = jQuery("#gallery_nav").children().size(); 
	// default to the first edition
	var previous_num = children_count;
	// if current_photo_num is less than to the number of children
	if (current_photo_num > 1){
		previous_num = jQuery("#gallery_nav_button" + current_photo_num).prev().attr("id").replace(/gallery_nav_button/,"");		
	}
	clickAction(previous_num);
}

function clickAction(num) {
	jQuery("#gallery_nav_button" + current_photo_num + " span").removeClass("current");
	jQuery("#photo" + current_photo_num).fadeOut("slow");
	current_photo_num = num;
	jQuery("#gallery_nav_button" + current_photo_num + " span").addClass("current");
	jQuery("#photo" + current_photo_num).fadeIn("slow");		
}



jQuery(document).ready(function(){
    // Preload dropdown menu hover images

 	// initialize gallery on page load
	jQuery("#gallery").each(function(){
		// dir, title, & photos defined in inline js
		if (jQuery(this).attr("class") == "ad") {
			buildGallery(dir,photos,10000);		
		} else {
			buildGallery(dir,photos,5000);
		}
	});

	
});

