
// Trim function in javascript 
function Trim(str)
{
    while (str.substring(0,1) == ' ') // check for white spaces from beginning
    {
        str = str.substring(1, str.length);
    }

    while (str.substring(str.length-1, str.length) == ' ') // check white space from end
    {
        str = str.substring(0,str.length-1);
    }
    return str;

}
// EOF Trim function 

function ifcity_india_usa(obj)
{
	if(document.frm1.city.options[document.frm1.city.selectedIndex].text == '- Any in Indian city -')
	{
		document.frm1.city10.disabled = false;
	}
	else
	{
		document.frm1.city10.disabled = true;
	}

}	

function ifcountry_india_usa(obj)
{
	
  if(obj.options[obj.selectedIndex].text == 'India')
	{
		document.frm1.state.disabled = false;

		document.frm1.city.disabled = false;
document.frm1.city10.disabled = true;
document.frm1.city10.value = "";
		document.frm1.state10.value = ""; 

		document.frm1.state10.disabled = true; 

		return true;
	}
	else
	{
		document.frm1.state10.disabled = false; 

		document.frm1.city.disabled = true;

		document.frm1.city10.disabled = false; 
		
		document.frm1.city.value = "";
		
		document.frm1.state[0].selected = true;
		
		document.frm1.state.disabled = true;

		return true;
		}
}



function Full(frm1)

{
var regExp = /^[A-Za-z\s,.()-]/;
var validvalue = /[0-9]/g;
// login
	if((frm1.username.value=="")||(frm1.username.value.indexOf('@',0) != -1)){

			alert("You must enter a valid username.");

			frm1.username.focus();

			return(false);

			}
	//*************username id validation**********
if (isNaN(frm1.username.value)== false){

			alert("Please enter alphanumeric characters .");

			frm1.username.focus();

			return(false);

			}
	// require at least 4 characters in the username field

	if (frm1.username.value.length < 4)

	{

	alert("Please enter at least 4 characters in the username.");

	frm1.username.focus();

	return (false);

	}

	// test if valid username,and must not have @ and .com



	//*************password validation**********

	// require at least 4 characters in the password field

	if (frm1.password.value.length < 4)

	{

	alert("Please enter at least 4 characters in the pasword.");

	frm1.password.focus();

	return (false);

	}

	

	// check if both password fields are the same

	if (frm1.password.value != frm1.cpassword.value)

	{

		alert("The two passwords are not the same.");

		frm1.cpassword.focus();

		return (false);

	}
	//*********blank field******************************************

	// check to see if the field is blank

	

	if((frm1.name.value=="")||(frm1.name.value.indexOf('@',0) !=-1)){

			alert("You must enter a valid name.");

			frm1.name.focus();

			return(false);

			}

			// test if valid name, must not have @ and .com

	var checkname= frm1.name.value;

          for(var i = 0; i < checkname.length; i++)

          {
       
            if (!checkname.charAt(i).match(regExp))

            {
            alert("Invalid Content!.");
			frm1.name.focus();
              return false;

            }

          }

	

	//****************email validation**************

	// check if email field is blank

		if (frm1.email.value == "")

			{

			alert("Please enter a value for the \"Email\" field.");

			frm1.email.focus();

			return(false);

			}



	// test if valid email address, must have @ and .

	

	var checkEmail = "@.";

	var checkStr = frm1.email.value;

	var EmailValid = false;0000000000

	var EmailAt = false;

	var EmailPeriod = false;

		for (i = 0;  i < checkStr.length;  i++)

		{

			ch = checkStr.charAt(i);

				for (j = 0;  j < checkEmail.length;  j++)

				{

					if (ch == checkEmail.charAt(j) && ch == "@")

						EmailAt = true;

					if (ch == checkEmail.charAt(j) && ch == ".")

						EmailPeriod = true;

		  			if (EmailAt && EmailPeriod)

				break;

      	  		if (j == checkEmail.length)

				break;

			}



				// if both the @ and . were in the string

				if (EmailAt && EmailPeriod)

				{

					EmailValid = true

					break;

				}

		}

			

			if (!EmailValid)

				{

					alert("Invalid email ID ! Please enter your valid email ID.");

					frm1.email.focus();

					return(false);

				}



			

				// test if valid address, must not have @ and .com

	// Checking for address
	var checkaddr= Trim(frm1.address.value);
	frm1.address.value=checkaddr;
	
	if (frm1.address.value == "")
	{
		alert("You must specify your Address ");
		frm1.address.focus();
		return(false);
	}

	// test if valid address, must not have @ and .com

	var checkAddress = "@";

	var checkStr = frm1.address.value;

	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);

		for (j = 0;  j < checkAddress.length;  j++)
		{
			if (ch == checkAddress.charAt(j) && ch == "@")
			{	
				alert("'@' is Invalid address content ! Please enter your valid address.");
				frm1.address.focus();
				return(false);
		   }
		}  
    }


	
	

	//***************country*********

	if (frm1.country.selectedIndex == 0)
	{
			alert("Please specify Country of residence");
			frm1.country.focus();
			//frm1.country.focus();
			return(false);
	}

		

