/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//
//								Slider jQuery Plugin 2011
//
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//=================================PREDEFINED ANIMATIONS==============================================================
var transitions = new Object();
//=================================FADE IN TRANSITION=========================================================
//
// init position: in place
// init size: all
// different selection pattern
// is hidden at the start true
//
//====================================================================================================================
transitions['tl-br-diagonal-fade'] = { 'init_pos': 'in-place', 
																			 'init_size': 'all',
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'chessboard-topleft-bottomright', 
																			 'is_hidden' : true };
																			 
transitions['br-tl-diagonal-fade'] = { 'init_pos': 'in-place', 
																			 'init_size': 'all', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-bottomright-topleft', 
																			 'is_hidden' : true };
																			 
transitions['bl-tr-diagonal-fade'] = { 'init_pos': 'in-place', 
																			 'init_size': 'all', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-bottomleft-topright', 
																			 'is_hidden' : true };
																			 
transitions['tr-bl-diagonal-fade'] = { 'init_pos': 'in-place', 
																			 'init_size': 'all', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-topright-bottomleft', 
																			 'is_hidden' : true };
																			 
transitions['spiral-in-fade'] = { 		 'init_pos': 'in-place', 
																			 'init_size': 'all', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'spiral-in', 
																			 'is_hidden' : true };
																			 
transitions['spiral-out-fade'] = { 		 'init_pos': 'in-place', 
																			 'init_size': 'all', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'spiral-out', 
																			 'is_hidden' : true };
																			 
transitions['zig-zag-right-fade'] = {  'init_pos': 'in-place', 
																			 'init_size': 'all', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'zig-zag-right', 
																			 'is_hidden' : true };
																			 
transitions['zig-zag-left-fade'] = {   'init_pos': 'in-place', 
																			 'init_size': 'all', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'zig-zag-left', 
																			 'is_hidden' : true };
																			 
transitions['zig-zag-up-fade'] = {     'init_pos': 'in-place', 
																			 'init_size': 'all', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'zig-zag-up', 
																			 'is_hidden' : true };
																			 
transitions['zig-zag-down-fade'] = {   'init_pos': 'in-place', 
																			 'init_size': 'all', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'zig-zag-down', 
																			 'is_hidden' : true };
																			 
transitions['zig-zag-random-fade'] = { 'init_pos': 'in-place', 
																			 'init_size': 'all', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'random', 
																			 'is_hidden' : true };
																			 
//=================================APPEAR TRANSITION=========================================================
//
// init position: in place
// init size: point
// different selection pattern
// is hidden at the start false
//
//====================================================================================================================
transitions['tl-br-diagonal-appear'] = { 'init_pos': 'in-place', 
																				 'init_size': 'point', 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'diagonal-topleft-bottomright', 
																				 'is_hidden' : false };
																				 
transitions['tl-br-chessboard-appear'] = { 'init_pos': 'in-place', 
																				 'init_size': 'point', 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'chessboard-topleft-bottomright', 
																				 'is_hidden' : false };																				 
																			 
transitions['br-tl-diagonal-appear'] = { 'init_pos': 'in-place', 
																			 'init_size': 'point', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-bottomright-topleft', 
																			 'is_hidden' : false };
																			 
transitions['bl-tr-diagonal-appear'] = { 'init_pos': 'in-place', 
																			 'init_size': 'point', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-bottomleft-topright', 
																			 'is_hidden' : false };
																			 
transitions['bl-tr-chessboard-appear'] = { 'init_pos': 'in-place', 
																			 'init_size': 'point', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'chessboard-bottomleft-topright', 
																			 'is_hidden' : false };																			 
																			 
transitions['tr-bl-diagonal-appear'] = { 'init_pos': 'in-place', 
																			 'init_size': 'point', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-topright-bottomleft', 
																			 'is_hidden' : false };
																			 
transitions['spiral-in-appear'] = { 	 'init_pos': 'in-place', 
																			 'init_size': 'point', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'spiral-in', 
																			 'is_hidden' : false };
																			 
transitions['spiral-out-appear'] = { 	 'init_pos': 'in-place', 
																			 'init_size': 'point', 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'spiral-out', 
																			 'is_hidden' : false };
																			 
transitions['zig-zag-right-appear'] = {  'init_pos': 'in-place', 
																				 'init_size': 'point', 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-right', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-left-appear'] = {   'init_pos': 'in-place', 
																				 'init_size': 'point', 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-left', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-up-appear'] = {     'init_pos': 'in-place', 
																				 'init_size': 'point', 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-up', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-down-appear'] = {   'init_pos': 'in-place', 
																				 'init_size': 'point', 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-down', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-random-appear'] = { 'init_pos': 'in-place', 
																				 'init_size': 'point', 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'random', 
																				 'is_hidden' : false };																			 																			 																			 																			 																			 																			 																			 																			 

//=================================APPEAR AND ROTATE TRANSITION=========================================================
//
// init position: in place
// init size: point
// init rotattion: -180 deg
// different selection pattern
// is hidden at the start false
//
//====================================================================================================================
transitions['tl-br-diagonal-appear-rotate'] = { 'init_pos': 'in-place', 
																				 'init_size': 'point',
																				 'init_rotation': -180, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'diagonal-topleft-bottomright', 
																				 'is_hidden' : false };
																			 
transitions['br-tl-diagonal-appear-rotate'] = { 'init_pos': 'in-place', 
																			 'init_size': 'point',
																			 'init_rotation': -180, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-bottomright-topleft', 
																			 'is_hidden' : false };
																			 
transitions['bl-tr-diagonal-appear-rotate'] = { 'init_pos': 'in-place', 
																			 'init_size': 'point',
																			 'init_rotation': -180, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-bottomleft-topright', 
																			 'is_hidden' : false };
																			 
transitions['tr-bl-diagonal-appear-rotate'] = { 'init_pos': 'in-place', 
																			 'init_size': 'point',
																			 'init_rotation': -180, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-topright-bottomleft', 
																			 'is_hidden' : false };
																			 
transitions['spiral-in-appear-rotate'] = { 	 'init_pos': 'in-place', 
																			 'init_size': 'point',
																			 'init_rotation': -180, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'zig-zag-right', 
																			 'is_hidden' : false };
																			 
transitions['spiral-out-appear-rotate'] = {  'init_pos': 'in-place', 
																			   'init_size': 'point',
																			   'init_rotation': -180, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'spiral-out', 
																			 'is_hidden' : false };
																			 
transitions['zig-zag-right-appear-rotate'] = {  'init_pos': 'in-place', 
																				 'init_size': 'point',
																				 'init_rotation': -180, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-right', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-left-appear-rotate'] = {   'init_pos': 'in-place', 
																				 'init_size': 'point',
																				 'init_rotation': -180, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-left', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-up-appear-rotate'] = {     'init_pos': 'in-place', 
																				 'init_size': 'point',
																				 'init_rotation': -180, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-up', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-down-appear-rotate'] = {   'init_pos': 'in-place', 
																				 'init_size': 'point-topleft',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'diagonal-topleft-bottomright', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-random-appear-rotate'] = { 'init_pos': 'spread-center', 
																				 'init_size': 'all',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'random', 
																				 'is_hidden' : true };
//=================================EXPAND TRANSITION=========================================================
//
// init position: in-center
// init size: point
// init rotattion: 0 deg
// different selection pattern
// is hidden at the start false
//
//====================================================================================================================
transitions['tl-br-diagonal-expand'] = { 'init_pos': 'in-center', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'diagonal-topleft-bottomright', 
																				 'is_hidden' : false };
																			 
transitions['br-tl-diagonal-expand'] = { 'init_pos': 'in-center', 
																			 'init_size': 'point',
																			 'init_rotation': 0, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-bottomright-topleft', 
																			 'is_hidden' : false };
																			 
transitions['bl-tr-diagonal-expand'] = { 'init_pos': 'in-center', 
																			 'init_size': 'point',
																			 'init_rotation': 0, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-bottomleft-topright', 
																			 'is_hidden' : false };
																			 
transitions['tr-bl-diagonal-expand'] = { 'init_pos': 'in-center', 
																			 'init_size': 'point',
																			 'init_rotation': 0, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-topright-bottomleft', 
																			 'is_hidden' : false };
																			 
transitions['spiral-in-expand'] = { 	 'init_pos': 'in-center', 
																			 'init_size': 'point',
																			 'init_rotation': 0, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'spiral-in', 
																			 'is_hidden' : false };
																			 
transitions['spiral-out-expand'] = { 		 'init_pos': 'in-center', 
																			   'init_size': 'point',
																			   'init_rotation': 0, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'spiral-out', 
																			 'is_hidden' : false };
																			 
transitions['zig-zag-right-expand'] = {  'init_pos': 'in-center', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-right', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-left-expand'] = {   'init_pos': 'in-center', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-left', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-up-expand'] = {     'init_pos': 'in-center', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-up', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-down-expand'] = {   'init_pos': 'in-center', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'diagonal-topleft-bottomright', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-random-expand'] = { 'init_pos': 'in-center', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'random', 
																				 'is_hidden' : true };
//=================================COLLAPSE TRANSITION=========================================================
//
// init position: spread-center
// init size: point
// init rotattion: 0 deg
// different selection pattern
// is hidden at the start true
//
//====================================================================================================================
transitions['tl-br-diagonal-collapse'] = { 'init_pos': 'spread-center', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'diagonal-topleft-bottomright', 
																				 'is_hidden' : true };
																			 
transitions['br-tl-diagonal-collapse'] = { 'init_pos': 'spread-center', 
																			 'init_size': 'point',
																			 'init_rotation': 0, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-bottomright-topleft', 
																			 'is_hidden' : true };
																			 
transitions['bl-tr-diagonal-collapse'] = { 'init_pos': 'spread-center', 
																			 'init_size': 'point',
																			 'init_rotation': 0, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-bottomleft-topright', 
																			 'is_hidden' : true };
																			 
transitions['tr-bl-diagonal-collapse'] = { 'init_pos': 'spread-center', 
																			 'init_size': 'point',
																			 'init_rotation': 0, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-topright-bottomleft', 
																			 'is_hidden' : true };
																			 
transitions['spiral-in-collapse'] = { 	 'init_pos': 'spread-center', 
																			 'init_size': 'point',
																			 'init_rotation': 0, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'spiral-in', 
																			 'is_hidden' : true };
																			 
transitions['spiral-out-collapse'] = { 	 'init_pos': 'spread-center', 
																			 'init_size': 'point',
																			 'init_rotation': 0, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'spiral-out', 
																			 'is_hidden' : true };
																			 
transitions['zig-zag-right-collapse'] = {'init_pos': 'spread-center', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-right', 
																				 'is_hidden' : true };
																			 
transitions['zig-zag-left-collapse'] = { 'init_pos': 'spread-center', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-left', 
																				 'is_hidden' : true };
																			 
transitions['zig-zag-up-collapse'] = {   'init_pos': 'spread-center', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-up', 
																				 'is_hidden' : true };
																			 
transitions['zig-zag-down-collapse'] = {   'init_pos': 'spread-center', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-down', 
																				 'is_hidden' : true };
																			 
transitions['zig-zag-random-collapse'] = { 'init_pos': 'spread-center', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'random', 
																				 'is_hidden' : true };																				 

transitions['zig-zag-random-collapse2'] = { 'init_pos': 'in-place', 
																				 'init_size': 'flat-top',
																				 'init_rotation': 0,
																				 'easing': 'easeOutBack', 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-down', 
																				 'is_hidden' : true };																				 

//=================================DROP TRANSITION=========================================================
//
// init position: in-line-top
// init size: point
// init rotattion: 0 deg
// different selection pattern
// is hidden at the start false
//
//====================================================================================================================
transitions['left-right-slide'] = { 'init_pos': 'in-line-right', 
																				 'init_size': 'all',
																				 'init_rotation': 0,
																				 'rows': 1,
																				 'columns': 1, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'diagonal-topleft-bottomright', 
																				 'is_hidden' : false };

transitions['tl-br-diagonal-drop'] = { 'init_pos': 'in-line-top', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'diagonal-topleft-bottomright', 
																				 'is_hidden' : false };
																			 
transitions['br-tl-diagonal-drop'] = { 'init_pos': 'in-line-top', 
																			 'init_size': 'point',
																			 'init_rotation': 0, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-bottomright-topleft', 
																			 'is_hidden' : false };
																			 
transitions['bl-tr-diagonal-drop'] = { 'init_pos': 'in-line-top', 
																			 'init_size': 'point',
																			 'init_rotation': 0, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-bottomleft-topright', 
																			 'is_hidden' : false };
																			 
transitions['tr-bl-diagonal-drop'] = { 'init_pos': 'in-line-top', 
																			 'init_size': 'point',
																			 'init_rotation': 0, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'diagonal-topright-bottomleft', 
																			 'is_hidden' : false };
																			 
transitions['spiral-in-drop'] = { 	 'init_pos': 'in-line-top', 
																			 'init_size': 'point',
																			 'init_rotation': 0, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'spiral-in', 
																			 'is_hidden' : false };
																			 
transitions['spiral-out-drop'] = { 	 'init_pos': 'in-line-top', 
																			 'init_size': 'point',
																			 'init_rotation': 0, 
																			 'slice_time_mode' : 'queue', 
																			 'selection_pattern' : 'spiral-out', 
																			 'is_hidden' : false };
																			 
transitions['zig-zag-right-drop'] = {'init_pos': 'in-line-top', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-right', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-left-drop'] = { 'init_pos': 'in-line-top', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-left', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-up-drop'] = {   'init_pos': 'in-line-top', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-up', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-down-drop'] = {   'init_pos': 'in-line-top', 
																				 'init_size': 'point',
																				 'init_rotation': 0, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'zig-zag-down', 
																				 'is_hidden' : false };
																			 
transitions['zig-zag-random-drop'] = { 'init_pos': 'in-line-top', 
																				 'init_size': 'point',
																				 'init_rotation': 0,
																				 'rows': 1, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'random', 
																				 'is_hidden' : true };
//=================================ZIPPER TRANSITION=========================================================
//
// init position: ZIPPER
// init size: all
// init rotattion: 0 deg
// different selection pattern
// is hidden at the start false
//
//====================================================================================================================
transitions['hor-zipper-right'] = { 'init_pos': 'top-bottom-zipper', 
																		'init_size': 'flat-top',
																		'init_rotation': 0, 
																		'slice_time_mode' : 'queue', 
																		'selection_pattern' : 'diagonal-topleft-bottomright',
																		'is_hidden' : false };

