function check_empty(text){
	var value="";
	value = text;
	if(value == ""){ return false; }
	if(value.match(/[^\s.+]/)){ return true; }
	return true;
}

function check_email(this_handle){		
		if(!check_empty(this_handle)){ return false; }
		var form_value="";
		form_value = this_handle;
		if(form_value.match(/\w.+\@\w.+\.(\b[a-zA-Z]{2,4}\b)/)){ return true; }
		else { return false; }
}

function check_lettersonly(this_handle){
	var form_value="";
	form_value = this_handle;
	if(form_value.match(/[^a-zA-Z]/)){ return true; }
	else { return false; } 
}

function check_numbersonly(this_handle){
	var form_value = "";
	form_value = this_handle;
	if(form_value.match(/[^\d\s_()-]/)){ return true; }
	else { return false; } 
}

function check_val(golfVal,NonGolfVal,GroupVal){
	totVal = "";
	totVal = parseInt(golfVal) + parseInt(NonGolfVal);
	if(totVal != GroupVal){ return false; }
	return true;
}

function is_leapyear(j) {
		return ((j % 4 == 0) && ((j % 100!= 0) || (j % 400 == 0)));	
}

function check_date(this_handle)
	{
		var datestring=""; var text = ""; var numbers="";  
		var day =0; var month =0; var year =0; var currYear =0; 
		var currDate = new Date(); 
		var currYear = currDate.getFullYear();
		var dateNumber ="";
		datestring = this_handle;
		
		// split in dd mm yyyy  
		numbers = datestring.split("/");
		if (numbers.length != 3) {return true;}

		// test of real date 
		mtage = new Array (0,31,28,31,30,31,30,31,31,30,31,30,31);
		day   = numbers[0]*1;	// String change into Integer 
		month = numbers[1]*1;
		year  = numbers[2]*1;
		
		
		if (is_leapyear(year)){mtage[2] = 29};// leapyear check by regard February  
		// if (year  < currYear || year  > 2020)			
		// {return true;} 
		if ((month < 1) || (month > 12))			
		{return true;}
		if ((day < 1) || (day > mtage[month]))	
		{return true;}

		// formating output 
		if (day   < 10){day   = "0" + day   }		
		if (month < 10){month = "0" + month }

		this_handle = (day + "/" + month + "/" + year);

 	return false;
	}

// compares 2 dates, if date1 less  ,or equal and less(option "ELT") than date2 RV = true, else RV = false 
// the dates must !!! be in the format (dd/mm/yyyy) Use the function check_date und CF to ensure this    
function comp_date(date1, date2, option)
{
	var RValue = false;
	var datestring1 = "";
	var datestring2 = "";
	var opt = option;
	
	datestring1 = date1;
	datestring2 = date2;
	
	// split in dd mm yyyy  
	numbers1 = datestring1.split("/");
	numbers2 = datestring2.split("/");
	
	// test of real date 
	day1   = numbers1[0]*1;	// String change into Integer 
	month1 = numbers1[1]*1;
	year1  = numbers1[2]*1;
	
	// test of real date 
	day2   = numbers2[0]*1;	// String change into Integer 
	month2 = numbers2[1]*1;
	year2  = numbers2[2]*1;
	
	if(year1 < year2){return true;}
	if(year1 == year2){
		if(month1 < month2){return true;}
		if(month1 == month2){
			if (opt){
					
				if((day1 < day2) || (day1 == day2)){return true;}
			}
			else{
				
				if(day1 < day2){return true;}
			}		
		}
	}
	return false;
} 

function get_currDate()
{
	var currDate = new Date();
	var month = new Array("1","2","3","4","5","6","7","8","9","10","11","12");
	var currMonth = month[currDate.getMonth()]
	var currYear = currDate.getFullYear();
	var currDay = currDate.getDate();

	var dateString = currDay+"/"+currMonth+"/"+currYear;

	return dateString;
}

