function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid E-mail ID")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid E-mail ID")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid E-mail ID")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		alert("Invalid E-mail ID")
		return false
	 }
	 return true					
}


function cont_validate(type)
{

var act=type;

if(type!="CON")
	{

if(document.reg_form.fname.value=="")
	{
     alert("Please mention your name"); 
	 document.reg_form.fname.focus();
	 return false;
	}


if (document.reg_form.fname.value!="")
{
	
	//check for name
	nwstl=document.reg_form.fname.value;

	if (nwstl==0 || nwstl==null)
	{
	alert("Please enter proper value");
	document.reg_form.fname.focus();
	return false;
	}
}


if(document.reg_form.fname.value !="")
	{
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@_/,- \n\r";
  var checkStr = document.reg_form.fname.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert('Data are invalid.Only a-z 0-9 @ _ . , /   are allowed');
    document.reg_form.fname.select();
    return false;
  }
}

if(document.reg_form.fname.value!="")
	{

		if(document.reg_form.fname.value.length > 100)
		{
					alert("Name cannot be greater than 100 Characters");
					document.reg_form.fname.focus();
					return false;
		}
	}	



if(document.reg_form.cantct.value=="")
	{
     alert("Please mention contact"); 
	 document.reg_form.cantct.focus();
	 return false;
	}


if (document.reg_form.cantct.value!="")
{
	
	//check for name
	nwstl=document.reg_form.cantct.value;

	if (nwstl==0 || nwstl==null)
	{
	alert("Please enter proper value");
	document.reg_form.cantct.focus();
	return false;
	}
}

if(document.reg_form.cantct.value !="")
	{
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@_/,- \n\r";
  var checkStr = document.reg_form.cantct.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert('Data are invalid.Only a-z 0-9 @ _ . , /   are allowed');
    document.reg_form.cantct.select();
    return false;
  }
}

if(document.reg_form.cantct.value!="")
	{

		if(document.reg_form.cantct.value.length > 200)
		{
					alert("Contact cannot be greater than 200 Characters");
					document.reg_form.cantct.focus();
					return false;
		}
	}	


if(document.reg_form.email.value=="")
	{
     alert("Please mention email"); 
	 document.reg_form.email.focus();
	 return false;
	}


if (document.reg_form.email.value!="")
{
	
	//check for name
	nwstl=document.reg_form.email.value;

	if (nwstl==0 || nwstl==null)
	{
	alert("Please enter proper value");
	document.reg_form.email.focus();
	return false;
	}
}


if(document.reg_form.email.value !="")
	{
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@_/,- \n\r";
  var checkStr = document.reg_form.email.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert('Data are invalid.Only a-z 0-9 @ _ . , /   are allowed');
    document.reg_form.email.select();
    return false;
  }
}

if(document.reg_form.email.value!="")
	{

		if(document.reg_form.email.value.length > 100)
		{
					alert("Email cannot be greater than 100 Characters");
					document.reg_form.email.focus();
					return false;
		}
	
		var str=document.reg_form.email.value;
		var valid=echeck(str);

		if (valid==0)
		{
			//alert('Invalid email id');
			document.reg_form.email.focus();
			return false;
		}
	
	}	



if(document.reg_form.agent.value=="")
	{
     alert("Please mention agent"); 
	 document.reg_form.agent.focus();
	 return false;
	}


if (document.reg_form.agent.value!="")
{
	
	//check for name
	nwstl=document.reg_form.agent.value;

	if (nwstl==0 || nwstl==null)
	{
	alert("Please enter proper value");
	document.reg_form.agent.focus();
	return false;
	}
}


if(document.reg_form.agent.value !="")
	{
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@_/,- \n\r";
  var checkStr = document.reg_form.agent.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert('Data are invalid.Only a-z 0-9 @ _ . , /   are allowed');
    document.reg_form.agent.select();
    return false;
  }
}

if(document.reg_form.agent.value!="")
	{

		if(document.reg_form.agent.value.length > 100)
		{
					alert("Agent cannot be greater than 100 Characters");
					document.reg_form.agent.focus();
					return false;
		}
	}	

	}

if(type=="CON")
	{
		
	if(document.reg_form.fname.value=="" || document.reg_form.fname.value=="First Name")
	{
     alert("Please mention firstname"); 
	 document.reg_form.fname.focus();
	 return false;
	}


	if (document.reg_form.fname.value!="")
	{
		
		//check for name
		nwstl=document.reg_form.fname.value;

		if (nwstl==0 || nwstl==null)
		{
		alert("Please enter proper value");
		document.reg_form.fname.focus();
		return false;
		}
	}


	if(document.reg_form.fname.value !="")
		{
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@_/,- \n\r";
	  var checkStr = document.reg_form.fname.value;
	  var allValid = true;
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
	  }
	  if (!allValid)
	  {
		alert('Data are invalid.Only a-z 0-9 @ _ . , /   are allowed');
		document.reg_form.fname.select();
		return false;
	  }
	}


	if(document.reg_form.lname.value=="" || document.reg_form.lname.value=="Surname")
	{
     alert("Please mention surname"); 
	 document.reg_form.lname.focus();
	 return false;
	}


	if (document.reg_form.lname.value!="")
	{
		
		//check for name
		nwstl=document.reg_form.lname.value;

		if (nwstl==0 || nwstl==null)
		{
		alert("Please enter proper value");
		document.reg_form.lname.focus();
		return false;
		}
	}


	if(document.reg_form.lname.value !="")
		{
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@_/,- \n\r";
	  var checkStr = document.reg_form.lname.value;
	  var allValid = true;
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
	  }
	  if (!allValid)
	  {
		alert('Data are invalid.Only a-z 0-9 @ _ . , /   are allowed');
		document.reg_form.lname.select();
		return false;
	  }
	}



	if(document.reg_form.addr.value=="" || document.reg_form.addr.value=="Address")
	{
     alert("Please mention address"); 
	 document.reg_form.addr.focus();
	 return false;
	}


	if (document.reg_form.addr.value!="")
	{
		
		//check for name
		nwstl=document.reg_form.addr.value;

		if (nwstl==0 || nwstl==null)
		{
		alert("Please enter proper value");
		document.reg_form.addr.focus();
		return false;
		}
	}


	if(document.reg_form.addr.value !="")
		{
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@_/,- \n\r";
	  var checkStr = document.reg_form.addr.value;
	  var allValid = true;
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
	  }
	  if (!allValid)
	  {
		alert('Data are invalid.Only a-z 0-9 @ _ . , /   are allowed');
		document.reg_form.addr.select();
		return false;
	  }
	}


