$(function(){
	$('.entry img').hover(function(){
			$(this).animate({opacity:'0.8'},{queue:false,duration:250});
		}, function(){
			$(this).animate({opacity:'1'},{queue:false,duration:250});
		});
});




/* Variables */
var showSb = false;
var curArr = 0;
var cheatcode = "";
var IsAnimate = false;
var IsMouseOver = false;
var recentHash = '';
var hashChange = false;
var mark = /\?/;

/* Settings */
var spArr = 13;
var frRotate = 25;




/* Funcions */
function checkLogo(){
	checkHash();
	if(!IsAnimate && !showSb){
		if(curArr == 1 && !IsMouseOver){
			
			curArr = 0;		
		}else if(curArr == 0 && IsMouseOver){
			
			curArr = 1;
		}
	}
}

function checkHash() {
	if ((window.location.hash != recentHash)) {
		hashChange = true;
		recentHash = window.location.hash;
		var hash = window.location.hash;
		if(hash.match(mark)){
			var splitHash = hash.split(/\?/);
			var section = splitHash[0];
			var item = splitHash[1];
			//directTo(section, item);
			if(section == '#portfolio'){
				path = pathPrefix + item + '.html';
				var projectIndex = jQuery.inArray(path, projects);
				curProject = projectIndex;
				$("#projects").load(path,initProject);
			}
		}
	}else{
		hashChange = false;
	}
}



function toggleSb(byKey){
		var obj = $("#footer");
		var badge = $("#btBar a");
		if (!showSb){
			obj.animate({height:"200px"}, {duration: 400, easing: "easeInOutQuint"});
			badge.animate({backgroundPosition: "0 -20px"}, frRotate);
			badge.animate({backgroundPosition: "0 -40px"}, frRotate);
			badge.animate({backgroundPosition: "0 -60px"}, frRotate);
			badge.animate({backgroundPosition: "0 -80px"}, frRotate);
			badge.animate({backgroundPosition: "0 0px"}, frRotate);
			badge.animate({backgroundPosition: "0 -20px"}, frRotate);
			badge.animate({backgroundPosition: "0 -40px"}, frRotate);
			badge.animate({backgroundPosition: "0 -60px"}, frRotate);
			badge.animate({backgroundPosition: "0 -80px"}, frRotate);;
			showSb = true;
			if (byKey){
				switchArr(0);
			}
		}else{		
			obj.animate({height:"30px"}, {duration: 400, easing: "easeInOutQuint"});
			badge.animate({backgroundPosition: "0 -80px"}, frRotate);
			badge.animate({backgroundPosition: "0 -60px"}, frRotate);
			badge.animate({backgroundPosition: "0 -40px"}, frRotate);
			badge.animate({backgroundPosition: "0 -20px"}, frRotate);
			badge.animate({backgroundPosition: "0 0px"}, frRotate);
			badge.animate({backgroundPosition: "0 -80px"}, frRotate);
			badge.animate({backgroundPosition: "0 -60px"}, frRotate);
			badge.animate({backgroundPosition: "0 -40px"}, frRotate);
			badge.animate({backgroundPosition: "0 -20px"}, frRotate);
			badge.animate({backgroundPosition: "0 0px"}, frRotate);
			showSb = false;
			if (byKey){
				switchArr(1);
			}
		}
}



/* Initialize */
$(document).ready(function(){
	Cufon.replace('#panel p', { fontFamily: 'NeoSans', hover: true});
	Cufon.replace('#panel li', { fontFamily: 'NeoSans Medium', hover: true});
	Cufon.replace('.post h2', { fontFamily: 'DINPro-Bold', hover: true});
	Cufon.replace('.page h2', { fontFamily: 'DINPro-Bold', hover: true});
	Cufon.replace('#comments', { fontFamily: 'NeoSans', hover: true});
	Cufon.replace('#respond h3', { fontFamily: 'NeoSans', hover: true});
	Cufon.replace('#botBar h2', { fontFamily: 'NeoSans', hover: true});
	Cufon.replace('#menu li', { fontFamily: 'NeoSans', hover: true});



	checkHash();
	setInterval(checkLogo, 200);

	$("#btBar").mouseover(function(){
		IsMouseOver = true;
		/*if (!showAbout && !logoIsAnimate){switchLogo(0);}*/
	});
	$("#btBar").mouseout(function(){
		IsMouseOver = false;
		/*if (!showAbout && !logoIsAnimate){switchLogo(1);}*/
	});
	$("#btBar").click(function(byKey){
		toggleSb(false);
		return false;
	});
});