/**

 * @fileOverview

 * <h2>Inception Slider</h2>

 * Inception Slider is a custom-coded JavaScript slider for the Eboss theme.

 * @author <a href="mailto:contact@omarabid.com">Abid Omar</a>

 * @name Inception Slider

 * @version 1.0.0

 */

(function($) {

	/**

	 * @namespace Inception. This namespace holds all the properties and methods of the inception slider.

	 * @param{param} The options of the slider.

	 * @constructor

	 * @example

	 * var new_slider = new Inception();

	 * @description

	 * <h3>Step 1: Theme Preparation</h3>

	 * <p>Prepare the theme for the slider implementation. Create jQuery objects reperesting the elements

	 * in the theme, return an object with a collection of functions required for the slider, adds light

	 * animation to some particular elements of the page and also apply the reflection effect.</p>

	 * <h3>Step 2: Main Slider</h3>

	 * <p>The Main Slider part, initialize the image and box sliders using the slider_fn object.</p>

	 * <h3>Step 3: Load Events</h3>

	 * <p>Bind events to the according element.</p>

	 * <h3>Step 4: Load Add-ons</h3>

	 * <p>Load custom add-ons for the slider</p>

	 */

	function Inception(param) {

		var that = this;



		/*

		 * The Default options for the Inception Slider

		 * @type object

		 */



		var defaults = {

			global : {

				timer : {

					enabled : false,

					disable_onclick : false,

					disable_onhover : false,

					duration : 5000

				}

			},

			slider : {

				image_slider : {

					duration : 1000,

					effect : 'slide',

					easing : 'easeInOutExpo'

				},

				box_slider : {

					duration : 1000,

					easing : 'easeOutQuad'

				},

				mini_slider : {

					duration : 1000,

					easing : 'easeOutCubic'

				},

				expand : {

					duration : 1000,

					easing : 'easeOutCirc'

				}

			}

		};

		// Extends the param with default options

		that.param = $.extend(true, defaults, param);



		/*

		* Step 1. Theme Preparation

		*/

		// Step 1.1: No Js and Clone3

		that.clone3();

		that.nojs();

		that.preload_imgs();

		// Step 1.2: jQuery Elements

		that.$el = that.jelements();

		// Step 1.3: Animation

		that.elements_animation();

		// Step 1.4: Reflection

		//that.reflect_effect();

		// Step 1.5: Return the basic functionality

		that.slider_fn = that.slider_functions();

		// Step 1.6: Global Variable to hold essential data

		that.global = {

			current : 0

		}



		/*

		* Step 2. Main Slider

		*/



		// Step 2.2: Initialize Image Slider

		that.slider_fn.image_slider.init();

		// Step 2.3: Initialize Box Slider

		that.slider_fn.box_slider.init();



		/*

		 * Step 3. Load Events

		 */

		that.load_events();



		/*

		 * Step 4. Load Add-ons

		 */

		that.addons();

	}



	/**

	 * @description Displays information about the Slider elements in the debugging console.

	 * @param {string} db The information that you want to be displayed

	 * @example

	 * inception_instance.debug('all');

	 * @lends Inception.prototype

	 */

	Inception.prototype.debug = function(db) {

		var that = this;

		if (db == 'all') {

			console.info(that);

		} else if (db == 'elements') {

			console.info(that.$el);

		} else if (db == 'functions') {

			console.info(that.slider_fn);

		}

	};

	/**

	 * @description This function is made for no-js browser compatibilty.

	 * @lends Inception.prototype

	 */

	Inception.prototype.nojs = function() {

		/*

		 * Display hidden no-js elements

		 */

		$('.no-js').removeClass('no-js');

	};

	/**

	 * @description Create a 3 similar clones if the list items number is 3

	 * @lends Inception.prototype

	 */

	Inception.prototype.clone3 = function() {

		/*

		 * Check the number of items

		 */

		if ($('UL>LI', '.inception-inner-wrapper').length == 3) {

			$('UL>LI', '.inception-inner-wrapper').clone(true).appendTo($('UL','.inception-inner-wrapper'));

			// Chrome Bug -_-

			$('.inception-toggle','.inception-inner-wrapper').css('opacity',1);

			$('.inception-revealed-content','.inception-inner-wrapper').css('opacity',1);

		}



	};

	/**

	 * @description Preloads Images

	 * @lends Inception.prototype

	 */

	Inception.prototype.preload_imgs = function() {

		/*

		 * Get the images links

		 */

		var imgs = [];

		$('.img_preload', '.inception-image-wrapper').each( function(i) {

			var url = "http://" + $(this).attr('id');

			url = url.replace(/iislash/gi,'/');

			imgs[i] = {

				number : $(this).attr('title'),

				url : url

			};

		});

		/*

		 * Display Waiting Image

		 *

		 $('.inception-image-wrapper').append('<div class="preloading_hint">Preloading...</div>');

		 $('.preloading_hint').css({

		 'position':'absolute',

		 'top':'50%',

		 'left':'50%'

		 });

		 */



		/*

		 * Create Imgs Elements

		 */

		$.each(imgs, function(i, val) {

			$('.inception-image-wrapper').append($('<img/>', {

				src : imgs[i].url,

				style : 'display: none',

				'class' : 'inceptimage'

			}));

		});

		/*

		 * Listen for images to load fully

		 */

		$('.inceptimage', '.inception-image-wrapper').load( function() {

			$('.preloading_hint').fadeOut();

		});

	};

	/**

	 * @description Create jQuery objects representing the used elements by the slider. The elements can be arranged

	 * into arrays and objects

	 * @returns {object} A collection of jQuery objects

	 * @lends Inception.prototype

	 */

	Inception.prototype.jelements = function() {

		var $el = {};

		/*

		 * Main Slider Wrapper

		 */

		$el.wrapper = $('#omc-wrapper');



		/*

		 * Slide Pagination Arrows

		 */

		$el.pagination = {

			back : $('.arrow.back', $el.wrapper),

			forward : $('.arrow.forward', $el.wrapper)

		}



		/*

		 * Reflection icons

		 */

		$el.reflection_icons = $('.inception-icon-reflect:not(.active-reflect)', $el.wrapper);



		/*

		 * Main Slider

		 */

		$el.slider = {

			container : $('.inception-inner-wrapper', $el.wrapper)

		};

		// Number of slides

		$el.slider.length = $('ul>li', $el.slider.container).length;

		// Slides Array

		$el.slider.slides = new Array($el.slider.length);

		for (var i = 0; i < $el.slider.length; i++) {

			$slide = $('ul>li', $el.slider.container).eq(i);

			$el.slider.slides[i] = {

				container : $slide,

				expandable_box : {

					container : $('.inception-expandable', $slide),

					header : $('.inception-header', $slide),

					switch_btn : $('.inception-toggle', $slide),

					content : $('.inception-revealed-content', $slide)

				},

				content_box : $('.inception-bottom-content', $slide)

			};

			// This is used for switch box tracking

			$el.slider.slides[i].expandable_box.switch_btn.attr('switch', i);

		}



		/*

		 * Image Slider

		 */

		$el.image_slider = {

			container : $('.inception-image-wrapper', $el.wrapper),

			imgs : $('.inception-image-wrapper IMG', $el.wrapper)

		};

		// Number of images

		$el.image_slider.length = $('IMG', $el.image_slider.container).length;

		// Images Array

		$el.image_slider.img = new Array($el.image_slider.length);

		for (var i = 0; i < $el.image_slider.length; i++) {

			$el.image_slider.img[i]=$('IMG', $el.image_slider.container).eq(i);

		}



		/*

		 * Mini Slider

		 */

		$el.mini = new Array($el.slider.length);

		for (var i = 0; i < $el.slider.length; i++) {

			// Mini-Slider

			$el.mini[i] = {

				container : $el.slider.slides[i].expandable_box.content

			}

			// Number of mini-slides

			var mini_slides = $('.mini-slide', $el.mini[i].container).length;

			// mini-slides Array

			$el.mini[i].slides = new Array(mini_slides);

			for (var j = 0; j < mini_slides; j++) {

				$el.mini[i].slides[j] = $('.mini-slide', $el.mini[i].container).eq(j);

			}

			// Mini-Slider Pagination

			$el.mini[i].pagination = $('.inception-mini-pagination', $el.mini[i].container);

		}



		/*

		 * Return the elements object

		 */

		return $el;

	}

	/**

	 * @description Apply animation and effects to some elements in the slider

	 * @lends Inception.prototype

	 */

	Inception.prototype.elements_animation = function() {

		var that = this;

		/*

		 * Slider Arrows

		 */

		if (!($.browser.msie && $.browser.version === '7.0' || $.browser.version === '8.0')) {

			$([that.$el.pagination.back[0], that.$el.pagination.forward[0]]).animate({opacity: 0.9}, 1).fadeIn(500).hover( function() {

				$(this).stop().animate({

					opacity: 1

				}, 300 );

			}, function() {

				$(this).stop().animate({

					opacity: 0.9

				}, 300 );

			});

		} else {

			$([that.$el.pagination.back[0], that.$el.pagination.forward[0]]).css('display', 'block');

		}

		/*

		 * Mini-Slider navigation buttons

		 */

		$('.inception-mini-pagination>li>a', that.$el.wrapper).each( function() {

			/*

			 * Change Pagination Highlight

			 */

			$(this).click( function() {

				if ($(':animated', $(this).parent().parent().parent().parent()).length == 0) {

					$(this).addClass('inception-active').removeClass('inception-inactive');

					$(this).parent().siblings().find('a').addClass('inception-inactive').removeClass('inception-active').css('opacity', 0.3);

				}

			});

			/*

			 * Highlight button on hover

			 */

			$(this).hover( function() {

				$(this).stop().animate({

					opacity: 1

				}, 100 );

			}, function() {

				$(this).not('.inception-active').stop().animate({

					opacity: 0.3

				}, 300 );

			});

		});

	};

	/**

	 * @description The icon-refection effect

	 * @lends Inception.prototype

	 */

	Inception.prototype.reflect_effect = function() {

		var that = this;

		if (!($.browser.msie && $.browser.version === '7.0' || $.browser.version === '8.0')) {

			that.$el.reflection_icons.hover( mouseover, mouseout);

		}

		$('.inception-icon', that.$el.reflection_icons[0]).addClass('inception-icon-active');

		function mouseover() {

			var that = this,

			$icon = $('.inception-icon', that);

			if (!$icon.hasClass('inception-icon-active')) {

				$icon.stop().animate({

					marginTop: "-14px"

				}, 250, function() {

					$icon.animate({

						marginTop: "-10px"

					}, 250);

				});

				$('.inception-icon-transformed', that).stop().animate({

					marginTop: "14px",

					opacity: 0.8

				}, 250);

			}

		}



		function mouseout() {

			var that = this,

			$icon = $('.inception-icon', that);

			if (!$icon.hasClass('inception-icon-active')) {

				$icon.stop().animate({

					marginTop: "4px"

				}, 250, function() {

					$icon.animate({

						marginTop: "0px"

					}, 250);

				});

				$('.inception-icon-transformed', that).stop().animate({

					marginTop: "0",

					opacity: 1

				}, 250);

			}

		}



	};

	/**

	 * @description Returns an object with functions and methods related to the slider

	 * @returns {object} A collection of functions and methods.

	 * @lends Inception.prototype

	 */

	Inception.prototype.slider_functions = function() {

		var that = this;

		var fn = {};

		/*

		 * Open/Close Expandable boxes

		 * @field

		 */

		fn.expand = {

			/*

			 * Opens an expandable box

			 * @param {integer} Box number

			 * @inner

			 * @function

			 */

			open : function(i, callback) {

				var $slide = that.$el.slider.slides[i];

				/*

				 * Change Switch Button

				 */

				$slide.expandable_box.switch_btn.addClass('inception-close').html('fechar');

				/*

				 * Expand

				 */

				$slide.expandable_box.container.animate({

					top: (-1) * $slide.expandable_box.container.height()

				},that.param.slider.expand.duration, that.param.slider.expand.easing, callback);

			},

			/*

			 * Close an expandable box

			 * @param {integer} Box number

			 * @inner

			 * @function

			 */

			close : function(i, callback) {

				var $slide = that.$el.slider.slides[i];

				/*

				 * Change Switch Button

				 */

				$slide.expandable_box.switch_btn.removeClass('inception-close').html('abrir');

				/*

				 * Collapse

				 */

				$slide.expandable_box.container.animate({

					top: -43

				},that.param.slider.expand.duration, that.param.slider.expand.easing,  callback);

			}

		}



		/*

		 * Mini-Slider

		 */

		fn.mini = {

			show : function(tab, slide) {

				if ($(':animated', that.$el.mini[tab].container).length == 0) {

					var active = $('.mini-slide:visible', that.$el.mini[tab].container),

					container = that.$el.mini[tab].container,

					target = that.$el.mini[tab].slides[slide];

					/*

					 * Get Current height

					 */

					var current_height = (-1) * (container.height() + 83);

					/*

					 * Get the Target Height

					 */

					$('.mini-slide', container).hide();

					target.show();

					var height = (-1) * (container.height() + 83);

					$('.mini-slide', container).hide();

					active.show();



					/*

					 * Animation

					 */

					if (current_height == height) {

						active.fadeOut( function() {

							target.fadeIn();

						});

					} else if (current_height < height) {

						active.animate({

							'opacity':0

						}, function() {

							container.parent().animate({

								'top':height

							}, function() {

								active.hide().css('opacity',1);

								target.fadeIn();

							});

							$('.inception-mini-pagination', container.parent()).css('top',((-1)*current_height)-78).animate	({

								'top':(-1)*(height)-78

							});

							container.parent().css('height', (-1)*height);

						});

					} else if (current_height > height) {

						active.fadeOut( function() {

							target.show().css('opacity', 0);

							$('.inception-mini-pagination', container.parent()).css('top',((-1)*current_height)-78).animate	({

								'top':(-1)*(height)-78

							});

							container.parent().css('height', (-1)*height).animate({

								'top':height

							}, function() {

								target.animate({

									'opacity':1

								});

							});

						});

					}

				}

			}

		}



		/*

		 * Image Slider

		 */

		fn.image_slider = {

			init : function() {

				/*

				 * 1. Hide All images

				 */

				that.$el.image_slider.imgs.hide();

				/*

				 * 2. Display the First Image

				 */

				that.$el.image_slider.img[0].show();

				/*

				 * 3. Set the current for the slider

				 */

				fn.image_slider.current = 0;

			}

		};

		fn.image_slider.slide = function(i, slide) {

			if ($(':animated', that.$el.image_slider.container).length == 0 && that.$el.image_slider.length > 1) {

				if (that.param.slider.image_slider.effect == 'fade') {

					/*

					 * FadeOut Current Image

					 */

					that.$el.image_slider.img[fn.image_slider.current].fadeOut(that.param.slider.image_slider.duration, that.param.slider.image_slider.easing);

					/*

					 * FadeIn Selected Image

					 */

					that.$el.image_slider.img[i].fadeIn(that.param.slider.image_slider.duration, that.param.slider.image_slider.easing);

					/*

					 * Update current

					 */

					fn.image_slider.current = i;

				} else {

					/*

					 * Prepare image to slide

					 */

					if (slide == 'back') {

						/*

						* Slide Back

						*/

						// Image Size

						var width = that.$el.image_slider.img[fn.image_slider.current].width();

						// Put next image in the left and display it

						that.$el.image_slider.img[i].css('left',(-1)*width).show();

						// Animate both images

						that.$el.image_slider.img[fn.image_slider.current].animate({

							left: width

						},that.param.slider.image_slider.duration, that.param.slider.image_slider.easing);

						that.$el.image_slider.img[i].animate({

							left: 0

						}, that.param.slider.image_slider.duration, that.param.slider.image_slider.easing, function() {// Hide the moved image

							that.$el.image_slider.img[fn.image_slider.current].hide();

							/*

							 * Reset the current

							 */

							fn.image_slider.current = i;

						});

					} else {

						/*

						* Slide Next

						*/

						// Image Size

						var width = that.$el.image_slider.img[fn.image_slider.current].width();

						// Put next image in the right and display it

						that.$el.image_slider.img[i].css('left',width).show();

						// Animate both images

						that.$el.image_slider.img[fn.image_slider.current].animate({

							left: (-1)*width

						}, that.param.slider.image_slider.duration, that.param.slider.image_slider.easing);

						that.$el.image_slider.img[i].animate({

							left: 0

						},that.param.slider.image_slider.duration, that.param.slider.image_slider.easing, function() {// Hide the moved image

							that.$el.image_slider.img[fn.image_slider.current].hide();

							/*

							 * Reset the current

							 */

							fn.image_slider.current = i;

						});

					}

				}

			}

		};

		fn.image_slider.forward = function() {

			if (fn.image_slider.current == that.$el.image_slider.length - 1) {

				fn.image_slider.slide(0);

			} else {

				fn.image_slider.slide(fn.image_slider.current+1);

			}

		};

		fn.image_slider.back = function() {

			if (fn.image_slider.current == 0) {

				fn.image_slider.slide(that.$el.image_slider.length -1, 'back');

			} else {

				fn.image_slider.slide(fn.image_slider.current-1, 'back');

			}

		};

		/*

		 * Boxes Slider

		 */

		fn.box_slider = {

			init : function() {

				// Set the current for the box slider

				fn.box_slider.current = 0;

			}

		};

		/*

		 * @description Deactivate animation on current Box icon

		 */

		fn.box_slider.anim = function() {

			/*

			 * Remove the .inception-icon-active class

			 */

			$('.inception-icon').removeClass('inception-icon-active').css('margin-top','0px');

			$('.inception-icon-transformed').css({

				marginTop: "",

				opacity: ""

			});

			/*

			 * Add the class to the current box

			 */

			$('.inception-icon', that.$el.reflection_icons[that.slider_fn.box_slider.current]).addClass('inception-icon-active');

			/*

			 * Smooth animation

			 */

			$('.inception-icon', that.$el.reflection_icons[that.slider_fn.box_slider.current]).stop().animate({

				'margin-top':'-10px'

			});

			$('.inception-icon-transformed', that.$el.reflection_icons[that.slider_fn.box_slider.current]).stop().animate({

				marginTop: "14px",

				opacity: 0.8

			}, 250);



		};

		/*

		 * @description Double Forward

		 */

		fn.box_slider.doubleforward = function() {

			if ($('.inception-inner-wrapper:animated').length == 0) {



				/*

				 * More code for the expandable boxes to avoid waiting for animations ;)

				 */

				/*

				 * Close Expandable Boxes

				 */

				var open = 0;

				if (fn.box_slider.current == that.$el.slider.length - 1) {

					open = 1;

					fn.expand.open(1);

				} else if (fn.box_slider.current == that.$el.slider.length - 2) {

					open =0;

					fn.expand.open(0);

				} else {

					open = fn.box_slider.current + 2;

					fn.expand.open(fn.box_slider.current+2);

				}

				for (var i = 0; i < that.$el.slider.length; i++) {

					if (i != open) {

						fn.expand.close(i);

					}

				}



				/*

				 * Move the container 330px

				 */

				that.$el.slider.container.animate({

					marginLeft: -330

				}, parseInt(that.param.slider.box_slider.duration/3,10), 'linear', function() {

					/*

					 * Append the current to the end of the list

					 */

					that.$el.slider.container.css('margin-left', 0);

					$('UL', that.$el.slider.container).append(that.$el.slider.slides[fn.box_slider.current].container);

					if (fn.box_slider.current == that.$el.slider.length - 1) {

						fn.box_slider.current = -1;

					}

					fn.box_slider.current++;

					/*

					 * Move the container 330px

					 */

					that.$el.slider.container.animate({

						marginLeft: -330

					}, parseInt((that.param.slider.box_slider.duration/3)*2,10), that.param.slider.box_slider.easing, function() {

						/*

						 * Append the current to the end of the list

						 */

						that.$el.slider.container.css('margin-left', 0);

						$('UL', that.$el.slider.container).append(that.$el.slider.slides[fn.box_slider.current].container);

						if (fn.box_slider.current == that.$el.slider.length - 1) {

							fn.box_slider.current = -1;

						}

						fn.box_slider.current++;

						fn.box_slider.anim();

					});

				});

			}

		};

		fn.box_slider.forward = function() {

			if ($('.inception-inner-wrapper:animated').length == 0) {

				/*

				 * More code for the expandable boxes to avoid waiting for animations ;)

				 */

				/*

				 * Close Expandable Boxes

				 */

				var open = 0;

				if (fn.box_slider.current == that.$el.slider.length - 1) {

					fn.expand.open(0);

				} else {

					open = fn.box_slider.current + 1;

					fn.expand.open(fn.box_slider.current+1);

				}

				for (var i = 0; i < that.$el.slider.length; i++) {

					if (i != open) {

						fn.expand.close(i);

					}

				}

				/*

				 * Move the container 330px

				 */

				that.$el.slider.container.animate({

					marginLeft: -330

				}, that.param.slider.box_slider.duration, that.param.slider.box_slider.easing, function() {

					/*

					 * Append the current to the end of the list

					 */

					that.$el.slider.container.css('margin-left', 0);

					$('UL', that.$el.slider.container).append(that.$el.slider.slides[fn.box_slider.current].container);

					if (fn.box_slider.current == that.$el.slider.length - 1) {

						fn.box_slider.current = -1;

					}

					fn.box_slider.current++;

					fn.box_slider.anim();

				});

			}

		};

		fn.box_slider.back = function() {

			if ($('.inception-inner-wrapper:animated').length == 0) {

				/*

				 * Prepare Width and Box

				 */

				that.$el.slider.container.css('margin-left', -330);

				var toPrepend = fn.box_slider.current - 1;

				if (toPrepend == -1) {

					toPrepend = that.$el.slider.length - 1;

				}

				$('UL', that.$el.slider.container).prepend(that.$el.slider.slides[toPrepend].container);

				that.$el.slider.container.animate({

					'margin-left': 0

				},  that.param.slider.box_slider.duration, that.param.slider.box_slider.easing);

				if (fn.box_slider.current == 0) {

					fn.box_slider.current = that.$el.slider.length;

				}

				fn.box_slider.current--;

				fn.box_slider.anim();

				/*

				 * Close Expandable Boxes

				 */

				fn.expand.open(fn.box_slider.current);

				for (var i = 0; i < that.$el.slider.length; i++) {

					if (i != fn.box_slider.current) {

						fn.expand.close(i);

					}

				}

			}

		};

		/*

		 * Main Slider Navigation

		 */

		fn.main_slider = {

			forward : function(timer) {

				// Image Slider

				that.slider_fn.image_slider.forward();

				// Box Slider

				that.slider_fn.box_slider.forward();

				/*

				 * Disable the timer

				 */

				if (timer != 'timer') {

					clearInterval(that.param.global.timer.interval);

				}

			},

			back : function(timer) {

				// Image Slider

				that.slider_fn.image_slider.back();

				// Box Slider

				that.slider_fn.box_slider.back();

				/*

				 * Disable the timer

				 */

				if (timer != 'timer') {

					clearInterval(that.param.global.timer.interval);

				}

			}

		};

		fn.main_slider.double_forward = function(timer) {

			var slide = that.slider_fn.image_slider.current;

			if (slide === that.$el.image_slider.length - 2) {

				slide = 0;

			} else if (slide === that.$el.image_slider.length - 1) {

				slide = 1;

			} else {

				slide = slide + 2;

			}

			// Image Slider

			that.slider_fn.image_slider.slide(slide);

			// Box Slider

			that.slider_fn.box_slider.doubleforward();

			/*

			 * Disable the timer

			 */

			if (timer != 'timer') {

				clearInterval(that.param.global.timer.interval);

			}

		};

		return fn;

	}

	/**

	 * @description Bind events to elements in the page

	 */

	Inception.prototype.load_events = function() {

		var that = this;

		/*

		* Expand/Collapse Switcher buttons

		*/

		// Whole header

		$('.inception-header').click( function() {

			/*

			 * Toggle Open/Close button

			 */

			$('.inception-toggle', this).toggleClass('inception-close');

			var length = that.$el.slider.length;

			var current = that.slider_fn.box_slider.current;

			var clicked = $('.inception-toggle', this).attr('switch');

			if ((clicked - current) == 1 || (clicked-current) == 0 || current == length - 1 && clicked == 0) {

				that.slider_fn.main_slider.forward();

			} else {

				that.slider_fn.main_slider.double_forward();

			}

			return false;

		});

		$('.inception-icon-reflect').click( function() {

			if (!$('.inception-icon', this).hasClass('inception-icon-active')) {

				var th = $('.inception-header',$(this).parent().parent());

				/*

				 * Toggle Open/Close button

				 */

				$('.inception-toggle', th).toggleClass('inception-close');

				var length = that.$el.slider.length;

				var current = that.slider_fn.box_slider.current;

				var clicked = $('.inception-toggle', th).attr('switch');

				if ((clicked - current) == 1 || (clicked-current) == 0 || current == length - 1 && clicked == 0) {

					that.slider_fn.main_slider.forward();

				} else {

					that.slider_fn.main_slider.double_forward();

				}

			}

			return false;

		});

		/*

		 * Mini-Slider Pagination

		 */

		for (var i = 0; i < that.$el.mini.length; i++) {

			var pag = that.$el.mini[i].pagination;

			// Mini-Slider Pagination

			$('li', pag).each( function(j, el) {

				// Uses closure

				$(el).click( (function(_i) {

					return function() {

						/*

						 * Toggle Mini-Slide

						 */

						that.slider_fn.mini.show(_i, j);

						return false;

					}

				})(i));

			});

		}

		/*

		 * Main Slider Pagination

		 */

		that.$el.pagination.back.click( function() {

			that.slider_fn.main_slider.back();

			return false;

		});

		that.$el.pagination.forward.click( function() {

			that.slider_fn.main_slider.forward();

			return false;

		});

	};

	/**

	 * @description Slider Add-ons

	 */

	Inception.prototype.addons = function() {

		var that = this;

		/*

		 * Timer

		 */

		if (that.param.global.timer.enabled) {

			that.param.global.timer.interval = setInterval(that.slider_fn.main_slider.forward ,that.param.global.timer.duration, 'timer');

		}

		/*

		 * Cuffon Code

		 */

		Cufon.replace('div.p_table h1, #omc-ribbon h1, .omc-content h1, h2, h3, h4, h5, h6, a.omc-tagline-button, span.testimonial-excerpt, .omc-twitter-user, .port_4_title,  a.omc-blog-button, .dropcap, .sc_button, a.omc-buy-now', {hover: true});	



		if(jQuery.browser.version.substring(0, 2) == "8." || jQuery.browser.version.substring(0, 2) == "7.") {} else {

			Cufon.replace('a.omc-glass-button, a.sign_up', {textShadow: '#EEE 1px 1px', color: '-linear-gradient(#868686, #000)'});	

			Cufon.replace('h2.col1, h2.col2, h2.col3, h2.col4, h2.col5 ', {textShadow: '#FFF 1px 1px', color: '-linear-gradient(#BBB, #888)'});	 

			Cufon.replace('.omc-tagline h1', {textShadow: '#FFF 1px 1px', color: '-linear-gradient(#555, #aaa)'});		

			Cufon.replace('#omc-ribbon	h1', { textShadow: '#000 1px 1px', color: '-linear-gradient(#FFF, #EEE)'});		

		}

		/*

		 * Pause on Hover

		 */

		if (that.param.global.timer.disable_onhover === true) {

			$('#inception-slider').hover( function() {

				clearInterval(that.param.global.timer.interval);

			}, function() {

				if (that.param.global.timer.enabled) {

					clearInterval(that.param.global.timer.interval);

					that.param.global.timer.interval = setInterval(that.slider_fn.main_slider.forward ,that.param.global.timer.duration, 'timer');

				}

			});

		}

	}

	/*

	 * Creates a new instance of Inception

	 */

	$(window).load( function() {

		var param = $('#param_def').data('localized');

		if (!param) {

			var param = null;

		}

		var newinception = new Inception(param);

		// Open the first box

		newinception.slider_fn.expand.open(0);



	});

})(jQuery);
