/* Author: 
thisispete
*/

if (typeof console == 'undefined') {
	var console = {};
	console.log = function(msg) {
		return;
	};
}


$(document).ready(function(){
	setTimeout(scrollTo, 5, ($("body").width() / 2) -($("#container").width()/2) -72, 1);
	var initialTab = 'About';
		
	if (window.location.pathname.indexOf(".html") > -1) {
		var filename = window.location.pathname.substring(window.location.pathname.lastIndexOf("/") + 1, window.location.pathname.indexOf(".html"));
		if(filename!="index")
			initialTab = filename.substring(0,1).toUpperCase() + filename.substr(1);
	}
	if (window.location.hash == "") {
		$.address.value(initialTab);
	}
		
	$("#navigation li a").removeAttr("href");
	$("#navigation li a").click(function(){
		$.address.value($(this).attr('id'));
	});
	$("#navigation li a").removeClass("navigationSelected");
	$("#"+initialTab.toLowerCase()).addClass("navigationSelected");
	
	$.address.init(function(event) {
		$("#content:first-child").attr('id', initialTab);
	})
	$.address.change(function(event) {
		var selection = event.value.substr(1);
		selection==""?selection:initialTab;
		$.address.title($.address.title().split(' | ')[0] + ' | ' + event.value.substr(1));
		$("#navigation li a").removeClass("navigationSelected");
		$("#"+selection).addClass("navigationSelected");
		selection = selection=="About" ? "index":selection;
		
		$("#headImage").append("<div></div>");
		$("#headImage div:last").load(selection.toLowerCase()+".html #headImage div >*", function(){
			$(this).hide();
			$(this).fadeIn(500, function(){
				$("#headImage div:first").remove();
			});
		});
		$("#content").before("<div></div>");
			$("#content").prev().load(selection.toLowerCase()+".html #content > *", function() {
				$(this).hide();
				$(this).delay(100).fadeIn(500).attr("id", "content");
				$(this).next().fadeOut(100,function(){$(this).remove();});
//				$(".lightbox").fancybox({'overlayColor'	: '#000','overlayOpacity'	: 0.7})
				$('a.[rel="facebox"]').facebox();
			});
	})
	$.address.history(true);
	preload(['images/headers/head0.jpg',
		'images/headers/head1.jpg',
		'images/headers/head2.jpg',
		'images/headers/head3.jpg',
		'images/headers/head4.jpg',
		'images/headers/head5.jpg',
		'images/headers/head6.jpg',
		'images/headers/head7.jpg',
		'images/headers/head8.jpg',
		'images/headers/head9.jpg'
	]);
	
	

});

function preload(arrayOfImages) {
	$(arrayOfImages).each(function(){
		$('<img/>')[0].src = this;
	});
}


function nextmonth() {
var cmonth= new Number(document.webervations_calendar.month_num.value);
var nmonth=cmonth+1;
if (nmonth == 13) {
	nmonth=1;
	}
document.webervations_calendar.month_num.value = nmonth;
document.calendar.src='http://www2.webervations.com/calendars/calendar_6106_avail'+nmonth+'.gif';
}

function lastmonth() {
cmonth=Number(document.webervations_calendar.month_num.value);
nmonth=cmonth-1;
if (nmonth == 0) {
	nmonth=12;
	}
document.webervations_calendar.month_num.value = nmonth;
document.calendar.src='http://www2.webervations.com/calendars/calendar_6106_avail'+nmonth+'.gif';
}