transitions['hor-zipper-left'] = { 'init_pos': 'top-bottom-zipper', 
																		'init_size': 'flat-top',
																		'init_rotation': 0, 
																		'slice_time_mode' : 'queue', 
																		'selection_pattern' : 'diagonal-bottomright-topleft',
																		'is_hidden' : false };																			
																			 
transitions['ver-zipper-bottom'] = { 'init_pos': 'left-right-zipper', 
																		 'init_size': 'all',
																		 'init_rotation': 0, 
																		 'slice_time_mode' : 'queue', 
																		 'selection_pattern' : 'diagonal-topleft-bottomright', 
																		 'is_hidden' : false };
																		 
transitions['ver-zipper-top'] = { 'init_pos': 'left-right-zipper', 
																		 'init_size': 'all',
																		 'init_rotation': 0, 
																		 'slice_time_mode' : 'queue', 
																		 'selection_pattern' : 'diagonal-bottomright-topleft', 
																		 'is_hidden' : false };
//=================================CORNER TRANSITION=========================================================
//
// init position: top left corner
// init size: point
// init rotattion: 0 deg
// different selection pattern
// is hidden at the start false
//
//====================================================================================================================
transitions['tl-corner-diagonal'] = { 'init_pos': 'top-left-corner', 
																		'init_size': 'point',
																		'init_rotation': 0, 
																		'slice_time_mode' : 'queue', 
																		'selection_pattern' : 'diagonal-topleft-bottomright',
																		'is_hidden' : false };

transitions['tl-corner-random'] = { 'init_pos': 'top-left-corner', 
																		'init_size': 'point',
																		'init_rotation': 0, 
																		'slice_time_mode' : 'queue', 
																		'selection_pattern' : 'random',
																		'is_hidden' : false };																			
																			 
transitions['tl-corner-spiral'] = { 'init_pos': 'top-left-corner', 
																		 'init_size': 'point',
																		 'init_rotation': 0, 
																		 'slice_time_mode' : 'queue', 
																		 'selection_pattern' : 'spiral-in', 
																		 'is_hidden' : false };
																		 
transitions['tl-corner-zigzagdown'] = { 'init_pos': 'top-left-corner', 
																		 'init_size': 'point',
																		 'init_rotation': 0, 
																		 'slice_time_mode' : 'queue', 
																		 'selection_pattern' : 'zig-zag-down', 
																		 'is_hidden' : false };

transitions['left-right-slide'] = { 'init_pos': 'in-line-right', 
																				 'init_size': 'all',
																				 'init_rotation': 0,
																				 'rows': 1,
																				 'columns': 1, 
																				 'slice_time_mode' : 'queue', 
																				 'selection_pattern' : 'diagonal-topleft-bottomright', 
																				 'is_hidden' : false };
