<!-- Image Selector
// Cameron Gregory - http://www.bloke.com/
// http://www.bloke.com/javascript/Random/
// This line and about must remain .. then you can use it for free...
//
// ChangeLog
//
// 
// Fri Apr 30 12:40:50 EDT 1999
//   Added target.
// Sat Sep 21 16:36:47 EDT 1996
//   Added associate URL list.
//
// Fri Sep 13 18:36:20 EDT 1996
//   Created from the base of Selector()
//
// Usage:
//  RandomImage(images)
//  RandomImageLong(images,iparams)
//  RandomImageLink(images,urls)
//  RandomImageLinkLongTarget(images,urls,iparams,hparams)
//     images		is space or comma separated file list
//     urls		is space or comma separated list of url's
//     iparams		params to add to <img>
//     hparams		params to add to <a href..>

function RandomImageLong(images,iparams)
{
/* 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;
      }
    }
  ind = Math.floor(Math.random() *cc);
  document.write("<img "+iparams+" src="+imageSet[ind]+" alt=\""+imageSet[ind]+"\">");
}

function RandomImage(images)
{
  RandomImageLong(images," ");
}

function RandomImageLinkLongTarget(images,urls,iparams,hparams)
{
/* si: start index 
** i: current index
** ei: end index
** cc: current count
*/
 imageSet = new Array();
 urlSet = new Array();
 si = 0; 
 ci=0;
 cc=0;
 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;
      }
    }
  ind = Math.floor(Math.random() *cc);
 si = 0; 
 ci=0;
 cc=0;
 ei = urls.length;
  for (i=1;i<ei && cc <=ind ;i++) {
    if (urls.charAt(i) == ' ' || urls.charAt(i) == ',') {
      urlSet[cc] = urls.substring(si,i);
      cc++;
      si=i+1;
      }
    }

  //document.write("<img "+iparams+" src="+imageSet[ind]+" alt=\""+imageSet[ind]+"\">");
  document.write("<a "+hparams+" href=\""+urlSet[ind]+"\"><img "+iparams+" src="+imageSet[ind]+" alt=\""+imageSet[ind]+"\"></a>");
}

function RandomImageLinkLong(images,urls,iparams)
{
  RandomImageLinkLongTarget(images,urls,iparams,"");
}

function RandomImageLink(images,urls)
{
  RandomImageLinkLongTarget(images,urls,"border=0","");
}

// End Script -->

<!-- Image Selector
// Cameron Gregory - http://www.bloke.com
// http://www.bloke.com/javascript/Selector/
//
// ChangeLog
//
// Wed Jul 10 11:29:51 EDT 1996
//    Added -1 check on array
// Wed Jul 10 06:25:30 EDT 1996
//    merged pulldown and selector into one.
//
// Wed Jul 10 06:03:05 EDT 1996
//    3.0b5a hosed something! Stopped using Image objects
//    and just stored in array.
//
// Usage:
//  Selector(width,height,images)
//  SelectorLong(width,height,boxHeight,images)
//  SelectorLongNames(width,height,boxHeight,images,names)
//  PullDownSelector(width,height,images)
//  PullDownSelectorNames(width,height,images,names)
//
//     width, height	is image size (-1,-1) if you don't want to specify
//     boxHeight	is the height of the select box
//     images		is space or comma separated file list
//     names		is corresponding name array (comma separated)



function selectImageN(n)
{
  document.flipForm.flip.src = imageSet[n];
  document.flipForm.which.selectedIndex = n ;
}

function selectNextImage()
{
   if (document.flipForm.which.selectedIndex < (imageSet.length-1) )
      selectImageN(document.flipForm.which.selectedIndex+1) ; // 
}


function selectPrivImage()
{
   if (document.flipForm.which.selectedIndex > 0 )
      selectImageN(document.flipForm.which.selectedIndex-1) ; // 
}


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 width=80% cols=9><tr height=360>") ;
// Кнопка пред
  document.writeln("<td align=center valign=center>") ;
//  document.writeln("<input name='Priv' type='Button' Value='<<' onClick='selectPrivImage()'> ") ;
  document.writeln("<image name='Priv' src=\"PICT/back.gif\" alt='Предыдущий снимок' onClick='selectPrivImage()'> ") ;
  document.writeln("</td>");

// Рисунок
  document.writeln("<td align=center colspan=7  class=\"sdw\">");
  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>");
// кнопка след.
  document.writeln("<td align=center valign=center>") ;
//  document.writeln("<input name='Next' type='Button' Value='>>' onClick='selectNextImage()'> ") ;
  document.writeln("<image name='Next' src=\"PICT/next.gif\" alt='Следующий снимок' onClick='selectNextImage()'> ") ;
  document.writeln("</td>");
  document.writeln("</tr>");

// Список наименований
  document.writeln("<tr><td align=left colspan=9>");
    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("</td>");

  document.writeln("</tr>");
  document.writeln("<tr>");
  ci=0 ;
  for (i=0; i<imageSet.length ; i++) {
      document.writeln("<td align=left width=20% class=\"sdw2\">") ;
      document.write("<image name='i" + i + "'") ;
      document.write(" src=" + imageSet[i] + " width=60 onClick='selectImageN(" + i + ")'") 
      document.write(" alt=\"Просмотр фотографии в увеличенном виде\"") ;
      document.writeln(">") ;
      document.writeln("</td>") ;
      ci++ ;
      if (ci == 8)  {
         document.writeln("</tr>");
         document.writeln("<tr>");
         ci = 0 ;
      	}
      }	
  document.writeln("</tr>");
  document.writeln("</table>");
  
  document.writeln("</FORM>");
 
}


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=5;
  SelectorLong(width,height,listHeight,images);
}

// End Script -->
