// JavaScript Document
function y2k(number) { return (number < 1000) ? number + 1900 : number; }

function isDate (day,month,year) {
// checks if date passed is valid
// will accept dates in following format:
// isDate(dd,mm,ccyy), or
// isDate(dd,mm) - which defaults to the current year, or
// isDate(dd) - which defaults to the current month and year.
// Note, if passed the month must be between 1 and 12, and the
// year in ccyy format.

    var today = new Date();
    year = ((!year) ? y2k(today.getYear()):year);
    month = ((!month) ? today.getMonth():month-1);
    if (!day) return false
    var test = new Date(year,month,day);
    if ( (y2k(test.getYear()) == year) &&
         (month == test.getMonth()) &&
         (day == test.getDate()) )
        return true;
    else
        return false
}


function IsTime(strTime) {
    	var strTime1 = /^(\d{1,2})(\:)(\d{2})\2(\d{2})(\ )\w[AM|PM|am|pm]$/;
    	var strTime2 = /^(\d{1,2})(\:)(\d{2})(\ )\w[A|P|a|p]\w[M|m]$/;
    	var strTime3 = /^(\d{1,2})(\:)(\d{1,2})$/;
    	
    	var strFormat1 = strTime.match(strTime1);
    	var strFormat2 = strTime.match(strTime2);
    	var strFormat3 = strTime.match(strTime3);
    // Check to see if it matches one of the
    //     3 Format Strings.


        	if (strFormat1 == null && strFormat2 == null && strFormat3 == null) {
        		return false;
        	}


            	else if (strFormat1 != null) {
            		// Validate for this format: 3:48:01 PM


                		if (strFormat1[1] > 12 || strFormat1[1] < 00) {
                			return false;
                		}


                    		if (strFormat1[3] > 59 || strFormat1[3] < 00) {
                    			return false;	
                    		}


                        		if (strFormat1[4] > 59 || strFormat1[4] < 00) {
                        			return false;	
                        		}
                        	}


                            	else if (strFormat2 != null) {
                            		// Validate for this format: 3:48 PM


                                		if (strFormat2[1] > 12 || strFormat2[1] < 00) {
                                			return false;
                                		}


                                    		if (strFormat2[3] > 59 || strFormat2[3] < 00) {
                                    			return false;	
                                    		}
                                    	}


                                        	else if (strFormat3 != null) {
                                        		// Validate for this format: 15:48


                                            		if (strFormat3[1] > 23 || strFormat3[1] < 00) {
                                            			return false;
                                            		}


                                                		if (strFormat3[3] > 59 || strFormat3[3] < 00) {
                                                			return false;	
                                                		}
                                                	}
                                                	return true;
                                            }
