$(document).ready(function() {
    var pathname = $.address.value();
	var pathname = pathname.replace("/", "");
/* 	alert(pathname); */
	if (pathname == "") {
		$('#content_container').load('home.php', function() {
			$('#content_container').animate({opacity: 1}, 1000);		
		});
	} else {
		$('#content_container').load(pathname, function() {
			$('#content_container').animate({opacity: 1}, 1000);		
		});
	}
/* 	setTimeout("$('#content_container').animate({opacity: 1}, 1000)", 1000);  */
    $('#music_box').mouseleave(function() {
    	$('#music_box').animate({top: -200}, 500);
    });
    $('#music_tab').mouseover(function() {
    	$('#music_box').animate({top: 0}, 500);
    });
    $('#music_tab').click(function() {
    	if ($('#music_box').css('top') == "0px") {
    		$('#music_box').animate({top: -200}, 500);
    	} else {
    		$('#music_box').animate({top: 0}, 500);
    	}
    });
 
/*
    $('a').address(function() {
        return $(this).attr('href');
    });
*/

    $('#topnav a').click(function(event) {
    	event.preventDefault();
    	var value = event.value;
    	var pageToLoad = $(this).attr("href");
		$('#content_container').empty();
		$('#content_container').append("<div class='loader'></div>");
    	$('#content_container').load(pageToLoad, function() {
			$('#content_container').animate({opacity: 1}, 500);		
    	});
    });
    $('#bottomnav a').click(function(event) {
    	event.preventDefault();
    	var pageToLoad = $(this).attr("href");
		$('#content_container').empty();
		$('#content_container').append("<div class='loader'></div>");
    	$('#content_container').load(pageToLoad, function() {
			$('#content_container').animate({opacity: 1}, 500);		
    	});
	    $.address.value($(this).attr('href'));
    });
    $('.inner_city').live('click', function(event) {
    	event.preventDefault();
    	var pageToLoad = $(this).attr("href");
		$('#content_container').empty();
		$('#content_container').append("<div class='loader'></div>");
    	$('#content_container').load(pageToLoad, function() {
			$('#content_container').animate({opacity: 1}, 500);		
    	});
	    $.address.value($(this).attr('href'));
    });
    $('#contactform').live('submit', function(event) {
    	event.preventDefault();
		$('#content_container').empty();
		$('#content_container').append("<div class='loader'></div>");
    	$.post('contactformhandler.php', $(this).serialize(), function() {
	    	$('#content_container').load('thankyou.php', function() {
				$('#content_container').animate({opacity: 1}, 500);		
	    	});
    	});
	    $.address.value('thankyou.php');
    });
    $.address.externalChange(function () {
    	var pathname = $.address.value();
		var pathname = pathname.replace("/", "");
		if (pathname == "") {
			$('#content_container').load('home.php');
		} else {
			$('#content_container').load(pathname);
		}
    });
});
