var fontsize = 13;
var savedFontSize = 13;
//	alert(savedFontSize);

function setFontSize() {
	if (savedFontSize)
	{
		savedFontSize = Get_Cookie("FontSize");
		if (parseInt(savedFontSize)) fontsize = savedFontSize;
		el = document.getElementsByTagName("body");
		if (el)
		{
			try
			{
				el[0].style.fontSize = fontsize + "px";	
			}
			catch (ex)
			{
				;
			}
			
		}
	}
}

function changeFontSize(direction) {
	el = document.getElementsByTagName("body");
	if (direction == 0)
	{
		el[0].style.fontSize = "13px";
		fontsize = 13;
	} else {
		if (fontsize >= 19 && direction > 0) return true;
		if (fontsize <= 11 && direction < 0) return true;
		fontsize = parseInt(fontsize) + parseInt(direction); 
		el[0].style.fontSize = fontsize + "px";
	}
	direction = 1 - direction;
	Set_Cookie("FontSize", fontsize, 1);
}


var curplan = 0;
var curobj = "";
function loadPlan(obj, x) {
	if (curobj)
	{
		curobj.src = curobj.src.replace('tn1','tn2');
		curobj.onmouseout = function () {this.src=this.src.replace('tn1','tn2');};
		curobj.style.borderColor = "#ffffff";
//		curobj.style.borderStyle = "none";
//		curobj.style.borderWidth = "0px";
	}
	el = document.getElementById('imgholder');
	obj.src = obj.src.replace('tn2','tn1');
	obj.style.borderColor = "#003767";
//	obj.style.borderStyle = "solid";
//	obj.style.borderWidth = "1px";
	obj.onmouseout = "";
	t = obj.src.replace("tn/", "");
	t = t.replace("-tn1", "");
	t = t.replace("_tn1", "");
	t = t.replace("-tn", "");
	el.style.backgroundImage = "url(" + t + ")";
	el = document.getElementById('homedetail');
	curplan =x;
	curobj = obj;
	if (el) {
		el.innerHTML = '<span class="homename"><nobr>' + models[x].name + '</nobr></span> <br />' + models[x].sqft + ' sq. ft. • elev.  ' + models[x].elevation;
		if (models[x].price)
		{
			el.innerHTML += ' • ' + models[x].price;
		}
	}
}

var suiteid = 0;
function showSuite(id) {
	suiteid = id;
	url = "suites.php?price=1";
	wait();
//	window.location = url;
//	return true;
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showSuite;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
	txt = "";


}

function _showSuite() {

	if(checkReadyState(xmlhttp)) {

		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("suiteID");
		for (i=0; i<ret.length ; i++ )
		{
			suite_id = getXMLNode(ret,i);
			if (suite_id == suiteid)
			{
				tmp=response.getElementsByTagName("model_name");
				nme = getXMLNode(tmp,i);
				tmp=response.getElementsByTagName("sqft");
				sq = getXMLNode(tmp,i);
				tmp=response.getElementsByTagName("description");
				descr = getXMLNode(tmp,i);
				tmp=response.getElementsByTagName("price2");
//				minprice = getXMLNode(tmp,i);
				minprice = "";
				planname = nme.replace("The ", "");
				planname = "../media/plans/condos/" + planname.replace(" Rose", "")  + ".gif";
				im = new Image();
				im.onload = function () { loadSuite(nme, sq, planname,minprice);}
				im.src=planname;
				break;
			}
		}
		return true;
		ret=response.getElementsByTagName("msg");
		msg= getXMLNode(ret);
		ret=response.getElementsByTagName("ret");
		resp= getXMLNode(ret);
		if (resp == "ok")
		{
//			el = document.getElementById("contentArea");
//			el.innerHTML = txt;
			window.location=txt;
			alert2(msg);
		} else {
			alert2(msg);
		}
		
	}


}

