/*{{{ CheckForm.js
 *
 * ver.0.2 - 20/01/2006
 *
 * :tabSize=4:indentSize=4:noTabs=false:
 * :folding=explicit:collapseFolds=1:
 *
 *}}}*/

/*{{{ copyright notice
 *
 * Copyright (C) 2006 Norbert E. Wagner
 *
 * This file is part of JavascriptScriptRepository
 *
 * The JavascriptScriptRepository is free software; you can redistribute
 * it and/or modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *}}}*/
 

 // remove
var errorString = "";

//{{{ isNull() function
/**
 * check if component is empty
 */
function isNull(component) {
        if (component.value == "") {
            errorString += "The "+component.name+" is missing! \n";
            return true;
        } else
            return false;
}/*}}}*/

//{{{ isDate() function
function isDate(component) {
    dateSep = new Array(/ /g, /\./g, /-/g);
    datePieces = new Array();
    var i;
    var strDate = component.value

    if (strDate == "") {
        return true;
    } else {
        for (i = 0; i < dateSep.length; i++) {
			strDate = strDate.replace(dateSep[i], "/")
        }
        datePieces = strDate.split("/");
        var result = true;
        if (datePieces[0] < 1 || datePieces[0] > 31
        		|| datePieces[0].length < 1 || datePieces[0].length > 2) {
        	errorString += "Invalid Day in "+component.name+". \n";
			result = false;
        }
        if (datePieces[1] < 1 || datePieces[1] > 12
        		|| datePieces[1].length < 1 || datePieces[1].length > 2) {
        	errorString += "Invalid Month in "+component.name+". \n";
            result = false;
        }
        if (datePieces[2].length != 2 && datePieces[2].length != 4) {
        	errorString += "Invalid Year in "+component.name+". \n";
            result = false;
        }
        return result;
    }
}/*}}}*/

//{{{ isEmail() function
function isEmail(component, allowFullName, js11) {
    if (component.value == "") {
    	return true;
    } else {
      if ( js11 ) {
        if (!checkEmail(component.value, allowFullName)) {
          errorString += "Invalid e-mail address. \n";
          return false;
        } else {
          return true;
        }
      }
    }
    return false;
}/*}}}*/

// remove
function warn() {
         alert(errorString);
         errorString = "";
}

function NumSort(a,b)
{ return a-b; }