//<![CDATA[

// Global variables
var savethissearchmessage_offset;	
var foo1 = false;
var foo2 = false;
var c = 0;
var t;
var currentquicksearchid;

// Animation constants
var SHOWSVSRCFMAPPEARDURATION = 0.5;
var SHOWSVSRCFMHIGHLIGHTDURATION = 1.0;
var HIDESVSRCFMFADEDURATION = 0.5;
var SAVESEARCHFADEDURATION = 1.0;
var SAVESEARCHAPPEARDURATION = 1.0;
var SAVESEARCHHIGHLIGHTDURATION = 0.5;
var UNSUBSCRIBESAVEDSEARCHFADEDURATION = 1.0;
var UNSUBSCRIBESAVEDSEARCHHIGHLIGHTDURATION = 10.0;
var QUICKSEARCH_SHOWAPPEARDURATION = 0.5
var QUICKSEARCH_SHOWHIGHLIGHTDURATION = 1.0;
var QUICKSEARCH_SHOWFADEDURATION = 0.5;
var CLEARSEARCHFORMFADEDURATION = 0.3;
var PROPERTYTYPE_SHOWAPPEARDURATION = 0.3;
var PROPERTYTYPE_SHOWHIGHLIGHTDURATION = 1.0;
var SHOWMOREOPTIONSAPPEARDURATION = 0.5;
var HIDEMOREOPTIONSAPPEARDURATION = 0.5;

