function showModelOptions(id) {
	el = document.getElementById("modelList" + id);
	el.style.display = "none";
	el = document.getElementById("modelOptions" + id);
	el.style.display = "block";
}


function hideModelOptions(id) {
	el = document.getElementById("modelList" + id);
	el.style.display = "block";
	el = document.getElementById("modelOptions" + id);
	el.style.display = "none";
}

function loadModel(name, type, price, lot, size, plans, thumb, img, id, beds) {
	el = document.getElementById('modelName');
	el.innerHTML = name;

	el = document.getElementById('modelType');
	el.innerHTML = type;

	el = document.getElementById('modelPrice');
	el.innerHTML = price;

	el = document.getElementById('modelSize');
	el.innerHTML = size;

	el = document.getElementById('modelLot');
	el.innerHTML = lot;

	el = document.getElementById('modelBeds');
	el.innerHTML = beds;

	el = document.getElementById('modelDwldPlans');
	el.href = plans;

	el = document.getElementById('modelDwldPlans2');
	el.href = plans;

	el = document.getElementById('enlargeLink');
	el2 = document.getElementById('enlargeLink2');
	el.href = "#self";
	el2.href = "#self";
	el.onclick = function () {showImagePopup(thumb)};
	el2.onclick = function () {showImagePopup(thumb)};

	el = document.getElementById('contactLink');
	el.href = "#self";
	el.onclick = function () {contactMe(id)};
	
//	el = document.getElementById('modelThumb');
//	el.src = thumb;
	
	el = document.getElementById('modelThumb');
	txt = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="360" height="245" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"><param name="movie" value="swf/model.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="transparent" />';
	txt += '<param <param name="FlashVars" value="imagePath='+thumb+'" />';
	txt += '<embed src="swf/model.swf" quality="high" bgcolor="#ffffff" width="360" height="245" name="model" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" FlashVars="imagePath='+thumb+'" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';
	el.innerHTML = txt;
		
//	el = document.getElementById('modelEnlarge1');
//	el.href = thumb;

}

function loadModelExtended(name, type, price, lot, size, plans, thumb, img, ffinfo, city, community, id, beds) {
	el = document.getElementById('modelDwldFF');
	el.href = ffinfo;

	el = document.getElementById('modelDwldFF2');
	el.href = ffinfo;

	el = document.getElementById('commName');
	el.innerHTML = community;

	el = document.getElementById('modelCity');
	el.innerHTML = city;

	loadModel(name, type, price, lot, size, plans, thumb, img, id, beds);
}


function showModelImage(id, name, thumb, img) {

	
	el = document.getElementById('modelThumb');
	txt = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="360" height="245" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"><param name="movie" value="swf/model.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="transparent" />';
	txt += '<param <param name="FlashVars" value="imagePath='+thumb+'" />';
	txt += '<embed src="swf/model.swf" quality="high" bgcolor="#ffffff" width="360" height="245" name="model" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" FlashVars="imagePath='+thumb+'" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';
	el.innerHTML = txt;

	el = document.getElementById('modelName');
	el.innerHTML = name;

	el = document.getElementById('enlargeLink');
	el2 = document.getElementById('enlargeLink2');
	el.href = "#self";
	el2.href = "#self";
	el.onclick = function () {showImagePopup(thumb)};
	el2.onclick = function () {showImagePopup(thumb)};

//	el = document.getElementById('modelEnlarge1');
//	el.href = thumb;

}

imageAlertID = 0
function showImagePopup(thumb) {
	img = new Image();
	img.src = thumb.replace(".jpg", "_l.jpg");
	img.onload = function() { imageAlertID = showAlert(imageAlertID, "<img src=\""+thumb.replace(".jpg", "_l.jpg")+"\">", "");};
}

function showImagePopup2(thumb) {
	imageAlertID = showAlert(imageAlertID, "<img src=\""+thumb+"\">", "");
}


function compare(id, type) {
	url = "index.php?n=Aspen&o=compare&id=" + id + "&type=" + type;
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_compare;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}


