//version date: 03/05/07
//copyright c.2006 EjReagh
var Lastbutton=0;       // last visited button number
var Thisbutton = 0;     // this button number
// --- data set ----------------------
var ImageFile = 'goodform.gifs/goodform.samplegifs',
 ButtonFile= 'goodform.gifs/buttongifs.etc',
 SelectGif = 'gfbluedot.gif',
 VisitedGif= 'gforangedot.gif',
 VisibleColor  = "#fe7013",
 InvisibleColor= "white",
 LaunchMsg="Launch website",
 LaunchTarget = '_self',
 LaunchUrl = '';
 DisableColor='grey';
// mainline stuff; set bluedot objects' onclick function
for (i=1;i <= 20; i++)
{ if ( ! (obj = document.getElementById('gfbluedot'+i) ) ) break;
  if (iname[i] ) obj.onclick = function(){SetImg(this)}  ;
}
// set subimage selection objects' onclick function
for (i=1;i <= 3; i++)
{ document.getElementById('imgsub'+i).onclick=function(){SetSubImg(this)};
}
//set next / previous arrows onclick function
document.getElementById('imgnext').onclick=function(){ArrowImg(this)};
var Bwidth=document.getElementById('imgprev').style.width;
document.getElementById('imgprev').onclick=function(){ArrowImg(this)};

// functions
function SetImg(obj)
{ Thisbutton = obj.name.substring(9);
  if (Thisbutton >= iname.length ) return;
  if (Lastbutton)
    document.getElementById("gfbluedot"+Lastbutton).src=
       ButtonFile+"/"+SelectGif;     // set last visited back to blue
  Lastbutton = Thisbutton;
  obj.src = ButtonFile+"/"+VisitedGif;// set visited to orange
  if(Thisbutton==1)              b=0; else b=Bwidth;
  document.getElementById('imgprev').style.width=b;
  if(Thisbutton==iname.length-1) b=0; else b=Bwidth; 
  document.getElementById('imgnext').style.width=b; 
  
  DoImgUrl(iname[Thisbutton][0]);
 
  var image_multiples = iname[Thisbutton].length ; // how many of the litte buggers are there?
  if (image_multiples == 1) image_multiples = 0;
  for (i=1;i <= 3; i++)
  {  nextobj = document.getElementById("imgsub"+i)
     if ( i > image_multiples )
		nextobj.style.color=InvisibleColor; //invisible
	 else
		nextobj.style.color=VisibleColor; // visible
  }
  return;
}

function DoImgUrl(imgurl)
{ var imgs = imgurl.split(';') ;         // split: imagename;url
  document.getElementById('gfplaceholder').src=ImageFile+'/'+imgs[0];
  obj = document.getElementById('gflaunch');
  obj.value = ''; obj.style.width = 0;
  if ( (LaunchUrl=imgs[1]) ) 
  { obj.value = LaunchMsg; obj.style.width = 120; obj.style.color=VisibleColor;
  } 
}

function SetSubImg(obj)
{ var nindex = obj.name.substring(6);
  DoImgUrl( iname[Thisbutton][nindex-1] );
}

function ArrowImg(obj)
{ var arrowid = obj.name;
  if(Thisbutton==1 && arrowid=='imgprev')return;
  if(Thisbutton==iname.length-1 && arrowid=='imgnext')return;
  if(arrowid=='imgprev') Thisbutton--;else Thisbutton++; 
  SetImg(document.getElementById('gfbluedot'+Thisbutton));
}

function Launch(obj)
{ window.open(LaunchUrl,'',LaunchTarget);
}
// end