﻿jQuery.fn.exists = function () { return jQuery(this).length > 0; }

function UrlEscape(str) {
    str = str.replace("%", "%25");
    str = str.replace(" ", "%20");
    str = str.replace("<", "%3C");
    str = str.replace(">", "%3E");
    str = str.replace("#", "%23");
    str = str.replace("{", "%7B");
    str = str.replace("}", "%7D");
    str = str.replace("|", "%7C");
    str = str.replace("\\", "%5C");
    str = str.replace("^", "%5E");
    str = str.replace("~", "%7E");
    str = str.replace("[", "%5B");
    str = str.replace("]", "%5D");
    str = str.replace("`", "%60");
    str = str.replace(";", "%3B");
    str = str.replace("/", "%2F");
    str = str.replace("?", "%3F");
    str = str.replace(":", "%3A");
    str = str.replace("@", "%40");
    str = str.replace("=", "%3D");
    str = str.replace("&", "%26");
    str = str.replace("$", "%24");
    return str;
}
if ($(".btn-email").exists()) {
    $(".btn-email").click(function () {
        var str = "mailto:";
        str += "?subject=";
        str += UrlEscape("From the Lane and Associates Family Dentistry Website");
        str += "&body=";
        str += UrlEscape("This might interest you: ");
        str += UrlEscape(window.document.title);
        str += UrlEscape(" | ");
        str += window.location;
        window.open(str);
    });
}
if ($(".btn-print").exists()) {
    $(".btn-print").click(function () {
        window.print();
    });
}
if ($(".btn").exists() && $(".btn-hover").exists()) {
    $(".btn").mouseover(function () {
        $(this).css("display", "none");
        $(this).next(".btn-hover").css("display", "inline");
    });
    $(".btn-hover").mouseout(function () {
        $(this).css("display", "none");
        $(this).prev(".btn").css("display", "inline");
    });
}
