function initCufon() {
	Cufon.replace(' #nav a, .ttl1, .ttl2, h2', { fontFamily: 'RockoFLF', hover: true });
}
/*--- change color ---*/
function colorChange(){
	$('div.changer-holder').each(function(){
		var speed =  300;
		var hold = $(this);
		var links = hold.find('a');
		var _box = $('ul.changer');
		
		var _cookieName = 'lastColor';
		if(getCookie(_cookieName)) $('#header-box').css('background',getCookie(_cookieName));
		if(getCookie('wrapClass')) $('#wrapper').addClass(getCookie('wrapClass'));
	
		hold.mouseenter(function(){
			_box.animate({
				top: 0
			}, {duration: speed, queue: false, complete: function(){
				$(this).css('opacity','auto');
			}});
		}).mouseleave(function(){
			_box.animate({
				top: -39
			}, {
				duration: speed,
				queue: false
			});
		});
		links.click(function(){
			setCookie(_cookieName, $(this).attr('rel'), 60, '/');
			$('#header-box').css('background',$(this).attr('rel'));
			var _class = $(this).parent('li').attr('class');
			$('#wrapper').removeClass();
			$('#wrapper').addClass('wrapper-' + _class);
			setCookie('wrapClass', $('#wrapper').attr('class'), 60, '/');
			// track with piwik
			try {
			piwikTracker.setDocumentTitle("color/" + _class);
			piwikTracker.trackPageView();
			}catch( err ) {}
			return false;
		});
	});
}
function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}
function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name+'='+escape( value ) +
		( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString()
		( ( path ) ? ';path=' + path : '' ) +
		( ( domain ) ? ';domain=' + domain : '' ) +
		( ( secure ) ? ';secure' : '' );
}
function deleteCookie( name, path, domain ) {
	if ( getCookie( name ) ) document.cookie = name + '=' +
			( ( path ) ? ';path=' + path : '') +
			( ( domain ) ? ';domain=' + domain : '' ) +
			';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}
$(document).ready(function(){
	initCufon();
	colorChange();
	// startpage: pull up the wite area
	if($('.promo').length > 0){
		$('#nav a').click(function(){
			var link = $(this);
			$('.promo').height(297).animate({
			   height: '-=297'
			}, 800, function() {
			console.log(this);
			    document.location.href = link.attr('href');
			});
			return false;
		});
	}
	
	// fadein projects
	var delay = 0;
	$('.catmenu').hide().fadeIn(1200);
	//$('.content-holder').hide().fadeIn(1200);
	//$('.aside').hide().delay(500).fadeIn(1200);
	$('.catmenu li').each(function(){
		$(this).hide().delay(delay).fadeIn(500);
		delay += 100;
	});
});

