var dragObj = "";
var windows = new Array();
var objIndex = 10000;

var btHome = 1;
var btClose = 2;
var btCart = 3;
var btAccount = 4;

var stdAlertID = 0;
var stdAlertID2 = 0;
var mainZIndex = 1;

function showAlert(alertID, title, msg, bt1, bt2) {

	if (!alertID)
	{
		alertID = generateID();
		mainZIndex ++;
	}

	makeAllTransparent(10);	
	
	el = document.getElementById("divMainAlert");

	x = document.getElementById("popwintitle");
	x.innerHTML = title;
	x = document.getElementById("popwincontent");
	x.innerHTML = msg;


	getDefaultAction(1, bt1);
	getDefaultAction(2, bt2);
	
	el.style.display='block';
	el.style.zIndex = mainZIndex ;

	h = el.offsetHeight;
	w = el.offsetWidth;
	
	y=getScrollLength("top") + document.documentElement.clientHeight / 2 - (h/2);
	x=getScrollLength("left") + document.documentElement.clientWidth /2 -(w/2);

	el.style.top = Math.max(0, y) + "px";
	el.style.left = Math.max(0, x) + "px";
	return alertID;

}

function getDefaultAction(button, action) {
	return true;
	btn = document.getElementById("alertBtn" + button);
	btn.style.display="block";
	switch (action)
	{
	case 1: 
		btn.onclick=actionHome;
		btn.src="images/btn_ok.gif";
		break;
	case 2: 
		btn.onclick=hideAlert;
		btn.src="images/btn_close.gif";
		break;
	case 3: 
		btn.onclick=actionCart;
		btn.src="images/btn_gotocart.gif";		
		break;
	case 4: 
		btn.onclick=actionAccount;
		btn.src="images/btn-myaccount.png";		
		break;
	default: btn.style.display="none";
	}
}

function actionHome() {
	if (dragObj) endDrop();
	window.location='http://dev.sharefolder.com/index.php';
}

function actionCart() {
	if (dragObj) endDrop();
	window.location='http://dev.sharefolder.com/index.php?n=Cart';
}

function actionAccount() {
	if (dragObj) endDrop();
	window.location='http://dev.sharefolder.com/index.php?n=Users&o=mine';
}

function hideAlert() {
	if (dragObj) endDrop();

	el = document.getElementById("divMainAlert");
	el.style.display='none';

	mainZIndex --;
	if (mainZIndex <= 1) makeAllTransparent(100);
	stdAlertID2 = 0;
}


