var imgExtensions = ["_top", "", "_angl"];

var xOffset = 0; var yOffset = -70;
var divXloc, divYloc;

function getLoc(evt) {
	
	divXloc = mouseX(evt);
	divYloc = mouseY(evt);
	
	if (divXloc < _minXPos || divXloc > _maxXPos) {
			hidePop(500);
		}
	
	return false;
}

// modified by jheinrichs@hansondodge.com 03.22.06
// Simple follow the mouse script
// copyright Stephen Chapman, 30th September 2005
// you may copy this script provided that you retain the copyright notice

function mouseX(evt)
{
	if (!evt) evt = window.event;
	
	if (evt.pageX) return evt.pageX; 
	
	else if (evt.clientX) return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); 

	else return 0;
} 

function mouseY(evt) 
{
	if (!evt) evt = window.event;
	
	if (evt.pageY) return evt.pageY;

	else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);

	else return 0;
}


function seriesPop(whichSeries) {
	var currentDiv;
	var whichDiv = document.getElementById(whichSeries);

	if ((whichSeries != currentSeries) && (currentSeries != "")) {
		currentDiv = document.getElementById(currentSeries);
		currentDiv.style.display = "none";
	}
	
	whichDiv.style.display = "block";
	
	whichDiv.style.left = divXloc + "px";
	whichDiv.style.top = divYloc + "px";
	//If the mouse is on the lower half of the screen, make up pop above the mouse instead of below.
	if ((divYloc - $(window).scrollTop()) > $(window).innerHeight()/2) {
		whichDiv.style.top = 'auto';
		whichDiv.style.top = (divYloc - whichDiv.offsetHeight) + "px";
	}
	currentSeries = whichSeries;
}
/*
function hidePop(whichSeries) {
	var whichDiv = document.getElementById(whichSeries);
	
	whichDiv.style.display = "none";
	currentSeries = "";
}
*/
// End Stephen Chapman script

function changeCategoryBorder(whichBox, onORoff) {
	var onColor = "#B0232A";
	var offColor = "#963";
		
	color = onORoff ? onColor : offColor;

	obj = document.getElementById(whichBox);
	obj.style.borderColor = color;
}

function changePopupItemBorder(whichBox, onORoff) {
	var onColor = "#9B4D1B";
	var offColor = "#E5D2B8";
		
	var bgonColor = "#F9EEDF";
	var bgoffColor = "#F1E3CF";
		
	color = onORoff ? onColor : offColor;
	bgcolor = onORoff ? bgonColor : bgoffColor;

	obj = document.getElementById(whichBox);
	obj.style.borderColor = color;
	obj.style.backgroundColor = bgcolor;
}

function showBoat(whichBoat) {
	var oldBoat = document.getElementById(currentBoat);
	var newBoat = document.getElementById(whichBoat);
	
	oldBoat.style.display = "none";
	newBoat.style.display = "block";
	
	currentBoat = whichBoat;
}
function extrasportPopup() {
	if ((this.wind == null) || (this.wind.closed)) 
		this.wind = window.open("/extrasportDemo.html","Demo","resizable=0,toolbar=0,scrollbars=0,width=500,height=400");
	else
		this.wind.focus();
}

function cayugaPopup() {
	if ((this.wind == null) || (this.wind.closed)) 
		this.wind = window.open("/cayuga.html","cayuga","resizable=0,toolbar=0,scrollbars=0,width=960,height=544");
	else
		this.wind.focus();
}

function enlargePopup() {
	var whichImage = imgBase + currentBoat + currentAngle[currentBoat] + "_lg.jpg";
	// window.alert(imgBase + currentBoat + currentAngle + "_sm.jpg");
	if ((this.wind == null) || (this.wind.closed)) 
		this.wind = window.open("/popup.html?boat=" + currentBoat + "&angle=" + currentAngle[currentBoat], "PhotoViewer", "resizable=0, toolbar=0, scrollbars=0, width=756 , height=318");
	else
		this.wind.location = "/popup.html?boat=" + currentBoat + "&angle=" + currentAngle[currentBoat];	
		this.wind.focus();
}

function changeAngle(whichAngle) {
	var photoHref = document.getElementById("angleLink" + currentAngle[currentBoat]);
	photoHref.style.textDecoration = "underline";
	
	photoHref = document.getElementById("angleLink" + whichAngle);
	photoHref.style.textDecoration = "none";

	document[currentBoat + "_photo"].src = imgBase + currentBoat + imgExtensions[whichAngle] + "_sm.jpg";
	
	currentAngle[currentBoat] = whichAngle;
}