var formName;
function getForm(frm)
{
	formName = frm
}

function objDisabled(con, stat)
{
	eval("document."+formName+"."+con+".disabled=true;");
	return true;
}

function file_extension(con, file_ext, msg)
{
	foc = (eval("document."+formName+"."+con+".focus()"));
	file_name=(eval("document."+formName+"."+con+".value"));
	file1=file_name.toUpperCase();
	file1_part=file1.split(".")
	x=file1_part.length;
	ext=file1_part[x-1];
	file_ext=file_ext.toUpperCase();
	file_ext_ary=file_ext.split(",");
	x=file_ext_ary.length;
	for(var i=0;i<x;i++)
	{
		if(ext==file_ext_ary[i])
			return true;
	}
	alert(msg);
	foc;
	return false;
}

function chkYear(con, uYear, msg)
{
	s = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));

	var pos=s.indexOf('-');
	s=s.substring(pos+1, s.length);
	pos=s.indexOf('-');
	s=s.substring(pos+1, s.length);
	pos=s.indexOf('-');
	jyear=s;
	if(uYear<=jyear)
	{
		alert(msg);
		foc;
		return false;
	}
	return true;
}

function selList(len, msg)
{
	if(len<1)
	{
		alert(msg);
//		con.focus();
		return false;
	}	
	return true
}

function IsChecked(con, value,msg)
{
	val = (eval("document."+formName+"."+con+".checked"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	if(val==value)
		return true;
	else
	{
		alert(msg);
		foc;
		return false;
	}
}

function IsSelect(con, msg)
{
	val = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	if(val==0)
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		return false;
	}
	if(val=='')
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		return false;
	}
	else
	{
		return true;
	}
}

function IsDecimal(con, msg)
{
	val = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	if(!(IsEmpty(con, "")))
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		return false;
	}
	var len = val.length;
	for(var i=0;i<len;i++)
	{
		if(((val.charCodeAt(i)>=48)&(val.charCodeAt(i)<=57))|(val.charCodeAt(i)==46))
			continue;	
		else
		{
			if ((msg.length)!=0)
				alert(msg);
			return false;
		}
	}
	return true;
}


function IsNumber(con, msg)
{
	val = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	if(!(IsEmpty(con, "")))
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		return false;
	}
	var len = val.length;
	for(var i=0;i<len;i++)
	{
		if((val.charCodeAt(i)>=48)&(val.charCodeAt(i)<=57))
			continue;	
		else
		{
			if ((msg.length)!=0)
				alert(msg);
			return false;
		}
	}
	return true;
}

function ChkLength(con, conLen, msg)
{
	val = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	if(val.length<conLen)
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		return false;
	}
	return true;
}

function UpperLength(con, conLen, msg)
{
	val = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	if(val.length>conLen)
	{
		alert(msg);
//		setval =(eval("document."+formName+"."+con+".value=''"));
		foc;
		return false;
	}
	return true;
}

function IsEmpty(con, msg)
{
	val = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	if(val==0)
	{
		if ((msg.length)!=0)
			alert(msg);
		setval =(eval("document."+formName+"."+con+".value=''"));
		foc;
		return false;
	}
	
	return true;
}

function IsSame(con1,con2, msg)
{
	val1 = (eval("document."+formName+"."+con1+".value"));
	foc1 = (eval("document."+formName+"."+con1+".focus()"));
	val2 = (eval("document."+formName+"."+con2+".value"));
	foc2 = (eval("document."+formName+"."+con2+".focus()"));
	if(!(IsEmpty(con1, "")))
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		return false;
	}
	if(!IsEmpty(con2, ""))
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		return false;
	}

	if(val1!=val2)
	{
		if ((msg.length)!=0)
			alert(msg);
		setval =(eval("document."+formName+"."+con1+".value=''"));
		setval =(eval("document."+formName+"."+con2+".value=''"));
		(eval("document."+formName+"."+con1+".focus()"));
		return false;
	}
	return true;
}

/*
function IsEmail(con, msg)
{
	s = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	if(!(IsEmpty(con, "")))
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		return false;
	}
	var len = s.length;
	for(var i=0;i<len;i++)
	{
		if(((s.charCodeAt(i)>=65)&(s.charCodeAt(i)<=90))|((s.charCodeAt(i)>=97)&(s.charCodeAt(i)<=122))|((s.charCodeAt(i)>=48)&(s.charCodeAt(i)<=57))|(s.charCodeAt(i)>=45)|(s.charCodeAt(i)>=46)|(s.charCodeAt(i)>=64)|(s.charCodeAt(i)>=95))
			continue;	
		else
		{
			if ((msg.length)!=0)
				alert(msg);
			foc;
			return false;
		}
	}
<!-- checking @@ .. @.  -->
	file1_part=s.split("..")
	x=file1_part.length;
	if(x>1)
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		return false;
	}
	file1_part=s.split("@.")
	x=file1_part.length;
	if(x>1)
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		return false;
	}
	file1_part=s.split("@@")
	x=file1_part.length;
	if(x>1)
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		return false;
	}
	file1_part=s.split("@")
	x=file1_part.length;
	if(x>2)
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		return false;
	}
	return true;
}
*/

