function openImage(w, h) {
    if (!w) w = 300;
    if (!h) h = 300;
    var str = "width=" + w + ",height=" + h + ",toolbar=0,menubar=0,status=0,resizable=1,scrollbars=0";
    var wnd = window.open('', 'image', str);
    wnd.focus();
}

function showNotepad() {
    if (bCookieNotepad != 0) {
        $('.note_div').show();
    }
    else {
        var wnd = window.open('notepad.aspx', 'notepad');
        wnd.focus();
    }
}
function hideCookieNotepad() {
    $('.note_div').hide();
}

function refreshNotepad() {
    $.post(
        '/Ajax.aspx',
        { tmpl: 'notepad_ajax', refresh_cookie_notepad: 1 },
        function (data) {
            var obj = $(data);
            $('#notepad_items_count').html($('#notepad_items_count', obj).html());
            $('#notepad_cookie_container').html($('#notepad_cookie_container', obj).html());

            bCookieNotepad = parseInt($('#b_cookie_notepad', obj).html());

            if ($('#notepad_cookie_empty', obj).length == 1) {
                hideCookieNotepad();
            }
        });

     refreshParentNotepad();
}

function refreshParentNotepad() {
    try {
        if (window.opener != null) {
            if (window.opener.refreshNotepad != null) {
                window.opener.refreshNotepad();
            }
        }
    }
    catch (e) {
    }
}

function refreshNotepadTimeout() {
    setTimeout(refreshNotepad, 1000);
    setTimeout(refreshNotepad, 3000);
    setTimeout(refreshNotepad, 9000);
}

function refreshParentNotepadTimeout() {
    try {
        if (window.opener != null) {
            if (window.opener.refreshNotepadTimeout != null) {
                window.opener.refreshNotepadTimeout();
            }
        }
    }
    catch (e) {
    }
}

function rememberInCookieNotepad(item_no, elLink) {
    $.post(
        '/Ajax.aspx',
        { tmpl: 'notepad_ajax', add_to_cookie_notepad: 1, item_no: item_no },
        function (data) {
            var obj = $(data);
            $('#notepad_items_count').html($('#notepad_items_count', obj).html());
            //$('#notepad_link').replaceWith($('#notepad_link', obj));
            //$('#notepad_button').html($('#notepad_button_html', obj).html());
            $(elLink.parentNode).html($('#item_remembered_message_html', obj).html());
            $('#notepad_cookie_container').html($('#notepad_cookie_container', obj).html());

            bCookieNotepad = parseInt($('#b_cookie_notepad', obj).html());

            refreshParentNotepad();
        });
}

function removeItemFromCookieNotepad(item_no) {
    $.post(
        '/Ajax.aspx',
        { tmpl: 'notepad_ajax', remove_from_cookie_notepad: 1, item_no: item_no },
        function (data) {
            var obj = $(data);
            $('#notepad_items_count').html($('#notepad_items_count', obj).html());
            //$('#notepad_link').replaceWith($('#notepad_link', obj).html());
            //$('#notepad_button').html($('#notepad_button_html', obj).html());
            $('#notepad_cookie_container').html($('#notepad_cookie_container', obj).html());

            bCookieNotepad = parseInt($('#b_cookie_notepad', obj).html());

            if ($('#notepad_cookie_empty', obj).length == 1) {
                hideCookieNotepad();
            }

            refreshParentNotepad();
        });
}