function showAlert2(alertID, title, msg, subtitle) {
	if (alertID == 0) mainZIndex ++;
	makeAllTransparent(10);
	el = document.getElementById("divMainBody");

	if (!alertID)
	{
		alertID = generateID();
		alertTxt = '<table border="0" cellpadding="0" cellspacing="0" id="divAlertID_'+alertID+'_innerTable">'+
						'	<tr>'+
						'		<td id="divAlertID_'+alertID+'_firstTD" height="20"><img id="alertTitle_'+alertID+'" src="images/poptab_'+title+'.gif" onmousedown="beginDropObj(\'divAlert_'+alertID+'\', event);" onmousemove="drag(event);"></td>'+
						'		<td width="5" rowspan="2" align="right" valign="bottom" height="95%">'+
						'			<table width="5" height="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#eeeeee">'+
						'				<tr>'+
						'					<td><img src="images/transparent.gif" width="5" height="1"></td>'+
						'				</tr>'+
						'			</table>'+
						'		</td>'+
						'	</tr>'+
						'	<tr>'+
						'		<td id="divAlertID_'+alertID+'_secondTD" align="left" valign="top" bgcolor="#FFFFFF" class="popborder">'+
						'			<table border=0 height="324" width="610" id="divAlertID_'+alertID+'_mainTable">'+
						'				<tr>'+
						'					<td id="alertSubTitle_'+alertID+'">'+subtitle+'</td>'+
						'					<td align="right"><a href="#self" onclick="hideAlert2('+alertID+');"><img border="0" src="images/bttn_close_up.gif" name="bttnclose" width="13" height="13" id="bttnclose" onMouseOver="MM_swapImage(\'bttnclose\',\'\',\'images/bttn_close_over.gif\',0)" onMouseOut="MM_swapImgRestore()"></a</td>'+
						'				</tr>'+
						'				<tr>'+
						'					<td colspan=2 id="alertBody_'+alertID+'" width="100%" height="100%">' + msg + '</td>' +
						'				<tr>'+
						'			</table>'+
						'		</td>'+
						'	</tr>'+
						'	</tr>'+
						'		<td height="5" colspan="2" align="right" valign="top">'+
						'			<table width="95%" height="5" border="0" cellpadding="0" cellspacing="0">'+
						'				<tr>'+
						'					<td width="100%" bgcolor="#eaeaea"><img src="images/transparent.gif" width="1" height="5"></td>'+
						'				</tr>'+
						'			</table>'+
						'		</td>'+
						'	</tr>'+
						'</table>';

		el = document.createElement("div");
		el.id = "divAlert_" + alertID;
		el.style.position =  'absolute';
		el.style.zIndex =  10;
		el.innerHTML = alertTxt;

		bdy = document.getElementsByTagName("body");
		bdy[0].appendChild(el);
	} else {
		if (title)
		{
			x = document.getElementById("alertTitle_" + alertID);
			x.src = 'images/poptab_'+title+'.gif';
		}
		x = document.getElementById("alertBody_" + alertID);
		x.innerHTML = msg;
		if (subtitle)
		{
			x = document.getElementById("alertSubTitle_" + alertID);
			x.innerHTML = subtitle;
		}
	}


	el.style.display='block';
	el.style.zIndex = mainZIndex ;

	h = el.offsetHeight;
	w = el.offsetWidth;
	
	y=getScrollLength("top") + document.documentElement.clientHeight / 2 - (h/2);
	x=getScrollLength("left") + document.documentElement.clientWidth /2 -(w/2);

	el.style.top = Math.max(0, y) + "px";
	el.style.left = Math.max(0, x) + "px";
	
	return alertID;
}

function moveAlert(tp, lft) {
	el = document.getElementById("divMainAlert");
	if (tp >=0) el.style.top = tp + "px";
	if (lft >=0) el.style.left = lft + "px";
}

function moveAlert2(id, tp, lft) {
	el = document.getElementById("divAlert_" + id);
	if (tp >=0) el.style.top = tp + "px";
	if (lft >=0) el.style.left = lft + "px";
}

function resizeAlert2(id, wd, ht) {
	el = document.getElementById("divAlertID_" + id + "_mainTable");	el.style.width=wd + "px";	el.style.height=ht + "px";
//	el = document.getElementById("divAlertID_" + id + "_secondTD");	el.style.width=wd + "px";	el.style.height=ht + "px";
//	el = document.getElementById("divAlertID_" + id + "_firstTD");	el.style.width=wd + "px";	
//	el = document.getElementById("divAlertID_" + id + "_innerTable");	el.style.width=wd + "px";	el.style.height=ht + "px";
	el = document.getElementById("divAlert_" + id);	el.style.width=wd + "px";	el.style.height=ht + "px";
}

function hideAlert2(id) {
	if (dragObj) endDrop();

	el = document.getElementById("divAlert_" + id);
	el.style.display='none';

	mainZIndex --;
	if (mainZIndex <= 1) makeAllTransparent(100);
}


function _showWindow(posX, posY, txt) {
	winid = generateID();
	windows[winid] = [winid, true];
	
	document.createElement("div");
	div.id = winid;
	div.style.position = "absolute";

	el = document.getElementById("body");
	el.appendChild(div);

	div.style.top = posX + "px";
	div.style.left = posY + "px";
	div.innerHTML = txt;

	div.onclick = "beginDrag";

	return winid;
}

function showWindowID(id) {
	windows[id] = [id, true];
	w = document.getElementById(winid);
	w.style.display = 'block';
}


function closeWindow(winid) {
	w = document.getElementById(winid);
	w.style.display = 'none';
	windows[winid][1] = [false];

}

function closeWindows() {
	for (x in windows)
	{
		closeWindow(windows[x]);
	}
}

