//These functions used on all Search screens.

//Create selectNodes and selectSingleNode methods for cross-browser combatability.
if (document.implementation.hasFeature("XPath", "3.0")) {
    // prototying the XMLDocument
    XMLDocument.prototype.selectNodes = function(cXPathString, xNode) {
        if (!xNode) { xNode = this; }
        var oNSResolver = this.createNSResolver(document.documentElement);
        var aItems = this.evaluate(cXPathString, xNode, oNSResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
        var aResult = [];
        for (var i = 0; i < aItems.snapshotLength; i++) {
            aResult[i] = aItems.snapshotItem(i);
        }
        return aResult;
    }
    // prototying the Element 
    Element.prototype.selectNodes = function(cXPathString) {
        if (this.ownerDocument.selectNodes) {
            return this.ownerDocument.selectNodes(cXPathString, this);
        }
        else { throw "For XML Elements Only"; }
    }

    // prototying the XMLDocument 
    XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode) {
        if (!xNode) { xNode = this; }
        var xItems = this.selectNodes(cXPathString, xNode);
        if (xItems.length > 0) {
            return xItems[0];
        }
        else {
            return null;
        }
    }
    // prototying the Element 
    Element.prototype.selectSingleNode = function(cXPathString) {
        if (this.ownerDocument.selectSingleNode) {
            return this.ownerDocument.selectSingleNode(cXPathString, this);
        }
        else { throw "For XML Elements Only"; }
    }
} 

//Not all pages have jquery defined.
if (typeof(jQuery) != "undefined") {
    $(document).ready(function() {

        $("a#ViewXmlForStandardSearch").click(function(event) {
            ViewXml(objCriteriaForEdit, event);
            event.stopPropagation();
            return false;
        });

        $("a#ViewXmlForSearchSummary").click(function(event) {
            ViewXml(objCriteriaForSummary, event);
            event.stopPropagation();
            return false;
        });
    });
}

// This function scrubs the empty tags and whitespace from the search XML "node". Firefox/W3C browsers
// preserve whitespace as child nodes, IE does not. The search engine is not equipped to handle or
// ignore the whitespaces, so I'm scrubbing them out on the XML level. This function is called in by
// the LoadStreetInfoxxx() function in this file.
function RemoveWhitespace(oNode) {
    var notaspace = /\S/;
  for (var x = 0; x < oNode.childNodes.length; x++) {
    var childNode = oNode.childNodes[x]
    if ((childNode.nodeType == 3)&&(!notaspace.test(childNode.nodeValue))) {
// Remove the child node if it is garbage/whitespace
      oNode.removeChild(oNode.childNodes[x])
      x--
    }
    if (childNode.nodeType == 1) {
// recursive call to remove whitespaces from children of child nodes
        RemoveWhitespace(childNode)
    }
}
return oNode;
}


//used for testing only
function ViewXml(xmlDoc, event) {    
    var html= "<html><body><textarea cols='100' rows='20' wrap='true'>" + xmlDoc.String() + "</textarea></body></html>"
    var d = window.open("", "xml", "height=350px,width=900px,help=no,status=no");    
//    d.document.open("text/html");
    d.document.write(html);
    d.document.close();
           
}
function ViewJson(xmlDoc) {
	//writes out search object's XML structure in JSON notation
	//requires /js/XML.ObjTree.js and /js/jkl-dumper.js
	//	(checks for their availability)
	if (typeof XML != 'undefined' && XML.ObjTree
			&& typeof JKL != 'undefined' && JKL.Dumper) {	//ensure xml parser and object dumper are available
		if (typeof xmlDoc == 'object' && xmlDoc.String()) {
			//parse XML into JSON
			var searchCrit = xmlDoc.String();
			var xotree     = new XML.ObjTree();
			var crit       = xotree.parseXML( searchCrit );	//source to JSON tree
			
			//make JSON into string
			var dumper = new JKL.Dumper();
			var json   = dumper.dump( crit );
			
			//output string
			var d = window.open('', 'json', 'height=350px,width=700px,help=no,status=no,');
			d.document.open('text/html');
			d.document.write('<textarea cols="80" rows="20">');
			d.document.write(json);
			d.document.write('</textarea>');
			d.document.close();
		}
	} else {
		ViewXml(xmlDoc);
	}
}//ViewJson()