/*		var checkstate = "@";

	var checkStr = frm1.state10.value;

		for (i = 0;  i < checkStr.length;  i++)

		{

			ch = checkStr.charAt(i);

				for (j = 0;  j < checkstate.length;  j++)

				{

					if (ch == checkstate.charAt(j) && ch == "@")

					{	

					alert("'@' is Invalid state content ! Please enter your valid state.");

					return(false);

				   }

				 }  

        }*/				

/*	   if (frm1.state.selectedIndex == 0)
		{
	    if(frm1.state10.value==" " || frm1.state10.value =="" || frm1.state10.value =="  " )
		{
			alert("Please specify  State of residence");
			frm1.state10.focus();
			//frm1.state.focus();
			return(false);
		}
		var checkstate= frm1.state10.value;

          for(var i = 0; i < checkstate.length; i++)

          {

            if (!checkstate.charAt(i).match(regExp))

            {
            alert("Invalid Content!");
			frm1.state10.focus();
              return false;

            }

          }

	}*/
	
	if (frm1.state.selectedIndex < 1)
	{
			alert("Please specify  State of residence");
			frm1.state.focus();
			//frm1.state.focus();
			return(false);
	}
		
/*		var checkstate= frm1.state10.value;
        if (validvalue.test(frm1.state10.value))
        {
            alert("No numeric character is allowed.");
			frm1.state10.focus();
            return false;
        }*/



/*	 if (frm1.state.selectedIndex > 0)

	 {

	    if(frm1.state10.value!="")

	    {

            alert("Please specify Your one State of residence");
            frm1.state.focus();
		return(false);

		}

      }*/

	
/*
	var checkcity = "@";

	var checkStr = frm1.city10.value;

		for (i = 0;  i < checkStr.length;  i++)

		{

			ch = checkStr.charAt(i);

				for (j = 0;  j < checkcity.length;  j++)

				{

					if (ch == checkcity.charAt(j) && ch == "@")

					{	

					alert("'@' is Invalid city content ! Please enter your valid city.");

				

					return(false);

				   }

				 }  

        }*/
	

/*	if (frm1.city.selectedIndex == 0)
	{
	    if(frm1.city10.value=="" )
		{
			alert("You must enter a value for the City field");
			frm1.city10.focus();
			//frm1.city.focus();
			return(false);
		}
		
    	var check_city= frm1.city10.value;
		if (validvalue.test(frm1.city10.value))
    	{
	    	alert("No numeric character is allowed.");
			frm1.city10.focus();
	        return false;
	    }
	}*/	
	if (frm1.city.selectedIndex == 0)
	{
			alert("You must enter a value for the City field");
			frm1.city.focus();
			//frm1.city.focus();
			return(false);
    
	}	

		
if (frm1.acceptterms.checked == false)

	{

	alert("Pls. select the box  to accept the Terms and Conditions of Services provided by marraigearrangements.com.");

	frm1.acceptterms.focus();

	return (false); 

	}	

}


