// JavaScript Document

function isValidControl(cntrl, msg)
{
	if(isBlank(cntrl.value))
	{
		alert(msg);
		cntrl.focus();
		return false;
	}
	else
		return true;
}

function isValidRadio(cntrl, msg)
{
 for (var x = 0; x < cntrl.length; x++) 
 { 
  if(cntrl[x].checked)
  	return true;
 } 
 alert(msg);
 return false;
}

function isBlank(str)
{
	if(str == "")
		return true;
	else
		return false;
}

function isValidZipCode(cntrl, msg)
{
	var filter  = /^[4][89]\d{3}$/;
	if(!filter.test(cntrl.value))
	{
		alert(msg);
		cntrl.focus();
		return false;
	}
	else
		return true;
}


function isValidEmail(cntrl, msg)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(!filter.test(cntrl.value))
	{
		alert(msg);
		cntrl.focus();
		return false;
	}
	else
		return true;
}

function isValidPassword(cntrl, msg)
{
	var filter  = /^\w{6,}$/;
	if(!filter.test(cntrl.value))
	{
		alert(msg);
		cntrl.focus();
		return false;
	}
	else
		return true;
}

function isValidDate(cntrl, msg)
{
	var filter  = /^\d{1,2}(\/)\d{1,2}\1\d{2,4}$/;
	if(!filter.test(cntrl.value))
	{
		alert(msg);
		cntrl.focus();
		return false;
	}
	else
		return true;
}

function isValidDay(cntrl, msg)
{
	var filter  = /^(([1-9])|([12][0-9])|(3[01]))$/;
	if(!filter.test(cntrl.value))
	{
		alert(msg);
		cntrl.focus();
		return false;
	}
	else
		return true;
}

function isValidTime(cntrl, msg)
{
	var filter  = /^([1-9]|1[0-2]|0[1-9]){1}(:[0-5][0-9] [aApP][mM]){1}$/;
	if(!filter.test(cntrl.value))
	{
		alert(msg);
		cntrl.focus();
		return false;
	}
	else
		return true;
}

function isValidUrl(cntrl, msg)
{
	var filter  = /^http:/;
	if(!filter.test(cntrl.value))
	{
		alert(msg);
		cntrl.focus();
		return false;
	}
	else
		return true;
}

function isValidInt(cntrl, msg)
{
	var filter  = /^\d{1,}$/;
	if(!filter.test(cntrl.value))
	{
		alert(msg);
		cntrl.focus();
		return false;
	}
	else
		return true;
}

function isValidDouble(cntrl, msg)
{
	var filter  = /^\d{1,}(\.\d{1,})?$/;
	if(!filter.test(cntrl.value))
	{
		alert(msg);
		cntrl.focus();
		return false;
	}
	else
		return true;
}

//function isValidAlpha(cntrl, msg)
//{
//	var filter  = /[^A-Za-z\\s]/;	
//	if(filter.test(cntrl.value))
//	//var filter  = /[^0-9]/;	
//	//if(!filter.test(cntrl.value))
//	{
//		alert(msg);
//		cntrl.focus();
//		return false;
//	}
//	else
//		return true;
//}

function isValidAlpha(cntrl, msg)
{
	var filter  = /[^a-zA-Z\s]/;
	if(filter.test(cntrl.value))
	{
		alert(msg);
		cntrl.focus();
		return false;
	}
	else
		return true;
}

function isValidAlphaDash(cntrl, msg)
{
	var filter  = /[^a-zA-Z\s\-]/;
	if(filter.test(cntrl.value))
	{
		alert(msg);
		cntrl.focus();
		return false;
	}
	else
		return true;
}

function isValidNumeric(cntrl, msg)
{
	var filter  = /[^0-9]/;
	//if(!filter.test(cntrl.value))
	if(filter.test(cntrl.value))
	{
		alert(msg);
		cntrl.focus();
		return false;
	}
	else
		return true;
}

function isValidNumeric(cntrl, msg)
{
	var filter  = /[^0-9]/;
	if(filter.test(cntrl.value))
	{
		alert(msg);
		cntrl.focus();
		return false;
	}
	else
		return true;
}

function isValidNumericDash(cntrl, msg)
{
	var filter  = /[^0-9\-]/;
	if(filter.test(cntrl.value))
	{
		alert(msg);
		cntrl.focus();
		return false;
	}
	else
		return true;
}
