﻿
/* 全部分类 深蓝心语制作*/
var _pCategory;
var _pCategoryself;
function ShowAllCategory() {
    $("#ChiefCategory .CCTitle").hover(function() {
        clearTimeout(_pCategory);
        _pCategoryself = this;
        _pCategory = setTimeout(function() { ShowSecCategory(_pCategoryself) }, 300)
    }, function() {
        clearTimeout(_pCategory);
        $(this).removeClass("curr");
        $(this).find(".TheCategory").hide();
    });
}
function ShowSecCategory(x) {
    clearTimeout(_pCategory);
    $(x).addClass("curr");
    var offSet = $(x).offset();
    if (parseInt(offSet.top + $(x).find(".TheCategory").height()) - parseInt(document.documentElement.clientHeight + document.body.scrollTop + document.documentElement.scrollTop) > 0) {
        $(x).find(".TheCategory").css({ "top": "-" + parseInt(parseInt(offSet.top + $(x).find(".TheCategory").height()) - parseInt(document.documentElement.clientHeight + document.body.scrollTop + document.documentElement.scrollTop - 15)) + "px" })
    } else {
        $(x).find(".TheCategory").css({ "top": "-3px" });
    }
    $(x).find(".TheCategory").show();
}
/* 
--趣友网首页JS 
--幻灯片 QYAdvPoint var 3.5 for 深蓝心语 QQ:22230576 flycocke@gmail.com
*/
$(function() {
    var QYAdvPointSetTime;
    var QYAdvPointNom = "0";
    $.fn.QYAdvPoint = function() {
        var PowerPointImg = ['', '<div id="PointNum">'];
        for (var i = 0; i < QYAdvPointData.length; i++) {
            PowerPointImg[0] += '<a href="' + QYAdvPointData[i][1] + '" rel="external"><img src="' + QYAdvPointData[i][0] + '" alt="' + QYAdvPointData[i][2] + '" id="PointImagesID0' + i + '" style="display:none" /></a>';
            PowerPointImg[1] += ' <a href="' + QYAdvPointData[i][1] + '" id="PointSelectID0' + i + '" onMouseOver="$.fn.QYAdvPoint.Show(' + i + ')">' + (i + 1) + '</a>';
        }
        PowerPointImg[1] += '</div>';
        $("#PointImages").html(PowerPointImg[0] + PowerPointImg[1]);
        $.fn.QYAdvPoint.Show("0");
    }
    $.fn.QYAdvPoint.Show = function(Nom) {
        clearTimeout(QYAdvPointSetTime);
        $("#PointImagesID0" + QYAdvPointNom).animate({ opacity: 'hide' }, 800);
        $("#PointImagesID0" + Nom).animate({ opacity: 'show' }, 800);
        $("#PointSelectID0" + QYAdvPointNom).removeClass("selected");
        $("#PointSelectID0" + Nom).addClass("selected");
        QYAdvPointNom = Nom;
        if (Nom < 3) { Nom++; } else { Nom = 0; }
        QYAdvPointSetTime = setTimeout('$.fn.QYAdvPoint.Show("' + Nom + '")', 8000)
    }
    $("#AdvPointArea").QYAdvPoint();
    $("#Frilinks").show();
    SetTabTime = setTimeout("IndexSetTab('Pop',1,3)", 1000);
    /*限时抢购*/
    StartCuXiao();
    /*伸缩广告*/
    //S_Pub_s();
})
/*缩微图加载到大图-鼠标动作*/
jQuery.fn.loadthumb = function(options) {
    options = $.extend({
        src: ""
    }, options);
    var _self = this;
    var img = new Image();
    $(img).load(function() {
        _self.attr("src", options.src);
        $("#FullZone").animate({ height: "350px", opacity: "show" }, 1000);
        setTimeout("S_Pub_b()", 5000);
    }).attr("src", options.src);  //.atte("src",options.src)要放在load后面，
    return _self;
}
function S_Pub_s() {
    var centents = '<div id="FullZone_banner1"><a href="http://www.365goba.com/sub/sub_38.html" target="_blank"><img src="/images/channel/NewYear/b.jpg" /></a></div><div style="display:none" id="FullZone_banner2"><a href="http://www.365goba.com/sub/sub_38.html" target="_blank"><img src="/images/channel/NewYear/a.gif" /></a></div><input class="S_Pub_close" id="S_Pub_close" type="button" onclick="S_Pub_close()" style="display:none" /><input class="S_Pub_open" id="S_Pub_open" type="button"  onclick="S_Pub_open()" style="display:none" />';
    $("#FullZone").html(centents);
    if ($.browser.version == "6.0" || $.browser.version == "7.0") {
        $("#FullZone").animate({ height: "350px", opacity: "show" }, 1000);
        setTimeout("S_Pub_b()", 5000);
    } else {
    var ImgUrl = '/images/channel/NewYear/b.jpg';
        $("#FullZone_banner1 img").loadthumb({ src: ImgUrl });
    };

}
function S_Pub_b() {
    $("#FullZone").animate({ height: "80px" }, 1000);
    setTimeout("S_Pub_c()", 1000);
}
function S_Pub_c() {
    $("#FullZone_banner1").hide();
    $("#FullZone_banner2").show();
    $("#S_Pub_open").show();

}
function S_Pub_open() {
    $("#FullZone_banner2").hide();
    $("#FullZone_banner1").show();
    $("#FullZone").animate({ height: "350px" }, 1000);
    $("#S_Pub_open").hide();
    $("#S_Pub_close").show();
}
function S_Pub_close() {
    S_Pub_b();
    setTimeout('$("#S_Pub_close").hide()', 1000);
}
/*小栏目切换*/
var SetTabTime;
function IndexMoveTab(name, cursel, n, na) {
    clearTimeout(SetTabTime);
    SetTabTime = setTimeout("IndexSetTab('" + name + "'," + cursel + "," + n + ")", 300);
}
function IndexSetTab(name, cursel, n, na) {
    clearTimeout(SetTabTime);
    for (i = 1; i <= n; i++) {

        var menu = document.getElementById(name + i);
        var con = document.getElementById("con_" + name + "_" + i);
        menu.className = i == cursel ? "select" : "";
        con.style.display = i == cursel ? "block" : "none";
    }
    if (cursel < n) { cursel++; } else { cursel = 1; }
    SetTabTime = setTimeout("IndexSetTab('" + name + "'," + cursel + "," + n + ")", 5000);
};
/*
限时抢购
*/

