function externalLinks() { 
	if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("a"); 
	for (var i = 0; i < anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank"; 
		}
	}
}

function nav_over(element) {
	if (element.className == 'selected') return;
	element.className = 'over';
}

function nav_out(element) {
	if (element.className == 'selected') return;
	element.className = '';
}

function popup(pageUrl, width, height) {
	var left = screen.width / 2 - width / 2;
	var top = screen.height / 2 - height / 2;
	
	window.open(pageUrl, '', 'width=' + width + ',height=' + height + ',top=' + top + ',left=' + left + ",scrollbars=yes,resizable=no");
}

function is_numeric_string(validationString) {
	return validationString.match('^[0-9]+$');
}

// two string methods from http://www.ditchnet.org/wp/2005/04/04/i-want-my-javalang/

/**
 *  String convenience method to trim leading and
 *  trailing whitespace.
 *  @returns string
 */
String.prototype.trim = function() { 
	return this.replace(/^\s+|\s+$/g, '');
};

/**
 *  String convenience method for checking if the
 *  end of this string equals a given string.
 *
 *  @returns boolean
 *  @throws IllegalArgumentException for parameters
 *                          not of type String
 */
String.prototype.endsWith = function (s) {
    if ('string' != typeof s) {
        throw('IllegalArgumentException: Must pass a ' +
            ' string to String.prototype.endsWith()');
    }
    var start = this.length - s.length;
    return this.substring(start) == s;
};

// from http://www.irt.org/script/1621.htm

function wordcount(string) {
  var a = string.split(/\s+/g); // split the sentence into an array of words
  return a.length;
}
