﻿var g_is_advance_search = 0;
var g_tab_no = 1;
var g_mbr_id = 0;
var g_frn_mbr_id = 0;
var g_finder_sex = '';
$(document).ready(function() {
    setCookie('focusTab', 'dating');
    setCookie('focusSub', 'datingsearch');
    header.update();

    $('#cmbACountry').change(function() {
        onCountryChange('#cmbACountry', '#fDivProvince', 'cmbAProvince');
    });
    initComboboxMultiSelectValueStandard('date_citizen');
    initComboboxMultiSelectValueStandard('date_ethinicity');
    initComboboxMultiSelectValueStandard('date_sign');

    $('#advanceSearch').click(function() { $('#basicDateSearch').hide(); $('#advanceDateSearch').show(); g_is_advance_search = 1; });
    $('#basicSearch').click(function() { $('#advanceDateSearch').hide(); $('#basicDateSearch').show(); g_is_advance_search = 0; });

    $('#btnBasSearch').click(function() {
        getDatingSearchResult(1, 1, 12);
    });

    $('#btnAdvSearch').click(function() {
        getDatingSearchResult(1, 1, 12);
    });

    $('body').append(getWinkDialog());
    $('body').append(getConfirmationDialog());
    $('body').append(getEmailDisableDialog());
    $('body').append(getDeleteConfirmationDialog());
    $('body').append(getLoginDialog());
    $('body').append(getNoAccessDialog());
    $('body').append(getMsgNoAccessDialog());
    $('body').append(getNoThankConfirmationDialog());

    $('#btnSendWink').click(function() {
        sendWingRequest();
    });

    if (g_seeking_mbr_id > 0 || g_finder_sex.length > 0) {
        $('#btnBasSearch').trigger('click');
    }
    if ($('#imgPoll').length > 0) { getPollBox('#imgPoll', 2); }
});

$(function() {
    $('.sendMsg_dialogue').dialog({
        autoOpen: false,
        width: 480,
        height: 'auto',
        closeOnEscape: false,
        closeText: 'close',
        //stack: false,
        position: 'middle',
        draggable: true,
        modal: true
    });
});

$(function() {
$('#confirmation_dialogue').dialog({
        autoOpen: false,
        width: 400,
        height: 'auto',
        closeOnEscape: false,
        closeText: 'close',
        //stack: false,
        position: 'middle',
        draggable: true,
        modal: true
    });
});
$(function() {
$('#noaccess_dialogue').dialog({
        autoOpen: false,
        width: 400,
        height: 'auto',
        closeOnEscape: false,
        closeText: 'close',
        //stack: false,
        position: 'middle',
        draggable: true,
        modal: true
    });
});
$(function() {
$('#msgnoaccess_dialogue').dialog({
        autoOpen: false,
        width: 400,
        height: 'auto',
        closeOnEscape: false,
        closeText: 'close',
        //stack: false,
        position: 'middle',
        draggable: true,
        modal: true
    });
});

$(function() {
$('#emaildisable_dialogue').dialog({
        autoOpen: false,
        width: 400,
        height: 'auto',
        closeOnEscape: false,
        closeText: 'close',
        //stack: false,
        position: 'middle',
        draggable: true,
        modal: true
    });
});
$(function() {
$('#deleteconfirm_dialogue').dialog({
        autoOpen: false,
        width: 400,
        height: 'auto',
        closeOnEscape: false,
        closeText: 'close',
        //stack: false,
        position: 'middle',
        draggable: true,
        modal: true
    });
});

$(function() {
    $('#no_thank_confirm_dialogue').dialog({
        autoOpen: false,
        width: 400,
        height: 'auto',
        closeOnEscape: false,
        closeText: 'close',
        //stack: false,
        position: 'middle',
        draggable: true,
        modal: true
    });
});

