﻿// Add Bookmark Link Script
/// <reference path="jQuery.intellisense.js" />

$(document).ready(function() {
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(setupBookmarkLink);
});

function setupBookmarkLink()
{
    // Only IE5+ and Firefox have JavaScript functions that create
    // a bookmark in the browser.
    
    // IE5+ bookmarks with window.external.AddFavorite(url, title).
    
    // Firefox bookmarks with window.sidebar.addPanel(title, url, "").
    // However, due to a quirk, it forces the bookmark to open in the sidebar
    // when clicked, unless the user manually edits the bookmark and unchecks
    // "Load this bookmark in the sidebar". Firefox has no way to add a bookmark
    // that does not automatically check this.
    
    // Opera can bookmark a page by using an anchor tag with rel="sidebar".
    
    if(window.opera)
    {
        $(".bookmarkLink")
            .attr("rel", "sidebar")
            .attr("href", location.href)
            .attr("title", document.title);
    }
    else
    {
        $(".bookmarkLink").click(function(event) {
            event.preventDefault();
            if(window.sidebar && window.sidebar.addPanel)
            {
                window.sidebar.addPanel(document.title, location.href, "");
            }
            else if(window.external)
            {
                window.external.AddFavorite(location.href, document.title);
            }
            else
            {
                alert("Your browser is unsupported. Please bookmark this page manually.");
            }
        });
    }
}
