﻿index = 0;
time = 0;
var imagepath = [];

var stopscroll = false;
function StoptScroll() {
    stopscroll = true;
}
function StartScroll() {
    stopscroll = false;
}
function AutoScroll(obj) {
    if (stopscroll == true) return;
    $(obj).find("li:first").animate({
        marginTop: "-60px"
    }, 2000, function () {
        $(this).css({ marginTop: "0px" }).appendTo(".hotright ul");
    });
}

$(document).ready(
         function () {
             $(".hotsiximg li img").each(
                 function () {
                     imagepath.push($(this).next().val());
                 });

             for (var procount = 0; procount < imagepath.length; procount++) {
                 $(".left .bigImgFrame .imgs").append("<img class=\"img" + procount + "\"  style=\"padding:3px 4px 3px 4px\" src=" + imagepath[procount] + " width=\"698\" height=\"239\" />");
             }

             $(".hotsiximg li").children().eq(0).css("background-image", "url(../../Images/Operation/Images/onprobg.gif)");

             time = setInterval('showPromotionimage()', 6000);

             setInterval('AutoScroll(".hotright ul")', 3000);

             $(".hotsiximg li").mouseover(
                   function () {

                       clearInterval(time);
                       clearAllImgState();

                       $(this).children().eq(0).css("background", "");
                       $(this).children().eq(0).css("background-image", "url(../../Images/Operation/Images/onprobg.gif)");

                       for (var count = 0; count < imagepath.length; count++) {
                           if ($(this).children().eq(1).children().next().val() == imagepath[count]) {
                               index = count;
                           }
                       }
                       for (var hideBigImgCount = 0; hideBigImgCount < imagepath.length; hideBigImgCount++) {
                           if (hideBigImgCount == index) {
                               $(".imgs .img" + hideBigImgCount).show();
                           }
                           else {
                               $(".imgs .img" + hideBigImgCount).hide();
                           }
                       }
                   });
             $(".hotsiximg li").mouseout(
                   function () {

                       time = setInterval('showPromotionimage()', 6000);

                       for (var showBigImgCount = 0; showBigImgCount < imagepath.length; showBigImgCount++) {
                           $(".imgs .img" + showBigImgCount).show();
                       }
                       clearAllImgState();
                   });

         });
function clearAllImgState() {
    for (var lispanCount = 0; lispanCount < imagepath.length; lispanCount++)
    { $(".hotsiximg li .span" + lispanCount).css("background", "#c4c6e7"); }
}

function showPromotionimage() {
    $(".imgs img:first").animate(
          { marginLeft: "-710px" }, 5000, function () {
              $(this).css({ marginLeft: "0px" }).appendTo(".left .imgs");
              clearAllImgState();
              for (var count = 0; count < imagepath.length; count++) {
                  if ($(this).attr("src") == imagepath[count]) {
                      count++;
                      if (count > 9) {
                          $(".hotsiximg li .span0").css("background", "url(../../Images/Operation/Images/onprobg.gif)");
                      }
                      else {
                          $(".hotsiximg li .span" + count).css("background", "url(../../Images/Operation/Images/onprobg.gif)");
                      }
                  }
              }
          });
}
