<!--hide this script from non-javascript-enabled browsers

//////////////////////////////////////////////////////////
//
// Oxford Cryosystems product selector
//
// Produced by Presenting Science
//  www.PresentingScience.com
//
// Copyright (C) Oxford Cryosystems
//
//////////////////////////////////////////////////////////

// List of images used for roll-over effects
var dynamicImages = new Array;
var nImages = 0;
var imageFolder = "selector/";

// Supply image name in document, passive and active images
function loadImages() {
	// Sample types: macromolecular, small molecule, powder flat plat, powder capillary
	dynamicImages[nImages++] = new DynamicImage("mm");		
	dynamicImages[nImages++] = new DynamicImage("sm");
	dynamicImages[nImages++] = new DynamicImage("pfp");
	dynamicImages[nImages++] = new DynamicImage("pc");
	
	// Temperature ranges: 160-300, 80-400, 80-500, <80
	dynamicImages[nImages++] = new DynamicImage("t0");
	dynamicImages[nImages++] = new DynamicImage("t1");
	dynamicImages[nImages++] = new DynamicImage("t2");
	dynamicImages[nImages++] = new DynamicImage("t3");
	
	// Source of cooling: liquid nitrogen or mechanical
	dynamicImages[nImages++] = new DynamicImage("useLN");
	dynamicImages[nImages++] = new DynamicImage("noLN");
	
	// Products
	dynamicImages[nImages++] = new DynamicImage("cryo");
	dynamicImages[nImages++] = new DynamicImage("cryop");
	dynamicImages[nImages++] = new DynamicImage("cryoc");
	dynamicImages[nImages++] = new DynamicImage("cobra");
	dynamicImages[nImages++] = new DynamicImage("cobrap");
	dynamicImages[nImages++] = new DynamicImage("helix");
	dynamicImages[nImages++] = new DynamicImage("phenix");
	dynamicImages[nImages++] = new DynamicImage("dtc");
	
	// Static labels
	dynamicImages[nImages++] = new DynamicImage("sample");
	dynamicImages[nImages++] = new DynamicImage("temp");
	dynamicImages[nImages++] = new DynamicImage("cooling");
	dynamicImages[nImages++] = new DynamicImage("tell");
	dynamicImages[nImages++] = new DynamicImage("product");
}

var currentSample = -1;
var currentTemp = -1;
var currentLN = -1;

function initSelector() {
	loadImages();
	currentSample = readCookie("currentSample");
	currentTemp = readCookie("currentTemp");
	currentLN = readCookie("currentLN");
	updateImages();
}

function updateImages() {
	setActive("sample", true);
	setActive("mm", currentSample==0);
	setActive("sm", currentSample==1);
	setActive("pfp", currentSample==2);
	setActive("pc", currentSample==3);	

	setActive("temp", currentSample!=-1);
	setActive("t0", currentTemp==3);	setDisable("t0", (currentSample==-1||currentSample==2||currentSample==3));
	setActive("t1", currentTemp==0);	setDisable("t1", (currentSample==-1||currentSample==2));
	setActive("t2", currentTemp==1);	setDisable("t2", (currentSample==-1||currentSample==2));
	setActive("t3", currentTemp==2);	setDisable("t3", (currentSample==-1||currentSample==3));
	
	var bMech = !(currentTemp==-1||currentSample==3);
	setActive("noLN", currentLN==0);	setDisable("noLN", !bMech);
	var bLN = !(currentTemp==-1||currentTemp==2||currentTemp==3);
	setActive("useLN", currentLN==1);	setDisable("useLN", !bLN);

	var bChoice = bMech && bLN;
	setDisable("tell", !bChoice);
	setActive("cooling", bChoice);
	
	setActive("product", currentSample!=-1 && currentTemp!=-1 && currentLN!=-1);
	
	var bCryo = !(currentLN!=1||currentTemp!=0||currentSample==3);
	setDisable("cryo", !bCryo);		setActive("cryo", bCryo);
	
	var bCryop = !(currentLN!=1||currentTemp!=1||currentSample==3);
	setDisable("cryop", !bCryop);		setActive("cryop", bCryop);
	
	var bCryoc = !(currentLN!=1||currentSample!=3);
	setDisable("cryoc", !bCryoc);		setActive("cryoc", bCryoc);

	var bCobra = !(currentLN!=0||currentSample==2||currentSample==3||currentTemp!=0);
	setDisable("cobra", !bCobra);		setActive("cobra", bCobra);

	var bCobrap = !(currentLN!=0||currentSample==2||currentSample==3||currentTemp!=1);
	setDisable("cobrap", !bCobrap);		setActive("cobrap", bCobrap);
	
	var bPhenix = !(currentLN!=0||currentSample!=2||currentTemp!=2);
	setDisable("phenix", !bPhenix);		setActive("phenix", bPhenix);

	var bHelix = !(currentLN!=0||currentSample==2||currentSample==3||currentTemp!=2);
	setDisable("helix", !bHelix );		setActive("helix", bHelix );

	var bDTC = !(currentLN!=0||currentSample==2||currentSample==3||currentTemp!=3);
	setDisable("dtc", !bDTC );		setActive("dtc", bDTC );
}

