function writeDate() {
  todaysDate = new Date()
  days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
  thisDay = days[todaysDate.getDay()]
  thisDate = todaysDate.getDate()
  ending = "th"
  if(thisDate==1 || thisDate==21 || thisDate==31) ending = "st"
  if(thisDate==2 || thisDate==22) ending = "nd"
  if(thisDate==3 || thisDate==23) ending = "rd"
  months = new   Array("January","February","March","April","May","June","July","August","September","October","November","December")
  thisMonth = months[todaysDate.getMonth()]
  thisYear = todaysDate.getFullYear()
  document.writeln(thisDay+" "+thisDate+ending+" "+thisMonth+", "+thisYear+"<br>")
}

function gohash()
{
  location.hash = "view"
}

preload_array = new Array('but_home_f2.gif', 'but_artists_f2.gif', 'but_exhibition_f2.gif', 'but_contact_f2.gif', 'but_enter_ex_f2.gif', 'but_next_f2.gif', 'but_prev_f2.gif', 'but_index_f2.gif')

out_array = new Array('but_home', 'but_artists', 'but_exhibition', 'but_contact', 'but_enter_ex', 'but_next', 'but_prev', 'but_index')


var t2 = 0

function preload()
{
return
  im = new Array()
  for (n=0; n<preload_array.length; n++)
  {
    im[n] = new Image()
    im[n].src = im_path + preload_array[n]
  }
}


function out(mode)
{
  clearTimeout(t2)
  for (n=0; n<out_array.length; n++)
  {
    if (document.images[out_array[n]]) document.images[out_array[n]].src = im_path + out_array[n] + ".gif"
  }
  if (mode == "reshow") show_button()
}

function over(but)
{
  out() //clear all over images first in case being shown by show_button
  document.images[but].src = im_path + but + "_f2.gif"
}


var win1

function newWin(url,w,h) {
if (win1 && win1.open || win1 && !win1.closed){win1.close()}
win1 = window.open(url,"win1","width="+w+",height="+h+",toolbar=no,location=no,menubar=no,status=no,scrollbars=no,resizable=yes")
}

//--------------------------------------------------------  Expand DIV
var exp_div_moving = new Array();
var exp_offsetHeights = new Array();
var changeTextArr1 = new Array();
var changeTextArr2 = new Array();
var scrolledAlready = 0;
var screenHeight = 0;
var y_offset = 0;
var using_buttons = 0;
var more_button = 'im/show_div.gif'
var less_button = 'im/hide_div.gif'

function changeText (obj, newTextStr) 
{
	if (changeTextArr2[obj.id])
	{
		obj.innerHTML = changeTextArr1[obj.id]; //already displaying newTextStr so go back to showing original str
		changeTextArr2[obj.id] = 0; //unset flag
	}
	else
	{
		changeTextArr1[obj.id] = obj.innerHTML; //store away original textStr for retrieval when re-clicking
		obj.innerHTML = newTextStr; //show newTextStr
		changeTextArr2[obj.id] = 1; //set flag to remember we did this
	}
}


function uncover (div_id, linkId, linkTxt)
{
	changeText (linkId, linkTxt);
	expand_div (div_id, 15); //offset of 15 applied to all sliding divs
}

//*|*

function init_expanding_divs()
{ /* used to capture full div heights before zapping them to 1 to prevent unsightly blank space below page content */
	args = init_expanding_divs.arguments;
	for (n = 0; n< args.length; n++)
	{
		div_id = args[n];
		elem = document.getElementById(div_id);
//		alert(elem)
		exp_offsetHeights[div_id] = parseInt(elem.offsetHeight);
//		alert(exp_offsetHeights[div_id]);		
		elem.style.height = 1;
//		alert(elem.style.height);
	}
}

function expand_div(div_id)
{
	//vars and arguments
	expanded_height = exp_offsetHeights[div_id]; //height of div when shown fully - array element remembers this between calls
	mode = expand_div.arguments[2];
	if (expand_div.arguments[1]) y_offset = expand_div.arguments[1];
	elem = document.getElementById(div_id);
	if (using_buttons) button = document.getElementById("but_"+div_id);
	
	//initial entry into function - no mode defined
	if (!mode) //&& !exp_div_moving[div_id]
	{
		screenHeight = getScreenHeight()
		if (elem.style.visibility == "visible") mode = "c"; else mode = "e"; //collapse if currently visible, else expand
		if (!exp_offsetHeights[div_id]) exp_offsetHeights[div_id] = parseInt(elem.offsetHeight); //initialise height to expand to - and remember this - height only registered when DIV is relative, not absolute (or something...)
		expanded_height = exp_offsetHeights[div_id];
		scrolledAlready = 0;
		exp_div_moving[div_id] = 1; //signify moving
		
		if (mode == "e")
		{
			elem.style.height = '0px';
			elem.style.position='relative';
			elem.style.visibility='visible';
			if (using_buttons) button.src = less_button;
		}		
		if (mode == "c")
		{
			if (!isNaN(elem.style.height)) elem.style.height = expanded_height; //jump start elem.style-height if initially starting expanded and collapse is first operation - otherwise the current_height line below gets NaN
			if (using_buttons) button.src = more_button;
		}			
	}
	
	if (mode == "e") move_inc = 15; else move_inc = -20;
	current_height = parseInt(elem.style.height);
	current_height += move_inc;

	if (mode == "e" && current_height > expanded_height) //stop expanding
	{
		elem.style.height = expanded_height + "px";
		exp_div_moving[div_id] = 0; //stop moving
	}
	else	if (mode == "c" && current_height < 0) //stop collapsing
	{
		elem.style.height = "0px";
		elem.style.position="absolute"
		elem.style.visibility="hidden"
		exp_div_moving[div_id] = 0; //stop moving
	}
	else if (mode == "c" || mode == "e") //expand or collapse
	{
		elem.style.height = current_height + 'px';
		t1 = setTimeout("expand_div('"+div_id+"', '', '"+mode+"')", 10);
		
		//scroll screen down while expanding if bottom of div disappears off bottom of page. Stop scrolling before top disappears though.
		if (mode == "e" && ((mouseY + y_offset + current_height + move_inc) > screenHeight && (mouseY - scrolledAlready - move_inc) > 0))
		{
			new_scroll_position = getScrollPosition() + move_inc
			window.scroll(0, new_scroll_position);
			scrolledAlready += move_inc;
		}
	}
}

var mouseY = 0;

function getMouseCoords(e) 
{
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (0) //e.pageX || e.pageY) 	
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	
	{
		posx = e.clientX // + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = e.clientY // + document.body.scrollTop + document.documentElement.scrollTop;
	}
	mouseY = posy;
}


function getScrollPosition()
{
	pos = window.pageYOffset || document.body.scrollTop || 0;
	return pos
}

function getScreenHeight()
{
	if (window.innerHeight) 
	{
		theHeight=window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		theHeight=document.documentElement.clientHeight;
	}
	else if (document.body) 
	{
		theHeight=document.body.clientHeight;
	}
	return theHeight
}

var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.ONCLICK)
document.onclick = getMouseCoords;

//--------------------------------------------------------