/*
	I Love Bass v3
	
	Global Scripts
*/

$(document).ready(function() {
	
	/* Easter Egg */
	$('#easterEgg').bind('click', function() {
		if(!$(this).hasClass('opened')) {
			$(this).animate({
				height: '450px',
			}, 1000, function() {
				$(this).addClass('opened');
				$(this).prepend('<span style="display:block;padding-top:25px;"><object width="980" height="395"><param name="movie" value="http://www.youtube.com/v/dQw4w9WgXcQ&autoplay=1"></param><embed src="http://www.youtube.com/v/dQw4w9WgXcQ&autoplay=1" type="application/x-shockwave-flash" width="980" height="395"></embed></object></span>');
			});
		}
	});
	
	/* Header Dropdown */
	$('nav a.hoverTag').hover(function() {
		hover = 1;
		element = $(this);
		name = element.html().toLowerCase();
		
		if(!$(this).hasClass('hover')) {
			hover = 2;
			$('nav a.hoverTag').removeClass('hover');
			$('#'+name).slideDown(100);
			$(this).addClass('hover');
		} else { setTimeout(setHover,5); }
	},
	function() {
		$('#'+name).hover(function() { hover = 3; }, function() { hover = 2; setTimeout(hideItNow,5); });
		setTimeout(hideItNow,5);
	});
	
	function hideItNow() { if(hover == 2) { $(element).removeClass('hover'); $('#'+name).hide(); } }
	function setHover() { hover = 2; }
	
	/* Header Search / Upcoming Submit : Click Status */
	$('#search,.submit input.left,.submit input.right,.clickable').bind('click', function(e) {
		
		$('#search,.submit input.left,.submit input.right,.clickable').removeClass('active');
		var element = $(this);
		
		$(this).addClass('active');
		$('body').live('click', function() { $(element).removeClass('active'); });
		
		e.stopPropagation();
	});
	
	/* Placeholder backup */
	$('[placeholder]').focus(function() {
		var input = $(this);
		if (input.val() == input.attr('placeholder')) {
			input.val('');
			input.removeClass('placeholder');
		}
	}).blur(function() {
		var input = $(this);
		if (input.val() == '' || input.val() == input.attr('placeholder')) {
			input.addClass('placeholder');
			input.val(input.attr('placeholder'));
		}
	}).blur().parents('form').submit(function() {
		$(this).find('[placeholder]').each(function() {
			var input = $(this);
			if (input.val() == input.attr('placeholder')) {
				input.val('');
			}
		})
	});
	
});