var _CuxXiaoStr = eval([[0, 0], [0, 0], [0, 0], [0, 0]]);
var _CuXiaoAjax = [0, 0, 0, 0];
var _CuXiaoLoop;
function StartCuXiao() {
    for (i = 0; i < 4; i++) { PromotionalPlugin(i); } /*限时促销循环加载*/
}
function PromotionalPlugin(S_area) {
    $.ajax({
        type: "get",
        url: "/Themes/Default/Control/W_Share/w_QiangGou.aspx",
        dataType: "json",
        data: "S_area=" + S_area + "&t=" + Math.random(),
        success: function(msg) {
            if (msg.stats == "false") {/*该类没有商品了 显示false*/
                $("#QiangGouBox" + S_area).hide(); $("#PaiHang" + S_area).show();
                /*如果框内没有商品了，则显示排行*/
            } else {
                ;
                clearTimeout(_CuXiaoLoop);
                for (t = 0; t < 2; t++) {
                    if (_CuxXiaoStr[S_area][t] != "0") {
                        clearTimeout(ShowCountDownRand[_CuxXiaoStr[S_area][t]]);
                    };
                };
                var gs = '<div class="ClassSecBuyTitle">' + msg.name + '</div><div class="ClassSecBuyList"><ul id="QiangGouList' + S_area + '">';
                $.each(msg.list, function(i, ss) {
                    gs += '<li id="countdownProID_' + ss.proid + '">';
                    gs += '<div class="times" id="countdownTimes_' + ss.proid + '"></div>';
                    gs += '<div class="img"><a href="' + ss.url + '" target="_blank"><img src="' + ss.img + '" alt="' + ss.name + '" /></a></div>';
                    gs += '<div class="name"><a href="' + ss.url + '" target="_blank">' + ss.name + '</a></div>';
                    if (parseInt(ss.count) <= 5) {
                        gs += '<div class="vp">抢购价：￥' + ss.QiangGou + ' <span>仅剩</span>' + ss.count + '<span>件</span></div>';
                    } else {
                        gs += '<div class="vp">抢购价：￥' + ss.QiangGou + '</div>';
                    }
                    gs += '<span id="countdownStats_' + ss.proid + '" class="mks" style="display:none"></span></li>';
                    _CuxXiaoStr[S_area][i] = ss.proid;
                });
                gs += '</ul></div>';
                $("#PaiHang" + S_area).hide();
                $("#QiangGouBox" + S_area).html(gs).show();
                $.each(msg.list, function(i, ss) {
                    ShowCountDownSun(new Date(ss.stimes).getTime(), new Date(ss.otimes).getTime(), ss.proid, ss.count, S_area);
                });
                _CuXiaoLoop = setTimeout('StartCuXiao()', 120000);
            }
        }
    });
}
/*在线客服*/
var QQService = {
    start: function() {
        clearTimeout(ComparePost);
        if ($(ComPID[0]).get(0) == null) {
            $("body").append('<div id="CompareArea"><div class="CompareTitle"></div><img src="' + BlankImg + '" alt="关闭" class="close" onClick="clearCompare()" /><div class="CompareProduct"><ul id="CompareList"></ul><div class="opencompare"><img src="' + BlankImg + '" alt="compare" onClick="OpenCompare()" /></div></div></div>')
            $(ComPID[0]).css({ top: "220px", right: "0px" });
            ComparaDataRead();
        }
    }

}