/**
*DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
*I did a bit of tweaking, so don't blame SmartWebby.com for the mistakes plus there are now other things in here as well
*/
//list of global variables
var intShow; //for timed events
var intShow1;//timer
var intShow2; //nother timer
var z = 1; //useless timer
var showCntr1 = 0; //position variable for height
var showCntr =0;
var map = null;
var geocoder = null;
var oldaddress = new Array();
var oldmarkerWindowInfo ="";
var addressCheck = false;
var mapType1 = 'G_NORMAL_MAP';
//change this to change the marker apperance
function getMarkerOptions () 
{
	var myIcon = new GIcon(G_DEFAULT_ICON);
	myIcon.image = "images/icon1.png";
	myIcon.iconSize = new GSize(50, 50);
	myIcon.shadow = "images/icon2.png";
	myIcon.shadowSize = new GSize(50, 50);
	myIcon.iconAnchor = new GPoint(25, 50);
	myIcon.infoWindowAnchor = new GPoint(25, 0);
	//myIcon.printImage = "my_custom_icon_print.gif";
	//myIcon.mozPrintImage = "my_custom_icon_mozPrint.gif";
	//myIcon.printShadow = "my_custom_icon_printShadow.gif";
	myIcon.transparent = "images/icon3.png";
	myIcon.imageMap = [ 10,25, 40,25, 40,0, 0,0 ]; 
	var markerOptions = { icon:myIcon };
	return markerOptions;
}

//prepares the map
function initialize(slat,slong) 
{
	if (GBrowserIsCompatible()) 
	{
		map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GSmallZoomControl3D());
		map.addControl(new GMapTypeControl());
		map.addControl(new GScaleControl());
		map.setCenter(new GLatLng(slat,slong), 15);
		map.setMapType(G_NORMAL_MAP);
		map.enableGoogleBar();
		geocoder = new GClientGeocoder();
	}
}
//places the marker at the specified place
function showAddress(address,linkVar) 
{
	//reset variables
	i = 0;
	addressCheck = false;
	if (geocoder) 
	{
		geocoder.getLatLng(
			address,
			function(point) 
			{
				if (!point) 
				{
					//alert(address + " not found");
				} 
				else
				{
					while (i < oldaddress.length)
					{
						if (address == oldaddress[i][0])
						{
							oldaddress[i][1]=oldaddress[i][1]+"<br />"+linkVar.substr(linkVar.lastIndexOf('=')+1,linkVar.length)+"<br /><a href='index_files/apartment.php?apt="+linkVar+"'>"+address+"</a>";
							//add 20 feet of potential difference for multiple markers at same location
							//var pointObs new GLatLong(point.lat(),point.lng()+Obs);
							var latObs = point.lat();
							var lngObs = point.lng();
							var pointObs = new GLatLng(latObs,lngObs);
							var marker = new GMarker(pointObs, getMarkerOptions());
							map.addOverlay(marker);	
							marker.bindInfoWindowHtml(oldaddress[i][1]);
							addressCheck=true;
							i = oldaddress.length;
						}
					i++
					}
					if (addressCheck=false)
					{
						//add 20 feet of potential difference for multiple markers at same location
						//var pointObs new GLatLong(point.lat(),point.lng()+Obs);
						oldmarkerWindowInfo="Click on the address to select the property:<br />"+linkVar.substr(linkVar.lastIndexOf('=')+1,linkVar.length)+"<br /><a href='index_files/apartment.php?apt="+linkVar+"'>"+address+"</a>";
						var latObs = point.lat();
						var lngObs = point.lng();
						var pointObs = new GLatLng(latObs,lngObs);
						var marker = new GMarker(pointObs, getMarkerOptions());
						map.addOverlay(marker);	
						marker.bindInfoWindowHtml(oldmarkerWindowInfo);
					}
				}
			}
		);
	}	
	oldaddress[oldaddress.length]=[address,oldmarkerWindowInfo];	
}
//checks email format
function echeck(str) {
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.lastIndexOf(dot);
		var rv = true;			

		if(lat<1||ldot-lat<4||ldot<5||lstr-ldot!=4){
			rv = false;
		}

                if (str.indexOf(" ")!=-1)
		{ 		     
                     rv = false;
		}

                if (rv==false)
                {
		     //alert("We're sorry, there seems to be a problem with your email format.  Can you please re-check it?");
		}
 		return rv;					
}

