// JavaScript Document

function MM_findObj(n, d) { //v4.01

  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

  if(!x && d.getElementById) x=d.getElementById(n); return x;

}



function MM_validateForm() { //v4.0

  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;

  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);

    if (val) { nm=val.name; if ((val=val.value)!="") {

      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');

        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';

      } else if (test!='R') { num = parseFloat(val);

        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';

        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');

          min=test.substring(8,p); max=test.substring(p+1);

          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';

    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }

  } if (errors) alert('The following error(s) occurred:\n'+errors);

  document.MM_returnValue = (errors == '');

}

//-->



function chk_string( str, req, min, max )// Checking the lent of the text box

{

	if( str.length == 0 && !req )

		return 0;

	if( str.length < min || str.length > max )

		return 1;

	return 0;

}





function chk_email( str, req )

{

	var email_RegEx = /^\w+([-.]\w+)*\@\w+([-.]\w+)*\.\w+$/;

	if( str.length == 0 && !req )

	    return 0;

	var found = email_RegEx.test( str );

	if( found == false )

	    return 1;

	return 0;

}

function datavalidation()
{	


	
	
	if( chk_string( document.form.name.value, 1, 2, 100 ) )
	{
		alert("Name is not specified");

		document.form.name.focus();

		return false;
	}	

	/*if( chk_string( document.form.designation.value, 1, 2, 100 ) )

	{

		alert("Designation is not specified");

		document.form.designation.focus();

		return false;

	}	*/

	if( chk_string( document.form.company.value, 1, 2, 200 ) )
	{
		alert("Company is not specified");

		document.form.company.focus();

		return false;
	}	

	if( chk_string( document.form.address1.value, 1, 2, 1000 ) )
	{
		alert("Address 1 is not specified");

		document.form.address1.focus();

		return false;
	}	

	if( chk_string( document.form.address2.value, 1, 2, 1000 ) )
	{
		alert("Address 2 is not specified");

		document.form.address2.focus();

		return false;
	}	

	if( chk_string( document.form.city.value, 1, 2, 100 ) )
	{
		alert("City is not specified");

		document.form.city.focus();

		return false;
	}	

	if( chk_string( document.form.postal_code.value, 1, 2, 50 ) )
	{
		alert("Postal Code is not specified");

		document.form.postal_code.focus();

		return false;
	}	

	/*if( chk_string( document.form.state.value, 1, 2, 350 ) )

	{

		alert("State is not specified");

		document.form.state.focus();

		return false;

	}	

	if( chk_string( document.form.country.value, 1, 2, 350 ) )
	{

		alert("Country is not specified");

		document.form.country.focus();

		return false;

	}	*/

	if( chk_string( document.form.telephone.value, 1, 2, 50 ) )
	{
		alert("Telephone No. is not specified");

		document.form.telephone.focus();

		return false;
	}	

	/*if( chk_string( document.form.mobile.value, 1, 2, 50 ) )

	{

		alert("Mobile No. is not specified");

		document.form.mobile.focus();

		return false;

	}	

	

	if( chk_string( document.form.fax.value, 1, 2, 50 ) )

	{

		alert("Fax No. is not specified");

		document.form.fax.focus();

		return false;

	}	

	*/

	 if( chk_email( document.form.email1.value, 1, 2, 200 ) )
	{
		alert("Email address 1 invalid or not specified");

		document.form.email1.focus();

		return false;
	} 

	/*if( chk_email( document.form.email2.value, 1, 2, 50 ) )

		{

			alert("Email address  2 invalid or not specified");

			document.form.email2.focus();

			return false;

		}

	

		

	if( chk_string( document.form.website.value, 1, 2, 150 ) )

	{

		alert("Website URL is not specified");

		document.form.website.focus();

		return false;

	}	*/

	if( chk_string( document.form.your_product.value, 1, 2, 1000 ) )
	{
		alert("Your Product is not specified");

		document.form.your_product.focus();

		return false;
	}	
	
	if( chk_string( document.form.captcha.value, 1, 2, 50 ) )
	{
		alert("Security Code is not specified");

		document.form.captcha.focus();

		return false;
	}	
	
	validateCaptcha()

	//validateCaptcha();
	/*if( chk_string( document.form.interested_product.value, 1, 2, 350 ) )

	{

		alert("Interested Product is not specified");

		document.form.interested_product.focus();

		return false;

	}

	

	 if((document.form.interest5.checked == false)&&( chk_string( document.form.interest_visiting_other.value, 1, 2, 50 )))

	{

		alert("Other option is not specified");

		document.form.interest_visiting_other.focus();

		return false;

	}*/

	//document.form.action="../registration/reg-thank-you.php";
}

function  check()
{

	  if ( document.form.interest5.checked == false )

	  {  

			document.getElementById('interest_visiting_other').style.visibility='hidden';

      }

	    else

      {     

	  		document.getElementById('interest_visiting_other').style.visibility='visible';

       }  

}

function numbersonly(e)
{

	var unicode=e.charCode? e.charCode : e.keyCode
	
	if (unicode!=8)
	
	if (unicode<48||unicode>57) 
	
	return false 
}




