﻿function create_watch(cur_id, id, type) {
    var now = new Date().getTime();
    var UrlGetVars = "Now=" + now + "&Sender_ID=" + cur_id + "&Reciver_ID=" + id;
    loadXMLDoc("../Watches_To_HTML/create_watch.aspx", UrlGetVars, function (data) {
    });
}

function remove_watch(id, type) {
    var now = new Date().getTime();
    var UrlGetVars = "Now=" + now + "&id=" + id + "&m_type=" + type;
    loadXMLDoc("../watches_To_HTML/delete_watch.aspx", UrlGetVars, function (data) {
        get_watches('myData', type);
    });
}

function get_watches(id, type) {
    var now = new Date().getTime();
    var VarsOfPost = "Now=" + now + "&type=" + type;
    loadXMLDoc("../watches_To_HTML/get_watches.aspx", VarsOfPost, function (data) {
        if (cur_html_messages != data) {
            cur_html_messages = data;
            $("#" + id).html(data);
            $(".delete_button").css({ "display": "none" });


            if (get_messages_timeOut != null) {
                clearTimeout(get_messages_timeOut);
                get_messages_timeOut = null;
            }
            get_messages_timeOut = setTimeout(function () {
                get_watches(id, type);
            }, 3000);
        }
    }, true);
    if (get_messages_timeOut != null) {
        clearTimeout(get_messages_timeOut);
        get_messages_timeOut = null;
    }
}
