﻿function leadsreset()
    {
    //document.getElementById("txtName").value==""
        document.myform.reset();
     
        return false;
    }  
function checkEmail(str) 
		{		
		  var ePass = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;	
		  if (!ePass.test(str))
			{
				alert("Please enter valid Email ID");
				return false;
			}
  		  return true;		
		}
function charsponly(e)
	    {	
		    var unicode=e.charCode? e.charCode : e.keyCode			
		    if (unicode!=8  && unicode!=46)
		    {
			    if ((unicode>64 && unicode<91) || (unicode>96 && unicode<123) || unicode==9  || unicode==32) 
			    return true;
			    else return false;
		    }
	    }
	    function isMaximum(string) 
     {
        if (string.search(/^[a-zA-Z0-9/.,#&)(\s ]+$/) != -1)
            return true;
        else
            return false;
    }
function isProper(string) {

       if (!string) return false;
       var iChars = "*|,\":<>[]{}`\';()@&$#%";

       for (var i = 0; i < string.length; i++) {
          if (iChars.indexOf(string.charAt(i)) != -1)
             return false;
       }
       return true;
    }	
function leadsvalidation()
        {       
            if(document.getElementById("txtName").value=="")
                {
                    alert("Please enter your Name");
                    document.getElementById("txtName").focus();
                    return false
                }
            var checkOKDL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";	    
    	 
            var checkStrDL = document.getElementById("txtName").value;
            var allValidDL = true;
	           for (i = 0;  i < checkStrDL.length;  i++)
	              {
		            chDL = checkStrDL.charAt(i);
		            for (j = 0;  j < checkOKDL.length;  j++)
		              if (chDL == checkOKDL.charAt(j))
			            break;
		            if (j == checkOKDL.length)
		            {
		              allValidDL = false;
		              break;
		            }
	              }
          
            if (!allValidDL)
              {
	             alert("Please enter valid name");
	              document.getElementById("txtName").focus(); 
	             return false;
              }
            if(document.getElementById("txtEmailid").value=="" || document.getElementById("txtEmailid").value=="E-mail *")
                {
                    alert("Please enter your Email ID.");
                    document.getElementById("txtEmailid").focus();
                    return false
                }            
            if(document.getElementById("txtEmailid").value!="" && !checkEmail(document.getElementById("txtEmailid").value))
			     {
				    document.getElementById("txtEmailid").focus();	
				    document.getElementById("txtEmailid").select();			
				    return false;
			     }
			     if(document.getElementById("txtCountry").value!="")
			     {
			     if (isProper(document.getElementById("txtCountry").value) == false)
                        {
                             alert("Please enter valid Country");
                             document.getElementById("txtCountry").focus();
                             return false;
                    }
				    
			     }    
			     if(document.getElementById("txtCity").value!="")
			     {
			     if (isProper(document.getElementById("txtCity").value) == false)
                        {
                             alert("Please enter valid City");
                             document.getElementById("txtCity").focus();
                             return false;
                    }
				    
			     }   
            if(isNaN(document.getElementById("txtMobileNo").value)&& (document.getElementById("txtMobileNo").value!="")&&(document.getElementById("txtMobileNo").value!="Mobile/Landline"))
                {
                    alert("Please enter a valid Contact No.");
                    document.getElementById("txtMobileNo").focus();
                    document.getElementById("txtMobileNo").select();
                    return false
                }
                 if(document.getElementById("txtOthers").value!="")
			     {
			     if (isMaximum(document.getElementById("txtOthers").value) == false)
                        {
                             alert("Please enter valid data in others Field");
                             document.getElementById("txtOthers").focus();
                             return false;
                         }
				    
			      }
			      if(document.getElementById("txtFeedback").value!="")
			     {
			     
			      if (isMaximum(document.getElementById("txtFeedback").value) == false)
                        {
                             alert("Please enter valid Feedback");
                             document.getElementById("txtFeedback").focus();
                             return false;
                        }
				    
			     }
             if(document.getElementById("txtFeedback").value.length > 1000)
             {
                alert("Feedback cannot exceed more than 1000 characters");
                document.getElementById("txtFeedback").focus();
                document.getElementById("txtFeedback").select();
                return false
             }
            return true;
        }
 function showsurveyform()
    { 
		var xmlHttp;
		try
			{  
				xmlHttp=new XMLHttpRequest();  
			}
		catch (e)
			{      
			try
				{      
				  
				  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
				}
			catch (e)
			  {      
				  try
					{       
						
					 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");       
					  }
				  catch (e)
					{        
						
						alert("Your browser does not support AJAX!");        
						return false;       
					 }     
			  } 
		 }
			xmlHttp.onreadystatechange=function()
			  {
			  
			  if(xmlHttp.readyState==4)
				{				 	
					if(xmlHttp.responseText!='')
						{
							document.getElementById("Popup").innerHTML =xmlHttp.responseText;
		                    document.getElementById("Popup").style.display = "block";					
						}
				}
			  }
					
		xmlHttp.open("GET","/applications/survey_form.aspx",false);		
		xmlHttp.send(null);
    }
  function hidesurveyform()
  {
    document.getElementById("Popup").innerHTML ='';
    document.getElementById("Popup").style.display = "none";
  }