﻿// JScript File

/*****************************Code of Home buy/sell/dealer location,Check numeric,check phone no..**************************/


function NumericOnly(a,c)
           {
                   var f=c;
                    if (f.indexOf("(")>-1 )
                    {
                        f=c.substring(0,c.indexOf("("));
                    }
                        var my_string=a.value;
                           if(isNaN(my_string))
                                {
                                      alert("Only numeric values are allowed.");
                                      a.value='';
                                      a.focus();
                                      return false; 
                                 }
                         var d=a.value.length; 
                         if(d>9)
                              {
                                alert("Max limit is 999999999.");
                                return false;
                              }
               	         return true;
	        }

  function checkPhone(a)
           {  
                   var c=a.value.length; 
                     if(c>15)
                      {
                        alert("Max limit is 15 Character.");
                        event.keyCode = 0;
                        a.focus();
				        return false;
                      }
	            if((event.keyCode > 47 && event.keyCode < 58) ||  event.keyCode==13 )
			        {			
			        }			
			    else
			        {
			           event.keyCode = 0;
				        return false;
            	    }
            	return true;
			}
			
  function checkNumeric()
  {
   
       if((event.keyCode > 47 && event.keyCode < 58) ||  event.keyCode==13 )
        {
   					
        }			
    else
        {
   			
            event.keyCode = 0;
	        return false;
   	
           }
   	
       return true;
  }
           
    function checkChar()
   {
   
    
        if((event.keyCode > 97 && event.keyCode < 90)  ||  event.keyCode==13 ||  event.keyCode==8 )
	        {
    					
	        }			
	    else
	        {
    			
	            event.keyCode = 0;
		        return false;
    	
            }
    	
        return true;
	
   
   }
           




function showstate(str)
             {      
                
                 /*Make asyncrhonouz request to searchajax.aspx*/
                   var url="../Customer/Script/Ajax.aspx";
               url=url+"?mode=1&CountryId="+str.value; 
              
                 CountryxmlHttp=GetXmlHttpObject()
                 if (CountryxmlHttp==null)
                    {
    			alert ("Your browser does not support AJAX!");
	    		return;
		    }
		    CountryxmlHttp.onreadystatechange=getCountry;
		    CountryxmlHttp.open("GET",url,true);
    		CountryxmlHttp.send(null);
   	    }
   	    
   	    
     function getCountry()
           { 
	        var str;
	           if (CountryxmlHttp.readyState==4)
                       { 
                            document.getElementById("ddlState").disabled=false;
			                str=CountryxmlHttp.responseText;
			                FillDropDownList(document.getElementById("ddlState"),str);
                       }
            }	
function showcity(str){      
            /*Make asyncrhonouz request to searchajax.aspx*/
            var url="../Customer/Script/Ajax.aspx";
            url=url+"?mode=2&StateId="+str.value;     
            
            StatexmlHttp=GetXmlHttpObject()
            if (StatexmlHttp==null){
    			alert ("Your browser does not support AJAX!");
	    		return;
		    }
		    StatexmlHttp.onreadystatechange=GetState;
		    StatexmlHttp.open("GET",url,true);
    		StatexmlHttp.send(null);
	    }



function GetState(){ 
	        var str;
	         if (StatexmlHttp.readyState==3)
	         {
	           document.getElementById("ddlCity").disabled=true;
	           var optionText = "Loading..."
               var objSelect = document.getElementById("ddlCity");
               objSelect.length=0;
               objSelect[0] = new Option(optionText);
	         }
		    if (StatexmlHttp.readyState==4){ 
		        document.getElementById("ddlCity").disabled=false;
			    str=StatexmlHttp.responseText;
                FillDropDownList(document.getElementById("ddlCity"),str);
              }
            }



  function FillDropDownList(dd1,mainstr)
        {
                
            var str=mainstr.replace("@","").split("|");
        
			dd1.options.length=0;	
			for(inc2=0;inc2<str.length-1;inc2++)
			{	
				var str3=str[inc2].split("#");	
				var newOpt = new Option(str3[1],str3[0]);
				var selLength = dd1.length;
				dd1.options[selLength] = newOpt;
			}
        } 
        


   
function GetXmlHttpObject()
{

	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}



 function cityvalue()
  {
    var a;
    a = document.getElementById("ddlCity").value;
    if (a == -1 || a == -2)
    {
        alert("Select proper value");
        document.getElementById("ddlCity").value = 0;
    }
   
  }

