var mainColorID = 1;
var mainColor = "purple";
var mainColorCodes = new Array(3);
mainColorCodes["purple"] = "#669999";
mainColorCodes["orange"] = "#66cccc";
mainColorCodes["green"] = "#66cc33";
var curFloor = 0;
var floorData = new Array();
var curSuiteID = 0;

function menuFloorHighlight(obj) {
	for (i=0; i<obj.cells.length; i++)
	{
		obj.cells[i].style.backgroundColor = "#f0f0f0";
	}

}

function menuFloorUnhighlight(obj) {
	for (i=0; i<obj.cells.length; i++)
	{
		obj.cells[i].style.backgroundColor = "#ffffff";
	}


}

function menuFloorSelect(obj) {
	el=document.getElementById('planIDDiv');
	el.innerHTML = "";
	el=document.getElementById('planNameDiv');
	el.innerHTML = "";
	el=document.getElementById('zoomIconDiv');
	el.style.display='none';

	if (curFloor != 0)
	{
		el=document.getElementById("selectedMenuFloor" + curFloor);
		if (el)
		{
			el.style.display="none";
		}
	}

	tmp = obj.id.split("_");
	el=document.getElementById("selectedMenuFloor" + tmp[1]);
	if (el)
	{
		el.style.display="block";
	}

	curFloor = tmp[1];
	el=document.getElementById("floorplateTD");
//	el.innerHTML = "<a href=\"#self\" onclick=\"showPlan(16);\"><img src=\"images/" + floorData[curFloor] + ".gif\" vspace=\"5\" border=\"0\"></a>";
//	el.innerHTML = "<script type=\"text/javascript\">AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','100%','height','100%','src','main','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','swf/floorplate.swf' ); </script>";
	if (floorData[curFloor] != "")
	{
		el.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="160" height="160"><param name="movie" value="swf/'+ floorData[curFloor] 	+'.swf"><param name="quality" value="high"><embed src="swf/'+ floorData[curFloor] 	+'.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="160" height="160"></embed></object>';
	} else {
		el.innerHTML = '<img src="images/placeholder.jpg">';
	}

	el=document.getElementById('planDetailsTable');
	el.style.display='none';
	el=document.getElementById('bttncontactme');
	el.style.display='none';
	el=document.getElementById('planThumbDiv');
	el.style.display='none';
	
}

function showPlan(planID) {
	url = "index.php?n=Condo&o=suite&id="+planID + "&floor=" + curFloor;
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showPlan	;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _showPlan() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;

	x=response.getElementsByTagName("name");
	name= x[0].firstChild.data;
	x=response.getElementsByTagName("id");
	id = x[0].firstChild.data;
	x=response.getElementsByTagName("pos");
	pos = x[0].firstChild.data;
	x=response.getElementsByTagName("thumb");
	image = x[0].firstChild.data;
	x=response.getElementsByTagName("image");
	fimage = x[0].firstChild.data;
	x=response.getElementsByTagName("pdf");
	pdf = x[0].firstChild.data;
	x=response.getElementsByTagName("features");
	features = x[0].firstChild.data;
	x=response.getElementsByTagName("price");
	price = x[0].firstChild.data;
	x=response.getElementsByTagName("sqft");
	sqft = x[0].firstChild.data;
	x=response.getElementsByTagName("type");
	type = x[0].firstChild.data;
	x=response.getElementsByTagName("occupancy");
	occupancy = x[0].firstChild.data;
	x=response.getElementsByTagName("view");
	view = x[0].firstChild.data;
	x=response.getElementsByTagName("floor");
	flr = x[0].firstChild.data;
	
	curSuiteID = id;

	el=document.getElementById('planNameDiv');
	el.innerHTML = name;

//	fimage = "images/fp_sample.gif";

	el=document.getElementById('planThumbDiv');
	el.innerHTML = "<a href=\"#self\"><img src=\""+image+"\" border=\"0\" onclick=\"showModelPopup('"+name+"','"+fimage+"','"+ pdf +"','"+ price+"','"+view+"', '"+flr+"', '"+sqft+"','"+ type+"','"+ pos+"','"+ features+"');\"></a>";

	el=document.getElementById('zoomIconDiv');
	el.innerHTML = '<a href="#self" '+" onclick=\"showModelPopup('"+name+"','"+fimage+"','"+ pdf +"','"+ price+"','"+view+"', '"+flr+"', '"+sqft+"','"+ type+"','"+ pos+"','"+ features+"');\""+'"><img src="images/plus_up_'+mainColor+'.gif" name="plusbttn" width="18" height="19" border="0" id="plusbttn" onMouseOver="MM_swapImage(\'plusbttn\',\'\',\'images/plus_over.gif\',1)" onMouseOut="MM_swapImgRestore()"></a>';

	el=document.getElementById('planOccup');
	el.innerHTML = "occupancy: " + occupancy;

//	el=document.getElementById('planPDF');
//	el.innerHTML = pdf;
//
	el=document.getElementById('planPrice');
	el.innerHTML = price;

	el=document.getElementById('planType');
	el.innerHTML = type;

	el=document.getElementById('planSQFT');
	el.innerHTML = sqft;

//	el=document.getElementById('planID');
//	el.innerHTML = name;

	el=document.getElementById('planViews');
	el.innerHTML = view;

	el=document.getElementById('planIDDiv');
	if (pos<10) pos2 = "0" + pos; else pos2 = pos;
	el.innerHTML = '<img src="images/plannum_'+pos2+'.gif" >';

	el=document.getElementById('planDetailsTable');
	el.style.display='block';

	el=document.getElementById('bttncontactme');
	el.style.display='inline';

	el=document.getElementById('planThumbDiv');
	el.style.display='inline';

	el=document.getElementById('zoomIconDiv');
	el.style.display='inline';

  }
}