function loadSuite(nme, sq, planname, price) {
	txt = '<table border="0" align="center" cellpadding="0" cellspacing="0">';
	txt += ' <tr>';
	txt += '    <td colspan="2" align="right" style="padding:10px;"><a href="#self" onclick="closeWait();"><img src="../images/bttn-close-1.gif" name="close" width="66" height="18" border="0" id="close" onmouseover="MM_swapImage(\'close\',\'\',\'../images/bttn-close-2.gif\',1)" onmouseout="MM_swapImgRestore()" /></a></td>';
	txt += '  </tr>';
	txt += '  <tr>';
	txt += '    <td colspan="2" style="padding:0px 0 10px 10px; color:#003767; background-color: #e5e5e5"><span class="pop-homename">'+nme+'</span> <span class="pop-sqft">'+sq+'</span></td>';
	txt += '  </tr>';
	txt += '  <tr>';
	txt += '    <td colspan="2" style="background-color:#ffffff"><img style="border:10px solid #ffffff; margin-left:auto; margin-right:auto;" src="'+planname+'"  /></td>';
	txt += '  </tr>';
	txt += '  <tr>';
	txt += '    <td colspan="2" class="mousetype">Specifications subject to change without notice.<br />';
	txt += '      Special offers may   be withdrawn without notice. E. &amp; O.E.<br />';
	txt += '      Ask Sales Representative for   details. </td>';
	txt += '  </tr>';
	txt += '</table>';
	showOverlay();
	box(txt);

}

function showPlanPopup(invprice) {
	xid = curplan;
	tmp = [];
	for (i in models)
	{
		if (models[i].id == models[xid].id)
		{
			tmp[tmp.length] = models[i];
		}
	}
minprice = tmp[0].price;
if (invprice) minprice = invprice;

txt = '<table border="0" align="center" cellpadding="0" cellspacing="0" height="800" width="530">';
txt += ' <tr>';
txt += '    <td colspan="2" align="right" style="padding:10px;"><a href="#self" onclick="closeWait();"><img src="../images/bttn-close-1.gif" name="close" width="66" height="18" border="0" id="close" onmouseover="MM_swapImage(\'close\',\'\',\'../images/bttn-close-2.gif\',1)" onmouseout="MM_swapImgRestore()" /></a></td>';
txt += '  </tr>';
txt += '  <tr>';
txt += '    <td colspan="2" style="padding:0px 0 10px 10px; color:#003767; background-color: #e5e5e5"><span class="pop-homename">'+tmp[0].name+'</span> <span class="pop-sqft">'+tmp[0].sqft+' sq.ft. • '+minprice+'</span></td>';
txt += '  </tr>';
txt += '  <tr>';
txt += '    <td colspan="2" style="background-color:#ffffff"><img style="border:10px solid #ffffff; margin-left:auto; margin-right:auto;" src="../'+tmp[0].planimage+'"  /></td>';
txt += '  </tr>';
txt += '  <tr>';
txt += '    <td colspan="2" class="mousetype"><p> Specifications, sizes, elevations and prices subject to change without notice. Special offers may be withdrawn without notice. <nobr>E. & O.E.</nobr> Ask Sales Representative for details. </p> </td>';
txt += '  </tr>';
txt += '</table>';
showOverlay();
box(txt);

}


function downloadPlan() {
	xid = curplan;
	tmp = [];
	for (i in models)
	{
		if (models[i].id == models[xid].id)
		{
			tmp[tmp.length] = models[i];
		}
	}
	window.open("../" + tmp[0].floorplan, "download");
}
function showRenderingPopup(renderingid) {
	if (!renderingid) renderingid = 0;
	xid = curplan;
	tmp = [];
	for (i in models)
	{
		if (models[i].id == models[xid].id)
		{
			tmp[tmp.length] = models[i];
		}
	}
minprice = tmp[0].price;

txt = '<table border="0" align="center" cellpadding="0" cellspacing="0" height="600" width="475">';
txt += ' <tr>';
txt += '    <td colspan="2" align="right" style="padding:10px;"><a href="#self" onclick="closeWait();"><img src="../images/bttn-close-1.gif" name="close" width="66" height="18" border="0" id="close" onmouseover="MM_swapImage(\'close\',\'\',\'../images/bttn-close-2.gif\',1)" onmouseout="MM_swapImgRestore()" /></a></td>';
txt += '  </tr>';
txt += '  <tr>';
txt += '    <td colspan="2" style="padding:0px 0 10px 10px; color:#003767; background-color: #e5e5e5"><span class="pop-homename">'+tmp[0].name+'</span> <span class="pop-sqft">'+tmp[0].sqft+' sq.ft. • '+minprice+'</span></td>';
txt += '  </tr>';
txt += '  <tr>';
if (tmp[0]) txt += '    <td style="padding:0px 0 10px 10px; color:#003767; "><a href="#self" onclick="showRenderingPopup(0)"><img border="0" src="../'+tmp[0].thumb1+'" /></a>&nbsp;Elevation '+tmp[0].elevation+'</td>';
if (tmp[1]) txt += '    <td style="padding:0px 0 10px 10px; color:#003767;"><a href="#self" onclick="showRenderingPopup(1)"><img border="0" src="../'+tmp[1].thumb1+'" /></a>&nbsp;Elevation '+tmp[1].elevation+'</td>';
txt += '  </tr>';
txt += '  <tr>';
txt += '    <td colspan="2" style="padding:0px 0 10px 10px; "><img style="border:2px solid #fff" src="../'+tmp[renderingid].fullimage.replace(".", "_full.")+'"  /><table border="0" align="left" cellpadding="0" cellspacing="0"><tr><td align="left"><a href="#self" class="link1" onclick="showPlanPopup();">view floorplan</a></td><td><a style="margin-left: 20px;" href="../'+tmp[0].floorplan+'" target="_blank" class="link1"><nobr>download plan</nobr></a></td></tr></table></td>';
txt += '  </tr>';
txt += '  <tr>';
txt += '    <td colspan="2" class="mousetype"><p> Specifications, sizes, elevations and prices subject to change without notice. Special offers may be withdrawn without notice. <nobr>E. & O.E.</nobr> Ask Sales Representative for details. </p> </td>';
txt += '  </tr>';
txt += '</table>';
showOverlay();
box(txt);

}

