
function validate_required(field,alerttxt)
{
	with (field)
	{
		if (value==null||value=="")
		  {alert(alerttxt);return false;}
		else {return true}
	}
}

function validate_email(field,alerttxt)
{
	with (field)
	{
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) 
		  {alert(alerttxt);return false;}
		else {return true;}
	}
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function resetCookie()
{
	setCookie("username","",1);
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}
function checkCookie()
{
	username=getCookie('username');
	if (username!=null && username!="")
	  {
		alert('Welcome again '+username+'!');
		return true;
	  }
	  else 
	  {
		alert('plz login again!');
		return false;
	  }
}

function textMobNo(field)
{
	with(field)
	{
		var x = field.value;
		//document.write(x);
		//if(field.value[field.value.length-1] < "0" || field.value[field.value.length-1]> "9" )
			//field.value = field.value.substring(0, field.value.length-1);
			
		if(isNaN(x)|| x.indexOf(" ")!=-1)
		{
			field.value = field.value.substring(0, field.value.length-1);
		}
		/*
		if (x.charAt(0)!="9" )
		{
			alert("it should start with 9 ");
			return false
		}
		*/
	}
}