function imagemove1(imgObj,check)
{
	//get the descriptions based on the source.
	xml=loadXMLDoc("xml/picturedesc.xml");	
	path="/MAIN/APARTMENT[NAME='"+imgObj.src.substring(imgObj.src.lastIndexOf('/')+1,imgObj.src.length)+"']";
	// code for IE
	if (window.ActiveXObject)
	{
		var xmlDoc=xml.selectNodes(path);
		document.getElementById("center1").innerHTML=xmlDoc[0].getElementsByTagName("DESCRIPTION")[0].childNodes[0].nodeValue;  
	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation && document.implementation.createDocument)
	{
		var nodes=xml.evaluate(path, xml, null, XPathResult.ANY_TYPE, null);
		var xmlDoc=nodes.iterateNext();
		document.getElementById("center1").innerHTML=xmlDoc.getElementsByTagName("DESCRIPTION")[0].childNodes[0].nodeValue;		
	}
	if (check==1)
	{
		document.getElementById("center1").innerHTML='';
	}

	document.getElementById('center').src=imgObj.src;
}
function imagemove(imgObj,offsetvar)
{
	
	//move the hidden information over and display it
	str=imgObj.src;
	//imgObj.style.top=imgObj.style.top-(offsetvar*100)+'px';
	document.getElementById('center').src=imgObj.src;
	document.getElementById('center1').innerHTML = document.getElementById(str.substring(str.lastIndexOf('/')+1,str.length)).innerHTML;
}

function mouseover(str,leftvalue)
{
	timer=str.parentNode.id+'1';		
	document.getElementById(timer).style.left=leftvalue+'px';
	document.getElementById(timer).style.top='200px';
	document.getElementById(timer).style.display='block';
	document.getElementById(timer).style.zIndex=1000;
	if (timer=="rentals1")
	{
	clearInterval(intShow);
	intShow=setInterval("showCntr=show(showCntr,timer,intShow)",2);	
	}
	else if (timer=="home1")
	{
	clearInterval(intShow1);
	intShow1=setInterval("showCntr1=show(showCntr1,timer,intShow1)",2);
	}
}
	
function show(i,showSite,intS)
{
	if(i<300)
	{
		i=i+10;
		document.getElementById(showSite).style.height=i+'px';		
	}
	else 
	{i=300;}
	return i;
}
function hide(i,hideSite,intS)
{
if (i>0)
	{
	i=i-20;
	document.getElementById(hideSite).style.height=i+'px';
	////alert(i);
	}
else {i=0;
		
		}
	return i;
}
function mouseout(str)
{
	clearInterval(intShow);
	intShow=setInterval("showCntr=hide(showCntr,'rentals1',intShow)",1);		
}

function TestDataCheck()
{
var FirstName = document.index2.FirstName.value;
var LastName  = document.index2.LastName.value;
var email     = document.index2.email.value;

var returnval;

if ( (FirstName != '') && (LastName != '') && (email != '')) {    
    returnval = true;   
}
else
   {
   //alert("Please Enter information in all required fields");      
   document.getElementById('fstNm').style.color="red";
   document.getElementById('lstNm').style.color="red";   
   document.getElementById('emailo').style.color="red";
   return false;
   }

if (echeck(email)==false)
{
    returnval = false;
}

return returnval;
}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "d";
  else
    return results[1];
}

function getStart (picOne)
{
	switch(picOne)
	{
	case 'studio':
		showAptBySort(aptByStudio);
		break;
	case 'joneBr':
		showAptBySort(aptByJOneBr);
		break;
	case 'oneBr':
		showAptBySort(aptByOneBr);
		break;
	case 'oneBrCar':
		showAptBySort(aptByOneBrCar);
		break;
	case 'twoBr':
		showAptBySort(aptByTwoBr);
		break;
	case 'dates':
		showAptBySort(aptByDate,2);
		break;
	case 'map':
		showAptByMap(gup('lat'),gup('long'));
		break;
	default:
		return;
	}
}
		
