<!--
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Project Name: Bahasa Indonesia Dictionary
// Directory:    bahasa/web
// File Name:    bahasa.js  
// Author(s):    John L. Whiteman
// Created:      June 23, 2003
// Modified:     October 16, 2003
// Description:  This file contains various javascript routines used 
//               throughout the website.
//
// Copyright (c) 2003 John L. Whiteman
//
// Permission is herby granted, free of charge, to any person obtaining a
// copy of this software, data, and associated documentation files
// (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHERE IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING IN THE SOFTWARE.
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
//This function checks if string token appears to be a valid e-mail 
//address.  It's does a pretty good job, but it's not perfect.
//Returns false if not valid otherwise true if valid.
//////////////////////////////////////////////////////////////////////////////
function is_email(token) {

	var regexp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

	if (regexp.test(token)) return(true);

	return(false);
}
//////////////////////////////////////////////////////////////////////////////
//This function checks if string token contains only white spaces or null.
//Returns false if not whitespace otherwise returns true if whitespace.
//////////////////////////////////////////////////////////////////////////////
function is_white_space(stoken) {

	if (stoken == null) return(true);

	if (stoken == '') return(true);

	if (stoken == "") return(true);

	return(false);
}
//////////////////////////////////////////////////////////////////////////////
//This function replaces both leading and trailing whitespaces from the 
//given token and returns the trimmed token to the caller.
//////////////////////////////////////////////////////////////////////////////
function trim(stoken) {

	if (is_white_space(stoken)) {

		return(stoken);
	}

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

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

	return(stoken);
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// -->
