﻿function SearchFormSubmit()
{        

        var _defaultURL = '/property/all/';
        var _targetURL = '';
        var _locationURL = jQuery('#ddlLocationFilters').val();
        var _typeURL = jQuery('#ddlTypeFilters').val();
       

        if (_typeURL == null)
            _typeURL = ''
        if (_locationURL == null)
            _locationURL = ''


        /*alert('_typeURL = ' + _typeURL);
        alert('_locationURL = ' + _locationURL);
        return false;*/


        if (_typeURL != '' )
            _targetURL += '/' + _typeURL;
        if (_typeURL != '' )
            _targetURL += '/' + _locationURL;

        if (_targetURL != '')
            _targetURL = '/property' + _targetURL;

        _targetURL = _targetURL.replace(/\/\//g, "\/");
        _targetURL = _targetURL.replace(/\/\//g, "\/");
        _targetURL = _targetURL.replace(/\/\//g, "\/");
        _targetURL = _targetURL.replace(/ /g, "_").toLowerCase()

        jQuery('#SearchBoxForm').attr("action", _targetURL);
        //window.location = _targetURL;
        jQuery('#SearchBoxForm').submit();
        return false;
}

function SubmitToLocation(url) {
    //alert(url);
    //hide submit button because page is being posted
    jQuery("#btnSearchSubmit").hide();
   /* var _typeURL = jQuery('#ddlTypeFilters').val();

    if (_typeURL != '' && _typeURL != 'undefined')
        url = _typeURL + '/' + url;

    url = url.replace(/\/\//g, "\/");
    url = url.replace(/\/\//g, "\/");
    url = url.replace(/\/\//g, "\/");
    url = url.replace(/\/\//g, "\/");
    url = url.replace(/\/\//g, "\/");
    url = url.replace(/ /g, "_").toLowerCase()*/

    if (url != '' && url != '/') {
        url = '/property/' + url
        url = url.replace(/\/\//g, "\/");
        url = url.replace(/\/\//g, "\/");
        url = url.replace(/\/\//g, "\/");
        url = url.replace(/\/\//g, "\/");
        url = url.replace(/\/\//g, "\/");
        url = url.replace(/\/\//g, "\/");
    }
    else
        url = '/property/all/' 
    
    jQuery('#SearchBoxForm').attr("action", url);        
    jQuery('#SearchBoxForm').submit();
    
    return false;

}



function RemoveFromURL(url) {    
    
    strSubmitPath = strCurrPageRequestPath.replace("/" + url + "/", "/");    
    if (strSubmitPath == "/property/")
        strSubmitPath = "/property/all/";
    jQuery('#SearchBoxForm')[0].action = strSubmitPath;
    listingPage.SaveFormVariables();
    jQuery('#SearchBoxForm')[0].submit();
    return false;
}


function isInteger(s) {
  return (s.toString().search(/^-?[0-9]+$/) == 0);
}
