function checkForm() {
	if (document.search.keyword.value=="") return false;
	return true;
}	
function doClear(theText) { if (theText.value == theText.defaultValue) { theText.value = "" } }	
function doDefault(theText) { if (theText.value == "") { theText.value = theText.defaultValue } }
	
$(document).ready(function() {
	$('.idx_control_type').change(function() {
		type = $("option:selected", this).val();
		if(type =="-1") return false;
		form = $('#form').val();
		url_max_price = URL_SITE+'select/max-price/'+type+'/'+form;
		url_min_price = URL_SITE+'select/min-price/'+type+'/'+form;
		jQuery('#min-price').load(url_min_price);
		jQuery('#max-price').load(url_max_price);
	});
	
	$('.idx_type').change(function() {
		type = $(this+":checked").val();
		if(type =="-1") return false;
		form = $('#form').val();
		url_max_price = URL_SITE+'select/max-price/'+type+'/'+form;
		url_min_price = URL_SITE+'select/min-price/'+type+'/'+form;
		jQuery('#min-price').load(url_min_price);
		jQuery('#max-price').load(url_max_price);
	});
	
	$('.list-tabs').live('click', function() {
		 var code = $(this).attr('rel');
		 $.ajax({
	          type: 'GET',
	          url: URL_SITE+'tab-page/'+code,
	          success: function(data) {
			    $('.content-tab').html(data);
	          }
	      });
	});
 });

 function pagination(url){
	jQuery('.content-right').load(url);
 }
 
 function submit_select(value, type) {
	if(value == 0) return false;
	switch(type) {
		case 1: url = URL_SITE+'properties/foreclosure/'+value; break;
		case 2: url = URL_SITE+'properties/condos/'+value; break; 
	}
	window.location.href = url;
 }
 
$('.add-favorites').live('click', function(){
	var mslid = $(this).attr('rel');
	$.ajax({
		url: URL_SITE+'properties/add-favorites/'+mslid,
		type: 'GET', 
		dataType: 'text',
		success: function(data) {
			if(data == 'login')
				document.location = URL_SITE+'login';
			else
			alert(data);
	    }
	});
});

$('.remove-favorites').live('click', function(){
	var mslid = $(this).attr('rel');
	$.ajax({
		url: URL_SITE+'properties/remove-favorites/'+mslid,
		type: 'GET', 
		dataType: 'text',
		success: function(data) {
			alert(data);
	    }
	});
});

function property_order(order) {
	$.ajax({
    	url: URL_SITE+'list-properties/order/'+order,
    	type: 'GET', 
    	success: function(data){
    			$('#idx_result_property').html(data);    		
    	}
    });
}
