/** Adds a trim function to the String class. */

String.prototype.trim = function() {
  var x=this;

  x=x.replace( /^\s*/, "" );
  x=x.replace( /\s*$/, "" );

  return x;
}

/** Function to generate popup windows. */

function launch(url, options) { 
	window.name = "opener";
	var remote = open(url, "remote", options);
}

function launchCentered( url, windowOptions, popupWidth, popupHeight ) {

	var leftOffset = ( screen.width - popupWidth ) / 2;
	var topOffset = ( screen.height - popupHeight ) / 2;

	if ( windowOptions != "" )
		windowOptions += ",";
		
	windowOptions += "top=" + topOffset + ",left=" + leftOffset + ",width=" + popupWidth + ",height=" + popupHeight;
	
	launch( url, windowOptions );
} 

/** Check that at least 1 item from the select list has been chosen. (assumes selectIndex 0 
corresponds to the --- Choose One --- option and is thus invalid. */

function validateFormSelection( myForm, mySelectList )
{
	// myForm.ID = spouse selection from drop-list
	if ( mySelectList.selectedIndex == 0 ) {
		alert( "Please choose an item from the list." );
	}
	else {
		myForm.submit();
	}
}