function onCountryChange(el, eldiv, combobox_name) {
    var country_code = $(el).val();
    var arr_loc = country_code.split('|');
    var loc_id = arr_loc[0];
    var loc_code = arr_loc[1];
    var url = server_root + '/Processor/GeneralProcess.aspx?country_code=' + loc_id + "&proc_id=1&combobox_name=" + combobox_name;
    getProvinceCombobox(eldiv, url);

    if (loc_id == 1 || loc_id == 2085 || loc_id == '') {
        $(eldiv).show();
    } else {
        $(eldiv).html('');
    }

}
//Get province combobox
function getProvinceCombobox(resultControl, url) {
    var respText = $.ajax({
        url: url,
        async: false
    }).responseText;
    $(resultControl).html(respText);
}
function onDateListClick(mbr_id) {    
    g_tab_no = 1;
    renderDatingClick(mbr_id);
}

function renderDatingClick(mbr_id) {
    $('#dateTab' + mbr_id).tabs(); checkGuideContentShow();
    if ($('#dList' + mbr_id).attr('class') == 'selected') {
        $('#dList' + mbr_id).removeClass('selected');
        $('#dList' + mbr_id).addClass('dateList');
        $('#dList' + mbr_id).hide();
    }
    else {
        $('#dList' + mbr_id).addClass('selected');
        $('#dList' + mbr_id).show();
        $('#d' + mbr_id).addClass('dfocus');
    }
    getDatingSearchDetail('dList' + mbr_id, mbr_id);
}

function checkGuideContentShow() {
    $('.dSearchResult .selected').each(function() {
        var dID = $(this).attr('id').substring(5);
        showListContent(dID);
    });
}

function showListContent(mbr_id) {
    $('#dList' + mbr_id).removeClass('selected');
    $('#dList' + mbr_id).hide();
    $('#d' + mbr_id).removeClass('dfocus');
}