function showModelPopup(name, fimage, pdf, price, views, floor, sqft, beds, pos, features) {
	if (pos<10) pos2 = "0" + pos; else pos2 = pos;
	title = '<table cellpadding="0" cellspacing="0" border="0" style="width: 100%;">' +
					'<tr>' +
					'<td style="width:40px; text-align:center"><img src="images/plannum_'+pos2+'.gif" ></td>' +
					'<td width="151" height="36" align="left" valign="middle">'+name+'</td>' +
					'<td width="100%" height="36" align="right" valign="bottom" >'+
						'<div id="poplinksDiv" style="width: 100%; text-align: right;" align="right"><nobr>'+
							'<a href="'+features+'"><img border="0" src="images/icon_fandf_'+mainColor+'.gif" name="fandficon" width="60" height="18" id="fandficon" onMouseOver="MM_swapImage(\'fandficon\',\'\',\'images/icon_fandf_over.gif\',1)" onMouseOut="MM_swapImgRestore()"></a>'+
							'<a href="'+pdf+'" target="_blank"><img src="images/icon_print_'+mainColor+'.gif" name="pdficon"  border="0" id="pdficon" onMouseOver="MM_swapImage(\'pdficon\',\'\',\'images/icon_print_over.gif\',1)" onMouseOut="MM_swapImgRestore()"></a>'+
							'<a href="#self"><img onclick="showModelPopupInfo(\'' + price + '\',\'' + views +'\',\''+ floor +'\',\''+ sqft + '\',\'' + beds + '\');" src="images/icon_info_'+mainColor+'.gif" name="infoicon" width="18" height="28" border="0" id="infoicon" onMouseOver="MM_swapImage(\'infoicon\',\'\',\'images/icon_info_over.gif\',1)" onMouseOut="MM_swapImgRestore()"></a></nobr>' +
						'</div>'+
					'</td>' +
			  '</tr>'+
			  '<tr>'+
				  '<td width="191" height="30" colspan="2" valign="middle" ><a href="#self" onclick="showContactUs(0, curSuiteID);"><img border="0" src="images/bttn_contactme_up.gif" name="bttncontactpop" hspace="10" id="bttncontactpop" onMouseOver="MM_swapImage(\'bttncontactpop\',\'\',\'images/bttn_contactme_over.gif\',1)" onMouseOut="MM_swapImgRestore()"></a></td>'+
				  '<td valign="bottom" align="right"><a href="http://www.adobe.com/go/EN_US-H-GET-READER" ><img border="0" src="images/get_adobe_reader.gif" style="margin-top: 12px;"></a></td>'+
			   '</tr>'+
			'</table>';
	content = '<img src="'+fimage+'" >	  </div><br><div class="mousetxt" style="text-align:left; margin-top:30px; margin-bottom:40px; margin-left:25px; width :335px;">All dimensions are approximate. Sizes and specifications are subject to change without notice.  E. &amp; O.E.  All illustrations are artist\'s concept.  Actual usablefloor space varies from the stated floor area.</div>';
	stdAlertID2 = showAlert(stdAlertID2, title, content);
	moveAlert(0,100);

}

