foundation + refactoring for crossbrower

used foundation and some refactoring to get better cross browser
niceness