//-------------------------------------------------------------------------------------------------------------------
// Project:						WACA
// Name:						/includes/jscripts/validation.js
// Author:						Brian Christie
// Date Created:				6/Nov/2001
// Purpose:						This Java Script contains common validation functions for client-side form validation.
//
// Prior Include File:			NONE
// Required Include File:		NONE
//
// CopyRight:					AEC Group Ltd.
//-------------------------------------------------------------------------------------------------------------------/


//#################################################
// Global variable we use in the form validation.
//#################################################
var defaultEmptyOK = false;
var decimalPointDelimiter = ".";


// Will check to see if the string is empty. TRUE if IT IS empty. 
function isEmpty(s) {
	var tmp = new String(s);
	if ( tmp.length <= 0 ) return true;
	return false;
}



/* 
 * This function is use to validate the new password. It is use
 * primarily for validating a new set of password that the user had
 * entered ie the form as 2 password boxes, one for password and the
 * other for confirmation.  
 */
function validateNewPassword(form, pass1_f_name, pass2_f_name, min_pass_len, max_pass_len) {
	var objPass1, objPass2;
	
	objPass1 = eval("form."+ pass1_f_name);
	objPass2 = eval("form."+ pass2_f_name);
	
	if ( isEmpty(objPass1.value) ) {
		alert("You New password CAN NOT be blank");
		objPass1.focus();
		return false;
	}

	if ( isEmpty(objPass2.value) ) {
		alert("You New password CAN NOT be blank");
		objPass2.focus();
		return false;
	}


	if ( objPass1.value != objPass2.value ) {
		alert("You New password AND the Confirmation Password MUST Match.");
		objPass1.focus();
		return false;
	}

	var strPass1 = new String(objPass1.value);
	var strPass2 = new String(objPass2.value);

	if ( 
		 ((strPass1.length < min_pass_len) || (strPass1.length > max_pass_len)) 
		 ||
		 ((strPass2.length < min_pass_len) || (strPass2.length > max_pass_len)) 
	   ) {
		alert("The length of your New password MUST BE between "+ min_pass_len +" and "+ max_pass_len +" characters long.");
		objPass1.focus();
		return false;
	}
	
	var re = /^\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*$/
	if (!re.test(strPass1)) { 
		alert("Please enter a valid password!\n\nYour password must contain at least 1 capital letter and 1 numerical value."); 
		return false;
	}

	return true;
}

// 
// This function is use to validate the required values. In order to 
// get the fields checked you MUST Provide the corresponding "hidden" form
// value. For example, if I wanted to check for empty value for the field "First Name"
// in my form, this is HTML I need to put in the form:
//
// First Name: <input type="text" name="first_name">
//                                      ^^^^^^^^^^(a)
// 
// <input type="hidden" name="required" name="first_name">
//                            ^^^^^^^^(1)     ^^^^^^^^^^(2)
//
// (a) This is the form field name
// (1) This is what you passed in the 2nd argument (strRequired_F_Marker) when calling this function 
// (2) This MUST MATCH extactly to your form name in (a), yes including lower and upper cases etc.
//     If you don't match them exactly it will not get checked.
//
// 

function validateRequired_Values(form, strRequired_F_Marker) {
	var i, j;
	var formname;
	var objForm
	var formtype;
	var counter;

	for ( i = 0; i < form.length; i++ ) {
		if ( form.elements[i].type.toLowerCase() == "hidden" && form.elements[i].name == strRequired_F_Marker ) {				
			formname = form.elements[i].value;	 // Grab the form name from the hidden (required) field
			objForm	 = eval("form."+ formname ); // create the handle to this form field				
					
			if ( objForm != null ) {					
					
				formtype = objForm.type;
				
				switch (formtype) {
					case "text":
						if ( objForm.name == "new_username" ) {
							if  ( !checkBadChars(form, objForm.name, "Username") ) return false;
						}				
						if ( !checkTextField(objForm, true, true, "Please fill in this value.") ) return false;
					break;
													
					case "textarea":
						if ( !checkTextField(objForm, true, true, "Please fill in this value.") ) return false;
					break;				
											
				}// end switch				
					
				// for select list objects
				if ( formtype == "select-one" || formtype == "select-multiple") {
					counter = 0;
					for ( j = 0; j < objForm.options.length; ++j ) {
						if ( objForm.options[j].selected ) {							
							if ( objForm.options[j].value.length > 0 &&  objForm.options[j].value.toLowerCase != "null" &&  objForm.options[j].text.length > 0 ) {
								++counter;
							}
						}
					}						
					if ( counter <= 0 ) {
						alert("You must make at least one selection");
						objForm.focus();
						return false;
					}
				} //end if
								
			}// if we have the object			
		} // end check if the form is hidden required
	} // end for
	
	return true;
}


