function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function loadSidebars(){
	
	var sidebar1;
	var sidebar2;
	
	//added as an afterthought, there is a better way to organize this
	var links = new Array(); 
	links[0] = "downloads/Emerson_Lofts_Brochure.pdf";	
	links[1] = "community_map.php";
	links[2] = "models.php";	
	links[3] = "features.php";
	
	
	var images = new Array(); 
	images[0] = "images/sidebar_opening.jpg";	
	images[1] = "images/sidebar_areamap.jpg";
	images[2] = "images/sidebar_siteplan.jpg";	
	images[3] = "images/sidebar_features.jpg";
	
	var text = new Array();
	text[0]	  = "<strong>History in the Making.</strong><br /> Our luxurious one and two bedroom lofts feature a perfect blend of historical and contemporary style. <a href = \"downloads/Emerson_Lofts_Brochure.pdf\">Click here</a> to download our brochure and learn more about Emerson Lofts.";	
	text[1]	  = "<strong>Your Surroundings.</strong><br /> What's not to love? A stylish new historic home in a relaxing enjoyable neighborhood. Check out the Opera House, or go shopping at the Woodstock Square. <a href = \"community_map.php\">Click here</a> to find out what else surrounds your new home.";
	text[2]	  = "<strong>Location Location Location.</strong><br /> Our \"L\" shaped building provides a mix of six different floorplans for you to choose from.  <a href = \"site_plan.php\">Click here</a> to view our color coded map to find out the locations of units that interest you.";	
	text[3]	  = "<strong>Everything including the kitchen sink.</strong><br /> All of our units feature a long list of luxurious features to provide the perfect balance of style and comfort. <a href = \"features.php\" >Click here </a>to see what we have in store for you.";
	
	
	var sidebar1 = Math.floor(Math.random() * (images.length -1) );
	
	if(sidebar1 == (images.length -1) )
		sidebar2 = 0;
		else sidebar2 = sidebar1 + 1;
	
	
	//output the sidebar to the page
	document.write('<a href = \"\ '+links[sidebar1]+ ' \"\ border = "0">');
	document.write('<img src = \"\ '+images[sidebar1]+ ' \"\ alt = \"sidebar\" border = "0"></a>');
	document.write('<p>' + text[sidebar1] + '</p>');
	
	document.write('<a href = \"\ '+links[sidebar2]+ ' \"\ border = "0">');
	document.write('<img src = \"\ '+images[sidebar2]+ ' \"\ alt = \"sidebar\" border = "0"></a>');
	document.write('<p>' + text[sidebar2] + '</p>');

}
