
function popupCenteredWindow(sUrl, lWidth, lHeight, sName, bScroll, bStatus){
	//	sURL	(URL of the page to open)
	//	lWidth	(width of the popup)
	//	lHeight	(height of the popup)
	//	sName	(name given to the window)
	//	bScroll	(allow scroll bars [yes|no|1|0])
	//	bStatus	(allow status bar [yes|no|1|0])
	lLeft = (window.screen.width/2) - ((lWidth/2) + 10); //half the screen width minus half the new window width (plus 5 pixel borders).
	lTop = (window.screen.height/2) - ((lHeight/2) + 30); //half the screen height minus half the new window height (plus title and status bars).
	newWin = window.open(sUrl, sName, "height=" + lHeight + ", width=" + lWidth + ", left=" + lLeft + ", top=" + lTop + ", screenX=" + lLeft + ", screenY=" + lTop + ", scrollbars=" + bScroll + ", status=" + bStatus);
	newWin.focus();
}


/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail Address, please review!")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail Address, please review!")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail Address, please review!")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail Address, please review!")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail Address, please review!")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail Address, please review!")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address, please review!")
		    return false
		 }

 		 return true					
	}


/* Client-side access to querystring name=value pairs
	Version 1.2.3
	22 Jun 2005
	Adam Vandenberg
*/
function Querystring(qs) { // optionally pass a querystring to parse
	this.params = new Object()
	this.get=Querystring_get
	
	if (qs == null)
		qs=location.search.substring(1,location.search.length)

	if (qs.length == 0) return

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

		if (pair.length == 2)
			value = unescape(pair[1])
		else
			value = name
		
		this.params[name] = value
	}
}

function Querystring_get(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null) default_ = null;
	
	var value=this.params[key]
	if (value==null) value=default_;
	
	return value
}


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 HTML special chars
	  if (bodyText.lastIndexOf(";", i) >= bodyText.lastIndexOf("&", i)) {
		// 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, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
  // if the treatAsPhrase parameter is true, then we should search for 
  // the entire phrase that was entered; otherwise, we will split the
  // search string so that each word is searched for and highlighted
  // individually
  var errs;
  if (treatAsPhrase) {
    searchArray = [searchText];
  } else {
    searchArray = searchText.split(" ");
  }
  
  if (!document.body || typeof(document.body.innerHTML) == "undefined") {
    if (warnOnFailure) {
      errs = "Sorry, for some reason the text of this page is unavailable. Searching will not work.";
    }
    return false;
  }
  
  var bodyText = document.body.innerHTML;
  for (var i = 0; i < searchArray.length; i++) {
    bodyText = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
  }
  
  document.body.innerHTML = bodyText;
  return true;
}

function geth(){

	var qs = new Querystring()
	var highlight = qs.get("highlight")
	if (highlight != null)
		if (highlight.length > 2)
			highlightSearchTerms(highlight, true);
	
	if(eval(document.searchform)) {
		document.searchform.searchStr.focus();
	}

	getFB();

}

function getFB() {
    var fbs;
    var myUrl;
    myUrl = document.URL;
    fbs = '<iframe src="http://www.facebook.com/plugins/like.php?href=' + encodeURIComponent(myUrl) + '&layout=standard&show_faces=true&width=450&action=like&colorscheme=light&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>';
    document.getElementById("fbLike").innerHTML = fbs;
}
