$(document).ready(function(){

	// slide show for homepage
	$('#slideshow img').removeClass('hide');
	$('#slideshow').cycle({
		fx:     'scrollUp', 
		speed: 'slow'
	 });
	
	$('.post img').hide();
	pageController.init();
});

window.onload = function(){
	$('.post img').fadeIn('slow');
}

function titleOver(e) {
	e.style.opacity = 0.5;
	e.style.filter = "alpha(opacity=50)";
}

function titleOut(e) {
	e.style.opacity = 1;
	e.style.filter = "alpha(opacity=100)";
}

var pageController = {
	// will store the url
	browserAddress : "",
	
	init: function(){
		// add url to browserAddress variable
		this.browserAddress = window.location.href;
		// and array with all the pages
		pages = ['/about/', '/collections/', '/category/diary/', '/press/'];
		//loop through all the pages and see if we're on that page
		for(var i = 0; i < pages.length; i++){
			// sent the page string to another function
			this.seeIfItsActive(pages[i]);
		}
	},
	
	seeIfItsActive: function(stringToCompareToUrl){
		// if the url contains the page string
		if(this.browserAddress.indexOf(stringToCompareToUrl) != -1){
			// add active class to it
			$(".nav li a[href*='"+stringToCompareToUrl+"']").addClass('active');
		}
	}
}