function showRenderingPopup2(renderingid, invprice) {
	if (!renderingid) renderingid = 0;
	xid = curplan;
	tmp = [];
	for (i in models)
	{
		if (models[i].id == models[xid].id)
		{
			tmp[tmp.length] = models[i];
		}
	}
minprice = tmp[0].price;
if (invprice) minprice = invprice;
txt = '<table border="0" align="center" cellpadding="0" cellspacing="0" height="600" width="475">';
txt += ' <tr>';
txt += '    <td colspan="2" align="right" style="padding:10px;"><a href="#self" onclick="closeWait();"><img src="../images/bttn-close-1.gif" name="close" width="66" height="18" border="0" id="close" onmouseover="MM_swapImage(\'close\',\'\',\'../images/bttn-close-2.gif\',1)" onmouseout="MM_swapImgRestore()" /></a></td>';
txt += '  </tr>';
txt += '  <tr>';
txt += '    <td colspan="2" style="padding:0px 0 10px 10px; color:#003767; background-color: #e5e5e5"><span class="pop-homename">'+tmp[0].name+ ' ' + tmp[renderingid].elevation +'</span> <span class="pop-sqft">'+tmp[0].sqft+' sq.ft. • '+minprice+'</span></td>';
txt += '  </tr>';
txt += '  <tr>';
txt += '    <td colspan="2" style="padding:0px 0 10px 10px; "><img style="border:2px solid #fff" src="../'+tmp[renderingid].fullimage.replace(".", "_full.")+'"  /><br><a href="#self" class="link1" onclick="showPlanPopup(\''+minprice+'\');">view floorplan</a></td>';
txt += '  </tr>';
txt += '  <tr>';
txt += '    <td colspan="2" class="mousetype"><p> Specifications, sizes, elevations and prices subject to change without notice. Special offers may be withdrawn without notice. <nobr>E. & O.E.</nobr> Ask Sales Representative for details. </p> </td>';
txt += '  </tr>';
txt += '</table>';
showOverlay();
box(txt);

}



function loadGalleryImage(obj) {
	if (curobj)
	{
		curobj.src = curobj.src.replace('tn1','tn2');
		curobj.onmouseout = function () {this.src=this.src.replace('tn1','tn2');};
		curobj.style.borderColor = "#ffffff";
//		curobj.style.borderStyle = "none";
//		curobj.style.borderWidth = "0px";
	}
	el = document.getElementById('imgholder');
	obj.src = obj.src.replace('tn2','tn1');
	obj.style.borderColor = "#003767";
//	obj.style.borderStyle = "solid";
//	obj.style.borderWidth = "1px";
	obj.onmouseout = "";
	t = obj.src.replace("-tn1", "");
	t = t.replace("_tn1", "");
	t = t.replace("tn/", "");
	t = t.replace("-tn", "");
	el.style.backgroundImage = "url(" + t + ")";
	curobj = obj;

	
//	el = document.getElementById('imgholder');
//	t = obj.replace("tn/", "");
//	el.style.backgroundImage = "url(" + t.replace("_tn1", "") + ")";

}


function showFeatures() {
	url = "features2.php?id=" + models[curplan].inventoryid;
	wait();
//	window.location = url;
//	return true;
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showFeatures;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
	txt = "";
}

