﻿
var XMLKeyShortening={Parameter:"p",Key:"k",Value:"v",ParameterType:"pt",MustHaveValue:"mhv"};
var ParameterType = { Value:0,Base:1, Advanced:2, MustHave:4, AdvancedAndMustHave:6,Email:8 };
var EmptyString={Value:""};
function GetStringParameterXMLItemString(key,value)
{
var result=new StringBuilder();
result.Append("<");
result.Append(XMLKeyShortening.Parameter);
result.Append(" ");
result.Append(XMLKeyShortening.Key);
result.Append("=\"");
result.Append(key);
result.Append("\" ");
result.Append(XMLKeyShortening.Value);
result.Append("=\"");
result.Append(value);
result.Append("\" ");
result.Append(" />");
return result.ToString();
}
function GetParameterXMLItemString(key,value,mustHaveValue)
{
var result=new StringBuilder();
result.Append("<");
result.Append(XMLKeyShortening.Parameter);
result.Append(" ");
result.Append(XMLKeyShortening.Key);
result.Append("=\"");
result.Append(key);
result.Append("\" ");
result.Append(XMLKeyShortening.Value);
result.Append("=\"");
result.Append(value);
result.Append("\" ");
result.Append(XMLKeyShortening.MustHaveValue);
result.Append("=\"");
result.Append(mustHaveValue);
result.Append("\" />");
return result.ToString();
}
function DropDownListParameter(controlId,key,mustOrNiceToHaveRadioButtonName,firstItemAavailable)
{
this.controlId=controlId;
this.key=key;
this.mustOrNiceToHaveRadioButtonName=mustOrNiceToHaveRadioButtonName;
this.firstItemAavailable=firstItemAavailable;
if(typeof DropDownListParameter._initialized=="undefined")
{
DropDownListParameter.prototype.GetXMLString=function ()
{
var control=document.getElementById(this.controlId);
if(control.selectedIndex==0 && !this.firstItemAavailable)return EmptyString.Value;
var inputValue=control.options[control.selectedIndex].value;
if(this.mustOrNiceToHaveRadioButtonName==null ||this.mustOrNiceToHaveRadioButtonName==undefined)
{
return GetStringParameterXMLItemString(this.key,inputValue);
}
else
{
var mustHaveValue=this.GetMustOrNiceToHaveValue();
return GetParameterXMLItemString(this.key,inputValue,mustHaveValue);
}
};
DropDownListParameter.prototype.GetMustOrNiceToHaveValue=function ()
{
var mustOrNiceToHaveRadioButtons=document.getElementsByName(this.mustOrNiceToHaveRadioButtonName);
return mustOrNiceToHaveRadioButtons[0].checked;
};
DropDownListParameter.prototype.GetValue=function ()
{	
var control=document.getElementById(this.controlId);
return control.options[control.selectedIndex].value;
};
DropDownListParameter._initialized=true;
}
}
function StringParameter(valueString,key)
{
this.valueString=valueString;
this.key=key;
if(typeof StringParameter._initialized=="undefined")
{
StringParameter.prototype.GetXMLString=function ()
{
if(this.valueString==EmptyString.Value)
{
return EmptyString.Value;
}
return GetStringParameterXMLItemString(this.key,this.valueString);
};
StringParameter.prototype.GetValue=function ()
{
return this.valueString;
};
StringParameter._initialized=true;
}
}
function StringParameterWithMustOrNiceToHave(valueString,key, mustOrNiceToHaveValue)
{
this.valueString=valueString;
this.key=key;
this.mustOrNiceToHaveValue = mustOrNiceToHaveValue;
if(typeof StringParameterWithMustOrNiceToHave._initialized=="undefined")
{
StringParameterWithMustOrNiceToHave.prototype.GetXMLString=function ()
{
if(this.valueString == null || this.valueString == "")
{
return EmptyString.Value;
}
else
{
return GetParameterXMLItemString(this.key,this.valueString,this.mustOrNiceToHaveValue);
}
};
StringParameterWithMustOrNiceToHave.prototype.GetValue=function ()
{
return this.valueString;
};
StringParameterWithMustOrNiceToHave._initialized=true;
}
}
function SelectParameterList()
{
this.UserID=EmptyString.Value;	
this.searchId=EmptyString.Value;	
this.CitySubAreaZipcodeString=EmptyString.Value;
this.ListingType=EmptyString.Value;
this.PropertyType=EmptyString.Value;
this.MinBedrooms=EmptyString.Value;
this.MinBathrooms=EmptyString.Value;
this.MinPrice=EmptyString.Value;
this.MaxPrice=EmptyString.Value;
this.IsAutoSaveSearch=EmptyString.Value;
this.SearchName=EmptyString.Value;
this.IsEmailUpdates=EmptyString.Value;
this.EmailUpdatesFrequency=EmptyString.Value;
this.MinSquareFeet=EmptyString.Value;
this.MinLotSize=EmptyString.Value;
this.NumberOfStories=EmptyString.Value;
this.MinDaysOnMarket=EmptyString.Value;
this.MaxDaysOnMarket=EmptyString.Value;
this.MinYearBuilt =EmptyString.Value;
this.MaxYearBuilt =EmptyString.Value;
this.ElementaryDistrict=EmptyString.Value;
this.HighSchoolDistrict=EmptyString.Value;
this.Garage=EmptyString.Value;
this.HasPhotos=EmptyString.Value;
this.StatusDESC=EmptyString.Value;
this.SeparateFamilyRoom=EmptyString.Value;
this.FormalDiningRoom=EmptyString.Value;
this.Library=EmptyString.Value;
this.DenOrStudy=EmptyString.Value;
this.FullBasement=EmptyString.Value;
this.SeparateLivingUnit=EmptyString.Value;
this.Cabin=EmptyString.Value;
this.CapeCod=EmptyString.Value;
this.Colonial=EmptyString.Value;
this.Contemporary=EmptyString.Value;
this.CottageOrBungalow=EmptyString.Value;
this.Ranch=EmptyString.Value;
this.Spanish=EmptyString.Value;
this.Traditional=EmptyString.Value;
this.Tudor=EmptyString.Value;
this.Victorian=EmptyString.Value;
this.SortString = EmptyString.Value;
this.SortType = null;

if(typeof SelectParameterList._initialized=="undefined")
{
SelectParameterList.prototype.GetXMLString=function ()
{
this.Update();
var result=new StringBuilder();
result.Append("<?xml version=\"1.0\"?>");
result.Append("<parameters>");
result.Append("<pParams>");
for(index in this.PropertyParameters)
{
result.Append(this.PropertyParameters[index].GetXMLString());
}
var niceToHaveString = XMLKeyShortening.MustHaveValue + "=\"false\"";
if(result.ToString().toLowerCase().indexOf(niceToHaveString) >= 0)
{
result.Append(GetStringParameterXMLItemString("needScore","true"));
}
else
{
result.Append(GetStringParameterXMLItemString("needScore","false"));
}
result.Append("</pParams>");
result.Append("<uParams>");
for(index in this.UserParameters)
{
result.Append(this.UserParameters[index].GetXMLString());
}
result.Append("</uParams>");
result.Append("</parameters>");
if(result.ToString()=="<?xml version=\"1.0\"?><parameters></parameters>")return EmptyString.Value;
return result.ToString();
};
SelectParameterList.prototype.Update=function ()
{
};
SelectParameterList._initialized=true;
}
}
