jQuery.fn.log = function() {
	if (window.console && window.console.log) {
        if (arguments.length) {
            console.log("%o args: %o", this, arguments);
        } else {
            console.log(this);
        }        
	}
    return this;
};

function log() {
	if (window.console && window.console.log) {
        console.log.apply(this, arguments);
	}
};

$.beautyOfCode.init();

$(document).ready(function(){

	// #nav
	// $('#nav li a:not(.active)').css({width: '30px'});
	$('#nav li a')
		.click(function(){
			$(this).addClass('clicked');
		})
		.hover(
			function(){
				$(this).stop().animate({width:'85px'}, { duration: 800 }, 'swing');
			},
			function(){
				if (!$(this).hasClass('clicked')) {
					$(this).stop().animate({width:'30px'}, { duration: 500 }, 'swing');
				}
			}
		);

	$('#nav li a').click(function(){
		$.cookie('menuclick', 'true', { path: '/', expires: 1 });
	});

	if ($.cookie('menuclick') != 'true') {
		$('#nav li a.active').css({width: '30px'});
	}
	$.cookie('menuclick', null, { path: '/', expires: 1 });

	setTimeout(function() {
		$('#nav li a.active').animate({width:'30px'}, { duration: 1500 }, 'swing');
	}, 1500);
	
	
	// Scroll to .error
	if ($('.error').size() > 0) {
	    $.scrollTo('.error:eq(0)',1000, {easing: 'swing'});
	}
	// Scroll to .alert
	if ($('.alert').size() > 0) {
	    $.scrollTo('.alert:eq(0)',1000, {easing: 'swing'});
	}
	

    // Contact form
    $('#content form input, #content form textarea').each(function(){
        if ($(this).val() == '' && $(this).attr('title') != '') {
            $(this).prev().hide();
            $(this).val($(this).attr('title'));
            $(this).focus(function(){
                if ($(this).val() == $(this).attr('title')) {
                    $(this).val('');
                }
            });
            $(this).blur(function(){
                if ($(this).val() == '') {
                    $(this).val($(this).attr('title'));
                }
            });
        }
    });

});