function showModelPopupInfo(price, views, floor, sqft, beds) {
	el = document.getElementById('popInfoDiv');
	clsName =  "t"+mainColorID+"col";
	if (!el)
	{
		txt = '<table width="180" height="150" border="0" cellpadding="5" cellspacing="0">'+
				'<tr><td width="51" align="right" valign="middle" class="borderPurpleR"><span class="'+clsName +'">from</span></td><td width="79" id="detailnfoPrice">' + price + ' &nbsp;&nbsp;&nbsp;&nbsp;<img src="images/bttn_close_up.gif" onclick="hideModelPopupInfo();" style="cursor: pointer; float: top right;" border="0"></td></tr>'+
				'<tr><td align="right" valign="middle" class="borderPurpleR"><span class="'+clsName +'">suite type</span></td><td id="detailnfoBeds">' + beds + '</td></tr>'+
				'<tr><td align="right" valign="middle" class="borderPurpleR"><span class="'+clsName +'">exposure</span></td><td id="detailnfoViews">'+views+' </td></tr>'+
				'<tr><td align="right" valign="middle" class="borderPurpleR"><span class="'+clsName +'">sq.ft.</span></td><td id="detailnfoSQFT">' + sqft + '</td></tr>'+
				'<tr><td align="right" valign="middle" class="borderPurpleR"><span class="'+clsName +'">floors</span></td><td id="detailnfoFloor">' + floor + '</td></tr>'+
				'</table>';
		el = document.createElement("div");
		el.id = "popInfoDiv";
		el.innerHTML = txt;
		el.style.width="180px";
		bdy = document.getElementsByTagName("body");
		bdy[0].appendChild(el);
	}
	el.className="detailinfo" + mainColor;
//	el.class="detailinfoPurple";

	mainel= document.getElementById('divMainAlert');
	el.style.display='block';
	el.style.position='absolute';
	mainZIndex ++;
	el.style.zIndex=mainZIndex;
	el.style.top=100;
	el.style.left = (parseInt(mainel.style.left) + 250) + "px";
	el.style.top = (parseInt(mainel.style.top) + 17) + "px";
	el.style.top = "50px";
	el.style.opacity = 1;
	el.style.mozOpacity = 1;
//	el.onmousemove = hideModelPopupInfo;

//	try
//	{
//		el.class = 'detailinfoPurple';
//		el.className = 'detailinfoPurple';
//	}
//	catch (err)
//	{
//		el.className = 'detailinfoPurple';
//	}

	el = document.getElementById('detailnfoPrice'); el.value=price;
	el = document.getElementById('detailnfoViews'); el.value=views;
	el = document.getElementById('detailnfoFloor'); el.value=floor;
	el = document.getElementById('detailnfoSQFT'); el.value=sqft;
	el = document.getElementById('detailnfoBeds'); el.value=beds;

//	el=document.getElementById('bttnclose');
//	mainel.onclick = hideModelPopupInfo();
}

function hideModelPopupInfo() {
	el = document.getElementById('popInfoDiv');
	el.style.display = 'none';	
	mainZIndex --;
	if (mainZIndex <= 1) makeAllTransparent(100);
}


var amenitiesArr = new Array();
function showAmenity(id) {
	mainel = document.getElementById("amenImage"); 
	mainel2 = document.getElementById("amenTxt"); 
	mainel3 = document.getElementById("amenTitle"); 
	
	path = amenitiesArr[id][0];
	path2 = amenitiesArr[id][1];

	el = document.getElementById(id); 
	mainel.innerHTML = "<a href=\""+path2+"\" target=\"_blank\"><img border=\"0\" src=\""+path+"\" alt=\""+el.alt+"\" class=\"imgBorderGray\"></a>";
	mainel2.innerHTML = el.alt;
	mainel3.innerHTML = el.title;
}

function showAmenities(type) {
	return  showBuildingAmenities(type);
	el = document.getElementById("amenitiesPicsBody");
	firstAmen = 0;
	for (i=0; i<el.rows.length; i++)
	{
		if (el.rows[i].className != "amenityName" + type) el.rows[i].style.display = "none"; else {
			el.rows[i].style.display = "block"; 
			if (firstAmen == 0) {
				firstAmen = 1;
				parts = el.rows[i].id.split("_");	
			}
		}
	}
	if (firstAmen == 1)
	{
		showAmenity("amenityID" + parts[1]);
	}
}

var viewsArr = new Array();
var viewAlertID = 0;
var viewIndex = 0;

function showView(id) {
//	if (viewAlertID > 0) hideAlert2(viewAlertID);
//	viewAlertID = 0;

	mainel = document.getElementById("amenImage"); 
	mainel2 = document.getElementById("amenTxt"); 
	mainel3 = document.getElementById("amenTitle"); 

	path = viewsArr[id][0];
	path2 = viewsArr[id][1];

	el = document.getElementById(id); 
	mainel.innerHTML = "<a href=\"#self\" onclick=\"showFullView('"+path2+"');\" ><img  border=\"0\" width=\"310\" src=\""+path+"\" alt=\""+el.alt+"\" class=\"imgBorderGray\"></a>";
	mainel2.innerHTML = el.alt;
	mainel3.innerHTML = el.title;
}

