contract ASStokenICO is Owned, ASStoken {
    //Applies SafeMath library to uint256 operations 
    using SafeMath for uint256;

    //Public Variables
    address public multiSigWallet;                  
    uint256 public amountRaised; 
    uint256 public deadline; 
    uint256 public hardcap; 
    uint256 public price;                            

    //Variables
    bool crowdsaleClosed = true;                    
    string tokenName = "ASStoken"; 
    string tokenSymbol = "ASS"; 
    uint256 initialTokens = 150000000000; 
    uint256 multiplier = 10000; 
    uint8 decimalUnits = 4;  

    

   	//Initializes the token
	function ASStokenICO(address beneficiaryAccount) 
    	ASStoken(tokenName, tokenSymbol, decimalUnits, multiplier, initialTokens) {
            balance[msg.sender] = initialTokens;     
            Transfer(0, msg.sender, initialTokens);    
            multiSigWallet = beneficiaryAccount;        
            hardcap = 55000000;    
            hardcap = hardcap.mul(multiplier); 
            setPrice(40000); 
    }

    //Fallback function creates tokens and sends to investor when crowdsale is open
    function () payable {
        require(!crowdsaleClosed 
            && (now < deadline) 
            && (totalSupply.add(msg.value.mul(getPrice()).mul(multiplier).div(1 ether)) <= hardcap)); 
        address recipient = msg.sender; 
        amountRaised = amountRaised.add(msg.value.div(1 ether)); 
        uint256 tokens = msg.value.mul(getPrice()).mul(multiplier).div(1 ether);
        totalSupply = totalSupply.add(tokens);
        balance[recipient] = balance[recipient].add(tokens);
        require(multiSigWallet.send(msg.value)); 
        Transfer(0, recipient, tokens);
    }   

    //Returns the current price of the token for the crowdsale
    function getPrice() returns (uint256 result) {
        return price;
    }

    //Sets the multisig wallet for a crowdsale
    function setMultiSigWallet(address wallet) onlyOwner returns (bool success) {
        multiSigWallet = wallet; 
        return true; 
    }

    //Sets the token price 
    function setPrice(uint256 newPriceperEther) onlyOwner returns (uint256) {
        require(newPriceperEther > 0); 
        price = newPriceperEther; 
        return price; 
    }

    //Allows owner to start the crowdsale from the time of execution until a specified deadline
    function startSale(uint256 lengthOfSale) onlyOwner returns (bool success) {
        deadline = now + lengthOfSale * 1 days; 
        crowdsaleClosed = false; 
        return true; 
    }

    //Allows owner to stop the crowdsale immediately
    function stopSale() onlyOwner returns (bool success) {
        deadline = now; 
        crowdsaleClosed = true;
        return true; 
    }
}
function () payable {
    require(!crowdsaleClosed 
        && (now < deadline) 
        && (totalSupply.add(msg.value.mul(getPrice()).mul(multiplier).div(1 ether)) <= hardcap)); 
    address recipient = msg.sender; 
    amountRaised = amountRaised.add(msg.value.div(1 ether)); 
    uint256 tokens = msg.value.mul(getPrice()).mul(multiplier).div(1 ether);
    totalSupply = totalSupply.add(tokens);
    balance[recipient] = balance[recipient].add(tokens);
    require(multiSigWallet.send(msg.value)); 
    Transfer(0, recipient, tokens);
}   

//Fallback function creates tokens and sends to investor when crowdsale is open