function generateID() {
	objIndex = objIndex + 1;
	return objIndex;
}


function getWaitIcon() {
	return " please wait ... ";
}

var lastErr = "";
function showLogin(err) {
	lastErr = err;
	el = document.getElementById("divMainAlert");
	stdAlertID = showAlert(stdAlertID, '<img src="images/ms_login_head.gif" width="200" height="13">', getWaitIcon(),0,0);

	url = "index.php?n=Users&o=login";
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showLogin;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _showLogin() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("content");
	y= x[0].firstChild.data;
	if (lastErr != '')
	{
		lastErr = "<center><span class='error'>" + lastErr + "</span></center><br>";
	}
	stdAlertID = showAlert(stdAlertID, '<img src="images/ms_login_head.gif" width="200" height="13">', lastErr + y, 0, 0);
	lastErr = "";
  }
}

/* contact us */
var contactAlertID = 0;
function showContactUs(towerid, suiteid) {
	contactAlertID = showAlert2(0, 'contact', getWaitIcon(),"");
	url = "index.php?n=Home&o=contact&towerid=" + towerid + "&suiteid=" + suiteid;
	showWait(contactAlertID);
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showContactUs;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}

}

function _showContactUs() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("content");
	y= x[0].firstChild.data;

	showAlert2(contactAlertID, 'contact', y, "");

  }
}

function submitContactUs() {
	el=document.getElementById('Name');	name = el.value;
	el=document.getElementById('Email');	email = el.value;
	el=document.getElementById('Subject');	subject = el.value;
	el=document.getElementById('Message');	msg = el.value;

	showWait(contactAlertID);

	url = "index.php?n=Home&o=docontact&Name=" + name + "&Email=" + email + "&Subject=" + subject + "&Message=" + msg;
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_submitContactUs;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _submitContactUs() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("result");
	y= x[0].firstChild.data;
	showAlert2(contactAlertID, 'contact', y, "");
	resizeAlert2(contactAlertID, 500, 100);
	contactAlertID = 0;
  }
}

/* END contact us */

var friendAlertID = 0;
/* send to friend  */
function showSendToFriend() {
	friendAlertID = showAlert2(0, 'sendfriend', getWaitIcon(),"");
	url = "index.php?n=Home&o=sendfriend&link=" + encodeURIComponent(window.location);
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showSendToFriend;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}

}

function _showSendToFriend() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("content");
	y= x[0].firstChild.data;
	showAlert2(friendAlertID, 'sendfriend', y, "");
  }
}

function submitSendToFriend() {
	el=document.getElementById('Name');	name = el.value;
	err = 0;
	
	el=document.getElementById('sendFriendNameErr');	
	if (name == " " || name == "")
	{
		el.innerHTML = "name is required<br>";
		err=1;
	} else {
		el.innerHTML = "";
	}

	el=document.getElementById('ToEmail');	email2 = el.value;
	el=document.getElementById('sendFriendEmail2Err');	
	if (email2 == "")
	{
		el.innerHTML = "Email address is required<br>";
		err=1;
	} else {
		el.innerHTML = "";
	}

	el=document.getElementById('Email');	email = el.value;
	el=document.getElementById('sendFriendEmailErr');	
	if (email == "")
	{
		el.innerHTML = "Email address is required<br>";
		err=1;
	} else {
		el.innerHTML = "";
	}
	
	el=document.getElementById('Subject');	subject = el.value;
	el=document.getElementById('sendFriendSubjectErr');	
	if (subject == "")
	{
		el.innerHTML = "Subject is required<br>";
		err=1;
	} else {
		el.innerHTML = "";
	}	
	
	if (err == 1)
	{
//		stdAlertID = showAlert2(stdAlertID, "error", ", "");
		return false;
	} 
	el=document.getElementById('Message');	msg = el.value;

	showWait(friendAlertID);

	url = "index.php?n=Home&o=dosendfriend&Name=" + name + "&ToEmail=" + email2 + "&Email=" + email + "&Subject=" + subject + "&Message=" + msg + "&link=" + encodeURIComponent(window.location) + "&suiteid=" + curSuiteID + "&blogid=" + curBlogID;
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_submitSendToFriend;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _submitSendToFriend() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("result");
	y= x[0].firstChild.data;
	showAlert2(friendAlertID, 'sendfriend', y, "");
	friendAlertID = 0;
  }
}

