function isblank(strval)
{
   	var len = strval.length;
	for (var i = 0; i < len; i++)
	{
      if (strval.charAt(i) != " ")
      {
	     return false;				// If the is any non-space character, isblank() returns false
      }
   }
   return true;
}



function checkLength(strval,maxlength,minlength)
{
	if((strval.length < minlength) || (strval.length > maxlength))
	{
		return false;
	}
	return true;
}

/*function validEmail(strval)
{
	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	var regex = new RegExp(emailReg);
	if(!regex.test(strval))
	{
		return false;
	}
	return true;
}*/

function validEmail(Paddress) {
	var Vre;
		var Vret;
		Vre = /^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/;
		Vret = Paddress.search(Vre);
		if(Vret == 0)
			{return true}
		else
			{return false}

}

function isNumeric(strval) {
	var bool = isNaN(strval);
	return bool;
}

function checkPositive(strval)
{
	if(parseFloat(strval) <= '0'){
	
		return false;
	}
	return true;
}

function isDate(day, mon, year)
{
	//alert(day + ' ' + mon + ' ' + year);
	// Check any of them are blanks
	dtcorrect = true;
	if (isblank(day) || isblank(mon) || isblank(year) )
	{
	   dtcorrect = false;
	}

	if ((year % 4) == 0)
	{
		if (mon == '02')
		{
			if (day > 29)
			{
				dtcorrect = false;
			}
		}
	}
	else
	{
		if (mon == '02')
		{
			if (day > 28)
			{
				dtcorrect = false;
			}
		}
	}
	switch (mon)
	{
		case '04':
		case '06':
		case '09':
		case '11': if (day > 30)
					{
						dtcorrect = false;
					}
	}
	return dtcorrect;
}

function validate_phone(val)
{
		var Vre;
		var Vret;
		Vre = /^[a-zA-Z0-9\(\)\+\-\s]+$/;
		if(!Vre.test(val))
			{return true}
		else
			{return false}
			
			/*
			if (validate_tele(form.text1.value) == true)
				{
					alert('NOT');
				}
				else
				{
					alert('OK');
				}
			*/
}

function validate_tele(val) {
		var Vre;
		var Vret;
		Vre = /^[a-zA-Z0-9\()\-\,\s]+$/;
		if(!Vre.test(val))
			{return true}
		else
			{return false}
}

function val_username_pwd(val) {
	var valid;
	valid = /^[a-zA-Z0-9]+$/;
	if (!valid.test(val)) {
		return true;
	} else {
		return false;
	}
}


function validFields(val) {
	var Vre;
		var Vret;
		Vre = /^[a-zA-Z0-9\-\+\(\)\%\_\s\/\\\.\,\<\>\?\;\:\&\*\^\$\#\@\!\|\=\[\]\{\}]+$/;
		//Vre = /^[a-zA-Z0-9\-\+\(\)\%\_]+$/;
		Vret = val.search(Vre);
		if(Vret == 0)
			{return true}
		else
			{return false}
    //. , < >  ? / ; :  ( ) & * ^ $ # @ ! | _ - + = \ / [ ] { } 

}