function buy( address _referrer ) public payable icoActive Initialized
    {
        
        
        
      require( msg.value >= min );
      

      uint256 _amount = crowdsaleBonus( msg.value.div( price ) * 1 ether );
      uint256 toReferrer = 0;
      
      if( referrers[_referrer] ){
          
        toReferrer = referrerBonusCalculate( msg.value );
        _referrer.transfer( toReferrer );
        _amount = _amount.add( referralBonusCalculate( msg.value, _amount ) );
        
        Referral( _referrer, msg.sender, msg.value, _amount );
        
      }
      
      
      
       
       
      token.delivery( msg.sender, _amount );
      totalEth = totalEth.add( msg.value );
      
      Delivery( msg.sender, _amount );
      
       
        
      if( getCrowdsaleState() == CrowdsaleStates.Presale ) {
          
          presale = presale.sub( _amount );
          
          for( uint256 i = 0; i <= owners.length - 1; i++ ){
              
            owners[i].transfer( ( msg.value.sub( toReferrer ) ).div( owners.length ) );
            
          }
      
      }
      
      
      investorsTotalBalances[msg.sender]  = investorsTotalBalances[msg.sender].add( _amount );
       
      if( investorsTotalBalances[msg.sender] >= threshold && investorsCheck[msg.sender] == false ){
          investors.push( msg.sender );
          investorsCheck[msg.sender] = true;
          
          NewInvestor( msg.sender );
      }
       
       
      
       
    }