  function validate(arr){
	   mes = new Array();
	   var len = arr.length;
	   for(j=0;j<len;j++){
			   func_name = eval(arr[j][1]);
			   return_value = func_name(arr[j][0],arr[j][2],arr[j][3],arr[j][4]);
			   if(typeof(return_value) == 'string'){
				   mes[mes.length] = return_value;
				   alert(return_value);
				   return false;
			   }
	   }
	   return true;
   }
   
   function isEmpty(value,message,id){
		if(value == ""){
			document.getElementById(id).focus();
			return message;
		}
		return 1;
   }

   function isAlpha(value,message,id){
	   exp = /^[a-zA-Z]+$/
	   if(value.search(exp) == -1){
			document.getElementById(id).focus();
			return message;
	   }
	   return 1;
   }

   function isDigit(value,message,id){
	   exp = /^[0-9]+$/
	   if(value.search(exp) == -1){
			document.getElementById(id).focus();
		    return message;
	   }
	   return 1;
   }
   
   function checkSame(value,message,id,value1){
		if(value === value1){
			return 1;
		}else{
			return message;
		}
   }
   
   function checkEmail(value,message,id){
	   exp = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/
	   if(value.search(exp) == -1){
			document.getElementById(id).focus();
     		   return message;
	   }
	   return 1;
   }
   
   function checkQuotes(value,message,id){
		if(value.search(/.*[\'\"]+.*/) == -1){ 
			document.getElementById(id).focus();
			return message;
		}
		return 1;
   }
   
   function isAlphaSpace(value,message,id){
		if(value.search(/$[a-zA-Z]+(\s+[a-zA-Z]*)?/) != -1) {
			document.getElementById(id).focus();
			return message;
   		}
		return 1;
   }                
   
   function checkUrl(value,message,id){
		if(value.search(/^http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/) == -1){
			document.getElementById(id).focus();
			return message;
		}
		return 1;
   }

   function checkDate(value,message,id){
	   my_date = new Date();
	   today   = my_date.getDate();
	   month   = my_date.getMonth() + 1;
	   if(month < 10){
		  month = '0'+month;
   	   }
   	   if(today < 10){
		  today = '0'+today;
       }
	   year    = my_date.getFullYear();
	   format  = month+'-'+today+'-'+year;
		   
	   if(value < format){   
			document.getElementById(id).focus();
	   		return message;
	   }else{
			return 1;   
	   }
   }
   
   function validateTime(time, message,id){
	    exp = /^(\d){2}:(\d){2}(:(\d){2})?$/
        if(time.search(exp) != -1){
			time = time.replace(".", ":");
			var newTime = time.substring(0, (time.indexOf(":") + 3)); // Strip out the seconds
			var status = ValidateTime(newTime, 2);
			
			if(status == false) {
	   			document.getElementById(id).focus();
				return message;
			}
				
			var seconds = time.substring(time.indexOf(":") + 4, time.length);
			if(seconds.length > 2) 
				seconds = seconds.substring(0, 2);                      // Remove any AM/PM afterwards
				
			if(!isNaN(seconds)) {			                                // Make sure its a number and it's between 0 and 59
				if((seconds <= 59) && (seconds >= 0)) 
					return 0;
			}
			document.getElementById(id).focus();
			return message;	
		}else{
			document.getElementById(id).focus();
			return message;	
		}
   }
   
   function ValidateTime(time, formatType) {
		var segments;			// Break up of the time into hours and minutes
		var hour;					// The value of the entered hour
		var minute;				// The value of the entered minute
			
		time = time.replace(".", ":");
			
		if (formatType == 1) {						                              /* Validating standard time */
			segments = time.split(":");
			
			if (segments.length == 2) {
				segments[1] = segments[1].substring(0,2);
				hour = segments[0];				                                  // Test the hour
				if ((hour > 12) || (hour < 1))  
					return false;
							
				minute = segments[1];			                                  // Test the minute
				if (( minute <= 59) && (minute >= 0)) 
					return true;
			}
				
		}
		else {												                                  /* Validating military time */
			segments = time.split(":");
			
			if (segments.length == 2) {
				hour = segments[0];				                                  // Test the hour
				if ((hour > 23) || (hour <= -1)) 
					return false;
					
				minute = segments[1];			                                  // Test the minute
				if (( minute <= 59) && (minute >= 0)) 
					return true;
			}
		}
		return false;
	 }	

   
   function checkLength(value,message,id){
		if(value.length < 6){
			document.getElementById(id).focus();
			return message;	
		}
		return 1;
   }
