

/*****************/
/* JQUERY onload */
/*****************/

jQuery(document).ready(function()
{

	//wrap navigation in another dv for spacing above search
	jQuery("#navigation").wrap("<div id='left'></div>");

	//move the search listings to end of home content (home page only)
	//add the special maintainence image to end of  home page content (after search) (home page only)
  	if(jQuery("BODY.home").length)
	{
		jQuery("#layoutDiv1").prepend(jQuery("#home-maint"));
 		jQuery("#layoutDiv1").prepend(jQuery("#searchListings"));
	}


	//add the special contact image to below navigation (home page only)
  	if(jQuery("BODY.home").length)
	{
		jQuery("#left").append(jQuery("#home-contact"));
	}

	//add the home pag image on top of the header ()
	jQuery("#header").append("<div id='home-image'></div>");
	jQuery("#home-image").append(jQuery("#headerText"));


	//move featured elements around (home page only)
  	if(jQuery("BODY.home").length)
  	{
		jQuery("DIV.featuredListing h2").prependTo(jQuery("DIV.location"));

		jQuery("DIV.featuredListing A.button").appendTo(jQuery("DIV.image"));
		jQuery("DIV.featuredListing A.button").wrap("<p></p>");
	}

	//add rounded cxorners to content
	jQuery("#content").prepend("<div id='content-top'>&nbsp;</div>");
	jQuery("#content").append("<div id='content-bottom'>&nbsp;</div>");


	//add rounded cxorners to featured (home page only)
  	if(jQuery("BODY.home").length)
  	{
		jQuery("#specialFeatures").prepend("<div id='specialFeatures-top'>&nbsp;</div>");
		jQuery("#specialFeatures").append("<div id='specialFeatures-bottom'>&nbsp;</div>");

		jQuery("#specialFeatures").append("<div id='specialFeatures-image'>&nbsp;</div>");

	}

	//fix gallery (rentals page only - bldg/unit)
  	if(jQuery("BODY.rentals").length)
  	{
		//wrap for v-align...
 		jQuery("DIV.Thumbnail IMG").wrap("<div class='thumbnail_align'></div>");

		jQuery("DIV.Thumbnail IMG").each(function(i){
		    this.onload=function(){ImageLoaded(i);};
		});
 	}


	//fix row hover for IE - rentals page
  	if(jQuery("BODY.rentals").length)
	{
   	   jQuery("TABLE.list tr").hover(
		   function(){jQuery(this).addClass("hover");},
		   function(){jQuery(this).removeClass("hover");});
   	}


	//change tenants page layout
  	if(jQuery("BODY.tenants").length)
  	{
		jQuery("#layoutDiv2").append(jQuery("#layoutDiv1"));
	}

	//move the footer to the end of the content area
	jQuery("#container").after(jQuery("#footer"));


});



/**********************************/
/* Gallery Image Loading Callback */
/**********************************/

var loaded_images=new Array();
function ImageLoaded(index)
{
	loaded_images[index]=true;

	for(var i=0;i<jQuery("DIV.Thumbnail IMG").length;i++)
	{
		if(!loaded_images[i]) return;
	}

	//if loaded, positionbased on height
	//max image height...
	var max_h=0;
	jQuery("DIV.Thumbnail IMG").each(function(i){
		if(this.height>max_h) max_h=this.height+5;
	});

	//align images bottom...
	jQuery("DIV.Thumbnail DIV.thumbnail_align").each(function(i){
		this.style.marginTop = max_h-jQuery("DIV.Thumbnail IMG").get(i).height;
	});
}
