var fontsize = 12;
var savedFontSize = 12;
//	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 = "12px";
		fontsize = 12;
	} else {
		if (fontsize >= 18 && direction > 0) return true;
		if (fontsize <= 10 && 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(name, id) {
//	message2('<div style="height: 600px; width: 695px;"><object id="doc_5783" name="doc_5783" height="600" width="695" type="application/x-shockwave-flash" data="http://d1.scribdassets.com/ScribdViewer.swf" style="outline:none;" >                <param name="movie" value="http://d1.scribdassets.com/ScribdViewer.swf">                 <param name="wmode" value="opaque">                 <param name="bgcolor" value="#ffffff">                 <param name="allowFullScreen" value="true">                 <param name="allowScriptAccess" value="always">                 <param name="FlashVars" value="document_id=34641420&access_key=key-1qq9wo3grr933twlfr6c&page=1&viewMode=list">                 <embed id="doc_5783" name="doc_5783" src="http://d1.scribdassets.com/ScribdViewer.swf?document_id=34641420&access_key=key-1qq9wo3grr933twlfr6c&page=1&viewMode=list" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" height="600" width="695" wmode="opaque" bgcolor="#ffffff"></embed>             </object></div>');
	suiteid = id;
	url = "get_plan.php?id=" + id +"&name=" + name ;
	wait();
//	window.location = url;
//	return true;
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_loadPlan;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
	txt = "";

}

function _loadPlan() {

	if(checkReadyState(xmlhttp)) {

		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		ret=response.getElementsByTagName("planpdf");
		pdf = getXMLNode(ret);
		ret=response.getElementsByTagName("planipaper");
		ipaper = getXMLNode(ret);
		message2('<div style="height: 600px; width: 695px;">' + ipaper + "</div>");

	}

}

function showFloorPlan(id, blockno) {
	loadPlan(id);
}

var suiteid = 0;
function showSuite(id) {
	suiteid = id;
	url = "suites.php";
	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);
				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/icon_delte_up.gif" name="close"  border="0" id="close" onmouseover="MM_swapImage(\'close\',\'\',\'../images/icon_delte_over.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+' sq.ft.  • '+price+'</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() {
	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="800" width="530">';
txt += ' <tr>';
txt += '    <td colspan="2" align="right" style="padding:10px;"><a href="#self" onclick="closeWait();"><img src="../images/icon_delte_up.gif" name="close"  border="0" id="close" onmouseover="MM_swapImage(\'close\',\'\',\'../images/icon_delte_over.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/icon_delte_up.gif" name="close"  border="0" id="close" onmouseover="MM_swapImage(\'close\',\'\',\'../images/icon_delte_over.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) {
	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/icon_delte_up.gif" name="close"  border="0" id="close" onmouseover="MM_swapImage(\'close\',\'\',\'../images/icon_delte_over.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();">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 = "features.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/icon_delte_up.gif" name="close"  border="0" id="close" onmouseover="MM_swapImage(\'close\',\'\',\'../images/icon_delte_over.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");
}



/***** homepage swap image *****/
var backImage = new Array();

backImage[0] = "images/hp-condo.gif";
backImage[1] = "images/hp-rental.gif";
backImage[2] = "images/hp-newhome.gif";
backImage[3] = "images/hp-retirement.gif";
backImage[4] = "images/hp-commercial.gif";
backImage[5] = "images/hp-inventory.gif";
backImage[6] = "";

function changeBGImage(whichImage){
	
	el=document.getElementById("home-menuholder")
	el.style.backgroundImage = "url(" + backImage[whichImage] + ")";
}
function setHomeBGImage() {
	document.body.style.backgroundImage = "url('images/homebg.gif')";
}

/** comment here */
function validate2(el) {
	el2 = document.getElementsByName('Interests[]');
	fnd = false;
	for(i=0; i<el2.length; i++) {
		if (el2[i].checked) {
			fnd = true;
			break;
		}
	}
	if (fnd) return validate(el); else {
		alert('Please specify one or more interests!');
		return false;
	}
}
