document.documentElement.className += ' js';

(function($){
    //open external links in a new window
    var hostname = window.location.hostname;
    hostname = hostname.replace("www.", "").toLowerCase();
    
    $('a').each(function(){
        if (this.href.indexOf("http://") != -1 && this.href.indexOf(hostname) == -1) {
            this.target = "_blank";
            this.className += " external";
        }
    });
	
	//clear form fields
    $('textarea, :text').bind('focus click', function(){
        if (this.value == this.defaultValue) {
            this.value = '';
        }
    });
	
	$('textarea, :text').bind('blur', function(){
        if (this.value === '') {
            this.value = this.defaultValue;
        }
    });
	
	//validate forms
	$('form').validate({
		errorClass: "invalid",
		validClass: "valid"
	});
	
	//visual stuff
	$('.menu a, .column a, .widget li a').wrapInner('<span></span>');
	
	//spotlight
	$('#spotlight ul').cycle({
		timeout:  8000
	});
	
	
	$('#content .navigation a').each(function(){
		var str = $(this).text();
		if(str.length > 25) {
			$(this).text(str.substring(0, 25) + '...');
		}
	});
})(jQuery);