//	default methods for geert lovink
//	copyright house of laudanum 2005
//	this file NOT included in creative commons licence

			my_links = new Array(0)
			my_links.length = 0
			
			my_links_base = '/cgi-bin/isengine.pl?o=geert&action=search&category='

			my_links[my_links.length] = new menuItem('Reports/Articles/Essays', my_links_base + 'article')
			my_links[my_links.length] = new menuItem('Interviews', my_links_base + 'interviews')
			my_links[my_links.length] = new menuItem('Reviews', my_links_base + 'review')
			my_links[my_links.length] = new menuItem('Journal', my_links_base + 'journal')
			my_links[my_links.length] = new menuItem('Geert Elsewhere', my_links_base + 'elsewhere')
			my_links[my_links.length] = new menuItem('Publications', my_links_base + 'publication')
//			my_links[my_links.length] = new menuItem('Conferences', my_links_base + 'conference')
//			my_links[my_links.length] = new menuItem('Event Diary', my_links_base + 'event')
//			my_links[my_links.length] = new menuItem('Lectures/Presentations', my_links_base + 'lecture')
			my_links[my_links.length] = new menuItem('Links', my_links_base + 'link&sort=01')
			my_links[my_links.length] = new menuItem('Interviews & Email with GL', my_links_base + 'interviewed')
			my_links[my_links.length] = new menuItem('Deutsch', '/cgi-bin/isengine.pl?o=geert&action=search&string=deutsch')
			my_links[my_links.length] = new menuItem('Nederlands', '/cgi-bin/isengine.pl?o=geert&action=search&string=nederlands')
			my_links[my_links.length] = new menuItem('Biography', '/geert/biography.shtml')
			my_links[my_links.length] = new menuItem('Audio', '/geert/audio.shtml')
			my_links[my_links.length] = new menuItem('Advanced Search', '/cgi-bin/isengine.pl?o=geert&action=advsearch')
			

			var t, v, m, n	//	timeout variable
			delay = 10		//	pause between step
			time = 0
			duration = 10	//	number of steps

			visible = 0

			var selected = 0	// = 5
			
			for ( i = 0; i < my_links.length; i++ )
				if ( location.href.indexOf(my_links[i].url) > 0 )
					selected = i
			
			var active = selected
			var revealing
			
			menu_alpha_max = 100
			menu_alpha_min = 100

			var menuitem_width_min
			var menuitem_width_max = 125

			if ( document.all )
				document.onmouseover = mouseover
			
			
			window.onresize = function()
			{
				buildMenu()
				if (active || active == 0)
					displayMenuItem(active)
				if ( selected || selected == 0)
					document.getElementById("div_" + selected).className = 'selected'
			}
			
			
			function main()
			{
				buildMenu()
				if ( selected )
				{
					displayMenuItem(selected)
					document.getElementById("div_" + selected).className = 'selected'
				}
				else
					displayMenuItem(0)
				
			}
			
			
			function buildMenu()
			{
							
				the_menu = document.getElementById('menu')
				
				if ( window.innerWidth )
					menu_width = window.innerWidth
				else if ( document.body.clientWidth )
					menu_width = document.body.clientWidth
					
//				menu_width = 1000
//				document.getElementById('titlebar').style.width = menu_width
				
				margin_total = 15
				if ( document.all )
					margin_total = 1
				menuitem_width_min = parseInt((menu_width - menuitem_width_max + margin_total) / (my_links.length - 1)) - margin_total

				menu_width_new = (menuitem_width_min + margin_total) * (my_links.length - 1) + menuitem_width_max - margin_total

//				the_menu.style.width = menu_width - 20
			
			
				while(the_menu.hasChildNodes() == true)
					the_menu.removeChild(the_menu.childNodes[0]);
				
				for ( i = 0; i < my_links.length; i++ )
				{
					window.status = i
					if ( ! my_links[i].text )
						continue
					div = document.createElement('div')
					div.id = 'div_' + i
					div.revealed = 0
					div.revealing = 0
					div.setAttribute('onMouseOver', 'displayMenuItem(' + i + ')')
					div.text = my_links[i].text
					div.style.width = menuitem_width_min
					txt = document.createTextNode(my_links[i].text)
					a = document.createElement('a')
					a.setAttribute('href', my_links[i].url)
					if ( document.all )
					{
						a.appendChild(txt)
						div.appendChild(a)
						the_menu.appendChild(div)
					}
					else
					{
						a.setAttribute('onMouseOver', 'displayMenuItem(' + i + ')')
						div.appendChild(txt)
						a.appendChild(div)
						the_menu.appendChild(a)
					}
				}
			}

			
			function mouseover(e) {
				if ( document.all )
				{
					if ( event.srcElement.revealed || event.srcElement.revealing )
						return
						
					id = event.srcElement.id
					if ( id.indexOf('div') == 0 )
					displayMenuItem(id.substr(4,id.length))
				}
			//	tmp = (is.NS5) ? e.target.getAttribute("id") : event.srcElement.id;
			//	alert(tmp)
			}


			function displayMenuItem(id)
			{					
				if ( id < 0 )
					return

				node = document.getElementById("div_" + id)					
				if ( node.revealed || node.revealing )
					return
				else
				{						
					active = id
					node.revealing = 1
					
					time = 0
					revealMenuItem(id)
					for ( i = 0; i < my_links.length; i++ )
						if (i == id ) {}
						else
							hideMenuItem(i)
				}
			}
			
			
			function hideMenuItem(id)
			{
				node_hiding = document.getElementById("div_" + id)
				if ( !node_hiding.revealing && !node_hiding.revealed )
					return
//				window.status = (id)
				node_hiding.time = 0
				node_hiding.revealing = 0
				node_hiding.revealed = 0
				collapseMenuItem(node_hiding)

			}
			
			
			function displayMenu()
			{
				return
				clearTimeout(v)
				menu = document.getElementById('menu')
			//	if ( menu.style.visibility == 'visible' )
			//		return
			//	menu.style.visibility = 'visible'
				if ( visible )
					return
				visible = 1
				time = 0
				reveal()
			}
			
			
			function hideMenu()
			{
				if ( ! visible )
					return
				menu = document.getElementById('menu')
				time = 0
				v = setTimeout('collapse()', 	2000)
			}
			
			
			function reveal()
			{
				clearTimeout(t)
				t = setTimeout("sizeUp()", delay)
			}


			function revealMenuItem()
			{
				clearTimeout(m)
				m = setTimeout("stretchOut()", delay)
			}
			
			
			function collapse()
			{
				clearTimeout(t)
				t = setTimeout("sizeDown()", delay)
			}
			
			
			function collapseMenuItem(node_collapsing)
			{
				if ( ! node_collapsing )
				{
					alert('no node')
					return
				}
//				window.status = (node_collapsing.text)
				if ( node_collapsing.id == "div_" + active )
				{
//					alert('attempt to collapse active node ' + node_collapsing.text)
					return
				}
				clearTimeout(node_collapsing.t)
				node_collapsing.t = setTimeout("stretchIn(" + node_collapsing.id + ")", delay)
			}
			
			
			function sizeUp()
			{
				time++
				if ( time > duration )
				{
					clearTimeout(t)
				}
				else
				{
					menu = document.getElementById('menu')
					val = Math.easeInOutQuad(time, 0, menu_alpha_max, duration) + menu_alpha_min;
					setAlpha(menu, val)
					reveal()
				}
			}


			function stretchOut()
			{
				node_stretching = document.getElementById('div_' + active)
				time++
				if ( time > duration )
				{
					clearTimeout(m)
					node_stretching.revealed = 1
					node_stretching.revealing = 0
				}
				else
				{
				//	menu = document.getElementById('div_' + active)
					val = Math.easeInOutQuad(time, menuitem_width_min, menuitem_width_max - menuitem_width_min, duration)
				//	setAlpha(menu, val)
					node_stretching.style.width = val
					revealMenuItem()
				}
			}


			function stretchIn(node_stretching_in)
			{
//				node_stretching_in = document.getElementById(node_stretching_in)
//				alert(node_stretching_in.text)
//				window.status = node_stretching_in.text
			//	menu = document.getElementById('div_' + id)
				node_stretching_in.time++
				if ( node_stretching_in.time > duration || parseInt(node_stretching_in.style.width) <= menuitem_width_min)
				{
					clearTimeout(node_stretching_in.t)
					node_stretching_in.style.width = menuitem_width_min
				//	menu.revealed = 1
				//	menu.revealing = 0
					node_stretching_in.revealed = 0
				}
				else
				{
				//	menu = document.getElementById('div_' + active)
					val = Math.easeInOutQuad(node_stretching_in.time, menuitem_width_max, menuitem_width_min - menuitem_width_max, duration)
				//	setAlpha(menu, val)
					node_stretching_in.style.width = val
					collapseMenuItem(node_stretching_in)
				}
			}


			function sizeDown()
			{
				time++
				if ( time > duration )
				{
					clearTimeout(t)
				//	menu.style.visibility = 'hidden'
					visible = 0
				}
				else
				{
					menu = document.getElementById('menu')
					val = Math.easeInOutQuad(time, menu_alpha_max, -menu_alpha_max, duration) + menu_alpha_min;
//					menu.style.height = val
					setAlpha(menu, val)
					collapse()
				}
			}
			
			
			function setAlpha(that, val)
			{
				that.style.opacity = val/100
				that.style.MozOpacity = val/100
			}


			Math.linearTween = function (t, b, c, d) {
		    	return c*t/d + b;
			};
		

			Math.easeInOutQuad = function (t, b, c, d) {
				t /= d/2;
				if (t < 1) return c/2*t*t + b;
				t--;
				return -c/2 * (t*(t-2) - 1) + b;
			};
	

			function menuItem(text, url)
			{
				obj = new Object
				obj.text = text
				obj.url = url

				return obj
			}
			
			
			function chapterInit()
			{

			}
			
			
			function setLink()
			{
			
			}

			
			function launch(url)
			{
				location.href = url
			}
			

			function entityToAscii(CharCode)
			{
				return String.fromCharCode(CharCode)
			}


			function padUnicode(unicode)
			{
				while(unicode.length < 4)
					unicode = "0" + unicode
				return unicode
			}
			

			function asciiToUnicode(ascii)
			{
				unicode = ascii.charCodeAt(0).toString(16).toUpperCase()
				while(unicode.length < 4)
					unicode = "0" + unicode
				return unicode
			}
			
			
			function asciiToEntity(ascii)
			{
				return ascii.charCodeAt(0)
			}
			
			
			function entityToUnicode(entity)
			{
				if ((entity >= 130) && (entity <= 140))
					return(entityToUnicode(lookupAnsiUnicode(entity)))
				if ((entity > 145) && (entity <= 159))
					return(entityToUnicode(lookupAnsiUnicode(entity)))
					
				return(asciiToUnicode(entityToAscii(entity)))
			}


			function lookupAnsiUnicode(entity)
			{
			//	alert(ansi[entity])
				return ansi[entity]
			}


			function convertEntitiesToUnicode(str)
			{
				cha = "&#"
				a = str.indexOf(cha)

				while(a > -1)
				{
					z = str.substring(a, str.length)
					b = z.indexOf(";")
//					entity = "\\u" + entityToUnicode(str.substring(a+2,a+b))
					entity = "\"\\u" + entityToUnicode(str.substring(a+2,a+b)) + "\""
//					alert("unicode " + eval(entity))
					pre = str.substring(0,a)
					post = str.substring(a+b+1, str.length)

					str = pre + eval(entity) + post
					
					a = str.indexOf(cha)
				}
				
				return(str)
			}


			ansi = new Array()

			ansi[130] = 8218
			ansi[131] = 402
			ansi[132] = 8222
			ansi[133] = 8230
			ansi[134] = 8224
			ansi[135] = 8225
			ansi[136] = 710
			ansi[137] = 8240
			ansi[138] = 352
			ansi[139] = 8249
			ansi[140] = 338
			ansi[141] = ""
			ansi[142] = 381
			ansi[143] = ""
			ansi[144] = ""
			ansi[145] = 8216
			ansi[146] = 8217
			ansi[147] = 8220
			ansi[148] = 8221
			ansi[149] = 8226
			ansi[150] = 8211
			ansi[151] = 8212
			ansi[152] = 732
			ansi[153] = 8482
			ansi[154] = 353
			ansi[155] = 8250
			ansi[156] = 339
			ansi[157] = ""
			ansi[158] = 382
			ansi[159] = 376


