/**
 * Bookmarks a page.
 * @param title The title of the page.
 * @param url The URL of the page.
 */
function bookmark(title, url) {
    try {

        // Gecko or compatible
        if (window.sidebar) {
           window.sidebar.addPanel(title, url, "");
           return;
        }

        // Opera or compatible
        if (window.opera && window.print) {
           var anchor = document.createElement('a');
           anchor.setAttribute('href', url);
           anchor.setAttribute('title', title);
           anchor.setAttribute('rel', 'sidebar');
           anchor.click();
           return;
        }

        // Internet Explorer 4 or compatible
        if (document.all && (parseInt(navigator.appVersion, 10) >= 4)) {
           window.external.AddFavorite(url, title);
           return;
        }

    } catch (e) {
       // fall through
    }

    alert("To bookmark the current page press Ctrl-D" +
        "\n(Internet Explorer, Firefox, Safari and Chrome)" +
        "\nor Ctrl-T (Opera)");
}

/**
 * Sets the target and title attributes for anchor and area elements.
 */
function anchorRels() {
    $("a[rel='group']").each(function(i){
        if (!this.target) {
            this.target = "_blank";
        }
        this.title = "the page will open in a new window";
    });
    $("a[rel='corporate']").each(function(i){
        if (!this.target) {
            this.target = "_blank";
        }
        this.title = "the page will open in a new window";
    });
    $("a[rel='customer']").each(function(i){
        if (!this.target) {
            this.target = "_blank";
        }
        this.title = "the page will open in a new window";
    });
    $("a[rel='external']").each(function(i){
        if (!this.target) {
            this.target = "_blank";
        }
        this.title = "the page will open in a new window";
        this.onclick = function() {trackPageview(this.href);};
    });
    $("a[rel='pdf']").each(function(i){
        if (!this.target) {
            this.target = "_blank";
        }
        this.title = "the PDF document will open in a new window";
        this.onclick = function() {trackPageview(this.href);};
    });
    $("a[rel='doc']").each(function(i){
        if (!this.target) {
            this.target = "_blank";
        }
        this.title = "the Word document will open in a new window";
        this.onclick = function() {trackPageview(this.href);};
    });
    $("a[rel='xls']").each(function(i){
        if (!this.target) {
            this.target = "_blank";
        }
        this.title = "the Excel spreadsheet will open in a new window";
        this.onclick = function() {trackPageview(this.href);};
    });
    $("a[rel='ppt']").each(function(i){
        if (!this.target) {
            this.target = "_blank";
        }
        this.title = "the Power Point presentation will open in a new window";
        this.onclick = function() {trackPageview(this.href);};
    });
    $("a[rel='wav']").each(function(i){
        if (!this.target) {
            this.target = "_blank";
        }
        this.title = "the audio clip will open in a new window";
        this.onclick = function() {trackPageview(this.href);};
    });
    $("a[rel='mp3']").each(function(i){
        if (!this.target) {
            this.target = "_blank";
        }
        this.title = "the MP3 audio clip will open in a new window";
        this.onclick = function() {trackPageview(this.href);};
    });
    $("area[class='rel_external']").each(function(i){
        if (!this.target) {
            this.target = "_blank";
        }
        this.title = "the page will open in a new window";
        this.onclick = function() {trackPageview(this.href);};
    });
}

/**
 * Executes anchorRels().
 */
$(document).ready(function () {
    anchorRels();
});

