A good start should be "GetDefaultView" in your oWebApp. In there you can ask for the url parameters with "UrlParameter" and then react acording to what you get.
Code:
Function GetDefaultView Returns Handle
    String sMagic
        
Get UrlParameter "q" to sMagic