/* END send to friend*/

/* contact us */
var registerAlertID = 0;
function showRegister(towerid, suiteid) {
	registerAlertID = showAlert2(0, 'contact', getWaitIcon(),"");
	url = "index.php?n=Home&o=register";
	showWait(contactAlertID);
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showRegister;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}

}

function _showRegister() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("content");
	y= x[0].firstChild.data;

	showAlert2(registerAlertID, 'contact', y, "");

  }
}

function submitRegister() {
	el=document.getElementById('Name');	name = el.value;
	el=document.getElementById('Email');	email = el.value;
	el=document.getElementById('Subject');	subject = el.value;
	el=document.getElementById('Message');	msg = el.value;

	showWait(registerAlertID);

	url = "index.php?n=Home&o=docontact&Name=" + name + "&Email=" + email + "&Subject=" + subject + "&Message=" + msg;
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_submitRegister;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _submitRegister() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("result");
	y= x[0].firstChild.data;
	showAlert2(registerAlertID, 'contact', y, "");
	resizeAlert2(registerAlertID, 500, 100);
	registerAlertID = 0;
  }
}


function showPage(page) {
//	stdAlertID = showAlert(stdAlertID, '<div width="200" height="13" style="background-color: #000000; ">&nbsp;</div>', getWaitIcon(),0,0);
	stdAlertID = showAlert2(0, 'legal', getWaitIcon(),"");
	url = "index.php?n=Home&o=get_full_page&id=" + page;
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showPage;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}

}

function _showPage() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("content");
	txt= x[0].firstChild.data;
	x=response.getElementsByTagName("title");
	title = x[0].firstChild.data;
//	stdAlertID = showAlert(stdAlertID, '<div style="width: 600px; height: 13px; background-color: #000000; color: #fff;">'+title+'</div>', "<div style='width: 600px; '>"+txt+"</body>", 0, 0);
	showAlert2(stdAlertID, 'buycondo', txt, "");

  }
}


function showBlogPopup(type) {
	stdAlertID = showAlert(stdAlertID, '<div width="200" height="13" style="background-color: #000000; ">&nbsp;</div>', getWaitIcon(),0,0);
	url = "index.php?n=Condo&o="+type+"&xml=true";
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showBlogPopup	;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}

}

function _showBlogPopup() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("content");
	txt= x[0].firstChild.data;
	x=response.getElementsByTagName("title");
	title = x[0].firstChild.data;
	stdAlertID = showAlert(stdAlertID, '<div width="200" height="13" style="background-color: #000000; color: #fff;">'+title+'</div>', "<div style='width: 450px; height: 450px;'>"+txt+"</body>", 0, 0);
  }
}


function showSearch() {
	makeAllTransparent(10);
	el = document.getElementById("divSearch");
	if (!el)
	{
		url = "index.php?n=Condo&o=get_search";
		initObj();
		if (xmlhttp!=null) {
		  xmlhttp.onreadystatechange=_showSearch;
		  xmlhttp.open("GET",url,true);
		  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
		  xmlhttp.send(null);
		}
	} else {
		el.style.display = 'block';
	}

}

function _showSearch() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("content");
	txt = getXMLNode(x);
	dv = document.createElement("div");
	dv.id="divSearch";
	dv.innerHTML = txt;
	dv.className = "searchpop";
	dv.style.display = 'block';
	dv.style.width="345px";
	dv.style.height="354px";
	dv.style.top = "120px";
	dv.style.left = "400px";
	mainZIndex ++;
	dv.style.zIndex = mainZIndex;
	bdy = document.getElementsByTagName("body");
	bdy[0].appendChild(dv);


  }

}

