﻿function handleKeyPress(e) {
    var key = e.keyCode || e.which;
    if (key == 13) {
        FindRecipe();
    }
}

function FindRecipe() {
    var recipe = document.getElementById("search_recipe");

    if ((recipe.value.length > 0) && (recipe.value.toString() != "Enter Keyword(s)")) {

        var url = "/food-center-recipe-search.aspx?tdmsearch=" + recipe.value.toString();
        setTimeout(function() {
            window.location = url;
        }, 0);
        return true;
    }
    else {
        var url = "/food-center-recipe-search.aspx";
        setTimeout(function() {
            window.location = url;
        }, 0);
        return true;

    }
}

function validateZIP(field) {
    var valid = "0123456789";

    if (field.length != 5) {
        document.getElementById("TireInputZIP").className = "Error";
        return false;
    }
    for (var i = 0; i < field.length; i++) {
        var temp = "" + field.substring(i, i + 1);
        if (valid.indexOf(temp) == "-1") {
            document.getElementById("TireInputZIP").className = "Error";
            return false;
        }
    }
    return true;
}


function FindTires() {
    var zip = document.getElementById("tire_search_zip");
    if (validateZIP(zip.value)) {
        window.location = "http://www.walmart.com/cservice/ca_storefinder_results.gsp?serviceName=TIRE_AND_LUBE&sfatt=TIRE_AND_LUBE&rx_dest=%2Fcatalog%2Fcatalog.gsp%3Fpath%3D0%253A91083%26dept%3D91083%26cat%3D91083&sfsearch_zip=" + zip.value;
    } else {
        var getZipSwitch = document.getElementById("TireInputZIP");
        getZipSwitch.style.display = "block";
    }
}

