jQuery(document).ready(function(){
    // Search button
    $("#go").click(function(event){
        submitLocationSearch()
        event.preventDefault();
        return false;
    });
    
    // Search input box
    $("#store_locator").keypress(function(event){
        if (event.keyCode == 13) {
            submitLocationSearch();
            event.preventDefault();
            return false;
        }
    });
    
    // Image Gallery
    $(".image-gallery-form").keypress(function(event){
        if (event.keyCode == 13){
            document.forms[0].submit();
            event.preventDefault();
            return false;
        }
    })
    
    // Left hand menu
    if (window.location.pathname != "/" && window.location.pathname != "") {
        var path = window.location.toString();
        if (path.indexOf("?") != -1)
            path = path.substr(0, path.indexOf("?")-1);
        
        $("#left_hand_top_mid li a").each(function(){
            if (this.href.indexOf(path) != -1)
                $(this).addClass("selected");
        });
    }
});

function submitLocationSearch()
{
    window.location.href = "/locator/default.aspx?place="+$("#store_locator").val();
}


function trapEnter(e, enterFunction){

    if (!e) e = window.event;
    if (e.keyCode == 13){
         e.cancelBubble = true;
         if (e.returnValue) e.returnValue = false;
         if (e.stopPropagation) e.stopPropagation();
         if (enterFunction) eval(enterFunction);
         //alert("To submit, click the button");

         return false;
    } else {
         return true;
    }
}

