$(document).ready(function(){
	//external attribute
	$('a[rel="external"]').click(function(){
		$(this).attr('target','_blank');
	});
	// teaser hover
	$('#music-teaser a, #pdm-teaser a, #about-teaser a').fadeTo(300, 0.6);
	$('#music-teaser a, #pdm-teaser a, #about-teaser a').hover(function() {
		$(this).fadeTo(300, 1).find('img').stop().css({'border-color' : '#FC6'});
	},function(){
		$(this).fadeTo(300, 0.6).find('img').stop().css({'border-color' : '#383E41'});
	});
	// book dt
	$('.book_now').click(function(){
		$('#booking-form').dialog({title: 'Book Derick', width: 515, modal: true});
		return false;
	});
	// nav
	$('.page-item-116 a').css('width', '90px').after('<em>New</em>'); // products
	$('.page-item-79 a').css('width', '110px').after('<em>New</em>'); // the manual
	// datepicker
	$('.date-picker').datepicker();
	// slide nav --- discography
	$('#discography ul').kwicks({max: 280, duration: 500, easing: 'easeOutQuad', complete: 'callback'});
	// alter post comment button
	$('#submit').replaceWith($('<button id="submit" type="submit">Post Comment</button>'));
	// recent post truncation
	$('.recent-comment p').truncatable({limit: 100, more: '...', less: true, hideText: '[hide]'});
	$('.recent-comment p a').click(function(){
		return false;
	});
	// newsletter
	$('#newsletter-wrapper a').click(function(){		
		if ($("#newsletter:hidden").length == 1) {
			$("#newsletter").animate({
				left: "+=70", 
				opacity: "toggle"
			}, 500);
		} else {
			$("#newsletter").animate({
				left: "-=70", 
				opacity: "toggle"
			}, 500);
		}
		return false;
	});
	// the manual
	$('.buy-manual-annually').click(function(){
		$('#manual-annually').submit();
		return false;
	});
	$('.buy-manual-quarterly').click(function(){
		$('#manual-quarterly').submit();
		return false;
	});
	// basic show / hide
	$('.this-title').click(function(){
		if ($(this).next().is(':visible')) {				
			$(this).next().slideUp(300);
		} else {
			$('.this-title').next().slideUp(300);
			$(this).next().slideToggle(300);
		}
		return false;
	});
});
