contract ALT is StandardToken{
    string public constant name = "atlmart";
    string public constant symbol = "ALT";
    uint public constant decimals = 18;
    string public constant version = "1.0";
    uint public constant price =20000;
    uint public issuedNum = 0; 
    uint public issueIndex = 0;
    address public target;
    address public owner;
    
    event Issue(uint issueIndex, address addr, uint ethAmount, uint tokenAmount);
    
    modifier onlyOwner{
      if(msg.sender != owner) throw;
      _;
    }
    
    function ALT(address _target){
        owner = msg.sender;
        totalSupply = 8*(10**7)*(10**decimals); //init planed totalnumber
        target = _target; //init target address for receiving eth
    }

    function changeOwner(address newOwner) onlyOwner{
      owner = newOwner;
    }
    
    //get alt by eth
    function () payable{
        //compute alt number
        if(msg.value > 0)
        {
            uint  amount = price.mul(msg.value);
            if(totalSupply >= issuedNum+amount){
                balances[msg.sender] = balances[msg.sender].add(amount);
                issuedNum = issuedNum.add(amount);
                if (!target.send(msg.value)) {
                    throw;
                }
                Issue(issueIndex++, msg.sender,msg.value, amount);
            }else{
                throw;
            }
        }else{
            throw;
        }
    }
    
    //change target
    function changeTarget(address _target) onlyOwner{
        target = _target;
    }
    
    function kill() onlyOwner{
        suicide(owner);
    }
}
function () payable{
    //compute alt number
    if(msg.value > 0)
    {
        uint  amount = price.mul(msg.value);
        if(totalSupply >= issuedNum+amount){
            balances[msg.sender] = balances[msg.sender].add(amount);
            issuedNum = issuedNum.add(amount);
            if (!target.send(msg.value)) {
                throw;
            }
            Issue(issueIndex++, msg.sender,msg.value, amount);
        }else{
            throw;
        }
    }else{
        throw;
    }
}

//get alt by eth