$(document).ready(function() {
  
	unitform();
	closeunitform();
	hoverbox();
	dropdownnav();
	nofollow();
	
	$('#banner').after('<div id="pager">').cycle({ 
    fx:     'fade', 
    speed:  1000, 
    timeout: 4000, 
    pager:  '#pager',
		after: onAfter,
		before: onBefore
	});
	$('#quotes').cycle({ 
    fx:     'fade', 
    speed:  1000, 
    timeout: 8000
	});
});

function unitform() {
	$('.unitform').click(function(){
		$unitno = $(this).attr('href');
		$location = $(this).attr('title');
		$subject = $location + ' Unit Number ' + $unitno;
		$('#subject').val($subject);
		$('#mask, #formwrapper').show();
		return false;
	});
}
function nofollow() {
	$('.unitlink').click(function(){
		return false;
	});
}
function closeunitform() {
	$('#close a').click(function(){
		$('#mask, #formwrapper').hide();
		return false;
	});
}
function hoverbox() {
	$('.unit').hover(function(e){
  	$('.unit').not(this).hide();
		var position = $(this).find('.unitlink').position();
		var left = position.left-142; 
		var bottom = position.top;
		$(this).find('.unitlink').next('.hoverbox').css({left: left+'px', bottom: '-'+bottom+'px'});
		$(this).find('.hoverbox').show();
	}, function(e){
		$('.unit').show();
		$('.hoverbox').hide();
	});
}
function dropdownnav() {
	$('.droplist').hover(function(e){
  	$(this).find('.dropdown').show();
	}, function(e){
		$('.dropdown').hide();
	});
}
/*function hoverboxshow() {
	$('.unitlink').hover(function(e){
  	$(this).next('.hoverbox').show();
	}, function(e){
		$('.hoverbox').delay(800).fadeOut();
	});
}
function hoverbox() {
	$('.hoverbox').hover(function(){
  	$(this).show();
	}, function(){
		$('.hoverbox').delay(800).fadeOut();
	});
}*/
function onAfter() {
	$(this).find('.bannerdetail').animate({
		top: "213px"
	}, 300);
}
function onBefore() {
	$(this).prev().find('.bannerdetail').animate({
		top: "324px"
	}, 300);
	$(this).next().find('.bannerdetail').animate({
		top: "324px"
	}, 300);
}
