﻿$(document).ready(function() {
    $(document).pngFix();
});
function gosearch() {
    var cate = $('#search_cate').val();
    var keyw = encodeURIComponent($('#keyw').val());
    if (cate != "") { location.href = '/Search/AdvancedSearch.aspx?item=' + cate + '&keywords=' + keyw; }
    else { location.href = '/Search/FullTextSearch.aspx?keyword=' + keyw; }
}
var theInt = null;
var curclicked = 0;
$(function() {
    $('#transparence').css('opacity', '0.5');
    $('#pic_list img').css({ 'opacity': '0.8' });
    $('#pic_list img:eq(0)').css({ 'top': '0', 'opacity': '1' });
    //$('#pic_list a').click(function() { return false });
    t(0);
    $('#pic_list img').mouseover(function() {
        if ($('#this_pic').attr('src') == $(this).attr('src')) return;
		clearInterval(theInt);
        t($('#pic_list img').index($(this)));
    });
});

t = function(i) {
    clearInterval(theInt);
    if (typeof i != 'undefined')
        curclicked = i;
    $('#this_pic').fadeOut(0).fadeIn(300).attr('src', $('#pic_list img').eq(i).attr('src').replace('s0', ''));
    $('#this_a').attr('href', $('#pic_list img').eq(i).parents('a').attr('href'));
    $('#this_a').attr('title', $('#pic_list img').eq(i).parents('a').attr('title'));
    $('#pic_list img').eq(i).parents('li').nextAll('li').find('img').animate({ top: 18, opacity: 0.8 }, 300);
    $('#pic_list img').eq(i).parents('li').prevAll('li').find('img').animate({ top: 18, opacity: 0.8 }, 300);
    $('#pic_list img').eq(i).animate({ top: 0 }, 300).css('opacity', '1');
    theInt = setInterval(function() {
        i++;
        if (i > $('#pic_list img').length - 1) { i = 0 };
        $('#this_pic').fadeOut(0).fadeIn(300).attr('src', $('#pic_list img').eq(i).attr('src').replace('s0', ''));
        $('#this_a').attr('href', $('#pic_list img').eq(i).parents('a').attr('href'));
        $('#this_a').attr('title', $('#pic_list img').eq(i).parents('a').attr('title'));
        $('#pic_list img').eq(i).parents('li').nextAll('li').find('img').animate({ top: 18, opacity: 0.8 }, 300);
        $('#pic_list img').eq(i).parents('li').prevAll('li').find('img').animate({ top: 18, opacity: 0.8 }, 300);
        $('#pic_list img').eq(i).animate({ top: 0 }, 300).css('opacity', '1');
    }, 3000)
}
function startmarquee(elementID, h, n, speed, delay) {
    var t = null;
    var box = '#' + elementID;
    $(box).hover(function() {
        clearInterval(t);
    }, function() {
        t = setInterval(start, delay);
    }).trigger('mouseout');
    function start() {
        $(box).children('ul:first').animate({ marginTop: '-=' + h }, speed, function() {
            $(this).css({ marginTop: '0' }).find("li").slice(0, n).appendTo(this);
        })
    }
}

$(function() {
    startmarquee('hotpicks', 100, 3, 1000, 3000);
})
