I will try and help on the what to expect.
Wear black or dark clothing, smart enough that you could wear it to something formal or for church. When you arrive there, you might have to wait a little, either at the Church or the Crematorium depending on where the funeral itself it held. Mostly people sit in silence, so hopefully you won't have to worry about making chit chat. Then there will be the service, which could be religious or secular and could last anything from a few minutes to half an hour. Sometimes family members read out poems or talk about the person who has died or play a song which the deceased person liked.
After the funeral there is usually some sort of reception, where people mingle a bit and talk about the person who has died. Nobody is going to expect you to be a social butterfly in this situation. The last funeral I went to I was almost catatonic for most of it, I just let people talk and talk. There are a few formal things you can say which are safe. To the close family you can say 'I'm very sorry for your loss' and if asked say something positive about the person who died. If you didn't know the person who died very well you could say something like 'I didn't get the chance to get to know him as well as I would have liked, but I've heard he was a very nice man'. Just let other people talk.
The reception part shouldn't be very long and after that you can go home. If you are not close family there shouldn't be an expectation for you to stay and spend time with the immediate family.
Sorry if this was all very obvious, I wasn't sure if you'd been to a funeral before or not from your post. Hopefully this helps a little.