function getWinkDialog() {
    var dialog_result = "<!--Send Wink Friend Dialog-->" +
                        "<div id=\"sendwink_dialogue\" class=\"sendwink_dialogue\" title=\"Send Wink Confirmation\" style=\"height:auto !important; display:none;\">" +
                        "    <div class=\"friendContainer\">" +
                        "    <div style=\"width:190px; margin:0 auto;\" >" +
                        "      <div class=\"friendImg\"><div class=\"friendListPic\"><img id=\"imgOrgTh\" src=\"styles/images/profile/friend_blank.gif\"/></div>                    " +
                        "      <div class=\"shortPhotoShadow\"></div>" +
                        "        <div class=\"friendRecon\"> </div></div>        " +
                        "        <div style=\"float:left; margin:10px 20px 10px 0;\"><img src=\"styles/images/wink.gif\" /></div>            " +
                        "      <div class=\"friendImg\"><div class=\"friendListPic\"><img id=\"imgAddFriendTh\" src=\"styles/images/profile/friend_blank.gif\"/></div>                    " +
                        "      <div class=\"shortPhotoShadow\"></div>" +
                        "        <div class=\"friendRecon\"> </div></div>        " +
                        "       <div class=\"clear\"></div>" +
                        "       </div>" +

                        "        <div class=\"friendAddData\" style=\"width:390px;\">" +
                        "            <div>" +
                        "                <ul>" +
                        "                  <li class=\"\"><input type=\"hidden\" id=\"spName\" /><div id=\"addFriendStatus\">Please confirm that you want to send a wink to <label id=\"full_name\" class=\"spName\">full name</label>. This will show that you are interested in <label id=\"first_name1\" id=\"strHisHer\">first name</label> and that you would like to begin a dialogue. If <label id=\"first_name2\">first name</label> winks back, then both of you can start sending emails to each other. </div></li>                                " +
                        "                  <li><div class=\"centerAlign topPadding\"><input type=\"button\" id=\"btnSendWink\" name=\"btnSendWink\" value=\"Send Wink\" class=\"buttonBlue\" /> <input type=\"button\" id=\"\" onclick=\"closeSentWinkDialogue()\" name=\"\" value=\"Cancel\" class=\"buttonSBlue\" /></div> </li>" +
                        "                </ul>" +
                        "            </div>" +
                        "        </div>" +
                        "    </div>" +
                        "</div>";
    return dialog_result;
}
function getConfirmationDialog() {
    var dialog_result = "<!--Send Wink Friend Dialog-->" +
                        "<div id=\"confirmation_dialogue\" class=\"sendwink_dialogue\" title=\"Return Wink Confirmation\" style=\"height:auto !important; display:none;\">" +
                        "    <div class=\"centerAlign\">" +
                        "    <label>Please confirm that you want to return <label id=\"con_full_name\" class=\"spName\">Wink To Fullname</label>’s wink and that you are interested in <label id=\"con_him_her\" id=\"strHisHer\">him/her</label>. Once confirmed, both of you can start sending emails to each other and get more personal.</label>" +
                        "    <div class=\"centerAlign topPadding\"><input type=\"button\" class=\"buttonBlue\" value=\"Return Wink\" name=\"\" id=\"\" onclick=\"sendConfirmWingRequest();\"/> <input type=\"button\" class=\"buttonSBlue\" value=\"Cancel\" name=\"\" onclick=\"closeMessageDialogue();\" id=\"\"/></div>" +                   
                        "    </div>" +
                        "</div>";
    return dialog_result;
}
function getEmailDisableDialog() {
    var dialog_result = "<!--No Email Access Dialog-->" +
                        "<div id=\"emaildisable_dialogue\" class=\"\" title=\"No Email Access\" style=\"height:auto !important; display:none;\">" +
                        "    <div class=\"centerAlign topSpacing\">" +
                        "    Since both of you have not winked at each other, neither of you have access to each other’s email. If you have already sent a wink, please be patient; otherwise, show your interest now by sending a wink. " +
                        "    <div class=\"centerAlign topPadding\"><input type=\"button\" class=\"buttonSBlue\" value=\"Close\" name=\"\" onclick=\"closeEmailDisableDialogue();\" id=\"\"/></div>" +                   
                        "    </div>" +
                        "</div>";
    return dialog_result;
}
function getNoAccessDialog() {
    var dialog_result = "<!--No Email Access Dialog-->" +
                        "<div id=\"noaccess_dialogue\" class=\"\" title=\"Dating Availability Required\" style=\"height:auto !important; display:none;\">" +
                        "    <div class=\"centerAlign topSpacing\">" +
                        "    You cannot send a wink while your dating status is inactive. To send a wink to <label id=\"nac_full_name\"></label>, activate your dating availability now by clicking on the button below. " +
                        "    <div class=\"centerAlign topPadding\"><input type=\"button\" class=\"buttonBlue\" value=\"Activate Dating\" name=\"\" id=\"mbrDatingActivate\" onclick=\"onClickActivateLink();\"/> <input type=\"button\" class=\"buttonSBlue\" value=\"Cancel\" name=\"\" onclick=\"closeNoAccessDialogue();\" id=\"\"/></div>" +                   
                        "    </div>" +
                        "</div>";
    return dialog_result;
}
function getMsgNoAccessDialog() {
    var dialog_result = "<!--No Email Access Dialog-->" +
                        "<div id=\"msgnoaccess_dialogue\" class=\"\" title=\"Dating Availability Required\" style=\"height:auto !important; display:none;\">" +
                        "    <div class=\"centerAlign topSpacing\">" +
                        "    You cannot send a message while your dating status is inactive. To send a message to <label id=\"msgnac_full_name\"></label>, activate your dating availability now by clicking on the button below. " +
                        "    <div class=\"centerAlign topPadding\"><input type=\"button\" class=\"buttonBlue\" value=\"Activate Dating\" name=\"\" id=\"mbrDatingActivate\" onclick=\"onClickActivateLink();\"/> <input type=\"button\" class=\"buttonSBlue\" value=\"Cancel\" name=\"\" onclick=\"closeMsgNoAccessDialogue();\" id=\"\"/></div>" +                   
                        "    </div>" +
                        "</div>";
    return dialog_result;
}
function getDeleteConfirmationDialog() {
    var dialog_result = "<!--Delete Confirmation Dialog-->" +
                        "<div id=\"deleteconfirm_dialogue\" class=\"\" title=\"Delete Confirmation\" style=\"height:auto !important; display:none;\">" +
                        "    <div class=\"centerAlign topSpacing\">" +
                        "    Please confirm that you want to delete all selected dating profile. " +
                        "    <div class=\"centerAlign topPadding\"><input type=\"button\" class=\"buttonSBlue\" value=\"Yes\" name=\"btnDeleteYes\" onclick=\"onDeleteYes();\" id=\"btnDeleteYes\"/> <input type=\"button\" class=\"buttonSBlue\" value=\"No\" name=\"\" onclick=\"closeDeleteConfirmationDialogue();\" id=\"\"/></div>" +                   
                        "    </div>" +
                        "</div>";
    return dialog_result;
}

