$(document).ready(function(){

	$('.links a:not([href*=passovervacations])').addClass('external').attr('target', '_blank');

// front screens
	if ($('#front_screens') !== null) {
	$('#front_screens').cycle({
		speed: 2000,
		timeout: 5000,
		//sync: false,
		random: '1',
		containerheight: '350px'
		});
	}

	$('#frontpage_resorts li a, #footer li a').bigTarget({
		class: 'hover',
		clickZone : 'li:eq(0)'
	});

// front screens
	if ($('.screens') !== null) {
		if ($('.screens li').length > 1) {
			$('.screens ul').cycle({
				speed: 2000,
				timeout: 5000,
				//sync: false,
				random: '1',
				containerheight: '390px'
			});
		}
	}


	if ($('#resort_display')  !== null) {
		$('#resort_display ul').cycle({
			speed: 2000,
			timeout: 5000,
			//sync: false,
			random: '1',
			containerheight: '390px'
		});
	}

	// Latest news
	if ($('#latest_news') !== null) {
		$('#latest_news').cycle({
			fx:	'fade',
			timeout: 5000,
			speed: 1500,
			sync: 0,
			pause: 1,
			slideExpr:'dd',
			cleartype:0
		});
	}

	// Gallery
	if ($('#slideshow') !== null) {
		$('#images').cycle({
    		speed:   600,
   			timeout:  0,
   			sync:1,
   			startingSlide: $('#images').data('start'),
   			next: '#next,#nextArea',
   			prev: '#previous,#previousArea',
   			pager: null,
   			//prevNextClick: prevNextClick,
   			before: onBefore
   		})
	}

	function prevNextClick(isNext, zeroBasedSlideIndex, slideElement) {
		location.hash = "#"+zeroBasedSlideIndex;
	}

	function onBefore() {
		$('#image_actions').html("<a href='"+ $(this).find('img').data('full-src')+ "'>Download this image</a> | <a href='/send-photo-to-a-friend?i_id="+ $(this).find('img').data('attachment-id')+ "'>Email this image</a>");
	}

	$('#print a').popup({
		    width: 780,
		    height: 480
		    });

})

