changed optional argument syntax of \img command (img.js extension) to be more LaTeX-like

Optional arguments are now given either as 

    \img[valign=<valign>,width=<width>,height=<height>]{URL}

or

    \img[<valign>][<width>][<height>]{URL}

which are both common ways to supply optional parameters in LaTeX (the latter is usually used when there is just one optional argument). Example in http://jsfiddle.net/c6sy534g/ 
Note that the string `trim()` function is not available in IE8 and below, so this will cause those browsers to die.  Perhaps using `parts[0].replace(/^ +/,"").replace(/ +$/,"")`would be better (if less efficient) here.