// cleartype ie correction
jQuery.fn.fadeTo = function(speed,to,callback) { 
    return this.animate({opacity: to}, speed, function() { 
        if (to == 1 && jQuery.browser.msie)  
            this.style.removeAttribute('filter');  
        if (jQuery.isFunction(callback)) 
            callback();  
    }); 
}; 

$(function(){
	window.defaultStatus="Design + Programming by FEINHEIT kreativ studio · www.feinheit.ch";

    var subnav_height = 0;
    $('#navigation div.sub').each(function(){
        subnav_height = Math.max(subnav_height, $(this).height());
    });

    var $navigation = $('#navigation');
    var nav_height = $navigation.height();

    $navigation.css('height', 45).hoverIntent({
        over: function(){
            $navigation.clearQueue().show().animate({height: subnav_height + 15 + nav_height}, 500);
        },
        out: function(){
            $navigation.clearQueue().animate({height: nav_height}, 500).hide();
        },
        timeout: 700
    });

    $('a.fancybox').fancybox({
        //'transitionIn': 'elastic',
        //'transitionOut': 'elastic',
        //'easingIn': 'easeOutBack',
        //'easingOut': 'easeInBack',
        'cyclic': true,
        'overlayOpacity': 0.7,
        'overlayColor': '#111',
        'padding': 10,
        'changeSpeed': 100,
        'changeFade': 100,
        'speedIn': 200,
        'speedOut': 100,
        //'titlePosition': 'over',
        'titleFormat': function(title, currentArray, currentIndex, currentOpts) {
            var str = '';
            if (title)
                str += title + ' ';

            if (currentArray.length>1)
                str += (currentIndex+1) + '/' + currentArray.length;

            return str;
        }
    });

    $('div.image>a').hide().first().show();
    $('#gallery-thumbnails>a').click(function(){
        var $image = $('#'+this.id.replace(/^thumb/, 'image'));
        if ($image.is(':visible'))
            return false;

        $('div.image>a:visible').fadeOut(100, function(){
            $image.fadeIn(100);
        });

        return false;
    });

	// Fieldtags
	$('form.fieldtag input').fieldtag();

	// Scrollabling
	$(".scrollable").scrollable({
		circular: true
	});
});

// usage: log('inside coolFunc',this,arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  if(this.console){
    console.log( Array.prototype.slice.call(arguments) );
  }
};
