function _refresh(_x,_y) {$(_x).hover(function(){$(this).addClass('hover');},function() {$(this).removeClass('hover');setTimeout(function(){Cufon.refresh(_y)}, 10);});}
function initCufon() { Cufon.replace('#nav, .main-menu a, h1,', { fontFamily: 'Breuer Text Medium', hover: true}); }

jQuery.timer = function(time,func,callback){
	var a = {timer:setTimeout(func,time),callback:null}
	if(typeof(callback) == 'function'){a.callback = callback;}
	return a;
};

jQuery.clearTimer = function(a){
	clearTimeout(a.timer);
	if(typeof(a.callback) == 'function'){a.callback();};
	return this;
};

jQuery(document).ready(function(){
	initCufon();
  	var loopTimer = { };

  	jQuery.changeFocus = function(to) {
  		jQuery.clearTimer(loopTimer);
  		var billede = jQuery("#animation-image" + to + "");
  		billede.stop().fadeTo(500,1);
  		var andrebilleder = jQuery("#images img");
  	  	andrebilleder.not(billede).stop().fadeTo(500,0);
		var antal = andrebilleder.length;
    	var nyFocus = parseInt(to)+1;
    	if(nyFocus > antal) { var nyFocus = 1; }
    	loopTimer = jQuery.timer(4000,"jQuery.changeFocus(" + nyFocus + ")");  
    }
    jQuery.changeFocus(1);
    loopTimer = jQuery.timer(4000,"jQuery.changeFocus(2)");

});