//Shows html in a popup browser, along with a message.
//This is used for testing only.
function ShowHtmlInPopup(displayHtml, message) {
    d = window.open();
    var page = message +  " <!-- ****** HTML STARTS AFTER THIS COMMENT ***** -->"  + displayHtml
    d.document.open("text/plain").write(page); 
    }

function _month(dt) {
    // Numeric representation of a month, with leading zeros
    return dt.getMonth() < 9?
    "0"+(dt.getMonth()+1) : 
    dt.getMonth()+1;
}

function _day(dt) {
    // Day of the month, 2 digits with leading zeros
    return new String(dt.getDate()).length == 1?
    "0"+dt.getDate() : dt.getDate();
}

function _year(dt) {
    // A full numeric representation of a year, 4 digits

    // we first check, if getFullYear is supported. if it
    // is, we just use that. ppks code is nice, but wont
    // work with dates outside 1900-2038, or something like that
    if (dt.getFullYear) {
        var newDate = new Date("January 1 2001 00:00:00 +0000");
        var x = newDate .getFullYear();
        if (x == 2001) {              
            // i trust the method now
            return dt.getFullYear();
        }
    }
    // else, do this:
    // codes thanks to ppk:
    // http://www.xs4all.nl/~ppk/js/introdate.html
    var x = dt.getYear();
    var y = x % 100;
    y += (y < 38) ? 2000 : 1900;
    return y;
}

function toDateYMD(dt) {
	// Format date YYYY-MM-DD
	
 	var d = new Date(dt);
 	return new String(_year(d) + '-' + _month(d) + '-' + _day(d));  
}

function dateYMD2MDY(dt) {
	// Converts date from yyyy-mm-dd or yyyy/mm-dd to mm/dd/yyyy
	
	var re = new RegExp('^(\d{4})(\/|-)(\d{2})(\/|-)(\d{2})$');
	if (dt.match(re)) {
		alert('dateYMD2MDY function error: expecting date format yyyy-mm-dd or yyyy/mm/dd as input');
		return '';
	}
	
	var arr;
	if (dt.indexOf('-') > -1) {
		arr = dt.split('-');
	}
	else if (dt.indexOf('/') > -1) {
		arr = dt.split('/');
	}
	else {
		return '';
	}
	
 	return new String(arr[1] + '/' + arr[2] + '/' + arr[0]);  
}

//MLS number contains only letters and digits, and max length of 20 characters.
function IsMlsNumber(value) {
    if (value === undefined || value === null) return false;

    var objRegex = new RegExp("^[a-zA-Z0-9]+$");
    return value.length <= 20 && objRegex.test(value);
}

/**********************************************

   Functions to return the control objects

***********************************************/


//Return the object for the field.
function GetFieldObject(xmlNodeName) {
	var control = arrFields[xmlNodeName]
	return control
}

//Return the object for the field and also load the data.
function GetFieldObjectAndLoadData(xmlNodeName, oNode) {
	var control = GetFieldObject(xmlNodeName)
	if (control != undefined) {
		if (oNode != null) {
			control.LoadSearchCriteria(oNode)
		}
	}
	return control
}

//Return the object for the field from the xml object.
function GetFieldObjectAndLoadDataFromXml(xmlNodeName, objXml) {
	var oNodes = objXml.selectNodes("/Search/" + xmlNodeName);
	var oNode = oNodes.nextNode;
	control = GetFieldObjectAndLoadData(xmlNodeName, oNode) 
	return control	
}

/****************************************

   Objects & Object Functions

****************************************/


//This object is used as the base class all fields controls.
function BaseControlInfo(xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition) {

	this.xmlNodeName = xXmlNodeName
	this.controlType = xControlType
	this.baseName = xBaseName
	this.sectionId = xSectionId
	this.uniquePosition = xUniquePosition
}

//This array keeps a copy of all the objects representing info about each field.
var arrFields = new Array

//This is a Javascript Object to represent the information on the client for the FromTo control
function FromToControlxx(xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition, xDisplayType, xAutoFill, xMin, xMax) {

	//Load the base control
	this.base = BaseControlInfo
    this.base (xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition)    

    this.displayType = xDisplayType
    this.autoFill = xAutoFill
    this.min = xMin
    this.max = xMax
    
    //fields loaded from the search criteria xml
    this.fromValue = ""
    this.toValue = ""
    this.total = ""
    this.duration = ""    
    this.dataType = ""
}

