// Copyright 20 February 2000, Cavalry Outpost Publications.

// This multifunction program:
//      1.0 Positions and loads a remote "playWindow" which displays
//          the name of the John Philip Sousa Military March which is
//          being played.
//
// *********************************************************************
// **********     Program Name = MarchMid.js Ver 03.11.30     **********
// *********************************************************************

// 1.0 DEFINE SCREEN and PLAY WINDOW PARAMETERS
// 1.1 Define Screen Coordinates

var ScrollbarWidth = "22";
var playWinFrameWidth = "6";
var xMax = screen.availWidth;

// 1.2 Define Screen and playWinParameters

var playWin = "";
var playWinWidth = 450, playWinHeight = 100;
var xOffset = ((xMax - ScrollbarWidth) - (playWinWidth + 2*playWinFrameWidth))/2;
var playWinParameters = 'width='+playWinWidth+',height='+playWinHeight+',screenX='+xOffset+',left='+xOffset+',screenY=0,top=0';

// 2.0 IDENTIFY "NAME" and "VALUE" SELECTION
    function select_item(name, value) {
        this.name = name;
        this.value = value;
    }

// 3.0 DEFINE get_selection function
    function get_selection(select_object) {
        contents = new select_item();
        for(var i=0; i < select_object.options.length; i++)
            if(select_object.options[i].selected == true) {
                contents.name = select_object.options[i].text;
                contents.value = select_object.options[i].value;
            }
            return contents;
    }

// 4.0  OPEN REMOTE PLAY WINDOW AND WRITE HTML PLAY SOUND SYNTAX
    function open_playWin(formfield) {
        selection = get_selection(formfield.march_tune);
        
        playWin = window.open('','Sousa_Military_March_Library', playWinParameters);
        
        playWin.document.open();
        playWin.document.write('<HTML>');
        playWin.document.write('<HEAD><TITLE>Sousa Military March Library</TITLE></HEAD>');
        playWin.document.write('<BODY BACKGROUND="bar_bkgd.gif" BGCOLOR="EEEDDD" TEXT="000000" onBlur="self.focus()">');
        playWin.document.write('<CENTER><STRONG>' + selection.name); 

// 4.1 Load Audio File (specify file name, two places), set Parameters and Play
        playWin.document.write('<NOEMDED><BGSOUND SRC="band_mid/' + selection.value + '" PLAYCOUNT="5"><\/NOEMDED>');
        if(navigator.appName != "Microsoft Internet Explorer") {
                playWin.document.write('<EMBED SRC="band_mid/' + selection.value + '" LOOP="5" AUTOSTART="TRUE" HIDDEN="TRUE"><\/EMBED>'); 
        }

// 4.2 Write Push Button FORM and complete HTML syntax
        playWin.document.write('<FORM><FONT COLOR="FF0000">');
        playWin.document.write('Close window prior <INPUT TYPE="button" VALUE="Close" onClick="window.close()"> to next selection.');
        playWin.document.write('</FONT></FORM>');
        playWin.document.write('</STRONG></CENTER></BODY></HTML>');
        playWin.document.close();
}

// 5.0 LOAD PLAY WINDOW (enable this function to auto load with host page)
// openplayWin();

// 6.0 CLOSE PLAY WINDOW
function closePlayWin() {
        var sLocType
        if (playWin) {
                if (!playWin.closed) {
                        sLocType = typeof playWin.location;
                        if (sLocType == 'object') {
                                playWin.close();
                        }
                }
        }

}