function doSearch() {
	url = "index.php?n=Condo&o=results";
	el = document.getElementById("Price");
	url += "&Price=" + el.options[el.selectedIndex].value;
	el = document.getElementById("Sqft");
	url += "&Sqft=" + el.options[el.selectedIndex].value;
	el = document.getElementsByName("View[]");
	for (i = 0; i<el.length; i++)
	{
		tmp = [];
		if (el[i].checked) 
		{
			url += "&View[]=" + el[i].value
		}
	}

	el = document.getElementsByName("Type[]");
	for (i = 0; i<el.length; i++)
	{
		tmp = [];
		if (el[i].checked) 
		{
			url += "&Type[]=" + el[i].value
		}
	}

	el = document.getElementsByName("CommunityID[]");
	for (i = 0; i<el.length; i++)
	{
		tmp = [];
		if (el[i].checked) 
		{
			url += "&CommunityID[]=" + el[i].value
		}
	}
	
	el = document.getElementById("divSearch");
	el.style.left= (getWindowWidth() - el.offsetWidth - 25) + "px";
//	el = document.getElementById("debug");
//	el.value = url;
		
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showSearchResults;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

function _showSearchResults() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("content");

	txt= getXMLNode(x);
	el = document.getElementById("divSearchResults");
	if (!el)
	{
		el = document.createElement("div");
		el.id="divSearchResults";
		el.className = "searchpop";
		el.style.display = 'block';
		el.style.top = "120px";
		bdy = document.getElementsByTagName("body");
		bdy[0].appendChild(el);
		mainZIndex ++;
	}  else {
		if (el.style.display != "block")
		{
			mainZIndex ++;
		}
	}
	el.innerHTML = txt;
	el.style.zIndex = mainZIndex;
	el2 = document.getElementById("noResults");
	cnt=response.getElementsByTagName("results");
	el2.innerHTML = getXMLNode(cnt);

	tigra_tables('resultslist', 1, 0, '#ffffff', mainColorCodes[mainColor], '#cccccc', '#cccccc');

	src = document.getElementById("divSearch");
	wd = parseInt(getWindowWidth()) - parseInt(src.offsetWidth) - 650;
	if (wd <0) wd = 0;
	el.style.left= wd + "px";
	el.style.display = 'block';
  }

}


function hideSearch() {
	el = document.getElementById("divSearch");
	el.style.display = 'none';
	mainZIndex --;
	if (mainZIndex <= 1) makeAllTransparent(100);

}

function hideSearchResults() {
	el = document.getElementById("divSearchResults");
	el.style.display = 'none';
	mainZIndex --;
	if (mainZIndex <= 1) makeAllTransparent(100);
}

function showWait(id) {
	showAlert2(id, '', getAjaxWait(), "");
}

function getAjaxWait() {
	return "<div style='width: 100%; text-align: center; '><img src='images/ajax.gif'></div>";
}

function showLegal() {
	stdAlertID = showAlert2(0, 'legal', getWaitIcon(),"");
	url = "index.php?n=Home&o=xml_page&id=legal";
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showLegal;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}

}

function _showLegal() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("content");
	y= x[0].firstChild.data;

	showAlert2(stdAlertID, 'legal', y, "");
  }
}

function showPrivacy() {
	stdAlertID = showAlert2(0, 'legal', getWaitIcon(),"");
	url = "index.php?n=Home&o=xml_page&id=privacy";
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showPrivacy;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}

}

function _showPrivacy() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("content");
	y= x[0].firstChild.data;

	showAlert2(stdAlertID, 'legal', y, "");
  }
}

function showTerms() {
	stdAlertID = showAlert2(0, 'legal', getWaitIcon(),"");
	url = "index.php?n=Home&o=xml_page&id=terms";
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showTerms;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}

}

function _showTerms() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("content");
	y= x[0].firstChild.data;

	showAlert2(stdAlertID, 'legal', y, "");
  }
}

function showAboutUs() {
	stdAlertID = showAlert2(0, 'legal', getWaitIcon(),"");
	url = "index.php?n=Home&o=xml_page&id=about-us";
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showAboutUs;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}

}

function _showAboutUs() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("content");
	y= x[0].firstChild.data;

	showAlert2(stdAlertID, 'legal', y, "");
  }
}

function showIndex() {
alert(mainZIndex);
}


function showMap(id) {
	switch (id)
	{
		case 1: showSalesMap();break;
		case 2: showAmenitiesMap();break;
	}
}