//Add the method to the /FromToControlInfo1 object to load the search criteria xml to the object
//Note: This method should be the exact same for ALL types of control
 FromToControlxx.prototype.LoadSearchCriteria = LoadFromToValues
 FromToControlxx.prototype.IsEmpty = FromToIsEmpty
 FromToControlxx.prototype.DataTypeIsRolling = FromToDataTypeIsRolling

function LoadFromToValues(oNode) {
	// ie=oNode.length  w3c=hasAttributes()	
	var hasAttributes = (oNode.attributes ? oNode.attributes.length : oNode.hasAttributes())	
	if (hasAttributes) {	
	    this.fromValue = oNode.getAttribute("From")
	    if (this.fromValue == null) {this.fromValue = ""}
	    this.toValue = oNode.getAttribute("To") 
	    if (this.toValue == null) {this.toValue = ""}
	
	    this.dataType = oNode.getAttribute("Type")
	    if (this.dataType == null) {this.dataType = ""}
	    this.total = oNode.getAttribute("Total") 
	    if (this.total == null) {this.total = ""}
	    this.duration = oNode.getAttribute("Duration") 
	    if (this.duration == null) {this.duration = ""}    	
	} else {
  		this.fromValue = ""
		this.toValue = ""
		this.dataType = ""
		this.total = ""
		this.duration = ""

	}

}

function FromToIsEmpty() {
	if (this.fromValue == "" && this.toValue == "" && this.total == "" && this.duration == "") {
		return true
	} else {
		return false
	}
}

function FromToDataTypeIsRolling() {
	if (this.fromValue == "" && this.toValue == "" && this.total != "" && this.duration != "") {
		return true
	} else {
		return false
	}
}

//This is a Javascript Object to represent the information on the client for the Checkbox control
function CheckboxControlxx(xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition, xRepeatColumns) {

	//Load the base control
	this.base = BaseControlInfo
    this.base (xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition)  
    
    this.repeatColumns = xRepeatColumns
    
    //this is loaded when the LoadCheckboxValues function is run.
    this.Values = new Array()  
}

//Add the method to the CheckboxControl object to load the search criteria xml to the object
//Note: This method name "LoadSearchCriteria" should be the exact same name for ALL types of control
 CheckboxControlxx.prototype.LoadSearchCriteria = LoadValues
 CheckboxControlxx.prototype.IsEmpty = ValueNodeIsEmpty  

//This is a Javascript Object to represent the information on the client for the Checkbox control
function StatusGroupCheckboxControlxx(xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition, xRepeatColumns) {

	//Load the base control
	this.base = BaseControlInfo
    this.base (xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition)  
    
    this.repeatColumns = xRepeatColumns
    
    //this is loaded when the LoadCheckboxValues function is run.
    this.Values = new Array()  
}

//Add the method to the CheckboxControl object to load the search criteria xml to the object
//Note: This method name "LoadSearchCriteria" should be the exact same name for ALL types of control
 StatusGroupCheckboxControlxx.prototype.LoadSearchCriteria = LoadValues
 StatusGroupCheckboxControlxx.prototype.IsEmpty = ValueNodeIsEmpty  

function LoadValues(oNode) {
    this.Values = new Array()
    if (oNode.hasChildNodes == true) {
        this.Values = populateArrayWithChildNodes(oNode)
    }
}

//This is a Javascript Object to represent the information on the client for the LookupList control
function LookupListControlxx(xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition, xDisplayType, xAddAction, xQuickAddMaxLength) {

	//Load the base control
	this.base = BaseControlInfo
    this.base (xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition)
    this.displayType = xDisplayType
    this.addAction = xAddAction
    this.quickAddMaxLength = xQuickAddMaxLength
    
    //this is loaded when the LoadLookupListValues function is run.
    this.Values = new Array()  
}

//Add the method to the LookupListControl object to load the search criteria xml to the object
//Note: This method name "LoadSearchCriteria" should be the exact same name for ALL types of control
 LookupListControlxx.prototype.LoadSearchCriteria = LoadValues
 LookupListControlxx.prototype.IsEmpty = ValueNodeIsEmpty  

