Updated with better backward compatibility and touch support. Added minified version.