﻿/// <reference path="../JQuery/Core/jquery-1.4.1-vsdoc.js" />
var IndexClass = new Object();
var pltanchu_yy = new Object();
$(function () {
    //评分层
    pltanchu_yy.comok = function (pfilmid) {
        filmID = pfilmid;
        $("#pltanchu").dialog({
            autoOpen: false,
            modal: true,
            height: '234',
            width: '352',
            draggable: false,
            resizeable: false
        });
        $("#pltanchu").removeClass('ui-dialog-content ui-widget-content');
        $("#pltanchu").parent().removeAttr("class");
        $("#pltanchu").parent().children().each(function () {
            if (this.id != "pltanchu") {
                this.style.display = "none";
            }
        });
        $("#pltanchu").dialog("open");
        $("#pltanchu").parent().css("height", "234px");
        $("#pltanchu").parent().css("width", "352px");
    }
    $("#pltanchuClose").click(function () {
        $("#pltanchu").dialog("close");
    });
    //edn 评分层

    $("#divLAndHTabs > div").click(function () {
        if ($("#" + this.lang).css("display") == "none") {
            $('#divTabs > div').slideUp();
            $("#" + this.lang).slideDown();
        }
        $('#divLAndHTabs > div').attr('class', 'flf poster_login_bqr');
        $(this).attr('class', 'flf poster_login_bql');
    });
    $("#divPageNumber > a").click(function () {
        for (var i = 1; i < 4; i++) {
            if ($("#divPage" + i).css("display") == "block") {
                $("#divPage" + i).hide();
            }
        }
        $("#divPageNumber > a").removeClass('booking_pagera');
        $("#" + this.lang).show();
        $(this).attr('class', 'booking_pagera');
    });
    $("#advInfo > div").mouseover(function () { clearInterval(t) });
    $("#advInfo > div").mouseout(function () {  t = setInterval("AutoScroll();", 12000); });
});

var cur = 0;
//公告板滚动JS

function AutoScroll() {
    $("#advInfo").find("div:first").animate({ marginTop: "-130px" }, 4, function () {
        $(this).css({ marginTop: "0px" }).find("div:first").appendTo(this);
    });
}
var t = setInterval("AutoScroll();", 12000);


/*海报切换 功能模块*/
{
    /*海报切换 函数*/
    var intervalId = setInterval("autoShow()", 5000);
    //暂停
    function pause() {
        clearInterval(intervalId);
    }
    //重新启动
    function restart() {
        intervalId = setInterval("autoShow()", 5000);
    }
    //其他隐藏
    function hideAnother2(c) {
        hideShow();
        pause();
        //divPosters

        $("#bigimage00" + c).show();
        //$("#bigimage00" + c).css("display", "block");
        $("#a" + c).attr("class", "flf poster_p1");
    }
    //其他隐藏
    function hideAnother(c) {
        for (var i = 0; i < 4; i++) {
            if (i == c) {
                $("#bigimage00" + i).show();
                //$("#bigimage00" + i).css("display", "block");
                $("#a" + i).attr("class", "flf poster_p1");
            }
            else {
                $("#bigimage00" + i).css("display", "none");
                $("#a" + i).attr("class", "flf poster_p");
            }
        }
    }
    //自动播放
    function autoShow() {
        if (cur == 4) {
            cur = 0;
            hideShow();
        }
        for (var i = 0; i < 4; i++) {
            if (i == cur) {
                $("#bigimage00" + i).show(); //.slideDown("fast");
                //$("#bigimage00" + i).css("display", "block");
                $("#a" + i).attr("class", "flf poster_p1");
                hideAnother(i);
            }
        }
        cur++;
    }
    //隐藏显示
    function hideShow() {
        //$("#divPosters > a").removeAttr("class");
        //$("#divPosters > img").slideUp("fast");
        //
        var flag = false;
        for (var i = 0; i < 4; i++) {
            $("#bigimage00" + i).hide();
            $("#a" + i).attr("class", "flf poster_p");
            if (i == 4) {
                flag = true;
            }
        }
        return flag;
    }
}
/*海报切换 函数 结束*/

/*hipass 开卡*/
$(function () {
    //卡号 密码
    $("#imgOpenCard").click(function () {
        var hipassCardNum = $("#HCardNum").val();
        var hipassCardPWD = $("#HCardPWD").val();
        if (hipassCardNum == "" || hipassCardNum == "您的hipass卡号") {
            alert("请输入卡号");
            return;
        }
        if (!ValidateHiPassCode(hipassCardNum)) {
            alert("请输入正确的hipass卡号");
            return;
        }
        if (hipassCardPWD == "") {
            alert("请输入密码");
            return;
        }
        if (!ValidateHiPassPwd(hipassCardPWD)) {
            alert("请输入正解的hipass卡密码");
            return;
        }
        //判断用户是否登陆
        var userid = $("#Content_hipassuserid").val();
        if (userid != "undefined" && userid > 0) {
            $.ajax({
                type: "GET",
                contentType: "application/html",
                url: $("#ROOTURL").val() + '/Utils/ActivateHIPass.aspx?pHIPassCode=' + hipassCardNum + '&pHiPassPassword=' + hipassCardPWD + '&pUserID=' + $("#Content_hipassuserid").val(),
                data: "",
                cache: false,
                dataType: "html",
                success: function (result) {
                    if (result == "开卡成功！") {
                        alert(result); window.location.reload();
                    } else {
                        alert(result);
                    }
                },
                error: function (result) {
                    if (status == 'error') { alert(status); }
                }
            }); //ajax结束
        }
        else {
            alert("请先登陆，或注册！");
        }
    }); //click结束
});
//校验HiPass卡号格式
function ValidateHiPassCode(txt) {
    var regValidateNum = /^\d{15}$/;
    return regValidateNum.test(txt);
}
//校验HiPass密码格式
function ValidateHiPassPwd(txt) {
    var regValidateNum = /^\d{6}$/;
    return regValidateNum.test(txt);
}
/*hipass 开卡结束*/
/*评分*/
var point = 0;
var context = "";
function CheckContext() {
    point = $('#selFilmCount').val();
    context = $('#txtContext').val();
    if (!UserState) {
        alert("请先登陆，再评论！");
        return;
    }
    if (context == "") {
        alert("请填写评论内容");
        return false;
    }
    $("#loading").show();
    $.get('Utils/Comments.aspx', { type: '1', filmID: filmID, point: point, context: context }, function (data) {
        if (data == "评分成功") {
            alert(data);
            location.reload();
        }
        else {
            alert(data);
            $("#loading").hide();
        }
    });
}