$(document).ready(function() {

// SET VERTICAL CENTRE FOR CONTENT

var setCentre = function() {
	var height = $(window).height();
	var offset = (height - 600) / 2;
	$('body').css('padding-top', offset);
	$('#wrapper').css('visibility','visible');
}
setCentre();
$(window).resize(setCentre);


// SLIDESHOW 

$('.slideshow').cycle({ 
    fx:    'fade', 
    speed:  3000,
	timeout: 9000,
	delay: -3000

 });
 

// SCROLLBAR

$('.scroll').jScrollPane();

 
// APARTMENTS - photo polygon image map hover actions

$('.map-lower').mouseover(function() {
	$('#apartment-s1-img').addClass('lower');
}).mouseout(function() {
	$('#apartment-s1-img').removeClass('lower');
});
$('.map-upper').mouseover(function() {
	$('#apartment-s1-img').addClass('upper');
}).mouseout(function() {
	$('#apartment-s1-img').removeClass('upper');
});
$('.map-penthouse').mouseover(function() {
	$('#apartment-s1-img').addClass('penthouse');
}).mouseout(function() {
	$('#apartment-s1-img').removeClass('penthouse');
});


// APARTMENTS - do some z-index magic to handle overlapping apartment images

$('ul.map li a').mouseover(function(e) {
	$(e.target).css('z-index', 4);
});
$('ul.map li a').mouseout(function(e) {
	$(e.target).css('z-index', 1);
});


// GALLERY CONTROLS

if ($('.gallery')) {
	var gallery = $('.gallery .block');
	var thumbs = $('.carousel li');
	thumbs.click(function(e) {
		e.preventDefault();
		gallery.removeClass('active');
		var orderNo = thumbs.index(this);
		$('.gallery .block:eq(' + orderNo + ')').addClass('active');
	}); 
}
 
// FORM CONTENT SWITCHER 

$('.section1 button').click(function(e) {
	e.preventDefault();
	$('.section1').css('display','none');
	$('.section2').css('display','block');
});


});

