/**search by community or city name**/	
function searchByName()
{
	var communityname = String(document.form1.text1.value);
	var communityid = "";
	
	if(!communityname)
	{
		return;
	} else
	{
		
		//extract the array from 
		
		//alert("data load request is still pending is " + dsLocations.getLoadDataRequestIsPending());
		
		//alert("entered the community name: " + communityname.toString());
		
		if(dsLocations.getDataWasLoaded())
		{
			
			var rows = new Array();
			rows = dsLocations.getData();
			
			var rowMatch = false;
			
			for (var i =0; i < rows.length; i++)
			{
				var temp = String(rows[i]["COM_NAM"]);
				//rows[i]["COM_NAM"] = temp.toLowerCase();
			
				
				if(temp.toLowerCase() == communityname.toLowerCase())
				{
						//alert("Match found " + rowMatch);
						rowMatch = true;
						//if there's a match, get the communityid and reset the communityname so that's formatting is correct (capital first letter)
						communityid = String(rows[i]["COM_ID"]);
						communityname = String(rows[i]["COM_NAM"]);
						break;
				}
				
			}
			
			//tempLocations.setDataFromArray(rows);
			
			//var firstMatchingRow = tempLocations.findRowsWithColumnValues({ COM_NAM: communityname.toLowerCase() }, true);
		
			
		
			if(rowMatch != false)
			{
				//found a match but now you have to find the appropriate communityid from the Dataset.
				try{
					
					if(document.form1.hidden1.value){
						communityid = document.form1.hidden1.value;	
						hideLocationsError();
						launchLightbox(communityid, communityname);
						document.getElementById('#TB_window').focus();
						return;
					}
						
				} catch(err)
				{
					//give the event that the communityid is not defined, go get it from the communityname which you know exists.
					
				}
				
			}else
			{
					//alert("no match found");
					showLocationsError(communityname);	
					return;
			}
			
		}
		
		
		else
		{	
			return;
		}
	}
		
}


function showLocationsError(communityname)
{
		var errorMessage = "There is no listing for '" + communityname + "'";
		var messageObj = document.getElementById("locationsError");
	
		messageObj.innerHTML = errorMessage;
		messageObj.style.display = "inline";
}

function hideLocationsError()
{
		var messageObj = document.getElementById("locationsError");
		messageObj.innerHTML = "";
		messageObj.style.display = "none";
}


function disableEnterKey(e)
{
     var key;      
     if(window.event)
          key = window.event.keyCode; //IE
     else
          key = e.which; //firefox      

     return (key != 13);
}


