(function($){

$(document).ready(function(){
	$('#color-select li a').hover(function(){ 
		$('#color-select span').toggleClass('active');
		var text = $(this).text();
		$('#color-select span').text(text);
	});
	
	$('#color-select').mouseleave(function(){ 
		if (!$('#color-select li a').hasClass('current')) {
			$('#color-select span').html('<em>view by</em> COLOR');
		};
	});
	
	$('#navigation li').hover(function(){ 
		var dd = $(this).find('ul');
		if ( dd.length) {
			if ($(dd).is(':animated')) {
				return false;
			}
			$(this).children('a:first').addClass('hover');
			$(dd).slideDown();
		};
	}, function() {
		var dd = $(this).find('ul');
		if ( dd.length) {
			$(this).children('a:first').removeClass('hover');
			$(dd).slideUp();
		};
	});
	
	$('#fav-wrapper li').hover(function(){ 
		var url = $(this).children('a').attr('href');
		$(this).children('.text').stop().fadeTo(300, 1);
		
		$(this).children('.text').click(function(){ 
			window.location = url;	
		});
	}, function() {
		$(this).children('.text').stop().fadeTo(300, 0);
	});
	
	$('.blink').
	    focus(function() {
	        if(this.title==this.value) {
	            this.value = '';
	        }
	    }).
	    blur(function(){
	        if(this.value=='') {
	            this.value = this.title;
	        }
	    });
	    
	// Apply PNG Fix for Internet Explorer 6
	if($.browser.msie && $.browser.version.substr(0,1) == 6) {
		DD_belatedPNG.fix('h1#logo a img, #navigation, .favs-callout img, .list-posts .post-entry h3, .post-single .post-title, .fullscreen');
	}
	
	/*
	var $gallery = $('a[rel=gallery]').colorbox({ opacity: 1 });
	$('a.fullscreen').click(function(e){
	  e.preventDefault();
	  $gallery.eq(0).click();
	});
	*/

	$('*[data-opacity]').each(function() {
		$(this).css('opacity', $(this).attr('data-opacity'));
	});

	$('#navigation > ul > li:last').addClass('last');
	

	$('*[data-toggle]').click(function() {
		$($(this).attr('data-toggle')).toggle();
		if ($($(this).attr('data-toggle')).is(':visible')) {
			$(this).html($(this).html().replace('hide', 'show'));
		} else {
			$(this).html($(this).html().replace('show', 'hide'));
		}
		
		return false;
	});
	
	$('#navigation a:contains("Categories")').click(function() {
		return false;
	});
	
});

})(jQuery)
