function trim(s){ return s.replace(/^[\s]+|[\s]+$/g, ""); }
String.prototype.blength = function() {
    var count = 0;
    for (var i = 0; i < this.length; i++) {
        var c = this.charAt(i);
        var enc = encodeURIComponent(c);
        count++;
        if (enc.length > 3) count++;
    }
    return count;
}

function LoginProcess()
{
    if($('#loginform :input[name=cardno]').val() == "") {
        alert("RevolutionカードのＩＤナンバーを入力して下さい。");
        $('#loginform :input[name=cardno]').focus();
        return false;
    }

    if($('#loginform :input[name=pw]').val() == "") {
        alert("パスワードを入力して下さい。");
        $('#loginform :input[name=pw]').focus();
        return false;
    }

    var param = $('#loginform').serialize();
    $.ajax({
        url: '/ajax/logincheck.php',
        type: 'post',
        data: param,
        success:function(res){
                LoginProcessed(res);
        }
        });
    return false;
}

function LoginProcessed(res)
{
    var retval = res;
    var obj = self.document.getElementById("loginform");
    if(retval == "1"){
        alert(obj.cardno.value + " は存在しません。");
        obj.cardno.select();
        obj.cardno.focus();
    }
    else if(retval == "2"){
        alert('パスワードが間違っています。');
        obj.pw.value = "";
        obj.pw.focus();
    }
    else if(retval == "3"){
        alert('このID NUMBERはログインできません。');
        obj.cardno.select();
        obj.cardno.focus();
    }
    else if(retval.indexOf("0") == 0){
	/*
	:r1403 rev01_kr.xlsx

        if(obj.returl.value) {
                self.location.href = obj.returl.value;
        }else{
	*/
                self.location.href = '/mypage/index.php';
        //}
    }
    else {
        alert("Login Error! code: -1\n\nContact us!");
    }
}

function setGiveup(){
        var msg = "本当に棄権しますか？";
        if(confirm(msg)){
                //var param = "registcode="+$('rform').entry_registcode.value;
                var param = "";
    		$.ajax({
		        url: '/ajax/setgiveup.php',
		        type: 'post',
		        data: param,
		        success:function(res){
		                setGiveuped(res);
		        }
	        });
        }
        return false;
}

function setGiveuped(res){
        var txt = res;
        if(txt == "1"){
                $("#btn_giveup").slideUp("fast",function(){
                	$("#btn_reset").slideDown("fast");
                });
                $("#give_up_alink").fadeOut("fast");
        }else{
                alert(txt);
        }
}


