﻿function do_shohidchecked(which1) {
	if (which1 == "checked") {
		document.getElementById("checkeddiv").style.display = (document.getElementById("checkeddiv").style.display=="block") ? "none" : "block";
	} else {
		document.getElementById("bigdiv").style.display = (document.getElementById("bigdiv").style.display=="block") ? "none" : "block";
	};
	document.getElementById("container").focus();
};

function do_navigate(frm) {
	var obj=frm.elements["gotos"];
	var sessnum=obj.value;
	var sessdivs = getArraybyClass(document.getElementById("bigdiv"),"sesstit");
	var togo = document.getElementById("thetop");
	for (var i=0; i<12; i++) { //number of sessions
		if (sessdivs[i].innerHTML.indexOf(sessnum) != -1) {
			togo = sessdivs[i];
			break;
		};
	};
	togo.scrollIntoView(true);
	document.getElementById("container").focus();
};

function do_checkkey(e) {
	var key = window.event ? e.keyCode : e.which;
	if (key==13) {expandbysearch(document.getElementById("uinterface"))};
};

		
function do_onload(){
	if (BrowserDetect.browser=="Explorer") {	// needed to prevent hanging indent problem in Explorer
		var i, cacheobj, altsheets=[""]
		for(i=0; (cacheobj=document.getElementsByTagName("link")[i]); i++) {
			if(cacheobj.getAttribute("rel").toLowerCase()=="alternate stylesheet" && cacheobj.getAttribute("title")) { //if this is an alternate stylesheet with title
				cacheobj.disabled = true
				altsheets.push(cacheobj) //store reference to alt stylesheets inside array
				if(cacheobj.getAttribute("title").indexOf("IE") == 0) //enable alternate stylesheet with title that matches parameter
				cacheobj.disabled = false //enable chosen style sheet
			}
		};
	};
// add event listener for search box
	if (window.addEventListener) {
		window.addEventListener("keypress", do_checkkey, false)
	}
	else if (window.attachEvent)
	{
		window.attachEvent("keypress", do_checkkey)
	};

//	document.getElementById("interface").elements["gotos"].selectedIndex = 0;
	tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : "";
	hasInnerText = (document.getElementsByTagName("div")[0].innerText != undefined) ? true : false;
	checkdivptr = document.getElementById("checkeddiv");
	addlisteners();	// adds event listeners for each panel title, to open or close all abstracts in that panel
	var allcheckboxes = document.getElementsByTagName("input");
	for (var i=0; i<allcheckboxes.length; i++) {
		if (allcheckboxes[i].type=="checkbox") {allcheckboxes[i].checked=false};
	};
	uniqueidn="firsttimeload"
	var alltags=document.all? document.all : document.getElementsByTagName("*")
	ccollect=getElementbyClass(alltags, "abstracttxt")
	if (enablepersist=="on" && ccollect.length>0){
		document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1; expires=15/01/2008 00:00:00" : uniqueidn+"=0; expires=15/01/2008 00:00:00"
		firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
		initialize();	//this is the init routine for the sorting code
		if (!firsttimeload) {
			revivecontent(true);
			curcheck = get_cookie("checked");
			assertchecked();	// this routine makes sure that the checked items are really in the checkeddiv
		};
	};
	document.getElementById("container").focus();
}

function addlisteners() {
	var panarr = document.getElementsByTagName("div");
	panarr = getElementbyClass(panarr,"paneltit");
	for (var i=0;i<panarr.length;i++) {
		if (window.addEventListener) {
			panarr[i].addEventListener("click", panelclick, true);
		}
		else if (window.attachEvent) {
			var temhtml = panarr[i].parentNode.innerHTML;
			var j=temhtml.indexOf("paneltit");
			if (j != -1) {
				var newtem = temhtml.substring(0,j+9)+" onclick="+'"panel' +'click()"'+temhtml.substring(j+9,temhtml.length);
				panarr[i].parentNode.innerHTML = newtem;
			};
		}
		else if (document.getElementById) {
			panarr[i].onclick = panelclick;
		};
	};
};

// script to add event listeners
if (window.addEventListener) {
window.addEventListener("load", do_onload, false)
//window.addEventListener("submit",do_onsubmit,true);
window.addEventListener("submit", do_onsubmit1, true);}
else if (window.attachEvent) {
window.attachEvent("onload", do_onload)
//window.attachEvent("submit",do_onsubmit)
window.attachEvent("submit",do_onsubmit1)}
else if (document.getElementById) {
window.onload=do_onload
window.submit=do_onsubmit
window.submit=do_onsubmit1}
if (enablepersist=="on" && document.getElementById) {
window.onunload=saveswitchstate;
}

/* CSS adjustments

// make persname smaller when the screen is smaller

*/


var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();



/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetxpoint=-100 //Customize x offset of tooltip
var offsetypoint=-64 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj


//this and the tiny function below is debug code
var bugcatcher=false;
function docatch(evt,obj) {
	alert("caught one");
	bugcatcher=!bugcatcher;
}

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
	if (enabletip){
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
if (bugcatcher) {alert("curY="+curY)};
		//Find out how close the mouse is to the corner of the window
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
		if (BrowserDetect.browser == "Safari") {bottomedge = window.innerHeight-e.clientY+document.body.scrollTop-offsetypoint-20};
		
		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
		
		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<tipobj.offsetWidth)
		//move the horizontal position of the menu to the left by it's width
		tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
		else if (curX<leftedge)
		tipobj.style.left="5px"
		else
		//position the horizontal position of the menu where the mouse is positioned
		tipobj.style.left=curX+offsetxpoint+"px"
		
		//same concept with the vertical position
		if (bottomedge<tipobj.offsetHeight) {
if (bugcatcher) {alert("e.clientY "+e.clientY+"\noffsetHeight "+tipobj.offsetHeight+"\nwindowinnerheight "+window.innerHeight+"\ne.y "+e.y+"\npageYoffset "+window.pageYOffset)};
			tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
		}
		else {
			tipobj.style.top=curY+offsetypoint+"px"
		};
if (bugcatcher) {alert("top: "+tipobj.style.top+"\nleft: "+tipobj.style.left)};
		tipobj.style.visibility="visible"
	}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip




/*
This script is written by Eric (Webcrawl@usa.net)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
NEEDS TO BE IN BODY SECTION
*/

function printit(){  
if (window.print) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}
}


/* NEEDS TO BE IN BODY OF PAGE
var NS = (navigator.appName == "Netscape");
var VERSION = parseInt(navigator.appVersion);
if (VERSION > 3) {
    document.write('<form><input type=button value="Print this Page" name="Print" onClick="printit()"></form>');        
}
*/