Event.observe( window, 'load', function() {	
	loadSearchForm(whichRegion);
	addClientOnLoad();
	if ($('geography_tabs')) { 
		var searchTabs = new Fabtabs('geography_tabs'); 
		setTimeout("setSearchValues('0',true)",1000);
	}	
} );
////////////////////////////////////////////////////////////////////////////////////////////////
// SHOW SEARCH FORM FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////////////////
//
// Checks parameters and loads correct search page or log in page
//
function onLoadFunctions() {
	// checks for save search option
	if ($('savethissearch')) {
		$('savethissearch').show();
		var coords = cumulativeOffset($('savethissearch'));
		savethissearchmessage_offset = coords[1];
		$('savethissearch').hide();
	} 
	else { 
		savethissearchmessage_offset = '';
	}
	
	// checks if user is logged in and is loading a saved search
	if ((loggedin) && ($('hidaction').value == 'newsavedsearch')) {
		showSaveSearchForm();
		$('hidaction').value = '';
		clearSearchForm();
	 
	
	// checks if user is logged in and is editing a saved search
	} else if ((loggedin) && ($('hidaction').value == 'editsavedsearch')) {
		showSaveSearchForm();	
		
	// checks if user is logged in and is loading current search
	} else if ((loggedin) && ($('hidaction').value == 'currentsavedsearch')) {
		showSaveSearchForm();
	//
	} else if (($('hidaction').value == 'unsubscribe') && ($('searchid').value != '')  && ($('userid').value != '')) {
		unsubscribeSavedSearch();	
	
	//
	} else if (($('hidaction').value == 'unsubscribe') && ($('searchid').value != ''))  {
		showLoginRegisterButtons('', '', 'unsubscribe');
		
	//	
	} else if ($('hidaction').value == 'editsavedsearch')  {
		showLoginRegisterButtons('', '', 'searchform');
		
	//	
	} else if ($('hidaction').value == 'currentsavedsearch')  {
		showLoginRegisterButtons('', '', 'searchform'); 
		
	// clears search form for a new search	
	} else if ($('hidaction').value == 'newsearch') {
		clearSearchForm();		
	}
	
}
//
// Loads the search form with the specified region
//
function loadSearchForm(whichRegion){
		// sets region to default region if length is not equal to 1
	if (whichRegion.length > 3) { whichRegion = default_mls_region }
		
	var search_form = $('search_form');		// loads value from search_form id on page
	var search_holder = $('search_holder');		// loads value from search_holder id on page
	var loading_div = $('loading_div');		// loads value from loading_div id on page		
	var whichPage = '/property-search/res/includes/search_forms/search_form_' + whichRegion + '.asp';		// sets whichPage string with selected region
	var whichJS = '/property-search/res/includes/search_forms/search_form_' + whichRegion + '.js';		// sets whichJS string with selected region
			
	// hides the search form and shows the loading div
	$(search_form).hide();
	$(loading_div).show();
		
	// clears innerHTML
	//local_javascript.innerHTML = '';
	var params = Form.serialize($('frmSearchHolder'));
	
	// creates post variable		
	var bindArgs = {
		asynchronous: false,
		method: 'post',
		parameters: params,
		onFailure: function(){
			search_form.innerHTML='<div style="margin-top: 20px; margin-bottom: 40px;  font-size: 12px; font-weight: bold;">An error occurred and we could not load the search form.  Please refresh this page to try again.</div>';
		},
		onSuccess: function(t){
			//load the contents of the selected search form into the search container
			search_form.innerHTML=t.responseText;
			
			// adds the regional javascript file if it is not already loaded
			newJS = document.createElement('script');
				newJS.type='text/javascript';
				newJS.src=whichJS;
				document.getElementsByTagName('head')[0].appendChild(newJS); 

			// clear the place holder search form in order to clear duplicate element ids.
			search_holder.innerHTML='';	
			foo2 = true;
			onLoadFunctions();
		}
	};	
	
	// loads search for for specified region from server
	new Ajax.Request(whichPage ,bindArgs);
	$(loading_div).hide();		
	$(search_form).show();
}
//
// Changes the search for to a different region
//
function changeSearchForm()	{
	var mlsregion = $('mlsregion');		// loads value from mlsregion id on page
	var whichRegion = $F('mlsregion')
	var search_form = $('search_form');		// loads value from search_form id on page
	var search_holder = $('search_holder');		// loads value from search_holder id on page
	var whichPage = '/property-search/res/includes/search_forms/search_form_' + whichRegion + '.asp';		// sets whichPage string with selected region
	var whichJS = '/property-search/res/includes/search_forms/search_form_' + whichRegion + '.js';		// sets whichJS string with selected region
	var local_javascript = $('local_javascript');		// loads value from local_javascript id on page
	
	//alert('whichRegion: ' + whichRegion);
	//alert('whichPage: ' + whichPage);
	//alert('whichJS: ' + whichJS);
	
	// sets region to default region if length is not equal to 1
	//if (whichRegion.length != 1)
	//	whichRegion = default_mls_region;
		
	var params = Form.serialize($('frmSearch'));
	
	// creates post variable		
	var bindArgs = {
		asynchronous: false,
		method: 'post',
		parameters: params,
		onFailure: function(){
			search_form.innerHTML='<div style="margin-top: 20px; margin-bottom: 40px;  font-size: 12px; font-weight: bold;">An error occurred and we could not load the search form.  Please refresh this page to try again.</div>';
		},
		onSuccess: function(t){
			//alert('success');
			//load the contents of the selected search form into the search container
			search_form.innerHTML=t.responseText;
						
			// adds the regional javascript file
			newJS = document.createElement('script');
			newJS.type='text/javascript';
			newJS.src=whichJS;
			document.getElementsByTagName('head')[0].appendChild(newJS);
		}
	};	
	
	// loads search for for specified region from server
	new Ajax.Request(whichPage ,bindArgs);
}
////////////////////////////////////////////////////////////////////////////////////////////////
// SAVE SEARCH FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////////////////
//
// Shows the form to save the current search
//
function showSaveSearchForm() {
	if (savethissearchmessage_offset.length == 0) {
		$('savethissearch').show();	
		var coords = cumulativeOffset($('savethissearch'));
		window.scrollTo(0, coords[1]-40);
		$('savethissearch').hide();
	} else {
		window.scrollTo(0, savethissearchmessage_offset-40);
	}	
	
	new Effect.Opacity($('savethissearchfields'));
	new Effect.Opacity($('savethissearchmessage'));	
	
	$('savethissearchfields').show();
	$('savethissearchmessage').hide();	
	
	new Effect.Opacity($('search_buttons'));
	new Effect.Opacity($('save_buttons_2'));
	
	new Effect.Opacity($('search_buttons_2'));
	new Effect.Opacity($('save_buttons_3'));	

	new Effect.BlindDown($('savethissearch'), {queue: 'end', duration: SHOWSVSRCFMAPPEARDURATION});
	new Effect.Highlight($('savethissearch'), {queue: 'end', duration: SHOWSVSRCFMHIGHLIGHTDURATION, startcolor: highlight_startcolor, endcolor: highlight_endcolor});

	$('search_buttons').hide();
	$('save_buttons_2').show();
	
	$('search_buttons_2').hide();
	$('save_buttons_3').show();	
}
//
// Hides the save search for once it has been saved or cancelled
//
function hideSaveSearchForm() {
	
	new Effect.Opacity($('search_buttons'));
	new Effect.Opacity($('save_buttons_2'));
	new Effect.Opacity($('search_buttons_2'));
	new Effect.Opacity($('save_buttons_3'));
	
	new Effect.BlindUp($('savethissearch'), {duration: HIDESVSRCFMFADEDURATION});
	
	$('save_buttons_2').hide();
	$('search_buttons').show();
	$('save_buttons_3').hide();	
	$('search_buttons_2').show();	
	
	new Effect.Opacity($('savethissearchfields'));
	new Effect.Opacity($('savethissearchmessage'));
	
	$('savethissearchfields').show();
	$('savethissearchmessage').hide();
	
	$('savethissearchmessage').innerHTML = '';	
	$('hidaction').value = '';	
}
//
// Clears the saved search form
//
function clearSavedSearchForm() {
	if ($('searchname')) 
		$('searchname').value = '';
	document.frmSearch.sendemail[0].checked=true;
	document.frmSearch.enddate[0].selected=true;
	$('hidaction').value = '';
}
//
// Calls the saved_search_process.asp page to save a new search or edit an existing search
//
function saveSearch() {
	
	var returnVal;
	returnVal = -2;
	
	var params = Form.serialize('frmSearch');

	var bindArgs = {
	asynchronous: false,
	method: 'post',
	parameters: params,
	onFailure: function(t){
		returnVal = t.responseText; 
		alert('An error occurred and the search could not be saved. Please try again. \n\n' + returnVal);
		$('savesearch1').value = 'Save Search';
		$('savesearch1').style.width = '120px';	
		$('savesearch2').value = 'Save Search';
		$('savesearch2').style.width = '120px';				
	},
	onSuccess: function(t){
		returnVal = parseFloat(t.responseText); 
		
		if (returnVal >= 1) {
			
			$('searchid').value = returnVal;
			$('hidaction').value = '';
			if (savethissearchmessage_offset.length == 0) {
				$('savethissearch').show();	
				var coords = cumulativeOffset($('savethissearch'));
				window.scrollTo(0, coords[1]-40);
				$('savethissearch').hide();
			} 
			else 
				window.scrollTo(0, savethissearchmessage_offset-40);
				
			// display the message that the search was saved successfully, then fade it out.
			$('savethissearchmessage').innerHTML = '<strong>Success!</strong> The search was saved successfully.<br /><br />To run this search now, <a href="javascript: full_search_from_form(\'2\');">click here</a>.&nbsp;&nbsp;To go to your Property Tracker, <a href="javascript: full_search_from_form(\'5\');">click here.</a>';			
			new Effect.BlindUp($('savethissearchfields'), {queue: 'end', duration: SAVESEARCHFADEDURATION});
			new Effect.BlindDown($('savethissearchmessage'), {queue: 'end', duration: SAVESEARCHAPPEARDURATION});
			new Effect.Highlight($('savethissearchmessage'), {queue: 'end', duration: SAVESEARCHHIGHLIGHTDURATION, startcolor: highlight_startcolor, endcolor: highlight_endcolor});
			//new Effect.Opacity($('search_buttons'));
			//new Effect.Opacity($('save_buttons_2'));
			
			//new Effect.Opacity($('search_buttons_2'));
			//new Effect.Opacity($('save_buttons_3'));			
			$('savesearch1').value = 'Save Search';
			$('savesearch1').style.width = '120px';	
			$('savesearch2').value = 'Save Search';
			$('savesearch2').style.width = '120px';	
			$('savesearch3').value = 'Save Search';
			$('savesearch3').style.width = '120px';				
			$('save_buttons_2').hide();
			$('search_buttons').show();
			
			$('save_buttons_3').hide();
			$('search_buttons_2').show();
			
			$('runSavedSearches').innerHTML += '<ul class="sidebar" style="margin-top: 0px;"><li class="sidebar"><a href="javascript: run_saved_search(\'' + returnVal + '\', \'2\');" style="text-decoration: underline;">' + $('searchname').value + '</a></li></ul>';
			sidebarUpdateSavedSearchesText(numSearches + 1);
			
			new Effect.BlindUp($('savethissearch'), {duration: SAVESEARCHFADEDURATION});
				
		} 
		else {
			alert('An error occurred and the search could not be saved. Please try again.');
			$('savesearch1').value = 'Save Search';
			$('savesearch1').style.width = '120px';	
			$('savesearch2').value = 'Save Search';
			$('savesearch2').style.width = '120px';
			$('savesearch3').value = 'Save Search';
			$('savesearch3').style.width = '120px';				
		}
	}
	};
	
	if ($('searchname').value.length > 0) {
		
		if ((document.frmSearch.sendemail[0].checked) && (document.frmSearch.enddate[document.frmSearch.enddate.selectedIndex].value == '')) {
			alert('Please select an end date for the new listings alerts.');
			document.frmSearch.enddate.focus();
		} else {
			$('savesearch1').value = 'Please Wait...';
			$('savesearch1').style.width = '145px';	
			$('savesearch2').value = 'Please Wait...';
			$('savesearch2').style.width = '145px';	
			$('savesearch3').value = 'Please Wait...';
			$('savesearch3').style.width = '145px';				
			
			// run the XHR Save Request
			new Ajax.Request ('/property-search/sist_ajax/saved_search_process.asp', bindArgs);
		}
	} 
	else 
	{
		alert('Please enter a name for your search.');
		document.frmSearch.searchname.focus();
	}		
}
//
// UPDATED, COULD NOT TEST
//
function unsubscribeSavedSearch() {
	
	var returnVal;
	returnVal = -2;
	
	$('savethissearch').show();
	$('savethissearchfields').hide();
	$('savethissearchmessage').show();
	
	var searchParams = Form.serialize($('frmSearch'));
	
	//document.location.href = '/property-search/sist_ajax/saved_search_process.asp?' + searchParams;
	
	var bindArgs = {
	asynchronous: true,
	method: 'post',
	parameters: Form.serialize($('frmSearch')),
	onFailure: function(){
		alert('An error occurred and the search could not be unsubscribed. Please try again.');
	},
	onSuccess: function(t){
		returnVal = parseFloat(t.responseText);
		
		if ($('hidaction')) { $('hidaction').value = ''; }
		
		if (returnVal >= 1) {
			
			if (savethissearchmessage_offset.length == 0) {
				var coords = cumulativeOffset($('savethissearch'));
				window.scrollTo(0, coords[1]-40);
			} else {
				window.scrollTo(0, savethissearchmessage_offset-40);
			}
			
			// display the message that the search was saved successfully, then fade it out.
			$('savethissearchmessage').innerHTML = '<strong>Unsubscribe Successful!</strong> You will no longer receive email alerts for this search.<br /><br />To enable alerts for this search at any time, just go to your <a href="javascript: full_search_from_form(\'5\');">Property Tracker (click here)</a>.';
			new Effect.BlindDown($($('savethissearchmessage')), {queue: 'end', duration: UNSUBSCRIBESAVEDSEARCHFADEDURATION});			
			new Effect.Highlight($('savethissearchmessage'), {queue: 'end', duration: UNSUBSCRIBESAVEDSEARCHHIGHLIGHTDURATION, startcolor: highlight_startcolor, endcolor: highlight_endcolor});
			
			new Effect.Opacity($('search_buttons'));
			new Effect.Opacity($('save_buttons_2'));
			
			new Effect.Opacity($('search_buttons_2'));
			new Effect.Opacity($('save_buttons_3'));			
			
			$('savesearch1').value = 'Save Search';
			$('savesearch1').style.width = '120px';	
			$('savesearch2').value = 'Save Search';
			$('savesearch2').style.width = '120px';	
			$('savesearch3').value = 'Save Search';
			$('savesearch3').style.width = '120px';				
			
			$('save_buttons_2').hide();
			$('search_buttons').show();
			
			$('save_buttons_3').hide();
			$('search_buttons_2').show();			
			
			new Effect.BlindUp($('savethissearch'), {queue: 'end', duration: UNSUBSCRIBESAVEDSEARCHFADEDURATION});
		} 
		else {
			alert('An error occurred and the search could not be unsubscribed. Please try again.');
			new Effect.Opacity($('search_buttons'));
			new Effect.Opacity($('save_buttons_2'));
			
			new Effect.Opacity($('search_buttons_2'));
			new Effect.Opacity($('save_buttons_3'));			
			
			$('savesearch1').value = 'Save Search';
			$('savesearch1').style.width = '120px';	
			$('savesearch2').value = 'Save Search';
			$('savesearch2').style.width = '120px';
			$('savesearch3').value = 'Save Search';
			$('savesearch3').style.width = '120px';			
			
			$('save_buttons_2').hide();
			$('search_buttons').show();
			
			$('save_buttons_3').hide();
			$('search_buttons_2').show();			
			
			new Effect.BlindUp($('savethissearch'), {duration: UNSUBSCRIBESAVEDSEARCHFADEDURATION});
		  }
		}
	};

	new Ajax.Request('/property-search/sist_ajax/saved_search_process.asp', bindArgs);		
}
////////////////////////////////////////////////////////////////////////////////////////////////
// QUICK SEARCH FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////////////////
//
// Shows quick search form on search form
//
function quicksearch_show(quicksearchid){
	var quick_search_container = $('quick_search_container');
	
	if(quicksearchid!=currentquicksearchid){
		quick_search_container.innerHTML='<img src="/property-search/res/images/loading.gif" align="absmiddle"> Loading...';
		
		var params = 'quicksearchtype=' + quicksearchid;
		
		var bindArgs = {
		method: 'get',
		parameters: params,		
		onFailure: function(){
			alert('An error occurred and we could not retrieve the quick search form.  Please try again.');
		},
		onSuccess: function(t){
			quick_search_container.innerHTML=t.responseText;
			new Effect.BlindDown(quick_search_container, {queue: 'end', duration: QUICKSEARCH_SHOWAPPEARDURATION});
			new Effect.Highlight(quick_search_container, {queue: 'end', duration: QUICKSEARCH_SHOWHIGHLIGHTDURATION, startcolor: highlight_startcolor, endcolor: highlight_endcolor});
		}
		};
		
		new Ajax.Request('/property-search/sist_ajax/quick_search.asp', bindArgs);
		
		currentquicksearchid=quicksearchid;
	} 
	else {
		new Effect.BlindUp(quick_search_container, {duration: QUICKSEARCH_SHOWFADEDURATION});
		currentquicksearchid='';
	}	
}
//
// Validates quick search form and runs search
//
function quick_search(quicksearchid) {

	clearHiddenFieldsFromSearchForm();
	document.frmSearch.quicksearchid.value = quicksearchid;
	
	// checks mls value entered
	if (quicksearchid=='1') 
	{
		var mlsVal = false;
		
		for (counter = 1; counter <= 8; counter++)
			if ($('mls'+counter).value != '') 
				mlsVal = true;
		
		if (mlsVal == true) {
			$('quicksearchid').value=quicksearchid;
			full_search('2');
		} 
		else {
			alert('Please enter at least one MLS number.');
			return false;
		}
		
	// checks zip code value entered
	} 
	else if (quicksearchid=='2') {
		var zipVal = false;
		
		for (counter = 1; counter <= 8; counter++) {
			if ($('zip'+counter).value != '') {
				zipVal = true;
			}
		}
		
		if (zipVal == true) {
			$('quicksearchid').value=quicksearchid;
			full_search('2');
		} else {
			alert('Please enter at least one Zip code.');
			return false;
		}		
	
	
	// checks street value entered
	} 
	else if (quicksearchid=='3') {
		var streetVal = false;
		
		for (counter = 1; counter <= 3; counter++) {
			if (($('streetnumber'+counter).value != '') || ($('streetname'+counter).value != '')) {
				streetVal = true;
			}
		}
		
		if (streetVal == true) {
			$('quicksearchid').value=quicksearchid;
			full_search('2');
		} else {
			alert('Please enter at least one street number or street name.');
			return false;
		}		
	
	
	// checks agent name entered
	} 
	else if (quicksearchid=='4') {
		var agentVal = false;
		
		for (counter = 1; counter <= 3; counter++) {
			if ($('agentlastname'+counter).value != '') {
				agentVal = true;
			}
		}
		
		if (agentVal == true) {
			$('quicksearchid').value=quicksearchid;
			full_search('2');
		} else {
			alert('Please enter at least one agent name.');
			return false;
		}
	} else if (quicksearchid=='5') {
		var subdivisionVal = false;
		
		for (counter = 1; counter <= 3; counter++) {
			if ($('subdivision'+counter).value != '') {
				subdivisionVal = true;
			}
		}
		
		if (subdivisionVal == true) {
			$('quicksearchid').value=quicksearchid;
			full_search('2');
		} else {
			alert('Please enter at least one subdivision.');
			return false;
		}			
		
	} else if (quicksearchid=='6') {
		var projectVal = false;
		
		for (counter = 1; counter <= 3; counter++) {
			if ($('condoprojectname'+counter).value != '') {
				projectVal = true;
			}
		}
		
		if (projectVal == true) {
			$('quicksearchid').value=quicksearchid;
			full_search('2');
		} else {
			alert('Please enter at least one project name.');
			return false;
		}			
		
	} else if (quicksearchid=='7') {
		var keywordVal = false;
		
		for (counter = 1; counter <= 3; counter++) {
			if ($('keyword'+counter).value != '') {
				keywordVal = true;
			}
		}
		
		if (keywordVal == true) {
			$('quicksearchid').value=quicksearchid;
			full_search('2');
		} else {
			alert('Please enter at least one keyword.');
			return false;
		}			
		
	}	
}
////////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS TO MODIFY THE SEARCH FORM
////////////////////////////////////////////////////////////////////////////////////////////////
//
// Changes the Property Type on the main search form
//
function changePropertyType(){
	var listtypeid = '';

	for (counter = 0; counter < document.frmSearch.listtype.length; counter++) 
		if (document.frmSearch.listtype[counter].checked) {
			listtypeid = document.frmSearch.listtype[counter].value;
		}
	
	switch (listtypid){
		case '1':
			showResidentialOptions();
			showMoreOptions();
			break;
		case '4':
			showLotOptions();
		case '3':
		case '5':
			hideResidentialOptions();
			hideMoreOptions();			
			clearMoreOptions();	
			break;
		default:
			break;
		}
}
//
// Displays the residential options
//
function showResidentialOptions() {
		$('bedrooms').style.display='';
		$('bathrooms').style.display='';
		$('search_garage').style.display='';
		$('search_acreage').style.display='';
		$('search_square_feet').style.display='';
		$('search_year_built').style.display='';		
}
//
// Hides the residential options
//
function hideResidentialOptions() {
	$('bedrooms').style.display='none';
	$('bathrooms').style.display='none';
	$('search_garage').style.display='none';
	$('search_acreage').style.display='none';
	$('search_square_feet').style.display='none';		
	$('search_year_built').style.display='none';
}
//
// Displays the lot options
//
function showLotOptions() {
		$('search_acreage').style.display='';
}

