
function isInteger(s)
{
  return (s.toString().search(/^-?[0-9]+$/) == 0);
}

function isUnsignedInteger(s)
{
  return (s.toString().search(/^[0-9]+$/) == 0);
}

(function( $ )
{
	$.fn.cloneLight = function()
	{
		if ($(this).get(0).tagName=="IMG")
		{
		clone = $("<img src=\""+$(this).attr("src")+"\">");
		return clone;
		}
		else
		{
		return $(this).clone();
		}
	}

	$.fn.stvSlider = function(method)
	{
		// system variables
		var vars =
		{
		hoverZindex: 1010,
		currentSlicesZindex: 1004,
		currentZindex: 1003,
		lastZindex: 1002,
		lastSlicesZindex: 1001,
		inactiveZindex: 1000,

		lastSliderIndex: 0,
		currentSliderIndex: 0,
		oldSliderIndex: 0,
		olderSliderIndex: 0,

		slides: [],

		containerSelector: "",

		clickEnabled: true,
		mouseOver: false,
		slideShowPaused: false,
		slideShowStoped: false,
		slideShowStartedAt: 0,
		slideShowRemaining: 0,
		slideShowTimeout:'',

		currentDirectionNext: true,
		currentChangeAutomatic: true,
		slicesShouldBeFinished: false,

		captionBoxEnabled: true,
		captionBoxVisible: false,
		prevnextOriginalStyle: "",

		slideshowCounter: -1
		}

		// default variables
		// don't edit them, you can overwrite all of them as a parameter
		var defaults =
		{
		/////////////////////////////////////////////////////////////////////////////////
		// width&height must be set either as parameters for the plugin, or in the style
		// attribute of the container div or in an outer style block
		/////////////////////////////////////////////////////////////////////////////////
		width: "", // width of the slider // any valid css size
		height: "", // height of the slider // any valid css size

		/////////////////////////////////////////////////////////////////////////////////
		// all the other parameters are optional, you can use the embedded default values
		// or you can overwrite them as a parameter given to the jQuery plugin
		/////////////////////////////////////////////////////////////////////////////////

		slideSelector: ".stvSliderSlide", // selector of the slide element // any valid jQuery selector
		animationSpeed: 2000, // transition time // numeric
		effect: "random", // "random"|effect name // string
		pace: "smooth", // "smooth"|"harsh"|"tremor"|"bounce"
		randomEffects: [["fade","smooth"],["puffInOut","smooth"],["slideThruHorizontal","smooth"],["slideInVertical","harsh"],["slideInOutHorizontal","tremor"],["slideThruVertical","bounce"],["scaleTC","harsh"],["blocksDrop","harsh"],["blocksStairs","harsh"],["curtainsWide","harsh"],["zigzagBlanket","harsh"],["zigzagWaves","harsh"]], // if effect is random, the effect will be selected from this array // array
		slideshowEffects: [["fade","smooth"],["puffInOut","smooth"],["slideThruHorizontal","smooth"],["slideInVertical","harsh"],["slideInOutHorizontal","tremor"],["slideThruVertical","bounce"],["scaleTC","harsh"],["blocksDrop","harsh"],["blocksStairs","harsh"],["curtainsWide","harsh"],["zigzagBlanket","harsh"],["zigzagWaves","harsh"]], // if effect is slideshow, the effect will be selected from this array // array
		minDelayTime: 1, // time for the manual nextprev are disabled after every transition // numeric|"auto"

		slideShowStart: true, // does automatic slideshow start on load? // true|false
		slideShowButton: false, // does it have a start/stop slideshow button? // true|false
		slideShowStartButtonLabel: "start slideshow", // label of the prev button // string
		slideShowStopButtonLabel: "stop slideshow", // label of the next button // string
		slideShowButtonCss: "", // CSS of the prev/next button boxes // any css
		slideShowButtonClass: "startstopButton", // class of the prev/next button boxes // any css class
		slideShowButtonCss: "", // CSS of the stop/start button box // any css
		slideShowTime: 3000, // pause time // numeric
		slideShowPauseAtHover: true, // does it pause if the mouse is over the image? // true/false

		prevnextButton: true, // does it have prev/next buttons in the box? // true|false
		prevButtonLabel: "< prev", // label of the prev button // string
		nextButtonLabel: "next >", // label of the next button // string
		prevnextButtonCss: "width: 100px;", // CSS of the prev/next button boxes // any css
		prevnextButtonClass: "prevnextButtonNormal", // class of the prev/next button boxes // any css class
		prevnextButtonActiveCss: "", // CSS of the prev/next button boxes on hover // any css
		prevnextButtonActiveClass: "prevnextButtonActive", // class of the prev/next button boxes on hover // any css class
		prevnextShadowCss: "", // CSS of the prev/next shadows // any css
		prevnextShadowClass: "prevnextShadowNormal", // class of the prev/next shadows // any css class
		prevnextShadowActiveCss: "", // CSS of the prev/next shadows on hover // any css
		prevnextShadowActiveClass: "prevnextShadowActive", // class of the prev/next shadows on hover // any css class

		outerPrevLinkSelector: "#outerPrevLink", // originally for testing purposes, selector of a link // any valid jQuery selector
		outerNextLinkSelector: "#outerNextLink", // originally for testing purposes, selector of a link // any valid jQuery selector

		captionBox: true, // does it have a caption box? // true|false
		captionBoxHide: true, // does it show the caption box only on mouseover? // true|false
		captionBoxHeight: "auto", // height of the caption box // numeric or "auto"
		captionBoxShadowCss: "", // CSS of the caption box (you can use external css for #captionBoxShadow instead) // any css
		captionBoxCss: "", // CSS of the caption box (you can use external css for #captionBoxInner instead) // any css
		captionContentFrom: "title", // name of attribute of slideSelector element that should be used as caption // any valid attribute
		removeCaptionAttr: true, // should the source attribute of the caption content be removed? // true|false

		redirectLink: true, // do the slides have links? // true|false
		redirectLinkFrom: "href", // name of attribute of slideSelector element that should be used as link // any valid attribute
		redirectTargetFrom: "target", // name of attribute of slideSelector element that should be used as link // any valid attribute
		removeLinkAttr: true, // should the source attributes of the link and target be removed? // true|false
		}

		var settings = {};


		var effects =
		{
		fade:
			{
			run: function()
				{
				$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex}); // delete // .css(vars.slides[vars.currentSliderIndex].originalCss)
				$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
				$(vars.slides[vars.currentSliderIndex].selector).fadeIn(settings.animationSpeed,effects[currentEffect]["paces"][currentPace]);
				$(vars.slides[vars.oldSliderIndex].selector).delay(settings.animationSpeed).queue(function()
					{
					$(this).fadeOut(0).dequeue();
					});
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuint",
				tremor: "easeInOutBounce",
				bounce: "easeInBounce",
				}
			},

		puffIn:
			{
			run: function()
				{
				$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
				$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
				$(vars.slides[vars.currentSliderIndex].selector).show("puff",{"percent":300,"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
					$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		puffOut:
			{
			run: function()
				{
				$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
				$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
				$(vars.slides[vars.oldSliderIndex].selector).hide("puff",{"percent":300,"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeOutQuart",
				tremor: "easeInOutBounce",
				bounce: "easeInBounce",
				}
			},

		puffInOut:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("puff",{"percent":300,"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);

					}
					else
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("puff",{"percent":300,"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
					$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeOutQuart",
				tremor: "easeInOutBounce",
				bounce: "easeInBounce",
				}
			},

		slideInHorizontal:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"right","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
					else
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"left","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		slideOutHorizontal:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"left","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					}
					else
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"right","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		slideInRight:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"right","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
					else
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"right","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		slideOutRight:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"left","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					}
					else
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"left","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		slideInOutHorizontal:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"right","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
					else
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"right","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeOutQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		slideThruHorizontal:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"right","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"left","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					}
					else
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"left","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"right","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					}
				},
			paces:
				{
				smooth: "linear",
				harsh: "linear",
				tremor: "linear",
				bounce: "linear",
				}
			},

		slideInVertical:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"up","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
					else
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"down","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		slideOutVertical:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"down","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					}
					else
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"up","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		slideInUp:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"up","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
					else
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"up","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		slideInDown:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"down","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
					else
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"down","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		slideOutUp:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"up","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					}
					else
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"up","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		slideOutDown:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"down","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					}
					else
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"down","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		slideInOutUp:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"up","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
					else
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"up","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		slideInOutDown:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"down","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
					else
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"down","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		slideThruVertical:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"down","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"up","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
					else
					{
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.oldSliderIndex].selector).hide("slide",{"direction":"up","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed);
					$(vars.slides[vars.currentSliderIndex].selector).show("slide",{"direction":"down","easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
				},
			paces:
				{
				smooth: "linear",
				harsh: "easeOutQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		scaleTC:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("scale",{"origin":["top","center"],"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
					else
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("scale",{"origin":["bottom","center"],"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		scaleTR:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("scale",{"origin":["top","right"],"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
					else
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("scale",{"origin":["bottom","left"],"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		scaleMC:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("scale",{"origin":["middle","center"],"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
					else
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("scale",{"origin":["middle","center"],"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		scaleMR:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("scale",{"origin":["middle","right"],"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
					else
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("scale",{"origin":["middle","left"],"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		scaleBC:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("scale",{"origin":["bottom","center"],"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
					else
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("scale",{"origin":["top","center"],"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		scaleBR:
			{
			run: function()
				{
					if (vars.currentDirectionNext)
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("scale",{"origin":["bottom","right"],"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
					else
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex});
					$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1});
					$(vars.slides[vars.currentSliderIndex].selector).show("scale",{"origin":["top","left"],"easing":effects[currentEffect]["paces"][currentPace]},settings.animationSpeed,function(){
						$(vars.slides[vars.oldSliderIndex].selector).css({"display":"none"});
					});
					}
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeInQuart",
				tremor: "easeInOutBounce",
				bounce: "easeOutBounce",
				}
			},

		zigzagBlanket:
			{
			run: function()
				{
				methods.animateSlices2.apply(this,[30,40,{"height":"0px","opacity":0},{"height":$(vars.containerSelector).height()+"px","opacity":1}]);
				},
			paces:
				{
				smooth: "easeOutQuint",
				harsh: "easeOutQuint",
				tremor: "easeOutQuint",
				bounce: "easeOutQuint"
				}
			},

		zigzagFalls:
			{
			run: function()
				{
				methods.animateSlices2.apply(this,[50,70,{"height":"0px","opacity":1},{"height":$(vars.containerSelector).height()+"px","opacity":1}]);
				},
			paces:
				{
				smooth: "easeInQuint",
				harsh: "easeInQuint",
				tremor: "easeInQuint",
				bounce: "easeInQuint"
				}
			},

		zigzagWaves:
			{
			run: function()
				{
				methods.animateSlices2.apply(this,[30,40,{"height":"0px","opacity":1},{"height":$(vars.containerSelector).height()+"px","opacity":1}]);
				},
			paces:
				{
				smooth: "easeInBounce",
				harsh: "easeInBounce",
				tremor: "easeInBounce",
				bounce: "easeInBounce"
				}
			},

		zigzagWave:
			{
			run: function()
				{
				methods.animateSlices2.apply(this,[50,70,{"height":"0px","opacity":1},{"height":$(vars.containerSelector).height()+"px","opacity":1}]);
				},
			paces:
				{
				smooth: "easeInOutBack",
				harsh: "easeInOutBack",
				tremor: "easeInOutBack",
				bounce: "easeInOutBack"
				}
			},

		blocksDrop:
			{
			run: function()
				{
				methods.animateSlices2.apply(this,[10,2,{"height":"0px","opacity":0},{"height":$(vars.containerSelector).height()+"px","opacity":1}]);
				},
			paces:
				{
				smooth: "linear",
				harsh: "linear",
				tremor: "linear",
				bounce: "linear",
				}
			},

		blocksStairs:
			{
			run: function()
				{
				methods.animateSlices2.apply(this,[10,6,{"height":"0px","opacity":0},{"height":$(vars.containerSelector).height()+"px","opacity":1}]);
				},
			paces:
				{
				smooth: "linear",
				harsh: "linear",
				tremor: "linear",
				bounce: "linear"
				}
			},

		columns10:
			{
			run: function()
				{
				methods.animateSlices2.apply(this,[10,0.1,{"height":"0px","opacity":1},{"height":$(vars.containerSelector).height()+"px","opacity":1}]);
				},
			paces:
				{
				smooth: "linear",
				harsh: "linear",
				tremor: "linear",
				bounce: "linear"
				}
			},

		columns4:
			{
			run: function()
				{
				methods.animateSlices2.apply(this,[4,0.1,{"height":"0px","opacity":1},{"height":$(vars.containerSelector).height()+"px","opacity":1}]);
				},
			paces:
				{
				smooth: "linear",
				harsh: "linear",
				tremor: "linear",
				bounce: "linear"
				}
			},

		columns3:
			{
			run: function()
				{
				methods.animateSlices2.apply(this,[3,0.1,{"height":"0px","opacity":1},{"height":$(vars.containerSelector).height()+"px","opacity":1}]);
				},
			paces:
				{
				smooth: "linear",
				harsh: "linear",
				tremor: "linear",
				bounce: "linear"
				}
			},

		columns2:
			{
			run: function()
				{
				methods.animateSlices2.apply(this,[2,0.1,{"height":"0px","opacity":1},{"height":$(vars.containerSelector).height()+"px","opacity":1}]);
				},
			paces:
				{
				smooth: "linear",
				harsh: "linear",
				tremor: "linear",
				bounce: "linear"
				}
			},

		curtainsWide:
			{
			run: function()
				{
				methods.animateSlices2.apply(this,[10,100,{"height":$(vars.containerSelector).height()+"px","opacity":0,"width":"0px"},{"width":"sliceWidth","opacity":1}]);
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeOutQuart",
				tremor: "easeInOutBounce",
				bounce: "easeInBounce",
				}
			},

		curtainsThin:
			{
			run: function()
				{
				methods.animateSlices2.apply(this,[20,100,{"height":$(vars.containerSelector).height()+"px","opacity":1,"width":"0px"},{"width":"sliceWidth","opacity":1}]);
				},
			paces:
				{
				smooth: "swing",
				harsh: "easeOutQuart",
				tremor: "easeInOutBounce",
				bounce: "easeInBounce",
				}
			}
		}

		var methods =
		{
			// start of INIT function
			init: function(options)
			{
			//methods.echo.apply(this, ["init started"]);
			vars.containerSelector = this.selector;
			$container = $(vars.containerSelector);
				$.each(options,
					function(key, value)
					{
					//methods.echo.apply(this, ["options."+key+":"+value]);
					}
				);
			settings = $.extend(true,{}, defaults, options);
				if ((settings.width=="") && ($container.width()!=0))
				{
				settings.width = $container.width()+"px";
				}
				if ((settings.height=="") && ($container.height()!=0))
				{
				settings.height = $container.height()+"px";
				}
			settings.oldSlideSelector = settings.slideSelector;
			settings.slideSelector = vars.containerSelector + " " + settings.slideSelector;
			$.each(settings,
				function(key, value)
				{
				//methods.echo.apply(this, ["settings."+key+":"+value]);
				}
			);

				$.each(vars,
					function(key, value)
					{
					//methods.echo.apply(this, ["vars."+key+":"+value]);
					}
			);
				if (settings.minDelayTime=="auto")
				{
				settings.minDelayTime = settings.animationSpeed;
				}
				if ((!settings.randomEffects.length) || (settings.randomEffects.length==0))
				{
				settings.randomEffects = ["none","smooth"];
				}
				if (!settings.slideShowStart)
				{
				vars.slideShowStoped = true;
				}
			$slides = $(settings.slideSelector);
			$slides.css({"position":"absolute","top":"0px","left":"0px"});
			$container.css({"position":"relative","width":settings.width,"height":settings.height,"overflow":"hidden"});

			$outerPrevLink = $(settings.outerPrevLinkSelector);
				if ($outerPrevLink.length)
				{
				$outerPrevLink.unbind("click").click(function(event)
					{
					methods.prevnextClick.apply(this, ["prev"]);
					event.preventDefault();
					});
				}

			$outerNextLink = $(settings.outerNextLinkSelector);
				if ($outerNextLink.length)
				{
				$outerNextLink.unbind("click").click(function(event)
					{
					methods.prevnextClick.apply(this, ["next"]);
					event.preventDefault();
					});
				}

				$(settings.slideSelector).each(function (index, domEle)
				{
				$(this).attr("stvSliderIndex",index);
					if (settings.captionBox)
					{
					$(this).attr("data-stvslider-caption",$(this).attr(settings.captionContentFrom));
						if (settings.removeCaptionAttr)
						{
						$(this).removeAttr(settings.captionContentFrom);
						}
					}

					if ((settings.redirectLink) && ($(this).attr(settings.redirectLinkFrom)!==undefined))
					{
					$(this).attr("data-stvslider-link",$(this).attr(settings.redirectLinkFrom));
						if (settings.removeLinkAttr)
						{
						$(this).removeAttr(settings.redirectLinkFrom);
						}
					}

					if ((settings.redirectLink))
					{
						if ($(this).attr(settings.redirectTargetFrom)!==undefined)
						{
						$(this).attr("data-stvslider-target",$(this).attr(settings.redirectTargetFrom));
						}
						else
						{
						$(this).attr("data-stvslider-target","");
						}

						if (settings.removeLinkAttr)
						{
						$(this).removeAttr(settings.redirectTargetFrom);
						}
					}

					if (!$(this).attr("id"))
					{
					$(this).attr("id", "stvSliderSlide"+index);
					}
				vars.slides[index] = {"id":$(this).attr("id"),"selector":vars.containerSelector + " #"+$(this).attr("id")}; // delete // "originalCss":{width:$(this).css("width"), height:$(this).css("height"), "top":$(this).css("top"),"left":$(this).css("left")}
					if (index == 0)
					{
					$(this).css({"z-index":vars.currentZindex});
					vars.currentSliderIndex = index;
					}
					else
					{
					$(this).css({"z-index":vars.inactiveZindex});
					$(this).css({"display":"none"});
					}
				vars.olderSliderIndex = vars.oldSliderIndex = vars.lastSliderIndex = index;
				});


				$(vars.containerSelector).mouseenter(function ()
					{
					//methods.echo.apply(this, ["mouseenter"]);
						if (!vars.slideShowStoped)
						{
						window.clearTimeout(vars.slideShowTimeout);
						}

						if (settings.captionBoxHide)
						{
						vars.captionBoxVisible = true;
						$("#captionBox:hidden").show("slide",{"direction":"down"},100);
						}
					});
				$(vars.containerSelector).mouseleave(function ()
					{
					//methods.echo.apply(this, ["mouseleave"]);
						if (!vars.slideShowStoped)
						{
						window.clearTimeout(vars.slideShowTimeout);
						methods.slideShowStart.apply(this,[settings.slideShowTime]);
						//vars.mouseOver = false;
						}

						if (settings.captionBoxHide)
						{
						vars.captionBoxVisible = false;
						$("#captionBox").hide("slide",{"direction":"down"},100);
						}
					});

			if (settings.captionBox)
			{
			$(vars.containerSelector).append("<div id=\"captionBox\"><div id=\"captionBoxShadow\">&nbsp;</div></div>");
				if (settings.prevnextButton)
				{
				$("#captionBox").append("<div id=\"prevShadow\">&nbsp;</div><a href=\"#\" id=\"prevButton\">"+settings.prevButtonLabel+"</a><div id=\"nextShadow\">&nbsp;</div><a href=\"#\" id=\"nextButton\">"+settings.nextButtonLabel+"</a>");
				methods.prevnextStyles.apply(this, ["normal","both"]);
				vars.prevnextOriginalStyle = $("#nextButton").attr("style");

				$("#prevButton").click(
					function(event)
					{
					methods.prevnextClick.apply(this, ["prev"]);
					}
				).hover(
					function ()
					{
					methods.prevnextStyles.apply(this, ["active","prev"]);
					},
					function ()
					{
					methods.prevnextStyles.apply(this, ["normal","prev"]);
					}
				);
				$("#nextButton").click(
					function(event)
					{
					methods.prevnextClick.apply(this, ["next"]);
					return false;
					}
				).hover(
					function ()
					{
					methods.prevnextStyles.apply(this, ["active","next"]);
					},
					function ()
					{
					methods.prevnextStyles.apply(this, ["normal","next"]);
					}
				);
				}
			$("#captionBox").append("<div id=\"captionBoxInner\">&nbsp;</div>");
			$("#captionBoxShadow").attr("style",settings.captionBoxShadowCss);
			$("#captionBoxInner").attr("style",settings.captionBoxCss);
				if (settings.prevnextButton)
				{
				prevButtonOuterWidth = $("#prevButton").outerWidth();
				nextButtonOuterWidth = $("#nextButton").outerWidth();
				}
				else
				{
				prevButtonOuterWidth = nextButtonOuterWidth = 0;
				}
			$("#captionBoxInner").css({"display":"block","position":"absolute","z-index":1225,"margin-left":prevButtonOuterWidth+"px","margin-right":nextButtonOuterWidth+"px","width":($(vars.containerSelector).width()-prevButtonOuterWidth-nextButtonOuterWidth)+"px","box-sizing":"border-box","-moz-box-sizing":"border-box","webkit-box-sizing":"border-box"});
			$("#captionBox").css({"display":"block","position":"absolute","bottom":"0px","z-index":1223,"width":$(vars.containerSelector).width()+"px"});
			$("#captionBoxShadow").css({"display":"block","position":"absolute","bottom":"0px","z-index":1010,"width":($(vars.containerSelector).width()-prevButtonOuterWidth-nextButtonOuterWidth)+"px","margin-left":prevButtonOuterWidth+"px","margin-right":nextButtonOuterWidth+"px","box-sizing":"border-box","-moz-box-sizing":"border-box","webkit-box-sizing":"border-box"});
			}

			methods.activateCaptionBoxAndLink.apply(this);

			$(vars.containerSelector).append("<div id=\"slices\"></div>");
			$(vars.containerSelector + " #slices").css({"display":"block","width":settings.width,"height":settings.height,"position":"absolute","top":"0px","left":"0px"});
				if (settings.slideShowStart)
				{
				methods.slideShowStart.apply(this,[settings.slideShowTime]);
				}
			},
			// end of INIT function

			slideShowStart: function(delay)
			{
				if (!vars.slideShowStoped)
				{
				vars.slideShowTimeout=setTimeout(
					function()
					{
						if ((!vars.mouseOver || !settings.slideShowPauseAtHover))
						{
						vars.currentChangeAutomatic = true;
						methods.prevnext.apply(this, ["next"]);
						}
					methods.slideShowStart.apply(this,[settings.slideShowTime+settings.animationSpeed])
					}
				,delay);
				}
			},

			prevnextStyles: function (type, which)
			{
			prevnextButtonHeight = $("#captionBoxShadow").outerHeight()+"px";
				if (which == "both")
				{
				selectorButton = "#prevButton, #nextButton";
				selectorShadow = "#prevShadow, #nextShadow";
				}
				else if (which == "prev")
				{
				selectorButton = "#prevButton";
				selectorShadow = "#prevShadow";
				}
				else if (which == "next")
				{
				selectorButton = "#nextButton";
				selectorShadow = "#nextShadow";
				}

				if (type=="normal")
				{
				$(selectorButton).removeClass().removeAttr("style").addClass(settings.prevnextButtonClass).attr("style",settings.prevnextButtonCss).css({"display":"block","position":"absolute","text-align":"center","text-decoration":"none","height":prevnextButtonHeight,"line-height":prevnextButtonHeight,"z-index":101});
				$(selectorShadow).removeClass().removeAttr("style").addClass(settings.prevnextShadowClass).attr("style",settings.prevnextShadowCss).css({"display":"block","position":"absolute","z-index":100,"height":prevnextButtonHeight});
				}
				else
				{
				$(selectorButton).removeClass().removeAttr("style").addClass(settings.prevnextButtonClass).addClass(settings.prevnextButtonActiveClass).attr("style",settings.prevnextButtonCss + "; " + settings.prevnextButtonActiveCss).css({"display":"block","position":"absolute","text-align":"center","text-decoration":"none","height":prevnextButtonHeight,"line-height":prevnextButtonHeight,"z-index":101});
				$(selectorShadow).removeClass().removeAttr("style").addClass(settings.prevnextShadowClass).addClass(settings.prevnextShadowActiveClass).attr("style",settings.prevnextShadowCss + "; " + settings.prevnextShadowActiveCss).css({"display":"block","position":"absolute","z-index":100,"height":prevnextButtonHeight});
				}

				if ((which == "both") || (which == "prev"))
				{
				$("#prevButton").css({"left":"0px"});
				$("#prevShadow").css({"left":"0px","width":$("#prevButton").outerWidth()+"px"});
				}
				if ((which == "both") || (which == "next"))
				{
				$("#nextButton").css({"right":"0px"});
				$("#nextShadow").css({"right":"0px","width":$("#nextButton").outerWidth()+"px"});
				}
			},

			activateCaptionBoxAndLink: function ()
			{
				if ((settings.redirectLink) && ($(vars.slides[vars.currentSliderIndex].selector).attr("data-stvslider-link")!="") && ($(vars.slides[vars.currentSliderIndex].selector).attr("data-stvslider-link")!==undefined))
				{
					if ($(vars.slides[vars.currentSliderIndex].selector).attr("data-stvslider-target")=="_blank")
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"cursor":"pointer"}).unbind("click").click(
						function()
						{
						window.open($(vars.slides[vars.currentSliderIndex].selector).attr("data-stvslider-link"));
						}
					);
					}
					else
					{
					$(vars.slides[vars.currentSliderIndex].selector).css({"cursor":"pointer"}).unbind("click").click(
						function()
						{
						window.location=$(vars.slides[vars.currentSliderIndex].selector).attr("data-stvslider-link");
						}
					);
					}

				}

			$("#captionBoxShadow, #captionBox").css({"display":"block","box-sizing":"border-box","-moz-box-sizing":"border-box","webkit-box-sizing":"border-box"});
			newCaptionContent = "";
			newCaptionContent = $(vars.slides[vars.currentSliderIndex].selector).attr("data-stvslider-caption");
				if (settings.slideShowButton)
				{
				$("#captionBoxInner").html(newCaptionContent+"<a id=\"slideShowButtonStart\" href=\"#start\">"+settings.slideShowStartButtonLabel+"</a><a id=\"slideShowButtonStop\" href=\"#stop\">"+settings.slideShowStopButtonLabel+"</a>");
				$("#slideShowButtonStart, #slideShowButtonStop").addClass(settings.slideShowButtonClass).attr("style",settings.slideShowButtonCss).css({"display":"block","margin-left":"auto","margin-right":"auto","text-align":"center","margin-top":"10px","box-sizing":"border-box","-moz-box-sizing":"border-box","webkit-box-sizing":"border-box"}); //,"width":($("#captionBoxInner").width())+"px"
				}
				else
				{
				$("#captionBoxInner").html(newCaptionContent);
				}

				if (vars.slideShowStoped)
				{
				$("#slideShowButtonStop").css({"display":"none"});
				}
				else
				{
				$("#slideShowButtonStart").css({"display":"none"});
				}
			$("#slideShowButtonStart").unbind("click").click(
				function(event)
				{
				vars.slideShowStoped = false;
				$("#slideShowButtonStart").css({"display":"none"});
				$("#slideShowButtonStop").css({"display":"block"});
				event.preventDefault();
				}
			);
			$("#slideShowButtonStop").unbind("click").click(
				function(event)
				{
				vars.slideShowStoped = true;
				$("#slideShowButtonStart").css({"display":"block"});
				$("#slideShowButtonStop").css({"display":"none"});
				event.preventDefault();
				}
			);
			$("#prevButton, #nextButton").attr("style",vars.prevnextOriginalStyle);

				if (isInteger(settings.captionBoxHeight))
				{
				$("#prevButton, #nextButton, #prevShadow, #nextShadow, #captionBoxShadow, #captionBox").css({"height":settings.captionBoxHeight+"px"});
				}
				else
				{
					if (settings.prevnextButton)
					{
						if ($("#nextButton").outerHeight()>$("#captionBoxInner").outerHeight())
						{
						$("#captionBoxShadow, #captionBox").css({"height":$("#nextButton").outerHeight()+"px"});
						}
						else
						{
						$("#prevButton, #nextButton, #prevShadow, #nextShadow, #captionBoxShadow, #captionBox").css({"height":$("#captionBoxInner").outerHeight()+"px"});
						}
					}
					else
					{
						if ((newCaptionContent=="") || (newCaptionContent=="&nbsp;"))
						{
						$("#captionBoxShadow, #captionBox").css({"height":"0px"});
						}
						else
						{
						$("#captionBoxShadow, #captionBox").css({"height":$("#captionBoxInner").outerHeight()+"px"});
						}
					}
				}

				if (settings.prevnextButton)
				{
					if (vars.currentDirectionNext)
					{
					methods.prevnextStyles.apply(this, ["normal","prev"]);
					methods.prevnextStyles.apply(this, ["active","next"]);
					}
					else
					{
					methods.prevnextStyles.apply(this, ["active","prev"]);
					methods.prevnextStyles.apply(this, ["normal","next"]);
					}
				}


				if (settings.captionBoxHide && vars.currentChangeAutomatic && !vars.captionBoxVisible)
				{
				$("#captionBox").css({"display":"none"});
				}

			},
			animateSlices2: function(numberOfSlices,sameTime,oldCss,newCss)
			{
			vars.slicesShouldBeFinished = true;
			$(vars.slides[vars.currentSliderIndex].selector).css({"z-index":vars.currentZindex,"display":"none"});
			$(vars.slides[vars.oldSliderIndex].selector).css({"z-index":vars.lastZindex,"display":"block","opacity":1,"overflow":"hidden"});
			$(vars.containerSelector + " #slices").css({"z-index":vars.currentSlicesZindex,"opacity":1}); //0.9

				if (vars.currentDirectionNext)
				{
				startFrom = "right";
				}
				else
				{
				startFrom = "left";
				}

			var sliceDuration = (settings.animationSpeed * sameTime) / (numberOfSlices + sameTime + 1); //1 + (settings.animationSpeed / numberOfSlices) - (1 / sameTime);
			var sliceDelay = sliceDuration / sameTime;
			var widthSoFar = 0;

			slicesHtml = "";
			$slices = $(vars.containerSelector + " #slices");
				for (i=0; i<numberOfSlices; i++)
				{
				slicesHtml += "<div class=\"slice\" id=\"slice"+i+"\"></div>";
				}
			$slices.append(slicesHtml);
			$slicesArray = [];
			src = $(vars.slides[vars.currentSliderIndex].selector).attr("src");
				for (i=0; i<numberOfSlices; i++)
				{
				$slicesArray[i] = $(vars.containerSelector + " #slice"+i);

				sliceWidth = Math.floor(($container.width()-widthSoFar)/(numberOfSlices-i));
					if (newCss.width)
					{
						if (newCss.width=="sliceWidth")
						{
						newCss.width = sliceWidth+"px";
						}
					}
				$slicesArray[i].css({"width":sliceWidth+"px","overflow":"hidden","display":"block","position":"absolute","background-image":"url("+src+")","background-repeat":"no-repeat","background-position":"-"+widthSoFar+"px 0px"}).css(oldCss);

				widthSoFar += sliceWidth;
					if (startFrom=="left")
					{
					$slicesArray[i].css({"left":($container.width()-widthSoFar)+"px"});
					}
					else
					{
					$slicesArray[i].css({"right":($container.width()-widthSoFar)+"px"});
					}
				}

			slicesFinished = 0;

				for (i=0; i<numberOfSlices; i++)
				{
					if (startFrom=="left")
					{
					j = i;
					}
					else
					{
					j = numberOfSlices - i - 1;
					}

					$slicesArray[i].delay(sliceDelay*j).animate(newCss,sliceDuration,effects[currentEffect]["paces"][currentPace],
						function()
						{
						slicesFinished++;
							if ((slicesFinished == numberOfSlices) && (vars.slicesShouldBeFinished))
							{
							vars.slicesShouldBeFinished = false;
							$(vars.slides[vars.currentSliderIndex].selector).show();
								for (k=0; k<numberOfSlices; k++)
								{
								$slicesArray[k].queue("fx", []).stop(true, true);
								}
							$slices.empty().queue("fx", []).stop(true, true).css({"z-index":vars.lastSlicesZindex});
							}
							else
							{
							}
						}
					);
				}
			},

			prevnextClick: function(change)
			{
				if (vars.clickEnabled)
				{
				/*
				vars.clickEnabled = false;
				vars.currentChangeAutomatic = false;
				$(settings.outerNextLinkSelector).delay(settings.minDelayTime).queue(function()
					{
					$(settings.outerNextLinkSelector).dequeue();
					vars.clickEnabled = true;
					});*/
				methods.prevnext.apply(this, [change]);
				}
			},

			prevnext: function(number)
			{
			vars.olderSliderIndex = vars.oldSliderIndex;
			vars.oldSliderIndex = vars.currentSliderIndex;
				if (isUnsignedInteger(number))
				{
				vars.currentSliderIndex = number;
				}
				else if ((number=="-") || (number=="-1") || (number=="prev"))
				{
				vars.currentSliderIndex = vars.currentSliderIndex-1;
				}
				else if ((number=="+") || (number=="+1") || (number=="next"))
				{
				vars.currentSliderIndex = vars.currentSliderIndex+1;
				}

				if (vars.currentSliderIndex < 0)
				{
				vars.currentSliderIndex = vars.lastSliderIndex;
				}
				if (vars.currentSliderIndex > vars.lastSliderIndex)
				{
				vars.currentSliderIndex = 0;
				}

				if (vars.slides.length<3)
				{
				vars.currentDirectionNext = true;
				}
				else if ((vars.oldSliderIndex==0) && (vars.currentSliderIndex==vars.lastSliderIndex))
				{
				vars.currentDirectionNext = false;
				}
				else if ((vars.oldSliderIndex==vars.lastSliderIndex) && (vars.currentSliderIndex==0))
				{
				vars.currentDirectionNext = true;
				}
				else if (vars.oldSliderIndex > vars.currentSliderIndex)
				{
				vars.currentDirectionNext = false;
				}
				else
				{
				vars.currentDirectionNext = true;
				}

			$(settings.slideSelector).not($(vars.slides[vars.currentSliderIndex].selector)).not($(vars.slides[vars.oldSliderIndex].selector)).css({"z-index":vars.inactiveZindex,"display":"none", "opacity":1});
				if (vars.slicesShouldBeFinished)
				{
				vars.slicesShouldBeFinished = false;
				$(vars.slides[vars.oldSliderIndex].selector).show();
				$(vars.containerSelector + " #slices .slice").each(function(){
					$(this).queue("fx", []).stop(true, true);
					});
				$(vars.containerSelector + " #slices").empty().queue("fx", []).stop(true, true).css({"z-index":vars.lastSlicesZindex});
				}
			$(vars.slides[vars.currentSliderIndex].selector).queue("fx", []).stop(true, true);
			$(vars.slides[vars.oldSliderIndex].selector).queue("fx", []).stop(true, true);
			$(vars.slides[vars.olderSliderIndex].selector).queue("fx", []).stop(true, true);
			$("#testCurrentSlider").val("#"+(vars.oldSliderIndex+1)+" -> #"+(vars.currentSliderIndex+1));
			methods.activateCaptionBoxAndLink.apply(this);
			methods.runEffect.apply(this);
			},

			runEffect: function()
			{
			currentEffect = settings.effect;
			currentPace = settings.pace;

				if (settings.effect == "slideshow")
				{
					if (vars.currentDirectionNext)
					{
					vars.slideshowCounter = vars.slideshowCounter+1;
					}
					else
					{
					vars.slideshowCounter = vars.slideshowCounter-1;
					}

					if (vars.slideshowCounter <0)
					{
					vars.slideshowCounter = settings.slideshowEffects.length-1;
					}
					if (vars.slideshowCounter > settings.slideshowEffects.length-1)
					{
					vars.slideshowCounter=0;
					}
				currentEffect = settings.slideshowEffects[vars.slideshowCounter][0];
				currentPace = settings.slideshowEffects[vars.slideshowCounter][1];
				}

				if (currentEffect == "random")
				{
				rnd = Math.floor(Math.random()*settings.randomEffects.length);
				currentEffect = settings.randomEffects[rnd][0];
				//e_cho (currentEffect);
				currentPace = settings.randomEffects[rnd][1];
				}

				if ((currentEffect in effects) && ("run" in effects[currentEffect]))
				{
				return effects[currentEffect]["run"].apply(this);
				}
				else
				{
				currentEffect = "fade";
				return effects[currentEffect]["run"].apply(this);
				}
			}

			/*
			,
			echo: function(str)
			{
				if ($("#echo").length)
				{
				$("#echo").html(str+"\n"+$("#echo").html());
				}
			}*/
		};

		// core-engine, calls the required method
		if ( methods[method] )
		{
		return methods[method].apply( this, Array.prototype.slice.call(arguments, 1));
		}
		else if (typeof method === 'object' || ! method)
		{
		return methods.init.apply(this, arguments);
		}
		else
		{
		$.error('Method ' +  method + ' does not exist on jQuery.stvSlide');
		}
	return this;
	};
})( jQuery );

