	$(document).ready(function(){

	// PageLoad function
	// This function is called when:
	// 1. after calling $.historyInit();
	// 2. after calling $.historyLoad();
	// 3. after pushing "Go Back" button of a browser
	function pageload(hash) {
		//alert("pageload: " + hash);
		// hash doesn't contain the first # character.
		if(hash) {
			// restore ajax loaded state
			if($.browser.msie) {
				// jquery's $.load() function does't work when hash include special characters like åäö.
				hash = encodeURIComponent(hash);
				//alert(hash);
			}
		
			$("#load").fadeTo("fast", 0.01, function(){ //fade
             $("#load").slideUp("fast", function() { //slide up
                 //$(this).remove(); //then remove from the DOM
                 $("#load").load("/pages/" + hash + ".php" + "?random=" + Math.random()*99999, function() {
                 
                 	$("#load").slideDown("slow")
                 	$("#load").fadeTo("fast", 1)
                 
                 });
             });
         });
			
		} else {
			// start page
			$("#load").empty();
		}
	}
		
		//apply rounded corners
		$('.rounded').corners();
	
		// Initialize history plugin.
		// The callback is called at once by present location.hash. 
		$.historyInit(pageload, "");
		
		// set onlick event for buttons
		//$("a[rel='history']").click(function(){
		$(".loadClick").click(function(){
			// 
			var hash = this.href;
			hash = hash.replace(/^.*#/, '');
			// moves to a new page. 
			// pageload is called at once. 
			// hash don't contain "#", "?"
			$.historyLoad(hash);
			return false;
		});
		
	$("#splashSet a").hover(function(){
		$(this).children("span").fadeOut();
	}, function(){
		//$(this).children("span").fadeIn();
	})	
	
	if(page==""){
		var t=$("#mainSplashImg");
		var l=$("#mainSplash");
	    var src1= t.attr('src'); // initial src
		var src2 = "/img/splash"+src1.substring(src1.lastIndexOf('/'), src1.lastIndexOf('.'));
	}
	
	$("#tabSet a").hover(function(){
		currentId = $(this).attr('id');
		$(this).children("span").fadeOut();
		var newSrc = src2 + '-' + currentId + '.' + /[^.]+$/.exec(src1);
    	t.attr('src', newSrc);
    	l.children("span").fadeOut();
	}, function(){
		$(this).children("span").fadeIn();
		t.attr('src', src1);
		//l.children("span").fadeIn();
	})	
	
	
		
	$("#printButton").click(function () { 
		$('#interior').jqprint();  
    });

	$(".pseudoClick").hover(function () {
		$(this).addClass("hover");
    }, function () {
		$(this).removeClass("hover");
    });

	var originalFontSize = $('html').css('font-size');
	$(".resetFont").click(function(){
		$('html').css('font-size', originalFontSize);
	});
	  
	// Increase Font Size
	$(".increaseFont").click(function(){
		var currentFontSize = $('html').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum*1.2;
		$('html').css('font-size', newFontSize);
			return false;
	});
	  
	// Decrease Font Size
	$(".decreaseFont").click(function(){
		var currentFontSize = $('html').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum*0.8;
		$('html').css('font-size', newFontSize);
	    	return false;
	});
	
	var click = false;
	
	$("#toggleFont").click(function(){
		var currentFontSize = $('html').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		//alert(currentFontSizeNum);
		if(click==true) {
			var newFontSize = currentFontSizeNum-2;
			click=false;
		} else {
			var newFontSize = currentFontSizeNum+2;
			click=true;
		}
		$('html').css('font-size', newFontSize);
	    	return false;
	});

	});