function _showFeatures() {

	if(checkReadyState(xmlhttp)) {

		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("msg");
		msg2= getXMLNode(ret);
		msg2 = "<div style='width: 350px; text-align: left; font-weight: normal; padding: 40px; background-color: #fff;'>"+msg2+"</div>";
		message2(msg2);
		
	}


}





function alert2(msg) {
	msg = "<div class='alert'>"+msg+"</div>";
	message2(msg);
}
function alert3(msg, url) {
	msg = "<div class='alert'>"+msg+"<br><br><center><a class='cssbutton' style='height: 21px;' href='"+url+"'>CLOSE<br></a></center></div>";
	message2(msg);
}
function wait() {
	message2("<div style='padding: 40px; text-align: center; background-color: #fff;'>Please wait ... <br><br><br><br><img src='../images/spinning.gif'></div>");
}

function showVillage() {
	txt = "";
	txt += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="810" height="600" id="villagecentre" align="middle">';
	txt += '<param name="allowScriptAccess" value="sameDomain" />';
	txt += '<param name="allowFullScreen" value="false" />';
	txt += '<param name="movie" value="villagecentre.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />	<embed src="villagecentre.swf" quality="high" bgcolor="#ffffff" width="810" height="600" name="villagecentre" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />';
	txt += '</object>';
	showOverlay();
	box(txt);
}

function showContact() {

txt = '<table border="0" align="center" cellpadding="0" cellspacing="0">';
txt += ' <tr>';
txt += '    <td colspan="2" align="right" style="padding:10px;"><a href="#self" onclick="closeWait();"><img src="../images/bttn-close-1.gif" name="close" width="66" height="18" border="0" id="close" onmouseover="MM_swapImage(\'close\',\'\',\'../images/bttn-close-2.gif\',1)" onmouseout="MM_swapImgRestore()" /></a></td>';
txt += '  </tr>';
txt += ' <tr><td colspan="2" style="background-color:#ffffff; padding: 30px 20px 0px 20px;"><h1>Contact Form</h1></td>';
txt += '  </tr>';
txt += ' <tr>';
txt += '    <td colspan="2" style="background-color:#ffffff;  padding: 0px 20px 30px;">';
txt += "<form id='frmSendEmail2'><table cellpadding='0' cellspacing='0' class='sendfriend'>";
txt += "<tr><td align='right' width='100'>Name</td><td align='left'><input type='text' name='sendName' id='sendName'></td></tr>";
txt += "<tr><td align='right'>Email</td><td align='left'><input type='text' name='sendEmail' id='sendEmail'></td></tr>";
txt += "<tr><td align='right'>Subject</td><td align='left'><input type='text' name='sendSubject' id='sendSubject'></td></tr>";
txt += "<tr><td align='right'>Message</td><td align='left'><textarea name='sendMessage' id='sendMessage' rows=4 cols=30></textarea></td></tr>";
txt += "<tr><td align='right'></td><td align='right'><input type=\"button\" value='SUBMIT' style=\"cursor: pointer;\" onclick=\" xyz=document.getElementById('frmSendEmail2');sendEmailFriend(xyz);\"></td></tr>";
txt += "</table></form>";
txt += '    </td>';
txt += '  </tr>';
txt += '</table>';
showOverlay();
box(txt);

}


function sendEmailFriend(obj) {
	el = document.getElementById("sendName"); if (!el.value) { alert("Name is required!"); return false; }
	el = document.getElementById("sendSubject"); if (!el.value) { alert("Subject is required!"); return false;}
	el = document.getElementById("sendEmail"); if (!el.value) { alert("Email is required!"); return false;}
	url = "contact.php?" + getForm(obj);
	wait();
	initObj();
//	alert(url);return false;
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_sendEmail;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
	txt = "";
}

function _sendEmail() {
	if(checkReadyState(xmlhttp)) {
		alert2("Thank you", "Your invitation was sent!");
	}
}

function showSitePlan(what) {
	i = new Image();
	path = "../images/site_" + what + ".jpg";
	i.onload = function () {message2('<img src="'+path+'">'); };
	i.src = path;
}

function showRendering(rendering) {
	imageF("../images/condo_" + rendering + ".jpg");
}

function loadSuitesHTML() {
	url = "suites2.php";
	initObj();
//	alert(url);return false;
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_loadSuitesHTML;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _loadSuitesHTML() {

	if(checkReadyState(xmlhttp)) {

		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("frmData");
		el = document.getElementById("suitesList"); 
		el.innerHTML = getXMLNode(ret);

	}


}
