var models = [];
var maxPrice = 9999999;
var homeType = 0;
var lowestPrice = 0;
var greatestPrice = 0;
function sortByName(a, b) {
	var x = a.Name.toLowerCase();
    var y = b.Name.toLowerCase();
    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

function sortByType(a, b) {
	var x = a.TypeID;
    var y = b.TypeID;
    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

function sortByBedrooms(a, b) {
	var x = parseInt(a.Bedrooms);
    var y = parseInt(b.Bedrooms);
	if (!x) x=99;
	if (!y) y=99;
    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

function sortByLot(a, b) {
	var x = a.Lot.toLowerCase();
    var y = b.Lot.toLowerCase();
    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

function sortByPrice(a, b) {
	var x = parseInt(a.Price);
    var y = parseInt(b.Price);
    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

function sortByBathrooms(a, b) {
	var x = parseInt(a.Bathrooms);
    var y = parseInt(b.Bathrooms);
    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

function sortBySize(a, b) {
	var x = parseInt(a.Size);
    var y = parseInt(b.Size);
    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

function sortByOccup(a, b) {
	var x = parseInt(a.Occupancy);
    var y = parseInt(b.Occupancy);
    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
}

function setType(type) {
	homeType = type;
	obj = document.getElementById("sliderDot1");
	if (obj) obj.style.marginLeft =   "0px";

	showModels();

//	el = document.getElementById("minPriceLabel");
//	el.innerHTML = formatPrice(lowestPrice);
//
//	el = document.getElementById("maxPriceLabel");
//	el.innerHTML = formatPrice(greatestPrice);

}

function setPrice(price) {
//	return true;
	newPrice = lowestPrice + (parseInt(price)/96) * (greatestPrice - lowestPrice);
	newPrice = Math.floor(newPrice);
//	if (Math.abs(newPrice - maxPrice) < 20000)
//	{
//		return true;
//	}
	maxPrice = newPrice;
	el = document.getElementById("maxPriceLabel");
	el.innerHTML = formatPrice(maxPrice);

	showModels();
}

function formatPrice(num)
{
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + '$' + num);
}

function sortModels(sortOrder) {
	switch (sortOrder)
	{
		case "name": models.sort(sortByName); break;
		case "type": models.sort(sortByType); break;
		case "bedrooms": models.sort(sortByBedrooms); break;
		case "bathrooms": models.sort(sortByBathrooms); break;
		case "lot": models.sort(sortByLot); break;
		case "price": models.sort(sortByPrice); break;
		case "size": models.sort(sortBySize); break;
		case "occup": models.sort(sortByOccup); break;
	}
	showModels();
}

function showModels() {
	el = document.getElementById("modelsList");
	txt = '';
	modelShown = -1;
	lowestPrice = 9999999;
	highestPrice = 0;
	count = 0;

	towns = 0;
	singles = 0;
	semis = 0;
	for (i in models)
	{
//		alert(models[i].TypeID);
		switch (parseInt(models[i].TypeID))
		{
			case 1: singles ++; break;
			case 2: semis ++; break;
			case 3: towns ++; break;
		}
		if (homeType != 0 && homeType != models[i].TypeID) continue;
		if (models[i].Price > maxPrice) continue;
		if (modelShown < 0)
		{
			modelShown = i;
		}
		count ++;
		if (parseInt(lowestPrice) > parseInt(models[i].Price)) lowestPrice = parseInt(models[i].Price);
		if (parseInt(highestPrice) < parseInt(models[i].Price)) highestPrice = parseInt(models[i].Price);

		if (getQueryVariable("o") == "move_in_now") colsp = 7; else colsp = 6;
		txt += '<table id="modelTable'+i+'" width="617" height="44" border="0" cellpadding="0" cellspacing="0" class="normal" onmouseover="modelOver(this, '+i+');" onmouseout="modelOut(this, '+i+');" onclick="selectModel(this, '+i+'); showModelPopup();">';
		txt += '			  <tr>';
		txt += '				<td height="20" colspan="'+colsp+'" style="padding-left:10px;"><b>'+models[i].City + '</b>';
		if (models[i].Encore == "yes") {
			txt += '<img align="center" src="images/encorecard_tn.jpg" style="margin: 0px 2px 0px 7px;" title="Encore Series">';
		}
		txt += '</td>';
		txt += '</tr>';
		txt += '			  <tr>';
		txt += '				<td height="20" colspan="'+colsp+'" style="padding-left:10px;"><i>'+models[i].Name+'</i></td>';
		txt += '</tr>';
		txt += '<tr>';
		txt += '		<td width="156" height="20"><span style="padding-left:10px;">'+models[i].Community+'</span></td>';
		
		if (getQueryVariable("o") == "move_in_now") {
			txt += '		<td width="93">'+models[i].Type.replace("single/", "") +'</td>';
			txt += '		<td width="68">'+models[i].Occupancy+' months</td>';
			txt += '		<td width="40">'+models[i].Bedrooms+'</td>';
	//		txt += '		<td width="84">'+models[i].Bathrooms+'</td>';
			txt += '		<td width="60">'+models[i].Lot+'</td>';
			txt += '		<td width="40">'+models[i].Size+'</td>';
			txt += '		<td width="78">'+models[i].FPrice+'</td>';
			txt += '</tr>';
		} else {
			txt += '		<td width="113">'+models[i].Type+'</td>';
			txt += '		<td width="58">'+models[i].Bedrooms+'</td>';
	//		txt += '		<td width="84">'+models[i].Bathrooms+'</td>';
			txt += '		<td width="53">'+models[i].Lot+'</td>';
			txt += '		<td width="55">'+models[i].Size+'</td>';
			txt += '		<td width="98">'+models[i].FPrice+'</td>';
			txt += '</tr>';
		}
		txt += '</table>';
	}	

	if (count == 0) {
				if (getQueryVariable("o") == "move_in_now") {
					txt = "<div style='width:100%; text-align: center;padding-top: 60px; '>There are no inventory homes available at this time.<br>Please check back later, we will be updating our inventory soon.<br>Thank you!</div>";
				} else {
					txt = "<img src='images/soldout.gif'>";
				}

	}
	el.innerHTML = txt;

	if (singles == 0) {
		el = document.getElementById("tabSingles"); 
		if (el) el.style.display="none";
	}
	if (semis == 0) {
		el = document.getElementById("tabSemis"); 
		if (el) el.style.display="none";
	}
	if (towns == 0) {
		el = document.getElementById("tabTowns"); 
		if (el) el.style.display="none";
	}
	selectModel(document.getElementById("modelTable" + modelShown), modelShown);

}

function prevModel() {
	newModelID = -1;
	for (i in models)
	{	
		if (parseInt(i) >= parseInt(selectedModel)) break;
		if (homeType != 0 && homeType != models[i].TypeID) continue;
		if (parseInt(models[i].Price) > parseInt(maxPrice)) continue;
		newModelID = i;
	}	

	if (newModelID == -1) //no models matching criteria were found, skip and continue
	{
		for (i in models)
		{
			if (parseInt(i) <= parseInt(selectedModel)) continue;
			if (homeType != 0 && homeType != models[i].TypeID) continue;
			if (models[i].Price > maxPrice) continue;
			newModelID = i;
		}
	}
	if (newModelID == -1) newModelID = selectedModel;
	closeModelPopup();
	selectModel(document.getElementById("modelTable" + newModelID), newModelID);
	showModelPopup();

}

function nextModel() {
	newModelID = -1;
	for (i in models)
	{	
		if (parseInt(i) <= parseInt(selectedModel)) continue;
		if (homeType != 0 && homeType != models[i].TypeID) continue;
		if (parseInt(models[i].Price) > parseInt(maxPrice)) continue;
		newModelID = i;
		break;
	}	
	if (newModelID == -1) //no models matching criteria were found, start from the beginning
	{
		for (i in models)
		{
			if (homeType != 0 && homeType != models[i].TypeID) continue;
			if (models[i].Price > maxPrice) continue;
			newModelID = i;
			break;
		}
	}
	closeModelPopup();
	selectModel(document.getElementById("modelTable" + newModelID), newModelID);
	showModelPopup();
}

var selectedModel = -1;
function modelOver(obj, id) {
//	if (selectedModel == id) return true;
	setClass(obj, "over");
}

function modelOut(obj,id) {
//	if (selectedModel == id) return true;
//	obj.setAttribute("class", "normal");
	setClass(obj, "normal");
}

function selectModel(obj, id) {
	if (selectedModel > 0)
	{
		el = document.getElementById("modelTable" + selectedModel);
		if (el) {
			el.setAttribute("class", "normal");
			el = document.getElementById("commLogoImage");
			if (el) el.src= models[selectedModel].CommLogo.replace(".gif", "2.gif");
		}
	}
	if (obj)
	{
		selectedModel = id;
		obj.setAttribute("class", "active");

//		el = document.getElementById("floorplan");
//		el.href = models[selectedModel].PDF;
//		el = document.getElementById("ffinfo");
//		el.href = models[selectedModel].FF;
//		el = document.getElementById("thumbnail");
//		el.src= models[selectedModel].Thumbnail;

		el = document.getElementById("commLogoImage");
		if (el) el.src= models[selectedModel].CommLogo.replace(".gif", "2.gif");

//		el = document.getElementById('enlargeLink');
//		el.href = "#self";
//		el.onclick = showModelPopup;
//
//		el = document.getElementById('contactLink');
//		el.href = "#self";
//		el.onclick = showElevationPopup;
	}
	
}

function showModelPopup() {
	if (models[selectedModel].ID == 1554 || models[selectedModel].ID == 1555) {
		alert("Floor plan unavailable please contact sales representative for details");
		return true;
	}
	setOpacity(10);

//	txt = '<table width="660" height="420" border="0" cellpadding="0" cellspacing="0">';
//	txt += '    <tr>';
//	txt += '      <td width="542" height="30" align="left" valign="top" style="padding-left:30px; padding-top:5px; padding-bottom:5px;"><div class="pophomename">'+models[selectedModel].Name	 +'</div></td>';
//	txt += '      <td width="118" align="right" valign="top" style="padding-top:5px; padding-right:5px;"><a href="javascript:;" onclick="closeModelPopup()" 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 += '    <tr>';
//	txt += '      <td align="left" valign="top" style="padding-left:30px; padding-bottom: 0px;"><img src="'+models[selectedModel].Image+'" /></td>';
//	txt += '      <td align="left" valign="top" style="font-size:11px; padding-left:8px;padding-bottom: 0px; height: 200px;">'+models[selectedModel].Type+'';
//	txt += '        <p>'+models[selectedModel].Bedrooms+' bedrooms </p>';
//	txt += '        <p>'+models[selectedModel].Bathrooms+' baths</p>';
//	txt += '        <p>'+models[selectedModel].Lot+'</p>';
//	txt += '        <p>'+models[selectedModel].Size+' sq.ft.</p>';
//	txt += '        <p>'+models[selectedModel].FPrice+'</td>';
//	txt += '    </tr>';
//	txt += '    <tr><td colspan="2" style="padding-left:30px; padding-top: 0px; ">';
//	txt += '      <div class="utility" style="margin-top: 0px; margin-left:0px;"><ul>';
//	txt += '				<li> <div class="print"><a href="'+models[selectedModel].PDF+'" target="_blank">print</a></div></li> ';
//	txt += '				<li><div class="download"> <a href="'+models[selectedModel].PDF+'" target="_blank">download PDF</a></div></li>';
//	txt += '				<li><div class="download"> <a href="'+models[selectedModel].FF+'" target="_blank">features + finishes</a></div></li>';
//	txt += '  			<li><div class="cont"> <a href="#self" onclick="">contact me about this home </a></div></li>';
//	txt += '			</ul></div></td></tr>';
//	txt += '  </table>';
txt = '';
txt += '	<table width="660"  border="0" cellpadding="0" cellspacing="0">';
txt += '		<tr><td height="30" colspan="2" align="left" valign="top" style="padding-left:30px; padding-top:0px; padding-bottom:5px"><img src="'+models[selectedModel].CommLogo+'" /></td></tr>';
txt += '		<tr>';
txt += '				<td height="30" colspan="2" align="left" valign="top" style="padding-top:5px; padding-bottom:5px">';
txt += '						<div style="float:left; margin-top:16px; margin-left:30px;"><a href="#self" onclick=\"prevModel();\" onmouseover="MM_swapImage(\'prebttn\',\'\',\'images/prebttn_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="images/prebttn_up.gif" name="prebttn" width="66" height="12" border="0" id="prebttn" /></a></div>';
txt += '						<div style="float:right; margin-top:16px; margin-right:120px;"><a href="#self" onclick=\"nextModel();\" onmouseover="MM_swapImage(\'nxtbttn\',\'\',\'images/nxtbttn_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="images/nxtbttn_up.gif" name="nxtbttn" width="40" height="10" border="0" id="nxtbttn" /></a></div>';
txt += '						<div style="margin-left:auto; margin-right:auto; text-align:left; width:70px;"><a href="#self" onclick="closeModelPopup()" onmouseover="MM_swapImage(\'closebttn\',\'\',\'images/clsebttn_over.gif\',1)" onmouseout="MM_swapImgRestore()"><img src="images/clsebttn_up.gif" name="closebttn" width="28" height="27" border="0" id="closebttn" /></a></div>';
txt += '			</td>';
txt += '		</tr>';
txt += '		<tr>';
txt += '			<td height="30" colspan="2" align="left" valign="top" style="padding-left:30px; padding-top:10px; padding-bottom:0px;"><div class="pophomename">'+models[selectedModel].Name	 +'</div></td>';
txt += '		</tr>';
txt += '		<tr>';
txt += '			<td width="448" align="left" valign="top" style="padding-left:30px; padding-top:5px; padding-bottom:5px;"><img src="'+models[selectedModel].Image+'" /></td>';
txt += '			<td width="152" align="left" valign="top" style="padding-top:20px; padding-left:5px;">'+models[selectedModel].Type;
txt += '					<p>'+models[selectedModel].Bedrooms+' bedrooms </p>';
txt += '					<p>'+models[selectedModel].Lot+'</p>';
txt += '					<p>'+models[selectedModel].Size+' sq.ft.</p>        ';
txt += '					<p>'+models[selectedModel].FPrice+'</p>';
if (models[selectedModel].PDF.match("pdf")) {
	txt += '					<p>'+'<a href="http://twitter.com/home?status=Check+out+this+model+http://www.aspenridgehomes.com/"'+models[selectedModel].PDF+' id="shareTwitter">Twitter</a></p>';
//	txt += '					<p><a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.aspenridgehomes.com%2F"'+models[selectedModel].PDF.replace("/", "%2F")+'&amp;t=Check out this Aspen floorplan" id="shareFacebook">Facebook</a>' +'</p>';
}
if (models[selectedModel].Notes)
{
	txt += '					<p>'+models[selectedModel].Notes+'</p>';
} else {
		if (getQueryVariable("o") == "move_in_now")
		{
			if (models[selectedModel].ID == 1067)
			{
				txt += '					<p></p>';
				txt += '					<p><b>Telephone: </b>416.570.6300'  ;
				txt += '					<br><b>Email: </b><a href="mailto:dcarinci@aspenridgehomes.com">click here</a></p>';
			} else {
				txt += '					<p></p>';
				txt += '					<p><b>Telephone: </b>416.725.5724' ;
				txt += '					<br><b>Email: </b><a href="mailto:yrawji@aspenridgehomes.com">click here</a></p>';
			}
		}
}
txt += '			</td>';
txt += '		</tr>';
txt += '		<tr>';
txt += '			<td colspan="2" align="left" valign="top" style=" padding-top:0px; padding-bottom:5px;">';
if (models[selectedModel].Occupancy > 0) txt += '<br><b>Occupancy: </b> within '+models[selectedModel].Occupancy+' months<br>';
txt += '					<div class="utility" style="margin-top:5px; margin-left:0px; padding-top:5px; height:22px; border-bottom:0px solid #a9d5f0;">';
txt += '							<ul>';
//txt += '								<li style=" padding-right:50px; padding-left:30px;"> <div class="print"><a href="'+models[selectedModel].PDF+'" target="_blank">print</a></div></li> ';
//txt += '								<li style="padding-right:50px;"><div class="download"> <a href="'+models[selectedModel].PDF+'" target="_blank">download floorplan</a></div></li>';
if (models[selectedModel].PDF.match("pdf")) {
		txt += '								<li style="padding-right:50px;"><div class="print"> <a href="'+models[selectedModel].PDF+'" target="_blank">print</a></div></li>';
		txt += '								<li style="padding-right:50px;"><div class="download"> <a href="'+models[selectedModel].PDF+'" target="_blank">download floorplan</a></div></li>';
} else {
		txt += '								<li style="width:auto; padding-right:45px;"><div class="print" style="padding:0;">  <a href="#self" onclick=\"alert(\'Please visit the sales office for more info\')\" ></a></div></li>';
		txt += '								<li style="width:auto; padding-right:45px;"><div class="download" style="padding:0;">  <a href="#self" onclick=\"alert(\'Please visit the sales office for more info\')\" > </a></div></li>';
}
if (models[selectedModel].FF.match("pdf")) txt += '								<li style="width:auto; padding-right:45px;"><div class="download" style="padding:0;">  <a href="'+models[selectedModel].FF+'" target="_blank">features + finishes</a></div></li>';
else txt += '								<li style="width:auto; padding-right:45px;"><div class="download" style="padding:0;">  <a href="#self" onclick=\"alert(\'Please visit the sales office for more info\')\" ></a></div></li>';
txt += '								<li style="width:100px; padding-right:0px; "><div class="cont" style="width:100px;; padding:0; margin-right:0px;"> <a href="#self" onclick="window.location=\'index.php?n=Aspen&o=community_contact&cid='+models[selectedModel].CommunityID+'\';"> tell me more</a></div></li>';
txt += '						</ul>';
txt += '				</div>	  ';
txt += '			</td>';
txt += '		</tr>';
txt += '	</table>';
	el = document.getElementById("pophome");
	if (!el)
	{
		el = document.createElement("div");
		el.id = "pophome";
		el.setAttribute("class", "pophome");
		el.className = "pophome";
		el.style.width =  'auto';
		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(660,580);
		
		el.style.position =  'absolute';
		el.style.zIndex = 1 ;

		el.style.top = Math.min(10, c.y) + "px";
		el.style.top = "-100px";
		el.style.left = Math.max(0, c.x) + "px";

	} else {
		el.innerHTML = txt;
	}
	el.style.display='block';


}

function closeModelPopup() {
	setOpacity(100);
	el = document.getElementById("pophome");
	el.style.display = "none";
}


var dragActive = false;
var activeSlider = 0;
function sliderStart(e, slider) {
	if (e)
	{
		dragActive = true;
		activeSlider = slider;
		document.onmousemove =sliderDrag;
		document.onmouseup = sliderEnd;
	}

}

function sliderDrag(e) {
	if (dragActive)
	{
		obj = document.getElementById("sliderDot" + activeSlider);
		anchorID = activeSlider;
		if (anchorID > 2) anchorID = 2;
		anchorID = "sliderCont" + anchorID;
		anchor = document.getElementById(anchorID);
		anchorX = findPosX(anchor);
		mouseOffset = getMouseX(e);
		gap = (mouseOffset - anchorX);
		

		if (activeSlider == 1) {
			if (gap <= 0) gap = 0;
			if (gap > 96) gap = 96;
			setPrice(gap);
			obj.style.marginLeft =  gap + "px";
		} 
		
		if (activeSlider == 2) {
			if (gap <= 10) gap = 10;
			if (gap > 160) gap = 160;
			obj.style.left =  (gap-85) + "px";
			setPriceField(gap, "maxprice");

			sliderLeft = document.getElementById("sliderDot3"); 
			sliderLeftX = parseInt(sliderLeft.style.left);
			sliderRight = document.getElementById("sliderDot2"); 
			sliderRightX = parseInt(sliderRight.style.left);

			if (sliderLeftX + 10 > (sliderRightX+85))
			{
				sliderLeft.style.left = (sliderRightX - 10 + 85) + "px";;
				setPriceField(sliderRightX-10+85, "minprice");
			}
		}

		if (activeSlider == 3) {
			if (gap <= 0) gap = 0;
			if (gap >= 150) gap = 150;
			obj.style.left = gap + "px";
			setPriceField(gap, "minprice");

			sliderLeft = document.getElementById("sliderDot3"); sliderLeftX = parseInt(sliderLeft.style.left);
			sliderRight = document.getElementById("sliderDot2"); sliderRightX = parseInt(sliderRight.style.left);

			if (sliderLeftX + 10 > (sliderRightX+85))
			{
				sliderRight.style.left = ((sliderLeftX + 10) - 85) + "px";;
				setPriceField(sliderLeftX + 10, "maxprice");
			}
		}
		
	}
}

function sliderEnd() {
		dragActive = false;
		activeSlider = 0;
		document.onmousemove = nothing;
		document.onmouseup = nothing;
}

function nothing() {
	return true;
}

function setPriceField (price, fld) {
	minPrice = 200000;
	maxPrice = 1500000;
	priceVal = (price / 160) * (maxPrice - minPrice) + minPrice;
	el = document.getElementById(fld);
	el.value = priceVal;
	el = document.getElementById(fld + "Label2");
	el.innerHTML = formatPrice(priceVal);

}



function showElevationPopup() {
	setOpacity(10);
	txt = '<table width="660" height="311" border="0" cellpadding="0" cellspacing="0">';
	txt += '    <tr>';
	txt += '      <td width="448" height="30" align="left" valign="top" style="padding-left:30px; padding-top:5px; padding-bottom:5px;"><div class="pophomename">'+models[selectedModel].Name	 +'</div></td>';
	txt += '      <td width="152" align="right" valign="top" style="padding-top:5px; padding-right:5px;"><a href="javascript:;" onclick="closeElevationPopup()" 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 += '    <tr>';
	txt += '      <td align="left" valign="top" style="padding-left:30px; width: 360px;"><img width=360 src="'+models[selectedModel].Image+'" /></td>';
	txt += '      <td id="pophometd" align="left" valign="top" style="font-size:11px; padding-left:10px; width: 230px;">';
	txt += '      <form name="frmContact" id="frmContact" action="index.php?n=Aspen&o=docontactme" method="POST" onsubmit="return validateForm();">';
	txt += '      <input type="hidden" name="ElevationID" id="ElevationID" value="'+models[selectedModel].ID+'">';
	txt += '      <table width="100%" border="0" cellspacing="2" cellpadding="0" style="margin-top:20px;">';
	txt += '      <tr><td align="left">first name </td></tr><tr><td><input type="text" name="FirstName"  title="required_FirstName"/></td></tr>';
	txt += '      <tr><td align="left">lastname</td></tr><tr><td><input type="text" name="LastName"/></td></tr>';
	txt += '      <tr><td align="left">email</td></tr><tr><td><input type="text" name="Email" title="required_Email" /></td></tr>';
	txt += '      <tr><td align="left">daytime phone </td></tr><tr><td><input type="text" name="DayPhone" /></td></tr>';
	txt += '      <tr><td align="left">evening phone </td></tr><tr><td><input type="text" name="EveningPhone"/></td></tr>';
	txt += '      <tr><td>&nbsp;</td></tr>';
	txt += '      <tr><td colspan="2" align="center"></tr><tr><td><input type="button" value="send" onclick="doContactMe();"></td></tr></table></form>';
	txt += '                </td>';
	txt += '    </tr>';
	txt += '  </table>';

	el = document.getElementById("pophome2");
	if (!el)
	{
		el = document.createElement("div");
		el.id = "pophome2";

		el.setAttribute("class", "pophome");
//		el.className = "pophome";

		el.style.backgroundImage = "url(images/bg_popup_contact.gif)";
		el.style.width =  'auto';
		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(660,350);
		
		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";

	} else {
		el.innerHTML = txt;
	}
	el.style.display='block';


}

function closeElevationPopup() {
	setOpacity(100);
	el = document.getElementById("pophome2");
	el.style.display = "none";
}