function getNoThankConfirmationDialog() {
    var dialog_result = "<!--Delete Confirmation Dialog-->" +
                        "<div id=\"no_thank_confirm_dialogue\" class=\"\" title=\"Delete Confirmation\" style=\"height:auto !important; display:none;\">" +
                        "    <div class=\"centerAlign topSpacing\">" +
                        "    Please confirm that you want to say No, thanks to <label id=\"nt_first_name\"></label>. " +
                        "    <div class=\"centerAlign topPadding\"><input type=\"button\" class=\"buttonSBlue\" value=\"Yes\" name=\"btnDeleteYes\" onclick=\"onNoThankClick();\" id=\"btnDeleteYes\"/> <input type=\"button\" class=\"buttonSBlue\" value=\"No\" name=\"\" onclick=\"closeNoThankConfirmationDialogue();\" id=\"\"/></div>" +
                        "    </div>" +
                        "</div>";
    return dialog_result;
}

$(function() { $('#sendwink_dialogue').dialog({ autoOpen: false, width: 410, height: 'auto', closeOnEscape: false, closeText: 'close', position: 'middle', draggable: true, modal: true }); });
function closeSentWinkDialogue() { $('#sendwink_dialogue').dialog('close'); }
function closeMessageDialogue() { $('#confirmation_dialogue').dialog('close'); }
function closeEmailDisableDialogue() { $('#emaildisable_dialogue').dialog('close'); }
function closeDeleteConfirmationDialogue() { $('#deleteconfirm_dialogue').dialog('close'); }
function closeNoAccessDialogue() { $('#noaccess_dialogue').dialog('close'); }
function closeMsgNoAccessDialogue() { $('#msgnoaccess_dialogue').dialog('close'); }
var session_sender_id, session_receiver_id, session_receiver_full_name, session_receiver_first_name, session_sender_photo, session_receiver_photo;
function openSentWinkDialogue(sender_id, receiver_id, receiver_full_name, receiver_first_name, sender_photo, receiver_photo) {    
    g_mbr_id = sender_id;
    g_frn_mbr_id = receiver_id;    
    session_sender_id = sender_id;
    session_receiver_id = sender_id;
    session_sender_id = receiver_id;
    session_receiver_full_name = receiver_full_name;
    session_receiver_first_name = receiver_first_name;
    session_sender_photo = sender_photo;
    session_receiver_photo = receiver_photo;
    var sessionInfo = getMemberId(); //function of main.js    
    var arrSessionInfo;
    var session_id;
    var log_mbr_id;
    var gmbr_id;

    arrSessionInfo = sessionInfo.split('|');
    session_id = arrSessionInfo[2].trim();
    log_mbr_id = arrSessionInfo[0].trim();

    var sessionMbrId = log_mbr_id;
    if (sessionMbrId > 0) {
        $('#imgOrgTh').attr('src', sender_photo);
        $('#imgAddFriendTh').attr('src', receiver_photo);
        $('#full_name').text(receiver_full_name);
        $('#first_name1').text(receiver_first_name);
        $('#first_name2').text(receiver_first_name);
        $('#sendwink_dialogue').dialog('open');
    }
    else { $('.login_dialogue').dialog('open'); }
}
var g_confirm_mbr_id = 0;
function openReturnWinkDialogue(mbr_id, receiver_full_name,str_him_her) {
    g_confirm_mbr_id = mbr_id;
    $('#con_full_name').text(receiver_full_name);
    $('#con_him_her').text(str_him_her);
    $('#confirmation_dialogue').dialog('open');
}
var g_proc_id = 0;
function openDeleteConfirmationDialogue(proc_id) {
    g_proc_id = proc_id;
    $('#deleteconfirm_dialogue').dialog('open');
}
var g_activate_url = '';
function openNoAccessDialogue(str_full_name, activate_url) {
    var sessionInfo = getMemberId(); //function of main.js    
    var arrSessionInfo;
    var session_id;
    var log_mbr_id;
    var gmbr_id;

    arrSessionInfo = sessionInfo.split('|');
    session_id = arrSessionInfo[2].trim();
    log_mbr_id = arrSessionInfo[0].trim();

    var sessionMbrId = log_mbr_id;
    if (sessionMbrId > 0) {
        g_activate_url = activate_url;
        $('#nac_full_name').text(str_full_name);
        $('#noaccess_dialogue').dialog('open');
    }
    else {
        $('.login_dialogue').dialog('open');
        g_activate_url = activate_url;
        $('#nac_full_name').text(str_full_name);
    }
}
function openMsgNoAccessDialogue(str_full_name, activate_url) {
    var sessionInfo = getMemberId(); //function of main.js    
    var arrSessionInfo;
    var session_id;
    var log_mbr_id;
    var gmbr_id;

    arrSessionInfo = sessionInfo.split('|');
    session_id = arrSessionInfo[2].trim();
    log_mbr_id = arrSessionInfo[0].trim();

    var sessionMbrId = log_mbr_id;
    if (sessionMbrId > 0) {
        g_activate_url = activate_url;
        $('#msgnac_full_name').text(str_full_name);
        $('#msgnoaccess_dialogue').dialog('open');
    }
    else {
        g_activate_url = activate_url;
        $('#msgnac_full_name').text(str_full_name);
    }
}
var g_no_thank_mbr_id = 0;
function openNoThankConfirmationDialogue(mbr_id, first_name) {
    g_no_thank_mbr_id = mbr_id;
    $('#nt_first_name').text(first_name);
    $('#no_thank_confirm_dialogue').dialog('open');
}

