$(document).ready(function(){
	if($.browser.msie && $.browser.version == 8) {
	    //$('#ie-info').text('You are using IE8 in version '+ document.documentMode +' compatible mode.');
	}
	
	var base_url_1 = 'http://www.chevychase.emilolsson.com';
	var base_url_2 = 'http://www.chevychase.emilolsson.com/';
	var base_url_3 = 'http://chevychase.emilolsson.com';
	var base_url_4 = 'http://chevychase.se/';
	var pathname = window.location;

	$.historyInit(function (hash) {
		if(hash) {
		
			if (hash == 'about') {
			
		    	$("#content").empty();
				$("#load").show();
				$("#content").fadeTo(0, 0);
				$("#content").load(""+base_url_4+"?p=2", {}, function(){
   					$("#load").hide();
   					$("#content").fadeTo(100, 1);
				});
				
			}
			
			else if (hash == 'process') {

		    	$("#content").empty();
				$("#load").show();
				$("#content").fadeTo(0, 0);
				$("#content").load(""+base_url_4+"?p=61", {}, function(){
   					$("#load").hide();
   					$("#content").fadeTo(100, 1);
				});
				
			}
			
			else if (hash == 'contact') {

		    	$("#content").empty();
				$("#load").show();
				$("#content").fadeTo(0, 0);
				$("#content").load(""+base_url_4+"?p=343", {}, function(){
   					$("#load").hide();
   					$("#content").fadeTo(100, 1);
				});

			}
			
			
			else if (hash.substr(0,4) == 'per_') {
				var permfix = hash.substr(4);
				
				$("#content").empty();
				$("#load").show();
				$("#content").fadeTo(0, 0);
				$("#content").load(""+base_url_4+"?p=" + permfix, {}, function(){
   					$("#load").hide();
   					$("#content").fadeTo(100, 1);
   					
					//$("#wrap_new").load("http://chevychase.emilolsson.com/?p=188 #e_wrap", {}, function(){

   					//});
   					
   				});
			
				
			}
			
			else if (hash.substr(0,4) == 'tag_') {
				var permfix = hash.substr(4);
				$("#content").empty();
				$("#load").show();
				$("#content").fadeTo(0, 0);
				$("#content").load(""+base_url_4+"?tag=" + permfix, {}, function(){
   					$("#load").hide();
   					$("#content").fadeTo(100, 1);
   					//alert('ok');
   					}
				);
			
				
			}
			
			else {
		    	$("#content").empty();
				$("#load").show();
				$("#content").fadeTo(0, 0);
				$("#content").load(""+base_url_4+"?tag=all", {}, function(){
   					$("#load").hide();
   					$("#content").fadeTo(100, 1);
				});
				alert("This page doesn't excist. Don't try to be creative with the Urls :). You are being redirected to the overview.");
			}
 			
		    
		} else {
				//alert('lsakdldk');
		    	$("#content").empty();
				$("#load").show();
				$("#content").fadeTo(0, 0);
				$("#content").load(""+base_url_4+"?tag=all", {}, function(){
   					$("#load").hide();
   					$("#content").fadeTo(100, 1);
				});
		}
	});
	
	
	if (pathname == base_url_4) {
				//alert('asdsdj');
		    	$("#content").empty();
				$("#load").show();
				$("#content").fadeTo(0, 0);
				$("#content").load(""+base_url_4+"?tag=all", {}, function(){
   					$("#load").hide();
   					$("#content").fadeTo(100, 1);
				});
	} else {}
	
	
	$(".history a").live('click', function(){
    	var hash = this.href;
    	var hash = hash.substr(26);
    	var hash = hash.replace(/\//,"");
		hash = 'tag_' + hash.replace(/^.*#/, '');
    	$.historyLoad(hash);
		return false;
	});
	
	$(".st-tag-cloud a").live('click', function(){
    	var hash = this.href;
    	var hash = hash.substr(26);
    	var hash = hash.replace(/\//,"");
		hash = 'tag_' + hash.replace(/^.*#/, '');
    	$.historyLoad(hash);
		return false;
	});
	
	$(".menushiz a, .entry a").live('click', function(){
		var hash = this.href;
		hash = hash.replace(/^.*#/, '');
		$.historyLoad(hash);
		return false;
	});
	
	
	$(".next_post a").live('click', function(){
		var hash = this.href;
		hash = hash.replace(/^.*#/, '');
		$.historyLoad(hash);
		return false;
	});
	
});