var options = {
	beforeSubmit: showRequest,
	success: showResponse,
	url: '/immoSearch.php'
};

function showRequest(formData, jqForm, options) {
    
	var immosucheValue = $('input[@name=check]').fieldValue(); 
      
  if (immosucheValue == '') {
  	 
   if (immosucheValue == '') {
   	
    $('#ImmosucheForm label:eq(0)').css('color', '#990000');
    $('#immosuche').css('border', '1px solid #990000');
    $('#immosuche').css('background', '#DCB1B1');
    $("#hinweis").fadeOut('slow', function() {
      $(this).css("display", "none");
    $("#error").fadeIn('slow', function() {
      $(this).css("display", "block");
    });
    }); 
   }
   else {
   	$('#ImmosucheForm label:eq(0)').css('color', '#707070');
   	$('#immosuche').css('border', '1px solid #CCC');
   	$('#immosuche').css('background', '#fff');
   }
   
 
 
  return false; 
  } 
   
return true;

}

function showResponse(responseText, statusText) {
		
	$('#ImmosucheForm label:eq(0)').css('color', '#707070');
	$('#immosuche').css('border', '1px solid #CCC');
	$('#immosuche').css('background', '#fff');
	
	if (responseText != "fehler") {
		var anum=/(^\d+$)|(^\d+\.\d+$)/
		if (anum.test(responseText)) {
			window.document.location.href = '/immobilien/'+responseText;
		}
		else {
			window.open("http://www." + responseText);
		}
	}
	else {
		$("#hinweis").fadeOut('slow', function() {
	      $(this).css("display", "none");
	      
	      $("#error").fadeIn('slow', function() {
	      	$(this).css("display", "block");
	    	});
	    }); 
	}
}

function immoAbsenden() {
	$('#ImmosucheForm').ajaxSubmit(options);
}