function closeNoThankConfirmationDialogue() {    
    $('#no_thank_confirm_dialogue').dialog('close');
}

function onClickActivateLink() {
    window.location.replace(g_activate_url);
}
var g_seeking_mbr_id = 0;
function getDatingSearchResult(page_no, paging_status, num_per_page) {
    var is_advance_search = g_is_advance_search;

    var finder_sex = 'M';
    var seeking_sex = 'F';
    var from_age = 18;
    var to_age = 35;
    var resident_country = 0;
    var resident_province = 0;
    var dat_ethnicity = 0;
    var dat_chinese_sign = '';
    var dat_citizenships = '';
    var seeking_mbr_id = 0;

    if (is_advance_search == 0) {
        finder_sex = $('#cmbBFinderSex').val();
        seeking_sex = $('#cmbBSeekingSex').val();
        from_age = $('#cmbBFromAge').val();
        to_age = $('#cmbBToAge').val();
        seeking_mbr_id = g_seeking_mbr_id;
    } else {
        finder_sex = $('#cmbAFinderSex').val();
        seeking_sex = $('#cmbASeekingSex').val();
        from_age = $('#cmbAFromAge').val();
        to_age = $('#cmbAToAge').val();
        resident_country = $('#cmbACountry').val();
        resident_country = resident_country == null ? 0 : resident_country;
        resident_province = $('#cmbAProvince').val();
        resident_province = resident_province == null ? 0 : resident_province;
        dat_ethnicity = $('#cmbEthinicity').val();
        dat_chinese_sign = $('#cmbChineseSign').val();
        dat_citizenships = $('#cmbCitizenship').val();
        seeking_mbr_id = 0;
    }    

    var line_per_page_id = 'cmbDatingSearchLinePerPage';
    var line_per_page = num_per_page;
    var on_line_per_page_func = 'onDatingSearchLinePerPageClick';
    var page_link_click_func = 'onDatingSearchPageLinkClick';

    loadingForm('#dSearchResult');
    $(this).oneTime(100, 'timer', function() {

        var url = server_root + "/Processor/GeneralProcessPart7.aspx";
        var respText = $.ajax({
            url: url,
            type: 'POST',
            async: false,
            data: {
                proc_id: 2, //Get Manage Group form
                is_advance_search: is_advance_search,
                finder_sex: finder_sex,
                seeking_sex: seeking_sex,
                from_age: from_age,
                to_age: to_age,
                resident_country: resident_country,
                resident_province: resident_province,
                dat_ethnicity: dat_ethnicity,
                dat_chinese_sign: dat_chinese_sign,
                dat_citizenships: dat_citizenships,
                page_no: page_no,
                line_per_page: line_per_page,
                paging_status: paging_status,
                on_line_per_page_func: on_line_per_page_func,
                line_per_page_id: line_per_page_id,
                page_link_click_func: page_link_click_func,
                seeking_mbr_id: seeking_mbr_id
            }
        }).responseText;

        $('#dSearchResult').html(respText);

        if (g_seeking_mbr_id > 0) {
            $('#d' + g_seeking_mbr_id).hide();
            $('#divImg' + g_seeking_mbr_id).trigger('click');
            g_seeking_mbr_id = 0;
        }
    });
}