function IsEmail(con, msg)
{
	val = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	if(!(IsEmpty(con, "")))
	{
		if ((msg.length)!=0)
		{
			alert(msg);
		}
		foc;
		setval =(eval("document."+formName+"."+con+".value=''"));
		return false;
	}
	var filter=/^.+@.+\..{2,3}$/
	if (filter.test(val))
		return true;
	else
	{
		if ((msg.length)!=0)
		{
			alert(msg);
		}
		return false;
	}
	return true;
}




function ChkRange(con, lYear, uYear, msg)
{
	s = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	for(var i=lYear;i<=uYear;i++)
	{
		if(s==i)
			return true;	
	}
	if ((msg.length)!=0)
		alert(msg);
	return false;
}

function IsAlphaNumeric(con, msg)
{
	s = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	if(!(IsEmpty(con, "")))
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		return false;
	}
	var len = s.length;
	for(var i=0;i<len;i++)
	{
		if(((s.charCodeAt(i)>=65)&(s.charCodeAt(i)<=90))|((s.charCodeAt(i)>=97)&(s.charCodeAt(i)<=122))|(s.charCodeAt(i)==32)|((s.charCodeAt(i)>=48)&(s.charCodeAt(i)<=57)))
			continue;	
		else
		{
			if ((msg.length)!=0)
				alert(msg);
			return false;
		}
	}
	return true;
}


function IsAlpha(con, msg)
{
	s = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	if(!(IsEmpty(con, "")))
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		return false;
	}
	var len = s.length;
	for(var i=0;i<len;i++)
	{
		if(((s.charCodeAt(i)>=65)&(s.charCodeAt(i)<=90))|((s.charCodeAt(i)>=97)&(s.charCodeAt(i)<=122))|(s.charCodeAt(i)==32))
			continue;	
		else
		{
			if ((msg.length)!=0)
				alert(msg);
			return false;
		}
	}
	return true;
}

function IsPhone(con, msg)
{
	s = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	var counth = 0;
	var counts = 0;
	var len = s.length;
	for(var i=0;i<len;i++)
	{
		if((s.charCodeAt(i)==45)|(s.charCodeAt(i)==32)|((s.charCodeAt(i)>=48)&(s.charCodeAt(i)<=57)))
			continue;	
		else
		{
			if ((msg.length)!=0)
				alert(msg);
			foc;
			return false;
		}
	}
	for(var i=0;i<len;i++)
	{
		if(s.charCodeAt(i)==45)
			counth = counth + 1;
		if(s.charCodeAt(i)==32)
			counth = counts + 1;
	}			
	if((counth>1)|(counts>1))
		return true;
	else
	{
		if ((msg.length)!=0)
		{
			alert(msg);
			foc;
			return false;
		}
	}
}

function NoSpaces(con, msg)
{
	s = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	if(!(IsEmpty(con, "")))
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		return false;
	}
	var len = s.length;
	for(var i=0;i<len;i++)
	{
		if(((s.charCodeAt(i)>=65)&(s.charCodeAt(i)<=90))|((s.charCodeAt(i)>=97)&(s.charCodeAt(i)<=122))|((s.charCodeAt(i)>=48)&(s.charCodeAt(i)<=57)))
			continue;	
		else
		{
			if ((msg.length)!=0)
				alert(msg);
			foc;
			return false;
		}
	}
	return true;
}

function IsDate(con, msg)
{
	s = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	if(!(IsEmpty(con, "")))
	{
		if ((msg.length)!=0)
			alert(msg);
		foc;
		setval =(eval("document."+formName+"."+con+".value=''"));
		return false;
	}
	var pos=s.indexOf('-');
	if (pos!=-1)
	{
		var jdate=s.substring(0, pos);
		s=s.substring(pos+1, s.length);
		pos=s.indexOf('-');
		if (pos!=-1)
		{
			var jmonth=s.substring(0,pos);
			if (jmonth>12)
			{
				if ((msg.length)!=0)
					alert(msg);
				foc;
				setval =(eval("document."+formName+"."+con+".value=''"));
				return false;
			}
			s=s.substring(pos+1, s.length);
			pos=s.indexOf('-');
			if (pos!=-1)
			{
				if ((msg.length)!=0)
					alert(msg);
				foc;
				setval =(eval("document."+formName+"."+con+".value=''"));
				return false;
			}
			jyear=s;
			if(jyear<1960)
			{
				if ((msg.length)!=0)
					alert("Must be above 1960");
				foc;
				return false;
			}			
			switch(jmonth)
			{
				case '4':
				case '6':
				case '9':
				case '11':
					nodays=30;
					break;
				case '2':
					if(jyear%4==0)
						nodays=29;
				else
					nodays=28;
					break;
				default :
					nodays=31;
			}
			if(jdate>nodays)
			{
				if ((msg.length)!=0)
					alert(msg);
				foc;
				setval =(eval("document."+formName+"."+con+".value=''"));
				return false;
			}
		return true;
		}
	}
	if ((msg.length)!=0)
		alert(msg);
	foc;
	setval =(eval("document."+formName+"."+con+".value=''"));
	return false;
}
