// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function previewContent(frm, actn) {
        prev_actn = frm.action;
        frm.target = "_blank";
        frm.action = actn;
        frm.submit();
        frm.target = "";

        // reset action once window has been opened
        frm.action = prev_actn;
}

function publishContent(frm, actn) {
        prev_actn = frm.action;
        frm.target = "_self";
        frm.action = actn;
        frm.submit();
        frm.target = "";

        // reset action once window has been opened
        frm.action = prev_actn;
}

function declineContent(statusId) {
    content = $("dp_comments");
    status = $(statusId);
    publish = $("publish_btn");
    decline = $("decline_btn");
    
    content.show();
    status.value = "Declined";
    publish.hide();
    decline.hide();
}

function toggleNewsLink(newsId) {
    content = $("news_content_" +newsId);
    close_link = $("close_link_" + newsId);

    content.toggle();
    close_link.toggle()
}

function toggleArchive(elementId) {
    content = $("element_" + elementId);
    content.toggle();
}

function externalLinks() {
        if (!document.getElementsByTagName) return;

        var anchors = document.getElementsByTagName("a");

        for (var i=0; i<anchors .length; i++) {
                var anchor = anchors[i];
                if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
                        anchor.target = "_blank";
                        anchor.title = (anchor.title != "") ? anchor.title+" (opens in a new window)" : "opens in a new window";
                        anchor.className = (anchor.className != '') ? anchor.className+' external' : 'external';
                }
        }
}

window.onload = externalLinks;


// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// -----------------------------------------------------------------------------