function ValueNodeIsEmpty() {
	if (this.Values.length == 0) {
		return true
	} else {
		return false
	}
}

//This is a Javascript Object to represent the information on the client for the FeatureList control
function FeatureListControlxx(xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition) {

	//Load the base control
	this.base = BaseControlInfo;
    this.base (xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition);
    
    //this is loaded when the LoadFeatureListValues function is run.
    this.Values = new Array();
    this.operatorValue = '';
}

//Add the method to the FeatureListControl object to load the search criteria xml to the object
//Note: This method name "LoadSearchCriteria" should be the exact same name for ALL types of control
 FeatureListControlxx.prototype.LoadSearchCriteria = LoadFeatureListValues;
 FeatureListControlxx.prototype.IsEmpty = ValueNodeIsEmpty;

function LoadFeatureListValues(oNode) {
    this.Values = new Array()
    if (oNode.hasChildNodes == true) {
        this.Values = populateArrayWithChildNodes(oNode)
        this.operatorValue = oNode.getAttribute('Operator');
    }
}

//This is a Javascript Object to represent the information on the client for the Checkbox control
function TextboxControlxx(xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition, xDisplayType, xSize, xMaxLength) {

	//Load the base control
	this.base = BaseControlInfo;
    this.base (xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition);
    
    this.displayType = xDisplayType
    this.size = xSize;
    this.maxLength = xMaxLength;
    
    //this is loaded when the LoadValueAttribute function is run.
    this.Value = '';  
}

//Add the method to the TextboxControl object to load the search criteria xml to the object
//Note: This method name "LoadSearchCriteria" should be the exact same name for ALL types of control
TextboxControlxx.prototype.LoadSearchCriteria = LoadValueAttribute
TextboxControlxx.prototype.IsEmpty = ValueAttributeIsEmpty  

function LoadValueAttribute(oNode) {
    this.Value = oNode.getAttribute('Value');
}

function ValueAttributeIsEmpty() {
	if (this.Value == null || this.Value == '') {
		return true;
	} else {
		return false;
	}
}

//This is a Javascript Object to represent the information on the client for the MlsMapCoordinate control
function MapCoordinateControlxx(xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition) {

	//Load the base control
	this.base = BaseControlInfo;
    this.base (xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition);
        
    //this is loaded when the LoadTextboxValue function is run.
    this.Type = '';	// This will be either "BullsEye" or "Single"
    this.Value = '';  // This will be a csv of map coordinates
}

//Add the method to the MapCoordinateControlxx object to load the search criteria xml to the object
//Note: This method name "LoadSearchCriteria" should be the exact same name for ALL types of control
MapCoordinateControlxx.prototype.LoadSearchCriteria = LoadMapCoordinateValue
MapCoordinateControlxx.prototype.IsEmpty = ValueAttributeIsEmpty  

function LoadMapCoordinateValue(oNode) {
    this.Value = oNode.getAttribute('Value');
    this.Type = oNode.getAttribute('Type');
}

//This is a Javascript Object to represent the information on the client for the RadioButtons control
function RadioButtonsControlxx(xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition) {

	//Load the base control
	this.base = BaseControlInfo;
    this.base (xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition);
    
    //this is loaded when the LoadValueAttribute function is run.
    this.Value = '';  
}

//Add the method to the RadioButtonsControl object to load the search criteria xml to the object
//Note: This method name "LoadSearchCriteria" should be the exact same name for ALL types of control
RadioButtonsControlxx.prototype.LoadSearchCriteria = LoadValueAttribute
RadioButtonsControlxx.prototype.IsEmpty = ValueAttributeIsEmpty  

//This is a Javascript Object to represent the information on the client for the Dropdown control
function DropdownControlxx(xXmlNodeName, xControlType , xBaseName, xSectionId, xUniquePosition, xDisplayType, xItemId, xItemId2 ) {

	//Load the base control
	this.base = BaseControlInfo;
    this.base (xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition);

    this.displayType = xDisplayType;
    this.itemId = xItemId;
    this.itemId2 = xItemId2;
    
    //this is loaded when the LoadValueAttribute function is run.
    this.Values = new Array();
}

