
function setPlan()
{

	init();
/*	if ((x=MM_findObj('fp'))!=null)
	{
		x.sPlan = 'a';
		x.sfp = '2.gif';
	}
*/
}

function loadplan()
{ //v3.0

	var i,j=0,x,a=loadplan.arguments;   

	if(a[0]=='fpA' || a[0]=='fpB')
	{

		if ((x=MM_findObj('fp'))!=null)
		{
			if(a[0]=='fpB')
			{
				x.sPlan = 'b';
				if((y=MM_findObj('fph'))!=null)
				{
					y.className='fp_head_b';
				}
			} else {
				x.sPlan = 'a';
				if((y=MM_findObj('fph'))!=null)
				{
					y.className='fp_head_a';
				}
			}
		}

		x.src= 'images/fp_' + x.sPlan + '_' + x.sfp;

	} else {

		for(i=0;i<(a.length-2);i+=3)
		{
			if ((x=MM_findObj(a[i]))!=null)
			{	
				x.src= 'images/fp_' + x.sPlan + '_' + a[i+2];
				x.sfp= a[i+2];
			}
		}
	}

}

selected_unit = null;
units = document.getElementsByName('unit');

function get_curr_unit_idx()
{
	for (var i = 0; i < units.length; i++)
		if (units[i] == selected_unit)
			return i;

	return 0;
}

function next_unit()
{
	curr_idx = get_curr_unit_idx();
	if (curr_idx <= 0)
		return;

	select_unit(units[curr_idx - 1]);
}

function previous_unit()
{
	curr_idx = get_curr_unit_idx();
	if (curr_idx >= (units.length - 1))
		return;

	select_unit(units[curr_idx + 1]);
}

function select_unit(unit)
{
	// restore the image and rollover functions for the last selected unit
	if (selected_unit != null) {
		selected_unit.src = 'images/units/normal/' + selected_unit.id + '.gif';
		selected_unit.onmouseout = MM_swapImgRestore;
		selected_unit.onmouseover = function() {
			MM_swapImage(this.id, '', 'images/units/rollover/' + this.id + '.gif', 1);
		}
	}

	// change the image and disable the rollover functions for the selected unit
	unit.src = 'images/units/selected/' + unit.id + '.gif';
	unit.onmouseout = null;
	unit.onmouseover = null;
	selected_unit = unit;

	change_floorplan(unit);
	change_sqft(unit);
}

function change_sqft(unit)
{
	document.getElementById('fp_sqft').src = 'images/floor_plans/sqft/' + unit.id + '_sqft.gif';
}

function change_floorplan(unit)
{
	document.getElementById('fp_title').src = 'images/floor_plans/' + unit.id + '_title.gif';
	document.getElementById('fp_1').style.background = "url('images/floor_plans/" + unit.id + "_fp_1.png') center no-repeat";
	document.getElementById('fp_2').style.background = "url('images/floor_plans/" + unit.id + "_fp_2.png') center no-repeat";
	document.getElementById('fp_3').style.background = "url('images/floor_plans/" + unit.id + "_fp_3.png') center no-repeat";
}

function show_floorplan()
{
	document.getElementById('fp_content').style.display = 'block';
	document.getElementById('fp_background').style.display = 'block';
}


function hide_floorplan()
{
	document.getElementById('fp_content').style.display = 'none';
	document.getElementById('fp_background').style.display = 'none';
}

function init() {
	for (var i = 0; i < units.length; i++) {
		units[i].onclick = function() {
			select_unit(this);
		}

		units[i].onmouseout = MM_swapImgRestore;
		units[i].onmouseover = function() {
			MM_swapImage(this.id, '', 'images/units/rollover/' + this.id + '.gif', 1);
		}
		MM_preloadImages('images/units/rollover/' + units[i].id + '.gif');
	}

	// select unit 1 initially
	select_unit(document.getElementById('unit_1'));
}