if(document.reg_form.city.value=="" || document.reg_form.city.value=="City")
	{
     alert("Please mention city"); 
	 document.reg_form.city.focus();
	 return false;
	}


	if (document.reg_form.city.value!="")
	{
		
		//check for name
		nwstl=document.reg_form.city.value;

		if (nwstl==0 || nwstl==null)
		{
		alert("Please enter proper value");
		document.reg_form.city.focus();
		return false;
		}
	}


	if(document.reg_form.city.value !="")
		{
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@_/,- \n\r";
	  var checkStr = document.reg_form.city.value;
	  var allValid = true;
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
	  }
	  if (!allValid)
	  {
		alert('Data are invalid.Only a-z 0-9 @ _ . , /   are allowed');
		document.reg_form.city.select();
		return false;
	  }
	}





if(document.reg_form.state.value=="" || document.reg_form.state.value=="State")
	{
     alert("Please mention state"); 
	 document.reg_form.state.focus();
	 return false;
	}


	if (document.reg_form.state.value!="")
	{
		
		//check for name
		nwstl=document.reg_form.state.value;

		if (nwstl==0 || nwstl==null)
		{
		alert("Please enter proper value");
		document.reg_form.state.focus();
		return false;
		}
	}


	if(document.reg_form.state.value !="")
		{
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@_/,- \n\r";
	  var checkStr = document.reg_form.state.value;
	  var allValid = true;
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
	  }
	  if (!allValid)
	  {
		alert('Data are invalid.Only a-z 0-9 @ _ . , /   are allowed');
		document.reg_form.state.select();
		return false;
	  }
	}





if(document.reg_form.pin.value=="" || document.reg_form.pin.value=="postcode")
	{
     alert("Please mention postcode"); 
	 document.reg_form.pin.focus();
	 return false;
	}


	if (document.reg_form.pin.value!="")
	{
		
		//check for name
		nwstl=document.reg_form.pin.value;

		if (nwstl==0 || nwstl==null)
		{
		alert("Please enter proper value");
		document.reg_form.pin.focus();
		return false;
		}
	}


	if(document.reg_form.pin.value !="")
		{
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@_/,- \n\r";
	  var checkStr = document.reg_form.pin.value;
	  var allValid = true;
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
	  }
	  if (!allValid)
	  {
		alert('Data are invalid.Only a-z 0-9 @ _ . , /   are allowed');
		document.reg_form.pin.select();
		return false;
	  }
	}




if(document.reg_form.phone.value=="phone")
	{
     alert("Please mention phone"); 
	 document.reg_form.phone.focus();
	 return false;
	}


	if(document.reg_form.phone.value !="")
		{
	var checkOK = "0123456789()+ ";
	  var checkStr = document.reg_form.phone.value;
	  var allValid = true;
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
	  }
	  if (!allValid)
	  {
		alert('Data are invalid.Only 0-9 allowed');
		document.reg_form.phone.select();
		return false;
	  }
	}





if(document.reg_form.email.value=="" || document.reg_form.email.value=="email")
	{
     alert("Please mention email"); 
	 document.reg_form.email.focus();
	 return false;
	}


if (document.reg_form.email.value!="")
{
	
	//check for name
	nwstl=document.reg_form.email.value;

	if (nwstl==0 || nwstl==null)
	{
	alert("Please enter proper value");
	document.reg_form.email.focus();
	return false;
	}
}


if(document.reg_form.email.value !="")
	{
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.@_/,- \n\r";
  var checkStr = document.reg_form.email.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert('Data are invalid.Only a-z 0-9 @ _ . , /   are allowed');
    document.reg_form.email.select();
    return false;
  }
}

if(document.reg_form.email.value!="")
	{

		if(document.reg_form.email.value.length > 100)
		{
					alert("Email cannot be greater than 100 Characters");
					document.reg_form.email.focus();
					return false;
		}
	
		var str=document.reg_form.email.value;
		var valid=echeck(str);

		if (valid==0)
		{
			//alert('Invalid email id');
			document.reg_form.email.focus();
			return false;
		}
	
	}	

		
	}


if(document.reg_form.qry.value=="enquiry")
	{
     alert("Please mention enquiry"); 
	 document.reg_form.qry.focus();
	 return false;
	}



}


function clr_val()
{
    if(document.reg_form.qry.value=="enquiry")
	{
	//alert("Please mention email sdfsdfsd"); 
	document.reg_form.qry.value="";
	}
	 
	 
}
