﻿/// <reference path="jquery-1.3.1-vsdoc.js" />

function docWrite(str) {
    // Useful if you need to write a swf file, that needs to work in IE.
    document.write(str);
}

function PopUp(url, features, name) {
    // Attempt to pop up a new window.  If blocked, redirect to that page.
    var newwin = window.open(url, name, features);
    if (!newwin) { document.location = url; }
}

function closePopUp() {
    try {
        var winopener = window.opener;
        if (winopener) {
            // Make sure popup blocker is not enabled, before attempting window.close();
            if (winopener.location != window.location) {
                window.close();
                return 
            }
        }
        if (history.length > 0) {
            // PopUp blocker detected, and history exists, try to just go back.
            // Note that history.length starts at 1 in Firefox, but in Firefox, 
            // the previous step has probably already closed this window.
            history.go(-1);
        } else {
            // PopUp blocker detected, but no history exists, try to close current window.
            var winself = window.open('', '_self', '');
            window.close();
        }
    } catch (e) {
    }
}

function mcmsOnEndRequest(sender, args) {
    // Display a pop-up message if there are any unhandled server-side errors processing an AJAX Request.
    var err = args.get_error();
    if (err != null) {
        args.set_errorHandled(true);
        var s = err.message;
        s = s.substr(s.indexOf(':') + 2, s.length);
        
        alert(s);
    }
}