function _compare() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		x=response.getElementsByTagName("id");
		id = getXMLNode(x);	

		x=response.getElementsByTagName("result");
		res = getXMLNode(x);	

		x=response.getElementsByTagName("error");
		error = getXMLNode(x);	

		el = document.getElementById("compareLink" + id);
		el.onclick = function() { compare(id, res);};
		if (res == "on") {
			el.innerHTML = "compare"; 
		} else {
			el.innerHTML = "uncompare";
			el.style.color = '#ffffff';
			el.style.backgroundColor = '#0066cc';
		}
		
		if (error != "none")
		{
			showError(error);
		}
	}
}

function addToFavorites(id, type) {
	url = "index.php?n=Aspen&o=add_to_faves&id=" + id + "&type=" + type;
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_addToFavorites;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}


function _addToFavorites() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		x=response.getElementsByTagName("id");
		id = getXMLNode(x);	

		x=response.getElementsByTagName("result");
		res = getXMLNode(x);	

		el = document.getElementById("favoritesLink" + id);
		el.onclick = function() { addToFavorites(id, res);};
		if (res == "on") el.innerHTML = "add to favourites"; else {
			el.innerHTML = "remove favourite";
			el.style.color = '#ffffff';
			el.style.backgroundColor = '#0066cc';
		}
		
	}
	if (getQueryVariable('o') == "favourites") window.location.reload();
}

function showComparison() {
	url = "index.php?n=Aspen&o=get_comparison";
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showComparison;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}


alertComparison = 0;
function _showComparison() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		x=response.getElementsByTagName("content");
		txt = getXMLNode(x);	
		
		alertComparison = showAlert(alertComparison, txt , "comparison");

	}
}

function showSearch() {
	return showHomeFinder();
}
function showHomeFinder() {
	url = "index.php?n=Aspen&o=get_finder";
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_showHomeFinder;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}


alertFinder = 0;
function _showHomeFinder() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		x=response.getElementsByTagName("content");
		txt = getXMLNode(x);	
		
		alertFinder = showAlert(alertFinder, txt , "newhomefinder");

	}
}

function searchByComm() {
	el = document.getElementById("SearchType");
	el.value = 'comm';
	el = document.getElementById("searchCommunities");
	el.style.display = "inline";
	el = document.getElementById("searchCities");
	el.style.display = "none";
}

function searchByCity() {
	el = document.getElementById("SearchType");
	el.value = 'city';
	el = document.getElementById("searchCommunities");
	el.style.display = "none";
	el = document.getElementById("searchCities");
	el.style.display = "inline";

}

function toggleAllComm(obj) {
	el = document.getElementsByName("CommunityID[]");
	for (i=0; i< el.length; i++)
	{
		if (obj.checked)
		{
			el[i].checked = true;
		} else {
			el[i].checked = false;
		}
	} 
}

function toggleAllCities(obj) {
	el = document.getElementsByName("CityID[]");
	for (i=0; i< el.length; i++)
	{
		if (obj.checked)
		{
			el[i].checked = true;
		} else {
			el[i].checked = false;
		}
	} 

}


function showNews(image, name, id) {

	
	el = document.getElementById('newsImage');
	el.src = image;

	el = document.getElementById('newsTitle');
	el.innerHTML = name;

	el = document.getElementById('newsLink');
	el.href = "index.php?n=News&o=view&id=" + id;

//	el = document.getElementById('modelEnlarge1');
//	el.href = thumb;

	el = document.getElementById('newsImage');
	txt = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="222" height="318" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"><param name="movie" value="swf/news.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="transparent" />';
	txt += '<param <param name="FlashVars" value="imagePath='+image+'" />';
	txt += '<embed src="swf/news.swf" quality="high" bgcolor="#ffffff" width="222" height="318" name="news" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" FlashVars="imagePath='+image+'" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';
	el.innerHTML = txt;

}

function showEvent(image, name, id) {

	
//	el = document.getElementById('eventImage');
//	el.src = image;

	el = document.getElementById('eventTitle');
	el.innerHTML = name;

	el = document.getElementById('eventLink');
	el.href = "index.php?n=Events&o=view&id=" + id;

	el = document.getElementById('eventImage');
	txt = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="222" height="318" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"><param name="movie" value="swf/news.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="transparent" />';
	txt += '<param <param name="FlashVars" value="imagePath='+image+'" />';
	txt += '<embed src="swf/news.swf" quality="high" bgcolor="#ffffff" width="222" height="318" name="news" align="middle" play="true" loop="false" quality="high" allowScriptAccess="sameDomain" FlashVars="imagePath='+image+'" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';
	el.innerHTML = txt;

}


