


//browser detection
var nn4 = (document.layers) ? true : false 
var ie = (document.all) ? true : false 
var dom = (document.getElementById && !document.all) ? true : false 

function browser(id){
  if(nn4) {
  path = document.layers[id]
  }
  else if(ie) {
  path = document.all[id]
  } 
  else {
  path = document.getElementById(id)
  }
return path  //return the path to the css layer depending on which browser is looking at the page
}


//cursor position detection
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0

// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  //document.Show.MouseX.value = tempX
  //document.Show.MouseY.value = tempY
  return true
}


// Main function to retrieve mouse x-y pos.s
function getMouseY() {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
//    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
//    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  //if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  //document.Show.MouseX.value = tempX
  //document.Show.MouseY.value = tempY
  return tempX
}

// Main function to retrieve mouse x-y pos.s
function getMouseX() {
  if (IE) { // grab the x-y pos.s if browser is IE
//    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
//    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
 // if (tempX < 0){tempX = 0}
 if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  //document.Show.MouseX.value = tempX
  //document.Show.MouseY.value = tempY
  return tempY
}

function hideLayer(id) {

	layer = browser(id)
	
	   if(nn4){
	   layer.visibility = "hidden"
	   }
	   else{
	   layer.style.visibility = "hidden"
	   }
   
}

function showLayer(id) {

	layer = browser(id)
	   if(nn4){
	   layer.visibility = "visible"
	   }
	   else{
	   layer.style.visibility = "visible"
	   }
   
}


function moveLayer(id,y,x) {

var layer = browser(id) // get browser specific path to block element

   if(nn4){
   layer.top = x
   layer.left = y
   }
   else{
   layer.style.top = x
   layer.style.left = y
   }

} 

//shows a layer and moves it to the mouseposition
function showAndMoveLayer(id){
	showLayer(id)
	moveLayer(id,getMouseY(),getMouseX())

}


function hideLayers(){

hideLayer('click');
hideLayer('picture');

}

function setPicture(picture,source){
	document.getElementById(picture).src= source
}

function disableHREFandShowLayer(anchorID,layer,ref){
		
	setPicture("bigpic",getLargeImage(ref.src));
	document.getElementById(anchorID).href="javascript:showLayer('" + layer + "')"
}

function getLargeImage(imgURL){
	//return the same URL with _small removed - works with Frontpage Autothumbnail
	return imgURL.replace(/_small/,"")
}

function hideLayerClearPicture(layerName){

	setPicture("bigpic","images/white.gif");
	
	hideLayer(layerName);
	
}

