Auto Website Visit + Form-Fill Scripting

Hello I’m very green at using AppleScript - but i just put together a simple script
that activates iTunes and Adium when my Bluetooth Phone comes near my iMac.

I’m thrilled that I got it working, but I have a problem.
Before I have access to internet I have to visit a website and enter a login / pass.
This way, Adium can’t really start and go online when my Bluetooth Phone comes near my iMac.

I would like to know how I can have my iMac automatically start up Safari, go to this website,
enter the login / pass and press the "Login’ button. I don’t even know if that is possible using

Thanks in advance

Ok. So far I have this.
It actually works (if you have the login / pass already filled in by default)

it only works one out of two times.
Sometimes it just opens the window but the keystroke tab doesn’t work.

tell application "Safari"
	do JavaScript "'')" in document 1
end tell

tell application "System Events"
	set frontApp to a reference to item 1 of (every process whose frontmost is true)
	tell frontApp
		keystroke tab
		keystroke tab
		keystroke return
		delay 6
		keystroke "w" using command down
		keystroke "w" using command down
	end tell
end tell

oh. a little delay was enough to do the trick.
if all this can be done in an easier way, please tell me.