//	default javascript methods  april 2005
//	copyright mr.snow@laudanum.net

			function show (id)
			{	
				nodes = document.getElementsByTagName('div')
				for ( i = 0; i < nodes.length; i++ )
				{
					if ( nodes[i].id.indexOf('z_') == 0 )
					{
						if ( nodes[i].id == ('z_'+id) )
						{
							if ( nodes[i].style.display == 'none' )						
								nodes[i].style.display = 'block'
						//	else
						//		nodes[i].style.display = 'none'
						}
						else
							nodes[i].style.display = 'none'
					}
				}
			}


			function adv(obj, incr)
			{
				obj = eval(obj)
				
				obj.count = obj.count + incr
				if ( obj.count >= obj.images.length ) obj.count = 0
				if ( obj.count < 0 ) obj.count = obj.images.length - 1

				go(obj, obj.count)
			}
			
			
			function go (obj, count)
			{
				obj = eval(obj)
				if (count || count == 0)
					obj.count = count

				if ( obj.images[obj.count].idx )
					show(obj.images[obj.count].idx)

//	set the image				
				var colour

				if ( obj.images[obj.count].colour )
					colour = obj.images[obj.count].colour
				if( !colour || colour == 'undefined' )
					colour = obj.colour

				document.getElementById(obj.image_element).style.background = 'url(' + obj.images[obj.count].src + ') no-repeat center ' + colour;

//	set the counter
				node = document.getElementById(obj.count_element)
				text = " " + (obj.count + 1) + " of " + obj.images.length + " "
				if (node.firstChild)
					node.firstChild.nodeValue = text
				else
					node.innerHTML = text

//	set the text
				node = document.getElementById(obj.info_element)
				text = obj.images[obj.count].caption
				if ( obj.images[obj.count].attribution )
					text += " \\ " + obj.images[obj.count].attribution
				if (node.firstChild)
					node.firstChild.nodeValue = text
				else
					node.innerHTML = text
			}


			function test(that) {
				alert(that.text)
				alert(that.className)
			}


			portraits_ready = false
			default_title = " // Ailie"
			var win = null

			function openWindow(Url, width, height, scrolling, title, status, location) {
//					alert(title)
					
				content = ''
			//	if(scrolling == '' || scrolling) scrolling = 'yes'
				if(!scrolling) scrolling = 'no'
				else	scrolling = 'yes'

				if((Url.indexOf(".jpg") == Url.length-4) || (Url.indexOf(".gif") > 0)) {			//	its not html
					content = "<html><head><title>"
					content += title + default_title
					content += "</title>"
//	alert(content)
					if(!browser.isIE)
						content += "<script>modw =(parseInt(self.outerWidth) - parseInt(self.innerWidth)); modh =(parseInt(self.outerHeight) - parseInt(self.innerHeight)); function resize(that) { mw = parseInt(that.width) + modw; mh = parseInt(that.height) + modh; window.status = mw + ', ' + mh; window.resizeTo(mw,mh); }</script>"
					else
						content += "<script>function resize(that) { window.resizeTo(" + width + "," + height + ");  modw=" + width + "-(document.body.clientWidth-that.width); modh=" + height + "-(document.body.clientHeight-that.height); window.resizeTo(modw,modh) }</script>"

					content += "</head><body bgcolor=white marginwidth=0 marginheight=0 leftmargin=0 rightmargin=0 topmargin=0 bottommargin=0>"
					content += "<img onLoad='window.resize(this);window.focus()' src=" + Url + ">"
			//		content += "<img onLoad='resizeImageWindow(this)' src=" + Url + " width=" + width + " height=" + height + ">"
					content += "</body></html>"
					scrolling = "no"
					Url = ""
				}
				
				else
				{
					if (Url.indexOf("<html>") > -1 )
					{
						content = Url
						Url = ""
					}
				}

				var x = 0
				var y = 0
				var margin = 50

				if (location)
				{
					if (location.indexOf('lower') > -1)
					{
						y = screen.availHeight - height - margin
					}
					if (location.indexOf('right') > -1)
					{
						x = screen.availWidth - width - margin
					}
//					win.moveTo(x,y)
				}

				if(!win || win.closed) {
					eval ("win = open('" + Url + "', 'win', 'left=" + x + ", top=" + y + ", width=" + width + ",height=" + height + ", toolbar=no,resizable=yes,location=no,menubar=no,scrollbars=" + scrolling + ",titlebar=no,status=" + status + "')")
					win.moveTo(x,y)
				}

				
				win.resizeTo(width,height)

				if(content != "") {
					win.document.open()
					win.document.writeln(content)
					win.document.close()
//					alert(content)
				}
				if (win.document.title && title && !content)
				{
//					alert(title)
					win.document.title = title
				}	
				win.focus()

				win_w = width
				win_h = height

			}


			function openLink(url) {
				linkWindow = open(url,'linWindow', 'width=760, height=420, toolbar=yes,status=yes,resizable=yes,location=yes,menubar=yes,scrollbars=yes,titlebar=yes')
				linkWindow.focus()
			}
			
			

			function get_person(which) {
				obj = which.split('_')
			//	alert(obj[1])
				return "person_" + obj[1]
			}


			function getPerson(which) {
				obj = which.split('_')
				return obj[1] - 1
			}


			function switch_person(type, which, that) {
				switchArea(type, which, that)
				switch_portrait(which)
			}


			function switchPerson(type, which, that) {		//	v0.2
				if (window.scrollTo)
				{
					window.scrollTo(0,0)
				}
				else if (window.scroll)
				{
					window.scroll(0,0)
				}
				switchPlaceholder(which, 'large')
				switchArea(type, which, that)
			}


			function switchPlaceholder(which, size) {			//	v0.2
				if (people_ready) {
					//	added people_target, as it is defined *before* the holder is loaded
					people_target = document.images['placeholder']
					i = getPerson(which)
					if (!people[i])
						return
					people_target.src = people[i][size].src
					
					//	causes page reflowing on mouse over
					if(!browser.isMac && !browser.isIE)
						people_target.alt = people[i].large.alt
					window.status = people[i].large.alt
				}
			}


			function switchPortrait(which) {				//	v0.2
			//	switch_info(which)
				switchPlaceholder(which, 'thumb')
			}


			function switch_placeholder(which) {
				if (portraits_ready) {
					document.images.placeholder.src = eval(get_person(which) + '.image.src')
			//	causes page reflowing on mouse over
					if(!browser.isMac && !browser.isIE)
						document.images.placeholder.alt = eval(get_person(which) + '.name')
					window.status = eval(get_person(which) + '.name')

				}
			}


			function switch_portrait(which) {
				switch_info(which)
				switch_placeholder(which)
			}


			//	alert(document.getElementById(which).innerHTML)
			//	alert(node.nodeName)	//	returns DIV
			//	alert(node.children)	//	returns HTML collection
			//	alert (list[i].innerHTML)
			//	alert (list[i].nodeValue)


			function switch_info(which) {
				node = document.getElementById(which)
				if(node.hasChildNodes()) {
					if (node.children)
						list = node.children
					if (node.childNodes)
						list = node.childNodes		//	mozilla

					for ( i = 0 ; i < list.length; i ++ ) {
//						if((list[i].id == "headline") || (list[i].getAttribute("id") == "headline")) {
						if(list[i].id == "headline") {
							if (list[i].innerText)
								window.status = (list[i].innerText)
							break
						}
					}
				}
				return true
			}


			function switchArea(type, which, that) {

				list = document.getElementsByTagName("*");
				for ( i = 0; i < list.length; i++ ) {
					if(list[i].id.indexOf(type) > -1) {
						if((list[i].id == which) || (which == true))
							show(list[i].id, true)
						else
							show(list[i].id, false)
					}
				}

			//	set the style for the active submenu
				if(that) {
					setActiveLink(that)
				} else {
					if(!which) {
					//	do nothing
					} else {
						if(which == true) return //	fixes weird page load bug
						
					//	use the number from 'content_xx' to identify the correct menu item
						target = parseInt(which.substring(which.indexOf('_')+1,which.length))
						count = 0
						for ( i = 0; i < document.links.length; i++ ) {
							if(document.links[i].className == "submenu") {
								count++
								if (count == target) {
									switchStyle(document.links[i], "submenuactive")
									active_submenu = document.links[i]
									break
								}
							}
						}
					}
				}
			}


			function switchShop(type, which, that) {
				switchArea(type, which, that)
				switchPlaceholder(which, 'mid')
				
				gallery_current = getPerson(which)
				if (people[gallery_current])			
	 				setContent('gallery_caption', people[gallery_current].caption)
			}

			function switchShopOver(which, that) {
				switchPlaceholder(which, 'thumb')			
				setContent('gallery_caption', '')
				gallery_current = getPerson(which)
			}
			
			
			function hide_all() {
				switchArea('content',false)
			}


			function show_all() {
				switchArea('content',true)
			}


			function switchStyle(that, style) {
	//			alert(that.className)
				if(that.className)
					that.className = style
			}
			
			
			function setStyle(id, style) {
				switchStyle(document.getElementById(id), style)
			}


			var active_submenu

			function setActiveLink(that) {
				switchStyle(that, "submenuactive")
				if (active_submenu)
					switchStyle(active_submenu, "submenu")
				active_submenu = that

			/*	for ( i = 0; i < document.links.length; i++ ) {
					if ( that == document.links[i] ) {
						window.status = that.text
						switchStyle(that, "submenuactive")
					} else {
						if(that.className.indexOf("submenu") > -1) {
							switchStyle(document.links[i], "submenu")
						}
					}
				}
			*/
			}


			function printable() {
					show_all()
					switchArea('body',false)
			}


			function generate_people() {
				if(people) {

					for ( i = 0; i < people.length; i++ ) {
						n = i+1
						obj = eval('person_' + n + ' = new Object()')

					//	person[i] = new Object()
						obj.name = people[i]
						obj.image = new Image()
						filename = people[i].toLowerCase().split(' ').join('_')
					//	limit the total filename length to 31 ( 27.jpg )
						if(filename.length > 27) {
							filename = filename.substring(0,27)
						}
						obj.image.src = portrait_path + filename + '.jpg'
					}
					portraits_ready = true
				}
			}



				function generatePeople(caption, file_thumb, file_large) {
					obj = new Object()

					obj.thumb = new Image()
					obj.thumb.src = people_path + file_thumb
					obj.thumb.alt = caption

					obj.large = new Image()
					obj.large.src = people_path + file_large
					obj.large.alt = caption

					obj.caption = caption

					return obj
				}


				function generateGallery(caption, file_thumb, file_large, text) {
					obj = new Object()

					obj.thumb = new Image()
					obj.thumb.src = gallery_path + file_thumb
					obj.thumb.alt = caption

//					obj.large = new Image()
//	by creating an object rather than an image, large images are not preloaded
					obj.large = new Object()
					obj.large.src = gallery_path + file_large
					obj.large.alt = caption

					obj.caption = caption
					obj.text = text

					return obj
				}


				function generateShopGallery(caption, file_thumb, file_mid, file_large) {
					obj = new Object()

					obj.thumb = new Image()
					obj.thumb.src = gallery_path + file_thumb
					obj.thumb.alt = caption

					obj.mid = new Image()
					obj.mid.src = gallery_path + file_mid
					obj.mid.alt = caption

//					obj.large = new Image()
//	by creating an object rather than an image, large images are not preloaded
					obj.large = new Object()
					obj.large.src = gallery_path + file_large
					obj.large.alt = caption

					obj.caption = caption

					return obj
				}


				function generateDownloads ()
				{
					node = document.getElementById('downloads')
					
					for ( i = 0; i < gallery.length; i++ )
					{
						li = document.createElement('li')
						text = document.createTextNode(gallery[i].text)
						link = document.createElement('a')
						link.setAttribute('href', gallery[i].large.src)
						link.setAttribute('onMouseOver', 'previewGallery(' + i + ')')
						link.appendChild(text)
						li.appendChild(link)
						node.insertBefore(li, node.lastChild)
					}
				}


				function generateSubMenu (id, content, imageID)
				{
					node = document.getElementById('submenu')
					content = convertEntitiesToUnicode(content)
					
					li = document.createElement('li')
					text = document.createTextNode(content)
					link = document.createElement('a')
					if ( imageID > -1 )
						link.setAttribute('href', 'javascript:go("gallery", '+imageID+')')
					else
						link.setAttribute('href', 'javascript:show('+id+')')
				//	link.setAttribute('onMouseOver', 'previewGallery(' + i + ')')
					link.appendChild(text)
					li.appendChild(link)
					node.insertBefore(li, node.lastChild)

				}


				function jogGallery(direction) {
					if ( !gallery )
						return
					if ( !gallery_target)
						return
					if ( gallery.length < 1 )
						return
						
					gallery_current += direction
					if (gallery_current < 0 ) gallery_current += gallery.length
					if (gallery_current >= gallery.length ) gallery_current = 0

					eval(gallery_target + ".src = gallery[gallery_current].thumb.src")
					eval(gallery_target + ".alt = gallery[gallery_current].thumb.alt")
					setContent('gallery_caption',gallery[gallery_current].caption.toUpperCase())
				}


				function previewGallery(gallery_current) {
					eval(gallery_target + ".src = gallery[gallery_current].thumb.src")
					eval(gallery_target + ".alt = gallery[gallery_current].thumb.alt")
					window.status = gallery[gallery_current].thumb.alt

					if ( document.getElementById('gallery_caption'))
					{
						setContent('gallery_caption',gallery[gallery_current].caption.toUpperCase())
					}
				}
				
				
				find = new Array()
				replace = new Array()

				find[0] = "<br>"
				replace[0] = " "
				find[1] = "&amp;"
				replace[1] = "&"


				function enlargeGallery() {
					caption = gallery[gallery_current].caption
					for ( i = 0; i < find.length; i++ )
					{
	//		internet explorer on a mac doesnt like 'm' in regex
	//					myregexp = new RegExp(find[i], "igm")
						myregexp = new RegExp(find[i], "ig")
						caption = caption.replace(myregexp, replace[i])
					} 					
					openWindow(gallery[gallery_current].large.src, 468, 546, false, caption)
				}


				function enlargeShop() {
					caption = gallery[gallery_current].caption
					for ( i = 0; i < find.length; i++ )
					{
						myregexp = new RegExp(find[i], "ig")
						caption = caption.replace(myregexp, replace[i])
					} 					
					openWindow(people[gallery_current].large.src, 468, 546, false, caption)
				}


				ph = 660
				pw = 468
				pha = 514	//	78%
				pwa = 364
				pm = 32
				phm = ph+pm
								