// 
// Will check to see if the text form field is empty. This function expects *at least* 2 arguments.
// These arguments being 
// 1) fname		: string  : Form field Name. 
// There are optional parameters:
// 1) displayErr	:	boolean : Specify wheather to display the error message in the alert box. IF this 
//						parameter is specifed you MUST also specify the following:
//		2) setFocus	:	boolean	: Wheather to set the focus to the Form field with the error.
//		3) ErrMsg	:	string	: What error message do you want to display.
//
// If these last 3 figures are not sent the DEFAULT values will be used instead i.e. we don't display
// the error message or set the focus.
//
function checkTextField(fname) {
	var argNum		= arguments.length;
	var displayErr	= false;	// default values
	var ErrMsg		= "You CAN NOT leave this field Empty";
	var setFocus	= false;
	
	// 
	// Now got to check to see how many args do we have. 
	// If there are more 3 arguments then we don't need to set the error message (we use default).
	// consult the function comments for the explanation.
	//
	if (argNum > 1 ) {
		displayErr	= eval("arguments[1]"); // acutally it's the 2nd after the required arg.
		setFocus	= eval("arguments[2]"); // actually it's the 3rd after the required arg.
	}
	
	if ( argNum == 4 ) {
		// 4 Args found, we need to set the error message the caller wants 
		ErrMsg	= arguments[3];
	}
	
	//alert("displayErr: " + displayErr + " setFocus: "+ setFocus +" ErrMsg: "+ ErrMsg );
	
	// Now check to see if the field is empty 
	if ( isEmpty(fname.value) ) {
		// Ok do we want to display error and set the focus?? 
		if ( displayErr ) {
			alert(ErrMsg);
			if ( setFocus ) {
				fname.focus();
			}
		}
		return false;
	}

	return true;
}

// checks for invalid chars in the field
function checkBadChars(form, fieldname, displayname){
	var i, myRegex;
	var flag = false;
	var myForm = eval("form."+ fieldname);
	var tmpstr;
	var pattern;
	
	if ( !checkTextField(form, myForm.name, displayname, myForm.value) ) {
		myForm.focus();
		return false;
	}

	// include [A-Za-z0-9_-] but exclude any white space char
	pattern = "^(\\w|-)*$";

	myRegex = new RegExp(pattern,"gi");
	if ( !myRegex.test(myForm.value) ){
		flag = true;
	}		

	// we got the flag.. print error then exit
	if (flag) {
		alert("Your "+ displayname +" contains illegal characters.\n"+ displayname +" CAN contain only a combination of alphanumeric, numeric and the hypen (-) and underscore (_) charactes");
		myForm.focus();
		return false;
	}
	return true;
}


// Generic date checks -- must be in format dd/mm/yy
function checkDate(datestr) {
	var tmpStr = new String(datestr)
	var arrayOfStrings = tmpStr.split("/");
	
	if (arrayOfStrings.length < 3 ) {
		return false;
	}
	
	var day  = arrayOfStrings[0];
	var month = arrayOfStrings[1];
	var year  = arrayOfStrings[2];
	
	// if the month is not number, may be it's a textual month format i.e june, jul etc.
	// lets try to convert it into numerical month format first. If it's still bad then
	// we know that it's really is bad.
	if ( isNumber(month) == false ) {
		retVal = monthName(month);		
		if ( retVal < 0 )  {
			return false;
		}
		else {
			month = retVal;
		}
	}
		
	if ( (isNumber(day) == true)  && (isNumber(year) == true) )  {
		
		if ( isDate(year, month, day) == false) {
			return false;
		}
	}
	else { 
		return false;
	}		
	return true;	
}


