jQuery(document).ready(function($) {	
	$('.no-js').removeClass('no-js');

	$(document).pngFix();
	
	// Based of Remy Sharp's Flickr Images
	// http;//remysharp.com
	$('img', '#social').hover(function(ev) {
		$('img', '#social').stop().fadeTo(200, 1).filter(function() {
			return !!(ev.target != this);
		}).stop().fadeTo(200, .5);
	}, function() {
		$('img', '#social').stop().fadeTo(200, 1);
	});
		
	$('a,img').each(function() {
		var title = $(this).attr('title');
		$(this).hover(function() {
			if( title == '' )
				return;
			if( $(this).parents('nav').length || $(this).parents('.wp-pagenavi').length )
				return;
			
			$('body').append('<span class="tooltip">' + title + '</span>');
			$('.tooltip').css('opacity', 0).stop().fadeTo(300, 1);
			$(this).attr('title', '');
			$(this).stop().fadeTo(300, 1)
				.mousemove(function(ev) {
				var pageX = ev.pageX - ($('.tooltip').outerWidth() / 2) + 10,
					pageY = ev.pageY + 20;
				$('.tooltip').css({
					left: pageX,
					top: pageY,
					color: '#fff'
				})
			});
		}, function() {
			$(this).attr('title', title);
			$('.tooltip').remove();
		});
	});
	
	$('input[type=text]', '#searchform').each(function() {
		var text = 'Search ...';
		
		if( $(this).val() == '' )
			$(this).val(text);
			
		$(this).focus(function() {
			if( $(this).val() == text ) {
				$(this).val('');
			}
		}).blur(function() {
			if( $(this).val() == '' ) {
				$(this).val(text);
			}
		});
		
	});
		
	if( !window.location.search )	
		$('#searchform').hide();
		
	$('#search-btn').click(function(e) {
		
		$('#searchform').slideToggle('fast');
		
		e.preventDefault();
	});
	
	//$('body').jwAnnounce({
	//	text: '<p><a href="http://designbyme.lego.com/">LEGO® Digital Designer</a> has just updated and some of our LDD Files need updates. If you have purchased an LDD File and it is not working, please be patient while we fix the files so they can be purchasable.<br />Once the files are fixed, we will send you the updated file.</p>',
	//	siteWidth: 900
	//});
});

// For discussion and comments, see: http://remysharp.com/2009/01/07/html5-enabling-script/
(function(){if(!/*@cc_on!@*/0)return;var e = "abbr,article,aside,audio,canvas,datalist,details,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video".split(','),i=e.length;while (i--){document.createElement(e[i])}})();