<!--
var mail2 = "mailto:";
var user2 = "gerald";
var at2 = "@"
var domain2 = "nature";
var suffix2 = "gov.ck";

var maximumSearchTerms = 5;

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function showImage(url, width, height, title) {
	var win=window.open("showImage.asp?file="+url+"&title="+title+"&height="+height+"&width="+width,"","height="+(height+20)+",width="+width+",scrollbars=no,toolbar=no,resizable=yes,status=no,top=200,left=300")
	//win.document.write("<html><head><title>"+title+"</title></head><body onResize='document.getElementById(\"theImage\").width=window.width;' style=\'padding:0; margin:0;'><img id='theImage' alt='"+title+"' src='"+url+"'></img></body></html>")
}
function showHide(tbl) {
	//alert(document.getElementById(tbl).style.display);
	if(document.getElementById(tbl).style.display=='none' || document.getElementById(tbl).style.display==''){
		document.getElementById(tbl).style.display='block';} 
	else { document.getElementById(tbl).style.display='none';}; 
	return false;
}

function checkSearch(showAdv)
{

	var strSrch=document.getElementById("ebg").value;
	var errorFlag = false;
	var errorMessage = "";
	
	//first check to see if any of the form menus and tick boxes have been changed from defaults
	// (document.getElementById("nameset").selectedIndex!=0) || 
	
	var formModified = false;
	if(
	(document.getElementById("BiologicalGroup").selectedIndex!=0) || 
	(document.getElementById("Country").selectedIndex!=0) || 
	(document.getElementById("Origin").selectedIndex!=0) || 
	(document.getElementById("Habitat").selectedIndex!=0) || 
	(document.getElementById("Area").selectedIndex!=0) || 
	(document.getElementById("PosSig").selectedIndex!=0) || 
	(document.getElementById("NegSig").selectedIndex!=0) || 
	(document.getElementById("Endangered").selectedIndex!=0) || 
	(document.getElementById("mmSound").checked) || 
	(document.getElementById("mmVideo").checked) || 
	showAdv)
	{
		formModified = true;
	}
	if(strSrch!="") {
		var aryCount = 0;
		
		// Added by JM 28/08/2005 - Trim off end blank of search terms
		strSrch = trim(strSrch);
		
		if(strSrch[strSrch.length -1] == ";") {
			strSrch = strSrch.slice(0, strSrch.length - 1);
		};
		///////
		
		var arySrch=strSrch.split(";");
		
		//////Added by JM 28/08/2005 - Limit the number of ; separated search terms	
		if(arySrch.length > maximumSearchTerms) {
			alert("Please limit the number of search items to a maximum of " + maximumSearchTerms + " per search.");
			return false;
		}
		//////////////
		
		for (var i=0;i<arySrch.length;i++) {
			if(trimString(arySrch[aryCount]).length < 2) {
				errorFlag = true;
				errorMessage = "One or more of your search terms are too short.\n - Search terms in the names field must be more than one character.";
			}
			aryCount++;
		}
	}
	else {
		if(!formModified) {
			errorFlag = false;
			//errorMessage = "To perform a search you need to:\n - Enter a name or names to search for\n OR \n - Apply at least one Search Option (excluding the multimedia options).";
		}
	}
	if(errorFlag) {
		alert(errorMessage);
		return false;
	}					
	else {
		return true;
	}
}

function trimString (str) {
  while (str.charAt(0) == ' ')
	str = str.substring(1);
  while (str.charAt(str.length - 1) == ' ')
	str = str.substring(0, str.length - 1);
  return str;
}
// ----------------------------------------------
// StyleSwitcher functions written by Paul Sowden
// http://www.idontsmoke.co.uk/ss/
// - - - - - - - - - - - - - - - - - - - - - - -
// For the details, visit ALA:
// http://www.alistapart.com/stories/alternate/

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;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

//-->
