function bookmark()
{
    var title = document.title;
    var url = location.href;
    if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4))
    {
        window.external.AddFavorite(url,title);
    }
    else if (navigator.appName == "Netscape")
    {
        window.sidebar.addPanel(title,url,"");
    }
    else
    {
        alert("Press CTRL-D (Netscape) or CTRL-T (Opera) to bookmark");
    }
}

function emailPage()
{
    var emailString = "mailto:?subject=Check out the " + document.title +
        "&body=I thought you might be interested in the " + document.title +
        ". You can view it at, " + location.href;

    location.href = encodeURI(emailString);
}

var am_images = new Array();

function am_preloadImages()
{
    if (document.images)
    {
        var imagesCount = am_images.length;
        for (var i = 0; i < arguments.length; i++)
        {
            am_images[imagesCount] = new Image;
            am_images[imagesCount].src = arguments[i];
            imagesCount++;
        }
    }
}

function setPanelOffset()
{
    var dashboard = document.getElementById('mainNav');
    var doc       = window.screen;
    var panel     = document.getElementById('panel');
    var offset = parseInt((doc.availWidth-dashboard.offsetWidth)/2,10) - 10;
    panel.style.right = offset+'px';
    panel.style.visibility = 'visible';
}

function am_onload()
{
    // fix search bar position
    setPanelOffset();

    var pageId = document.getElementsByTagName('body')[0].id;
    if ('videos' == pageId || 'images' == pageId || 'files' == pageId || 'list' == pageId)
    {
        // preload long main nav hover images
        am_preloadImages('../images/head_menu/about_hover.gif', '../images/head_menu/advertise_hover.gif',
            '../images/head_menu/contact_hover.gif', '../images/head_menu/faq_hover.gif',
            '../images/head_menu/home_hover.gif', '../images/head_menu/howto_hover.gif',
            '../images/head_menu/premium_hover.gif', '../images/head_menu/purchase_hover.gif',
            '../images/head_menu/tos_hover.gif');
    }
    else
    {
        // preload short main nav hover images
        am_preloadImages('../images/short_main_nav/about_us_hover.gif',
            '../images/short_main_nav/advertise_hover.gif',
            '../images/short_main_nav/contact_us_hover.gif',
            '../images/short_main_nav/home_hover.gif',
            '../images/short_main_nav/howto_hover.gif',
            '../images/short_main_nav/login_hover.gif');
    }

    // preload second nav hover images
    am_preloadImages('../images/second_nav/videos_hover.gif',
        '../images/second_nav/images_hover.gif', '../images/second_nav/files_hover.gif',
        '../images/list_files_hover.gif', '../images/upload_hover.gif',
        '../images/register_hover.gif');
}

window.onload = function() {
    am_onload();
}

function am_highlight(element)
{
    element.focus();
    element.select();
}