﻿var weibo_count = 0;
var msg_index = 0;
var msg_look = 0;

$(function() {
    $("#KinSlideshow").KinSlideshow();

    setTimeout("GetMsg()", 5000);

    $("#index_say").mouseover(function() {
        msg_look = 1;
    });
    $("#index_say").mouseleave(function() {
        msg_look = 0;
    });

    $("#index_product span img").mouseover(function() {
        $(this).css('opacity', '1.0');
    });

    $("#index_product span img").mouseleave(function() {
        $(this).css('opacity', '0.8');
    });
});

function GetMsg() {
    if (msg_look == 1) {
        setTimeout("GetMsg()", 5000);
        return;
    }
    msg_index = msg_index + 2;

    var msg_right;

    if (msg_index > (weibo_count - 1)) {
        msg_index = 0;
    }

    msg_right = msg_index + 1;
    if (msg_right > weibo_count) {
        msg_right = 1;
    }

    var p_left = $("#index_say").offset().left;
    var p_top = $("#index_say").offset().top;
    var roll = $("<div/>", { css: { position: "absolute", border: "solid 1px #999", left: p_left + 665, top: p_top, height: "179px", width: "1px", margin: "3px", background: "#fff url(images/index/eCX.png) repeat-y -200px 0px"} }).appendTo($("#index_say").parent());
    $(roll).animate({
        left: p_left,
        width: "332px",
        "background-position-x": "272px",
        "background-position-y": "0px"
    }, 1000, function() {

        $(roll).fadeOut(300, function() {
            $(roll).remove();
        })


        if (weibo_count > 0) {
            for (var i = 0; i < weibo_count; i++) {
                if (i % 2 == 0) {
                    if (msg_index == i) {
                        $("#index_say_left_" + i).show();
                    }
                    else {
                        $("#index_say_left_" + i).hide();
                    }
                }
                else {
                    if (msg_right == i) {
                        $("#index_say_right_" + i).show();
                    }
                    else {
                        $("#index_say_right_" + i).hide();
                    }
                }
            }
        }
    });
    setTimeout("GetMsg()", 5000);
}



$(function() {
    var _wrap = $('#div_xianzhi'); //定义滚动区域 
    var _interval = 3000; //定义滚动间隙时间 
    var _moving; //需要清除的动画 
    
    _wrap.hover(function() {
        clearInterval(_moving); //当鼠标在滚动区域中时,停止滚动
    }, function() {
        _moving = setInterval(function() {            
            var _field = _wrap.find('li:first'); //此变量不可放置于函数起始处,li:first取值是变化的 
            var _h = _field.height(); //取得每次滚动高度(多行滚动情况下,此变量不可置于开始处,否则会有间隔时长延时) 
            _field.animate({ marginTop: -_h + 'px' }, 600, function() {//通过取负margin值,隐藏第一行 
                _field.css('marginTop', 0).appendTo(_wrap); //隐藏后,将该行的margin值置零,并插入到最后,实现无缝滚动 
            })
        }, _interval)//滚动间隔时间取决于_interval 
    }).trigger('mouseleave'); //函数载入时,模拟执行mouseleave,即自动滚动 
});

function rss_click() {
    var txt_Birthday = $('#txt_Birthday').val();
    var txt_Email = $('#txt_Email').val();

    if ($.trim(txt_Birthday) == '') {
        $('#txt_Birthday').addClass('tooltipinputerr');
        art.dialog({ time: 2, content: '请输入宝宝生日或预产期，如：2011-10-10' });
        return false;
    }

    if ($.trim(txt_Email) == '') {
        $('#txt_Email').addClass('tooltipinputerr');
        art.dialog({ time: 2, content: '请输入接收电子邮箱，如：xxx@xxx.com' });
        return false;
    }
    
    var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
    if (!reg.test(txt_Email)) {
        $('#txt_Email').addClass('tooltipinputerr');
        art.dialog({ time: 2, content: '请输入正确的邮箱地址，如：xxx@xxx.com' });
        return false;
    }

    $('#btn_Rss').html("提交中...");

    $.ajax({
        type: "Post",
        url: "ajaxAshx/Comment.aspx/Jihua_Rss",
        data: "{'txt_Birthday':'" + txt_Birthday + "','txt_Email':'" + txt_Email + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(data) { 
            if (data.d == "1") {
                $('#btn_Rss').html("已订阅");
                $("#btn_Rss").attr("disabled", "disabled");
                art.dialog({ time: 2, content: '订阅成功，请您留意邮箱接收信息！' });
            }
            else {
                art.dialog({ time: 2, content: '此邮箱已经订阅过了,您可以换个邮箱订阅!' });
                document.getElementById('btn_Rss').innerHTML = "免费订阅";
            }
        }
    });
}

(function($) {
    $.fn.center = function(settings) {
        var style = $.extend({
            position: 'absolute', //absolute or fixed
            top: '50%',            //50%即居中，将应用负边距计算，溢出不予考虑了。
            left: '50%',
            zIndex: 2009,
            relative: true        //相对于包含它的容器居中还是整个页面
        }, settings || {});

        return this.each(function() {
            var $this = $(this);

            if (style.top == '50%') style.marginTop = -$this.outerHeight() / 2;
            if (style.left == '50%') style.marginLeft = -$this.outerWidth() / 2;
            if (style.relative && !$this.parent().is('body') && $this.parent().css('position') == 'static')
                $this.parent().css('position', 'relative');
            delete style.relative;
            //ie6
            if (style.position == 'fixed' && $.browser.version == '6.0') {
                style.marginTop += $(window).scrollTop();
                style.position = 'absolute';
                $(window).scroll(function() {
                    $this.stop().animate({
                        marginTop: $(window).scrollTop() - $this.outerHeight() / 2
                    });
                });
            }

            $this.css(style);
        });
    };
})(jQuery);

$(document).ready(function() {
//    $("#centerDiv").center({ position: 'fixed', top: '50%' });
//    $('<div id="lsxBlank"></div>').prependTo("body");
//    $("#lsxBlank").css({
//        width: $("body").width(),
//        height: $("body").height(),
//        "opacity": 0.15
//    });


//    $("#center_close").click(function() {
//        $("#centerDiv").hide();
//        $("#lsxBlank").hide();
//    });
});



function get_cookie() {
    var allcookie = document.cookie;
    var szcookie = allcookie.split(';');
    for (var i = 0; i < szcookie.length; i++) {
        var first_cookie = szcookie[i].split('=');
        //alert(first_cookie[0]);
        if (first_cookie[0] == 'tipcookie') {
            // alert(first_cookie[1]);
        }
    }
}
$(function() {
    var toid = $('[id$=hi_uid]').val();
    if (toid == '0') {       
        setTimeout(function() {
            var bg = $("#lsxBlank");
            if (bg.length > 0) {
                bg.show();
            }
            else {
                $('<div id="lsxBlank"></div>').prependTo("body");
                $("#lsxBlank").css({
                    width: $("body").width(),
                    height: $("body").height(),
                    "opacity": 0.15
                });
            }
            $("#iframe_div_two").center({ position: 'fixed', top: '50%' });
            $('#iframe_div_two').show();
            if (document.cookie.indexOf('tipcookie') != -1) {
                document.getElementById('lsxBlank').style.visibility = 'hidden';
                document.getElementById('iframe_div_two').style.visibility = 'hidden';
            }
        }
            , 5000);
    }
}); 


