$(document).ready(function(){
	  // selects divs (pages) hides them except the first one
	  var tabContainers = $('div.tabs > .contentbox');
	  tabContainers.hide().filter(':first').show();
	  // selects the loginbox divs and hides them
	  var loginbox = $('.loginbox');
	  loginbox.hide();
	  
	  //function that controls the change
	  $(window).bind('hashchange', function () {
		// selects hash part of url and defaults home
		var hash = window.location.hash || '#home';
		
		//hides all divs except the hash one
		tabContainers.hide();
		tabContainers.filter(hash).show();
		//hides all loginboxes except the current one
		var currentlogin = hash +'_login';
		loginbox.hide().filter(currentlogin).show();
		//displays selected class tab
		$('div.tabs ul.tabNavigation a').removeClass('selected');
		$('a[hash=' + hash + ']').addClass('selected');
		//displays appropriate image in header
		var hash2 = hash.replace('#', '');
		var currentpic = hash2 +'_pic.jpg';
		$('#header').css('background-image', 'url(images/'+currentpic+')');
	  });
	  
	  //everytime the window url gets updated runs function
	  $(window).trigger("hashchange");
	
});