function showCareDetails(id) {
	el = document.getElementById("Community" + id);
	el.style.display = "none";
	el = document.getElementById("Details" + id);
	el.style.display = "block";
}

function hideCareDetails(id) {
	el = document.getElementById("Community" + id);
	el.style.display = "block";
	el = document.getElementById("Details" + id);
	el.style.display = "none";
}

curFontSize = 12;
function changeFontSize(dif) {
	el = document.getElementsByTagName("body");
	curFontSize += dif;
	el[0].style.fontSize = (curFontSize) + "px";
//	alert(el[0].style.fontSize);
//	for (i=0 ; i<el.length ; i++)
//	{
//		el[i].style.fontSize = parseInt(el[i].style.fontSize) + dif;
//	}
//
//	el = document.getElementsByTagName("td");
//	for (i=0 ; i<el.length ; i++)
//	{
//		el[i].style.fontSize = parseInt(el[i].style.fontSize) + dif;
//	}
//
//	el = document.getElementsByTagName("span");
//	for (i=0 ; i<el.length ; i++)
//	{
//		el[i].style.fontSize = parseInt(el[i].style.fontSize) + dif;
//	}
//
//	el = document.getElementsByTagName("a");
//	for (i=0 ; i<el.length ; i++)
//	{
//		el[i].style.fontSize = parseInt(el[i].style.fontSize) + dif;
//	}

}


function contactMe(id) {
	url = "index.php?n=Aspen&o=contactme&id=" + id;
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_contactMe;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

contactAlertID = 0
function _contactMe() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		x=response.getElementsByTagName("content");
		txt = getXMLNode(x);	
		contactAlertID = showAlert(contactAlertID, txt, "contactme");
		
	}
}

function doContactMe() {
	obj = document.getElementById("frmContact");
	txt = getForm(obj);
	if (txt != "error") url = "index.php?n=Aspen&o=docontactme&" + txt ;
	else return false;
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_doContactMe;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}


function _doContactMe() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		x=response.getElementsByTagName("content");
		txt = getXMLNode(x);	
		el = document.getElementById("pophometd");
		el.innerHTML = txt;
	}
}

function sendToFriend(id) {
	url = "index.php?n=Aspen&o=sendtofriend";
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_sendToFriend;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}

contactAlertID = 0
function _sendToFriend() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		x=response.getElementsByTagName("content");
		txt = getXMLNode(x);	
//		contactAlertID = showAlert(contactAlertID, txt, "sendfriend");
		showWait(txt);
		
	}
}

function doSendToFriend() {
	obj = document.getElementById("frmContact");
	url = "index.php?n=Aspen&o=dosendtofriend&" + getForm(obj);
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_doSendToFriend;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}
}


function _doSendToFriend() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		x=response.getElementsByTagName("content");
		txt = getXMLNode(x);	
		showWait(txt);
	}
}

mapAlertID = 0;
function showGoogleMap(lat, lng, txt) {
	if (GBrowserIsCompatible()) {
//		mapAlertID = showAlert(mapAlertID, "<div id='map1' style='width: 800px; height: 500px; '></div>", "");

		showGooglePopup();
	  var map = new GMap2(document.getElementById("map1"));
	  var point = new GLatLng(lat,lng);
	  map.addControl(new GLargeMapControl());
	  map.addControl(new GMapTypeControl());
	  map.setCenter(point, 15, G_HYBRID_MAP);
	  function createMarker(point, txt) {
		var marker = new GMarker(point);
		GEvent.addListener(marker, "click", function() {
		  marker.openInfoWindowHtml(txt);
		});
		return marker;
	  }
	  var point = new GLatLng(lat, lng);
	  map.addOverlay(createMarker(point, txt));
	}
}


