// -- Simplified Image Swap
function swap(imgName, imgSrc){
	document[imgName].src = imgSrc
}

// window popup
function popWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

// simple window popup
function simplePopup(theURL) {
  window.open(theURL,'window','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=760,height=450,left=10,top=10');
}

// prevent right clicking
function noRightClick() {
	var message=" All images and copy on this site are property of WSAFC.\n To request permission to use any of this site's content please contact:\n webmaster@wsafc.org.nz ";

	function click(e) {
	if (document.all) {
	   if (event.button == 2) {
		  alert(message);
	      return false;
	    }
	}

	if (document.layers) {
	   if (e.which == 3) {
		alert(message);
		return false;
	   }
    }
	}

    if (document.layers) {
      document.captureEvents(Event.MOUSEDOWN);
	}

    document.onmousedown=click;
}
// correct height of container elements
function setTall() {
	if (document.getElementById) {
		// read the height of each div element
		var contentHeight = document.getElementById('mainContent');
		var rightHeight = document.getElementById('rightSidebar');
		var leftHeight = document.getElementById('leftSidebar');
		var minHeight = 400;
		var maxElement = "";
		// see if the content div is the tallest and set the style.height of the other two accordingly
		if ((contentHeight.offsetHeight >= rightHeight.offsetHeight) && (contentHeight.offsetHeight >= leftHeight.offsetHeight) && (contentHeight.offsetHeight >= minHeight)) {
			minHeight = (contentHeight.offsetHeight-0) + 'px';
			//alert("contentHeight");
		}
		else if ((rightHeight.offsetHeight >= contentHeight.offsetHeight) && (rightHeight.offsetHeight >= leftHeight.offsetHeight) && (rightHeight.offsetHeight >= minHeight)) {
			minHeight = (rightHeight.offsetHeight-0) + 'px';
			//alert("rightHeight");
		}
		else if ((leftHeight.offsetHeight >= contentHeight.offsetHeight) && (leftHeight.offsetHeight >= rightHeight.offsetHeight) && (leftHeight.offsetHeight >= minHeight)) {
			minHeight = (leftHeight.offsetHeight-0) + 'px';
			//alert("leftHeight");
		}
		leftHeight.style.height = minHeight;
		contentHeight.style.height = minHeight;
		rightHeight.style.height = minHeight;
	}
}

window.onload = function() {
	setTall();
}

window.onresize = function() {
	//setTall();
}

function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}