var lastMenu = 'foo';
var lastTop;
var hide_with_delay;
var lastCal = 'foo';

// cross platform
if (document.layers) {
  visible = 'show';
  hidden = 'hide';
} else if (document.all) {
  visible = 'visible';
  hidden = 'hidden';
} else if (document.getElementById) {
  visible = 'visible';
  hidden = 'hidden';
}

function hideTimer() {
		hide_with_delay = setTimeout("hideLast()", 250);
}

function clearHider() {
	if (hide_with_delay) {
		clearTimeout(hide_with_delay);
	}
}

function hideLast() {
	// turn off old menu
    lastMenu.visibility = hidden;
    lastTop.visibility = hidden;
    lastMenu = 'foo';
}

function toggler(top, menu) {

// clear the Timeout
	if (hide_with_delay) {
		clearTimeout(hide_with_delay);
	}

	// Set popup to a browser specific value
	//
	if (document.layers) {
    	popup = document.layers[menu];
   		topup = document.layers[top];
	} else if (document.all) {
    	popup = document.all(menu).style;
    	topup = document.all(top).style;
	} else if (document.getElementById) {
    	popup = document.getElementById(menu).style;
    	topup = document.getElementById(top).style;
	}
	
    if (lastMenu != popup && lastMenu != 'foo') { 
    	// turn off old menu
		hideLast();
    }
    			
  	popup.visibility = visible;
	topup.visibility = visible;
	
    // set these variables for use next time
    lastMenu = popup;
    lastTop = topup;
}

//Open a new window and give it focus
//This is the seminar abstract popup

var newwindow = '';

function new_win(url) {
	if (newwindow.location && !newwindow.closed) {
	    newwindow.location.href = url;
	} else {
	    newwindow=window.open(url,'abstract_window','toolbar=no,menubar=no,scrollbars=yes,directories=no,status=no,width=620,height=720');
	    if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {
		newwindow.focus()
	}
}

//This is the smaller resizable generic window

var genwindow = '';

function gen_win(url) {
if (genwindow.location && !genwindow.closed) {
	  genwindow.location.href = url;
	} else {
	    genwindow=window.open(url,'gen_window','toolbar=no,menubar=no,scrollbars=yes,directories=no,status=no,resizable=yes,width=420,height=310');
	    if (!genwindow.opener) genwindow.opener = self;
	}
	if (window.focus) {
		genwindow.focus()
	}
}

//This is the larger publications list popup

var pubwindow = '';

function pub_win(url) {
if (pubwindow.location && !pubwindow.closed) {
	  pubwindow.location.href = url;
	} else {
	   pubwindow=window.open(url,'pub_window','toolbar=no,menubar=no,scrollbars=yes,directories=no,status=no,resizable=yes,width=620,height=600');
	    if (!pubwindow.opener) pubwindow.opener = self;
	}
	if (window.focus) {
		pubwindow.focus()
	}
}

//This is the larger publications list popup

var infowindow = '';

function info_win(url) {
if (infowindow.location && !infowindow.closed) {
	  infowindow.location.href = url;
	} else {
	   infowindow=window.open(url,'info_window','toolbar=no,menubar=no,scrollbars=yes,directories=no,status=no,resizable=yes,width=600,height=300');
	    if (!infowindow.opener) infowindow.opener = self;
	}
	if (window.focus) {
		infowindow.focus()
	}
}

function setBinaryClock(imageBase) {
	var hours, minutes, seconds;
	stamp = new Date();
	seconds = stamp.getSeconds();
	minutes = stamp.getMinutes();
	hours = stamp.getHours();
	days = stamp.getDate();
	months = stamp.getMonth() + 1;
	years = stamp.getFullYear();
	
	var s1 = seconds % 10;
	var s2 = (seconds - s1)/10;
	
	var m1 = minutes % 10;
	var m2 = (minutes - m1)/10;
	
	var h1 = hours % 10;
	var h2 = (hours - h1)/10;
	
	var d1 = days % 10;
	var d2 = (days - d1)/10;
	
	var n1 = months % 10;
	var n2 = (months - n1)/10;
	
	ya = years % 1000;
	yb = ya % 100;
	y1 = yb % 10;
	y2 = (yb - y1)/10;
	y3 = (yb -ya)/100;
	y4 = (years - ya)/1000;
	
	var sec1 = document.getElementById('seconds1');
	var sec2 = document.getElementById('seconds2');
	sec1.src = imageBase + s1 + ".gif";
	sec2.src = imageBase + s2 + ".gif";
	
	var min1 = document.getElementById('minutes1');
	var min2 = document.getElementById('minutes2');
	min1.src = imageBase + m1 + ".gif";
	min2.src = imageBase + m2 + ".gif";
	
	var hr1 = document.getElementById('hours1');
	var hr2 = document.getElementById('hours2');
	hr1.src = imageBase + h1 + ".gif";
	hr2.src = imageBase + h2 + ".gif";
	
	var day1 = document.getElementById('days1');
	var day2 = document.getElementById('days2');
	day1.src = imageBase + d1 + ".gif";
	day2.src = imageBase + d2 + ".gif";
	
	var mon1 = document.getElementById('months1');
	var mon2 = document.getElementById('months2');
	mon1.src = imageBase + n1 + ".gif";
	mon2.src = imageBase + n2 + ".gif";
	
	var year1 = document.getElementById('years1');
	var year2 = document.getElementById('years2');
	var year3 = document.getElementById('years3');
	var year4 = document.getElementById('years4');
	year1.src = imageBase + y1 + ".gif";
	year2.src = imageBase + y2 + ".gif";
	year3.src = imageBase + y3 + ".gif";
	year4.src = imageBase + y4 + ".gif";
		
}
