var cont_pages = 1;
var cont_gallery_photos = 0;
var cur_photo = 0;
var cur_page = 0;
jQuery(document).ready(function() {
	jQuery('#nav li').hover(function(){ jQuery(this).addClass("hover");}, function(){ jQuery(this).removeClass("hover");});
	cont_pages = jQuery('#page-content .cont_split').size();
	if(cont_pages>1) {
		jQuery('.readmore_nav').css("visibility","visible");
		launch_readmore();
	}
	cont_gallery_photos = jQuery('#photo_strip img').size();
	if(cont_gallery_photos>1) {
		jQuery('#photostrip_nav a#psn_next').css("visibility","visible");
		cont_gallery_photos--;
		launch_gallerynav();
	}
});

var launch_readmore = function() {
	jQuery(".rmnav").click(function(){
		if(jQuery(this).hasClass("disabled")) {
			return false;
		}
		direction = (jQuery(this).attr("id")=="readmore_next") ? 1 : -1 ;
		cur_page = cur_page + direction;
		jQuery(".cont_split:visible").slideUp("slow");
		jQuery(".cont_split").eq(cur_page).slideDown("slow");
		jQuery(".rmnav").removeClass("disabled");
		if((cur_page+1)==cont_pages) {
			jQuery("#readmore_next").addClass("disabled");
		}
		if(cur_page==0) {
			jQuery("#readmore_prev").addClass("disabled");
		}
		return false;
	});
}

var photo_area_width = 755;
var launch_gallerynav = function() {
	jQuery("#photostrip_nav a").click(function(){
		nextpos = (jQuery(this).attr("id")=="psn_next") ? (cur_photo * photo_area_width) + photo_area_width : (cur_photo * photo_area_width) - photo_area_width;
		jQuery("#photo_strip").animate({ left:-nextpos }, 1500, "swing");
		cur_photo = (jQuery(this).attr("id")=="psn_next") ? cur_photo+1 : cur_photo-1;
		jQuery('#photostrip_nav a#psn_next').css("visibility",((cur_photo==cont_gallery_photos)? "hidden" : "visible" ));
		jQuery('#photostrip_nav a#psn_prev').css("visibility",((cur_photo==0)? "hidden" : "visible" ));
		return false;
	});
}