//-----------------------------------API VARS--------------------------------
(function($) {
  id = 0;
jQuery.fn.slider_plugin = function(set) {

	id++;
	
	if (this.length > 1){
      this.each(function() { $(this).slider_plugin(set) });
      return this;
  }
	
	set = $.extend({
				  theme: 'modern',													// theme used for slider classic or modern
				  columns : 4,															// amount of colums
				  rows : 4,															    // amount of rows
				  init_pos: 'in-place',
				  init_size: 'all',
				  dest_pos: 'in-place',											// for future use - DON'T CHANGE
				  dest_size: 'all',													// for future use - DON'T CHANGE
				  easing: null,
					rotate_easing: null,
					opacity_easing: null,
					width_easing: null,
					height_easing: null,
					left_easing: null,
					top_easing: null,
					run_transition_on: 'in',									// for future use - DON'T CHANGE 
				  slice_time_mode: 'queue',
				  selection_pattern: 'diagonal-topleft-bottomright',
				  def_transition: 'tl-corner-random',
				  init_rotation: 0,
				  final_rotation: 0,												// for future use - DON'T CHANGE
				  slide_timeout: 5000,											// how long each slide will be shown
				  slide_animation : 3000,										// how long animation will take
				  show_direction : 'forward',								// show direction forward backward or random 
				  auto_play : true,
				  interactive_while_playing : true,
				  socondary_nav_type: 'thumbs',						// describes how secondary navigation will be shown - possible values 'bullets', 'thumbs', 'none'
				  secondary_nav_pos: 'bottom',		// describes secondary navigation position - possible values 'top', 'bottom', 'left', 'right', -> for 'thumbs' only this options are valid
				  																					// 'bottom-right-hor', 'bottom-left-hor', 'top-right-hor', 'top-left-hor',
				  																					// 'bottom-right-ver', 'bottom-left-ver', 'top-right-ver', 'top-left-ver', -> all options are available for bullets	 
				  secondary_nav_placement: 'inside',
				  pause_on_hover : true,
				  spread_factor : 1.5,
				  auto_hide_primary_nav: true,						// play, pause, next, prev etc
				  auto_hide_primary_nav_delay: 300,
				  auto_hide_primary_time: 1000,
				  
				  auto_hide_secondary_nav: false,					// bullets or thumbs
				  auto_hide_secondary_nav_delay: 1000,
				  auto_hide_secondary_time: 1000,
				  
				  auto_hide_secondary_callback: function(){ this.hide( 'drop', { distance: 50,direction: 'down'}, 300 ); },
				  auto_show_secondary_callback: function(){ this.show( 'drop', { distance: 50,direction: 'up'}, 300 ); },
				  
				  ken_burns_for_thumbs: true,
				  kb_thumbs_zoomfactor: 1.5,
				  kb_thumbs_start_cpoint: [30,70],										// describes where is center of canvas located over image at the beginning of ken burns effect ( units: x,y percents of original image size 0 - 100) 
				  kb_thumbs_start_cpoint_random: true,								// idf true above array is treated like range from where point is randomly picked
				  kb_thumbs_dest_cpoint: [30,70],											// describes where is center of canvas located over image at the end of ken burns effect ( units: x,y percents of original image size 0 - 100) 
				  kb_thumbs_dest_cpoint_random: true,                 // idf true above array is treated like range from where point is randomly picked
				  kb_thumbs_anim_time: 5000,													// animation time described in miliseconds
				  kb_thumbs_play_in_loop: true,												// ken burn effect loop mode: if true effext will be looped when it reaches its end otherwise no
				  
				  thumbs_my_position: 'bottom center',
				  thumbs_at_position: 'top center',
				  thumbs_show_effect: 'drop',
				  thumbs_hide_effect: 'drop',
				  thumb_show_dir: 'up',
				  thumb_hide_dir: 'up',
				  
				  thumb_title_show_callback: function(){ this.show( 'drop', { distance: 20,direction: 'up'}, 300 ); },
				  thumb_title_hide_callback: function(){ this.hide( 'fade', { distance: 20, direction: 'down'}, 500 ); },
				  
				  show_thumb_titles: true,
				  ken_burns_for_slides: true,
				  
				  kb_slides_zoomfactor: 1.5,
				  kb_slides_start_cpoint: [40,60],										// describes where is center of canvas located over image at the beginning of ken burns effect ( units: x,y percents of original image size 0 - 100) 
				  kb_slides_start_cpoint_random: true,								// idf true above array is treated like range from where point is randomly picked
				  kb_slides_dest_cpoint: [40,60],											// describes where is center of canvas located over image at the end of ken burns effect ( units: x,y percents of original image size 0 - 100) 
				  kb_slides_dest_cpoint_random: true,                 // idf true above array is treated like range from where point is randomly picked
				  kb_slides_anim_time: 5000,													// animation time described in miliseconds
				  kb_slides_play_in_loop: true,												// ken burn effect loop mode: if true effext will be looped when it reaches its end otherwise no
				  
				  
				  title_show_callback: function(){ this.show( 'fade', { distance: 20,direction: 'down'}, 500 ); },
				  title_hide_callback: function(){ this.hide( 'fade', { distance: 20, direction: 'down'}, 500 ); },
				  
				  videobutton_show_callback: function(){ this.show( 'fade', { distance: 20,direction: 'left'}, 500 ); },
				  videobutton_hide_callback: function(){ this.hide( 'fade', { distance: 20, direction: 'left'}, 500 ); },
				  
				  show_titles: true,
				  
				  timer_position: 'center',				// describes where circular timer is displayed - 'center', 'top-left', 'top-right', 
				  																// 'bottom-right', 'bottom-left', 'on_current_bullet' or 
				  																// 'line' - simple progress bar displayd at the bottom or top - see css file - all IE are forced to use this 
				  show_timer: true
				},
			set || {});


var $this = this;

return this.each(function() {
//-----------------------------------GLOBAL VARS--------------------------------
//var $this = $(this);

////window.//console.log("$this " + $this.attr('class') );

var rows = set.rows;
var columns = set.columns;
var init_pos = set.init_pos;
var init_size = set.init_size;
var dest_pos = set.dest_pos;
var dest_size = set.dest_size;	
var slide_timeout = set.slide_timeout;
var slide_animation = set.slide_animation;

var init_rotation = set.init_rotation;
var final_rotation = set.final_rotation;
var slice_time_mode = set.slice_time_mode;	// timing used for slices animation: 'regular' - all slices animated in the same time -> slide_animation
																						//																	 'queue' - all slices animated in the same time but fired with small delay:
																						//																	          -> slice_animation_difference 		
																						//																	 'rising'	- the further item is in animation queue the longer
																						//																							it takes to complete this slice niamation
																						//																							-> time = slide_animation + i * slice_animation_difference
																						//																	 'waterfall' - next slide animation starts when previous block is finished
																						//																							 time for one block = slice_animation_difference	
var selection_pattern = set.selection_pattern;
var	def_transition = set.def_transition;
var easing = set.easing;
var rotate_easing = set.rotate_easing;
var opacity_easing = set.opacity_easing;
var width_easing = set.width_easing;
var height_easing = set.height_easing;
var left_easing = set.left_easing;
var top_easing = set.top_easing;
var spread_factor = set.spread_factor;
var is_hidden = true;

var supports_rotate_transform = true;
var pause_on_hover = set.pause_on_hover;
var width = 0;
var height = 0;
var current_slide = 0;
var next_slide = 0;
var slideshow_temp_counter = 0;
var slices_count = 0;
var slices_finished = 0;										// used to count finished slices animation
var slice_animation_difference = 300;
var $slides = $this.children('ul');
var slides_amount = $slides.children('li').size();

var slice_anim_finished_event = 'slice_anim_finished' ;
var is_playing = false;											// variable indicating if slideshow is playing - dont' touch!!!
var slideshow_timer = null;
var is_mouse_inside = false;								//
var is_animating_transition = false; 				// flag indicating if transition is in progress
var theme = set.theme;
var run_transition_on = set.run_transition_on;
var socondary_nav_type = set.socondary_nav_type;				
var	secondary_nav_pos = set.secondary_nav_pos;

var secondary_nav_container = null;
var secondary_nav_wrap = null;
var hor_sec_snap = null;
var ver_sec_snap = null;

var auto_hide_primary_timer = null;
var auto_hide_secondary_timer = null;

var outer_wrap = null;
var circular_timer = null;
var circular_timer_left = null;
var circular_timer_right = null;

var slide_title = null;

var bullet_kenburns_map = new Object();
var slides_ken_burns_map = new Object();

var slide_img_original_sizes = new Object();		// contains all original image sizes which are inside slides - needed for ken burns
var thumbs_img_original_sizes = new Object();   // contains all original image sizes which are inside thumbs - needed for ken burns

var images_to_load = 0;
var video_button = null;
var video_is_playing = false;																		 														 																													 																				 																				 																		 																			 																			 																			 																			 																			 																			 																			 																			 
//=================================FUNCTIONS==========================================================================		                      
		function show_thumb_title( $target ) {
			set.thumb_title_show_callback.call( $target );
		}
		
		function hide_thumb_title( $target ) {
			set.thumb_title_hide_callback.call( $target );
		}
		
		function preload_all_img_and_thumbs() {
			//window.//console.log("preload_all_img_and_thumbs");
			
			if( set.ken_burns_for_slides ) {
					images_to_load += $slides.children('li').find('img.bk_ken_burns_img').size();
					
					$slides.children('li').each( function(){
							$(this).find('img.bk_ken_burns_img').each( function(){
									  var img = new Image();
									  var img_src = $(this).attr('src');
										img.onload = function() {
												images_to_load--;
												var dims = new Object();
												dims['width'] = this.width;
												dims['height'] = this.height;
												slide_img_original_sizes[img_src] = dims; 
												
						  			    //window.//console.log("slide img onload - src: " + img_src + " org_width:" + dims['width'] + " org_height:" + dims['height']);					  
											}
											
										img.onerror = function() {
											images_to_load--;
											//window.//console.log("slide img onerror - src: " + img_src);
										}	
											
										img.src = img_src;
							});	
		 			});
 		  }
 		  
 		  if( set.ken_burns_for_thumbs ) {
					images_to_load += slides_amount;
					
					$slides.children('li').each( function(){
					 
					var thumb_src = $(this).attr("data-thumb"); 
			 	  if( thumb_src != '' && thumb_src != undefined ) {
							var img = new Image();
							var img_src = thumb_src;
							img.onload = function() {
										images_to_load--;
										var dims = new Object();
										dims['width'] = this.width;
										dims['height'] = this.height;
										thumbs_img_original_sizes[img_src] = dims; 
														
								  	//window.//console.log("thumb img onload - src: " + img_src + " org_width:" + dims['width'] + " org_height:" + dims['height']);					  
							}
							
							img.onerror = function() {
											images_to_load--;
											//window.//console.log("slide img onerror - src: " + img_src);
							}
							
							img.src = img_src;
          } else {
          	images_to_load--;
          }	
		 			});
 		  }
 		  
 		  preload_waiter();
		}
		
		function preload_waiter() {
			 if( images_to_load > 0 ) {
			     //window.//console.log("preload_waiter()");
			     setTimeout( arguments.callee, 10 );
			     return;
			 } else {
			 	 init_slider();
			 }	
		}			
		
		function init_slider() {
			 //window.//console.log("init_slider()");
			 width = $this.width();
			 height = $this.height();
			 
			 if( jQuery.browser.msie && ( parseInt(jQuery.browser.version, 10) < 9 ) )
					 supports_rotate_transform = false;
					 
			 if( jQuery.browser.msie )
			     set.timer_position = 'line';		 
					 
			 $this.prepend('<div class="slices-area"></div>');
			 
			 var offset = 0;
			 
			 if( theme == 'classic') {
			   	 $this.addClass('classic-frame');
			   	 $this.append('<div id="prev-button" class="classic-prev"></div>' +
			   	 							'<div id="next-button" class="classic-next"></div>' +
			   	 							'<div id="pp-button" class="classic-pause"></div>');
			   	 							
			   	 offset = -22;														 
			 	 }
			 else if( theme == 'modern' ) {
			 	   $this.addClass('modern-frame');
			   	 $this.append('<div id="prev-button" class="modern-prev"></div>' +
			   	 							'<div id="next-button" class="modern-next"></div>');					
			 	
			 	   offset = 0;
			   }
			 else if( theme == 'coffee') {
			   	 $this.addClass('classic-frame');
			   	 $this.append('<div id="prev-button" class="classic-prev"></div>' +
			   	 							'<div id="next-button" class="classic-next"></div>' +
			   	 							'<div id="pp-button" class="classic-pause"></div>');
			   	 							
			   	 offset = -30;														 
			 	 }  
			   
			 var $prev_button = $this.find('#prev-button');
			 var $next_button = $this.find('#next-button');
			 var $pp_button = $this.find('#pp-button');
			   	 
			 var x = 0;
			 var y = 0;
			   	 
			 y = place_on_center( height, $prev_button.outerHeight(true) );
			 $prev_button.css({ top:  y + 'px', left: offset + 'px' });
			   	 
			 y = place_on_center( height, $next_button.outerHeight(true) );
			 $next_button.css({ top:  y + 'px', right: offset + 'px' });
			   	 
			 y = place_on_center( height, $pp_button.outerHeight(true) );
			 x = place_on_center( width, $pp_button.outerWidth(true) );
			 $pp_button.css({ top:  y + 'px', left: x + 'px' });  		 
			 	 
			 if( socondary_nav_type == 'bullets' ) {
			 	 
			 	 $this.append('<div class="bk-diamond-secondary-nav ' + theme + '"><div class="bk-secondary-nav-wrap"></div></div>');
			 	 secondary_nav_container = $this.find("div.bk-diamond-secondary-nav");
			 	 secondary_nav_wrap = secondary_nav_container.find("div.bk-secondary-nav-wrap");
			 	 
			 	 var size = 0;
			 	 var $target = null;
			 	 for( x = 0; x < slides_amount; x++ ) {
			 	 	secondary_nav_wrap.append('<a class="bk-bullet bk-secondary-nav-item ' + theme + '" rel="' + x + '"></a>');//
			 	 	$target = secondary_nav_wrap.children("a.bk-secondary-nav-item").eq(x);
			 	 	size += $target.outerWidth(true);// - parseInt($target.css("margin-left"));

			 	 	
			 	 	if( secondary_nav_pos == "bottom" || secondary_nav_pos == "bottom-left-hor" || secondary_nav_pos == "bottom-right-hor" ||
			 	 	    secondary_nav_pos == "top" || secondary_nav_pos == "top-left-hor" || secondary_nav_pos == "top-right-hor" ) {
					 	 	var left = $target.outerWidth(true) * x;
					 	 	$target.css({top: '0px', left: left + 'px'});
					 	 	secondary_nav_container.css({ height: $target.outerHeight(true) + 'px' });
			 	  } else if( secondary_nav_pos == "left" || secondary_nav_pos == "top-left-ver" || secondary_nav_pos == "bottom-left-ver" ||
			 	  					 secondary_nav_pos == "right" || secondary_nav_pos == "top-right-ver" || secondary_nav_pos == "bottom-right-ver" ) {
			 	  		var top = $target.outerHeight(true) * x;
					 	 	$target.css({top: top + 'px', left: '0px'});
					 	 	secondary_nav_container.css({ width: $target.outerWidth(true) + 'px' });			 	
			 	  }
			 	 
			 	  var thumb_src = get_slide_option( x, "data-thumb" );
			 	  var content = '<div class="bk-bullet-img-wrap ' + theme + '"><img class="bk-bullet-img" src="' + thumb_src + '" /></div>';
			 	  var title = get_slide_option( x, "data-thumb-title" );
			 	  if( set.show_thumb_titles && title != '' && title != undefined )
			 	 	    content = '<div class="bk-bullet-img-wrap ' + theme + '"><img class="bk-bullet-img" src="' + thumb_src + '" /><div class="bk-thumb-title ' + theme + '">' + title + '</div></div>';
			 	 	
			 	 	var thumbs_my_position = set.thumbs_my_position;
			 	 	var thumbs_at_position = set.thumbs_at_position;
			 	 	
			 	 	var my_position = get_slide_option( x, "data-thumb-my-position" );
			 	 	if( my_position != '' && ( typeof my_position !== "undefined" ) )
			 	 	    thumbs_my_position = my_position;
			 	 	
			 	 	var at_position = get_slide_option( x, "data-thumb-at-position" );
			 	 	if( at_position != '' && ( typeof at_position !== "undefined" ) )
			 	 	    thumbs_at_position = at_position;
			 	 	
			 	 	$target.qtip({
					   content: {
					      text: content
					   },
					   position: {
					      my: thumbs_my_position,  // Position my top left...
					      at: thumbs_at_position  //  at the bottom right of...
					   },
					   style: {
					      classes: 'ui-tooltip ' + theme + ' ui-thumb-shadow bk-thumb-tooltip'
					   },
					   show: {
					      effect: function(offset) {
					         $(this).show( set.thumbs_show_effect, {distance: 20, direction: set.thumb_show_dir}, 300, 
					         
					         function() { 
					         		if( set.show_thumb_titles )
					         			  show_thumb_title( $(this).find('div.bk-thumb-title') );
					         		
					         		if( set.ken_burns_for_thumbs && (typeof bullet_kenburns_map[$(this).attr('id')] === "undefined") ) {
					         				var original_width = thumbs_img_original_sizes[thumb_src].width;
					         				var original_height = thumbs_img_original_sizes[thumb_src].height;
					         				
					         				var kb_thumbs_start_cpoint = set.kb_thumbs_start_cpoint;
												  var kb_thumbs_start_cpoint_random = set.kb_thumbs_start_cpoint_random;
												  var kb_thumbs_dest_cpoint = set.kb_thumbs_dest_cpoint ;
												  var kb_thumbs_dest_cpoint_random = set.kb_thumbs_dest_cpoint_random;
												  var kb_thumbs_anim_time = set.kb_thumbs_anim_time;
												  var kb_thumbs_play_in_loop = set.kb_thumbs_play_in_loop;
												  var kb_thumbs_zoomfactor = set.kb_thumbs_zoomfactor;     
					         				
					         				if( (typeof original_width !== "undefined") && original_width > 0 &&
					         						(typeof original_height !== "undefined") && original_height > 0 ) {
								         			 var ref = $(this).find('img.bk-bullet-img').kenburns_plugin({ zoomfactor: kb_thumbs_zoomfactor,
								         			 																															 hover_mode: 'none', 
								         																																		 flash_at_start: true,
								         																																		 orig_img_width: original_width,
							  																																						 orig_img_height: original_height,
							  																																						 theme: theme + ' thumb',
							  																																						 start_cpoint: kb_thumbs_start_cpoint,
							  																																						 start_cpoint_random: kb_thumbs_start_cpoint_random,
							  																																						 dest_cpoint: kb_thumbs_dest_cpoint,
							  																																						 dest_cpoint_random: kb_thumbs_dest_cpoint_random,
							  																																						 anim_time: kb_thumbs_anim_time,
							  																																						 play_in_loop: kb_thumbs_play_in_loop });
								         			 bullet_kenburns_map[$(this).attr('id')] = ref;
					         			  }
					         	  } else if( set.ken_burns_for_thumbs ) {
					         	  	  //bullet_kenburns_map[$(this).attr('id')].kenburns_plugin.Play();
					         	  }	
					         } 
					         );
					      },
					      solo: false
					   },
					   hide: {
					      effect: function(offset) {
					         //$(this).hide(); // "this" refers to the tooltip		 
					         //bullet_kenburns_map[$(this).attr('id')].kenburns_plugin.Pause();
					         
					         if( set.show_thumb_titles )
					         		 $(this).find('div.bk-thumb-title').hide();		 
					         		 
					         $(this).hide( set.thumbs_hide_effect, {distance: 20, direction: set.thumb_hide_dir}, 1000 );
					      },
					      solo: false
					   }
				 });
				 
			 	 }
			 	 
			 	 hor_sec_snap = secondary_nav_wrap.children("a.bk-secondary-nav-item").outerWidth(true);
			 	 ver_sec_snap	= hor_sec_snap; 
			 	 
			 	 var x = place_on_center( width, size );
			 	 var y = place_on_center( height, size );	
			 	 
			 	 setup_secondary_nav( "a.bk-bullet", x, y, size, size );
			 	 
			 } else if ( socondary_nav_type == 'thumbs' ) {
			 	 $this.append('<div class="bk-diamond-secondary-nav ' + theme + '"><div class="bk-secondary-nav-wrap"></div></div>');
			 	 secondary_nav_container = $this.find("div.bk-diamond-secondary-nav");
			 	 secondary_nav_wrap = secondary_nav_container.find("div.bk-secondary-nav-wrap");
			 	 
			 	 var size_x = 0;
			 	 var size_y = 0;
			 	 var $target = null;
			 	 for( x = 0; x < slides_amount; x++ ) {
			 	 	var thumb_src = get_slide_option( x, "data-thumb" );
			 	 	var content = '<a class="bk-secondary-nav-item ' + theme + '" rel="' + x + '"><div class="bk-thumb-img-frame ui-thumb-shadow ' + theme + '" ><img src="' + thumb_src + '" class="bk-thumb-img" /></div></a>';
			 	  var title = get_slide_option( x, "data-thumb-title" );
			 	  if( set.show_thumb_titles && title != '' && title != undefined ) {
			 	 	    content = '<a class="bk-secondary-nav-item" rel="' + x + '"><div class="bk-thumb-img-frame ui-thumb-shadow ' + theme + '" ><img src="' + thumb_src + '" class="bk-thumb-img" /><div class="bk-thumb-title ' + theme + '">' + title + '</div></div></a>';
			 	 	}    
			 	 	
			 	 	secondary_nav_wrap.append(content);//
			 	 	
			 	 	$target = secondary_nav_wrap.find("div.bk-thumb-img-frame").eq(x);
			 	 	
			 	 	if( secondary_nav_pos == "bottom" || secondary_nav_pos == "bottom-left-hor" || secondary_nav_pos == "bottom-right-hor" ||
			 	 	    secondary_nav_pos == "top" || secondary_nav_pos == "top-left-hor" || secondary_nav_pos == "top-right-hor" ) {
					 	 	var left = $target.outerWidth(true) * x;
					 	 	$target.css({top: '0px', left: left + 'px'});
					 	 	secondary_nav_container.css({ height: $target.outerHeight(true) + 'px' });
			 	  } else if( secondary_nav_pos == "left" || secondary_nav_pos == "top-left-ver" || secondary_nav_pos == "bottom-left-ver" ||
			 	  					 secondary_nav_pos == "right" || secondary_nav_pos == "top-right-ver" || secondary_nav_pos == "bottom-right-ver" ) {
			 	  		var top = $target.outerHeight(true) * x;
					 	 	$target.css({top: top + 'px', left: '0px'});
					 	 	secondary_nav_container.css({ width: $target.outerWidth(true) + 'px' });			 	
			 	  }					 	
			 	 	
			 	 	size_x += $target.outerWidth(true);
			 	 	size_y += $target.outerHeight(true);
			 	 	
				 	 if( set.ken_burns_for_thumbs ) {
				   	   var original_width = thumbs_img_original_sizes[thumb_src].width;
						   var original_height = thumbs_img_original_sizes[thumb_src].height;
						   
						   var kb_thumbs_start_cpoint = set.kb_thumbs_start_cpoint;
							 var kb_thumbs_start_cpoint_random = set.kb_thumbs_start_cpoint_random;
							 var kb_thumbs_dest_cpoint = set.kb_thumbs_dest_cpoint ;
							 var kb_thumbs_dest_cpoint_random = set.kb_thumbs_dest_cpoint_random;
							 var kb_thumbs_anim_time = set.kb_thumbs_anim_time;
						   var kb_thumbs_play_in_loop = set.kb_thumbs_play_in_loop;
							 var kb_thumbs_zoomfactor = set.kb_thumbs_zoomfactor;
						   
						   if( (typeof original_width !== "undefined") && original_width > 0 &&
						       (typeof original_height !== "undefined") && original_height > 0 ) {
									  $target.find('img').kenburns_plugin({ orig_img_width: original_width,
								  																				orig_img_height: original_height,
							  																					theme: theme  + ' thumb',
							  																					start_cpoint: kb_thumbs_start_cpoint,
							  																					start_cpoint_random: kb_thumbs_start_cpoint_random,
							  																					dest_cpoint: kb_thumbs_dest_cpoint,
							  																					dest_cpoint_random: kb_thumbs_dest_cpoint_random,
							  																					anim_time: kb_thumbs_anim_time,
							  																					play_in_loop: kb_thumbs_play_in_loop,
							  																					zoomfactor: kb_thumbs_zoomfactor });
						      }	
				   }
			 	 	
			 	 }
			 	 
			 	 hor_sec_snap = $target.outerWidth(true);
			 	 ver_sec_snap = $target.outerHeight(true);
			 	 
			 	 var x = place_on_center( width, size_x );
			 	 var y = place_on_center( height, size_y );
			 	 
			 	 setup_secondary_nav( "a.bk-secondary-nav-item .bk-thumb-img-frame", x, y, size_x, size_y );  
	 	   }
	 	   
	 	   // timer_position = 'center', 'top-left', 'top-right', 'bottom-right', 'bottom-left', 'on_current_bullet'
	 	   if( set.show_timer ) {
			 	   if( set.timer_position == 'line' ) {
			 	   	   $this.append('<div class="bk-progressbar ' + theme + '">');
			 	   } else { 
					 	   var button = '';
					 	   
					 	   if( theme == 'modern' )
					 	       button = '<div id="pp-button" class="modern-pause"></div>';
					 	   
					 	   $this.append('<div class="bk-circular-timer-outerwrap b-big ' + theme + '"><div class="bk-circular-timer-wrap ' + theme + '"><div class="bk-circular-timer-left ' + theme + '" /><div class="bk-circular-timer-right ' + theme + '" /></div>' + button + '</div>');
					 	   outer_wrap = $this.find('div.bk-circular-timer-outerwrap');
					 	   circular_timer = $this.find('div.bk-circular-timer-wrap');
					 	   circular_timer_left = circular_timer.find('div.bk-circular-timer-left');
							 circular_timer_right = circular_timer.find('div.bk-circular-timer-right');
					 	   
					 	   outer_wrap.css({'width': circular_timer.outerWidth(true) + 'px', 
					 	   								 'height': circular_timer.outerHeight(true) + 'px', 
					 	   								 'position': 'absolute' });
					 	   
					 	   if( set.timer_position == 'top-right' ) {
									 outer_wrap.css({ top: '0px', right: '0px' });
					 	   } else if( set.timer_position == 'top-left' ) {
									 outer_wrap.css({ top: '0px', left: '0px' });
					 	   } else if( set.timer_position == 'bottom-right' ) {
									 outer_wrap.css({ bottom: '0px', right: '0px' });
					 	   } else if( set.timer_position == 'bottom-left' ) {
									 outer_wrap.css({ bottom: '0px', left: '0px' });
					 	   } else if( set.timer_position == 'center' ) {
					 	   	   var y = place_on_center( height, circular_timer.outerHeight(true) );
					   	     var x = place_on_center( width, circular_timer.outerWidth(true) );
									 outer_wrap.css({ top:  y + 'px', left: x + 'px' });
					 	   } else if( set.timer_position == 'on_current_bullet' && socondary_nav_type == 'bullets') {
									 outer_wrap.removeClass('b-big');
									 circular_timer.addClass('b-small');
									 circular_timer_left.addClass('b-small');
							     circular_timer_right.addClass('b-small'); 
									 
									 outer_wrap.css({'width': circular_timer.outerWidth(true) + 'px', 
					 	   								 'height': circular_timer.outerHeight(true) + 'px', 
					 	   								 'position': 'absolute' });
									
									 var bulletwidth = secondary_nav_wrap.children("a.bk-bullet").outerWidth(false);
									 var bulletheight = secondary_nav_wrap.children("a.bk-bullet").outerHeight(false);
		
									 var x = place_on_center( bulletwidth, outer_wrap.outerHeight(true) );
					   	     var y = place_on_center( bulletheight, outer_wrap.outerWidth(true) );
		
									 outer_wrap.css({ top: x + 'px', left: y + 'px' });						 
					 	   } else {
					 	   	   set.timer_position = 'center';
					 	   	   var y = place_on_center( height, circular_timer.outerHeight(true) );
					   	     var x = place_on_center( width, circular_timer.outerWidth(true) );
									 outer_wrap.css({ top:  y + 'px', left: x + 'px' });
					 	   }
					 	   
					 	   if( theme == 'modern' ) {
					 	   	   var $pp_button = $this.find('#pp-button');
									 var x = 0;
									 var y = 0;
									 $pp_button.css({ width: circular_timer.width() + 'px', height: circular_timer.height() + 'px' });  	 
									 y = place_on_center( circular_timer.outerHeight(true), $pp_button.height() );
									 x = place_on_center( circular_timer.outerWidth(true), $pp_button.width() );
									 $pp_button.css({ top:  y + 'px', left: x + 'px'});
									 $pp_button.show();
					 	   }
			 	 }  	
	 	   }	
	 	     
	 	     
	 	    if( !set.auto_hide_primary_nav ) {
					 $prev_button.show();
					 $next_button.show();
					 if( $pp_button )
					     $pp_button.show();
			 }
	 	    
	 	    if( set.socondary_nav_type == 'thumbs' || set.socondary_nav_type == 'bullets' ) { 
			 	    secondary_nav_container.bind('mousewheel', function(event, delta) {
					            if( delta > 0 ) {
					            	secondary_nav_container.find('div.bk-sec-top').trigger('click');
					            	secondary_nav_container.find('div.bk-sec-right').trigger('click');
					            } else if( delta < 0 ) {
					            	secondary_nav_container.find('div.bk-sec-bottom').trigger('click');
					            	secondary_nav_container.find('div.bk-sec-left').trigger('click');
					            }		
					            return false;
					  });
			   }
			   
			   if( set.auto_hide_secondary_nav ) {
			   	   if( set.socondary_nav_type == 'thumbs' || set.socondary_nav_type == 'bullets' ) 		
		 	  		 		 secondary_nav_container.hide();
		 	   }
		 	   
		 	   if( set.show_titles ) {
		 	   	   $this.append('<div class="bk-title"></div>');
		 	   	   slide_title = $this.find('div.bk-title');
		 	   }
		 	   
		 	   $this.append('<div class="bk-pp-video-button ' + theme + ' play"></div>');
			 	 video_button = $this.find('div.bk-pp-video-button');
			 	 
			 	 if( set.secondary_nav_placement == 'outside' && ( secondary_nav_pos == "right" || secondary_nav_pos == "top-right-ver" || secondary_nav_pos == "bottom-right-ver") ) {
			 	      video_button.css({ top:  '-23px', right: '10px' });
			   } else {
			   	    video_button.css({ top:  '10px', right: '-23px' });
			   }	
				    
				 bind_all_events();
				 
				 
				 
				 $slides.fadeIn('fast', function() {
      		  show_slide( current_slide );
						if( set.auto_play ) {
						    //toggle_play();
						    
						    if( set.ken_burns_for_slides && supports_rotate_transform ) {
			 		 					prep_kenburns_for_slide(current_slide);
			 		 					show_slide( current_slide );													
			 					}

						    is_playing = true;
						    setTimeout(function(){time_tick();}, 10);
						}
						
						update_play_icon();    
      	 });    			 
		}
		
		function setup_secondary_nav( item_selector, x, y, size_x, size_y ) {
			   
			   if( set.socondary_nav_type != 'thumbs' && set.socondary_nav_type != 'bullets' )
			       return;
			   
			   if( secondary_nav_pos == "bottom" || secondary_nav_pos == "bottom-left-hor" || secondary_nav_pos == "bottom-right-hor") {
			 	     secondary_nav_wrap.find(item_selector).css({'display': "block", 'float': 'left'});
			 	     
			 	     if ( socondary_nav_type == 'thumbs' )
			 	     			place_bullets_hor(secondary_nav_wrap, x, x);
			 	     else if( socondary_nav_type == 'bullets' )
			 	     	  	place_bullets_hor(secondary_nav_wrap, x, width - size_x);		
			 	     
			 	     if( size_x > width ) {
			 	     	   secondary_nav_wrap.css({width: size_x + "px"});
			   			   add_secondary_hor_buttons();
			   		 }
			   		 
			   		 if( set.secondary_nav_placement == 'outside' )
			 	     		 secondary_nav_container.css({bottom: ( secondary_nav_container.outerHeight() * -1 ) + 'px', left: '0px', width: '100%'});
			 	     else
			 	     	   secondary_nav_container.css({bottom: '0px', left: '0px', width: '100%'});
			 	         		 		 		 
			   } else if( secondary_nav_pos == "top" || secondary_nav_pos == "top-left-hor" || secondary_nav_pos == "top-right-hor") {
			 	     secondary_nav_wrap.find(item_selector).css({'display': "block", 'float': 'left'});
			 	     
			 	     if ( socondary_nav_type == 'thumbs' )
			 	     			place_bullets_hor(secondary_nav_wrap, x, x);
			 	     else if( socondary_nav_type == 'bullets' )
			 	     	  	place_bullets_hor(secondary_nav_wrap, x, width - size_x);	
			 	     
			 	     if( size_x > width ) {
			   				 secondary_nav_wrap.css({width: size_x + "px"});
			   				 add_secondary_hor_buttons()
			   		 }
			   		 
			   		 if( set.secondary_nav_placement == 'outside' )
			 	     		 secondary_nav_container.css({top: ( secondary_nav_container.outerHeight() * -1 ) + 'px', left: '0px', width: '100%'});
			 	     else
			 	     		 secondary_nav_container.css({top: '0px', left: '0px', width: '100%'});	
			 	     
			   } else if( secondary_nav_pos == "left" || secondary_nav_pos == "top-left-ver" || secondary_nav_pos == "bottom-left-ver") {
			 	     secondary_nav_wrap.find(item_selector).css({display: "block"});
			 	     
			 	     if ( socondary_nav_type == 'thumbs' )
			 	     			place_bullets_ver(secondary_nav_wrap, y, y);
			 	     else if( socondary_nav_type == 'bullets' )
			 	     			place_bullets_ver(secondary_nav_wrap, y, height - size_x);
			 	     
			 	     if( size_y > height ) {
			 	     	   secondary_nav_wrap.css({height: size_y + "px"});
			   			   add_secondary_ver_buttons();
			   		 }
			   		 
			   		 if( set.secondary_nav_placement == 'outside' )
			 	     		 secondary_nav_container.css({top: '0px', left: ( secondary_nav_container.outerWidth() * -1 ) + 'px', height: '100%'});
			 	     else
			 	     		 secondary_nav_container.css({top: '0px', left: '0px', height: '100%'});	
			   		 
			   } else if( secondary_nav_pos == "right" || secondary_nav_pos == "top-right-ver" || secondary_nav_pos == "bottom-right-ver") {
			 	     secondary_nav_wrap.find(item_selector).css({display: "block"});
			 	     
			 	     if ( socondary_nav_type == 'thumbs' )
			 	     			place_bullets_ver(secondary_nav_wrap, y, y);
			 	     else if( socondary_nav_type == 'bullets' )
			 	     			place_bullets_ver(secondary_nav_wrap, y, height - size_x);			
			 	     
			 	     if( size_y > height ) {
			 	     	   secondary_nav_wrap.css({height: size_y + "px"});
			   			   add_secondary_ver_buttons();
			   		 }
			   		 
			   		 if( set.secondary_nav_placement == 'outside' )
			 	     		 secondary_nav_container.css({top: '0px', right: ( secondary_nav_container.outerWidth() * -1 ) + 'px', height: '100%'});
			 	     else
			 	     	   secondary_nav_container.css({top: '0px', right: '0px', height: '100%'});	
			   }
		}	
		
		function get_slide_option( index, attr_name ) {
			return $slides.children('li').eq(index).attr(attr_name);
		}	
		
		function add_secondary_hor_buttons() {
			secondary_nav_container.append('<div class="bk-secondary-nav-hor-button bk-sec-nav-button-back bk-sec-left ' + theme + '"></div>');
			secondary_nav_container.find('div.bk-sec-left').css({ left: "0px" });
			secondary_nav_container.append('<div class="bk-secondary-nav-hor-button bk-sec-nav-button-back bk-sec-right ' + theme + '"></div>');
			secondary_nav_container.find('div.bk-sec-right').css({ right: "0px" });
		}
		
		function add_secondary_ver_buttons() {
			secondary_nav_container.append('<div class="bk-secondary-nav-ver-button bk-sec-nav-button-back bk-sec-top ' + theme + '"></div>');
			secondary_nav_container.find('div.bk-sec-top').css({ top: "0px" });
			secondary_nav_container.append('<div class="bk-secondary-nav-ver-button bk-sec-nav-button-back bk-sec-bottom ' + theme + '"></div>');
			secondary_nav_container.find('div.bk-sec-bottom').css({ bottom: "0px" });
		}	
		
		function place_bullets_ver(secondary_nav_wrap, y, z ) {
			if( secondary_nav_pos.indexOf("top") != -1 )
			 	  secondary_nav_wrap.css({ top: "0px" });
			else if( secondary_nav_pos.indexOf("bottom") != -1 )
			 	  secondary_nav_wrap.css({ top: z + "px" });
			else 
			 	  secondary_nav_wrap.css({ top: y + "px" });
		}
		
		function place_bullets_hor(secondary_nav_wrap, x, z ) {
			if( secondary_nav_pos.indexOf("left") != -1 )
			 	  secondary_nav_wrap.css({ left: "0px" });
			else if( secondary_nav_pos.indexOf("right") != -1 )
			 	  secondary_nav_wrap.css({ left: z + "px" });
			else 
			 	  secondary_nav_wrap.css({ left: x + "px" });
		}	
		
		function place_on_center( parent_size, children_size ) {
			return Math.round( ( parent_size - children_size ) / 2 );
		}	
		
		function get_slice_coords( init_pos, init_size, x, y, slice_w, slice_h ) {
			var coords = new Object();
			if( init_pos == 'in-place' && init_size == 'point' )					// point in center of destination cell
			  {
			  	coords['top'] = Math.round( y * slice_h + slice_h / 2 );
			  	coords['left'] = Math.round( x * slice_w + slice_w / 2 );
			  	coords['width'] = 0;
			  	coords['height'] = 0;	
			  	return coords;
			  }
			else if( init_pos == 'in-place' && init_size == 'point-topleft' )					// point in topleft corner of destination cell
			  {
			  	coords['top'] = Math.round( y * slice_h);
			  	coords['left'] = Math.round( x * slice_w);
			  	coords['width'] = 0;
			  	coords['height'] = 0;	
			  	return coords;
			  }  
			else if( init_pos == 'in-place' && init_size == 'point-topright' )					// point in top right corner of destination cell
			  {
			  	coords['top'] = Math.round( y * slice_h);
			  	coords['left'] = Math.round( x * slice_w + slice_w);
			  	coords['width'] = 0;
			  	coords['height'] = 0;	
			  	return coords;
			  }
			else if( init_pos == 'in-place' && init_size == 'point-bottomleft' )					// point in bottom left corner of destination cell
			  {
			  	coords['top'] = Math.round( y * slice_h + slice_h);
			  	coords['left'] = Math.round( x * slice_w);
			  	coords['width'] = 0;
			  	coords['height'] = 0;	
			  	return coords;
			  }
			else if( init_pos == 'in-place' && init_size == 'point-bottomright' )					// point in bottom right of destination cell
			  {
			  	coords['top'] = Math.round( y * slice_h + slice_h);
			  	coords['left'] = Math.round( x * slice_w + slice_w);
			  	coords['width'] = 0;
			  	coords['height'] = 0;	
			  	return coords;
			  }      
			else if( init_pos == 'in-place' && init_size == 'flat-top' )
			  {
			  	coords['top'] = Math.round( y * slice_h );
			  	coords['left'] = Math.round( x * slice_w );
			  	coords['width'] = slice_w;
			  	coords['height'] = 0;
			  	return coords;
			  }
			else if( init_pos == 'in-place' && init_size == 'flat-bottom' )
			  {
			  	coords['top'] = Math.round( y * slice_h ) + slice_h;
			  	coords['left'] = Math.round( x * slice_w );
			  	coords['width'] = slice_w;
			  	coords['height'] = 0;
			  	return coords;
			  }
			else if( init_pos == 'in-place' && init_size == 'flat-left' )
			  {
			  	coords['top'] = Math.round( y * slice_h );
			  	coords['left'] = Math.round( x * slice_w );
			  	coords['width'] = 0;
			  	coords['height'] = slice_h;
			  	return coords;
			  }
			else if( init_pos == 'in-place' && init_size == 'flat-right' )
			  {
			  	coords['top'] = Math.round( y * slice_h );
			  	coords['left'] = Math.round( x * slice_w ) + slice_w;
			  	coords['width'] = 0;
			  	coords['height'] = slice_h;
			  	return coords;
			  }
			else if( init_pos == 'in-place' && init_size == 'flat-center-hor' )
			  {
			  	coords['top'] = Math.round( y * slice_h ) + Math.round( slice_h / 2 );
			  	coords['left'] = Math.round( x * slice_w );
			  	coords['width'] = slice_w;
			  	coords['height'] = 0;
			  	return coords;
			  }
			else if( init_pos == 'in-place' && init_size == 'flat-center-ver' )
			  {
			  	coords['top'] = Math.round( y * slice_h );
			  	coords['left'] = Math.round( x * slice_w ) + Math.round( slice_w / 2 );
			  	coords['width'] = 0;
			  	coords['height'] = slice_h;
			  	return coords;
			  }    
			  
			else if( init_pos == 'in-center' && init_size == 'point' )
			  {
			  	coords['top'] = Math.round( height / 2 );
			  	coords['left'] = Math.round( width / 2 );
			  	coords['width'] = 0;
			  	coords['height'] = 0;
			  	return coords;
			  }
			else if( init_pos == 'in-center' && init_size == 'all' )
			  {
			  	coords['top'] = Math.round( ( height - slice_h ) / 2 );
			  	coords['left'] = Math.round( ( width - slice_w ) / 2 );
			  	coords['width'] = slice_w;
			  	coords['height'] = slice_h;
			  	return coords;
			  }            
			else if( init_pos == 'in-place' )
			  {
			  	coords['top'] = Math.round( y * slice_h );
			  	coords['left'] = Math.round( x * slice_w );
			  }
			else if( init_pos == 'spread-center' && init_size == 'point' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + slice_h / 2 ) * spread_factor - ( height * spread_factor - height ) / 2 );
			  	coords['left'] = Math.round( (x * slice_w + slice_w / 2 ) * spread_factor - ( width * spread_factor - width ) / 2 );
			  	coords['width'] = 0;
			  	coords['height'] = 0;
			  	return coords;
			  }
			else if( init_pos == 'spread-center' && init_size == 'all' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + ( ( slice_h * spread_factor ) - slice_h ) / 2 ) * spread_factor - ( height * spread_factor - height ) / 2 );
			  	coords['left'] = Math.round( (x * slice_w + ( ( slice_w * spread_factor ) - slice_w ) / 2 ) * spread_factor - ( width * spread_factor - width ) / 2 );
			  	coords['width'] = slice_w;
			  	coords['height'] = slice_h;
			  	return coords;
			  } 
			else if( init_pos == 'spread-right-bottom' && init_size == 'point' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + slice_h / 2 ) * spread_factor - ( height * spread_factor - height ) );
			  	coords['left'] = Math.round( (x * slice_w + slice_w / 2 ) * spread_factor - ( width * spread_factor - width ) );
			  	coords['width'] = 0;
			  	coords['height'] = 0;
			  	return coords;
			  }
			else if( init_pos == 'spread-right-bottom' && init_size == 'all' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + ( ( slice_h * spread_factor ) - slice_h ) / 2 ) * spread_factor - ( height * spread_factor - height ) );
			  	coords['left'] = Math.round( (x * slice_w + ( ( slice_w * spread_factor ) - slice_w ) / 2 ) * spread_factor - ( width * spread_factor - width ) );
			  	coords['width'] = slice_w;
			  	coords['height'] = slice_h;
			  	return coords;
			  }
			else if( init_pos == 'spread-right' && init_size == 'point' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + slice_h / 2 ) * spread_factor - ( height * spread_factor - height ) / 2 );
			  	coords['left'] = Math.round( (x * slice_w + slice_w / 2 ) * spread_factor - ( width * spread_factor - width )  );
			  	coords['width'] = 0;
			  	coords['height'] = 0;
			  	return coords;
			  }
			else if( init_pos == 'spread-right' && init_size == 'all' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + ( ( slice_h * spread_factor ) - slice_h ) / 2 ) * spread_factor - ( height * spread_factor - height ) / 2 );
			  	coords['left'] = Math.round( (x * slice_w + ( ( slice_w * spread_factor ) - slice_w ) / 2 ) * spread_factor - ( width * spread_factor - width )  );
			  	coords['width'] = slice_w;
			  	coords['height'] = slice_h;
			  	return coords;
			  }
			else if( init_pos == 'spread-bottom' && init_size == 'point' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + slice_h / 2 ) * spread_factor - ( height * spread_factor - height )  );
			  	coords['left'] = Math.round( (x * slice_w + slice_w / 2 ) * spread_factor - ( width * spread_factor - width ) / 2 );
			  	coords['width'] = 0;
			  	coords['height'] = 0;
			  	return coords;
			  }
			else if( init_pos == 'spread-bottom' && init_size == 'all' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + ( ( slice_h * spread_factor ) - slice_h ) / 2 ) * spread_factor - ( height * spread_factor - height )  );
			  	coords['left'] = Math.round( (x * slice_w + ( ( slice_w * spread_factor ) - slice_w ) / 2 ) * spread_factor - ( width * spread_factor - width ) / 2 );
			  	coords['width'] = slice_w;
			  	coords['height'] = slice_h;
			  	return coords;
			  }
			else if( init_pos == 'spread-top' && init_size == 'point' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + slice_h / 2 ) * spread_factor   );
			  	coords['left'] = Math.round( (x * slice_w + slice_w / 2 ) * spread_factor - ( width * spread_factor - width ) / 2 );
			  	coords['width'] = 0;
			  	coords['height'] = 0;
			  	return coords;
			  }
			else if( init_pos == 'spread-top' && init_size == 'all' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + ( ( slice_h * spread_factor ) - slice_h ) / 2 ) * spread_factor  );
			  	coords['left'] = Math.round( (x * slice_w + ( ( slice_w * spread_factor ) - slice_w ) / 2 ) * spread_factor - ( width * spread_factor - width ) / 2 );
			  	coords['width'] = slice_w;
			  	coords['height'] = slice_h;
			  	return coords;
			  }  
			else if( init_pos == 'spread-left-top' && init_size == 'point' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + slice_h / 2 ) * spread_factor );
			  	coords['left'] = Math.round( (x * slice_w + slice_w / 2 ) * spread_factor );
			  	coords['width'] = 0;
			  	coords['height'] = 0;
			  	return coords;
			  }
			else if( init_pos == 'spread-left-top' && init_size == 'all' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + ( ( slice_h * spread_factor ) - slice_h ) / 2 ) * spread_factor );
			  	coords['left'] = Math.round( (x * slice_w + ( ( slice_w * spread_factor ) - slice_w ) / 2 ) * spread_factor );
			  	coords['width'] = slice_w;
			  	coords['height'] = slice_h;
			  	return coords;
			  }
			else if( init_pos == 'spread-left' && init_size == 'point' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + slice_h / 2 ) * spread_factor - ( height * spread_factor - height ) / 2 );
			  	coords['left'] = Math.round( (x * slice_w + slice_w / 2 ) * spread_factor );
			  	coords['width'] = 0;
			  	coords['height'] = 0;
			  	return coords;
			  }
			else if( init_pos == 'spread-left' && init_size == 'all' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + ( ( slice_h * spread_factor ) - slice_h ) / 2 ) * spread_factor - ( height * spread_factor - height ) / 2 );
			  	coords['left'] = Math.round( (x * slice_w + ( ( slice_w * spread_factor ) - slice_w ) / 2 ) * spread_factor );
			  	coords['width'] = slice_w;
			  	coords['height'] = slice_h;
			  	return coords;
			  }
			else if( init_pos == 'spread-left-bottom' && init_size == 'point' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + slice_h / 2 ) * spread_factor - ( height * spread_factor - height ) );
			  	coords['left'] = Math.round( (x * slice_w + slice_w / 2 ) * spread_factor );
			  	coords['width'] = 0;
			  	coords['height'] = 0;
			  	return coords;
			  }
			else if( init_pos == 'spread-left-bottom' && init_size == 'all' )
			  {
			  	coords['top'] = Math.round( (y * slice_h + ( ( slice_h * spread_factor ) - slice_h ) / 2 ) * spread_factor - ( height * spread_factor - height ) );
			  	coords['left'] = Math.round( (x * slice_w + ( ( slice_w * spread_factor ) - slice_w ) / 2 ) * spread_factor );
			  	coords['width'] = slice_w;
			  	coords['height'] = slice_h;
			  	return coords;
			  }            
			////////////////////////////////////////////////////           
			else if( init_pos == 'in-line-top')
			  {
			  	coords['top'] = -slice_h;
			  	coords['left'] = Math.round( x * slice_w );
			  }
			else if( init_pos == 'in-line-bottom')
			  {
			  	coords['top'] = height;
			  	coords['left'] = Math.round( x * slice_w );
			  }
			else if( init_pos == 'in-line-left')
			  {
			  	coords['top'] = Math.round( y * slice_h );
			  	coords['left'] = -slice_w;
			  }
			else if( init_pos == 'in-line-right')
			  {
			  	coords['top'] = Math.round( y * slice_h );
			  	coords['left'] = width;
			  }
			else if( init_pos == 'top-bottom-zipper' )
			  {
			  	if( x % 2 == 1 )
			  	  coords['top'] = height;
			  	else
			  		coords['top'] = -slice_h;
			  		  
			  	coords['left'] = Math.round( x * slice_w );
			  }
			else if( init_pos == 'left-right-zipper' )
			  {
			  	if( y % 2 == 1 )
			  	  coords['left'] = width;
			  	else
			  		coords['left'] = -slice_w;
			  		  
			  	coords['top'] = Math.round( y * slice_h );
			  } 
			else if( init_pos == 'top-left-corner')
			  {
			  	coords['left'] = -slice_w;
			    coords['top'] = -slice_h;
			  }
			else if( init_pos == 'top-right-corner')
			  {
			  	coords['left'] = width;
			    coords['top'] = -slice_h;
			  }
			else if( init_pos == 'bottom-right-corner' )
			  {
			  	coords['left'] = width;
			    coords['top'] = height;
			  }
			else if( init_pos == 'bottom-left-corner' )
			  {
			  	coords['left'] = -slice_w;
			    coords['top'] = height;
			  }
			  
			if( init_size == 'all' )
			  {
			  	coords['width'] = slice_w;
			  	coords['height'] = slice_h;
			  }
			else if( init_size == 'point' )
				{
			  	coords['width'] = 0;
			  	coords['height'] = 0;
			  }
			else if( init_size == 'flat-top' )
				{
			  	coords['width'] = slice_w;
			  	coords['height'] = 0;
			  }
			else if( init_size == 'flat-bottom' )
				{
			  	coords['width'] = slice_w;
			  	coords['height'] = 0;
			  }
			else if( init_size == 'flat-left' )
				{
			  	coords['width'] = 0;
			  	coords['height'] = slice_h;
			  }
			else if( init_size == 'flat-right' )
				{
			  	coords['width'] = 0;
			  	coords['height'] = slice_h;
			  }          	  
			  
			return coords;                          
		}	
		
		function slice_up_and_prep_slide( index, init_pos, init_size, init_rot, columns_amount, rows_amount, hidden ) {
			 
			 var slice_width = Math.round( width / columns_amount );
			 var slice_height = Math.round( height / rows_amount );
			 
			 var opacity = 1;
			    	
			 if( hidden )
			     opacity = 0;
			     
			 if( !hidden )
			 		 $this.find('.slices-area').css({'overflow' : 'hidden'});
			 else
			 	   $this.find('.slices-area').css({'overflow' : 'visible'});		     

			 for( x = 0; x < columns_amount; x++ )
			    {
			     for( y = 0; y < rows_amount; y++ )
			    	  {
			    	  	var coords = get_slice_coords( init_pos, init_size, x, y, slice_width, slice_height );
			    	  	
			    	  	$this.find('.slices-area').append('<div class="slider-slice" id="slice-' + x + '-' + y + '"><div class="slice-content"></div></div>');
			    	  	var $slice = $this.find('#slice-' + x + '-' + y + '');
			    	  	
			    	  	$slice.css({width: coords['width'] + 'px' , height: coords['height'] + 'px', 
			    	  							left: coords['left'] + 'px', top: coords['top'] + 'px',
			    	  							opacity: opacity });
			    	  							
			    	  	var content = $slides.children('li').eq(index).html();
			    	  	//$(content).remove('div.bk_canvas_underlay');												 
			    	  	
			    	  	$slice.find('.slice-content').css({width: width + 'px' , height: height + 'px', 
			    	  																		 left: -(x * slice_width) + 'px', top:  -(y * slice_height) + 'px' })
			    	  															 .append( content );
			    	  															 
			    	  	$slice.find('.slice-content div.bk_canvas_underlay').remove();														 
			    	  															 
			    	  	if( ( init_rot !== final_rotation ) && supports_rotate_transform )
			    	  	  $slice.rotate( init_rot + 'deg' );														 
			    	  															  							
			    	  	/*
			    	  	if( hidden )
			    	  			$slice.hide();
			    	  	else
			    	  		  $slice.show();
			    	  	*/	  																															
			    	  }	
			    }
			    
			 if( set.ken_burns_for_slides ) {
			 		 prep_kenburns_for_slide(index);													
			 }    
			    
			 //if( hidden )
			 //    $this.find('.slider-slice').hide();
			 //else
			     $this.find('.slider-slice').show();        	
		}
		
		function prep_kenburns_for_slide(index) { // neede to make first slide working for kb		   																				
		     if( run_transition_on == 'in' )  {
				  	 $slides.children('li').eq(index).find('img.bk_ken_burns_img').not('.bk_canvas_underlay img').each(function(i) {
					      
				  					//var ref = prep_kenburns_for_slide(index);
				  					var id = $(this).attr('src') + "_" + i;
							      var shift;
							      var img_src = $(this).attr('src');
							      var original_width = slide_img_original_sizes[img_src].width;
										var original_height = slide_img_original_sizes[img_src].height;
										
							      var kb_slides_start_cpoint = set.kb_slides_start_cpoint;
										var kb_slides_start_cpoint_random = set.kb_slides_start_cpoint_random;
										var kb_slides_dest_cpoint = set.kb_slides_dest_cpoint ;
										var kb_slides_dest_cpoint_random = set.kb_slides_dest_cpoint_random;
										var kb_slides_anim_time = set.kb_slides_anim_time;
										var kb_slides_play_in_loop = set.kb_slides_play_in_loop;
										var kb_slides_zoomfactor = set.kb_slides_zoomfactor;
							      
								    if( (typeof original_width !== "undefined") && original_width > 0 &&
								        (typeof original_height !== "undefined") && original_height > 0 ) {
							      
									      var ref = $(this).kenburns_plugin({ hover_mode: 'none',
								 		 																				orig_img_width: original_width,
								  																					orig_img_height: original_height,
								  																					canvas_width: width,
								  																					canvas_height: height,
								  																					alignment: 'absolute',
								  																					flash_at_start: false,
								  																					run_at_init: false,
									  																				theme: theme,
									  																				start_cpoint: kb_slides_start_cpoint,
									  																				start_cpoint_random: kb_slides_start_cpoint_random,
									  																				dest_cpoint: kb_slides_dest_cpoint,
									  																				dest_cpoint_random: kb_slides_dest_cpoint_random,
									  																				anim_time: kb_slides_anim_time,
									  																				play_in_loop: kb_slides_play_in_loop,
									  																				zoomfactor: kb_slides_zoomfactor });
									  																				
									  		slides_ken_burns_map[id] = ref;
						  			    shift = ref.kenburns_plugin.Current_Shift();
						  			    var p1 = shift['trx'];
						  			    var p2 = shift['try'];
						  			    var s = shift['scale'];
						  			    $this.find('.slices-area img').css({  'width': original_width + 'px', 'height': original_height + 'px',
						  			    																			'-webkit-transform': "translate(" + p1 + "px," + p2 + "px) scale(" + s + ")",
																											     	 	'-ms-transform': "translate(" + p1 + "px," + p2 + "px) scale(" + s + ")",
																											     	 	'-o-transform': "translate(" + p1 + "px," + p2 + "px) scale(" + s + ")",
																											     	 	'-moz-transform': "translate(" + p1 + "px," + p2 + "px) scale(" + s + ")",
																											     	 	'transform': "translate(" + p1 + "px," + p2 + "px) scale(" + s + ")",
																											     	 	'filter': 'progid:DXImageTransform.Microsoft.Matrix(FilterType="nearest neighbor",M11=' + s + ',M12=0,M21=0,M22=' + s + ",Dx=" + p1 + ",Dy=" + p2 + ")",
																											     	 	'-ms-filter': 'progid:DXImageTransform.Microsoft.Matrix(FilterType="nearest neighbor",M11=' + s + ',M12=0,M21=0,M22=' + s + ",Dx=" + p1 + ",Dy=" + p2 + ")", 
																											     	 	'-webkit-transform-origin' : '0px 0px', '-moz-transform-origin' : '0px 0px', '-o-transform-origin' : '0px 0px', 
					 	 																									'-ms-transform-origin' : '0px 0px', 'transform-origin' : '0px 0px' }); 																		
							 		  }																
					 	});
					 	
				}	 	
		}	
		
		function run_animation_on_slices( selection_pattern, init_pos, init_size, init_rot, final_rot, columns_amount, rows_amount, hidden, time_mode,
																			easing, opacity_easing, rotate_easing, left_easing, top_easing, width_easing, height_easing ) {
																				
			  var animation_queue = new Array();
			  
			  var slice_width = Math.round( width / columns_amount );
			  var slice_height = Math.round( height / rows_amount );
			  
			  if( selection_pattern == 'diagonal-topleft-bottomright' || selection_pattern == 'diagonal-bottomright-topleft')
			    {
			    	for( x = 0; x < columns_amount; x++ )
			    			{
						     for( y = 0; y < rows_amount; y++ )
						    	  {
						    	  	var slide = new Object();
						    	  	slide.x = x;
						    	  	slide.y = y;
						    	  	slide.obj = $this.find('#slice-' + x + '-' + y + '');
						    	  	
						    	  	if( selection_pattern == 'diagonal-topleft-bottomright' )
						    	  			animation_queue.push( slide );
						    	  	else if( selection_pattern == 'diagonal-bottomright-topleft' )
						    	  		  animation_queue.unshift( slide );		
						    	  }
						    }	  	
			    }
			  else if( selection_pattern == 'diagonal-bottomleft-topright' || selection_pattern == 'diagonal-topright-bottomleft')
			    {
			    	for( x = columns_amount - 1; x >= 0; x-- )
			    			{
						     for( y = 0; y < rows_amount; y++ )
						    	  {
						    	  	var slide = new Object();
						    	  	slide.x = x;
						    	  	slide.y = y;
						    	  	slide.obj = $this.find('#slice-' + x + '-' + y + '');
						    	  	
						    	  	if( selection_pattern == 'diagonal-topright-bottomleft' )
						    	  			animation_queue.push( slide );
						    	  	else if( selection_pattern == 'diagonal-bottomleft-topright' )
						    	  		  animation_queue.unshift( slide );		
						    	  }
						    }	  	
			    }
			  else if( selection_pattern == 'spiral-in' || selection_pattern == 'spiral-out' )
			    {
			    	var l = 0;
			    	for( i = 0, c = columns_amount - 1, r = rows_amount - 1;  c >= 0 && r >= 0;  i++, c--, r-- ) {  
 
					    // Traversing Forward
					    for( k = i ; k <= c; k++ ) {
					      if( l == rows_amount * columns_amount ) break;
					      var slide = new Object();
						    slide.x = k;
						    slide.y = i;
						    slide.obj = $this.find('#slice-' + k + '-' + i + '');

						    if( selection_pattern == 'spiral-in' )
						    	  animation_queue.push( slide );
						    else if( selection_pattern == 'spiral-out' )
						    	  animation_queue.unshift( slide );
						    l++; 
					    }
					 
					    // Traversing Downward
					    for( k = i + 1; k <= r; k++ ) { 
					      if( l == rows_amount * columns_amount )	break;
					      var slide = new Object();
						    slide.x = c;
						    slide.y = k;
						    slide.obj = $this.find('#slice-' + c + '-' + k + '');

						    if( selection_pattern == 'spiral-in' )
						    	  animation_queue.push( slide );
						    else if( selection_pattern == 'spiral-out' )
						    	  animation_queue.unshift( slide );
						    l++;
					    }
					 
					    // Traversing Backward
					    for( k = c - 1; k >= i; k-- ) { 
					      if( l == rows_amount * columns_amount ) break;
					      var slide = new Object();
						    slide.x = k;
						    slide.y = r;
						    slide.obj = $this.find('#slice-' + k + '-' + r + '');

						    if( selection_pattern == 'spiral-in' )
						    	  animation_queue.push( slide );
						    else if( selection_pattern == 'spiral-out' )
						    	  animation_queue.unshift( slide );
						    l++;
					    }
					 
					    // Traversing Upward
					    for( k = r - 1; k > i; k-- ) {
					      if( l == rows_amount * columns_amount ) break;
					      var slide = new Object();
						    slide.x = i;
						    slide.y = k;
						    slide.obj = $this.find('#slice-' + i + '-' + k + '');

						    if( selection_pattern == 'spiral-in' )
						    	  animation_queue.push( slide );
						    else if( selection_pattern == 'spiral-out' )
						    	  animation_queue.unshift( slide );
						    l++;
					    }
					 
					  }
					}
				else if( selection_pattern == 'zig-zag-right' || selection_pattern == 'zig-zag-left' )
					{
						var forward = true;
						for( x = 0; x < columns_amount; x++ )
			    			{
						     if( forward )
						       {
								     for( y = 0; y < rows_amount; y++ )
								    	  {
								    	  	var slide = new Object();
								    	  	slide.x = x;
								    	  	slide.y = y;
								    	  	slide.obj = $this.find('#slice-' + x + '-' + y + '');
								    	  	
								    	  	if( selection_pattern == 'zig-zag-right' )
								    	  			animation_queue.push( slide );
								    	  	else if( selection_pattern == 'zig-zag-left' )
								    	  		  animation_queue.unshift( slide );		
								    	  }
								    	  forward = false;
								    }
								  else
								  	{
								  		for( y = rows_amount - 1; y >= 0; y-- )
								    	  {
								    	  	var slide = new Object();
								    	  	slide.x = x;
								    	  	slide.y = y;
								    	  	slide.obj = $this.find('#slice-' + x + '-' + y + '');
								    	  	
								    	  	if( selection_pattern == 'zig-zag-right' )
								    	  			animation_queue.push( slide );
								    	  	else if( selection_pattern == 'zig-zag-left' )
								    	  		  animation_queue.unshift( slide );		
								    	  }
								    	  forward = true;
								  	}	  	  
						    }	
					}
				else if( selection_pattern == 'zig-zag-down' || selection_pattern == 'zig-zag-up' )
					{
						var forward = true;
						for( y = 0; y < rows_amount; y++ )
			    			{
						     if( forward )
						       {
								     for( x = 0; x < columns_amount; x++ )
								    	  {
								    	  	var slide = new Object();
								    	  	slide.x = x;
								    	  	slide.y = y;
								    	  	slide.obj = $this.find('#slice-' + x + '-' + y + '');
								    	  	
								    	  	if( selection_pattern == 'zig-zag-down' )
								    	  			animation_queue.push( slide );
								    	  	else if( selection_pattern == 'zig-zag-up' )
								    	  		  animation_queue.unshift( slide );		
								    	  }
								    	  forward = false;
								    }
								  else
								  	{
								  		for( x = columns_amount - 1; x >= 0; x-- )
								    	  {
								    	  	var slide = new Object();
								    	  	slide.x = x;
								    	  	slide.y = y;
								    	  	slide.obj = $this.find('#slice-' + x + '-' + y + '');
								    	  	
								    	  	if( selection_pattern == 'zig-zag-down' )
								    	  			animation_queue.push( slide );
								    	  	else if( selection_pattern == 'zig-zag-up' )
								    	  		  animation_queue.unshift( slide );		
								    	  }
								    	  forward = true;
								  	}	  	  
						    }	
					}
				else if( selection_pattern == 'chessboard-topleft-bottomright' || selection_pattern == 'chessboard-bottomright-topleft')
			    {
			    	var temp_animation_queue_1 = new Array();
			    	var temp_animation_queue_2 = new Array();
			    	for( x = 0; x < columns_amount; x++ )
			    			{
						     for( y = 0; y < rows_amount; y++ )
						    	  {
						    	  	var slide = new Object();
						    	  	slide.x = x;
						    	  	slide.y = y;
						    	  	slide.obj = $this.find('#slice-' + x + '-' + y + '');
						    	  	
						    	  	var even_column = true;
						    	  	if( x % 2 == 1 )
						    	  		  even_column = false;
						    	  		  
						    	  	var even_row = true;
						    	  	if( y % 2 == 1 )
						    	  		  even_row = false;	  
						    	  	
						    	  	if( selection_pattern == 'chessboard-topleft-bottomright' )
						    	  	  {
						    	  			if( ( even_column && even_row ) || ( !even_column && !even_row ) )
						    	  					 temp_animation_queue_1.push( slide );
						    	  			else
						    	  				   temp_animation_queue_2.push( slide );
						    	  		}	
						    	  	else if( selection_pattern == 'chessboard-bottomright-topleft' )
						    	  		{
						    	  		  if( ( even_column && even_row ) || ( !even_column && !even_row ) )
						    	  					 temp_animation_queue_1.unshift( slide );
						    	  			else
						    	  				   temp_animation_queue_2.unshift( slide );
						    	  		}  		
						    	  }
						    }
						 animation_queue = animation_queue.concat( temp_animation_queue_1, temp_animation_queue_2 );
						    	  	
			    }
			   else if( selection_pattern == 'chessboard-bottomleft-topright' || selection_pattern == 'chessboard-topright-bottomleft')
			    {
			    	var temp_animation_queue_1 = new Array();
			    	var temp_animation_queue_2 = new Array();
			    	for( x = 0; x < columns_amount; x++ )
			    			{
						     for( y = rows_amount - 1; y >= 0; y-- )
						    	  {
						    	  	var slide = new Object();
						    	  	slide.x = x;
						    	  	slide.y = y;
						    	  	slide.obj = $this.find('#slice-' + x + '-' + y + '');
						    	  	
						    	  	var even_column = true;
						    	  	if( x % 2 == 1 )
						    	  		  even_column = false;
						    	  		  
						    	  	var even_row = true;
						    	  	if( y % 2 == 1 )
						    	  		  even_row = false;	  
						    	  	
						    	  	if( selection_pattern == 'chessboard-bottomleft-topright' )
						    	  	  {
						    	  			if( ( even_column && even_row ) || ( !even_column && !even_row ) )
						    	  					 temp_animation_queue_1.push( slide );
						    	  			else
						    	  				   temp_animation_queue_2.push( slide );
						    	  		}	
						    	  	else if( selection_pattern == 'chessboard-topright-bottomleft' )
						    	  		{
						    	  		  if( ( even_column && even_row ) || ( !even_column && !even_row ) )
						    	  					 temp_animation_queue_1.unshift( slide );
						    	  			else
						    	  				   temp_animation_queue_2.unshift( slide );
						    	  		}  		
						    	  }
						    }
						animation_queue = animation_queue.concat( temp_animation_queue_2, temp_animation_queue_1 );     	
			    }  	
				else if( selection_pattern == 'random' )
					{
						 var temp_queue = new Array();
						 
						 for( x = 0; x < columns_amount; x++ )
			    			{
						     for( y = 0; y < rows_amount; y++ )
						    	  {
						    	  	var slide = new Object();
						    	  	slide.x = x;
						    	  	slide.y = y;
						    	  	slide.obj = $this.find('#slice-' + x + '-' + y + '');
						    	  	
						    	  	temp_queue.push( slide );
						    	  }
						    }
						 var index = 0;   
						 while( temp_queue.length )
						    {
						    	index = Math.floor( Math.random() * ( temp_queue.length - 1 ) );
						    	animation_queue.push( temp_queue[index] );
						    	temp_queue.splice(index,1)
						    }	  
					}					
					  	  	      
			  
			  var opacity = 1;
			    	
			  if( hidden )
			    	opacity = 0;
			  
			  var time = slide_animation;
			  var after = 0;
			  
			  if( time_mode == 'rising' )
			    {
			    	time = slide_animation / slices_count;
			    	slice_animation_difference = time; 
			    }
			  else if( time_mode == 'queue' )
			  	{
			  		time = slide_animation / 2;
			  		slice_animation_difference = time / slices_count;
			  	}	  
			  else if( time_mode == 'waterfall' )
			  	{
			    	time = slide_animation / slices_count;
			    	slice_animation_difference = time; 
			  	}	
			  
			  for( i = 0; i < animation_queue.length; i++ )
			    {
			    	var slide = animation_queue[i];
			    	     
			    	if( time_mode == 'rising' )
			    	    time += slice_animation_difference;
			    	    
			    	if( time_mode == 'waterfall' )
						    after = i * slice_animation_difference;
						    
						if( time_mode == 'queue' )
						    after = i * slice_animation_difference;           
			    	
			    	var coords = get_slice_coords( init_pos, init_size, slide.x, slide.y, slice_width, slice_height );
			    	
			    	slide.obj.delay(after).animate(  { width: coords['width'] + 'px' , 
										    											 height: coords['height'] + 'px', 
										    	  									 left: coords['left'] + 'px', 
										    	  									 top: coords['top'] + 'px',
										    	  									 opacity: opacity,
										    	  									 rotate: final_rot + 'deg' }, 
										    	  								 { duration : time,
										    	  								 	 easing: easing,
										    	  								 	 
										    	  								 	 specialEasing: {
																						      opacity: opacity_easing,
																						      rotate: rotate_easing,
																						      left: left_easing,
																						      top: top_easing,
																						      width: width_easing,
																						      height: height_easing
																						    },
																						    
							  															 complete: function() {
							   																	$this.trigger( slice_anim_finished_event );
							  																} 			 
							  														 } 
							  													 );	  													 	  													 	  													 										 								 								 								  													
			    }	  	
		}	
		
		function prepare_and_launch_animation( index ) {		  
			   
			   if( video_is_playing )
			       remove_video();	
			   
			   if( set.ken_burns_for_slides )
			  		 stop_all_ken_burns(); 
			   
			   slideshow_temp_counter = 0;
			   
				 update_circular_timer();
				 
				 hide_title_for_current_slide();
				 
				 hide_video_button();
			   
			   var transition = new Object();
			   transition['rows'] = rows;
				 transition['columns'] = columns;
				 transition['init_pos'] = init_pos;
				 transition['init_size'] = init_size;
				 transition['dest_pos'] = dest_pos;
				 transition['dest_size'] = dest_size;	
				 transition['slide_timeout'] = slide_timeout;
				 transition['slide_animation'] = slide_animation;
				 transition['init_rotation'] = init_rotation;
				 transition['final_rotation'] = final_rotation;
				 transition['slice_time_mode'] = slice_time_mode;	
				 transition['selection_pattern']= selection_pattern;
				 transition['transition']= transition;
				 transition['easing'] = easing;
				 transition['rotate_easing'] = rotate_easing;
				 transition['opacity_easing'] = opacity_easing;
				 transition['width_easing'] = width_easing;
				 transition['height_easing'] = height_easing;
				 transition['left_easing'] = left_easing;
				 transition['top_easing'] = top_easing;
				 transition['spread_factor'] = spread_factor;
				 transition['is_hidden'] = is_hidden;
				 
			   var default_transition = def_transition;
			   
			   var option = get_slide_option( index, "data-def_transition" );
				 if( option != '' && typeof option !== "undefined" ) {
					   	   default_transition = option;
				 }
			   
			   jQuery.extend( transition, transitions[default_transition] );
			 	 
			 	 for(var key in transition) {
					   var option_key = "data-" + key;
					   var option = get_slide_option( index, option_key );
					   
					   ////window.//console.log("search for: " + option_key + " index:" + index);
					   
					   if( option != '' && typeof option !== "undefined" ) {
					   	   transition[key] = option;
					   	   ////window.//console.log("option_key: " + option);
					   }	 
				 }
			   
			   slices_count = transition['columns'] * transition['rows'];
			   slices_finished = 0;
			   
			   var is_hidden_begin = false;
			   var is_hidden_end = false;
			   
			   if( run_transition_on == 'in' )
			     {
						is_hidden_begin = transition['is_hidden'];
						is_hidden_end = false;
					 }	
				 else if( run_transition_on == 'out' )
				 	 {
					  is_hidden_begin = false;
						is_hidden_end = transition['is_hidden'];
					 } 
			  
			   slice_up_and_prep_slide( index, transition['init_pos'], transition['init_size'], transition['init_rotation'], transition['columns'], transition['rows'], is_hidden_begin );
			   run_animation_on_slices( transition['selection_pattern'], transition['dest_pos'], transition['dest_size'], transition['init_rotation'], transition['final_rotation'], 
			  												  transition['columns'], transition['rows'], is_hidden_end, transition['slice_time_mode'], transition['easing'], transition['opacity_easing'], 
			  												  transition['rotate_easing'], transition['left_easing'], transition['top_easing'], transition['width_easing'], transition['height_easing'] );
		}	
		
		function progress_finished() {
			  stop_progress();
			  slideshow_temp_counter = 0;
			  if( set.show_direction == 'forward' ) {
			      go_to_next_slide();
			  }
			  else if( set.show_direction == 'backward' ) {
			  	  go_to_prev_slide();
			  }
			  else if( set.show_direction == 'random' ) {
			  	  var index = Math.floor( Math.random() * ( slides_amount - 1 ) );
			  	  while( index == current_slide ) {
			  	  	  index = Math.floor( Math.random() * ( slides_amount - 1 ) ); 
			  	  }				  	    
			  	  go_to_slide_number( index );
			  }	   	  	
		}
		
		function go_to_next_slide() {
			  is_animating_transition = true;
			  get_next_slide_index();
			  if( run_transition_on == 'in' )
						prepare_and_launch_animation( next_slide );
				else if( run_transition_on == 'out' )
					{ 
					  show_slide_internal( next_slide, true );
					  prepare_and_launch_animation( current_slide );
					}  		
		}
		
		function go_to_prev_slide() {
			  is_animating_transition = true;
			  get_prev_slide_index();
				if( run_transition_on == 'in' )
						prepare_and_launch_animation( next_slide );
				else if( run_transition_on == 'out' )
					{ 
					  show_slide_internal( next_slide, true );
					  prepare_and_launch_animation( current_slide );
					}	
		}
		
		function go_to_slide_number( index ) {
				if( index < 0 || index > slides_amount - 1 )
				    return;
				    
				is_animating_transition = true;
				next_slide = index;
				if( run_transition_on == 'in' )
						prepare_and_launch_animation( next_slide );
				else if( run_transition_on == 'out' )
					{ 
					  show_slide_internal( next_slide, true );
					  prepare_and_launch_animation( current_slide );
					}   
		}		
		
		function time_tick() {
			  slideshow_temp_counter += 10;
			  //jQuery('#log').text(  'time: ' + slideshow_temp_counter );
			  if( slideshow_temp_counter >= slide_timeout ) {
			      is_animating_transition = true;
			      progress_finished();
			      if( set.show_timer && circular_timer )
			          circular_timer.hide();
			  } else {   
			      update_circular_timer();
			      slideshow_timer = setTimeout(function(){time_tick();}, 10); 
			  }     
		}
		
		function update_circular_timer() {
			  if( set.show_timer ) {
			 	   
						var progress = ( slideshow_temp_counter * 100 ) / slide_timeout;
						
					  if( set.timer_position == 'line' ) {
			 	   	   var prog_width = width * progress / 100;
			 	   	   $this.find('div.bk-progressbar').css({width: prog_width + 'px'});
			 	   	   return;
			 	   	}   
						
						
						var angle = progress * 360 / 100;
						var size = circular_timer.width();
						var half_size = size / 2;
						
						if( progress < 50 ) {  // left side rotate
							circular_timer.css({ 'clip' : 'rect(0px,'+ size +'px,'+ size +'px,'+ half_size +'px)' });
							circular_timer_left.css({
									'transform': 'rotate('+ angle +'deg)',
									'-ms-transform': 'rotate('+ angle +'deg)', /* IE 9 */
									'-webkit-transform': 'rotate('+ angle +'deg)', /* Safari and Chrome */
									'-o-transform': 'rotate('+ angle +'deg)', /* Opera */
									'-moz-transform': 'rotate('+ angle +'deg)' /* Firefox */
						  });
						  
						  if( !supports_rotate_transform ) {
							  var cos = Math.cos(Math.PI * 2 / 360 * angle);
								var sin = Math.sin(Math.PI * 2 / 360 * angle);
	
								circular_timer_left.css("filter","progid:DXImageTransform.Microsoft.Matrix(M11="+cos+",M12=-"+sin+",M21="+sin+",M22="+cos+",SizingMethod='auto expand',FilterType='nearest neighbor')");
								circular_timer_left.css("left",-Math.floor((circular_timer_left.width() - size)/2));
								circular_timer_left.css("top",-Math.floor((circular_timer_left.height() - size)/2));
						  }
							circular_timer_right.hide();
							circular_timer_left.show();
							//circular_timer.show();
						} else if( progress < 100 ) { // left side rotated - rotate right part
							circular_timer.css({ 'clip' : 'rect(0px,'+ size +'px,'+ size +'px,0px)' });
							angle -= 180;
							circular_timer_right.css({
									'transform': 'rotate('+ angle +'deg)',
									'-ms-transform': 'rotate('+ angle +'deg)', /* IE 9 */
									'-webkit-transform': 'rotate('+ angle +'deg)', /* Safari and Chrome */
									'-o-transform': 'rotate('+ angle +'deg)', /* Opera */
									'-moz-transform': 'rotate('+ angle +'deg)' /* Firefox */
						  });
						  
						  if( !supports_rotate_transform ) {
							  var cos = Math.cos(Math.PI * 2 / 360 * angle);
								var sin = Math.sin(Math.PI * 2 / 360 * angle);
	
								circular_timer_right.css("filter","progid:DXImageTransform.Microsoft.Matrix(M11="+cos+",M12=-"+sin+",M21="+sin+",M22="+cos+",SizingMethod='auto expand',FilterType='nearest neighbor')");
								circular_timer_right.css("left",-Math.floor((circular_timer_right.width() - size)/2));
								circular_timer_right.css("top",-Math.floor((circular_timer_right.height() - size)/2));
						  }
							circular_timer_right.show();
							//circular_timer.show();
						}
						
								
	 	   }	
		}	
		
		function stop_progress() {
				clearTimeout(slideshow_timer);	
		}
		
		function freeze_progress() {
			  clearTimeout(slideshow_timer);
		}
		
		function update_play_icon() {
			  if( !is_playing )
				  {
				   if( theme == 'classic' )
				   		 $this.find('#pp-button').removeClass("classic-pause").addClass("classic-play");
				   else if( theme == 'modern' )
				   	   $this.find('#pp-button').removeClass("modern-pause").addClass("modern-play");		
				  } 
			  else
					{
					 if( theme == 'classic' )
					 		 $this.find('#pp-button').removeClass("classic-play").addClass("classic-pause");
					 else if( theme == 'modern' )
					 	   $this.find('#pp-button').removeClass("modern-play").addClass("modern-pause");		 
					} 
		}
		
		function toggle_play() {
			  is_playing = !is_playing;  
			  update_play_icon();
			  if( is_playing )
			    {
			    	progress_finished();
			    }
			  else
			  	{
			  		stop_progress();
			  	}	  	
		}
		
		function launch_progress() {			  
			  var rest_of_time = slide_timeout - slideshow_temp_counter;
				slideshow_timer = setTimeout(function(){time_tick();}, 10);							        					  
		}
		
		function show_slide_internal( index, initial ) {	// if initial == true this function was called for run on out during prerender
			  if( index < 0 || index > slides_amount - 1 )
			  		index = 0;
			  
			  if( socondary_nav_type != 'none' ) {
			  	  secondary_nav_wrap.find("a.bk-secondary-nav-item").removeClass("active");
			  	  secondary_nav_wrap.find("a.bk-secondary-nav-item").eq(index).addClass("active");
			  	  
			  	  
			  	  if( set.timer_position == 'on_current_bullet' && socondary_nav_type == 'bullets') {
			  	  	  
			  	  	  var $target = secondary_nav_wrap.find("a.bk-secondary-nav-item").eq(index);
			  	  	  
			  	  	  $target.append( outer_wrap );
			  	  	  outer_wrap = $target.find('div.bk-circular-timer-outerwrap');
			  	  	  circular_timer = $target.find('div.bk-circular-timer-wrap');
			 	        circular_timer_left = circular_timer.find('div.bk-circular-timer-left');
					      circular_timer_right = circular_timer.find('div.bk-circular-timer-right');
					      
					      if( current_slide != -1 )
					          secondary_nav_wrap.find("a.bk-secondary-nav-item").eq(current_slide).remove('div.bk-circular-timer-outerwrap');
					          
			  	  }		
			  }
			  
			  if( set.ken_burns_for_slides ) {
				  	 $slides.children('li').eq(index).find('img.bk_ken_burns_img').not('.bk_canvas_underlay img').each(function(i) {
					      var id = $(this).attr('src') + "_" + i;
					      var img_src = $(this).attr('src');
					      var original_width = slide_img_original_sizes[img_src].width;
								var original_height = slide_img_original_sizes[img_src].height;
					      
					      
					      if( run_transition_on == 'in' ) {
				  				  var ref = slides_ken_burns_map[id];
					  				if( typeof ref !== "undefined") {  
					  				  shift = ref.kenburns_plugin.Current_Shift();
					  			    var p1 = shift['trx'];
					  			    var p2 = shift['try'];
					  			    var s = shift['scale'];
					  			    $(this).css({  'width': original_width + 'px', 'height': original_height + 'px',
					  			    							 '-webkit-transform': "translate(" + p1 + "px," + p2 + "px) scale(" + s + ")",
																		 '-ms-transform': "translate(" + p1 + "px," + p2 + "px) scale(" + s + ")",
																		 '-o-transform': "translate(" + p1 + "px," + p2 + "px) scale(" + s + ")",
																		 '-moz-transform': "translate(" + p1 + "px," + p2 + "px) scale(" + s + ")",
																		 'transform': "translate(" + p1 + "px," + p2 + "px) scale(" + s + ")", 
																		 '-webkit-transform-origin' : '0px 0px', '-moz-transform-origin' : '0px 0px', '-o-transform-origin' : '0px 0px', 
				 	 													 '-ms-transform-origin' : '0px 0px', 'transform-origin' : '0px 0px' });
					  			    
					  				  ref.kenburns_plugin.Start();
					  				  //ref.kenburns_plugin.Play();
					  				  //window.//console.log("Play - " + i + ":  " + id );
					  			}	  	  
				  			}																								      
					   });															
			  }
			  
			  $slides.children('li').eq(index).show();
			  $slides.children('li').not(':eq(' + index + ')').hide();
			  
			  remove_all_ken_burns_except(index);
				
				//window.//console.log("initial: " + initial + "index: " + index + " current_slide: " + current_slide );
				
				var video_link = get_slide_option( index, 'data-video-link' );
				if( video_link != '' && ( typeof video_link !== "undefined" ) ) {
					  set.videobutton_show_callback.call( video_button );
				}   	
			  
			  return index;
		}
		
		function stop_all_ken_burns() {
			  for( index = 0; index < slides_amount; index++ ) {
			  
					  $slides.children('li').eq(index).find('img.bk_ken_burns_img').not('.bk_canvas_underlay img').each(function(i) { 
					  	var id = $(this).attr('src') + "_" + i;
					  	
					  	if( typeof slides_ken_burns_map[id] !== "undefined") {
					  		 slides_ken_burns_map[id].kenburns_plugin.Pause();
					  		 ////window.//console.log("Pause: " + id);
					  		 //window.//console.log("Pause - " + i + ":  " + id );
					  	}	 
					  });
			  }	
		}
		
		function remove_all_ken_burns_except(index) {
			  $slides.children('li').not(':eq(' + index + ')').find('div.bk_canvas_underlay').remove();
		}
		
		function show_title_for_current_slide() {
			  var title = get_slide_option( current_slide, "data-title" );
			 	if( title != '' && title != undefined ) {
			 		  slide_title.empty().append(title);
			 		  set.title_show_callback.call( slide_title );
			 	}	
		}
		
		function hide_title_for_current_slide() {
			  if( set.show_titles && current_slide != -1 )
			      set.title_hide_callback.call( slide_title );
		}
		
		function hide_video_button() {
			  var video_link = get_slide_option( current_slide, 'data-video-link' );
				if( video_link != '' && ( typeof video_link !== "undefined" ) ) {
			  		set.videobutton_hide_callback.call( video_button );
			  }		
		}					
		
		function show_slide( index ) {
			  current_slide = show_slide_internal( index, false );
			  
			  if( set.show_titles )
			      show_title_for_current_slide();
			  
			  $this.find('.slider-slice').remove();
			  
			  if( set.show_timer && circular_timer )
			      circular_timer.show();																			 
		}
		
		function get_next_slide_index() {
			  next_slide = current_slide + 1;
			  if( next_slide > slides_amount - 1 )
			      next_slide = 0;
		}
		
		function get_prev_slide_index() {
			  next_slide = current_slide - 1;
			  if( next_slide < 0 )
			      next_slide = slides_amount - 1;
		}
		
		function hide_primary_nav() {
			  if( !is_mouse_inside ) {
					  var buttons = '#pp-button, #next-button, #prev-button';
			   							
			   		if( theme == 'modern' ) {
			   				buttons = '#next-button, #prev-button';
			   		}
					  
					  $this.find(buttons).stop();
					  $this.find(buttons).fadeOut(set.auto_hide_primary_time);
			  }
		}
		
		function hide_secondary_nav() {
			  if( !is_mouse_inside ) {
					  if( set.socondary_nav_type == 'thumbs' || set.socondary_nav_type == 'bullets' ) {
							  secondary_nav_container.stop();
							  //secondary_nav_container.fadeOut(set.auto_hide_secondary_time);
							  set.auto_hide_secondary_callback.call( secondary_nav_container );
					  }
			  }
		}
		
		function embedd_video_and_play() {
			  var video_link = get_slide_option( current_slide, 'data-video-link' );
				if( video_link != '' && ( typeof video_link !== "undefined" ) ) {
					  if( video_link.match(/http:\/\/www.youtube.com\//) )
					      $slides.children('li').eq( current_slide ).append('<iframe id="bk-diamond-embedded-player" width="' + width + '" height="' + height + '" src="' + video_link + '?autoplay=1" frameborder="0" allowfullscreen></iframe>');
			      else if( video_link.match(/http:\/\/player.vimeo.com\//) )
			      	  $slides.children('li').eq( current_slide ).append('<iframe id="bk-diamond-embedded-player" width="' + width + '" height="' + height + '" src="' + video_link + '?autoplay=1" frameborder="0" allowfullscreen></iframe>');
			      else 
			      	   return;
			      
			      video_is_playing = true;
			      freeze_progress();
			      
			      video_button.removeClass('play').addClass('close');
			      
			      if( set.ken_burns_for_slides ) {
				  	 $slides.children('li').eq(current_slide).find('img.bk_ken_burns_img').not('.bk_canvas_underlay img').each(function(i) {
					      var id = $(this).attr('src') + "_" + i;
								var ref = slides_ken_burns_map[id];
					  				if( typeof ref !== "undefined") {  
					  				  ref.kenburns_plugin.Pause(); 
				  			}																								      
					   });															
			     }
				}
		}
		
		function remove_video() {
			  $slides.children('li').eq( current_slide ).find("#bk-diamond-embedded-player").remove();
			  video_is_playing = false;
			  
			  video_button.removeClass('close').addClass('play');
			  
			  if( set.ken_burns_for_slides ) {
					  $slides.children('li').eq(current_slide).find('img.bk_ken_burns_img').not('.bk_canvas_underlay img').each(function(i) {
							      var id = $(this).attr('src') + "_" + i;
										var ref = slides_ken_burns_map[id];
							  				if( typeof ref !== "undefined") {  
							  				  ref.kenburns_plugin.Play(); 
						  			}																								      
					  });
				}	  
		}					
					
//=================================END OF FUNCTIONS==========================================================================	
	 
		if (jQuery.browser.webkit && document.readyState != "complete"){
		    setTimeout( arguments.callee, 100 );
		    return;
    }

//=================================MAIN======================================================================================		
		$slides.hide();
		preload_all_img_and_thumbs();						
//================================END OF MAIN=====================================================================		
		

//================================EVENT HANDLERS==================================================================
		function bind_all_events() {
		
		video_button.click( 
		            function(event){
		            	if( video_is_playing ) {
		            		remove_video();
		            	} else {
		            		embedd_video_and_play(); 
		            	}		
		            }
		);            	
		
		$this.live( slice_anim_finished_event, 
								function(event)	{ 
										slices_finished++;
										if( slices_finished == slices_count )
										  {
										  	slices_finished = 0;
										  	show_slide( next_slide );
										  	
										  	is_animating_transition = false;
										  	
										  	if( is_playing && pause_on_hover && set.interactive_while_playing && !is_mouse_inside )
										  	    setTimeout(function(){time_tick();}, 10);
										  }	
								}
		  );
		  
		$this.mouseenter(
								function(event){
									is_mouse_inside = true;
									
									if( is_playing && pause_on_hover && set.interactive_while_playing && !is_animating_transition )
		        					freeze_progress();
		        					
		        			if( set.auto_hide_primary_nav )
			   						{
			   							clearTimeout( auto_hide_primary_timer );
			   							var buttons = '#pp-button, #next-button, #prev-button';
			   							
			   							if( theme == 'modern' ) {
			   								  buttons = '#next-button, #prev-button';
			   							}	
			   							
			   							$this.find(buttons).stop();
			   							$this.find(buttons).fadeTo(set.auto_hide_primary_time, 1);
			   						}
			   					
			   					if( set.auto_hide_secondary_nav )
			   						{
			   							if( set.socondary_nav_type == 'thumbs' || set.socondary_nav_type == 'bullets' ) {
					   							clearTimeout( auto_hide_secondary_timer );
					   							//secondary_nav_container.stop();
					   							//secondary_nav_container.fadeTo(set.auto_hide_secondary_time, 1);
					   							set.auto_show_secondary_callback.call( secondary_nav_container );
			   						  }	
			   						}
			   					//window.//console.log("slider $this.mouseenter: " );	
			   					return true;						
    				    });
    
    $this.mouseleave(
								function(event){
									is_mouse_inside = false;
									
									if( is_playing && pause_on_hover && set.interactive_while_playing && !is_animating_transition && !video_is_playing )
            	  			launch_progress(); 
            	  			
            	  	if( set.auto_hide_primary_nav )
			   						{
											auto_hide_primary_timer = setTimeout(function(){hide_primary_nav();}, set.auto_hide_primary_nav_delay);
			   						}
			   					
			   					if( set.auto_hide_secondary_nav )
			   						{
			   							if( set.socondary_nav_type == 'thumbs' || set.socondary_nav_type == 'bullets' )
			   									auto_hide_secondary_timer = setTimeout(function(){hide_secondary_nav();}, set.auto_hide_secondary_nav_delay);
			   						}
			   					//window.//console.log("slider $this.mouseleave: " );
			   					return true;				
    						});
    						
    
    $this.find("div.bk-diamond-secondary-nav .bk-thumb-img-frame").mouseenter(
    						function(event){
    							 if( set.show_thumb_titles )
    							     show_thumb_title( $(this).find('div.bk-thumb-title') );
    							  	
    						});
    						
    $this.find("div.bk-diamond-secondary-nav .bk-thumb-img-frame").mouseleave(
    						function(event){
    							 if( set.show_thumb_titles )
    							     hide_thumb_title( $(this).find('div.bk-thumb-title') ); 
    						});												
    						
    						
    $this.find('#pp-button').click(
    						function(event){
    							  if( !is_animating_transition )
										    toggle_play();	
    						});
    						
    $this.find('#next-button').click(
    						function(event){
     							  if( !is_animating_transition )
     						        go_to_next_slide();
    						}); 
    						
    $this.find('#prev-button').click(
    						function(event){
    							  if( !is_animating_transition )
     							      go_to_prev_slide();	
    						});
    						
    $this.find("div.bk-diamond-secondary-nav .bk-secondary-nav-item").click(
    						function(event){
    							  if( !is_animating_transition ) {
		    							  var i = jQuery(this).attr("rel");
		    							  if( i != current_slide )
		    							  		go_to_slide_number( i );
    							  }	
    						});
    						
    $this.find('div.bk-sec-top').live( 'click', 
								function(event)	{ 
									var shift = ver_sec_snap;
									if( secondary_nav_wrap.position().top + shift >= $(this).outerHeight( true ) )
											shift =  secondary_nav_wrap.position().top * -1 + $(this).outerHeight( true );
											
									if( shift < 0 )
									    shift = 0;		
									
									secondary_nav_wrap.stop();
									secondary_nav_wrap.animate({top: '+=' + shift}, 'fast', 'swing' );
								}
		);
		
		$this.find('div.bk-sec-bottom').live( 'click', 
								function(event)	{ 
									var shift = ver_sec_snap;
									if( secondary_nav_wrap.position().top + secondary_nav_wrap.height() - shift <= height - $(this).outerHeight( true ) )
											shift = ( secondary_nav_wrap.position().top + secondary_nav_wrap.height() ) - height + $(this).outerHeight( true );
											
									if( shift < 0)
									    shift = 0;		
												
									secondary_nav_wrap.stop();
									secondary_nav_wrap.animate({top: '-=' + shift}, 'fast', 'swing' );	
								}
		);
		
		$this.find('div.bk-sec-left').live( 'click', 
								function(event)	{ 
									var shift = hor_sec_snap;
									if( secondary_nav_wrap.position().left + shift >= $(this).outerWidth( true ) )
											shift =  secondary_nav_wrap.position().left * -1 + $(this).outerWidth( true );
											
									if( shift < 0 )
									    shift = 0;		
									
									secondary_nav_wrap.stop();
									secondary_nav_wrap.animate({left: '+=' + shift}, 'fast', 'easeOutBack' );		
								}
		);
		
		$this.find('div.bk-sec-right').live( 'click', 
								function(event)	{ 
									var shift = hor_sec_snap;
									if( secondary_nav_wrap.position().left + secondary_nav_wrap.width() - shift <= width - $(this).outerWidth( true ) )
											shift = ( secondary_nav_wrap.position().left + secondary_nav_wrap.width() ) - width + $(this).outerWidth( true );
											
									if( shift < 0 )
									    shift = 0;		
												
									secondary_nav_wrap.stop();
									secondary_nav_wrap.animate({left: '-=' + shift}, 'fast', 'easeOutBack' );	
								}
		);
		
	  }												 												 						  
		
//================================END OF EVENT HANDLERS==================================================================		
});

};
})(jQuery);		
