﻿// Manages news story windows by id. Called from Silverlight.

var openWindows = [];

function openWindow(id, title, headline, content) {

    var openWindow = openWindows[id];

    if (openWindow != null && !openWindow.closed) {
        //alert("focusing window id=" + id);       
        openWindow.focus();
    }
    else {
        //alert("opening window id=" + id);
        var newWindow = window.open(null, id, "width=640,height=480,resizable=1,scrollbars=1,menubar=0,toolbar=0,status=0");
        newWindow.document.write("<HTML>")
        newWindow.document.write("<BODY>")
        newWindow.document.write("<TITLE>" + title + "</TITLE>")
        newWindow.document.write("<h3>" + headline + "</h3>")
        newWindow.document.write(content)
        newWindow.document.write("</BODY>")
        newWindow.document.write("</HTML>")
        openWindows[id] = newWindow;
    }
}

function closeWindows() {
    for (var id in openWindows) {
        var openWindow = openWindows[id];
        //alert("closing window id=" + id);        
        openWindow.close();
    }
    openWindows = [];
}
