Correctly check for element existence.
Use jQuery.isEmptyObject to check whether properties are set.
Add comment to cookie deletion.
Use RegEx literal instead of a string.