$(document).ready(function(){ 		
	
	$("a[rel='external']").attr("target","_blank"); // open links in new window
	
	/* Cufon font replacement
	********************************/	
	Cufon.replace('#content h2, #content h3, #content .font_impact', { fontFamily: 'Rockwell' });	
	Cufon.replace('#header h1, #content .font_script', { fontFamily: 'Stylograph' });	
	
	
	/* Dropcard Lightbox
	********************************/
	$("#head_dropcard a, #home_dropcard a").colorbox({
		'iframe'		: true,
		'opacity'		: 0.8,
		'innerWidth'	: 470,
		'innerHeight'	: 300,
		'initialWidth'	: 600,
		'initialHeight' : 500
	});
	
	/* Gallery Lightbox
	********************************/
	$("#gallery_thumbs a").colorbox({	
		'opacity'		: 0.8,
		'scrolling'		: false,
		'initialWidth'	: 600,
		'initialHeight' : 500,
		'onComplete'    : function() {
			$("#cboxTitle").hide(); 
			link = $.fn.colorbox.element(); 
			title = $(link).attr("title"); 
			$('<div id="customTitle">'+title+'</div>').insertAfter('#cboxPhoto'); 
			$.fn.colorbox.resize(); 
		} 
	});	
	
	/* Press Items Lightbox
	********************************/
	
	// text
	$("#press_items a.view_text").colorbox({
	    'inline'		: true,
		'href'			: function(){ return $(this).attr('href'); }, 
		'opacity'		: 0.8,
		'scrolling'		: false,
		'innerWidth'	: 710,
		'initialWidth'	: 600,
		'initialHeight' : 500,
		'onComplete'    : function() {
			$("#cboxTitle").hide(); 
			link = $.fn.colorbox.element(); 
			title = $(link).attr("title"); 
			$('<div id="customTitle">'+title+'</div>').insertAfter('#cboxLoadedContent .popup_text'); 
			$.fn.colorbox.resize(); 
		} 
	});	
	
	// image
	$("#press_items a.view_image").colorbox({	
		'opacity'		: 0.8,
		'scrolling'		: false,
		'initialWidth'	: 600,
		'initialHeight' : 500,
		'onComplete'    : function() {
			$("#cboxTitle").hide(); 
			link = $.fn.colorbox.element(); 
			title = $(link).attr("title"); 
			$('<div id="customTitle">'+title+'</div>').insertAfter('#cboxPhoto'); 
			$.fn.colorbox.resize(); 
		} 
	});	
	
	
	/* Show/Hide Lyrics
	********************************/	
	if( $('#lyrics').length > 0 ){	
		
		var showLyricsTxt = '&raquo; show lyrics';
		var hideLyricsTxt = '&laquo; hide lyrics';
		
		$('#lyrics p strong').after('<a class="expander">'+showLyricsTxt+'</a>')		
		
		$("#lyrics .column_one_half:eq(0) .lyrics:gt(0), #lyrics .column_one_half:eq(1) .lyrics:gt(0)").hide();
		
		$("#lyrics .column_one_half:eq(0) .lyrics:eq(0), #lyrics .column_one_half:eq(1) .lyrics:eq(0)")
			.prev().children('a.expander')
				.html(hideLyricsTxt);	
		
		$("#lyrics a.expander").click(function(event) {
			event.preventDefault();
			
			$(this).parent().next('.lyrics:visible')
				.slideUp("fast")
				.prev().children('a.expander').html(showLyricsTxt);				
				
			$(this).parent().next('.lyrics:hidden')
				.slideDown("fast")
				.prev().children('a.expander').html(hideLyricsTxt);
				
			return false;
		});
	}
	
	
	/***
	 Contact form validation
	****************************/	
	
	// validate signup form on keyup and submit
	$("#contact_form").validate({
		errorElement: 'span',
		rules: {
			name: {
				required: true,
				minlength: 2
			},
			email: {
				required: true,
				email: true
			},
			location: {
				minlength: 2
			},
			phone: {
				minlength: 10
			},
			comments: {
				required: true
			}
		},
		messages: {
			name: {
				required: "required field: please enter your name",
				minlength: "error: your name must consist of at least 2 characters"
			},
			email: {
				required: "required field: please enter your email address",
				email: "error: please enter a valid email address"
			},
			location: {
				minlength: "error: your location should consist of at least 2 characters"
			},
			phone: {
				minlength: "error: your phone number should consist of at least 10 digits"
			},
			comments: {
				required: "required field: please enter your query"
			}
		}
	});
	
	
}); 
