// JavaScript Document

var myimgpath = "/Portals/0/"; // need to point to the images directory

var captions = new Array(); 
	captions[0] = "The modified templates are hybridized to the poly(T) surface in the HeliScope Flow Cell.";
	captions[1] = "The modified templates are hybridized to the poly(T) surface in the HeliScope Flow Cell.";
	captions[2] = "~25 A-C-G-T cycles (or &quot;quads&quot;) of tSMS are carried out to sequence the 3&rsquo; end of the template.";
	captions[3] = "Once the first 25-base read is obtained, the template is copied to the end, in a single step, using a polymerase and all four natural nucleotides.";
	captions[4] = "The template is melted off the surface, leaving behind the covalently bound reverse complement.";
	captions[5] = "A universal primer is hybridized to the universal priming site that was added during the sample preparation process.";
	captions[6] = "Another round of ~25 tSMS quads is carried out to sequence the 5&rsquo; end of the original template, i.e. the 3&rsquo; end of the reverse complement.";
	//captions[7] = "(OPTIONAL) If ultra-high accuracy of this second read is required, a round of melt and resequence can be carried out using the same universal primer as the one used in step 5.";
	//captions[8] = "(OPTIONAL) If ultra-high accuracy of this second read is required, a round of melt and resequence can be carried out using the same universal primer as the one used in step 5.";
	//captions[9] = "(OPTIONAL) If ultra-high accuracy of this second read is required, a round of melt and resequence can be carried out using the same universal primer as the one used in step 5.";

function images1()  // pre-load slide images
{
	this[0] = new Image(); this[0].src = myimgpath + 'Melting-Sequences_01.jpg';
	this[1] = new Image(); this[1].src = myimgpath + 'Melting-Sequences_02.jpg';
	this[2] = new Image(); this[2].src = myimgpath + 'Melting-Sequences_03.jpg';
	this[3] = new Image(); this[3].src = myimgpath + 'Melting-Sequences_04.jpg';
	this[4] = new Image(); this[4].src = myimgpath + 'Melting-Sequences_05.jpg';
	this[5] = new Image(); this[5].src = myimgpath + 'Melting-Sequences_06.jpg';
	this[6] = new Image(); this[6].src = myimgpath + 'Melting-Sequences_07.jpg';
	//this[7] = new Image(); this[7].src = myimgpath + 'Melting-Sequences_08.jpg';
	//this[8] = new Image(); this[8].src = myimgpath + 'Melting-Sequences_09.jpg';
	//this[9] = new Image(); this[9].src = myimgpath + 'Melting-Sequences_10.jpg';
}
var pictures = new images1();
var nslides = 7;  // number of images
var icntr = nslides;  // (counter)
var tID = null;
var random_images = false;

function rotate()
{
	toggle_playpause("pause")
	if (random_images)  icntr = Math.round(Math.random() * nslides);
	else if (icntr < nslides) ++icntr;
	if (icntr == nslides) icntr=0;
	
	showslide(icntr);
	
	if (icntr == nslides-1) {
		toggle_playpause("play")
		tID=setTimeout("rotate()", 15000); // pause on last slide
	}
	else tID=setTimeout("rotate()", 5000);
}

function playss()
{
	clearTimeout(tID);
	toggle_playpause("pause")
	rotate();
}

function pausess(ssmode)
{
	clearTimeout(tID);
	toggle_playpause("play")
}

function toggle_playpause(ssmode)
{
	if (ssmode == "play") {
	var sstr = '<a href="#" onClick="playss();return false">play sequence</a>';
		MM_setTextOfLayer("ssmbpp",'',sstr);
	} else if (ssmode == "pause") {
		var sstr = '<a href="#" onClick="pausess();return false">pause sequence</a>';
		MM_setTextOfLayer("ssmbpp",'',sstr);
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_setTextOfLayer(objName,x,newText) { //v4.01
  //var alignedtext = '<div align="left">' + newText + "</div>";
  var alignedtext = newText;
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(alignedtext)); document.close();}
    else innerHTML = unescape(alignedtext);
}

function nextslide()
{
	//alert("Next slide (ocntr="+icntr+")");
	clearTimeout(tID);
	toggle_playpause("play")
	if (icntr < nslides) ++icntr;
	if (icntr == nslides) --icntr;
	jump2slide(icntr);
}

function prevslide()
{
	//alert("Prev slide (ocntr="+icntr+")");
	clearTimeout(tID);
	toggle_playpause("play")
	if (icntr>0) --icntr;
	jump2slide(icntr);
}

function showslide(idx)
{
	if ( idx<0 || idx>nslides) {
		//alert("ERROR! index out of range!  "+idx);
		idx=0;
	}
	icntr=idx;
	document.images.photo.src=pictures[icntr].src;
	MM_setTextOfLayer('Layer1','',captions[icntr]);
	showINstate(icntr);
}

function jump2slide(idx)
{
	if ( idx<0 || idx>nslides) {
		//alert("ERROR! index out of range!  "+idx);
		idx=0;
	}
	//alert("Jumping to slide #"+(idx+1));
	clearTimeout(tID);
	icntr=idx;
	document.images.photo.src=pictures[icntr].src;
	MM_setTextOfLayer('Layer1','',captions[icntr]);
	showINstate(icntr);
	//tID=setTimeout("rotate()", 15000); // resume autoplay? 
}

function showINstate (d) {
	for (var i=0;i<nslides;i++){
		clearINstate(i)
	}
	var dname = "ssmb0" + (d+1);
	var sstr = '<span style="color:#C41230 !important;">'+(d+1)+'</span>';
	MM_setTextOfLayer(dname,'',sstr);
}
function clearINstate (d) {
	var dname = "ssmb0" + (d+1);
	var sstr = '<a href="#" onClick="jump2slide('+d+');return false">'+(d+1)+'</a>';
	//var sstr = ""+(d+1)+"";
	MM_setTextOfLayer(dname,'',sstr);
}
