// Java Document

/*function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
}*/

function isEmail(val)
{
    var iEmail = false;

    if (val.length > 0)
    {
        e = val
        if ((e.indexOf("@") > 0) && (e.indexOf(".") > 0) && (e.length > 5))
            iEmail = true;
        else    
            iEmail = false;
    }
    return iEmail;
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


function frmSubmit()
{
	if ( frm.term.checked == true ) 
	{
		// Checking ID
		if ( frm.t1.value == "" )
		{
			alert ( "ID should enter ! " ); frm.t1.focus(); return false;
		}
		//checks character length
		if ( frm.t1.value.length < 4 ) { alert ( "Minimum 4 charcters should enter" ); frm.t1.focus();	return false; }

		//Checking Password1
		if ( frm.t2.value == "")
		{
			alert ( "Password must enter ! " ); frm.t2.focus(); return false;
		}
		//Checks character length
		if ( frm.t2.value.length < 4 ) { alert ( "Minimum 4 charcters should enter" ); frm.t2.focus();	return false; }

		//Checking password2
		if ( frm.t3.value == "")
		{
			alert ( "Password must enter ! " ); frm.t3.focus(); return false;
		}
		// comparing passwords
		if (  frm.t2.value != frm.t3.value  ) { alert ( "The retyped password not matched" ); frm.t3.focus(); return false; }

		//Checking Name
		if ( frm.t4.value == "" )
		{
			alert ( "Your name should enter ! " ); frm.t4.focus(); return false;
		}

		//Checking State 
		if ( frm.t10.value == "" )
		{
			alert ( "State not be blank " ); frm.t10.focus(); return false; 
		}
	
		//Checking Phone 
		if ( frm.t13.value == "" )
		{
			alert ( "Phone not be blank " ); frm.t13.focus(); return false; 
		}

		//Checking Email
		if ( frm.t15.value == "" )
		{
			alert ( "e-Mail not be blank " ); frm.t15.focus(); return false; 
		}
		
		//Validating Email
		if ( !isEmail ( frm.t15.value ) ) 
		{
			alert ( "Not a valid e-Mail " ); frm.t15.focus(); return false; 
		}
		if ( frm.t8a.value == "" )
		{
			alert ( "House/Plot Nubmber can not be blank " ); frm.t8a.focus(); return false; 
		}
		if ( frm.t8b.value == "" )
		{
			alert ( "Street can not be blank " ); frm.t8b.focus(); return false; 
		}
		if ( frm.t8c.value == "" )
		{
			alert ( "City can not be blank " ); frm.t8c.focus(); return false; 
		}
		if ( frm.t12.value == "" )
		{
			alert ( "Pin/Zip code can not be blank " ); frm.t12.focus(); return false; 
		}
		if ( frm.t9.value == "" )
		{
			alert ( "District can not be blank " ); frm.t9.focus(); return false; 
		}
		if ( frm.t10.value == "" )
		{
			alert ( "State/Province can not be blank " ); frm.t10.focus(); return false; 
		}
		if ( frm.p1.value == "" )
		{
			alert ( "Title can not be blank " ); frm.p1.focus(); return false; 
		}
		if ( frm.p2.value == "" )
		{
			alert ( "Location can not be blank " ); frm.p2.focus(); return false; 
		}
		if ( frm.p2a.value == "" )
		{
			alert ( "Description can not be blank " ); frm.p2a.focus(); return false; 
		}
		if ( ( frm.p3.value == "" ) || (  !IsNumeric(frm.p3.value) ) )
		{
			alert ( "Area can not be blank / Use numbers only in the area field. eg:- 65" ); frm.p3.focus(); return false; 
		}
		if ( ( frm.p4.value == "" ) || (  !IsNumeric(frm.p4.value) ) )
		{
			alert ( "Price can not be blank / Use numbers only in the price field. eg:- 125000" ); frm.p4.focus(); return false; 
		}
		if ( frm.punit.value == 0 )
		{
			alert ( "Select a value " ); frm.punit.focus(); return false; 
		}
		if ( frm.munit.value == 0 )
		{
			alert ( "Select a value " ); frm.munit.focus(); return false; 
		}
		if ( frm.category.value == 0 )
		{
			alert ( "Select a value " ); frm.category.focus(); return false; 
		}
		
		frm.submit();
		return true;
	}
	else
	{
		alert ("You have to agree \n with the terms and conditions");
		frm.term.focus();
		return false;
	}
}


