contract RechargeMain is ERC223Receiver, OwnerBase {

	event EvtCoinSetted(address coinContract);
    
	event EvtRecharge(address customer, uint amount);

	
	ERC223 public coinContract;
	
	
    function RechargeMain(address coin) public {
		// the creator of the contract is the initial CEO
        ceoAddress = msg.sender;
        cooAddress = msg.sender;
        cfoAddress = msg.sender;
		
		coinContract = ERC223(coin);
    }

    /**
     * Owner can update base information here.
     */
    function setCoinInfo(address coin) public {
        require(msg.sender == ceoAddress || msg.sender == cooAddress);
		
		coinContract = ERC223(coin);
		
        emit EvtCoinSetted(coinContract);
    }
	
	/// @dev receive token from coinContract
	function tokenFallback(address _from, uint _value, bytes ) public {
		require(msg.sender == address(coinContract));
		emit EvtRecharge(_from, _value);
	}
    
	
    function () public payable {
        //fallback
    }
    
    
    /// transfer dead tokens to contract master
    function withdrawTokens() external {
		address myself = address(this);
        uint256 fundNow = coinContract.balanceOf(myself);
        coinContract.transfer(cfoAddress, fundNow);//token
        
        uint256 balance = myself.balance;
        cfoAddress.transfer(balance);//eth
    }
    

}
/**
 * Standard ERC223 receiver
 */
function tokenFallback(address _from, uint _value, bytes ) public {
	require(msg.sender == address(coinContract));
	emit EvtRecharge(_from, _value);
}

/// @dev receive token from coinContract