$j = jQuery.noConflict();
$j(document).ready(function(){
	//();
});

var searchBox = {
	Init:function(){
		// objects
		// objects
		searchBox.CountryDropDown = $j('#selectCountry')[0];
		searchBox.RegionDropDown = $j('#selectRegion')[0];
		searchBox.MinPriceDropDown = $j('#selectMinPrice')[0];
		searchBox.MaxPriceDropDown = $j('#selectMaxPrice')[0];
		searchBox.MinBedDropDown = $j('#selectMinBed')[0];
		searchBox.MaxBedDropDown = $j('#selectMaxBed')[0];
		searchBox.CurrencyDropDown = $j('#selectCurrency')[0];
		searchBox.AutoCompleteTextBox = $j('#searchIntellLocation')[0]; 
		searchBox.PropertyNameTextBox = $j('#searchPropertyName')[0];
		searchBox.ReferenceTextBox = $j('#searchPropertyID')[0];
		searchBox.SubmitButton = $j('#searchSubmit')[0];
		searchBox.MessageBox = $j('#searchMessageBox')[0];
		searchBox.PriceUnitValueControl = $j('#ctr_searchBox_PriceUnitValue');
		searchBox.KeywordsTextBox = $j('#ctr_searchBox_Keywords');
		searchBox.isLondonLocation = false; //$j('#ctr_searchBox_isLondonLocation');
		
		searchBox.AutoCompleteTextBox = $j('#searchIntellLocation')[0];
		searchBox.AutoCompleteTypeBox = $j('#searchIntellType')[0];
		
		// prepare Controls
		this.EnableMinControls();
		
		
		// Watermark Controls
		if(siteIsSubdomain){
			$j(searchBox.AutoCompleteTextBox).Watermark("Where? Country, Region or Place","#0271D4");
			$j(searchBox.AutoCompleteTypeBox).Watermark("What? Property Type or Property ID","#0271D4");
		}else{
			$j(searchBox.AutoCompleteTextBox).Watermark("Where? Location","#0271D4");
			$j(searchBox.AutoCompleteTypeBox).Watermark("What? Type or Id","#0271D4");
		}
		
		// DataBind()
		if(siteIsSubdomain==false){
		this.FillDropDown(this.getCountries(),this.CountryDropDown);
		this.FillDropDown(this.getCurrencies(),this.CurrencyDropDown);
		this.FillDropDown(this.getPriceRanges(),this.MinPriceDropDown);
		this.FillDropDown(this.getPriceRanges(),this.MaxPriceDropDown);
		//this.FillDropDown(this.getBedRanges(),this.MinBedDropDown);
		//this.FillDropDown(this.getBedRanges(),this.MaxBedDropDown);
		}
		
		// events
		$j(this.SubmitButton).click(function(e){searchBox.onSubmit(e);});
		if(siteIsSubdomain==false){
			$j(this.CountryDropDown).change(function(e){searchBox.onCountryChanged(e);});
			/*$j(this.RegionDropDown).change(function(e){searchBox.onRegionChanged(e);});*/
			$j(this.CurrencyDropDown).change(function(e){searchBox.onCurrencyChanged(e);});
			$j(this.MinPriceDropDown).change(function(e){searchBox.onMinPriceChanged(e);});
			$j(this.MaxPriceDropDown).change(function(e){searchBox.onMaxPriceChanged(e);});
			/*$j(this.MinBedDropDown).change(function(e){searchBox.onMinBedChanged(e);});
			$j(this.MaxBedDropDown).change(function(e){searchBox.onMaxBedChanged(e);});*/
		}
		// get current controls value
		// this.SelectedCurrencyCode = $j("option:selected",this.CurrencyDropDown).val();
		
		// auto complete
		$j(this.AutoCompleteTextBox).autocomplete('/tmc.system/geo.services.locations.asp', {
		    delay: 400,
		    width: 400,
		    scroll: false,
		    formatItem: formatItem,
		    formatResult: formatResult,
			selectFirst: true,
			cacheLength: 1,
			max:15,
		    extraParams: {
				country: "Myanmar",
		        countryID: "",
				GetLocationsByPrefix:"a"
		    }
	    });
		
		// auto complete for types
		$j(this.AutoCompleteTypeBox).autocomplete('/tmc.system/tmc.services.locations.asp', {
		    delay: 100,
		    width: 400,
		    scroll: false,
		    formatItem: formatItem,
		    formatResult: formatResult,
			selectFirst: true,
		    extraParams: {
				country: "Myanmar",
		        countryID: "",
				GetTypesByPrefix:"a"
		    }
	    });
		
		$j(this.AutoCompleteTypeBox).result(function(event,data,formatted){
			var url = data[3];
			var name = data[1];
			var id = data[2];
			
			searchBox.SelectedTypeID = id;
			searchBox.SelectedTypeURL = url;
		});
		
		$j(this.AutoCompleteTextBox).result(function(event,data,formatted){
			//alert(data);
			var level = data[4];
			var IDs;
			var regionID;
                //alert(data);
            IDs = data[3].split('_');
			if(level==1){ regionID = data[2]; }
			else{ regionID = IDs[0]; }
			
			// Utils.DropDownSelect(searchBox.RegionDropDown,regionID);
			
			// set loation id
			searchBox.SelectedLocationID = data[2];
			// country subdomain check 
			
			if(siteIsSubdomain && siteIsCountrySubDomain)
				if(siteRootLocation =='UK')
					searchBox.SelectedLocationURL = data[1].replace('united_kingdom/','');			
				else
					searchBox.SelectedLocationURL = data[1].replace(siteRootLocation.toLowerCase().replace(' ','_')+'/','');			
			else
				searchBox.SelectedLocationURL = data[1];
			
			// now check if the selected location is in Greater London?
			// if (IDs[0]==50503&&IDs[1]==0) { - Russ - 06/11/2009 remove IDs[1] check to allow /Barking and Dagenham/ level
			if (IDs[0]==50503) {
				searchBox.isLondonLocation = true;
			}
		});
	},
	onSubmit:function(e){
		//mansoor
		e.preventDefault();
		//alert("here");
		/*alert($j('#searchForm #ctr_searchBox_minPriceIndex').length);
		alert(searchBox.MinPriceDropDown.selectedIndex);
		alert(searchBox.MaxPriceDropDown.selectedIndex);
		alert(searchBox.MinBedDropDown.selectedIndex);
		alert(searchBox.MaxBedDropDown.selectedIndex);*/
		
		//alert('submitting form now');
		// now update form control with price bands index
		
		$j('#searchForm').attr("action",searchBox.SubmitURL);
		$j('#searchForm').attr("method",searchBox.SubmitMethod);
		
		// construct URL here
		var _targetDomain = 'http://'+document.domain;
		var _defaultURL = '/property/all/';
		var _targetURL = '';
		if(searchBox.SelectedTypeURL!='')			
			_targetURL += '/' + searchBox.SelectedTypeURL;		
		if(searchBox.SelectedLocationURL!= '')
			_targetURL += '/' + searchBox.SelectedLocationURL;
		if(_targetURL=='')
			_targetURL = _defaultURL;					
		else
			_targetURL = '/property' + _targetURL ;
		
		// window.location.replace(_targetDomain+_targetURL);
		if (isInteger($j('#searchIntellType').val()))	//if property id then redirect to property detail page		
			_targetURL = '/property/details/' + ($j('#searchIntellType').val()) + '/';
			
		if (siteIsSubdomain){
			if(_targetURL == '/property/all/')
			{
				if($j('#searchIntellLocation').val()!='')
				{
					if($j('#searchIntellLocation').val().toLowerCase().indexOf('where?') == -1)
						_targetURL = '/property/search_location/' + $j('#searchIntellLocation').val() + '/';
					else if($j('#searchIntellType').val()!='')
					{				
						if($j('#searchIntellType').val().toLowerCase().indexOf('what?') == -1)
							_targetURL = '/property/search_type/' + $j('#searchIntellType').val() + '/';
					}
				}
			}
			window.location = _targetDomain+_targetURL;
		}else{
			/* --- .com site --- */
			if ($j("option:selected",searchBox.CountryDropDown).text()!='Please Select Country' && (searchBox.AutoCompleteTextBox.value == 'Where? Location' || searchBox.AutoCompleteTextBox.value == '')){
				_targetURL += $j("option:selected",searchBox.CountryDropDown).text() + '/';
				_targetURL = _targetURL.replace('/all','');				
			}
			
			if (searchBox.AutoPriceIndexSelect){
				$j('#searchForm #ctr_searchBox_minPriceIndex').attr("value",searchBox.MinPriceDropDown.selectedIndex);
				$j('#searchForm #ctr_searchBox_maxPriceIndex').attr("value",searchBox.MaxPriceDropDown.selectedIndex);
			}else{
				$j('#searchForm #ctr_searchBox_minPriceIndex').attr("value",-1);
				$j('#searchForm #ctr_searchBox_maxPriceIndex').attr("value",-1);
			}
			$j('#searchForm #ctr_searchBox_countryName').attr("value",$j("option:selected",searchBox.CountryDropDown).text());
			$j('#searchForm #ctr_searchBox_countryID').attr("value",$j("option:selected",searchBox.CountryDropDown).val());
			$j('#searchForm #ctr_searchBox_isLondonLocation').attr("value",searchBox.isLondonLocation);
			
			$j('#searchIntellLocation').val('');
			$j('#searchIntellType').val('');
			$j('#searchBox_isFromSearchForm').val('false');
			
			// alert((_targetDomain+_targetURL).toLowerCase());
			
			
			
			$j('#searchForm').attr("action",(_targetDomain+_targetURL).toLowerCase());
			$j('#searchForm').attr("method",searchBox.SubmitMethod);
			
			$j('#searchForm').submit();
		}
		// $j('#searchForm').submit();
	},
	onCountryChanged:function(e){
		e.preventDefault();
		
		// if no country selected? then reset form back to original state.
		if($j("option:selected",this.CountryDropDown).val()==0){
			this.Init();
			this.SelectedDropdown = "";
			return false;
		}
		
		this.SelectedDropdown = "country";
		
		// enable controls
		if($j(this.RegionDropDown).is(":disabled")){this.RegionDropDown.disabled=false;}
		if($j(this.PropertyNameTextBox).is(":disabled")){this.PropertyNameTextBox.disabled=false;}
		if($j(this.AutoCompleteTextBox).is(":disabled")){this.AutoCompleteTextBox.disabled=false;}
		if($j(this.MinBedDropDown).is(":disabled")){this.MinBedDropDown.disabled=false;}
		
		// set loation id
		this.SelectedLocationID = $j("option:selected",this.CountryDropDown).val();
		
		//alert($j("option:selected",this.CountryDropDown).text() + " is selected.");
		/*
		this.FillMinBedsDropDown();
		this.FillRemoteDropDown(this.RegionDropDown,this.CountryDropDown);
		*/
		//alert(Utils.getCurrencyRate($j("option:selected",this.CountryDropDown).text()));
		
		// check currency
		//alert('Currency : '+searchBox.SelectedCurrencyCode);
		//alert($j("option:selected",searchBox.CurrencyDropDown).val());
		
		// if current selected currency is not GBP EUR USD
		var currentCurrency = $j("option:selected",searchBox.CurrencyDropDown).val();
		if ((currentCurrency!='GBP'&&currentCurrency!='USD'&&currentCurrency!='EUR')||currentCurrency=='Currency'){
			// then refill dropdown with default currencies or no currency is selected
			if($j(this.MinPriceDropDown).is(":disabled")){
				this.MinPriceDropDown.disabled=false;
				this.FillMinPriceDropDown();
			}
			this.FillDropDown(this.getCurrencies(),this.CurrencyDropDown);
		}
		
		// first get default currency and rate of selected Country
		var countryRate = parseInt(Utils.getCurrencyRate($j("option:selected",this.CountryDropDown).text()));
		var countryCurrency = Utils.getCurrencyCode($j("option:selected",this.CountryDropDown).text());
		
		// if country's default Currency is not GBP EUR USD
		if(countryCurrency!='GBP'&&countryCurrency!='EUR'&&countryCurrency!='USD'){
			// now add a new currency to the drop down list
			this.AddCurrency(countryCurrency);
			//this.CurrencyCode = countryCurrency;
			//this.ExchangeRate = countryRate;
			if($j(this.MinPriceDropDown).is(":disabled")){this.MinPriceDropDown.disabled=false;}
			//this.FillMinPriceDropDown();
			
		}
		
		// check current selected CUR on the drop-down contorl
		var selectedCurrency = $j("option:selected",this.CurrencyDropDown).val();
		if(selectedCurrency == 'Currency'){
			// if not currency is selected then, set the country default currency as selected currency;
			this.SelectCurrencyByCode(countryCurrency);
		}
		
		searchBox.SelectedCurrencyCode = $j("option:selected",searchBox.CurrencyDropDown).val();
				
		this.UpdateSubmitButton();
		
		$j(this.AutoCompleteTextBox).setOptions({
			extraParams : { country:$j('option:selected',$j(this.CountryDropDown)).text(), countryID:"0",GetLocationsByPrefix:"a"}
		}).flushCache();
	},
	onCurrencyChanged:function(e){
		e.preventDefault();
		//alert($j(this.CurrencyDropDown).val() + " is selected.");
		searchBox.SelectedCurrencyCode = $j("option:selected",searchBox.CurrencyDropDown).val();
		//alert(searchBox.SelectedCurrencyCode);
		
		this.UpdateSubmitButton();
		
		if(this.SelectedCurrencyCode=='Currency'){
			this.SelectedMixPrice = 0;
			this.SelectedMaxPrice = 0;
			this.FillMinPriceDropDown();
			this.FillMaxPriceDropDown();
			this.MinPriceDropDown.disabled=true;
			this.MaxPriceDropDown.disabled=true;
			return false;
		}
		
		if(this.SelectedCurrencyCode=='GBP'||this.SelectedCurrencyCode=='EUR'||this.SelectedCurrencyCode=='USD'){
			//alert(searchBox.SelectedCurrencyCode);
			this.ExchangeRate = Utils.getCurrencyRateByCurrency(this.SelectedCurrencyCode);
			this.CurrencyCode = this.SelectedCurrencyCode;
		}else{
			this.ExchangeRate = parseInt(Utils.getCurrencyRate($j("option:selected",this.CountryDropDown).text()));
			//alert(this.ExchangeRate);
			this.CurrencyCode = $j("option:selected",this.CurrencyDropDown).val();
		}
		
		if(this.ExchangeRate==0){ExchangeRate=1;}
		this.FillMinPriceDropDown();
		if($j(this.MinPriceDropDown).is(":disabled")){this.MinPriceDropDown.disabled=false;}
		this.MaxPriceDropDown.disabled=true;
		this.SelectedMixPrice = 0;
		this.SelectedMaxPrice = 0;
	},
	onMinPriceChanged:function(e){
		e.preventDefault();
		if($j("option:selected",this.MinPriceDropDown).text()!="Min Price"){
			if($j(this.MaxPriceDropDown).is(":disabled")){this.MaxPriceDropDown.disabled=false;}
			this.SelectedMinPrice = $j("option:selected",this.MinPriceDropDown).val();
			this.SelectedMinPriceIndex = this.MinPriceDropDown.selectedIndex;
			this.FillMaxPriceDropDown();
		}
		else{
			this.MaxPriceDropDown.disabled=true;
			this.SelectedMixPrice = 0;
			this.SelectedMinPriceIndex = this.MinPriceDropDown.selectedIndex;
			this.SelectedMaxPrice = 0;
			this.SelectedMaxPriceIndex = this.MaxPriceDropDown.selectedIndex;
		}
	},
	onMaxPriceChanged:function(e){
		e.preventDefault();
		if($j("option:selected",this.MaxPriceDropDown).text()!="Max Price"){
			this.SelectedMaxPrice = $j("option:selected",this.MaxPriceDropDown).val();
			this.SelectedMaxPriceIndex = this.MaxPriceDropDown.selectedIndex;
		}
	},
	FillBedDropDown:function(data,obj){
		$j(obj).removeOption(/./);
		//alert(searchBox.ExchangeRate);
		var label = "Min Beds";
		var skip = false;
		var lastItemIndex = data.length;
		
		if(obj.id=='selectMaxBed'){label="Max Beds"};
		
		$j(data).each(function(index){
			var cols = data[index].split('|');
			//$j(obj).addOption(cols[1],cols[0]);
			
			var optn = document.createElement("option");
			var value = cols[1]; //parseInt(cols[1])*searchBox.ExchangeRate;
			optn.text = cols[0].replace("@value",value).replace("@label",label);
			
			if(lastItemIndex==(index+1)&&obj.id=='selectMaxBed'){optn.text = optn.text + " > ";}
			
			optn.value = value;
			if (cols[1]!=undefined){
				if(obj.id=='selectMaxBed'){
					if(searchBox.SelectedMinBeds > value){skip=true;}else{skip=false;}
				}else{
					if(lastItemIndex==index){skip=true;}//skip the last highest item for max drop-down
				}
				if(optn.text=="Studio"&&obj.id!='selectMaxBed'){skip=false;}// if min bed label, do not skip
				if(!skip){
					$j(obj)[0].options.add(optn);
				}
			}
		});
	},
	FillPriceDropDown:function(data,obj){
		$j(obj).removeOption(/./);
		//alert(searchBox.ExchangeRate);
		var label = "Min Price";
		var skip = false;
		var lastItemIndex = data.length-1;
		
		if(obj.id=='selectMaxPrice'){label="Max Price"};
		
		$j(data).each(function(index){
			var cols = data[index].split('|');
			//$j(obj).addOption(cols[1],cols[0]);
			
			var optn = document.createElement("option");
			var value = parseInt(cols[1])*searchBox.ExchangeRate;
			if (cols.length==3) {
				optn.text = cols[2];
			}else{
				optn.text = cols[0].replace("@value",value).replace("@label",label);
				optn.text = optn.text.replace("1000k","1m").replace("2000k","2m");
			}
			
			if(lastItemIndex==index){optn.text = optn.text + " > ";}
			
			optn.value = value;
			if (cols[1]!=undefined){
				if(obj.id=='selectMaxPrice'){
					if(searchBox.SelectedMinPrice > value){skip=true;}else{skip=false;}
				}else{
					if(lastItemIndex==index){skip=true;}//skip the last highest item for max drop-down
				}
				// if label, do not skip
				if(parseInt(cols[1])<0){ skip=false; }
				
				if(!skip){
					$j(obj)[0].options.add(optn);
				}
			}
		});
	},
	FillDropDown:function(data,obj){
		$j(obj).removeOption(/./);
		
		$j(data).each(function(index){
			var cols = data[index].split('|');
			//$j(obj).addOption(cols[1],cols[0]);
			
			var optn = document.createElement("option");
			optn.text = cols[0];
			optn.value = cols[1];
			if (cols[1]!=undefined){
				$j(obj)[0].options.add(optn);}
		});
	},
	AutoCompleteTextBox:null,
	AutoCompleteTypeBox:null,
	SubmitButton:null,
	MessageBox:null,
	
	CountryDropDown:null,
	RegionDropDown:null,
	Location1DropDown:null,
	Location2DropDown:null,
	Location3DropDown:null,
	AutoCompleteTextBox:null,
	SubmitButton:null,
	CurrencyDropDown:null,
	MinPriceDropDown:null,
	MaxPriceDropDown:null,
	PriceUnitValue:0,
	KeywordsTextBox:null,
	MinBedDropDown:null,
	MaxBedDropDown:null,
	PropertyNameTextBox:null,
	ReferenceTextBox:null,
	MessageBox:null,
	ExchangeRate:1,
	CurrencyCode:"GBP",
	SelectedDropdown:"",
	SelectedMinBeds:0,
	SelectedMaxBeds:0,
	SelectedMinPrice:0,
	SelectedMinPriceIndex:0,
	SelectedMaxPrice:0,
	SelectedMaxPriceIndex:0,
	SelectedCurrencyCode:"",
	SelectedLocationID:0,
	
	SelectedLocationURL:'',
	SelectedTypeID:0,
	SelectedTypeURL:'',
	SelectedCountryLocationID:function(){
		return this.SelectedCountryLocationIDByName(siteRootLocation);
	},
	SelectedCountryLocationIDByName:function(name){
		var i = null;
		var countries = this.getCountries();
		$j(countries).each(function(index){
			var cols = countries[index].split('|');
			//$j(obj).addOption(cols[1],cols[0]);
			if(cols[0]==name)
			{
				i = cols[1];
				index = 1000;
			}
		});
		return i;
	},
	CacheRegions:true,
	UseFreshCountryData:false,
	AutoPriceIndexSelect:true,
	AutoBedroomIndexSelect:true,
	isLondonLocation:false,
	SubmitURL:"property/search",
	SubmitMethod:"POST",
	SelectCountryByID:function(id){
		Utils.DropDownSelect(searchBox.CountryDropDown,id);
	},
	SelectRegionByID:function(id){
		Utils.DropDownSelect(searchBox.RegionDropDown,id);
	},
	SelectCurrencyByCode:function(CurrencyCode){	
		Utils.DropDownSelect(searchBox.CurrencyDropDown,CurrencyCode);
	},
	SelectMinPriceByValue:function(value){
		Utils.DropDownSelect(searchBox.MinPriceDropDown,value);
	},
	SelectMaxPriceByValue:function(value){
		Utils.DropDownSelect(searchBox.MaxPriceDropDown,value);
	},
	SelectMinBedByValue:function(value){
		Utils.DropDownSelect(searchBox.MinBedDropDown,value);
	},
	SelectMaxBedByValue:function(value){
		Utils.DropDownSelect(searchBox.MaxBedDropDown,value);
	},
	IsCurrencyExist:function(CurrencyCode){
		var exist = false;
		$j("option",searchBox.CurrencyDropDown).each(function(index){
			if(searchBox.CurrencyDropDown.options[index].value==CurrencyCode && exist==false)
				exist = true;
		});
		return exist;
	},
	AddCurrency:function(CurrencyCode){
		if(!this.IsCurrencyExist(CurrencyCode)){
			//alert('addnow'+CurrencyCode);
			if(CurrencyCode!=0){
				Utils.AddOptionToDropDown(CurrencyCode,CurrencyCode,searchBox.CurrencyDropDown);
			}
		}
	},
	RemoveCurrency:function(CurrencyCode){
		if(!this.IsCurrencyExist(CurrencyCode)){
			//alert('remove now');
			alert($j("option[value='"+CurrencyCode+"']",this.CurrencyDropDown).text());
		}
	},
	FillMinPriceDropDown:function(){
		this.FillPriceDropDown(this.getPriceRanges(),this.MinPriceDropDown);
	},
	FillMaxPriceDropDown:function(){
		this.FillPriceDropDown(this.getPriceRanges(),this.MaxPriceDropDown);
	},
	FillMinBedsDropDown:function(){
		this.FillBedDropDown(this.getBedRanges(),this.MinBedDropDown);
	},
	FillMaxBedsDropDown:function(){
		this.FillBedDropDown(this.getBedRanges(),this.MaxBedDropDown);
	},
	FillPriceDropDowns:function(){
		this.FillMinPriceDropDown();
		this.FillMaxPriceDropDown();
	},
	FillBedDropDowns:function(){
		this.FillBedDropDown(this.getBedRanges(),this.MinBedDropDown);
		this.FillBedDropDown(this.getBedRanges(),this.MaxBedDropDown);
	},
	UpdateSubmitButton:function(){
		var msg = "";
		
		if(msg!=""){
			msg = "Please select " + msg;
			$j(this.SubmitButton).hide();
			$j(this.MessageBox).text(msg);
		}else{
			$j(this.MessageBox).hide();
			$j(this.SubmitButton).show();
		}
	},
	remoteURL:"/tmc.system/tmc.services.locations.asp?IncludePromoted="+showPromotedLocation+"&IsDeep="+deepPromotedIncluded+"&GetLMSChildLocations=",
	remoteCountryDataURL:"/tmc.system/tmc.services.locations.asp?Country=ActiveLMS",
	EnableMinControls:function(){
		this.AutoCompleteTextBox.disabled = false;
		this.AutoCompleteTypeBox.disabled = false;
		this.UpdateSubmitButton();
	},
	getCountries:function(){
		if (this.UseFreshCountryData){
			var dummy = 'Please Select Country|0';
			$j.ajax({
				type: "GET",
				url:this.remoteCountryDataURL,
				async:false,
				beforeSend: function(xhr) {
				},
				success:function(s){
					// var ukLocations = 'England|35283\nScotland|50505\nWales|50535\nNorthern Ireland|50558\n';
					// s = ukLocations + s;
					var ary = s.split('\n').join(':');
					dummy = dummy + ':' + ary;
					//alert(dummy);
				}
			});
			
			return dummy.split(":");
		}else{
			return countries;
		}
	},
	getCurrencies:function(){return defaultCurrencies;},
	getPriceRanges:function(){return ("@label|-1:@value|0:@valuek|25:@valuek|50:@valuek|75:@valuek|100:@valuek|150:@valuek|200:@valuek|300:@valuek|500:@valuek|1000").split(":");},
	getBedRanges:function(){return ("@label|@label:Studio|0:1|1:2|2:3|3:4|4:5|5:6|6:7|7:8|8:9|9:10|10").split(":");}
}

function Init(){
	searchBox.Init();
}

function formatItem(row) {
    //var row = row.split("|");
    //return row[0] + " (id: " + row[1] + ")";
    return row[1].replace(/[/]/gi," &#187 ").replace(/[_]/gi," ");
}

function formatResult(row) {
	return row[0];
}

function isInteger(s) {
  return (s.toString().search(/^-?[0-9]+$/) == 0);
}