//--------------------------------------------
// Number functions
//--------------------------------------------

	
// Returns true if character c is a digit 
// (0 .. 9).
function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}


// Generic numerical checks
function isNumber(s) { 
	if ( isEmpty(s) == false ) {
		if ( isNonnegativeInteger(s) == false) { 
			return false;
		}
	}
	else {	
		return false;
	}
	return true;
}



// isNonnegativeInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if string s is an integer >= 0.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isNonnegativeInteger (s) {   
	var secondArg = false;

    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a number >= 0

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s, 10) >= 0) ) );
}

// isSignedInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if all characters are numbers; 
// first character is allowed to be + or - as well.
//
// Does not accept floating point, exponential notation, etc.
//
// We don't use parseInt because that would accept a string
// with trailing non-numeric characters.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
//
// EXAMPLE FUNCTION CALL:          RESULT:
// isSignedInteger ("5")           true 
// isSignedInteger ("")            false;
// isSignedInteger ("-5")          true
// isSignedInteger ("+5")          true
// isSignedInteger ("", false)     false
// isSignedInteger ("", true)      true

function isSignedInteger (s){   

	if (isEmpty(s)) 
       if (isSignedInteger.arguments.length == 1) return false;
       else return (isSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = false;

        if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isInteger(s.substring(startPos, s.length), secondArg))
    }
}

// isInteger (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if all characters in string s are numbers.
//
// Accepts non-signed integers only. Does not accept floating 
// point, exponential notation, etc.
//
// We don't use parseInt because that would accept a string
// with trailing non-numeric characters.
//
// By default, returns false if s is empty.
// There is an optional second argument called emptyOK.
// emptyOK is used to override for a single function call
//      the default behavior which is specified globally by
//      false.
// If emptyOK is false (or any value other than true), 
//      the function will return false if s is empty.
// If emptyOK is true, the function will return true if s is empty.
//
// EXAMPLE FUNCTION CALL:     RESULT:
// isInteger ("5")            true 
// isInteger ("")             false
// isInteger ("-5")           false
// isInteger ("", true)       true
// isInteger ("", false)      false
// isInteger ("5", false)     true

function isInteger (s)	{   
	var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return false;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;

}


// isIntegerInRange (STRING s, INTEGER a, INTEGER b [, BOOLEAN emptyOK])
// 
// isIntegerInRange returns true if string s is an integer 
// within the range of integer arguments a and b, inclusive.
// 
// For explanation of optional argument emptyOK,
// see comments of function isInteger.


function isIntegerInRange (s, a, b)
{   if (isEmpty(s)) 
       if (isIntegerInRange.arguments.length == 1) return defaultEmptyOK;
       else return (isIntegerInRange.arguments[1] == true);

    // Catch non-integer strings to avoid creating a NaN below,
    // which isn't available on JavaScript 1.0 for Windows.
    if (!isInteger(s, false)) return false;

    // Now, explicitly change the type to integer via parseInt
    // so that the comparison code below will work both on 
    // JavaScript 1.2 (which typechecks in equality comparisons)
    // and JavaScript 1.1 and before (which doesn't).
    var num = parseInt (s, 10);
    return ((num >= a) && (num <= b));
}


// isFloat (STRING s [, BOOLEAN emptyOK])
// 
// True if string s is an unsigned floating point (real) number. 
//
// Also returns true for unsigned integers. If you wish
// to distinguish between integers and floating point numbers,
// first call isInteger, then call isFloat.
//
// Does not accept exponential notation.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isFloat (s)

