// jQuery.noConflict();

(function(w, $) {
    "use strict";
    var img2345 = new Image();
    var imgObj, objId;
    // globach = globach || 1;
    var ipcsrc = w.cam_addr + "Snapshot/1/RemoteImageCapture?ImageFormat=2?";
    w.motionjpeg = function motionjpeg(id, url) {
        ipcsrc = url ? url : ipcsrc; 
        objId = id;
        img2345.src = ipcsrc + (new Date()).getTime();
        img2345.onerror = takeError;
        img2345.onload = update;
    };

    function takeError() {
        img2345.src = ipcsrc + (new Date()).getTime();
    }

    function update() {
        var id = objId.replace("#", "");
        imgObj = document.getElementById('' + id);
        if (imgObj) {
            imgObj.src = img2345.src;
            img2345.src = ipcsrc + (new Date()).getTime();
        }
    }

}(window, jQuery));