function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		base11_s = newImage("pix/base11_s.gif");
		base12_s = newImage("pix/base12_s.gif");
		base13_s = newImage("pix/base13_s.gif");
		base14_s = newImage("pix/base14_s.gif");
		base17_s = newImage("pix/base17_s.gif");
		preloadFlag = true;
	}
}

function selectImage(f)
{
if (document.flipForm.which.selectedIndex >= 0)
  document.flipForm.flip.src = imageSet[document.flipForm.which.selectedIndex];
}

function SelectorLongNames(width,height,listHeight,images,names)
{
/* si: start index 
** i: current index
** ei: end index
** cc: current count
*/
 si = 0; 
 ci=0;
 cc=0;
 imageSet = new Array();
 ei = images.length;
  for (i=1;i<ei;i++) {
    if (images.charAt(i) == ' ' || images.charAt(i) == ',') {
      imageSet[cc] = images.substring(si,i);
      cc++;
      si=i+1;
      }
    }
  currentFlip = 0;
 si = 0; 
 ci=0;
 cc=0;
 nameSet = new Array();
 ei = names.length;
  for (i=1;i<ei;i++) {
    if (names.charAt(i) == ',') {
      nameSet[cc] = names.substring(si,i);
      cc++;
      si=i+1;
      }
    }
  currentFlip = 0;

  // should check nameSet.length == imageSet.length

  document.writeln("<FORM name=flipForm>");
  document.writeln("<table border=0><tr><td>");
  document.write("<img name='flip'");
  if (width >0)
    document.write("width="+width);
  if (height >0)
    document.write(" height=" +height);
  document.writeln(" src=" +imageSet[0]+ ">");
  document.writeln("</td><td>");

  document.write("<Select");
  if (listHeight > 0)
    document.write(" size="+listHeight);
  document.write(" name='which' onChange='selectImage(this.form)'>");

  for (i=0;i<imageSet.length;i++)
    if (i<nameSet.length)
      document.write("<OPTION value="+i+">"+nameSet[i]);
    else
      document.write("<OPTION value="+i+">"+imageSet[i]);

  document.writeln("</SELECT>");
  
  document.writeln("</FORM>");
 
 document.writeln("</td></tr></table>");
}


function SelectorLong(width,height,listHeight,images)
{
  SelectorLongNames(width,height,listHeight,images,",");
}

function PullDownSelector(width,height,images)
{
  SelectorLongNames(width,height,-1,images,",")
}

function PullDownSelectorNames(width,height,images,names)
{
  SelectorLongNames(width,height,-1,images,names)
}

// use -1 -1 if you don't know the width and height for the image
function Selector(width,height,images)
{
 listHeight=8;
  SelectorLong(width,height,listHeight,images);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

