function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

var $j = jQuery.noConflict();

$j(document).ready(function(){
    //$j("#selectionresult").hide();

    $j("#selection").change(RetrieveAreas);
	
	
	function RetrieveAreas()
	{	var theform = $j(this).parents("form").attr("name");
		if(theform == "search-home")
		{	$j(this).parents("form").attr("action", "/search-properties/houses-for-sale-in-"+$j(this).val());
		}
		
        $j("#selectionresult").hide();
        $j("#result").html('Retrieving ...');
        $j.ajax({
            type: "POST",
            data: "data=" + $j(this).val(),
            url: "/search-properties/counties-areas.php",
            success: function(msg){
                if (msg != ''){
                    $j("#selectionresult").html(msg).show();
                    $j("#result").html('');
                }
                else{
                    $j("#result").html('<em>No item result</em>');
                }
            }
        });
    }
	
	$j("#sort").change(reSort);
	

	function reSort()
	{	if($j(this).val() != "")
		{	window.location.replace($j(this).val());
		}
    }
	
	
});