function showSalesMap() {
	if (GBrowserIsCompatible()) {
		showAlert2(0, "salescentre", "<div id='map1' style='width: 800px; height: 500px; '></div>", "");
	  var map = new GMap2(document.getElementById("map1"));
	  var point = new GLatLng(43.608950,-79.556831);
	  map.addControl(new GLargeMapControl());
	  map.addControl(new GMapTypeControl());
	  map.setCenter(point, 15, G_HYBRID_MAP);
	  txt = "Sales Office <br>700 Evans Ave<br>Etobicoke, Ontario;<br>M9C 1A1	";
	  function createMarker(point, txt) {
		var marker = new GMarker(point);
		GEvent.addListener(marker, "click", function() {
		  marker.openInfoWindowHtml(txt);
		});
		return marker;
	  }
	  var point = new GLatLng(43.608950,-79.556831); map.addOverlay(createMarker(point, txt));
	}
}


function showAmenitiesMap() {
	showAlert2(0, "neighbourhood", "<div id='map4' style='width: 900px; height: 520px; '></div>", "");
	load(4);
	return true;
	if (GBrowserIsCompatible()) {
		showAlert2(0, "map", "<div id='map4' style='width: 900px; height: 550px; '></div>");
	  var map = new GMap2(document.getElementById("map4"));
	  var point = new GLatLng(43.608950,-79.556831);
	  map.addControl(new GLargeMapControl());
	  map.addControl(new GMapTypeControl());
	  map.setCenter(point, 15, G_HYBRID_MAP);
	  txt = "Sales Office <br>700 Evans Ave<br>Etobicoke, Ontario;<br>M9C 1A1	";
	  function createMarker(point, txt) {
		var marker = new GMarker(point);
		GEvent.addListener(marker, "click", function() {
		  marker.openInfoWindowHtml(txt);
		});
		return marker;
	  }
	  var point = new GLatLng(43.608950,-79.556831); map.addOverlay(createMarker(point, txt));
	}
}

var areaAmenities = new Array();
function showAreaAmen(amenid) {
//	status = areaAmenities[amenid][0];
//	areaAmenities[amenid][0] = 1 - areaAmenities[amenid][0];
//	el = document.getElementById("img_" + amenid);
	  var point = new GLatLng(areaAmenities[amenid][1], areaAmenities[amenid][2]);
	areaMap.setZoom(12);
	areaMap.panTo(point);
}


alertPDF = 0;
function checkPDF() {
	if (acrobatVersion > 1) return true;
	checkPDF = showAlert2(alertPDF, "acrobat", "<div style=\"padding: 30px; height: 250px; \">This document requires the Adobe Acrobat Reader. Click on the image below to obtain this free software.<br><br><a href='http://www.adobe.com/go/EN_US-H-GET-READER'><img border=\"0\" src=\"images/get_adobe_reader.gif\" ></a></div>", "");
}

function doLogin() {
	el = document.getElementById('Username');
	lastErr = "";
	url = "index.php?n=Users&o=ajaxlogin&username=" + el.value;
	el = document.getElementById('Password');
	url += "&password=" + md5(el.value);
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_doLogin;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
	return false;
}

function _doLogin() {
  if(checkReadyState(xmlhttp)) {
	var response = xmlhttp.responseXML.documentElement;
	response.normalize;
	x=response.getElementsByTagName("content");
	content= getXMLNode(x);
	x=response.getElementsByTagName("response");
	ret= x[0].firstChild.data;
	x=response.getElementsByTagName("nexturl");
	url= x[0].firstChild.data;


	if (ret != 'ok')
	{
		lastErr = "<center><span class='error'>" + ret + "</span></center><br>";
		stdAlertID = showAlert(stdAlertID, '<img src="images/ms_login_head.gif" width="200" height="13">', lastErr + content, 0, 0);
		lastErr = "";
	} else {
		if (url != "x")
		{
			window.location = url;
		} else {
			stdAlertID = showAlert(stdAlertID, '<img src="images/ms_login_head.gif" width="200" height="13">', content, 0, 0);
			lastErr = "";
		}

	}
  }

}