function onDatingSearchPageLinkClick(page_no, status) {
    var no_per_page = $('#no_per_page').length > 0 ? $('#no_per_page').val() : 12;
    getDatingSearchResult(page_no, status, no_per_page);
}

function onDatingSearchLinePerPageClick(num_per_page) {
    getDatingSearchResult(1, 1, num_per_page);
}

function getDatingSearchDetail(container_name, mbr_id) {
    loadingForm('#' + container_name);
    $(this).oneTime(100, 'timer', function() {
        var url = server_root + "/Processor/GeneralProcessPart7.aspx";
        var respText = $.ajax({
            url: url,
            cache: false,
            type: 'POST',
            async: false,
            data: {
                proc_id: 3,
                mbr_id: mbr_id
            }
        }).responseText;
        $('#' + container_name).html(respText);
        $('#dateTab' + mbr_id).tabs();        
        
        $('#dateTab' + mbr_id).triggerTab(g_tab_no);        
    });
}

function onNewPhotoClick(mbr_id) {
    g_tab_no = 3;
    renderDatingClick(mbr_id);
}

function onVideoClick(mbr_id) {
    g_tab_no = 2;
    renderDatingClick(mbr_id);
}

function sendWingRequest() {
    var df_status_cd = 'R';
    var df_req_status_cd = 'W';
    var url = server_root + "/Processor/GeneralProcessPart7.aspx";
    var respText = $.ajax({
        url: url,
        cache: false,
        type: 'POST',
        async: false,
        data: {
            proc_id: 5,            
            frn_mbr_id: g_frn_mbr_id,
            df_status_cd: df_status_cd,
            df_req_status_cd: df_req_status_cd
        }
    }).responseText;    
    g_frn_mbr_id = 0;
    closeSentWinkDialogue();
}

