jQuery.preloadImages = function() 
{
  for(var i = 0; i<arguments.length; i++) 
  {
  jQuery("<img>").attr("src", arguments[i]);
  }
}

$.preloadImages("");

//sidenav on and off states
function sidenav(a)
{
	$('#nav-list>li>a').removeClass('active');
	$(a).addClass('active');
}
//hide other sections and show active one
function show_tier(tier)
{
	$('#tier-plans>div').css({'display' : 'none'});
	$(tier).css({'display' : 'block'});
}
//change header image
function change_hdr(file)
{
	$('#container #right #content h1').css({ 'background-image':'url(/images/floorplans/headers/' + file + ')'});
}
// (div to show, header file to change to, tag to add active class to, tier plan to show)
function show_section(div,a,tier)
{
	$('#fp-left>div').css({'display' : 'none'});;
	$(div).css({'display' : 'block'});
	//makes 'a' and 'tier' optional parameters
	if (typeof a != 'undefined')
	{
		sidenav(a);
	}
	if (typeof tier != 'undefined')
	{
		show_tier(tier);
	}
	
}


$(document).ready( function() 
{  
    
	$('A[rel="external"]').click( function() 
	{
        window.open( $(this).attr('href') );
        return false;
    }); 

	

	
//side nav on, off, and roll states

	$('#nav>li').bind('onState',function()
	{	
		
		$(this).find('a').addClass('on');
	}
		
	).bind('rollState',function()
		{
			$(this).find('a').addClass('roll');		
		}
	).bind('outState',function()
		{
			$(this).find('a').removeClass('roll');
		}
	).hover(function()
		{
			if(!$(this).is('.active'))
			{
				$(this).trigger('rollState');
			}
		},
		function()
		{
			if(!$(this).is('.active'))
			{
				$(this).trigger('outState');
			}
		}		
	);
	
	//TOP NAV
	var a = document.URL.split("//"); // split at protocol
	a = (a[1] ? a[1] : a[0]).split("/");
	subd = a[1];
	// use last element of a; split at /
	// host is a[0]; path is a[1..(n-1)]; a[n] is page
	
	//hover states for nav	
	
	if (subd =="" || subd=="index.html") 
	{
		$('#nav li.home').trigger('onState').addClass('active');
	} 
	else {
			$('#nav li.'+subd).trigger('onState').addClass('active');
		}
		
		
	$.localScroll(
	{
	 	duration: 500
	});

	
	
	
	
});

// END DOC READY
	



