function myga_save_build_and_price(make, model, trim, price, vehicle_id, set_options) {
    var url="/mygoauto/api/save_build_and_price/";
    url+="?make="+make;
    url+="&model="+model;
    url+="&trim="+trim;
    url+="&price="+price;
    url+="&vehicle_id="+vehicle_id;
    url+="&set_options="+set_options;
    //alert(url);
    $.ajax({
            type: "GET",
            url: url,
            processData: true,
            data: {},
            dataType: "json",
            success: function(data, txtStatus) {
                //$("#btnSavedItems").fadeOut().html(data.count+" Saved Vehicles").fadeIn();
                alert("Saved");
            },
            error: function(x,y,z) {
                //$("h1").html(url);
                    window.location="/mygoauto/login/?msg=ACTION_REQUIRES_LOGIN&next="+window.location.pathname;      
            }
        });
}


function myga_delete_build_and_price(pk) {
    if (confirm("Are you sure you want to delete this saved vehicle?")) {
        var url="/mygoauto/api/delete_build_and_price/?pk="+pk;
            $.getJSON(url, function(data){
                //alert("Deleted");
            });
            return true;
    }
    return false;
}


function myga_save_vehicle(v_id, d_id) {
    //alert("Saving...");
    var url="/mygoauto/api/save_inventory/?did="+d_id+"&vid="+v_id;
        $.ajax({
            type: "GET",
            url: url,
            processData: true,
            data: {},
            dataType: "json",
            success: function(data, txtStatus) {
                $("#btnSavedItems").fadeOut().html(data.count+" Saved Vehicles").fadeIn();                
            },
            error: function(x,y,z) {
                //alert(x+" / " + y + " / " + z);
                    window.location="/mygoauto/login/?msg=ACTION_REQUIRES_LOGIN&next="+window.location.pathname;      
            }
        });
        
        //$.getJSON(url, function(data, txtStatus){
        //    alert(txtStatus);
        //    $("#btnSavedItems").html(data.count+" Saved Vehicles");
        //    $("#btnSavedItems").hide();
        //    $("#btnSavedItems").fadeIn();
        //});
        return true;
}

function myga_delete_vehicle(v_id, d_id) {
    if (confirm("Are you sure you want to delete this saved vehicle?")) {
        var url="/mygoauto/api/delete_inventory/?did="+d_id+"&vid="+v_id;
            $.getJSON(url, function(data){
                $("#btnSavedItems").html(data.count+" Saved Vehicles");
                $("#btnSavedItems").hide();
                $("#btnSavedItems").fadeIn();
            });
            return true;
    }
    return false;
}

function myga_save_search(search_url) {
    //alert('saving: '+search_url)
    var url="/mygoauto/api/save_search/?searchparams="+search_url;
    //$.getJSON(url, function(data, txtStatus){
    //        //alert(txtStatus);
    //});
    $.ajax({
        type: "GET",
        url: url,
        processData: true,
        data: {},
        dataType: "json",
        success: function(data, txtStatus) {
            alert("Saved.");                
        },
        error: function(x,y,z) {
            window.location="/mygoauto/login/?msg=ACTION_REQUIRES_LOGIN&next="+window.location.pathname;      
        }
    });
        
    return false;
}

function myga_delete_search(search_pk) {
    //alert('deleting: '+search_pk)
    if (confirm("Are you sure you want to delete this saved search?")) {
        var url="/mygoauto/api/delete_search/?pk="+search_pk;
        $.getJSON(url, function(data, txtStatus){
                //alert(txtStatus);
        });
        return true;
    }
    return false;
}

