The most economical fix would be a salvage yard replacement. The glass is glued to the frame with urethane and is quite tough to separate. I would think you can purchase the whole assembly at a salvage yard for what you would pay for just the frame new.
If you have a sunroof the hose that allows the gland around the glass window to drain has plugged. Also reported is the rubber hose connection to the drain in the roof gland has also relaxed allowing the water to leak from the connection. This is an easy repair and several videos are available to DIY. If the car sits outside near trees, or has been baking in the sun are the most likely cause .
Hope this helps?
Sunroof Repair
Sounds like either a fuel pump or throttle position sensor. Check the pressure at the port on the fuel rail. It should be at least 30 PSI while running. TPS is mounted right on the throttle body. Amazon sells them both.
Your check engine light must be on. To pull up your codes Put your key into ignition and turn key ON,OFF,ON,OFF and finally ON.The codes will show on your dash. From what you described it seems to me you may have a bad CRANKSHAFT SENSOR and MAF SENSOR. GOOD LUCK FRIEND.