﻿
$(document).ready(function() {
    //alert('ready');

    var ind;
    var inv;
    var loc;

    ind = $('#Industry').val();
    inv = $('#Investment').val();
    loc = $('#Location').val();

    if (ind == '')
    { ind = '0'; }
    if (inv == '')
    { inv = '0'; }
    if (loc == '')
    { loc = '0' }

    //if (ind != '0')
    //{ $('#IndustryDsc').val($('#Industry :selected').text()); }
    if (inv != '0')
    { $('#InvestmentDsc').html($('#Investment :selected').text()); }
    if (loc != '0')
    { $('#LocationDsc').html($('#Location :selected').text()); }


    $('#searchbutton').click(function() {
        //alert('document');

        ind = $('#Industry').val();
        inv = $('#Investment').val();
        loc = $('#Location').val();

        if (ind == '')
        { ind = '0'; }
        if (inv == '')
        { inv = '0'; }
        if (loc == '')
        { loc = '0' }

        if (ind != 0) {
        
            $.ajax({
                type: "GET",
                url: "/Search/NetworkSeoUrl/",
                dataType: "json",
                data: { industry: ind },
                success: function(result) {
                    
                    var strSearch_Save = "\"" + inv + "|" + loc + "\"";
                    $.cookie('ParamInvestmentStateCode', strSearch_Save, { path: '/' });
                    window.location.href = result + "?IndustryId=" + ind + "&InvestmentId=" + inv + "&LocationId=" + loc;
                    
                }
            });
            
        }
        else {
            window.location.href = '/Search/SearchResults/' + ind + '/' + inv + '/' + loc;
        }

    });

});
