//String.prototype.startsWith = function (t, i) { if (i == false) { return (t == this.substring(0, t.length)); } else { return (t.toLowerCase() == this.substring(0, t.length).toLowerCase()); } }
//String.prototype.endsWith = function (t, i) { if (i == false) { return (t == this.substring(this.length - t.length)); } else { return (t.toLowerCase() == this.substring(this.length - t.length).toLowerCase()); } }

//$.fn.outerHTML = function (s) { return (s) ? this.before(s).remove() : jQuery("<p>").append(this.eq(0).clone()).html(); }
//$.fn.tagName = function () { if (1 === this.length) { return this[0].tagName.toLowerCase(); } else { var tagNames = []; this.each(function (i, el) { tagNames[i] = el.tagName.toLowerCase(); }); return tagNames; } }


$(document).ready(function () {
    //    $('#navigation a').each(function (i, o) {
    //        $(this).html('<span class="hidden">' + $(this).text() + '</span>').css('display', 'inline-block');
    //    }).hover(function () {
    //        $(this).addClass('hover');
    //    }, function () {
    //        $(this).removeClass('hover');
    //    }).click(function () {
    //        $(this).addClass('selected');
    //    });


    var url = window.location.pathname;
    //alert(url);
    url = url.toLowerCase().replace('-', '').replace('%2d', '').replace('%2d', '').replace('-', '');
    //alert(url);

    if (url.indexOf('/morningideas') != -1) {
        $('#navigation li.header-nav-morning').addClass('selected');
    } else if (url.indexOf('/ourproducts') != -1) {
        $('#navigation li.header-nav-product').addClass('selected');
    } else if (url.indexOf('/recipeshowto') != -1) {
        $('#navigation li.header-nav-recipe').addClass('selected');
    } else if (url.indexOf('/aboutthomas') != -1) {
        $('#navigation li.header-nav-about').addClass('selected');
    }
});

function ClearText(txtField) {
    if (txtField.defaultValue == txtField.value) {
        txtField.value = "";
        txtField.style.color = "#000000";
        txtField.style.fontStyle = "normal";
        //txtField.style.width = "108px";
    }
}

function FillText(txtField) {
    if (txtField.value == "") {
        txtField.value = txtField.defaultValue;
        txtField.style.color = "#666666";
        txtField.style.fontStyle = "italic";
        txtField.style.fontSize = "11px";
    }
}

function HighlightSelectText(ddlstField) {
    ddlstField.style.color = "#000000";
    ddlstField.style.fontStyle = "normal";
}

function clickButton(e, buttonid) {
    var evt = e ? e : window.event;
    var bt = document.getElementById(buttonid);
    if (bt) {
        if (evt.keyCode == 13) {
            bt.click();
            return false;
        }
    }
}

function trace(s) {
    if (window.console) console.log(s);
}
function xalert(o) {
    var s = "";
    for (var p in o) {
        //if(p.indexOf("ancel") != -1)
        s += p + ':' + o[p] + "\n";
    }
    alert(s);
}



