$(document).ready (function (){

jQuery.fn.fadeToggle = function(speed, easing, callback) {
	return this.animate({opacity: 'toggle'}, speed, easing, callback);
}; 

	//remove margin from last paragraph in content
	$("div#more-content p:last-child, div.news-detail p:last-child").css({margin:"0"})

	//toggle content
	$("#more").hide();
	
	$("a#show-more").click(function(){
		$("div#more").slideToggle("fast");
		$("div#wrapper").toggleClass("full");
		$(this).slideToggle();
		//$(this).toggleClass("show-less");
		//$(this).text($(this).text() == 'More' ? 'Less' : 'More');
	return false;
	});	
	
	$("a#hide-more").click(function(){
		$("div#more-content").slideToggle("fast");
		$(this).text($(this).text() == 'Hide' ? 'Show' : 'Hide');
		
		if ( $("div#wrapper").hasClass("full") ){
			$("div#wrapper").toggleClass("full");
			$("div#more").slideToggle("fast");
		}else{
			$("a#show-more").slideToggle("fast");
		}
		
	return false;
	});	
	
	
	// prettyPhoto popups
	$("a[rel^='prettyPhoto']").prettyPhoto({
			animationSpeed: 'normal', /* fast/slow/normal */
			padding: 40, /* padding for each side of the picture */
			opacity: 0.8, /* Value betwee 0 and 1 */
			showTitle: false, /* true/false */
			allowresize: false, /* true/false */
			counter_separator_label: ' of ', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'dark_square' /* light_rounded / dark_rounded / light_square / dark_square */
		});
	
	
	// when the form is submitted
		$('form#form-reservations').submit( function(){
		
			var reg_email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/; 
		
			var inputcheck = $('#reserve-name');
			// if field has something in it, do submit actions, otherwise write out error
			if( inputcheck.val() == '' ){
				// add class to change colour
				inputcheck.addClass("required").get(0).focus();
				return false;
			}else{
				inputcheck.removeClass("required");
			}
			
			var inputcheck = $('#reserve-email');
			// if field has something in it, do submit actions, otherwise write out error
			if( inputcheck.val() == '' || !reg_email.test( inputcheck.val() ) ){
				// add class to change colour
				inputcheck.addClass("required").get(0).focus();
				return false;
			}else{
				inputcheck.removeClass("required");
			}
			
			var inputcheck = $('#reserve-enquiry');
			// if field has something in it, do submit actions, otherwise write out error
			if( inputcheck.val() == '' ){
				// add class to change colour
				inputcheck.addClass("required").get(0).focus();
				return false;
			}else{
				inputcheck.removeClass("required");
			}
			
			var inputcheck = $('#reserve-captcha');
			// if field has something in it, do submit actions, otherwise write out error
			if( inputcheck.val() == '' ){
				// add class to change colour
				inputcheck.addClass("required").get(0).focus();
				return false;
			}else{
				inputcheck.removeClass("required");
			}
			
		});
		
		
	// when the form is submitted
		$('form#form-subscribe').submit( function(){
		
			var reg_email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/; 
		
			var inputcheck = $('#name');
			// if field has something in it, do submit actions, otherwise write out error
			if( inputcheck.val() == '' ){
				// add class to change colour
				inputcheck.addClass("required").get(0).focus();
				return false;
			}else{
				inputcheck.removeClass("required");
			}
			
			var inputcheck = $('#jiuiii-jiuiii');
			// if field has something in it, do submit actions, otherwise write out error
			if( inputcheck.val() == '' || !reg_email.test( inputcheck.val() ) ){
				// add class to change colour
				inputcheck.addClass("required").get(0).focus();
				return false;
			}else{
				inputcheck.removeClass("required");
			}
			
		});
		
		
		
		
});