{   var i;
    var seenDecimalPoint = false;

    if (isEmpty(s)) 
       if (isFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isFloat.arguments[1] == true);

    if (s == decimalPointDelimiter) return false;

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if ((c == decimalPointDelimiter) && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}

// isSignedFloat (STRING s [, BOOLEAN emptyOK])
// 
// True if string s is a signed or unsigned floating point 
// (real) number. First character is allowed to be + or -.
//
// Also returns true for unsigned integers. If you wish
// to distinguish between integers and floating point numbers,
// first call isSignedInteger, then call isSignedFloat.
//
// Does not accept exponential notation.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isSignedFloat (s)

{   if (isEmpty(s)) 
       if (isSignedFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedFloat.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedFloat.arguments.length > 1)
            secondArg = isSignedFloat.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isFloat(s.substring(startPos, s.length), secondArg))
    }
}


// isNonNegativeFloat (STRING s)
// check to see if the floating number a non-negative value
//
function isNonNegativeFloat(s) {
	if (isEmpty(s)) return false;
	if (!isFloat(s)) return false;
	var startPos = 0;
	return ( isNonnegativeInteger(s.charAt(startPos)) );
}



//--------------------------------------------
// Date functions
//--------------------------------------------

// isYear (STRING s [, BOOLEAN emptyOK])
// 
// isYear returns true if string s is a valid 
// Year number.  Must be 2 or 4 digits only.
// 
// For Year 2000 compliance, you are advised
// to use 4-digit year numbers everywhere.
//
// And yes, this function is not Year 10000 compliant, but 
// because I am giving you 8003 years of advance notice,
// I don't feel very guilty about this ...
//
// For B.C. compliance, write your own function. ;->
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isYear (s)
{   if (isEmpty(s)) 
       if (isYear.arguments.length == 1) return false;
       else return (isYear.arguments[1] == true);
    if (!isNonnegativeInteger(s)) return false;
    return ((s.length == 2) || (s.length == 4));
}


// isMonth (STRING s [, BOOLEAN emptyOK])
// 
// isMonth returns true if string s is a valid 
// month number between 1 and 12.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isMonth (s)
{   if (isEmpty(s)) 
       if (isMonth.arguments.length == 1) return false;
       else return (isMonth.arguments[1] == true);
    return isIntegerInRange (s, 1, 12);
}



// isDay (STRING s [, BOOLEAN emptyOK])
// 
// isDay returns true if string s is a valid 
// day number between 1 and 31.
// 
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isDay (s)
{   if (isEmpty(s)) 
       if (isDay.arguments.length == 1) return defaultEmptyOK;
       else return (isDay.arguments[1] == true);   
    return isIntegerInRange (s, 1, 31);
}



// daysInFebruary (INTEGER year)
// 
// Given integer argument year,
// returns number of days in February of that year.