//This is an example of a typical Dropdown Search criteria
//<RoomInformation>
//	<Value>
//		<Item Id="Room">1</Item>
//		<Item Id="Level">3</Item>
//	</Value>
//	<Value>
//		<Item Id="Room">2</Item>
//		<Item Id="Level">3</Item>
//	</Value>
//</RoomInformation>
//<SaleTerms>
//	<Value>
//		<Item Id="1">3</Item>
//	</Value>
//</SaleTerms>

//Add the method to the DropdownControl object to load the search criteria xml to the object
//Note: This method name "LoadSearchCriteria" should be the exact same name for ALL types of control
DropdownControlxx.prototype.LoadSearchCriteria = LoadDropdownValues
DropdownControlxx.prototype.IsEmpty = ValuesArrayIsEmpty

function LoadDropdownValues(oNode) {
    if (oNode.hasChildNodes) {
    	var valueNodes = oNode.childNodes;
    	var itemNodes;
    	var itemObj;
    	var items;
    	for (var i=0; i < valueNodes.length; i++) {
    		items = new Array();
    		itemNodes = valueNodes[i].childNodes
    		for (var j = 0; j < itemNodes.length; j++) {
    			if (itemNodes[j].xml != '') {
    				itemObj = new DropdownItem()
    				itemObj.ItemId = itemNodes[j].getAttribute('Id');
    				itemObj.ItemValue = itemNodes[j].text;
    				items.push(itemObj);
    			}
    		}
			this.Values.push(items);
    	}
    }
}

function ValuesArrayIsEmpty() {
	if (this.Values == null || this.Values.length == 0) {
		return true;
	} else {
		return false;
	}
}

//This is a Javascript object the represent an dropdown item.
function DropdownItem() {
	this.ItemId = '';
	this.ItemValue = '';
}

//This is a Javascript Object to represent the information on the client for the StreetInfo control
function StreetInfoxx(xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition) {

	//Load the base control
	this.base = BaseControlInfo;
    this.base (xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition);
    this.StreetItems = new Array()  //Each item in here makes up a "Street" Object"    
}

// This includes individual Street Items in the StreetInfoxx control
function StreetItem(from, to, direction, unit, streetName, mlsArea) {
	//These are the default properties for a given street.
	this.From = from
	this.To = to
	this.Direction = direction
	this.Unit = unit
	this.StreetName = streetName
	this.MLSArea = mlsArea
}

//Add the method to the StreetInfoxx object to load the search criteria xml to the object
//Note: This method name "LoadSearchCriteria" should be the exact same name for ALL types of control

StreetInfoxx.prototype.LoadSearchCriteria = LoadStreetInfoxx
StreetInfoxx.prototype.IsEmpty = StreetInfoIsEmpty  

function LoadStreetInfoxx(oNode) {
	
 	//Initialize the StreetItems array
 	this.StreetItems = new Array()
 	var from, to, direction, unit, streetName, MLSArea
 	// Call to function which scrubs out the whitespace from the passed xml node
 	// for browser compatability
 	oNode = RemoveWhitespace(oNode);
	
	 if (oNode.hasChildNodes) {
	     var itemNodes = oNode.childNodes;
    	
    	// Look at all the items
    	for (var itemPos=0; itemPos < itemNodes.length; itemPos++) {

			// Look at all the elements within the item    			
    		if (itemNodes[itemPos].hasChildNodes) {
    			
    			from = ""
    			to = ""
    			direction = ""
    			unit = ""
    			streetName = ""
    			MLSArea = ""
    			
    			var individualElementNodes = itemNodes[itemPos].childNodes
    			for (var xmlNodePos = 0; xmlNodePos < individualElementNodes.length; xmlNodePos++) {

    				if (individualElementNodes[xmlNodePos].nodeName == 'StreetNumber') {
    					from = individualElementNodes[xmlNodePos].getAttribute('From')
    					to = individualElementNodes[xmlNodePos].getAttribute('To')
    				}
    				if (individualElementNodes[xmlNodePos].nodeName == 'Direction') {
    					directionValueNode = individualElementNodes[xmlNodePos].selectNodes("Value")
    					if (directionValueNode != null) {
    						direction = getNodeTextValue(directionValueNode);

    					}
    				}
    				if (individualElementNodes[xmlNodePos].nodeName == 'StreetName') {
    					singleStreetNameValueNode = individualElementNodes[xmlNodePos].selectNodes("Value")
    					if (singleStreetNameValueNode != null) {
    						streetName = getNodeTextValue(singleStreetNameValueNode);

    						if (streetName.charAt(streetName.length - 1) == "%") {
    							streetName = streetName.replace(/\%$/, "")
    						}

    					}
    				}
    				if (individualElementNodes[xmlNodePos].nodeName == 'Unit') {
    					unit = individualElementNodes[xmlNodePos].getAttribute("Value")
    				}
    				if (individualElementNodes[xmlNodePos].nodeName == 'SingleMLSArea') {
    					singleMLSAreaValueNode = individualElementNodes[xmlNodePos].selectNodes("Value")
    					if (singleMLSAreaValueNode != null) {
    						MLSArea = getNodeTextValue(singleMLSAreaValueNode);
    					}
    				}
    			}
    			
				var street = new StreetItem (from, to, direction, unit, streetName, MLSArea)
	    		this.StreetItems.push(street)	    				
    			
    		}
    	}
    }
}

