﻿$(function() {
    $('#forget-pw').click(function() {
        jPrompt('請輸入您的email : ', '', '忘記密碼', function(email) {
            if (email) {
                $.getJSON('ajax.ashx?a=forget&e=' + email + '&jsoncallback=?', function(data) {
                    if (data.msg != '') { jAlert(data.msg); }
                })
             }
        });
        /*
        var email = jPrompt('請輸入您的email', '');
        if (email == null || email.length == 0) { return; }
        $.getJSON('ajax.ashx?a=forget&e=' + email + '&jsoncallback=?', function(data) {
            if (data.msg != '') { jAlert(data.msg); }
        })
        */
    })
    $('.zh-TW').click(function() { document.location.href = '/'; })
    $('.en-US').click(function() { document.location.href = '/english/'; })
    /*
    $('.zh-TW, .en-US').click(function() {
    $.ajax({
    url: 'ajax.ashx',
    type: 'POST',
    async: false,
    dataType: 'json',
    data: {
    a: 'changeLanguage',
    lg: $(this).attr('class')
    },
    error: function(xhr) {
    _msg = 'Ajax request 發生錯誤';
    },
    success: function(data) {
    if (data.msg != '') { jAlert(data.msg); } else { history.go(0); }
    }
    });
    })
    */
})
function triggerMustLogin() {
    $('.mustLogin').attr({ 'href': 'javascript:' });
    $('.mustLogin').removeAttr('onclick');
    $('.mustLogin').each(function() {
        $(this).click(function(e) {
            jAlert('請先登入會員');
            return false ;
        })
    })

}
function CheckCode(_chkno) {
    var _msg = '';
    $.ajax({
        url: 'ajax.ashx',
        type: 'POST',
        async: false,
        dataType: 'json',
        data: {
            a: 'CheckCode',
            chkno: _chkno
        },
        error: function(xhr) {
            _msg= 'Ajax request 發生錯誤';
        },
        success: function(data) {
            _msg= data.msg;
        }
    });
    return _msg;
}
function CheckCode_Click() {
    $('#CheckCode').attr({'src':'/ValidateCode.ashx?code='+Math.random()});
}
