﻿// JScript File

$(function(){
    $(".dlrLocatorRdo").click(function(){
        var rdoVal = $(this).attr("value");
        if (rdoVal != "Zip") {
            $("#drpMilesVisible").css("display","none");
            }
        else {
            $("#drpMilesVisible").css("display","block");
            }
    });
});

$(function(){
    var oldHref = $("#hijaxText").attr("href");
    function addThickbox() {
        $(this).attr("href", "foo3.html?KeepThis=true&TB_iframe=true&height=400&width=600");
    };
    function removeThickbox() {
        $(this).attr("href", (oldHref));
    };
    $("#hijaxText").hoverIntent(addThickbox,removeThickbox);    
});

$(function() {
        $(".dealerLocatorGo").click(function() {
        
        var SearchType;
        var ErrMsg = "";
        var DealerLoc = $(this).parent("div.dealerLoc");
        var SearchValue = DealerLoc.children(".dlrLocatorTxt").val();
        var Distance = DealerLoc.children(".dlrLocatorMiles").val();
        var City = DealerLoc.children(".dlrLocatorCity").attr("checked");
        var State = DealerLoc.children(".dlrLocatorState").attr("checked");
        if ((City == true) && (ErrMsg =="")) {
            SearchType = "City";
            }
        else if ((State == true) && (ErrMsg =="")) {
            SearchType = "State";
            }            
        else {
            SearchType = "Zip";
            }

        $.ajax({
            type: "POST", //POST
            url:"http://localhost/ASPDotNetStoreFront71/showproduct.aspx/GetDealerString",
            data: "{'searchType':'"+SearchType+"', 'searchValue':'"+SearchValue+"', 'distance':'"+Distance+"'}",
            contentType: "application/json; charset=utf-8", //Set Content-Type
            dataType: "json", // Set return Data Type
            success: function(msg, status) {
                $("#divLoading").css('display','none');
                $("#resultsTest").html(msg);
            },
            error: function(msg,e){
                alert(msg);//Error Callback
                }
        });
        return false;
        
    });
});


                  