function adlinks( number )
{
	var ad1 = '<p><b><font color="#003300" face="Arial, Helvetica, sans-serif" size="2">Available April 1</font><font face="Arial, Helvetica, sans-serif" size="2"><br><a href="/2br.html#4th">2 BR</a><br>4th &amp; C NE<br></font></b><font face="Arial, Helvetica, sans-serif" size="2">$4850 - $6270/month</font></p>';
	var ad2 = '<p><b><font color="#003300" face="Arial, Helvetica, sans-serif" size="2">April 1<br></font><font size="2"><font color="#000000" face="Arial, Helvetica, sans-serif"><a href="/jr1br.html#2St3A">Junior 1 BR</a></font><font face="Arial, Helvetica, sans-serif"> <br>2nd St. #3A<br></font></font></b><font face="Arial, Helvetica, sans-serif" size="2">$3450 - $4850/month</font></p>';
	var ad3 = "http://www.eonenvironmental.com/";
	var ad4 = "http://www.mediatemple.net/go/order/?refdom=network2market.com/";
	var ad5 = "http://www.network2market.com/shop";
		switch(number)
		{
		case 1:
		  return ad1;
		case 2:
		  return ad2;
		case 3:
		  return ad2;
		case 4:
		  return ad1;
		case 5:
		  return ad2;
		default:
		  return "http://www.network2market.com";
		}
}		
function checkLen(x,y)
{
if (y.length==x.maxLength)
  {
  var next=x.tabIndex;
  if (next<document.getElementById("myForm").length)
    {
    document.getElementById("myForm").elements[next].focus();
    }
  }
}


function imgload (dook,heightd)
{
	dook.height=heightd;
}

function showPic (indexNum, checkType)
{	
	var sportLink=new Array(); 
	sportLink[0]="images/exterior.jpg"; 
	sportLink[1]="images/pic1.jpg"; 
	sportLink[2]="images/pic2.jpg"; 
	////alert(checkType);Math.floor(Math.random()*2)+1)
	document.getElementById('typePic1').src=sportLink[Math.floor(Math.random()*3)];
	if (checkType==1)
	{		
		t=setTimeout("showPic(Math.floor(Math.random()*3),1)",12000);
	}
}

