if (document.cookie.indexOf("resize=1") == -1) window.resizeTo(1024, 768); 
//expiryDate = ';expires="Thursday, 01-Dec-11 12:00:00 GMT"';//
document.cookie = 'resize=1';// + expiryDate;


im_path = "im/";
ub = 0; //default no up button
var blink_cnt = 0;

buttons1 = new Array('but_email')
buttons2 = new Array('but_1', 'but_2', 'but_3', 'but_prev', 'but_next')
buttons3 = new Array('map1_richard')

function gload(arr)
{
  im = new Array()
  for (n=0; n<arr.length; n++)
  {
    im[n] = new Image()
    im[n].src = im_path + arr[n] + "_f2.gif"
  }
}

function jload(arr)
{
  im = new Array()
  for (n=0; n<arr.length; n++)
  {
    im[n] = new Image()
    im[n].src = im_path + arr[n] + "_f2.jpg"
  }
}

function gmover(id, page_id)
{
  im = id + page_id
  document.images[im].src = im_path + id + "_f2.gif"
}

function gmout(id, page_id)
{
  im = id + page_id
  document.images[im].src = im_path + id + ".gif"
  restore_up_button()
}

function jmover(id, page_id)
{
  im = id + page_id
  document.images[im].src = im_path + id + "_f2.jpg"
}

function jmout(id, page_id)
{
  im = id + page_id
  document.images[im].src = im_path + id + ".jpg"
  restore_up_button()
}

function jmover2(id, page_id)
{
//  im = id + page_id
  document.images[page_id].src = im_path + id + "_f2.jpg"
}

function jmout2(id, page_id)
{
  im = id + page_id
  document.images[page_id].src = im_path + id + ".jpg"
//  restore_up_button()
}

function restore_up_button()
{
  if (ub) document.images[up_button].src = im_path + up_button + "_f3.jpg"
}

//-------- check relatedTarget

function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

function checkMouseEnter (element, evt) {
  if (element.contains && evt.fromElement) {
    return !element.contains(evt.fromElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

function checkMouseLeave (element, evt) {
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}
//-------- /check relatedTarget


//----- fade in/out divs

function SetOpacity(elem, opacityAsInt)
{
	var opacityAsDecimal = opacityAsInt;
	
	if (opacityAsInt > 100)
	opacityAsInt = opacityAsDecimal = 100; 
	else if (opacityAsInt < 0)
	opacityAsInt = opacityAsDecimal = 0; 
	
	opacityAsDecimal /= 100;
	if (opacityAsInt < 1)
	opacityAsInt = 1; // IE7 bug, text smoothing cuts out if 0
	
	elem.style.opacity = (opacityAsDecimal);
	elem.style.filter  = "alpha(opacity=" + opacityAsInt + ")"; 
}

fadeInPattern = new Array(20, 30, 40, 50, 55, 60, 65, 70, 75, 80, 85, 90, 90, 90, 90);
fadeOutPattern = new Array(90, 87, 85, 80, 73, 65, 57, 50, 40, 30, 20, 10, 0, 0, 0);
//fadeOutPattern = new Array(80, 60, 45, 35, 28, 22, 17, 13, 10, 5, 0, 0, 0 ,0 ,0);
var fade_opacity_steps = 15; // length of above arrays

var fade_opacity_stepNum = new Array();
var fade_opacity_inOut = new Array();

function FadeOpacityStep(elemId)
{
	stepNum = fade_opacity_stepNum[elemId];
	inOut = fade_opacity_inOut[elemId];
	
	if (inOut == "in") 
	{
		document.getElementById(elemId).style.visibility = "visible";
		SetOpacity(document.getElementById(elemId), fadeInPattern[stepNum]); 
		stepNum++;
		fade_opacity_stepNum[elemId] = stepNum;
		if (stepNum < fade_opacity_steps) setTimeout("FadeOpacityStep('" + elemId + "')", 30); 
		else fade_opacity_stepNum[elemId] = 0;
	}
	
	if (inOut == "out") 
	{
		SetOpacity(document.getElementById(elemId), fadeOutPattern[stepNum]); 
		stepNum++;
		fade_opacity_stepNum[elemId] = stepNum;
		if (stepNum < fade_opacity_steps) setTimeout("FadeOpacityStep('" + elemId + "')", 30); 
		else
		{
			document.getElementById(elemId).style.visibility = "hidden";
			fade_opacity_stepNum[elemId] = 0;
		}
	}
}

function Fade(elemId, inOut) 
{ 
	var fading_in_progress = 0;
	if (fade_opacity_stepNum[elemId] || fade_opacity_inOut[elemId] == inOut) fading_in_progress = 1; //part way through step sequence or already faded that way
	
	if (!fade_opacity_stepNum[elemId]) fade_opacity_stepNum[elemId] = 0; //definitely to zero (might be undefined as yet);

	//check if reversed fading direction while fading - if so adjust stepNum accordingly to start at opposite end of other array
	if (fading_in_progress && fade_opacity_inOut[elemId] != inOut)
	{
		fade_opacity_stepNum[elemId] = fade_opacity_steps - fade_opacity_stepNum[elemId];
	}
	fade_opacity_inOut[elemId] = inOut; //remember requested state
	
	if (!fading_in_progress) FadeOpacityStep(elemId); 
}

//----------- /fade in/out divs
