jQuery(document).ready(function() {


$('ul#menu-for-homeowners').each(function() {
    $(this).find('li').each(function(i) {
        $(this).find('a').addClass('fancy' + (i+1));
    });
});
$('ul#menu-quick-links').each(function() {
    $(this).find('li').each(function(i) {
        $(this).find('a').addClass('quick' + (i+1));
    });
});
$('ul#menu-frequently-requested-info').each(function() {
    $(this).find('li').each(function(i) {
        $(this).find('a').addClass('requested' + (i+1));
    });
});
$("a.fancy1").fancybox();
$("a.fancy4").fancybox();
$("a.quick1").fancybox();
$("a.requested4").fancybox();
$("a.quick6").fancybox();
$("a.proposalpopup").fancybox();

//	jQuery('#cycle').cycle({
//		fx: 'fade'
//	});

//	jQuery('figure.gallery-item a').attr('rel','gallery');
//	jQuery('figure.gallery-item a[rel="gallery"]').fancybox();
$('#slider3').mbSlider({
     autoplay: true,
     pauseOnHover: true,
     playPauseButtonSeperate: true,
     pagination: true,
     orientation: 'horizontal',
     playDirection: 'right',
     continuous: true,
 	slideDuration: 8000,
     showControls : {
         next: false,
         prev: false,
         play: false,
         pause: false,
         first: false,
         last: false
     }
})



if ($('ul.top-images').length) {
	var toptimer = setInterval(topChanger,4000);
}
function topChanger() {
	$('ul.top-images li').first().hide('slow', function() {
		$(this).appendTo('ul.top-images');
	});
	$('ul.top-images li').eq(4).show('slow');
}

$('form input:text').each(function() {
	if ($(this).attr('title')) {
		$(this).val($(this).attr('title'));
		$(this).addClass('ghost-text');
		$(this).focus(function() {
			$(this).val('');
			$(this).removeClass('ghost-text');
		});
		$(this).blur(function() {
			if ($(this).val().length == 0) {
				$(this).val($(this).attr('title'));
				$(this).addClass('ghost-text');
			}
		});
	}
});

$('div.propsearch select').change(function() {
	$('#propquery').val('');
	if (!$('#propquery').hasClass('ghost-text')) { $('#propquery').addClass('ghost-text'); }
	if ($(this).attr('value') == 'l') {
		$('#propquery').val('zip, address or city');
		$('#propquery').attr('title','zip,address or city');
	} else {
		$('#propquery').val('community name');
		$('#propquery').attr('title','community name');
	}
});

$('div.accordion').each(function() {
	$(this).accordion({
		active:true,
		collapsible:true,
		fillSpace:false,
		autoHeight: false
	});
});

$('input.datepicker').datepicker({
	onSelect:function(dateText,inst) {
		var today = new Date();
		var selectedDate = new Date(dateText);
		var difference = selectedDate - today;
		var days = Math.round(difference/(1000*60*60*24)) + 1;
		if (days < 6) {
			$(this).val('');
			$(this).blur();
			$('#date-error').show('fast');
			$('#closing-request-submit').attr('disabled','disabled');
		} else {
			$('#date-error').hide('fast');
			$('#closing-request-submit').removeAttr('disabled');
		}
	}
});


$('a.screenshot-link').fancybox();
$('a.iframe-link').fancybox({'type':'iframe','width':810,'height':620});
$('a.fancy2').fancybox({'type':'iframe','width':'75%','height':'75%'});
$('a.quick3').fancybox({'type':'iframe','width':'75%','height':'75%'});
$('a.residentlogin').fancybox({'type':'iframe','width':'95%','height':'95%'});

});

