$(document).ready(function() {
	var queryhash = window.location.hash
	switch (queryhash) {
		case "#home":
			document.title = "welcome / marc kimmel / a graphic designer and peripheral visionary from vancouver";
			showelsewhere(true);
			break;
		case "#elsewhere":
			document.title = "elsewhere / marc kimmel / a graphic designer and peripheral visionary from vancouver";
			showelsewhere(true);
			break;
		case "#about":
			document.title = "about / marc kimmel / a graphic designer and peripheral visionary from vancouver";
			showAbout(true);
			break;
		case "#contact":
			document.title = "contact / marc kimmel / a graphic designer and peripheral visionary from vancouver";
			showcontact(true);
			break;
		default:
			showInitial();
			break;
	}
	
	//IE support
	if(!jQuery.support.opacity){
		$('#header h1 span').css('opacity', '0');
		$('#home span').css('opacity', '0');
		$('#elsewhere span').css('opacity', '0');
		$('#about span').css('opacity', '0');
		$('#contact span').css('opacity', '0');
	}
	
  $('#home').click(function(){
		showhome();
	});
	
	$('#elsewhere').click(function(){
		showelsewhere();
	});

	$('#about').click(function(){
		showAbout();
	});

	$('#contact').click(function(){
		showcontact();
	});

});

function showInitial()
{
	$('#nav a').removeClass('active');
	$('#home').addClass('active');
	$('#home-content').slideDown();
}

function showhome(initial)
{
	if(!$('#home').hasClass('active')){
		$('#nav a').removeClass('active');
		$('#home').addClass('active');
		document.title = "welcome / marc kimmel / a graphic designer and peripheral visionary from vancouver";
		if(initial == true){
			$('#home-content').slideDown();
		} else {
			$('#content div:visible').slideUp('normal', function(){
				$('#home-content').slideDown();
			});
		}
	}
}

function showelsewhere(initial)
{
	if(!$('#elsewhere').hasClass('active')){
		$('#nav a').removeClass('active');
		$('#elsewhere').addClass('active');
		document.title = "elsewhere / marc kimmel / a graphic designer and peripheral visionary from vancouver";
		if(initial == true){
			$('#elsewhere-content').slideDown();
		} else {
			$('#content div:visible').slideUp('normal', function(){
				$('#elsewhere-content').slideDown();
			});
		}
	}
}

function showAbout(initial)
{
	if(!$('#about').hasClass('active')){
		$('#nav a').removeClass('active');
		$('#about').addClass('active');
		document.title = "about / marc kimmel / a graphic designer and peripheral visionary from vancouver";
		if(initial == true){
			$('#about-content').slideDown();
		} else {
			$('#content div:visible').slideUp('normal', function(){
				$('#about-content').slideDown();
			});
		}
	}
}

function showcontact(initial)
{
	if(!$('#contact').hasClass('active')){
		$('#nav a').removeClass('active');
		$('#contact').addClass('active');
		document.title = "contact / marc kimmel / a graphic designer and peripheral visionary from vancouver";
		if(initial == true){
			$('#contact-content').slideDown();
		} else {
			$('#content div:visible').slideUp('normal', function(){
				$('#contact-content').slideDown();
			});
		}
	}
}

	// Background Rotation
$(document).ready(function() {
    $('.background').cycle({ 
    fx:      'fade', 
    speed:    1000,
    timeout:  25000,
    random:   1
});
});
$(document).ready(function() {
    $('.caption').cycle({ 
    fx:      'fade', 
    speed:    10,
    timeout:  0,
    next:   '#next', 
    prev:   '#prev'
});
});