Automatic Yahoo Mail Checker (Can switch keyboard layout also)

Script can check email from Yahoo Mail Account. It can switch keyboard layout also ( Turkish QWERTY PC / U.S. )

Thank you Stefan for your Help.

set oldLanguage to changeInputLanguage("U.S.")

tell application "Safari"
	make new document
	set URL of document 1 to ""
end tell

delay 3

tell application "System Events"
	tell process "Safari"
		keystroke ""
		keystroke tab
		delay 0.5
		keystroke "your_password"
		delay 1
		keystroke return
	end tell
end tell

on changeInputLanguage(l)
	tell application "System Events" to tell process "SystemUIServer"
		tell (1st menu bar item of menu bar 1 whose value of attribute "AXDescription" is "text input")
			set v to its value
			delay 0.2
			click menu 1's menu item l
			delay 1.0
			return v
		end tell
	end tell
end changeInputLanguage

Note: the handler to change the keyboard layout works only in Leopard

seems to be broken now