//	the margin in safari & msie5mac is too small
//	+22 safari
//	+16 msie5mac
				
				if ( screen.availHeight )
				{
					if ( screen.availHeight < ph )
					{
						ph = pha
						pw = pwa
					}
				}
				

				function enlargePoster(file, caption, date) {
					if (browser.isIE && browser.isMac)
						phm = ph + pm + 16
						
					if (browser.isIE && browser.isWin)
						phm = ph + pm + 32
						
					if ( browser.isSafari )
						phm = ph + pm + 22
					
					for ( i = 0; i < find.length; i++ )
					{
						myregexp = new RegExp(find[i], "ig")
						caption = caption.replace(myregexp, replace[i])
					}
					
					content = "<html><head><title>"
					content += date + " " + caption
//					content += "</title><link href='/xmedia/css/default.css' rel='stylesheet' type='text/css'></head>"
					content += "</title><style>td {	font-family : helvetica, arial, sans-serif; font-size : 11px; line-height: 16px; color : #656565 }</style></head>"
					content += "<body topmargin=0 bottommargin=0 rightmargin=0 leftmargin=0 marginwidth=0 marginheight=0>"
					content += "<table border=0 cellspacing=0 cellpadding=0 height=" + (ph+pm) + "><tr height=" + ph + "><td valign='top' height=" + ph + ">"
					content += "<img alt='"
					content += date + " " + caption
					content += "' border=0 width=" + pw + " height=" + ph + " src='"
					content += file
					content += "'></td></tr><tr height=" + pm + "><td valign='center' height=" + pm + ">"
					content += " . <strong>"
					content += date
					content += "</strong> "
					content += caption
					content += "</td></tr></table></body></html>"
					
					openWindow(content, pw, phm, false, date + " " + caption)
				}


				function setContent(which, content) {
					document.getElementById(which).innerHTML = content
				}


			nav_path = '/xmedia/nav/'

			function nav(which, how, event) {

				img = document.images[which]
				img.src = nav_path + which + '_' + how + '.gif'
				
				if (browser.isIE && browser.isMac)
					img.blur()
			}


			function pad(num) {
				if ( num < 10 ) return '0' + num
				else return num
			}


			function unhideEmail(email, inline) {
				//	v0.3

				//	array of things to find
				find = new Array()
				replace = new Array()

				find[0] 	= "\\s*\\[\\s*dot\\s*\\]\\s*"
				replace[0] 	= '.'
				find[1] 	= "\\s*\\[\\s*at\\s*\\]\\s*"
				replace[1] 	= '@'

				for ( i = 0; i < find.length; i++ ) {
					eval("regexp = /" + find[i] + "/ig")
					email = email.replace(regexp, replace[i])
				}

				if(inline)
					return email
				else {
					if ( email.indexOf('mailto') < 0 ) 
						email = 'mailto:'  + email
					location.href = email
				}
			}


			function checkEmailForm(that) { 
				if(that.elements.required.value == '')
					return false

				err = new Array()
				err.length = 0

				req = that.elements.required.value.split(',')

				for ( i = 0; i < that.elements.length; i++ )
					for ( j = 0; j < req.length; j++ )
						if(that.elements[i].name == req[j])
							if(that.elements[i].value == '')
								err[err.length] = req[j]

				if(validEmail(that.elements.username,'email'))
					err[err.length] = validEmail(that.elements.username,'email')

				if( err.length > 0 ) {
					msg = 'The following fields are required :'
					for ( i = 0; i < err.length; i++ )
						msg += '\n - ' + err[i]
					alert(msg)
					return false
				}
				else
					that.submit()
			}


			function bugReport() {
				url_report = 'http://isEngine.net/bugreport.shtml'
				url_target = location.href
				url_window = url_report + '?' + url_target
				openWindow(url_window,400,300,true)
			}



			function generateNav (nom)
			{
				obj = new Object()
				obj.name = nom
				
				obj.on = new Image()
				obj.on.src = nav_path + nom + "_on.gif"
				obj.off = new Image()
				obj.off.src = nav_path + nom + "_off.gif"
				obj.over = new Image()
				obj.over.src = nav_path + nom + "_over.gif"
				
				return obj
			}
			

			function loadNav ()
			{
				nav = new Object()
				nav.buttons = new Array()
				nav.enlarge = generateNav("enlarge")
				nav.next = generateNav("next")
				nav.back = generateNav("back")
				nav.play = generateNav("play")
				nav.hi = generateNav("hi")
				nav.lo = generateNav("lo")
			}

			
			function switchNav(which, way)
			{
				that = document.images[which]				
				that.src = eval("nav." + which + "." + way + ".src")
				if (browser.isIE && browser.isMac)
					that.blur()
			}	

			
			function enlargeMovie()
			{
				content = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'> <html> <head> <title>Sydney Dance Company</title> <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'> </head> <body bgcolor='#000000' leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>"
				content += "<embed src='" + movie.selected.src + "' width='" + movie.selected.width + "' height='" + movie.selected.height + "' autostart='true' autoplay='true' controller='true' controls='true' enablejavascript='true' kioskmode='true' > </embed> </body> </html>"
				openWindow(content, movie.selected.width, movie.selected.height, false, "Sydney Dance Company")
//				openWindow(movie.selected.src, , )
			}


			function playMovie()
			{
				openWindow(movie.selected.src, movie.selected.width, movie.selected.height)
			}


			function switchMovie(which)
			{
				movie.selected = eval("movie." + which)
		/*		switchNav(which,"on");
				if (which == "lo" )
					switchNav("hi","off");
				else					
					switchNav("lo","off");
			*/
			}
			
			
			function getXYOffset ()
			{
				if (self.pageYOffset) // all except Explorer
				{
					x = self.pageXOffset;
					y = self.pageYOffset;
				}
				else if (document.documentElement && document.documentElement.scrollTop)
				// Explorer 6 Strict
				{
					x = document.documentElement.scrollLeft;
					y = document.documentElement.scrollTop;
				}
				else if (document.body) // all other Explorers
				{
					x = document.body.scrollLeft;
					y = document.body.scrollTop;
				}

				return [x,y]
			}


			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
