var formName;
function getForm(frm)                                          
{
	formName = frm    										  
}

function getCookie(name)										
{
	var cookifound=false;										
	var start=0;
	var end=0;
	var cookiestring=document.cookie;
	var i=0;
	while (i<=cookiestring.length)
	{
		start=i;
		end=start+name.length;
		if(cookiestring.substring(start,end)==name)
		{
			return true;
			break;
		}
		i++;
	}
	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;
	}
	else
	{
		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;
		setval =(eval("document."+formName+"."+con+".value=''"));
		return false;
	}
	if(isNaN(val))
	{
		if ((msg.length)!=0)
		{
			alert(msg);
		}
		setval =(eval("document."+formName+"."+con+".value=''"));
		foc;
		return false;
	}
	else
	{
		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);
		}
		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 IsSearch(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;
	}
	if(val=="Search a Product")
	{
		if ((msg.length)!=0)
		{
			alert(msg);
		}
		setval =(eval("document."+formName+"."+con+".value=''"));
		foc;
		return false;
	}
	return true;
}

function IsPassword(con, msg)
{
	val = (eval("document."+formName+"."+con+".value"));
	foc = (eval("document."+formName+"."+con+".focus()"));
	if(val.length<6)
	{
		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 IsQuantity(con1,con2, msg)
{
	val1 = (eval("document."+formName+"."+con1+".value"));
	val2 = (eval("document."+formName+"."+con2+".value"));
    
    if(val2!=0)
    {
	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=''"));
		(eval("document."+formName+"."+con1+".focus()"));
		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 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<1900)
			{
				if ((msg.length)!=0)
				{
					alert(msg);
				}
				foc;
				setval =(eval("document."+formName+"."+con+".value=''"));
				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;
}

