﻿// JScript File

function OnLoadActivity()
{

   var divshow=document.getElementById('hdShowDiv');

   if(divshow.value !='NO')
   {
   
      ShowDiv();
        document.getElementById('ddlName').style.display="none";
        document.getElementById('Tax_receipt').style.display="none";
        document.getElementById('ddlState2').style.display="none";
        document.getElementById('ddlCountry2').style.display="none";
   }            
          
}
var productid        = null;
var Variantid        = null;
var Tax_Benefit_Name = null;
var _ProductId;
var _VarientId;
var _TaxBenefitName;

function ShowDiv()
{
	  //alert('IN SHOW DIV');
	  var Productid=document.getElementById('hdProductid').value;
      var Varientid= document.getElementById('hdvarientid').value;
      var Taxbenefit=document.getElementById('hdProductype').value;
			
	  _ProductId=Productid;
	  _VarientId=Varientid;
	  _TaxBenefitName=Taxbenefit;
	  
	  //alert(_ProductId);
      //alert(_VarientId);
     // alert(_TaxBenefitName);
	  
	  var customerTPS = document.getElementById('hdCustomerTpssigin').value;
	  var customerPan =document.getElementById('hdCustomerPansignin').value;
      //alert(customerTPS);			    
      //alert(customerPan );
      if( _TaxBenefitName.toUpperCase() == "35AC" || _TaxBenefitName.toUpperCase() == "35(1)(ii)" || _TaxBenefitName.toUpperCase() == "35(1)(iii)")
	  {
	    //alert('Rao');
    	if(customerTPS.toUpperCase()== "INR" || customerTPS.toUpperCase()== "NRI" || customerTPS.toUpperCase()== "OTH")
		{
		  //  alert('InCustomer TPS');
        	if(customerPan == "")
			{
			//    alert('InCustomer pan empty');
    			divid();
			}
			else
			{
			  //  alert('InCustomer pan not empty');
    			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()
{
   
   document.getElementById('divfillpan').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";
   document.location.href="searchadv.aspx";
}
function CloseNonExistPanDiv()
{
    var divid=document.getElementById('dvpopup');
    divid.style.visibility="hidden";
    var divid1=document.getElementById('divfillpan');
    divid1.style.visibility="hidden";
    document.getElementById('txtPannumber').value="";
    document.location.href="searchadv.aspx";
}
function divid()
{ 
    var divid=document.getElementById('dvpopup');           
    divid.style.visibility="visible"; 
}

function divexistpan()
{          
    var divid=document.getElementById('dvexistpan');             
    divid.style.visibility="visible";            
}
function checkPannumberSign()
{            
         
          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();
      }
  }   	