function loadXMLDoc(dname)
{
	if (window.XMLHttpRequest)
	{
		xhttp=new XMLHttpRequest();		
	}
	else 
	{
		xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xhttp.open("GET",dname,false);
	xhttp.send("");
	return xhttp.responseXML;
}

function checkForm(appForm)
{	
	var t=true;
	for (var i=0;i<appForm.length;i++)
	{
		if (appForm.elements[i].value=='')
		{
			var t = false;
			appForm.elements[i].style.backgroundColor='pink';
		}
	}
	if (t==false) {
		alert("Please fill in all fields marked with a red background.  If the field is not applicable, enter n/a and resubmit.");
		return t;}
	var r=confirm("By Clicking OK, I hereby authorize Capitol Hill Stay and its representatives to conduct a credit check to determine rental suitability.  I acknowledge that this property is non-smoking.");
	return r;
}
function checkContactForm(appForm)
{	
	var t=true;
	if (appForm.elements[1].value=='' || appForm.elements[3].value=='')
		{
			var t = false;
			appForm.elements[1].style.backgroundColor='pink';
			appForm.elements[3].style.backgroundColor='pink';
		}
	if (t==false) {
		alert("Please fill in all fields marked with a red background.");
		return t;}	
	return r;
}

function getAptData(aptVal,aptpicArray)
{
	//aptpic array is multidim w/ 5 arrays of picture data
	//open the file and pull out the stuff for the requested apartment
	var photoposcounter = 0;
	var counter = 0;
	var picUrl=new Array(); 
	var date = 0;
	picUrl[0]="Outside";
	picUrl[1]="Livingroom";
	picUrl[2]="Bedroom";
	picUrl[3]="Bathroom";
	picUrl[4]="Kitchen";
	picUrl[5]="2Bedroom";
	xml=loadXMLDoc("xml/apart.xml");
	path="/CATALOGA/APARTMENT[KEYVAL/MAINDIR='"+aptVal+"']";
	// code for IE
	if (window.ActiveXObject)
	{
		var xmlDoc=xml.selectNodes(path);
		document.getElementById("street").innerHTML=xmlDoc[0].getElementsByTagName("STREET")[0].childNodes[0].nodeValue+' '+xmlDoc[0].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue;
		document.getElementById("beds").innerHTML=xmlDoc[0].getElementsByTagName("BEDS")[0].childNodes[0].nodeValue;
		document.getElementById("baths").innerHTML=xmlDoc[0].getElementsByTagName("BATHS")[0].childNodes[0].nodeValue;
		document.getElementById("parking").innerHTML=xmlDoc[0].getElementsByTagName("PARKING")[0].childNodes[0].nodeValue;
		document.getElementById("pets").innerHTML=xmlDoc[0].getElementsByTagName("PETS")[0].childNodes[0].nodeValue;
		date=xmlDoc[0].getElementsByTagName("DATEAVAIL")[0].childNodes[0].nodeValue;
		document.getElementById("smallfeat").innerHTML=xmlDoc[0].getElementsByTagName("SMALLFEAT")[0].childNodes[0].nodeValue;
		document.getElementById("price").innerHTML=xmlDoc[0].getElementsByTagName("PRICERANGE")[0].childNodes[0].nodeValue; 
		document.getElementById("features").innerHTML=xmlDoc[0].getElementsByTagName("FEATURES")[0].childNodes[0].nodeValue; 
		document.getElementById("reviews").innerHTML=xmlDoc[0].getElementsByTagName("REVIEWS")[0].childNodes[0].nodeValue;
	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation && document.implementation.createDocument)
	{
		var nodes=xml.evaluate(path, xml, null, XPathResult.ANY_TYPE, null);
		var xmlDoc=nodes.iterateNext();
		document.getElementById("street").innerHTML=xmlDoc.getElementsByTagName("STREET")[0].childNodes[0].nodeValue+' '+xmlDoc.getElementsByTagName("TITLE")[0].childNodes[0].nodeValue;
		document.getElementById("beds").innerHTML=xmlDoc.getElementsByTagName("BEDS")[0].childNodes[0].nodeValue;
		document.getElementById("baths").innerHTML=xmlDoc.getElementsByTagName("BATHS")[0].childNodes[0].nodeValue;
		document.getElementById("parking").innerHTML=xmlDoc.getElementsByTagName("PARKING")[0].childNodes[0].nodeValue;
		document.getElementById("pets").innerHTML=xmlDoc.getElementsByTagName("PETS")[0].childNodes[0].nodeValue;
		date=xmlDoc.getElementsByTagName("DATEAVAIL")[0].childNodes[0].nodeValue;
		document.getElementById("smallfeat").innerHTML=xmlDoc.getElementsByTagName("SMALLFEAT")[0].childNodes[0].nodeValue;
		document.getElementById("price").innerHTML=xmlDoc.getElementsByTagName("PRICERANGE")[0].childNodes[0].nodeValue; 
		document.getElementById("features").innerHTML=xmlDoc.getElementsByTagName("FEATURES")[0].childNodes[0].nodeValue;	
		document.getElementById("reviews").innerHTML=xmlDoc.getElementsByTagName("REVIEWS")[0].childNodes[0].nodeValue;
	}
	
	//get to 2010...
	//get there from text dates\
	//alert(date);
	x = date;
	var date2 = new Date(x.substr(0,4),x.substring(x.indexOf(',')+1,x.lastIndexOf(','))-1,x.substr(x.lastIndexOf(',')+1,2));	
	var year = date2.toDateString();
	//year = year.substr(year.length-2,2);
	document.getElementById("dateavail").innerHTML=year;	
	//print photos!
	
	while (photoposcounter < 6)
	{
	
		picUrlcomplete = aptVal+"/"+picUrl[photoposcounter];
		var photoId = 'photos'+photoposcounter;
		stringArgument = "document.getElementById('center').src='images/empty2.png';document.getElementById('center1').innerHTML=''";
		while (counter < (aptpicArray[photoposcounter].length-1))
		{
			//check to see if there is an image at the next counter 
			////alert(document.getElementById(photoId).innerHTML); css to make this look good again:=.outside li{margin-left:2px;padding:0;display:inline;white-space:nowrap;height:140px;}
			document.getElementById(photoId).innerHTML=document.getElementById(photoId).innerHTML+'<li class="outside"><img onload="imgload(this,\'100\')" onmouseover="imagemove(this,'+photoposcounter+')" onmouseout="'+stringArgument+'" id="pic'+counter+'" src="images/'+picUrlcomplete+'/'+aptpicArray[photoposcounter][counter][0]+'" onclick="showFullSizeImage(this)" alt="apt views"></img><span style="display:none" id="'+aptpicArray[photoposcounter][counter][0]+'">'+aptpicArray[photoposcounter][counter][1]+'</span></li>';			
			
			counter++;
		}
			
		//check to see if there are any photos in the given array part.
		if (aptpicArray[photoposcounter].length < 2)
		{
			document.getElementById(photoId).style.display='none';
		}
		//move to the next photo directory
		photoposcounter++;
		counter=0;
	}
	
}
function showFullSizeImage(picObj)
{
window.open(picObj.src,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=800, height=800");
}
function changeHeight(listNode)
{
	if(listNode.clientHeight > 40)
	{
		listNode.style.height='18px';
	}
	else
	{
		listNode.style.height='auto';
	}
}
function getSmallAptData(aptVal,positionVar)
{
	//open the file and pull out the stuff for the requested apartment
 
	var date = 0;

	xml=loadXMLDoc("xml/apart.xml");
	path="/CATALOGA/APARTMENT[KEYVAL/MAINDIR='"+aptVal+"']";
  
	// code for IE
	if (window.ActiveXObject)
	{

		var xmlDoc=xml.selectNodes(path);
		document.getElementById("street"+positionVar).innerHTML=xmlDoc[0].getElementsByTagName("STREET")[0].childNodes[0].nodeValue+' '+xmlDoc[0].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue;
		document.getElementById("beds"+positionVar).innerHTML=xmlDoc[0].getElementsByTagName("BEDS")[0].childNodes[0].nodeValue;
		document.getElementById("baths"+positionVar).innerHTML=xmlDoc[0].getElementsByTagName("BATHS")[0].childNodes[0].nodeValue;
		document.getElementById("parking"+positionVar).innerHTML=xmlDoc[0].getElementsByTagName("PARKING")[0].childNodes[0].nodeValue;
		document.getElementById("pets"+positionVar).innerHTML=xmlDoc[0].getElementsByTagName("PETS")[0].childNodes[0].nodeValue;
		date=xmlDoc[0].getElementsByTagName("DATEAVAIL")[0].childNodes[0].nodeValue;
		document.getElementById("smallfeat"+positionVar).innerHTML=xmlDoc[0].getElementsByTagName("SMALLFEAT")[0].childNodes[0].nodeValue;
		document.getElementById("pricerange"+positionVar).innerHTML=xmlDoc[0].getElementsByTagName("PRICERANGE")[0].childNodes[0].nodeValue;
		
		
	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation && document.implementation.createDocument)
	{
		var nodes=xml.evaluate(path, xml, null, XPathResult.ANY_TYPE, null);
		var xmlDoc=nodes.iterateNext();
		document.getElementById("street"+positionVar).innerHTML=xmlDoc.getElementsByTagName("STREET")[0].childNodes[0].nodeValue+' '+xmlDoc.getElementsByTagName("TITLE")[0].childNodes[0].nodeValue;
		document.getElementById("beds"+positionVar).innerHTML=xmlDoc.getElementsByTagName("BEDS")[0].childNodes[0].nodeValue;
		document.getElementById("baths"+positionVar).innerHTML=xmlDoc.getElementsByTagName("BATHS")[0].childNodes[0].nodeValue;
		document.getElementById("parking"+positionVar).innerHTML=xmlDoc.getElementsByTagName("PARKING")[0].childNodes[0].nodeValue;
		document.getElementById("pets"+positionVar).innerHTML=xmlDoc.getElementsByTagName("PETS")[0].childNodes[0].nodeValue;
		date=xmlDoc.getElementsByTagName("DATEAVAIL")[0].childNodes[0].nodeValue;
		document.getElementById("smallfeat"+positionVar).innerHTML=xmlDoc.getElementsByTagName("SMALLFEAT")[0].childNodes[0].nodeValue;
		document.getElementById("pricerange"+positionVar).innerHTML=xmlDoc.getElementsByTagName("PRICERANGE")[0].childNodes[0].nodeValue;
			
	}
	//get to 2010...
	//alert(date);
	x = date;
	var date2 = new Date(x.substr(0,4),x.substring(x.indexOf(',')+1,x.lastIndexOf(','))-1,x.substr(x.lastIndexOf(',')+1,2));	
	var year = date2.toDateString();;
	document.getElementById("dateavail"+positionVar).innerHTML=year;	
	//add picture, too
	document.getElementById("pic"+positionVar).src="images/"+aptVal+"/Outside/exterior.jpg";
}
function showAptBySort(arrayVar,highLval)
{
	var x = 0;
	//reset the field so we don't get endless apartment tables
	document.getElementById('workspace').innerHTML='';
	while (x < arrayVar.length)
	{
		//populate the page...
		//different code for ie explorer..again
		if (window.ActiveXObject)
		{
			document.getElementById('workspace').innerHTML=document.getElementById('workspace').innerHTML+'<div class="apttable"><p><br />Please Click on the Image below to View the Selected Apartment</p><table><tr></tr><tr><td onclick="window.location.replace(\'apartment.php?apt='+arrayVar[x]+'\')"><b>Street:</b><br /> <span id="street"></span></td><td id="beddata" onclick="window.location.replace(\'apartment.php?apt='+arrayVar[x]+'\')"><b>Beds:</b><br /> <span id="beds"></span></td><td onclick="window.location.replace(\'apartment.php?apt='+arrayVar[x]+'\')"><b>Baths:</b><br /> <span id="baths"></span></td><td onclick="window.location.replace(\'apartment.php?apt='+arrayVar[x]+'\')" rowspan="2"><img id="pic" src=""></img></td></tr><tr><td onclick="window.location.replace(\'apartment.php?apt='+arrayVar[x]+'\')" id="datedata"><b>Date Available:</b><br /> <span id="dateavail"></span></td><td onclick="window.location.replace(\'apartment.php?apt='+arrayVar[x]+'\')" ><b>Pets:</b><br /> <span id="pets"></span></td><td onclick="window.location.replace(\'apartment.php?apt='+arrayVar[x]+'\')"><b>Parking:</b><br /> <span id="parking"></span></td></tr><tr><td  onclick="window.location.replace(\'apartment.php?apt='+arrayVar[x]+'\')" colspan="4" id="smallfeat"></td></tr><tr><td id="pricerange" colspan="4"></td></tr></table><br /><br /></div>';
		}
		else 
		{
			document.getElementById('workspace').innerHTML=document.getElementById('workspace').innerHTML+'<div class="apttable"><p><br />Please Click on the Image below to View the Selected Apartment</p><table><tr></tr><tr><td onclick="window.location.replace(\'index_files/apartment.php?apt='+arrayVar[x]+'\')"><b>Street:</b><br /> <span id="street"></span></td><td id="beddata" onclick="window.location.replace(\'index_files/apartment.php?apt='+arrayVar[x]+'\')"><b>Beds:</b><br /> <span id="beds"></span></td><td onclick="window.location.replace(\'incex_files/apartment.php?apt='+arrayVar[x]+'\')"><b>Baths:</b><br /> <span id="baths"></span></td><td onclick="window.location.replace(\'index_files/apartment.php?apt='+arrayVar[x]+'\')" rowspan="2"><img id="pic" src=""></img></td></tr><tr><td onclick="window.location.replace(\'index_files/apartment.php?apt='+arrayVar[x]+'\')" id="datedata"><b>Date Available:</b><br /> <span id="dateavail"></span></td><td onclick="window.location.replace(\'index_files/apartment.php?apt='+arrayVar[x]+'\')" ><b>Pets:</b><br /> <span id="pets"></span></td><td onclick="window.location.replace(\'index_files/apartment.php?apt='+arrayVar[x]+'\')"><b>Parking:</b><br /> <span id="parking"></span></td></tr><tr><td  onclick="window.location.replace(\'index_files/apartment.php?apt='+arrayVar[x]+'\')" colspan="4" id="smallfeat"></td></tr><tr><td id="pricerange" colspan="4"></td></tr></table><br /><br /></div>';
		}
		document.getElementById('street').id='street'+x;
		document.getElementById('beds').id='beds'+x;
		document.getElementById('baths').id='baths'+x;
		document.getElementById('dateavail').id='dateavail'+x;
		document.getElementById('pets').id='pets'+x;
		document.getElementById('parking').id='parking'+x;
		document.getElementById('smallfeat').id='smallfeat'+x;
		document.getElementById('pic').id='pic'+x;
		document.getElementById('pricerange').id='pricerange'+x;
		if (highLval==2) 
		{
			document.getElementById('datedata').style.backgroundColor='yellow';
			document.getElementById('datedata').id='';
		}
		else
		{
			document.getElementById('beddata').style.backgroundColor='yellow';
			document.getElementById('beddata').id='';
		}
		getSmallAptData(arrayVar[x],x);
		x++;
	}
	
}
function showMenu(tdObj)
{
	tdObj.firstChild.style.visibility="visible";
}
function hideMenu(tdObj)
{
	tdObj.firstChild.style.visibility="hidden";
}
function showAptByMap(startLat,startLong)
{
	document.getElementById('workspace').innerHTML='<div><br /><br />Please allow a few moments for all CHS apartments to appear on the map.  When the CHS icons have built, click on the icon to see links to each apartment at that specific location.<br /><br /><br /></div><div id="map_canvas" style="width: 790px; height: 480px;border:5px inset grey;"></div><div style="width:800px">Click on map upper left corner to zoom out to see Capitol Hill Stay\'s central location in the greater DC area.  You can also search for restaurants, local attractions, etc.</div>';
	initialize(startLat,startLong);
	
	var pointObs2 = new GLatLng('38.895729','-77.072368');
	var marker2 = new GMarker(pointObs2, getMarkerOptions());
	map.addOverlay(marker2);	
	marker2.bindInfoWindowHtml('<br /><br />Click <a href="http://www.monumentviewapartments.com/" target="_blank">HERE</a> to go to Monument View Apartments');
	var pointObs3 = new GLatLng('38.911686','-77.042027');
	var marker3 = new GMarker(pointObs3, getMarkerOptions());	
	map.addOverlay(marker3);	
	marker3.bindInfoWindowHtml('<br /><br />Click <a href="http://www.dcstay.com/" target="_blank">HERE</a> to go to the DC Stay Website');
	var loopCounter = 0;
	while (loopCounter < aptByLoc.length)
		{
			//makes sure the requests are staggered out a bit...
			var t = setTimeout("showAddress(aptByLoc["+loopCounter+"],aptByLocLink["+loopCounter+"])",(loopCounter*500));
			loopCounter++;
		}
	//show monument view and dupont apartments
	//document.getElementById('workspace').innerHTML=document.getElementById('workspace').innerHTML+"<div>Click on map upper left corner to zoom out to see Capitol Hill Stay's central location in the greater DC area.  You can also search for restaurants, local area attractions, etc.</div>";
}
function checkstatus(caseVar)
{
	switch (caseVar)
	{
	case 'pass':
		alert('Thank you for your submission.  Someone from CHS will be with you shortly to answer your questions');
		document.getElementById("text-tag").style.color="green";
		document.getElementById("text-tag").innerHTML="Thank you for your submission.  Someone from CHS will be with you shortly to answer your questions";
		break;
	case 'fail':
		alert("I'm sorry, but it seems your e-mail was invalid.  Please recheck and resubmit.");
		document.getElementById("text-tag").style.color="red";
		document.getElementById("text-tag").innerHTML="I'm sorry, but it seems your e-mail was invalid.  Please recheck and resubmit.";
		break;
	default:
		break;
	}
}
function checkstatus1(caseVar)
{
	switch (caseVar)
	{
	case 'pass':
		alert('Thank you for your submission.  You will recieve an answer on your application shortly.');
		document.getElementById("text-tag").style.color="green";
		document.getElementById("text-tag").innerHTML="Thank you for your submission.  You will recieve an answer on your application shortly.";
		break;
	case 'fail':
		alert("I'm sorry, but it seems your e-mail was invalid.  Please recheck and resubmit.");
		document.getElementById("text-tag").style.color="red";
		document.getElementById("text-tag").innerHTML="I'm sorry, but it seems your e-mail was invalid.  Please recheck and resubmit.";
		break;
	default:
		break;
	}
}
function getFAQs()
{

	xml=loadXMLDoc("xml/faqs.xml");
	path="/faqlist";	
	i = 0;
	// code for IE
	if (window.ActiveXObject)
	{
		var xmlDoc=xml.selectNodes(path);
		while(i < xmlDoc[0].getElementsByTagName("question").length)
		{
			document.getElementById("faqsList").innerHTML=document.getElementById("faqsList").innerHTML+xmlDoc[0].getElementsByTagName("question")[i].childNodes[0].nodeValue+"<br />";
			document.getElementById("faqsList").innerHTML=document.getElementById("faqsList").innerHTML+xmlDoc[0].getElementsByTagName("answer")[i].childNodes[0].nodeValue+"<br /><br />";
			i++;
		}
	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation && document.implementation.createDocument)
	{
		var nodes=xml.evaluate(path, xml, null, XPathResult.ANY_TYPE, null);
		var xmlDoc=nodes.iterateNext();
		while(i < xmlDoc.getElementsByTagName("question").length)
		{
			document.getElementById("faqsList").innerHTML=document.getElementById("faqsList").innerHTML+xmlDoc.getElementsByTagName("question")[i].childNodes[0].nodeValue+"<br />";
			document.getElementById("faqsList").innerHTML=document.getElementById("faqsList").innerHTML+xmlDoc.getElementsByTagName("answer")[i].childNodes[0].nodeValue+"<br /><br />";
			i++;
		}
	}
}
function ridingOnTheMetro(address) {
	//get the lat/long of the property
	geocoder = new GClientGeocoder();
	if (geocoder) 
	{
		geocoder.getLatLng(
			address,
			function(point) 
			{
				if (!point) 
				{
					//alert(address + " not found");
				} 
				initialize(point.lat(),point.lng());
				pointObs = new GLatLng(point.lat(),point.lng());
				var marker = new GMarker(pointObs, getMarkerOptions());
				map.addOverlay(marker);
				  
				
				marker.openInfoWindowHtml("<p>Click Here to get walking directions<br /> to apartment from:</p><span class=\"bluebkg\" onclick ='showDirections(1,\""+address+"\")'>Blue/Orange Line<br /></span><span class=\"bluebkg\" onclick ='showDirections(2,\""+address+"\")'>Red Line<br /></span>");				
				
			}
		);
	}		
}
function showDirections(addressVar,address)
{
	var directionsPanel;
	var directions;
	document.getElementById("my_textual_div").innerHTML='';
	directionsPanel = document.getElementById("my_textual_div");
	directions = new GDirections(map, directionsPanel);
	
	
	switch (addressVar)
	{
	//capitol South market or the other one...		
		case 1:
			if (address.substring(0,4) == ' 623')
			{
				directions.load("from: 801 Pennsylvania Ave SE Washington, DC 20003 to: "+address+" ", {travelMode:G_TRAVEL_MODE_WALKING});
			}
			else 
			{
				directions.load("from: 355 1st St SE Washington, DC 20003 to: "+address+" ", {travelMode:G_TRAVEL_MODE_WALKING});
			}
			break;
		//union station
		case 2:
			directions.load("from: 701 1st St NE Washington, DC 20002 to: "+address+" ", {travelMode:G_TRAVEL_MODE_WALKING});
			break;
	}
}
function showAptByMap1(startLat,startLong)
{
	document.getElementById('workspace').innerHTML='<div id="map_canvas" style="margin-left:auto;margin-right:auto;width: 790px; height: 440px;border:5px inset grey;"></div><div style="width:800px;margin-left:auto;margin-right:auto">Click on map upper left corner to zoom out to see Capitol Hill Stay\'s central location in the greater DC area.  You can also search for restaurants, local attractions, etc.</div>';
	initialize(startLat,startLong);	
	var polygon = new GPolygon([
            new GLatLng(38.890776,-77.000606),
            new GLatLng(38.890876,-76.996143),
            new GLatLng(38.889673,-76.996143),
			new GLatLng(38.889707,-77.003567),
			new GLatLng(38.891845,-77.003481),
			new GLatLng(38.893181,-77.000434),
			new GLatLng(38.890776,-77.000606)
		  ], "#f33f00", 2, 1, "#ff0000", 0.2);
		  map.addOverlay(polygon);
	pointObs = new GLatLng('38.889607','-77.003009');
	var marker = new GMarker(pointObs, getMarkerOptions());
	map.addOverlay(marker);	
	marker.openInfoWindowHtml('<br /><br />Click <a href="index_files/aptpage.php?start=map&amp;lat=38.893214&amp;long=-77.000177">HERE</a> to go to properties');
}
function bookmark()
{
	url = location.href;
	title = window.name;
	if (window.sidebar) 
	{// firefox
		window.sidebar.addPanel(title, url, "");
	}
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 
	else if(document.all)// ie
	{
		window.external.AddFavorite(url, title);
	}
}
