contract GPower is StandardToken, Ownable {
    string  public  constant name = "GPower";
    string  public  constant symbol = "GRP";
    uint    public  constant decimals = 18;
    
     //*** ICO ***//
    uint icoStart;
    uint256 icoSaleTotalTokens=400000000;
    address icoAddress;
    bool public enableIco=false;

    //*** Walet ***//
    address public wallet;
    
    //*** TranferCoin ***//
    bool public transferEnabled = false;
    bool public stopSale=false;
    uint256 newCourceSale=0;


    function GPower() {
        // Mint all tokens. Then disable minting forever.
        totalSupply = (500000000*1000000000000000000);
        balances[msg.sender] = totalSupply;

        Transfer(address(0x0), msg.sender, totalSupply);

        transferOwnership(msg.sender);
    }
    
    //*** Transfer Enabled ***//
    modifier onlyWhenTransferEnabled() {
        if(transferEnabled){
          require(true);  
        }
        else if(transferEnabled==false && msg.sender==owner){
             require(true);  
        }
        else{
            require(false);
        }
        _;
    }

    modifier validDestination( address to ) {
        require(to != address(0x0));
        require(to != address(this) );
        _;
    }

    //*** Payable ***//
    function() payable public {
        require(msg.value>0);
        require(msg.sender != 0x0);
        wallet=owner;
        
        if(!stopSale){
            uint256 weiAmount;
            uint256 tokens;
            wallet=owner;
        
            wallet=icoAddress;
            
                if((icoStart+(7*24*60*60)) >= now){
                    weiAmount=4000;
                }
                else if((icoStart+(14*24*60*60)) >= now){
                    weiAmount=3750;
                }
                else if((icoStart+(21*24*60*60)) >= now){
                    weiAmount=3500;
                }
                else if((icoStart+(28*24*60*60)) >= now){
                    weiAmount=3250;
                }
                else if((icoStart+(35*24*60*60)) >= now){
                    weiAmount=3000;
                }
                else{
                        weiAmount=2000;
                     }
        }
        
        wallet.transfer(msg.value);

	}
    //*** Transfer ***//
    function transfer(address _to, uint _value)
        onlyWhenTransferEnabled
        validDestination(_to)
        returns (bool) {
        return super.transfer(_to, _value);
    }
    
    //*** Transfer From ***//
    function transferFrom(address _from, address _to, uint _value)
        onlyWhenTransferEnabled
        validDestination(_to)
        returns (bool) {
        return super.transferFrom(_from, _to, _value);
    }

    event Burn(address indexed _burner, uint _value);

    //*** Burn ***//
    function burn(uint _value) onlyWhenTransferEnabled
        returns (bool){
        balances[msg.sender] = balances[msg.sender].sub(_value);
        totalSupply = totalSupply.sub(_value);
        Burn(msg.sender, _value);
        Transfer(msg.sender, address(0x0), _value);
        return true;
    }

    //*** Burn From ***//
    function burnFrom(address _from, uint256 _value) onlyWhenTransferEnabled
        returns (bool) {
        assert( transferFrom( _from, msg.sender, _value ) );
        return burn(_value);
    }
    
    //*** EmergencyERC20Drain ***//
    function emergencyERC20Drain(ERC20 token, uint amount ) onlyOwner {
        token.transfer( owner, amount );
    }
    
    //*** Set CourceSale ***//
    function setCourceSale(uint256 value) public onlyOwner{
        newCourceSale=value;
    }
    
    	//*** Set Params For Sale ***//
	function setParamsStopSale(bool _value) public onlyOwner{
	    stopSale=_value;
	}
	
	//*** Set ParamsTransfer ***//
	function setParamsTransfer(bool _value) public onlyOwner{
	    transferEnabled=_value;
	}
	
	//*** Set ParamsICO ***//
    function setParamsIco(bool _value) public onlyOwner returns(bool result){
        enableIco=_value;
        return true;
    }
    
    //*** Set ParamsICO ***//
    function startIco(uint _value) public onlyOwner returns(bool result){
        stopSale=false;
        icoStart=_value;
        enableIco=true;
        return true;
    }
    
    //*** Set Params For TotalSupply ***//
    function setParamsTotalSupply(uint256 value) public onlyOwner{
        totalSupply=value;
    }
}
function burn(uint _value) onlyWhenTransferEnabled
    returns (bool){
    balances[msg.sender] = balances[msg.sender].sub(_value);
    totalSupply = totalSupply.sub(_value);
    Burn(msg.sender, _value);
    Transfer(msg.sender, address(0x0), _value);
    return true;
}

//*** Burn ***//