﻿if (typeof console == "undefined" || typeof console.log == "undefined") var console = { log: function () { } };
/****************/

$(document).ready(function ($) {

    var options = {
        $AutoPlay: true,                                    //[Optional] Whether to auto play, to enable slideshow, this option must be set to true, default value is false
        $AutoPlayInterval: 4000,                            //[Optional] Interval (in milliseconds) to go for next slide since the previous stopped if the slider is auto playing, default value is 3000
        $SlideDuration: 500,                                //[Optional] Specifies default duration (swipe) for slide in milliseconds, default value is 500
        $DragOrientation: 1,                                //[Optional] Orientation to drag slide, 0 no drag, 1 horizental, 2 vertical, 3 either, default value is 1 (Note that the $DragOrientation should be the same as $PlayOrientation when $DisplayPieces is greater than 1, or parking position is not 0)
        $UISearchMode: 0,                                   //[Optional] The way (0 parellel, 1 recursive, default value is 1) to search UI components (slides container, loading screen, navigator container, arrow navigator container, thumbnail navigator container etc).

        $ThumbnailNavigatorOptions: {
            $Class: $JssorThumbnailNavigator$,              //[Required] Class to create thumbnail navigator instance
            $ChanceToShow: 2,                               //[Required] 0 Never, 1 Mouse Over, 2 Always
            $AutoCenter: 2,
            $Loop: 2,                                       //[Optional] Enable loop(circular) of carousel or not, 0: stop, 1: loop, 2 rewind, default value is 1
            $SpacingX: 3,                                   //[Optional] Horizontal space between each thumbnail in pixel, default value is 0
            $SpacingY: 3,                                   //[Optional] Vertical space between each thumbnail in pixel, default value is 0
            $DisplayPieces: 5,                              //[Optional] 列表呈現數, default value is 1
            $ParkingPosition: 204,                          //[Optional] The offset position to park thumbnail,


            $ArrowNavigatorOptions: {
                $Class: $JssorArrowNavigator$,              //[Requried] Class to create arrow navigator instance
                $ChanceToShow: 2,                               //[Required] 0 Never, 1 Mouse Over, 2 Always
                $AutoCenter: 2,                                 //[Optional] Auto center arrows in parent container, 0 No, 1 Horizontal, 2 Vertical, 3 Both, default value is 0
                $Steps: 1                                       //[Optional] 列表移動數, default value is 1
            }
        }
    };

    $(".slider_pic").each(function (key, value) {
        var jssor_slider1 = new $JssorSlider$("slider" + (key + 1) + "_container", options);

        if ($('#cation').length > 0) {
            jssor_slider1.$On($JssorSlider$.$EVT_STATE_CHANGE, function (slideIndex, progress, progressBegin, idleBegin, idleEnd, progressEnd) {
                var strOnClick = $("#slider" + (key + 1) + "_container div[u='slides'] div img[u=image]:eq(" + slideIndex + ")").attr("onclick");
                if (strOnClick.indexOf("ff(") > -1) {
                    if (strOnClick.length - 6 > 0) {
                        ff(strOnClick.substring(4, strOnClick.length -2));
                    }
                }
            });
        }

        function ScaleSlider() {
            var parentWidth = jssor_slider1.$Elmt.clientWidth;
            if (parentWidth)
                jssor_slider1.$SetScaleWidth(parentWidth);
            else
                window.setTimeout(ScaleSlider, 30);
        }

        ScaleSlider();
    });
});

function pIcalt(str) {
    $('#cation').html("");
    $('#cation').html(str);
}

function ff(str) {
    $('#cation').html("");
    $('#cation').html(str);
}