function sendConfirmWingRequest() {
    var df_status_cd = 'R';
    var df_req_status_cd = 'W';
    var url = server_root + "/Processor/GeneralProcessPart7.aspx";
    var respText = $.ajax({
        url: url,
        cache: false,
        type: 'POST',
        async: false,
        data: {
            proc_id: 6,            
            frn_mbr_id: g_confirm_mbr_id,
            df_status_cd: df_status_cd,
            df_req_status_cd: df_req_status_cd
        }
    }).responseText;    
    g_confirm_mbr_id = 0;
    closeMessageDialogue();
    onWinkFiler(1, 1, 12);
}

function onSetBlockFromContactMe(frn_mbr_id, block_status) {    
    var url = server_root + "/Processor/GeneralProcessPart7.aspx";
    var respText = $.ajax({
        url: url,
        cache: false,
        type: 'POST',
        async: false,
        data: {
            proc_id: 8,
            frn_mbr_id: frn_mbr_id,
            block_status: block_status
        }
    }).responseText;
    onDateListClick(frn_mbr_id);
}

function onSetBlockFromSearchMe(frn_mbr_id, block_status) {    
    var url = server_root + "/Processor/GeneralProcessPart7.aspx";
    var respText = $.ajax({
        url: url,
        cache: false,
        type: 'POST',
        async: false,
        data: {
            proc_id: 9,
            frn_mbr_id: frn_mbr_id,
            block_status: block_status
        }
    }).responseText;
    onDateListClick(frn_mbr_id);
}

function onBookMarkDating(frn_mbr_id) {
    var url = server_root + "/Processor/GeneralProcessPart7.aspx";
    var respText = $.ajax({
        url: url,
        cache: false,
        type: 'POST',
        async: false,
        data: {
            proc_id: 10,
            frn_mbr_id: frn_mbr_id            
        }
    }).responseText;
}

