function checkOptions(code)
{
    $.getJSON("http://www.basegear.biz/inv1/checkOptions.php?code=" + code + "&jsonp=?", function(data) 
    { 
        if (typeof(data) == 'object')
        {
            $.each(data, function(key,val)
                {
                    $("option[value='" + key + "']").remove();
                }
            );
            try {
                if ($("form[action*=order] select").get()[0].options.length == 1)
                {
                   $("input[alt='Add to Cart']").replaceWith("<b>Sorry, this item is currently out of stock.</b><br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;");
                }
            }
            catch(e)
            {
                if(typeof(data[code]) != 'undefined' && data[code] == 0)
                {
                   $("input[alt='Add to Cart']").replaceWith("<b>Sorry, this item is currently out of stock.</b><br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;");
                }
            }
        } 
    });
}    
