﻿function leadsreset()
    {
        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 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(!fldValValidator(document.getElementById("txtCountry").value))
				{
					alert("Please enter a valid country");
					document.getElementById("txtCountry").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(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(!fldValValidator(document.getElementById("txtCity").value))
				{
					alert("Please enter a valid city");
					document.getElementById("txtCity").focus();
					return false;
				}
			 if(!fldValValidator(document.getElementById("txtOthers").value))
				{
					alert("Please enter a valid suggestion");
					document.getElementById("txtOthers").focus();
					return false;
				}
			if(!fldValValidator(document.getElementById("txtFeedback").value))
				{
					alert("Please enter a 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
             }
           submitformdata();
           return false;
        }
 function submitformdata()
    { 
		var xmlHttp;
		var targeturl;
		var varcomfort, varwhtmore, varlook;
		varcomfort = varwhtmore = varlook = "";
		if(document.SurveyForm.chkComfort[0].checked==true)
		    {
		        varcomfort = "bad";
		    }
		else if(document.SurveyForm.chkComfort[1].checked==true)
		    {
		        varcomfort = "ok";
		    }
		else if(document.SurveyForm.chkComfort[2].checked==true)
		    {
		        varcomfort = "good";
		    }
		    
		if(document.SurveyForm.chkWhatMore[0].checked==true)
		    {
		        varwhtmore = "Product information";
		    }
		else if(document.SurveyForm.chkWhatMore[1].checked==true)
		    {
		        varwhtmore = "Colour ideas";
		    }
		else if(document.SurveyForm.chkWhatMore[2].checked==true)
		    {
		       varwhtmore = "Contact points";
		    }
		else if(document.SurveyForm.chkWhatMore[3].checked==true)
		    {
		       varwhtmore = "Others";
		    }
		
		if(document.SurveyForm.chkLook[0].checked==true)
		    {
		        varlook = "good";
		    }
		else if(document.SurveyForm.chkLook[1].checked==true)
		    {
		        varlook = "ok";
		    }
		else if(document.SurveyForm.chkLook[2].checked==true)
		    {
		        varlook = "bad";
		    }		
		targeturl = "/applications/Submitsurvey.aspx";
		targeturl = targeturl + "?txtName="+document.getElementById("txtName").value;
		targeturl = targeturl + "&txtCountry="+document.getElementById("txtCountry").value;
		targeturl = targeturl + "&txtEmailid="+document.getElementById("txtEmailid").value;
		targeturl = targeturl + "&txtCity="+document.getElementById("txtCity").value;
		targeturl = targeturl + "&txtMobileNo="+document.getElementById("txtMobileNo").value;
		targeturl = targeturl + "&chkComfort="+varcomfort;
		targeturl = targeturl + "&chkLook="+varlook;
		targeturl = targeturl + "&chkWhatMore="+varwhtmore;
		targeturl = targeturl + "&txtFeedback="+document.getElementById("txtFeedback").value;
		targeturl = targeturl + "&txtOthers="+document.getElementById("txtOthers").value;
		
		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",targeturl,true);		
		xmlHttp.send(null);
    }
 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";					
		                    setTimeout("document.getElementById('Popup').style.display = 'block'",5000);
							if(document.getElementById("iSurveyForm")!=null)
								{
									document.getElementById('iSurveyForm').style.display = 'block';
								}
						}
				}
			  }
					
		xmlHttp.open("GET","/applications/survey_form.aspx",true);		
		xmlHttp.send(null);
    }
  function hidesurveyform()
  {
    document.getElementById("Popup").innerHTML ='';    
	if(document.getElementById("iSurveyForm")!=null)
		{
			document.getElementById('iSurveyForm').style.display = 'none';
		}
	document.getElementById("Popup").style.display = "none";
  }
  
  function fldValValidator(fldval)
    {
      var checkAdd = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890#&()-//., ";
      var checkStrAdd = fldval;
    	
      var allValidAdd = true;
	      for (m = 0;  m< checkStrAdd.length;  m++)
		      {
			    ch = checkStrAdd.charAt(m);
			    for (n = 0;  n < checkAdd.length;  n++)
				    if (ch == checkAdd.charAt(n))
				    break;
				    if (n == checkAdd.length)
					    {						
						    allValidAdd = false;
						    break;
					    }
		      }

	    if (allValidAdd==false)
		     {				
			    return false;
		     }
	    else
		     {				
			    return true;
		     }
    }