///////////////////////////////////////////////
// Simple message map
function handleClick(name) {
	var di = findImage(name);
	if (di != null && !di.disable) {
		
		if (name=="mm") setSample(0);
		if (name=="sm") setSample(1);
		if (name=="pfp") setSample(2);
		if (name=="pc") setSample(3);
		
		if (name=="t0") setTemp(3);	
		if (name=="t1") setTemp(0);	
		if (name=="t2") setTemp(1);	
		if (name=="t3") setTemp(2);	
		
		if (name=="noLN") setLN(0);
		if (name=="useLN") setLN(1);
		
		if (name=="tell") LNorMechanical();
		
		if (name=="helix") document.location = "helix/index.htm";
		if (name=="phenix") document.location = "phenix/index.htm";
		if (name=="cobra") document.location = "cobra/index.htm";
		if (name=="cobrap") document.location = "cobra/index.htm";
		if (name=="cryo") document.location = "cryostream/index.htm";
		if (name=="cryop") document.location = "cryostream/plus.htm";
		if (name=="cryoc") document.location = "cryostream/compact.htm";
		if (name=="dtc") document.location = "dtc/index.htm";
		
		writeCookie();
	}
}

function reset() {
	currentSample = -1;
	currentTemp = -1;
	currentLN = -1;
	updateImages();	
	writeCookie();
}

function setSample(s) {
	if (s==2) {
		setTemp(2);	
	}
	else if (s==3) {
		setTemp(1);
		currentLN = 1;
	}
	currentSample = s;
	updateImages();	
}

function setTemp(s) {
	if (s==2 || s==3) {
		currentLN=0;
	}
	currentTemp = s;
	updateImages();	
}

function setLN(s) {
	currentLN = s;
	updateImages();	
}

/////////////////////////////////////////////////////////////////////////////////////
//
// Generic four-state image code
//
/////////////////////////////////////////////////////////////////////////////////////

function di_setActive(active) {
	this.active = active;
	if (!this.disable)
		document.images[this.name].src = this.active? 
			this.activeImage.src : this.passiveImage.src;	
}

function di_setOver(over) {
	if (!this.disable && !this.active) {
		document.images[this.name].src = over? 
			this.overImage.src : this.passiveImage.src;	
	}
}

function di_setDisable(disable) {
	this.disable = disable;
	if (disable)
		document.images[this.name].src = this.disableImage.src;
	else
		this.setActive(this.active);	
}

function DynamicImage(n) {
	this.name = n;	

	this.passiveImage = new Image();	this.passiveImage.src = imageFolder+n+"p.gif";
	this.overImage = new Image();		this.overImage.src = imageFolder+n+"o.gif";
	this.activeImage = new Image();		this.activeImage.src = imageFolder+n+"a.gif";
	this.disableImage = new Image();	this.disableImage.src = imageFolder+n+"d.gif";
	
	this.active = false;
	this.disable = false;
	
	this.setActive = di_setActive;
	this.setOver = di_setOver;
	this.setDisable = di_setDisable;
}

function findImage(name) {
	var i, n = dynamicImages.length;
	for (i=0; i<n; i++) {
		if (dynamicImages[i].name == name) {
			return dynamicImages[i];	
		}
	}
	return null;
}

function setActive(name, active) {
	var di = findImage(name);
	if (di != null) 
		di.setActive(active);
}

function setOver(name, over) {
	var di = findImage(name);
	if (di != null) 
		di.setOver(over);
}

function setDisable(name, disable) {
	var di = findImage(name);
	if (di != null) 
		di.setDisable(disable);
}

// Called on mouse over - set bold image
function mouseOver(imageName, status) {
    setOver(imageName, true);
    window.status = status;
    return true;
}

// Called on mouse out - revert to standard image
function mouseOut(imageName) {
    setOver(imageName, false);
    window.status = '';
    return true;
}

/**
 * Extract and return part of the cookie
 */
 function readCookie(label) {
    var c = document.cookie;
    var pos = c.indexOf(label);
    if (pos != -1) {
        var start = pos+label.length;
         var d = c.substring(start, c.length)
         var end = d.indexOf(":");
         if (end == -1) end = d.length;
         var h = d.substring(0, end)-0;
         h = unescape(h);
         if (h.length>0) {
            return h;
        }
    }
    return -1;
}
 
/**
 * Write the cookie
 */
 function writeCookie() {
     var nextYear = new Date();
     nextYear.setFullYear(nextYear.getFullYear()+1);	// Will last for one year
     document.cookie = "currentSample "+escape(currentSample) + ": currentTemp "+escape(currentTemp) + ": currentLN "+escape(currentLN) 
	 	+ ":; ";//expires=" + nextYear.toGMTString()+";";
		
 }
 
var aboutWindow = null;

function LNorMechanical() {
	var url = imageFolder + "LNorMechanical.htm";
	
    if (aboutWindow && !aboutWindow.closed) {
        aboutWindow.focus();
    }
    else {
        var w = 700;
        var h = 600;
        var l = (screen.width - w)/2;
        var t = (screen.height - h)/2;
        aboutWindow = window.open(url,
            "aboutWin",
            "status=no,scrollbars=yes,resizable=yes,"+
            "width="+w+",height="+h+
            ",top="+t+",left="+l);
    }
}

 

// stop hiding -->
