function createGallery( totalImages, imageDirectory, myName ) { 

var x = (screen.width) ? ( screen.width - 640 ) / 2 : 0;
var y = (screen.height) ? ( screen.height - 500 ) / 2 : 0;
var settings = 'height=500,width=640,top=' + y + ',left=' + x + ',scrollbars=no,resizable=yes,status=no,menubar=no';

var myWin = window.open('','',settings);

myWin.document.writeln( "<html><head>");
myWin.document.writeln( "<scr" + "ipt language=\"JavaScript\" type=\"text/javascript\">" );

myWin.document.writeln( "var IMAGE_TOTAL = " + totalImages + ";" );
myWin.document.writeln( "var current_image = " + totalImages + ";" );
myWin.document.writeln( "var cache_image   = new Array(IMAGE_TOTAL + 1);" );
myWin.document.writeln( "var image_num     = new Array(IMAGE_TOTAL + 1);" );   

myWin.document.writeln( "function previousImage() {");
myWin.document.writeln( "if ( current_image < IMAGE_TOTAL ) current_image++;");
myWin.document.writeln( "else current_image = 1;");
myWin.document.writeln( "refreshImage();");
myWin.document.writeln( "return;");
myWin.document.writeln( "}");

myWin.document.writeln( "function nextImage() {");
myWin.document.writeln( "if ( current_image > 1 ) current_image--;");
myWin.document.writeln( "else current_image = IMAGE_TOTAL;");
myWin.document.writeln( "refreshImage();");
myWin.document.writeln( "return;");
myWin.document.writeln( "}");

myWin.document.writeln( "function refreshImage() {");
myWin.document.writeln( "document.myImage.src = \"" + imageDirectory + "/\" + current_image + \".jpg\";");
myWin.document.writeln( "document.myForm.image_state.value = \"\" + ( IMAGE_TOTAL - current_image + 1 ) + \" OF \" + IMAGE_TOTAL;");
myWin.document.writeln( "}" );

myWin.document.writeln( "</scr" + "ipt>" );
myWin.document.writeln( "<title>LucasArts Gallery</title>" );
myWin.document.writeln( "</head>" );

myWin.document.writeln( "<body text=\"white\" link=\"white\" vlink=\"white\" alink=\"white\" bgcolor=\"black\"  leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">" );

myWin.document.writeln( "<form name=\"myForm\">" );
myWin.document.writeln( "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"640\">" );
myWin.document.writeln( "<tr>" );
myWin.document.writeln( "<td colspan=\"3\" background=\"" + imageDirectory + "/" + totalImages + ".jpg\"><img name=\"myImage\" src=\"/images/clear.gif\" width=\"640\" height=\"480\"></td>" );
myWin.document.writeln( "</tr>" );

myWin.document.writeln( "<tr>" );
myWin.document.writeln( "<td><img src=\"/images/clear.gif\" width=\"100\" height=\"1\"></td>" );
myWin.document.writeln( "<td><img src=\"/images/clear.gif\" width=\"440\" height=\"1\"></td>" );
myWin.document.writeln( "<td><img src=\"/images/clear.gif\" width=\"100\" height=\"1\"></td>" );
myWin.document.writeln( "</tr>" );

myWin.document.writeln( "<tr>" );
myWin.document.writeln( "<td align=\"left\" nowrap=\"nowrap\" style=\"font-family:Verdana,Arial;color:white;font-size: 7pt\"><a href=\"javascript:previousImage()\" style=\"text-decoration: none;\"> < PREVIOUS</a></td>" );
myWin.document.writeln( "<td align=\"center\" style=\"font-family:Verdana,Arial;color:white;font-size: 7pt\"><font color=\"white\" face=\"Verdana,Arial\" size=\"1\">" + myName + "    <input size=\"8\" type=\"text\" name=\"image_state\" value=\"1 OF " + totalImages + "\" style=\"border: 0;background-color: black;font-family:Verdana,Arial;color:white;font-size: 7pt\"></td>" );
myWin.document.writeln( "<td align=\"right\"  nowrap=\"nowrap\" style=\"font-family:Verdana,Arial;color:white;font-size: 7pt\"><font color=\"white\" face=\"Verdana,Arial\" size=\"1\"><a href=\"javascript:nextImage()\"  style=\"text-decoration: none;\">NEXT > </a></td>" );
myWin.document.writeln( "</tr>" );
myWin.document.writeln( "</table>" );
myWin.document.writeln( "</form>" );

myWin.document.writeln( "</body>" );
myWin.document.writeln( "</HTML>" );

}

function showTrailer( myMovie, myName, w, h ) {
var wh = h + 16;
var x = (screen.width) ? ( screen.width - w ) / 2 : 0;
var y = (screen.height) ? ( screen.height - wh ) / 2 : 0;
var settings = 'height='+wh+',width='+w+',top=' + y + ',left=' + x + ',scrollbars=no,resizable=yes,status=no,menubar=no';

var myWin = window.open('','',settings);

myWin.document.writeln( "<html><head>");
myWin.document.writeln( "<title>" + myName + "</title>" );
myWin.document.writeln( "</head>" );
myWin.document.writeln( "<body text=\"white\" link=\"white\" vlink=\"white\" alink=\"white\" bgcolor=\"black\"  leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">" );

myWin.document.writeln( "<OBJECT CLASSID=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" WIDTH=\""+w+"\" HEIGHT=\""+wh+"\" CODEBASE=\"http://www.apple.com/qtactivex/qtplugin.cab\" border=\"0\" bgcolor=\"#000000\" target=\"myself\">" );
myWin.document.writeln( "<PARAM name=\"SRC\" VALUE=\"" + myMovie + "\">" );
myWin.document.writeln( "<PARAM name=\"AUTOPLAY\" VALUE=\"true\">" );
myWin.document.writeln( "<PARAM name=\"CONTROLLER\" VALUE=\"true\">" );
myWin.document.writeln( "<PARAM name=\"border\" VALUE=\"0\">" );
myWin.document.writeln( "<PARAM name=\"bgcolor\" VALUE=\"#000000\">" );
myWin.document.writeln( "<PARAM name=\"target\" VALUE=\"myself\">" );
myWin.document.writeln( "<embed src=\"" + myMovie + "\" width=\""+w+"\" height=\""+wh+"\" border=\"0\" bgcolor=\"#000000\" target=\"myself\" pluginspage=\"http://www.apple.com/quicktime/download/\">" );
myWin.document.writeln( "</OBJECT>" );

myWin.document.writeln( "</body>" );
myWin.document.writeln( "</HTML>" );
}

function docWritePop( html, w, h ) {

var x = (screen.width) ? ( screen.width - w ) / 2 : 0;
var y = (screen.height) ? ( screen.height - h ) / 2 : 0;

    popUp = window.open(html,"popUp","width="+w+",height="+h+",toolbar=no,resizable=no,scrollbars=no,location=no,directories=no,menubar=no,status=no,top="+y+",left="+x+"");

   popUp.document.write( html );

} 

