// JavaScript Document
var time2hide;

function showmenu(){
	$('#site_menu .hide').slideDown(400);
	$('#site_menu .more').slideUp(400);
	if(jQuery.support.opacity) {
		$('.phone').fadeOut(300);
	} else {
		$('.phone').hide();
	}
	keepmenu();
}

function keepmenu(){
	if(time2hide) { clearTimeout(time2hide); }
	time2hide = setTimeout("hidemenu()",4000);
}

function hidemenu(){
	$('#site_menu .hide').slideUp(400);
	$('#site_menu .more').slideDown(400);
	if(jQuery.support.opacity) {
		$('.phone').fadeIn(300);
	} else {
		$('.phone').hide();
	}
}

$(function(){
	if(jQuery.support.opacity) {
		$('.lantern,.close_dialog').hover(
			function(){	$('img',this).stop(true,true).fadeIn(300); },
			function(){	$('img',this).fadeOut(600); }
		);
	} else {
		$('.lantern,.close_dialog').hover(
			function(){	$('img',this).stop(true,true).show(); },
			function(){	$('img',this).hide(); }
		);
	}

	if ($.support.opacity || ($.browser.msie && $.browser.version >= 7)) {
		/* Center Dialog */
		$('.dialog').each(function(){ 
			var height = $(this).outerHeight() / 2;
			var width = $(this).outerWidth() / 2;
			
			$(this).css({
				position:'fixed',left:'50%',top:'50%', 
				marginTop:'-'+height+'px',
				marginLeft:'-'+width+'px',
				zIndex:'1000'
			});
		});
	
		$('.open_dialog').live('click',function(e){ e.preventDefault(); $('.dialog').fadeIn(400); });
		$('.close_dialog').live('click',function(e){ e.preventDefault(); $('.dialog').fadeOut(400); });
		
		$('.open_dialog[rel=img]').live('click',function(e){ 
			e.preventDefault();
			var $src = $(this).attr('href');
			$('.lg_img').html('<img src="'+$src+'" alt="New Construction" />');
		});
	}
	
	// Setup Navigation
	$('#site_menu .hide').slideUp(200);
	$('#site_menu .more').css({display:'block'}).mouseover( function(){ showmenu(); });
	$('#site_menu').mouseover( function(){ keepmenu(); });
	
	$('a[href*=www],a[href*=http],a[href*=pdf]').not('a[href*='+location.hostname+']').attr('target','_blank');
	$('a[href*=www],a[href*=http]').not('a[href*='+location.hostname+'],a[href*=livingstone],a:has("img")').append('&nbsp;<small>[GO]</small>');
	$('a[href*=pdf]').append('&nbsp;<small>[PDF]</small>');


});
	
// Load scrollbar after everything has loaded so the height will be proper.	
$(window).load(function(){ $('.scroll').jScrollPane({ scrollbarWidth:25, scrollbarMargin:10, wheelSpeed:30, showArrows:true }); });

