var t = n = 0, count = 0;
$(document).ready(function() {
    var tip1 = $("#Header1_txtNickName").attr("title");
    $("#Header1_txtNickName").attr("value", tip1);
    $("#Header1_txtNickName").focus(function() {
        if ($(this).attr("value") == tip1) {
            $(this).attr("value", "")
        }
    });
    var tip2 = $("#Header1_txtPwd").attr("title");
    //$("#Userpassword").attr("type","text");
    $("#Header1_txtPwd").attr("value", tip2);
    $("#Header1_txtPwd").focus(function() {
        //$(this).attr("type","24");
        if ($(this).attr("value") == tip2) {
            $(this).attr("value", "")
        }
    });
    $(".product_cate_content p span:last-child").remove();
    $(".product_cate_content p a:last-child").addClass("last");
    $(".pro_cate_link a:last-child").addClass("last");
    $(".product_topsales_list:gt(2)").children(".img").addClass("aftertop3");

    /*index 3 carousel start*/
    //	var mycarousel_itemList = [
    //    {href: '/product/detail.aspx?id=7827',url: '/ImgUpload/ProductImage/YX00084A.jpg', title: '纸板数字',price1: '8.95'},
    //	];

    function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt) {
        // The index() method calculates the index from a
        // given index who is out of the actual item range.
        if (mycarousel_itemList.length == 0) return;
        var idx = carousel.index(i, mycarousel_itemList.length);
        carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[idx - 1]));
    };

    function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt) {
        carousel.remove(i);
    };


    //	var mycarousel_itemList2 = [
    //    {href: '/product/detail.aspx?id=7827',url: '/ImgUpload/ProductImage/YX00084A.jpg', title: '纸板数字',price1: '8.95'}
    //	];

    function mycarousel_itemVisibleInCallback2(carousel, item, i, state, evt) {
        // The index() method calculates the index from a
        // given index who is out of the actual item range.
        if (mycarousel_itemList2.length == 0) return;
        var idx = carousel.index(i, mycarousel_itemList2.length);
        carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList2[idx - 1]));
    };

    function mycarousel_itemVisibleOutCallback2(carousel, item, i, state, evt) {
        carousel.remove(i);
    };
    //	var mycarousel_itemList3 = [
    //    {href: '/product/detail.aspx?id=7827',url: '/ImgUpload/ProductImage/YX00084A.jpg', title: '纸板数字',price1: '8.95',price2: '6.95'}
    //	];

    function mycarousel_itemVisibleInCallback3(carousel, item, i, state, evt) {
        // The index() method calculates the index from a
        // given index who is out of the actual item range.
        if (mycarousel_itemList3.length == 0) return;
        var idx = carousel.index(i, mycarousel_itemList3.length);
        carousel.add(i, mycarousel_getItemHTML3(mycarousel_itemList3[idx - 1]));
    };

    function mycarousel_itemVisibleOutCallback3(carousel, item, i, state, evt) {
        carousel.remove(i);
    };
    /**
    * Item html creation helper.
    */
    function mycarousel_getItemHTML(item) {
        return '<a target="_blank" href="' + item.href + '" class="imgbox" target="_blank"><img src="' + item.url + '" alt="' + item.title + '" title="' + item.title + '"/></a><p class="pro_name"><a  target="_blank" href="' + item.href + '" title="' + item.title + '">' + item.title.substr(0, 6) + '</a></p><p class="pro_price">一口价:￥' + item.price1 + '</p>';
    };

    function mycarousel_getItemHTML3(item) {
        return '<a href="' + item.href + '" class="imgbox"><img src="' + item.url + '" alt="' + item.title + '" title="' + item.title + '"/></a><p class="pro_name"><a href="' + item.href + '" title="' + item.title + '">' + item.title.substr(0, 6) + '</a></p><p class="pro_price" style="display:none">市场价:<del>￥' + item.price1 + '</del></p><p class="member_price"><span><img src="images/index/cu.jpg" /></span>￥' + item.price2 + '</p>';
    };
    $('#mycarousel').jcarousel({
        auto: 0,
        scroll: 3,
        wrap: 'circular',
        itemVisibleInCallback: { onBeforeAnimation: mycarousel_itemVisibleInCallback },
        itemVisibleOutCallback: { onAfterAnimation: mycarousel_itemVisibleOutCallback }
    });
    $('#mycarousel2').jcarousel({
        auto: 0,
        scroll: 3,
        wrap: 'circular',
        itemVisibleInCallback: { onBeforeAnimation: mycarousel_itemVisibleInCallback2 },
        itemVisibleOutCallback: { onAfterAnimation: mycarousel_itemVisibleOutCallback2 }
    });
    $('#mycarousel3').jcarousel({
        auto: 0,
        scroll: 3,
        wrap: 'circular',
        itemVisibleInCallback: { onBeforeAnimation: mycarousel_itemVisibleInCallback3 },
        itemVisibleOutCallback: { onAfterAnimation: mycarousel_itemVisibleOutCallback3 }
    });
    /*index 3 carousel end*/
    count = $("#play_list a").size();
    $("#play_list a:not(:first-child)").hide();
    $("#play_info").html($("#play_list a:first-child").find("img").attr('alt'));
    $("#play_text li:first-child").addClass("current");
    $("#play_info").click(function() { window.open($("#play_list a:first-child").attr('href'), "_blank") });
    $("#play_text li").click(function() {
        var i = $(this).text() - 1;
        n = i;
        if (i >= count) return;
        $("#play_info").html($("#play_list a").eq(i).find("img").attr('alt'));
        $("#play_info").unbind().click(function() { window.open($("#play_list a").eq(i).attr('href'), "_blank") })
        $("#play_list a").filter(":visible").fadeOut(1000).parent().children().eq(i).fadeIn(1000);
        $(this).addClass("current").siblings().removeClass("current");
    });
    t = setInterval("showAuto()", 3000);
    $("#play").hover(function() { clearInterval(t) }, function() { t = setInterval("showAuto()", 3000); });
});

function showAuto()
{
	n = n >= (count - 1) ? 0 : ++n;
	$("#play_text li").eq(n).trigger('click');
}
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};