function showGooglePopup() {
	setOpacity(10);
	txt = "";
	txt += '<table width="780" height="30" border="0" cellpadding="0" cellspacing="0">';
	txt += '		<tr>';
	txt += '			<td width="518" height="30" align="left" valign="top" style="padding-left:30px; padding-top:5px; padding-bottom:5px;"><div class="pophomename">Google Map</div></td>';
	txt += '			<td width="314" align="right" valign="top" style="padding-top:5px; padding-right:5px;"><a href="javascript:;" onclick="closeGooglePopup()" onmouseover="MM_swapImage(\'bttnclosepop\',\'\',\'images/closepop_over.gif\',0)" onmouseout="MM_swapImgRestore()"><img src="images/closepop_up.gif" name="bttnclosepop" width="20" height="20" border="0" id="bttnclosepop" /></a></td>';
	txt += '		</tr>';
	txt += '</table>';
	txt += '<div id="map1" style="width: 700px; height: 470px; margin: 10px 0px; "></div>';

	el = document.getElementById("popgoogle");
	if (!el)
	{
		el = document.createElement("div");
		el.id = "popgoogle";
		el.style.backgroundImage = "url(images/bg_popup_google.gif)";
		el.style.width =  '834px';
		el.style.backgroundRepeat =  'no-repeat';
		el.style.height=  '564px';
		el.style.zIndex =  10;
//		el.style.backgroundColor =  "#ffffff";
		el.innerHTML = txt;
		el.style.display='block';

		bdy = document.getElementsByTagName("body");
		bdy[0].appendChild(el);
		
		h = el.offsetHeight;
		w = el.offsetWidth;

		c = getCenter2(832,550);
		
		el.style.position =  'absolute';
		el.style.zIndex = 1 ;

		el.style.top = Math.max(0, c.y - 100) + "px";
		el.style.left = Math.max(0, c.x) + "px";

	} 
	el.style.display='block';


}

function closeGooglePopup() {
	setOpacity(100);
	el = document.getElementById("popgoogle");
	el.style.display = "none";
}


var generalPopupID = 0
function showPage(type) {
	url = "index.php?n=Aspen&o=get_page&id=" + type;
	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 = getXMLNode(x);	
		x=response.getElementsByTagName("title");
		title = getXMLNode(x);	
		contactAlertID = showAlert(contactAlertID, txt, title);
	}
}

function imapInit(id) {
	url = "index.php?n=Aspen&o=get_amenities_map&id=" + id;
	initObj();
	if (xmlhttp!=null) {
	  xmlhttp.onreadystatechange=_imapInit;
	  xmlhttp.open("GET",url,true);
	  xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
	  xmlhttp.send(null);
	}

}

var amenityTypes = [];
var amenities = [];
var markers = [];
function _imapInit() {
	if(checkReadyState(xmlhttp)) {
		var response = xmlhttp.responseXML.documentElement;
		response.normalize;
		x=response.getElementsByTagName("content");
		txt = getXMLNode(x);	
		x=response.getElementsByTagName("amenScript");
		eval(getXMLNode(x));	

		if (GBrowserIsCompatible()) {
			mapAlertID = showAlert(mapAlertID, txt, "");
		  var map = new GMap2(document.getElementById("map1"));
		  var point = new GLatLng(amenities[0][3], amenities[0][4]);
		  map.addControl(new GLargeMapControl());
		  map.addControl(new GMapTypeControl());
		  map.setCenter(point, 12, G_HYBRID_MAP);
		  function createMarker(point, txt) {
			var marker = new GMarker(point);
			GEvent.addListener(marker, "click", function() {
			  marker.openInfoWindowHtml(txt);
			});
			return marker;
		  }
			for (i=0; i< amenities.length; i++)
			{
				var point = new GLatLng(amenities[i][3], amenities[i][4]); 
				txt = "<b>" + amenities[i][1] + "</b><br><br>" + amenities[i][2];
				markers[markers.length] = map.addOverlay(createMarker(point, txt));
			}
		}
	}
}

function _nothing() {

}


function showGallery(id) {
	txt ='<object width="600" height="422" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param value="swf/gallery.swf" name="movie"/><param value="high" name="quality"/><param value="#ffffff" name="bgcolor"/><param value="transparent" name="wmode"/><param value="galleryID='+id+'" name="FlashVars"/><embed width="600" height="422" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" flashvars="galleryID='+id+'" allowscriptaccess="sameDomain" quality="high" loop="false" play="true" name="gallery" bgcolor="#ffffff" src="swf/gallery.swf"/></object>';
	el = document.getElementById('amenlarge');	
	el.innerHTML = txt;
}

function showPrint() {
	window.open(location.href.replace("#self", "") + "&print=yes",'print','width=880, height=500, menus=yes, scrollbars=yes');
}

