﻿           
       function closewin()
        {
            window.close();
        }
        
    
      function Demo_OpenPopuphscode()
        {        
            window.open('Demo-HSCodeLocator.aspx','HSCODELOCATOR','scrollbars=yes,top=0, left=560, status=yes, width=704, height=620');
            return false;
        }    


    function GetRowValuehscode(val,id)
        {      
         if(document.getElementById(id).checked)
           {                     
                var sat_hscodelen = window.opener.document.getElementById('ctl00_BodyContents_txthscode').value.length;
                var sat_hscodevalue = window.opener.document.getElementById('ctl00_BodyContents_txthscode').value;
                var sat_hscodecomma = sat_hscodevalue.lastIndexOf(',');           
                if ((window.opener.document.getElementById('ctl00_BodyContents_txthscode').value).match(val + ',') === null)
                    {
                    if(((sat_hscodecomma + 1) === sat_hscodelen))
                        {
                        window.opener.document.getElementById('ctl00_BodyContents_txthscode').value = window.opener.document.getElementById('ctl00_BodyContents_txthscode').value + val  + ','; 
                        }
                    else
                        {
                        window.opener.document.getElementById('ctl00_BodyContents_txthscode').value = window.opener.document.getElementById('ctl00_BodyContents_txthscode').value + ',' + val  + ','; 
                        }         
                    }
           }
          else
          {
          //if value are available in the parent checkbox                
            if ((window.opener.document.getElementById('ctl00_BodyContents_txthscode').value).match(val + ',') !== null)
               {   
                var sat_rep = (window.opener.document.getElementById('ctl00_BodyContents_txthscode').value).match(val + ',');                  
                window.opener.document.getElementById('ctl00_BodyContents_txthscode').value = window.opener.document.getElementById('ctl00_BodyContents_txthscode').value.replace(sat_rep,'');
               }  
          }               
        }
        
      

  function Demo_OpenPopupforeigncountry()
        {              
            window.open('Demo-ForCountryLocator.aspx','FORCOUNTRYLOCATOR','scrollbars=yes, top=0, left=600, status=yes, width=443, height=620');                                   
            return false;
        }      
        
        

      
  function GetRowValueforcountry(val,id)
        {        
         if(document.getElementById(id).checked)
           {    
                var sat_forcount_len = window.opener.document.getElementById('ctl00_BodyContents_txtforeigncontry').value.length;
                var sat_forcount_value = window.opener.document.getElementById('ctl00_BodyContents_txtforeigncontry').value;
                var sat_for_count_comma = sat_forcount_value.lastIndexOf(',');           
                if ((window.opener.document.getElementById('ctl00_BodyContents_txtforeigncontry').value).match(val + ',') === null)
                    {
                    if(((sat_for_count_comma + 1) === sat_forcount_len))
                        {
                        window.opener.document.getElementById('ctl00_BodyContents_txtforeigncontry').value = window.opener.document.getElementById('ctl00_BodyContents_txtforeigncontry').value + val  + ','; 
                        }
                    else
                        {
                        window.opener.document.getElementById('ctl00_BodyContents_txtforeigncontry').value = window.opener.document.getElementById('ctl00_BodyContents_txtforeigncontry').value + ',' + val  + ','; 
                        }         
                    } 
           }
        else
          {
          //if value are available in the parent checkbox                
            if ((window.opener.document.getElementById('ctl00_BodyContents_txtforeigncontry').value).match(val + ',') !== null)
               {   
                var sat_rep = (window.opener.document.getElementById('ctl00_BodyContents_txtforeigncontry').value).match(val + ',');                  
                window.opener.document.getElementById('ctl00_BodyContents_txtforeigncontry').value = window.opener.document.getElementById('ctl00_BodyContents_txtforeigncontry').value.replace(sat_rep,'');
               }  
          }             
        }       
        
        
  function Demo_OpenPopupforeignport()
        {              
            window.open('Demo-ForPortLocator.aspx','ForPortLoc','scrollbars=yes, top=0, left=600, status=yes, width=443, height=620');                                   
            return false;
        } 
   
   
     function getforportval(val,id)
        {        
         if(document.getElementById(id).checked)
           {    
                var sat_forcount_len = window.opener.document.getElementById('ctl00_BodyContents_txtforeignport').value.length;
                var sat_forcount_value = window.opener.document.getElementById('ctl00_BodyContents_txtforeignport').value;
                var sat_for_count_comma = sat_forcount_value.lastIndexOf(',');           
                if ((window.opener.document.getElementById('ctl00_BodyContents_txtforeignport').value).match(val + ',') === null)
                    {
                    if(((sat_for_count_comma + 1) === sat_forcount_len))
                        {
                        window.opener.document.getElementById('ctl00_BodyContents_txtforeignport').value = window.opener.document.getElementById('ctl00_BodyContents_txtforeignport').value + val  + ','; 
                        }
                    else
                        {
                        window.opener.document.getElementById('ctl00_BodyContents_txtforeignport').value = window.opener.document.getElementById('ctl00_BodyContents_txtforeignport').value + ',' + val  + ','; 
                        }         
                    } 
           }
        else
          {
          //if value are available in the parent checkbox                
            if ((window.opener.document.getElementById('ctl00_BodyContents_txtforeignport').value).match(val + ',') !== null)
               {   
                var sat_rep = (window.opener.document.getElementById('ctl00_BodyContents_txtforeignport').value).match(val + ',');                  
                window.opener.document.getElementById('ctl00_BodyContents_txtforeignport').value = window.opener.document.getElementById('ctl00_BodyContents_txtforeignport').value.replace(sat_rep,'');
               }  
          }             
        }       
 
        
        
        
 
   function getDropDownListvalue()
    {
        var IndexValue = window.document.getElementById('ddlCriteria').selectedIndex;
        var SelectedVal = window.document.getElementById('ddlCriteria').options[IndexValue].value;
        
        if(SelectedVal === '1')
            {           
                
                if(window.document.getElementById('txt_searchbox').value.length < 4)
                    {
                    alert('Please Provide At-Least 4 Digits On HsCode Search!');
                    return false ;
                    }
            }
       
        if(SelectedVal === '2')
            {
             
                if(window.document.getElementById('txt_searchbox').value.length < 3)
                    {
                    alert('Please Provide At-Least 3 Characters On Product Search!');
                    return false;
                    }            
            }   
    }  
    
    
 function satonlynumber_hscode(e)         
    {
        var IndexValue = window.document.getElementById('ddlCriteria').selectedIndex;
        var SelectedVal = window.document.getElementById('ddlCriteria').options[IndexValue].value;
        
        if(SelectedVal === '1')
            {
                    var code;   
                    e = e || window.event;
                if (e.keyCode) 
                    {
                        code = e.keyCode;   
                    } 
                else if (e.which) 
                    {
                        code = e.which;
                    }

                if (code === 32) 
                    {
                        e.cancelBubble = true;
                        e.returnValue = false;
                    
                        if (e.stopPropagation) 
                            {
                                e.stopPropagation();
                                e.preventDefault();
                            }
                    return false;
                    }   
   
    if((code < 48 || code >57) && (code !== 8) && (code !== 44) && (code !== 46) && (code !== 37) && (code !== 39))
    {
        e.cancelBubble = true;
        e.returnValue = false;
        
         if (e.stopPropagation) 
            {
                e.stopPropagation();
                e.preventDefault();
            }
            
        return false;   
    }          
             
            
    }//main if condition close here
}     //function close here


   function Demo_Disp_value()
   {
        var IndexValue = window.document.getElementById('ddlCriteria').selectedIndex;
        var SelectedVal = window.document.getElementById('ddlCriteria').options[IndexValue].value; 
        
        if(SelectedVal === '1')
            {   
                window.document.getElementById('txt_searchbox').value = "";                                              
                return false ;
            }
            else
            {   
                window.document.getElementById('txt_searchbox').value = "";                
                return false ;
            }            
    }        
  //End of the above function here
