jQuery().ready(function($) {
	//for fun, we'll write a super simple plug-in
	$.fn.transform = function(funcs) {
		this.each(function() {
			var elem = this;
			$.each(funcs, function(func, val) {
				if (func == 'rotate') {
					rotate(elem, val);
				}
			});
		});
	}

	function rotate(elem, deg) {
		var $elem = $(elem);
    
		if (!$.browser.msie) {
		//do it the easy way
		}
    
		// use parseFloat twice to kill exponential numbers and avoid things like 0.00000000
		var rad = deg * (Math.PI/180),
		costheta = parseFloat(parseFloat(Math.cos(rad)).toFixed(8)),
		sintheta = parseFloat(parseFloat(Math.sin(rad)).toFixed(8));
    
		// collect all of the values  in our matrix
		var a = costheta,
		b = sintheta,
		c = -sintheta,
		d = costheta,
		tx = 0,
		ty = 0;
    
		// Transform the element in IE
		elem.style.filter = 'progid:DXImageTransform.Microsoft.Matrix(M11=' + a + ', M12=' + c + ', M21=' + b + ', M22=' + d + ', sizingMethod=\'auto expand\')';
	}
	if($.browser.msie && $.browser.version<9){
		$('.counter-holder').hide();
	}else{	
		$('.counter-holder').transform({
			rotate: -15
		}); // rotates 45 degrees
	
		function TimeUntil(thedate){	
			dd=parseInt(thedate.getTime())-parseInt((new Date()).getTime());
			dday=Math.floor(dd/(60*60*1000*24)*1);
			dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1);
			dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1);
			dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1);
		
			if(dday==0&&dhour==0&&dmin==0&&dsec==1){			
				return "00:00:00:00";
			}else{
				if(dday<10)dday="0"+dday;
				if(dhour<10)dhour="0"+dhour;
				if(dmin<10)dmin="0"+dmin;
				if(dsec<10)dsec="0"+dsec;
				return dday+":"+dhour+":"+dmin+":"+dsec;			
			}
		}
		var d=new Date("2012/01/01");
		$('#counter').countdown({
			image: themepath+'/js/countdown/img/digits.png',
			startTime: TimeUntil(d),
			digitWidth: 22,
			digitHeight: 32
		});
	}

			  
	
	$('#portfolio-slider').codaSlider({
		dynamicArrows:false,
		dynamicTabsAlign:"right",
		crossLinking:false,
		autoSlide: true,
		autoSlideInterval: 8000,
		autoSlideStopWhenClicked: true, 
		slideEaseDuration:2000
	});
	$("a[rel=external]").attr("target","_blank");
	//$(".contact-page .staff").equalizeCols();
	//$(".contact-page .box").equalizeCols();

	/* Cufon */
	/*function execCufon(){
		//Cufon.replace('h2 a',{hover:{textDecoration:"underline"},textShadow: '0px 1px rgba(50,50,50,50.2)'});
		Cufon.replace('#header .description p strong,h1,h2, h3, h4, h5, h6',{
			hover:{
				"border-bottom":'1px solid #fff'
			},
			hoverables:{
				a:true
			},
			textShadow: '0px 1px rgba(50,50,50,50.2)'
		});
		Cufon.replace('#top-menu ul li a,#header .logo span.location',{
			hover:{
				color: '-linear-gradient(#f1f1f1, #fff)'
			}
		});
	}
	if(!$.fontAvailable('Century Gothic') || $.browser.msie) {
		$("h1 a,h2 a,h3 a,h4 a, h5 a,h6 a").hover(
			function(){
				$(this).css("border-bottom", "1px solid #fff")
			},
			function(){
				$(this).css("border-bottom", "0px solid #fff")
			}
			);
		execCufon();
	}*/

	/* Sticky footer*/
	var heightdiff=0;	
	var bodyheight=$(document.body).height();
	function positionFooter(){		
		heightdiff = $(window).height()-(bodyheight);
		if( heightdiff > 22 ){
			$("#content hr:eq(1)").css({
				"margin-top":heightdiff-22
			});
		}
	}
	positionFooter();
	$(window).resize(positionFooter);

	/*Simple comments*/
	$(".post .postmetadata a.reply").click(function(){
		$("#comment").focus();
		return false;
	});

	
	
});



Cufon.now();

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
try {
	var pageTracker = _gat._getTracker("UA-8243377-1");
	pageTracker._trackPageview();
} catch(err) {}