function showFullView(path) {
//	viewAlertID = showAlert2(viewAlertID, "", "", "");
//	viewAlertID = showAlert2(viewAlertID, "", "<img  border=\"0\" onclick=\"hideAlert2(viewAlertID);\" width=\"800\"  style=\"cursor: pointer;\" src=\""+path+"\" class=\"imgBorderGray\">", "");
	viewAlertID = showAlert2(0, "views", "<img  border=\"0\" onclick=\"hideAlert2(viewAlertID);\" width=\"800\"  style=\"cursor: pointer;\" src=\""+path+"\" class=\"imgBorderGray\">", "");
	moveAlert2(viewAlertID, 30,-1);
}

function showViews() {
//	el = document.getElementById("scrollArea");
//	el.innerHTML = "<nobr>";
//	for (i=0; i<viewsArr.length; i++)
//	{
//		el.innerHTML += '<a href="#self" onclick="showView2('+i+');"><img id="scrollThumb'+i+'" src="'+viewsArr[i][0]+'" border="0" style="margin: 0px 5px; display: none;"></a>';
//	}
//
//	el.innerHTML += "</nobr>";
	updateViews();
	showView2(0)
}


function updateViews() {
	k=1;
	for (i=1; i<=5; i++)
	{
		el = document.getElementById("Slot" + i);
		el.innerHTML = '<img src="images/spacer.gif" border="0" width="60" height="1">';

	}
	for (i=viewIndex; i<viewIndex + 5; i++)
	{
		if (i - viewIndex >=viewsArr.length) continue;
		x = i;
		if (x >= viewsArr.length) x = x - viewsArr.length;
		el = document.getElementById("Slot" + k);
		el.innerHTML = '<a href="#self" onclick="showView2('+x+');"><img src="'+viewsArr[x][0]+'" border="0" style="margin: 0px"></a>';
		k++;
	}
}

function scrollToLeft() {
	if (viewsArr.length <= 5) return false;
	viewIndex = viewIndex - 1;
	if (viewIndex < 0) viewIndex = viewsArr.length - 1;
	updateViews();
}

function scrollToRight(id) {
	if (viewsArr.length <= 5) return false;
	viewIndex = viewIndex + 1;
	if (viewIndex >= viewsArr.length) viewIndex = 0;
	updateViews();
	if (id >= 0)
	{
		nextView = id + 1;
		if (nextView>=viewsArr.length) nextView = 0;
		showView2(nextView);
	}
}

function showView2(id) {

	mainel = document.getElementById("amenImage"); 
	mainel2 = document.getElementById("amenTxt"); 
	mainel3 = document.getElementById("amenTitle"); 
	mainel4 = document.getElementById("enlargeLink"); 
	mainel5 = document.getElementById("enlargeLink1"); 

	path = viewsArr[id][1];
	path2 = viewsArr[id][2];

	el = document.getElementById(id); 
	mainel.innerHTML = "<a href=\"#self\" onclick=\"scrollToRight("+id+");\" ><img  border=\"0\" width=\"360\" src=\""+path+"\" alt=\""+viewsArr[id][4]+"\" class=\"imgBorderGray\"></a>";
	mainel2.innerHTML = "";
	if (viewsArr[id][4] != '') mainel2.innerHTML = viewsArr[id][4];
	mainel3.innerHTML = "";
	if (viewsArr[id][3] != '' && mainel3) mainel3.innerHTML = viewsArr[id][3];
	mainel4.innerHTML = '<a href="#self" onclick="showFullView(\''+path2+'\')"><img src="images/bttn_plus_up.gif" alt="view larger" name="bttnplus" width="13" height="13" border="0" id="bttnplus" onMouseOver="MM_swapImage(\'bttnplus\',\'\',\'images/bttn_plus_over.gif\',1)" onMouseOut="MM_swapImgRestore()"></a>';
//	mainel5.innerHTML = '<a href="#self" onclick="showFullView(\''+path2+'\')">view<br>larger</a>';
}

var buildingAmenities = new Array();
function showBuildingAmenities(type) {
	viewsArr.length = 0;
	x = 0;
	viewIndex = 0;
	for (i in buildingAmenities)
	{
		if (type == "" || i == type)
		{
			viewsArr[x] = buildingAmenities[i];
			x ++;
		}
	}
	updateViews();
	showView2(0);
}