function mime_from_data(data) // Simple function that checks for JPG, GIF and PNG from image data. Otherwise returns false. { if('GIF'==data.substr(0,3))return 'image/gif'; else if('PNG'==data.substr(1,3))return 'image/png'; else if('JFIF'==data.substr(6,4))return 'image/jpg'; return false; }; function data_string(data) // Generates the binary data string from character / multibyte data { var data_string=''; for(var i=0,il=data.length;i