function StreetInfoIsEmpty() {
	if (this.StreetItems.length > 0) {
		for (var i=0; i < this.StreetItems.length; i++) {
			var street = this.StreetItems[i]
			//The node is considered not empty if a street name has been entered.
			if (street.StreetName != "") {
				return false
			}
		}		
	}
	return true
}


//This is a Javascript Object to represent the information on the client for the DateTime control
function DateTimeControlxx(xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition) {

	//Load the base control
	this.base = BaseControlInfo;
    this.base (xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition);
        
    //this is loaded when the LoadValueAttribute function is run.
    this.DateText = '';  
    this.TimeText = '';
}

//Add the method to the TextboxControl object to load the search criteria xml to the object
//Note: This method name "LoadSearchCriteria" should be the exact same name for ALL types of control
DateTimeControlxx.prototype.LoadSearchCriteria = LoadDateTimeAttributes
DateTimeControlxx.prototype.IsEmpty = DateTimeAttributesIsEmpty  

function LoadDateTimeAttributes(oNode) {
    this.DateText = oNode.getAttribute('DateText');
    this.TimeText = oNode.getAttribute('TimeText');
}

function DateTimeAttributesIsEmpty() {
	if (this.DateText == null || this.DateText == '') {
		return true;
	} else {
		return false;
	}
}


//This is a Javascript Object to represent the information on the client for the Radius control
function RadiusControlxx(xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition) {

	//Load the base control
	this.base = BaseControlInfo;
	this.base(xXmlNodeName, xControlType, xBaseName, xSectionId, xUniquePosition);

	//fields loaded from the search criteria xml
	this.centerLatitude = "";
	this.centerLongitude = "";
	this.distance = "";
	this.locationText = "";
}

//Add the method to the TextboxControl object to load the search criteria xml to the object
//Note: This method name "LoadSearchCriteria" should be the exact same name for ALL types of control
RadiusControlxx.prototype.LoadSearchCriteria = LoadRadiusValues
RadiusControlxx.prototype.IsEmpty = RadiusIsEmpty

function LoadRadiusValues(oNode) {
	var hasAttributes = (oNode.attributes ? oNode.attributes.length : oNode.hasAttributes())
	if (hasAttributes) {
		this.centerLatitude = oNode.getAttribute("CenterLatitude");
		if (this.centerLatitude == null) {this.centerLatitude = "";}
		
		this.centerLongitude = oNode.getAttribute("CenterLongitude");
		if (this.centerLongitude == null) { this.centerLongitude = ""; }
		
		this.distance = oNode.getAttribute("Distance");
		if (this.distance == null) { this.distance = ""; }

		this.locationText = oNode.getAttribute("LocationText");
		if (this.locationText == null) { this.locationText = ""; }
	} else {
		this.centerLatitude = "";
		this.centerLongitude = "";
		this.distance = "";
		this.locationText = "";
	}
}

function RadiusIsEmpty() {
	if (this.centerLatitude == "" && this.centerLongitude == "" && this.distance == "" && this.locationText == "") {
		return true
	} else {
		return false
	}
}
