﻿var newsIndex = 0;
var autoRunNewsTimer=null;
function autoRunNews() {
            var liSelected = $('#flashBtn > ul > li').eq(newsIndex);
            liSelected.parent().children('li').removeClass('selected');
            liSelected.addClass('selected');

            $('#flashBanner > ul').stop().animate({ 'left': -newsIndex * 540 + 'px' }, 300);

            newsIndex = newsIndex == 2 ? 0 : ++newsIndex;
            //alert(newsIndex);
            clearTimeout(autoRunNewsTimer);
            autoRunNewsTimer = setTimeout('autoRunNews()', 3000);
            
}
$(function () {

//    $('#videoView').colorbox({ width: '420px', height: '420px', iframe: true });
    autoRunNewsTimer = setTimeout('autoRunNews()', 3000);

    $('#flashBtn > ul > li').mouseover(function () {
        var index = $(this).attr('rel');
        newsIndex = index;
        autoRunNews();
    });

    $('.gqxx').jCarouselLite({
        speed: 600,
        auto: 5000,
        vertical: true,
        visible: 7
    });

    $('#button > div').mouseover(function () {
        $(this).parent().find('.selected').removeClass('selected');
        $(this).addClass('selected');

        $('#userGuide div.tab').removeClass('selected');
        $('#userGuide div.tab').eq($(this).attr('rel')).addClass('selected');
    });

    $('.productCt > ul > li.parent').hover(function () {
        $(this).addClass('selected');
        var top = $(this).offset().top + 'px';
        var left = $(this).offset().left + 145 + 'px';
        $('.productCt > ul > li.parent > ul.menuProductCategoryChild').css({ 'top': top, 'left': left });
        $('.productCt > ul > li.parent > ul.menuProductCategoryChild tr').each(function () {
            $(this).find('td:first').css({ 'border-left-style': 'none' })
        });
        $(this).find('ul.menuProductCategoryChild tr .categoryImg').each(function () {
            if ($(this).attr('src') == '') {
                $(this).attr('src', $(this).attr('lazysrc'));
            }
        });
    }, function () {
        $(this).removeClass('selected');
    });



    setTimeout(function () {
        $.get('/home/friendship.htm', function (result) {
            $('#friendshipLink').html(result);
        });

        $.get('/home/partner.htm', function (result) {
            $('#partner').html(result);
            $('#partner').jCarouselLite({
                speed: 2000,
                auto: 3000,
                visible: 4,
                scroll: 1
            });
        });
    }, 10000);

    $('#advertising .topAd a').mouseover(function () {
        $('#advertising .topAd').find('.selected').removeClass('selected');
        $(this).addClass('selected');
        $('#advertising .tabs').find('.selected').removeClass('selected');
        $('#advertising .tabs .tab').eq($(this).attr('rel')).addClass('selected');
        return false;
    });

    $('#recommendCompany li').hover(function () {
        $(this).css('z-index', 999);
        $(this).find('div').css('z-index', 999).show();
    }, function () {
        $(this).css('z-index', 1);
        $(this).find('div').css('z-index', 1).hide();
    });
});
