var count = 0;

Cufon.replace('.tabitha');

$(document).ready(function(){
	$(function() {
		$('#picture-gallery1 a').lightBox({
			fixedNavigation:true,
			txtImage: '',
			txtOf: '/',
			imageBtnClose: '/images/lightbox-btn-close.gif'
		});
		$('#picture-gallery2 a').lightBox({
			fixedNavigation:true,
			txtImage: '',
			txtOf: '/',
			imageBtnClose: '/images/lightbox-btn-close.gif'
		});
		$('#picture-gallery3 a').lightBox({
			fixedNavigation:true,
			txtImage: '',
			txtOf: '/',
			imageBtnClose: '/images/lightbox-btn-close.gif'
		});
		$('#picture-gallery4 a').lightBox({
			fixedNavigation:true,
			txtImage: '',
			txtOf: '/',
			imageBtnClose: '/images/lightbox-btn-close.gif'
		});
		$('#picture-gallery5 a').lightBox({
			fixedNavigation:true,
			txtImage: '',
			txtOf: '/',
			imageBtnClose: '/images/lightbox-btn-close.gif'
		});
		$('#picture-gallery6 a').lightBox({
			fixedNavigation:true,
			txtImage: '',
			txtOf: '/',
			imageBtnClose: '/images/lightbox-btn-close.gif'
		});				
		$('#picture-gallery7 a').lightBox({			
			fixedNavigation:true,			
			txtImage: '',			
			txtOf: '/',			
			imageBtnClose: '/images/lightbox-btn-close.gif'		
		});
		
		$('.house-row .big-left a, .house-row .tiny-center a').lightBox({
			fixedNavigation:true,
			txtImage: '',
			txtOf: '/',
			imageBtnClose: '/images/lightbox-btn-close.gif'
		});
		
		$('#lightbox-nav-btnNext').removeAttr('href');
	});
	
	$('area').click(function(){
		$('#popup-' + this.id.substring(5)).show();
		$('#mask').show();
	});
	$('area').hover(function(){
		$('#info-' + this.id.substring(5)).show();
	});
	$('area').mouseout(function(){
		$('#info-' + this.id.substring(5)).hide();
	});
	$('.popup .close-bar a').click(function(){
		$('#' + this.id.substring(6)).hide();
		$('#mask').hide();
	});
	$('.popup').click(function(){
		$('#' + this.id).hide();
		$('#mask').hide();
	});
	$("#backtotop").click(function(){
		scroll(0,0);
	});
	
	$(window).scroll(function(){
		count++;
		setTimeout('checkIfScrollFinished('+count+')', 500);
	});
});

function checkIfScrollFinished(countVar)
{
	if (countVar == count)
	{
		var pos = $(window).scrollTop();
		$("#backtotop").animate({ top: pos + 200 + "px" },300);
	}
}
