/// <reference path="jqueryintellisense.js" />
/*
Intro page UI effects and highlight box slideshow effect.
Uses the Revealing Module Pattern.
*/
try {
	var test = COMO.ns;
}
catch (e) {
	COMO = {};
}

COMO.Intro = {};

COMO.Intro.UI = (function($) {
	var ns = 'COMO.Intro.UI';
	var description = 'Enables interactive elements of hotel intro page.';

	function init() {
		// set up the intro text box
		// dragging
		$('#content.intro #bodyholder').draggable({
			containment: 'parent',
			cancel: '.bodytext,.closebutton',
			delay: 100
		});
		// show/hide via slide
		$('#content.intro .closebutton').toggle(function() {
			$('#content.intro .highlights').toggle();
			$('#content.intro .bodytext').slideToggle('fast');
			$('#content.intro .closebutton').removeClass('closebutton').addClass('closebuttonup');
			$('#content.intro .draghandle').addClass('opendrag');
		}, function() {
			$('#content.intro .bodytext').slideToggle('fast', function() {
				$('#content.intro .highlights').toggle();
				$('#content.intro .closebuttonup').removeClass('closebuttonup').addClass('closebutton');
				$('#content.intro .opendrag').removeClass('opendrag');
			});
		});
	}
	return {
		init: init
	};

} (jQuery));

COMO.Intro.Highlights = (function($) {
	var ns = 'COMO.Intro.Highlights';
	var description = 'Handles making a slideshow of the highlight boxes on the intro page.';
	var slideshowEngine;

	// slideshow initialiser
	function createSlideshow() {
		slideshowEngine = new imageslideshowEngine();
		slideshowEngine.images = $('#content.intro .highlights li').get();
		slideshowEngine.init(6000, 700);
	}

	function pause() {
		if (slideshowEngine) {
			slideshowEngine.pauseEngine();
		}
	}
	function unpause() {
		if (slideshowEngine) {
			slideshowEngine.unpauseEngine();
		}
	}

	return {
		ns: ns,
		description: description,
		createSlideshow: createSlideshow,
		pause: pause,
		unpause: unpause
	};

} (jQuery));

COMO.Shortbreaks = (function($) {
	var ns = 'COMO.Shortbreaks';
	var description = 'Enables interactive elements of hotel shortbreak page.';

	function init() {
		$('.shortbreaksclosebutton').toggle(function() {
			$('.shortbreakitemtype').slideToggle('slow');
		}, function() {
			$('.shortbreakitemtype').slideToggle('slow');
			$('.shortbreakitemtype').toggle();
		});
	}

	function inittype() {
		$('.titleimage').toggle(function() {
			$(this).next('.itemlist').slideToggle('slow');
		}, function() {
			$(this).next('.itemlist').slideToggle('slow');
			$(this).next('.itemtype').toggle();
		});

	}

	function initHeader() {

		$('.shortbreakresultarrow').toggle(function() {
			$(this).parent().find('.description').slideToggle('slow');
			$(this).parent().children('.shortbreakresultarrow').attr('src', '/images/arrow_down.gif');
		}, function() {
			$(this).parent().find('.description').slideToggle('slow');
			$(this).parent().children('.shortbreakresultarrow').attr('src', '/images/arrow_right.gif');
			$(this).parent().find('.description').toggle();
		});

		$('.nameclickable').toggle(function() {
			$(this).parent().children('.description').slideToggle('slow');
			$(this).parent().parent().children('.shortbreakresultarrow').attr('src', '/images/arrow_down.gif');
		}, function() {
			$(this).parent().children('.description').slideToggle('slow');
			$(this).parent().parent().children('.shortbreakresultarrow').attr('src', '/images/arrow_right.gif');
			$(this).parent().children('.description').toggle();
		});

		$('.nameclickable').parent().children('.description').hide();
	}

	return {
		init: init,
		inittype: inittype,
		initHeader: initHeader
	};

} (jQuery));

// set up the above items
jQuery(document).ready(COMO.Intro.UI.init);
jQuery(document).ready(COMO.Intro.Highlights.createSlideshow);
jQuery(document).ready(COMO.Shortbreaks.init);
jQuery(document).ready(COMO.Shortbreaks.inittype);
jQuery(document).ready(COMO.Shortbreaks.initHeader);

