jQuery.fn.fadeToggle = function(speed, easing, callback) {
	return this.animate({opacity: 'toggle'}, speed, easing, callback);
};

$(document).ready(function() {
	$('.clicknclear').click(function() {
		$(this).attr('rel', $(this).val());
		$(this).val('');
	}).blur(function() {
		if ($(this).val().length < 1)
			$(this).val($(this).attr('rel'));
	});

	// Expandable content areas
	$('.expand-content').hide();
	$('#expand-link').click(function (e) {
		e.preventDefault();
		$('.expand-content').fadeToggle();
	});

	if (typeof jQuery.fn.fancybox == 'function')
		$('a[rel]="gallery"').fancybox({ 'zoomSpeedIn': 500, 'zoomSpeedOut': 500, 'overlayOpacity': 0.8 }); 


	// Apply date picker if loaded
	if (typeof jQuery.fn.datepicker == 'function')
		$('input.selectdate').datepicker({dateFormat: 'dd/mm/yy', showOn: 'button', buttonImage: '/skin/images/icon-calendar.gif', buttonImageOnly: true});

    $('.submit').change(function () {
	    var form = $(this).parents('form:first');
		form.submit();
		return false;
	});

});
