// JavaScript Document
var popUpWin;
function popUpWindow(URLStr, wd, ht, txt, gpT) {
	var left = 20;
	var top = 20;
	wd+=20;
	ht+=42;
	var myBars = 'directories="no",location="no",menubar="no",status="yes"';
	myBars += ',titlebar="no",toolbar=no"';
	var myOptions = 'height='+ht+', width='+wd+' ,left='+left+', top='+top+', screenX='+left+', screenY='+top+', scrollbars="no", copyhistory="yes", resizable="no"';
	var myFeatures = myBars + ',' + myOptions;
	popUpWin  = parent.document.open("","PopWin",myFeatures);
	if (URLStr.length>0) {
		popUpWin.document.write('<HEAD><TITLE>'+txt+' - www.dartboat.com</TITLE></HEAD><BODY  bgcolor="whitesmoke" onclick="self.close()"><IMG border="1px" alt="'+txt+'" style="cursor:hand" id="popImg" SRC="'+URLStr+'"><table width="100%"><tr><td style="letter-spacing:2px;font-size:xx-small;color:indigo;font-family:arial" align="left">'+gpT+' '+txt+'</td><td style="font-size:xx-small;color:blue;font-family:Arial, Helvetica, sans-serif;" align="right">[ close ]</td></tr></table></BODY>');
	} else {
		popUpWin.document.write('<HEAD><TITLE>'+txt+' - Falcon</TITLE></HEAD><BODY  bgcolor="whitesmoke" onclick="self.close()"><IMG border="1px" alt="'+txt+'" style="cursor:hand" id="popImg" SRC="./explore.jpg"><table width="100%"><tr><td style="letter-spacing:2px;font-size:xx-small;color:indigo;font-family:arial" align="left">'+gpT+' '+txt+'</td><td style="font-size:xx-small;color:blue;font-family:Arial, Helvetica, sans-serif;" align="right">[ close ]</td></tr></table></BODY>');
	}
	popUpWin.document.close();
	popUpWin.status = gpT;
	popUpWin.focus();
}

function topNavMouseOut1(argID,argColourCode)
{
var strClassString = ''; 
if(argColourCode == 'selected'){
strClassString = "bgTopNav" + argID;
strClassString="document.getElementById('"+argID+"').className='"+strClassString+"'";}
else{
strClassString = "topNav";
strClassString="document.getElementById('"+argID+"').className='"+strClassString+"'";} 
eval(strClassString);
}
function topNavMouseOver1(argID)
{
var strClassString = "bgTopNav" + argID;
strClassString="document.getElementById('"+argID+"').className='"+strClassString+"'";
//alert(strClassString);
eval(strClassString);
}
function cssHorScrolls(val){
document.body.style.overflowX = val;
}
function loadPg(ref) {
	this.ref = ref;
	var arrPages = new Array();
	arrPages['tblExploring'] = "explore.htm";
	arrPages['tdExplore'] = "explore.htm";
	arrPages['tblDiving'] = "diving.htm";
	arrPages['tdDiving'] = "diving.htm";	
	arrPages['tblSkipper'] = "skipper.htm";
	arrPages['tblHome'] = "home.htm";
	arrPages['tdArea'] = "area.htm";
	arrPages['tdHome'] = "home.htm";
	arrPages['tdContact'] = "contact.htm";	
	arrPages['tdSitemap'] = "admin.hm";	
	document.location.href = arrPages[this.ref];
}
function firstFocus() {
	if (document.forms.length > 0) {
	var field = document.forms[0];
	for (i = 0; i < field.length; i++) {
	if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
	document.forms[0].elements[i].focus();
	break;
			 }
		  }
	   }
	   if (location.search) {
			var loc = location.search;
			var qValAr = loc.split("=");
			var searchText = qValAr[1];
			var highlightStartTag = "<span class='hilite'>";
			var highlightEndTag = "</span>";
			highlightSearchTerms(searchText,highlightStartTag,highlightEndTag);
		}
}

/*
 * This is the function that actually highlights a text string by
 * adding HTML tags before and after all occurrences of the search
 * term. You can pass your own tags if you'd like, or if the
 * highlightStartTag or highlightEndTag parameters are omitted or
 * are empty strings then the default <font> tags will be used.
 */
function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag) 
{
  // the highlightStartTag and highlightEndTag parameters are optional
  if ((!highlightStartTag) || (!highlightEndTag)) {
    highlightStartTag = "<font style='color:blue; background-color:yellow;'>";
    highlightEndTag = "</font>";
  }
  
  // find all occurences of the search term in the given text,
  // and add some "highlight" tags to them (we're not using a
  // regular expression search, because we want to filter out
  // matches that occur within HTML tags and script blocks, so
  // we have to do a little extra validation)
  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();
    
  while (bodyText.length > 0) {
    i = lcBodyText.indexOf(lcSearchTerm, i+1);
    if (i < 0) {
      newText += bodyText;
      bodyText = "";
    } else {
      // skip anything inside an HTML tag
      if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
        // skip anything inside a <script> block
        if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
          newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
          bodyText = bodyText.substr(i + searchTerm.length);
          lcBodyText = bodyText.toLowerCase();
          i = -1;
        }
      }
    }
  }
  
  return newText;
}


/*
 * This is sort of a wrapper function to the doHighlight function.
 * It takes the searchText that you pass, optionally splits it into
 * separate words, and transforms the text on the current web page.
 * Only the "searchText" parameter is required; all other parameters
 * are optional and can be omitted.
 */
function highlightSearchTerms(searchText, highlightStartTag, highlightEndTag)  {

  var bodyText = document.body.innerHTML;
  bodyText = doHighlight(bodyText, searchText, highlightStartTag, highlightEndTag);
  document.body.innerHTML = bodyText;
  return true;

}