function daysInFebruary (year)
{   // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}

// daysInFebruary (INTEGER year)
// 
// Given integer argument year,
// returns number of days in February of that year.

function daysInFebruary (year)
{   // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}


// Attempting to make this library run on Navigator 2.0,
// so I'm supplying this array creation routine as per
// JavaScript 1.0 documentation.  If you're using 
// Navigator 3.0 or later, you don't need to do this;
// you can use the Array constructor instead.

function makeArray(n) {
	// ** BUG: If I put this line in, I get two error messages:
	//(1) Window.length can't be set by assignment
	//(2) daysInMonth has no property indexed by 4
	//If I leave it out, the code works fine.
	//   this.length = n;
   for (var i = 1; i <= n; i++) {
      this[i] = 0
   } 
   return this
}

var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 29;   // must programmatically check this
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;

// isDate (STRING year, STRING month, STRING day)
//
// isDate returns true if string arguments year, month, and day 
// form a valid date.
// 

function isDate (year, month, day)
{   // catch invalid years (not 2- or 4-digit) and invalid months and days.
    if (! (isYear(year, false) && isMonth(month, false) && isDay(day, false))) return false;

    // Explicitly change type to integer to make code work in both
    // JavaScript 1.1 and JavaScript 1.2.
    var intYear = parseInt(year, 10);
    var intMonth = parseInt(month, 10);
    var intDay = parseInt(day, 10);

    // catch invalid days, except for February
    if (intDay > daysInMonth[intMonth]) return false; 

    if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;

    return true;
}


// Will determined the difference between the 2 dates. 
// If will calculate the difference based on the option given
function timeDiff(laterdate,earlierdate, option) {    

	var difference, returnValue;
	var strOption = new String(option);

	switch (strOption.toLowercase) {

		case "h" :	
			//Hour diff
			difference -= daysDifference*1000*60*60*24;
			returnValue = Math.floor(difference/1000/60/60);    
		break;
    
		case "m" :
			//Minutes diff
			difference -= 	hoursDifference*1000*60*60        
			returnValue = Math.floor(difference/1000/60);       
		break;
    
		case "s" :
			//Seconds diff
			difference -= minutesDifference*1000*60        
			returnValue = Math.floor(difference/1000);
		break;

		default : // default is Days		
			//Day diff
			difference = laterdate.getTime() - earlierdate.getTime();    
			returnValue = Math.floor(difference/1000/60/60/24);    			
	}
		
	return (returnValue);
}


// isFloat (STRING s [, BOOLEAN emptyOK])
// 
// True if string s is an unsigned floating point (real) number. 
//
// Also returns true for unsigned integers. If you wish
// to distinguish between integers and floating point numbers,
// first call isInteger, then call isFloat.
//
// Does not accept exponential notation.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isFloat (s)

{   var i;
    var seenDecimalPoint = false;

    if (isEmpty(s)) 
       if (isFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isFloat.arguments[1] == true);

    if (s == ".") return false;

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if ((c == ".") && !seenDecimalPoint) seenDecimalPoint = true;
        else if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}



// isSignedFloat (STRING s [, BOOLEAN emptyOK])
// 
// True if string s is a signed or unsigned floating point 
// (real) number. First character is allowed to be + or -.
//
// Also returns true for unsigned integers. If you wish
// to distinguish between integers and floating point numbers,
// first call isSignedInteger, then call isSignedFloat.
//
// Does not accept exponential notation.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isSignedFloat (s)

{   if (isEmpty(s)) 
       if (isSignedFloat.arguments.length == 1) return false;
       else return (isSignedFloat.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = false;

        if (isSignedFloat.arguments.length > 1)
            secondArg = isSignedFloat.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isFloat(s.substring(startPos, s.length), secondArg))
    }
}




// isAlphabetic (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if string s is English letters 
// (A .. Z, a..z) only.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
//
// NOTE: Need i18n version to support European characters.
// This could be tricky due to different character
// sets and orderings for various languages and platforms.

function isAlphabetic (s)

{   var i;

    if (isEmpty(s)) 
       if (isAlphabetic.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphabetic.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-alphabetic character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is letter.
        var c = s.charAt(i);

        if (!isLetter(c))
        return false;
    }

    // All characters are letters.
    return true;
}




// isAlphanumeric (STRING s [, BOOLEAN emptyOK])
// 
// Returns true if string s is English letters 
// (A .. Z, a..z) and numbers only.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
//
// NOTE: Need i18n version to support European characters.
// This could be tricky due to different character
// sets and orderings for various languages and platforms.

function isAlphanumeric (s){   
	var i;

    if (isEmpty(s)) 
       if (isAlphanumeric.arguments.length == 1) return defaultEmptyOK;
       else return (isAlphanumeric.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-alphanumeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number or letter.
        var c = s.charAt(i);

        if (! (isLetter(c) || isDigit(c) ) )
        return false;
    }

    // All characters are numbers or letters.
    return true;
}

// Convert the textual months to numerical format
function monthName(strmonth) {

	var tmp = new String(strmonth);
	var m	= tmp.toLowerCase();
		
	switch (m.substring(0, 3)) {
		case "jan" :
			return(1);
		break;
		
		case "feb" :
			return(2);
		break;

		case "mar" :
			return(3);
		break;

		case "apr" :
			return(4);
		break;

		case "may" :
			return(5);
		break;
		
		case "jun" :
			return(6);
		break;
		
		case "jul" :
			return(7);
		break;
		
		case "aug" :
			return(8);
		break;
		
		case "sep" :
			return(9);
		break;
		
		case "oct" :
			return(10);
		break;

		case "nov" :
			return(11);
		break;

		case "dec" :
			return(12);
		break;	
		
		default: 
			return(-1);
	}

}
