﻿var iCurValue = -1;
var iMax = 4;
var pauseTime = 4000;
var timer1;

$(function () {
    $("#PrevImg").click(function () {
        stopScroll();
        if (iCurValue > 0) {
            iCurValue--;
            hideAll();
            $(".dc").eq(iCurValue).show();
            $("#spCur").html(iCurValue + 1);
        }
        else {
            iCurValue = 4;
            $(".dc").eq(4).show();
            $("#spCur").html(5);
            fwdScroll();
        }
        timer1 = setTimeout("fwdScroll()", pauseTime);
    })

    $("#NextImg").click(function () {
        stopScroll();
        if (iCurValue < iMax) {
            iCurValue++;
            hideAll();
            $(".dc").eq(iCurValue).show();
            $("#spCur").html(iCurValue + 1);
        }
        else {
            iCurValue = -1;
            hideAll();
            $(".dc").eq(0).show();
            $("#spCur").html(1);
            fwdScroll();
        }
        timer1 = setTimeout("fwdScroll()", pauseTime);
    })
    fwdScroll();

    $("#DropDown").toggle(function () {
        $(this).removeClass("down");
        $(this).addClass("up");
        $("#FlowDiv").show();

    }, function () {
        $(this).removeClass("up");
        $(this).addClass("down");
        $("#FlowDiv").hide();
    })

    $("#FlowDiv .li").each(function (i) {
        $(this).find("a").click(function () {
            $("#DropDown").html($(this).html());
            $("#LanguageJump").attr("href", $(this).attr("rel"));
            $("#FlowDiv").hide();
            $("#DropDown").removeClass("up");
            $("#DropDown").addClass("down");
        })
    })

})
function hideAll() {
    $(".dc").hide();
}

function fwdScroll() {
    stopScroll();
    if (iCurValue < iMax) {
        iCurValue++;
        hideAll();
        $(".dc").eq(iCurValue).show();
        $("#spCur").html(iCurValue + 1);
    }
    else {
        iCurValue = -1;
    }
    if (iCurValue == 4) {
        timer1 = setTimeout("fwdScroll()", 200);
    }
    else {
        timer1 = setTimeout("fwdScroll()", pauseTime);
    }
}

function stopScroll() {
    clearTimeout(timer1);
}

function _GetDetail(_id) {
    GetDetail(parseInt(_id), function (response) {
    $("#PreView").html(response.value);
    });
    $("#PreView").html("<div id=\"PreViewTitle\" style=\"text-align:center;font-size:14px;color:white\">loading....</div>");
}

