﻿// JScript File

var productid        = null;
var Variantid        = null;
var Tax_Benefit_Name = null;

var _ProductId;
var _VarientId;
var _TaxBenefitName;
				
function validateNumbers()
{
	
	if(document.getElementById("txtBudget").value != "")
	  {
		if(document.getElementById("txtBudget").value == "")
    	 {
    	   alert("Please Enter Amount");
    	   return false;
    	  }
    	if(document.getElementById("txtBudget").value == 0)
    	 {
    	   alert("Amount can't be Zero");
    	   return false;
    	 }
		var sFullNumber = document.getElementById("txtBudget").value;
		var reg= /^[0-9]\d*$/;
        var matchArray = sFullNumber.match(reg);
		if (matchArray == null)
		 {
			alert("Please Enter Whole Numbers Only");
            return false;
         }
		if(isNaN(sFullNumber))
		{
			alert("Only Whole Numbers Are Allowed ");
			return false;
		}
	}
			
}
								
				
				function ShowDiv(productid,Variantid,Tax_Benefit_Name)
				{
				    
				    _ProductId=productid;
				    
				    _VarientId=Variantid;
				    
				    _TaxBenefitName=Tax_Benefit_Name;
				    
    				
				       var customerTPS = document.getElementById('hdCustomerTpsDS').value;
				       var customerPan = document.getElementById('hdCustomerPanDS').value;
    				    
    				   
				         if( Tax_Benefit_Name.toUpperCase() == "35AC" || Tax_Benefit_Name.toUpperCase() == "35(1)(ii)" || Tax_Benefit_Name.toUpperCase() == "35(1)(iii)")
				         {
    				   
				           if(customerTPS.toUpperCase()== "INR" || customerTPS.toUpperCase()== "NRI" || customerTPS.toUpperCase()== "OTH")
				               {
    				            
        				        
				                 if(customerPan == "")
				                     {
    				                     
    				                      divid();
				                     }
				                 else
				                     {
    				                    
    				                    divexistpan();
				                     }
				               }
				           else
				               {
        				         document.location.href="AddtoCart.aspx?ProductID="+_ProductId+"&VariantID="+_VarientId+"&CartRecID="+0+"&IsGifted="+0+"&Product_Type="+_TaxBenefitName;
				               }
				       }
				       else
				       {
				          document.location.href="AddtoCart.aspx?ProductID="+_ProductId+"&VariantID="+_VarientId+"&CartRecID="+0+"&IsGifted="+0+"&Product_Type="+_TaxBenefitName;
				       }
				}
           function ProceedAs80G()
            {                  
            document.location.href="AddtoCart.aspx?ProductID="+_ProductId+"&VariantID="+_VarientId+"&CartRecID="+0+"&IsGifted="+0+"&Product_Type="+"80G";
            }

            function Get35ACtaxReceipt()
            {  
             document.location.href="AddtoCart.aspx?ProductID="+_ProductId+"&VariantID="+_VarientId+"&CartRecID="+0+"&IsGifted="+0+"&Product_Type="+_TaxBenefitName;
            }
            
            function Get80GtaxReceipt()
            { 
            document.location.href="AddtoCart.aspx?ProductID="+_ProductId+"&VariantID="+_VarientId+"&CartRecID="+0+"&IsGifted="+0+"&Product_Type="+"80G";
            }

            function showPanDiv()
            {
            var divid1=document.getElementById('divfillpan');
            divid1.style.visibility="visible";
            }

            function HideDiv()
            {
            var divid1=document.getElementById('divfillpan');
            divid1.style.visibility="hidden";
            var divid=document.getElementById('dvpopup');
            divid.style.visibility="hidden";
            document.getElementById('txtPannumber').value="";
            document.location.href="donationsearch.aspx";
            }
            function CloseExistPanDiv()
            {
                    var divid=document.getElementById('dvexistpan');
                    divid.style.visibility="hidden";
            }
             function CloseNonExistPanDiv()
             {
                var divid=document.getElementById('dvpopup');
                divid.style.visibility="hidden";
                var divid1=document.getElementById('divfillpan');
                divid1.style.visibility="hidden";
                document.getElementById('txtPannumber').value="";
             }
            function divid()
            { 
                var divid=document.getElementById('dvpopup');           
                divid.style.visibility="visible"; 
            }

            function divexistpan()
            { 
           
                var divid=document.getElementById('dvexistpan');             
                divid.style.visibility="visible";            
            }

           
            function checkPannumber()
            {            
                
                var pannumber=document.getElementById('txtPannumber').value;

                var _panumber          = document.getElementById('txtPannumber').value;

                if(_panumber.length != "" || _panumber.length != 0)
                    {
                        if(_panumber.length > 0 )
                            {
           
                
                                
                                var _str               = /^[a-zA-Z]+$/;
                                var _str1              = "CPHFATBLJG";
                                var _str2              = /^[0-9]\d*$/;

                                if ( _panumber.length == 10)
                                {

                                    var _firstThreeValidation = _panumber.substring(0,3);

                                    var _fourthValidation     = _panumber.substring(3,4);

                                    var _fifthValidation      = _panumber.substring(4,5);

                                    var _NumericValidation    = _panumber.substring(5,5+4);

                                    var _tenthValidation      = _panumber.substring(9,9+1);


                                    if (_firstThreeValidation.search(_str) != -1)
                                    {

                                            if (_str1.toUpperCase().indexOf(_fourthValidation.toUpperCase()) > -1)
                                            {

                                                if (_fifthValidation.search(_str)!= -1)
                                                 {

                                                    if (_NumericValidation.search(_str2) != -1)
                                                    {

                                                        if (_tenthValidation.search(_str) != -1)
                                                        {
                                                         document.location.href="AddtoCart.aspx?ProductID="+_ProductId+"&VariantID="+_VarientId+"&CartRecID="+0+"&IsGifted="+0+"&PanNumber="+pannumber+"&Product_Type="+_TaxBenefitName;
                                                         }
                                                        else
                                                        {

                                                        alert("Please enter a valid PAN NUMBER");
                                                        document.getElementById('txtPannumber').focus();
                                                        }
                                                    }
                                                    else
                                                    {
                                                        alert("Please enter a valid PAN NUMBER");
                                                        document.getElementById('txtPannumber').focus();
                                                    }
                                                 }
                                                 else
                                                 {
                                                    alert("Please enter a valid PAN NUMBER");
                                                    document.getElementById('txtPannumber').focus();
                                                 }
                                            }
                                            else
                                            {
                                                    alert("Please enter a valid PAN NUMBER");
                                                    document.getElementById('txtPannumber').focus();
                                            }

                                                }
                                                else
                                                {
                                                alert("Please enter a valid PAN NUMBER");
                                                document.getElementById('txtPannumber').focus();
                                                }
                                            }
                                            else
                                            {
                                            alert("Please enter a valid PAN NUMBER");
                                            document.getElementById('txtPannumber').focus();

                                            }
                                    }
                                    else
                                    {
                                         return true;
                                    }
                                  }
                                  else
                                  {
                                    alert("Please enter a PAN NUMBER");
                                    document.getElementById('txtPannumber').focus();
                                  }
            }
           