function getDatingActivityResult(page_no, paging_status, num_per_page, filter_no, search_value, panel_id, line_per_page_id, on_line_per_page_func, page_link_click_func) {    

    //var line_per_page_id = 'cmbDatingActivityLinePerPage';
    var line_per_page = num_per_page;
    //var on_line_per_page_func = 'onDatingActivityLinePerPageClick';
    //var page_link_click_func = 'onDatingActivityPageLinkClick';

    $('#divConfirmWinkResult').html('');
    $('#divReceivedWinkResult').html('');
    $('#divSentWinkResult').html('');
    $('#divFavoriteSearchResult').html('');
    $('#dBlockedSearchResult').html('');    

    loadingForm(panel_id);
    $(this).oneTime(100, 'timer', function() {

        var url = server_root + "/Processor/GeneralProcessPart7.aspx";
        var respText = $.ajax({
            url: url,
            type: 'POST',
            async: false,
            data: {
                proc_id: 11, //Get Dating Activity Result
                filter_no: filter_no,
                search_value: search_value,
                page_no: page_no,
                line_per_page: line_per_page,
                paging_status: paging_status,
                on_line_per_page_func: on_line_per_page_func,
                line_per_page_id: line_per_page_id,
                page_link_click_func: page_link_click_func
            }
        }).responseText;
        $(panel_id).html(respText);

        if (g_lnk_mbr_id > 0) {
            $('#divImg' + g_lnk_mbr_id).trigger('click');
            g_lnk_mbr_id = 0;
        }

        if (filter_no == 2)
            $('#spReceivedWink').text($('#totalRecord').val());
        else if (filter_no == 3)
            $('#spSentWink').text($('#totalRecord').val());
        else {
            $('#spReceivedWink').text('0');
            $('#spSentWink').text('0');
        }        
    });
}
$(function() {
    $('.login_dialogue').dialog({
        autoOpen: false,
        width: 330,
        closeOnEscape: false,
        closeText: 'close',
        stack: false,
        position: 'middle',
        draggable: true,
        modal: true
    });
});
function getLoginDialog() {
    var dialog_result = "    <!--Log in Dialogue-->" +
                        "    <div class=\"login_dialogue\" title=\"Login\" style=\"left:10px;top:10px; display:none;\">" +
                        "    <div class=\"beforeLogin\">" +
                        "        <fieldset>    " +
                        "        <div class=\"centerAlign statusError\">You Must Be Logged In To Continue</div>    " +
                        "        <div class=\"topPadding\"><div style=\"width:70px; text-align:right; float:left; padding:5px 10px;\">Email:</div> <div style=\"float:left;\"><input type=\"text\" id=\"evtemail\" name=\"evtemail\" maxlength=\"50\" value=\"\" title=\"Email\" class=\"txt inputtext\" /><br /><label class=\"statusError\" id=\"pEmailEvtError\"></label></div></div>" +
                        "        <div class=\"clear\"></div><div style=\"width:70px; text-align:right; float:left; padding:0px 10px;\"><p class=\"labelGrey\">example:</p></div> <div style=\"float:left;\"> <p class=\"labelGrey\">stevenpath@yahoo.com</p></div>" +
                        "        <div class=\"clear\"></div><div style=\"width:70px; text-align:right; float:left; padding:5px 10px;\">Password:</div><div style=\"float:left;\"><input type=\"password\" style=\"display: block;\" id=\"evtpassword\" class=\"inputtext\" name=\"evtpassword\" maxlength=\"50\" value=\"\" class=\"txt\" onkeypress=\"clickButton(event, 'btnEvtLogin')\" /></div>" +
                        "        <div class=\"clear\"></div><div style=\"width:70px; text-align:right; float:left; padding:0px 10px;\"><p class=\"labelGrey\">example:</p></div><div style=\"float:left;\"><p class=\"labelGrey\">sTe1G (case sensitive) </p></div>" +
                        "        <div class=\"clear\"></div>" +
                        "        <div style=\"padding-left: 90px;\"><label><input type=\"checkbox\" name=\"evtremember\" id=\"evtremember\" value=\"yes\" /> Remember Me</label></div>" +
                        "        <div style=\"height:20px;\"><div id=\"pEvtError\" class=\"centerAlign statusError\" style=\"display:none;\"></div> </div>" +
                        "        <div class=\"centerAlign\"><input type=\"button\" onclick=\"myCommitEvtLoginForm();\" id=\"btnEvtLogin\" name=\"btnLogin\" value=\"Login\" class=\"buttonSBlue login\" /><input type=\"button\" onclick=\"closeDialogue();\" id=\"btnClose\" name=\"btnClose\" value=\"Cancel\" class=\"buttonSBlue login\" /></div>        " +
                        "        <div class=\"centerAlign\">If you are new, click <a href=\"" + server_root + "\">here</a> to sign up</div>" +
                        "        <div class=\"centerAlign\"><a href=\"" + server_root + "/forgotPassword.aspx\">Forgot your password?</a></div>" +
                        "        </fieldset>" +
                        "    </div>" +
                        "    </div>";
    return dialog_result;
}
function myCommitEvtLoginForm() {
    checkLoginSub('evtremember', 'evtemail', 'evtpassword', 'pEvtError');
}
function closeDialogue() {
    $('.login_dialogue').dialog("close");
}

function onSuccessSub() {
    if (g_activate_url != "") {
        var isShow = onCheckIsAvailable();
        if (isShow.trim().indexOf("False") > -1)
            $('#noaccess_dialogue').dialog('open');
        else
            openSentWinkDialogue(session_sender_id, session_sender_id, session_receiver_full_name, session_receiver_first_name, session_sender_photo, session_receiver_photo);
    }
    else {
        openSentWinkDialogue(session_sender_id, session_sender_id, session_receiver_full_name, session_receiver_first_name, session_sender_photo, session_receiver_photo);
    }
}

function onCheckIsAvailable() {
    var url = server_root + "/Processor/GeneralProcessPart7.aspx";
    var respText = $.ajax({
        url: url,
        type: 'POST',
        async: false,
        data: {
            proc_id: 19
        }
    }).responseText;

    return respText;
}