//
// Show the advanced search options
//
function showMoreOptions(){		

	if ($('more_options').style.display == 'none') {
		new Effect.BlindDown($('more_options'), {duration: SHOWMOREOPTIONSAPPEARDURATION});
		$('search_buttons_2').show();	
	}
}

//
// Hide the advanced search options
//
function hideMoreOptions(){
	new Effect.BlindUp($('more_options'), {duration: HIDEMOREOPTIONSAPPEARDURATION});
	clearMoreOptions();
	
	$('save_buttons_3').hide();
	$('search_buttons_2').hide();
}

//
// When main property category changes, shows the prop types available for that category
//
function propertytype_show(listtype){
	
	if (listtype != '') {
		var property_type_container = $('property_type_container');
		property_type_container.innerHTML='<img src="/property-search/res/images/loading.gif" align="absmiddle"> Loading...';
	}
	
	var params = Form.serialize($('frmSearch'));
	
	var bindArgs = {
		asynchronous: false,
		method: 'post',
		parameters: params,
		onFailure: function(){
			alert('An error occurred and we could not retrieve the property types.  Please try again.');
		},
		onSuccess: function(t){		
			property_type_container.innerHTML=t.responseText;
			new Effect.BlindDown(property_type_container, {queue: 'end', duration: PROPERTYTYPE_SHOWAPPEARDURATION});
			new Effect.Highlight(property_type_container, {queue: 'end', duration: PROPERTYTYPE_SHOWHIGHLIGHTDURATION, startcolor: highlight_startcolor, endcolor: highlight_endcolor});
		}
	};
	
	new Ajax.Request('/property-search/sist_ajax/property_types.asp',bindArgs);
}
//
// Validate low price
//
function validateLPrice(){
		
	var lPrice = $('lprice');
	var uPrice = $('uprice');
	var minPrice = parseInt(lPrice.options[lPrice.selectedIndex].value);
	var maxPrice = parseInt(uPrice.options[uPrice.selectedIndex].value);
	var newSelected = false;
	var newMax = lPrice.options[lPrice.selectedIndex + 1].value;
	
	if(isNaN(maxPrice))
		maxPrice = 0;
		
	if(maxPrice > newMax)
		newMax = maxPrice;
	
	for (var i=1;i<lPrice.options.length; i++)
		if(parseInt(lPrice.options[i].value) <= newMax)
			lPrice.options[i].style.color='#000000';
		else
			break;

	for (var i=uPrice.options.length - 1;i>=0; i--) {
		if(parseInt(uPrice.options[i].value) < minPrice)
		{
			uPrice.options[i].style.color = '#CCCCCC';
			if(!newSelected && maxPrice < minPrice)
				if( (i + 2) < uPrice.options.length)
				{					
					if(uPrice.selectedIndex != 0)
						uPrice.options[i + 2].selected = true;
					newSelected = true;
				}
		}
		else
			uPrice.options[i].style.color='#000000';
	}

}
//
// Validate Upper price
//
function validateUPrice(){	

	var lPrice = $('lprice');
	var uPrice = $('uprice');
	var minPrice = parseInt(lPrice.options[lPrice.selectedIndex].value);
	var maxPrice = parseInt(uPrice.options[uPrice.selectedIndex].value);
	
	if(isNaN(minPrice))
		minPrice = 0;
	
	uPrice.options[uPrice.selectedIndex].style.color = '#000000';
	
	for (var i=lPrice.options.length - 1;i>=0; i--) {
		if(parseInt(lPrice.options[i].value) >= maxPrice)
		{
			lPrice.options[i].style.color='#CCCCCC';
			if( minPrice > maxPrice)
			{
				lPrice.options[i - 1].selected = true;	
				lPrice.options[i - 1].style.color = '#000000';
			}
		}	
		else if(parseInt(lPrice.options[i].value) >= minPrice)
			lPrice.options[i].style.color='#000000';
	}
}
//]]>
