/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

if (!jQuery.easing.easeInQuad) {jQuery.extend( jQuery.easing,
{
	//def: 'easeOutQuad',
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) {return c/2*t*t + b;}
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) {return c/2*t*t*t + b;}
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) {return c/2*t*t*t*t*t + b;}
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t===0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t===0) {return b;}
		if (t==d) {return b+c;}
		if ((t/=d/2) < 1) {return c/2 * Math.pow(2, 10 * (t - 1)) + b;}
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t===0) {return b;}  
		if ((t/=d)==1) {return b+c;}  
		if (!p) {p=d*0.3;}
		if (a < Math.abs(c)) { a=c; s=p/4; }
		else {s = p/(2*Math.PI) * Math.asin (c/a);}
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t===0) {return b;}  
		if ((t/=d)==1) {return b+c;}  
		if (!p) {p=d*0.3;}
		if (a < Math.abs(c)) { a=c; s=p/4; }
		else {s = p/(2*Math.PI) * Math.asin (c/a);}
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t===0) {return b;}  
		if ((t/=d/2)==2) {return b+c;} 
		if (!p) {p=d*(0.3*1.5);}
		if (a < Math.abs(c)) { a=c; s=p/4; }
		else { s = p/(2*Math.PI) * Math.asin (c/a);}
		if (t < 1) { return -0.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;}
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*0.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s === undefined) { s = 1.70158;}
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s === undefined) { s = 1.70158;}
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s === undefined) { s = 1.70158;} 
		if ((t/=d/2) < 1) { return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;}
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + 0.75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + 0.9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + 0.984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) { return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * 0.5 + b;}
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * 0.5 + c*0.5 + b;
	}
});}

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */ 
(function($) {

	$.pixelentity = $.pixelentity || {version: '1.0.0'};

	$.pixelentity.Geom = {
		getScaler: function (scaleMode,halign,valign,w,h,tw,th) {
			
			var info = {};
			
			var rw = w/tw;
			var rh = h/th;
			var r;
			
			// get scale ratio
			if (typeof scaleMode  == 'string') {
				switch (scaleMode) {
					case "fill":
					case "fillmax":
						r = rw > rh ? rw : rh;
						if (scaleMode == "fill") {r = Math.min(1,r);}
					break;
					case "fit":
					case "fitmax":
						r = rw < rh ? rw : rh;
						if (scaleMode == "fit") {r = Math.min(1,r);}
					break;
					case "none":
						r = 1;
					break;
				}
			} else {
				r = scaleMode;
			}
			
			// scale ration
			info.ratio = r;
			
			info.diff = {};
			info.offset = {};
			info.align = {w:halign,h:valign};
			
			// now compute offset with requested alignment
			//with (info) {
			
			var diff = info.diff;
			var offset = info.offset;
			
			diff.w = offset.w = w-tw*r;
			diff.h = offset.h = h-th*r;
			
			switch (halign) {
				case "center":
					offset.w = diff.w / 2;
				break;
				case "left":
					offset.w = 0;
				break;
			}
		
			switch (valign) {
				case "center":
					offset.h = diff.h / 2;
				break;
				case "top":
					offset.h = 0;
				break;
			}
				
			//}
			
			
			// return the scaler object
			return info;
		},
		
		// split a string in object
		splitProps : function(comma,numeric) {
			var token = comma.split(/,/);
			
			return numeric ? { h:parseFloat(token[0]), w:parseFloat(token[1])} : { h:token[0], w:token[1]};
		}
	};
		
})(jQuery);

		

 
(function($) {

	$.pixelentity = $.pixelentity || {version: '1.0.0'};
	
	if ($.pixelentity.ticker) {
		return;
	}

	var queue = [];
	var active = 0;
	
	function now() {
		return (new Date()).getTime();
	}
		
	var tim1,tim2,tim3 
	
	var loop =	window.requestAnimationFrame || 
				window.webkitRequestAnimationFrame || 
   		      	window.mozRequestAnimationFrame    || 
       			window.oRequestAnimationFrame      || 
				window.msRequestAnimationFrame ||
				false;
		
	function tick() {
		
		var n,entry;
		if (active > 0) {
			n= now();
		
			for (var i in queue) {
				entry = queue[i];
				if (n-entry.last >= entry.each) {
					entry.callback();
					entry.last = n;
				}
			}
			
			if (loop) {
				loop(tick);
			}
			
		}
	}
		
	var ticker = $.pixelentity.ticker = {
		register: function (callback,fps) {
			active++;
			queue.push({"callback":callback,"last":now(),"each": fps ? parseInt(1000/fps,10) : 33});
			if (active == 1) {
				if (loop) {
					loop(tick)
				} else {
					tim1 = setInterval(tick, 16);
					tim2 = setInterval(tick, 20);
					tim3 = setInterval(tick, 30);
				}
			}
		},
		unregister: function (callback) {
			for (var i in queue) {
				if (queue[i].callback == callback) {
					delete queue[i];
					active--;
				}
			}
			if (active <= 0) {
				clearInterval(tim1);
				clearInterval(tim2);
				clearInterval(tim3);
			}
		}
	}
		
})(jQuery); 
(function($) {

	$.pixelentity = $.pixelentity || {version: '1.0.0'};
	
	if ($.pixelentity.youtube) {
		return;
	}
	
	var loading = false;
	var player = window.YT && window.YT.Player;
	var list = []; 
	
	function callbacks() {
		for (var i=0;i<list.length;i++) {
			list[i](player);
		}
	}
	
	function loadPlayer() {
		if (loading) {
			return;
		}
		loading = true;
		var tag = document.createElement('script');
		tag.src = "http://www.youtube.com/player_api";
		var firstScriptTag = document.getElementsByTagName('script')[0];
		firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
		
		window.onYouTubePlayerAPIReady = function() {
			player = YT.Player;
			callbacks();
		};
		
	}
	
	$.pixelentity.youtube = function(callback) {
		if (player) {
			callback(player);
		} else {
			list.push(callback);
			loadPlayer();
		}
	};
	
})(jQuery); 
(function($) {

	$.pixelentity = $.pixelentity || {version: '1.0.0'};
	
	if ($.pixelentity.vimeo) {
		return;
	}
	
	var playerID=0;
	
	function VimeoPlayer(target,conf) {
		
		var self = this;
		var player;

		function start() {
			playerID++;
			var iframe = $('<iframe id="pe_vimeo_player'+playerID+'" src="http://player.vimeo.com/video/'+conf.videoId+'?autoplay='+(conf.playerVars.autoplay ? 1 : 0)+'&loop='+(conf.playerVars.loop ? 1 : 0)+'&api=1&player_id=pe_vimeo_player'+playerID+'&origin='+location.href.match(/:\/\/(.[^\/]+)/)[1]+'" width="'+conf.width+'" height="'+conf.height+'" frameborder="0"></iframe>')[0];
			$(target).append(iframe);
			player = Froogaloop(iframe);
			player.addEvent("ready",ready);
			setTimeout(ready,4000);
		}
		
		
		function ready() {
			player.removeEvent("ready",ready);
			player.addEvent("finish",ended);
		}
		
		function ended() {
			$(self).trigger("pixelentity.video_ended");
		}
		
		$.extend(self, {
			destroy: function() {
				player.removeEvent("ready",ready);
				player.removeEvent("finish",ended);
				$(player.element).remove();
				delete player.element;
				player = undefined;
				self = undefined;
			}
		});
		
		start();
	}
	
	$.pixelentity.vimeo = function(callback) {
		callback(VimeoPlayer);
	};
	
})(jQuery); 
(function($) {

	var origin = "0px 0px";
	// nearest
	var scalingMode = "bilinear";

	// stripped down internal modernizr (css3 3d transform only)
	var Modernizr=function(a,b,c){function z(a,b){for(var d in a)if(j[a[d]]!==c)return b=="pfx"?a[d]:!0;return!1}function y(a,b){return!!~(""+a).indexOf(b)}function x(a,b){return typeof a===b}function w(a,b){return v(m.join(a+";")+(b||""))}function v(a){j.cssText=a}var d="2.0.6",e={},f=b.documentElement,g=b.head||b.getElementsByTagName("head")[0],h="modernizr",i=b.createElement(h),j=i.style,k,l=Object.prototype.toString,m=" -webkit- -moz- -o- -ms- -khtml- ".split(" "),n={},o={},p={},q=[],r=function(a,c,d,e){var g,i,j,k=b.createElement("div");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),k.appendChild(j);g=["&shy;","<style>",a,"</style>"].join(""),k.id=h,k.innerHTML+=g,f.appendChild(k),i=c(k,a),k.parentNode.removeChild(k);return!!i},s,t={}.hasOwnProperty,u;!x(t,c)&&!x(t.call,c)?u=function(a,b){return t.call(a,b)}:u=function(a,b){return b in a&&x(a.constructor.prototype[b],c)};var A=function(a,c){var d=a.join(""),f=c.length;r(d,function(a,c){var d=b.styleSheets[b.styleSheets.length-1],g=d.cssRules&&d.cssRules[0]?d.cssRules[0].cssText:d.cssText||"",h=a.childNodes,i={};while(f--)i[h[f].id]=h[f];e.csstransforms3d=i.csstransforms3d.offsetLeft===9},f,c)}([,["@media (",m.join("transform-3d),("),h,")","{#csstransforms3d{left:9px;position:absolute}}"].join("")],[,"csstransforms3d"]);n.csstransforms3d=function(){var a=!!z(["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"]);a&&"webkitPerspective"in f.style&&(a=e.csstransforms3d);return a};for(var B in n)u(n,B)&&(s=B.toLowerCase(),e[s]=n[B](),q.push((e[s]?"":"no-")+s));v(""),i=k=null,e._version=d,e._prefixes=m,e.testProp=function(a){return z([a])},e.testStyles=r;return e}(this,this.document);

	/*
		very stripped down version of 
		https://github.com/heygrady/transform/blob/master/README.md
	*/
	
	var rmatrix = /progid:DXImageTransform\.Microsoft\.Matrix\(.*?\)/;
	
	// Steal some code from Modernizr
	var m = document.createElement( 'modernizr' ),
		m_style = m.style;
		
	/**
	 * Find the prefix that this browser uses
	 */	
	function getVendorPrefix() {
		var property = {
			transformProperty : '',
			MozTransform : '-moz-',
			WebkitTransform : '-webkit-',
			OTransform : '-o-',
			msTransform : '-ms-'
		};
		for (var p in property) {
			if (typeof m_style[p] != 'undefined') {
				return property[p];
			}
		}
		return null;
	}
	
	function supportCssTransforms() {
		var props = [ 'transformProperty', 'WebkitTransform', 'MozTransform', 'OTransform', 'msTransform' ];
		for ( var i in props ) {
			if ( m_style[ props[i] ] !== undefined  ) {
				return true;
			}
		}
	}
		
	// Capture some basic properties
	var vendorPrefix			= getVendorPrefix(),
		transformProperty		= vendorPrefix !== null ? vendorPrefix + 'transform' : false,
		transformOriginProperty	= vendorPrefix !== null ? vendorPrefix + 'transform-origin' : false;
	
	// store support in the jQuery Support object
	$.support.csstransforms = supportCssTransforms();
	
	$.support.hw3dTransform = (Modernizr["csstransforms3d"] && $.browser.webkit); //&& (navigator.userAgent.toLowerCase().match(/(iphone|ipod|ipad|chrome)/) !== null);
	
	// IE9 public preview 6 requires the DOM names
	if (vendorPrefix == '-ms-') {
		transformProperty = 'msTransform';
		transformOriginProperty = 'msTransformOrigin';
	}

	function transform(el,ratio,dx,dy,w,h) {
		if ($.support.csstransforms) {
			var offs;
			
			if ($.support.hw3dTransform) {
				dx=100*dx/w;
				dy=100*dy/h;
				offs = (dx !== undefined ) ? "translate3d("+dx+"%,"+dy+"%,0) " : "translateZ(0) ";
			} else {
				offs = (dx !== undefined ) ? "translate("+dx+"px,"+dy+"px) " : "";
			}
			//var offs = (dx != undefined ) ? ( $.support.hw3dTransform ? "translate3d("+dx+"px,"+dy+"px,0) " : "translate("+dx+"px,"+dy+"px) ") : ( $.support.hw3dTransform ? "translateZ(0) " : "");
			$(el).css(transformOriginProperty,origin).css(transformProperty,offs+"scale("+ratio+")");
		} else if ($.browser.msie) {
			var style = el.style;
			var matrixFilter = 'progid:DXImageTransform.Microsoft.Matrix(FilterType="'+scalingMode+'",M11='+ratio+',M12=0,M21=0,M22='+ratio+',Dx='+dx+',Dy='+dy+')';
			var filter = style.filter || $.curCSS( el, "filter" ) || "";
			style.filter = rmatrix.test(filter) ? filter.replace(rmatrix, matrixFilter) : filter ? filter + ' ' + matrixFilter : matrixFilter;
		}
	}

	$.fn.transform = function(ratio,dx,dy,w,h) {
		
		this.each(function() {
			transform(this,ratio,dx,dy,w,h);
		});
		
		return this;		 
	};	
		
})(jQuery);

		

 
// Init style shamelessly stolen from jQuery http://jquery.com
var Froogaloop = (function(){

    // Define a local copy of Froogaloop
    function Froogaloop(iframe) {
        // The Froogaloop object is actually just the init constructor
        return new Froogaloop.fn.init(iframe);
    }

    var eventCallbacks = {},
        hasWindowEvent = false,
        slice = Array.prototype.slice;

    Froogaloop.fn = Froogaloop.prototype = {
        playerDomain: '',

        element: null,

        init: function(iframe) {
            if (typeof iframe === "string") {
                iframe = document.getElementById(iframe);
            }

            this.element = iframe;
            return this;
        },

        /*
         * Calls a function to act upon the player.
         *
         * @param {string} method The name of the Javascript API method to call. Eg: 'play'.
         * @param {Array|Function} valueOrCallback params Array of parameters to pass when calling an API method
         *                                or callback function when the method returns a value.
         */
        api: function(method, valueOrCallback) {
            if (!this.element || !method) {
                return false;
            }

            var self = this,
                element = self.element,
                target_id = element.id != '' ? element.id : null,
                params = !isFunction(valueOrCallback) ? valueOrCallback : null,
                callback = isFunction(valueOrCallback) ? valueOrCallback : null;

            // Store the callback for get functions
            if (callback) {
                storeCallback(method, callback, target_id);
            }

            postMessage(method, params, element);
            return self;
        },

        /*
         * Registers an event listener and a callback function that gets called when the event fires.
         *
         * @param eventName (String): Name of the event to listen for.
         * @param callback (Function): Function that should be called when the event fires.
         */
        addEvent: function(eventName, callback) {
            if (!this.element) {
                return false;
            }

            var self = this,
                element = self.element,
                target_id = element.id != '' ? element.id : null;


            storeCallback(eventName, callback, target_id);
            
            // The ready event is not registered via postMessage. It fires regardless.
            if (eventName != 'ready') {
                postMessage('addEventListener', eventName, element);
            }

            // Register message event listeners
            if (hasWindowEvent) {
                return self;
            }

            playerDomain = getDomainFromUrl(element.getAttribute('src'));

            // Listens for the message event.
            // W3C
            if (window.addEventListener) {
                window.addEventListener('message', onMessageReceived, false);
            }
            // IE
            else {
                window.attachEvent('onmessage', onMessageReceived, false);
            }

            hasWindowEvent = true;
            return self;
        },

        /*
         * Unregisters an event listener that gets called when the event fires.
         *
         * @param eventName (String): Name of the event to stop listening for.
         */
        removeEvent: function(eventName) {
            if (!this.element) {
                return false;
            }

            var self = this,
                element = self.element,
                target_id = element.id != '' ? element.id : null,
                removed = removeCallback(eventName, target_id);

            // The ready event is not registered
            if (eventName != 'ready' && removed) {
                postMessage('removeEventListener', eventName, element);
            }
        }
    };

    /**
     * Handles posting a message to the parent window.
     *
     * @param method (String): name of the method to call inside the player. For api calls
     * this is the name of the api method (api_play or api_pause) while for events this method
     * is api_addEventListener.
     * @param params (Object or Array): List of parameters to submit to the method. Can be either
     * a single param or an array list of parameters.
     * @param target (HTMLElement): Target iframe to post the message to.
     */
    function postMessage(method, params, target) {
        if (!target.contentWindow.postMessage) {
            return false;
        }

        var url = target.getAttribute('src').split('?')[0],
            data = JSON.stringify({
                method: method,
                value: params
            });

        target.contentWindow.postMessage(data, url);
    }

    /**
     * Event that fires whenever the window receives a message from its parent
     * via window.postMessage.
     */
    function onMessageReceived(event) {
        // Handles messages from moogaloop only
        if (event.origin != playerDomain) {
            return false;
        }

        var data = JSON.parse(event.data),
            value = data.value,
            method = data.event || data.method,
            eventData = data.data,
            target_id = target_id == '' ? null : data.player_id,

            callback = getCallback(method, target_id),
            params = [];

        if (!callback) {
            return false;
        }

        if (value !== undefined) {
            params.push(value);
        }

        if (eventData) {
            params.push(eventData);
        }

        if (target_id) {
            params.push(target_id);
        }

        return params.length > 0 ? callback.apply(null, params) : callback.call();
    }


    /**
     * Stores submitted callbacks for each iframe being tracked and each
     * event for that iframe.
     *
     * @param eventName (String): Name of the event. Eg. api_onPlay
     * @param callback (Function): Function that should get executed when the
     * event is fired.
     * @param target_id (String) [Optional]: If handling more than one iframe then
     * it stores the different callbacks for different iframes based on the iframe's
     * id.
     */
    function storeCallback(eventName, callback, target_id) {
        if (target_id) {
            if (!eventCallbacks[target_id]) {
                eventCallbacks[target_id] = {};
            }
            eventCallbacks[target_id][eventName] = callback;
        }
        else {
            eventCallbacks[eventName] = callback;
        }
    }

    /**
     * Retrieves stored callbacks.
     */
    function getCallback(eventName, target_id) {
        if (target_id) {
            return eventCallbacks[target_id][eventName];
        }
        else {
            return eventCallbacks[eventName];
        }
    }

    function removeCallback(eventName, target_id) {
        if (target_id && eventCallbacks[target_id]) {
            if (!eventCallbacks[target_id][eventName]) {
                return false;
            }
            eventCallbacks[target_id][eventName] = null;
        }
        else {
            if (!eventCallbacks[eventName]) {
                return false;
            }
            eventCallbacks[eventName] = null;
        }

        return true;
    }

    /**
     * Returns a domain's root domain.
     * Eg. returns http://vimeo.com when http://vimeo.com/channels is sbumitted
     *
     * @param url (String): Url to test against.
     * @return url (String): Root domain of submitted url
     */
    function getDomainFromUrl(url) {
        var url_pieces = url.split('/'),
            domain_str = '';

        for(var i = 0, length = url_pieces.length; i < length; i++) {
            if(i<3) {domain_str += url_pieces[i];}
            else {break;}
            if(i<2) {domain_str += '/';}
        }

        return domain_str;
    }

    function isFunction(obj) {
        return !!(obj && obj.constructor && obj.call && obj.apply);
    }

    function isArray(obj) {
        return toString.call(obj) === '[object Array]';
    }

    // Give the init function the Froogaloop prototype for later instantiation
    Froogaloop.fn.init.prototype = Froogaloop.fn;

    // Expose froogaloop to the global object
    return (window.Froogaloop = Froogaloop);

})(); 
(function($) {

	$.pixelentity = $.pixelentity || {version: '1.0.0'};
	
	$.pixelentity.video = {	
		conf: { 
		} 
	};
	
	function PeVideo(t, conf) {
		var self = this;
		var jthis = $(this);
		var target = t;
		var player;
		var checkTimer;
		
		function start() {
			switch (conf.type) {
				case "youtube":
					$.pixelentity.youtube(youtubePlayerReady);
				break;
				case "vimeo":
					$.pixelentity.vimeo(vimeoPlayerReady);
				break;
			}
		} 
		
		
		function youtubePlayerReady(ytplayer) {
			player = new ytplayer(target[0], {
				height: conf.height,
				width: conf.width,
				videoId: conf.videoId,
				playerVars: {
					theme: "dark",
					wmode: "opaque",
					autohide: 0,
					enablejsapi: 1,
					origin: location.href.match(/:\/\/(.[^\/]+)/)[1],
					loop: conf.loop ? 1 : 0,
					autoplay: conf.autoPlay ? 1 : 0,
					showinfo:0,
					iv_load_policy:3,
					modestbranding:1,
					showsearch:0,
					fs:0
				},
				events: {
				  'onStateChange': ytStateChange
				}
			});
			checkTimer = setInterval(ytStateChange,250);
		}
		
		function vimeoPlayerReady(vimeoplayer) {
			player = new vimeoplayer(target[0], {
				height: conf.height,
				width: conf.width,
				videoId: conf.videoId,
				playerVars: {
					autohide: 0,
					origin: location.href.match(/:\/\/(.[^\/]+)/)[1],
					loop: conf.loop ? 1 : 0,
					autoplay: conf.autoPlay ? 1 : 0
				}
			});
			$(player).one("pixelentity.video_ended",vimeoVideoEnded);
		}
		
		function vimeoVideoEnded() {
			jthis.trigger("pixelentity.video_ended");
		}
		
		function ytStateChange() {
			if (!player) {return;}
			
			switch (player.getPlayerState()) {
				case YT.PlayerState.ENDED:
					jthis.trigger("pixelentity.video_ended");
				break;
				case YT.PlayerState.PLAYING:
					if ((player.getDuration()-player.getCurrentTime()) < 0.4) {
						jthis.trigger("pixelentity.video_ended");
					}
				break;
				
			}
		}
		
		$.extend(self, {
			bind: function(ev,hander) {
				jthis.bind(ev,handler);
			},
			destroy: function() {
				clearInterval(checkTimer);
				if (jthis) {
					jthis.remove();
				}
				jthis = self = undefined;
				if (player) {
					$(player).unbind("pixelentity.video_ended");
					player.destroy();
				}
				player = undefined;
				target.data("peVideo", null);
				target = undefined;
				
			}
		});
		
		start();
		
		
	}
	
	// jQuery plugin implementation
	$.fn.peVideo = function(conf) {
		// return existing instance
		
		var api = this.data("peVideo");
		
		if (api) { 
			return api; 
		}

		conf = $.extend(true, {}, $.pixelentity.video.conf, conf);
		
		// install kb for each entry in jQuery object
		this.each(function() {
			api = new PeVideo($(this), conf);
			$(this).data("peVideo", api); 
		});
		
		return conf.api ? api: this;		 
	};
	
		
})(jQuery); 
(function($) {

	$.pixelentity = $.pixelentity || {version: '1.0.0'};

	$.pixelentity.kenburnsImg = {	
		conf: { 
			zoom	: 'random',
			align	: 'random',
			pan		: 'random',
			duration: '15',
			paused	: false
		} 
	};
	
	var scaleCSS = {
		width: 0,
		height: 0,
		"margin-left": 0,
		"margin-top" : 0
	};
	
	// align/pan values
	var valign = ["top","center","bottom"];
	var halign = ["left","center","right"];
	
	var useCSS = false;
	var useCanvas = false;
	var blackBackground = false;
	var isIE9 = $.browser.msie && $.browser.version > 8;
	//isIE9 = false
	
	// check for css transforms 
	if ($.browser.msie) {
		useCSS = true;
		blackBackground = $.browser.msie;
	} /*
	  // only enable for iDevices, causes bug on chrome 13
	  else if ($.support.hw3dTransform) {
		useCSS = true;
	}
	*/
	
	// check for canvas support
	if (!useCSS && !!document.createElement('canvas').getContext) {
		useCanvas = true;
	}
	
	var iDev = navigator.userAgent.toLowerCase().match(/(iphone|ipod|ipad)/);
	
	if (iDev) {
		useCSS = true;
		useCanvas = false;
	}
	
	function transform(target,canvas,tw,th,ratio,offsX,offsY) {
	
		if (useCanvas) {		
			if (canvas) {
				canvas.drawImage(target[0],offsX,offsY,tw*ratio,th*ratio);
			}
		} else if (useCSS) {
			if (target) {
				target.transform(ratio,offsX,offsY,tw,th);
			}
		} else {
			scaleCSS.width = tw*ratio;
			scaleCSS.height = th*ratio;
			scaleCSS["margin-left"] = offsX;
			scaleCSS["margin-top"] = offsY;		
			if (target) {
				target.css(scaleCSS);
			}
		}
	}
	
	function KenBurns(t, conf) {

		/* private vars */

		var self = this;
		var target = t;

		if (useCanvas) { 
			t.hide();
		}

		var tw,th,w,h,ratioFrom,ratioTo,xFrom,xTo,yFrom,yTo,xPrev,yPrev,counter,duration = 500,repeat = 0,canvas, canvasDom;
		var zoom,pan,align;
		var paused = false;
	
		
		// get a scaler object
		function computeValues() {
		
			var scaler;
		
			// deal with loop
			if (repeat > 0) {
				// not first run, save last scale ratio
				xFrom = xTo;
				yFrom = yTo;
				ratioFrom = ratioTo;
			} else {
				// get the scaler using conf options
				scaler = $.pixelentity.Geom.getScaler(zoom == "out" ?  "fill" : "none",align.w,align.h,w,h,tw,th);
				xFrom = scaler.offset.w;
				yFrom = scaler.offset.h;
				ratioFrom = scaler.ratio;
			}
			
			scaler = $.pixelentity.Geom.getScaler(zoom == "in" ?  "fill" : "none",pan.w,pan.h,w,h,tw,th);
			xTo = scaler.offset.w;
			yTo = scaler.offset.h;
			ratioTo = scaler.ratio;
				
			xPrev = 0;
			yPrev = 0;
				
			duration = parseFloat(conf.duration)*33;
				
			// reset counter
			counter = isIE9 ? 20 : 0;
			
			// update runs count
			repeat++;
			
		}
		
		function randomSpot() {
			return valign[parseInt(Math.random()*2+0.5,10)]+","+halign[parseInt(Math.random()*2+0.5,10)];
		}
		
		function computeSettings() {
			
			zoom = conf.zoom == "random" ? (Math.random() > 0.5 ? "out" : "in") : conf.zoom	;
			//if (iDev) zoom = "none";			
			align = $.pixelentity.Geom.splitProps(conf.align == "random" ? randomSpot() : conf.align);
			pan = $.pixelentity.Geom.splitProps(conf.pan == "random" ? randomSpot() : conf.pan);
		
		}
		
		
		function worker() {
			if (paused) { return; }
			var now = counter/duration;
			var ratio = ratioFrom+(ratioTo-ratioFrom)*now;
			var offsX = xFrom+(xTo-xFrom)*now;
			var offsY = yFrom+(yTo-yFrom)*now;
		
			transform(target,canvas,tw,th,ratio,offsX,offsY);
			counter++;
			
			if ((counter+(isIE9 ? 20 : 0)) > duration) {
				self.pause();
				//self.stop()
			}
			
		}
	
			 
		$.extend(self, {
			init: function(e) {
				tw = t.width() || t[0].width;
				th = t.height() ||  t[0].height;
				
				var el = t.parent();
				
				while (el && !el.width()) {
					el = el.parent();
				}
				
				w = el ? el.width() : 800;
				h = el ? el.height() : 600;
				
				target.css("image-rendering","optimizeQuality").css("-ms-interpolation-mode","bicubic");
				if (blackBackground) {
					target.parent().css("background-color","black");
				}
				self.start();
			},
			
			
			
			start: function() { 
				repeat = 0;
				computeSettings();
				computeValues();
				paused = false; /* check this */
				if (useCanvas) {
					if (!canvas) {
						canvasDom = $('<canvas width="'+w+'" height="'+h+'"></canvas>');
						canvas = canvasDom[0];
						target.hide().after(canvasDom);
						canvas = canvas.getContext("2d");
						canvas.fillStyle = "rgb(255,255,255)";
					} 
				}
				
				if (conf.paused) {
					worker();
					paused = true;
				} 
				
				
				$.pixelentity.ticker.register(worker);
			},
			
			stop: function() {
				$.pixelentity.ticker.unregister(worker);
			},
			
			reset: function() {
				paused = true;
				repeat = 0;
				computeSettings();
				computeValues();
				paused = false;
				//transform(target,canvas,tw,th,ratio,0,0)
			},
			
			getTarget: function() {
				if (canvasDom) {
					return canvasDom;
				}
				return target;
			},
			
			pause: function() {
				paused = true;
			},
			
			resume: function() {
				paused = false;
			},
			
			destroy: function() {
				self.paused = true;
				self.stop();
				if (useCanvas && canvasDom) {
					canvasDom.remove();
					canvasDom = undefined;
					canvas = undefined;
				}
				self = undefined;
				target.data("peKenburnsImg", null);
				target = undefined;		
			}
		
		});
		
		//if (t.width() == 0 && t[0].width == 0) {
		if ((!t.width()) && (!t[0].width)) {
			t.one("load",self.init);
		} else {
			self.init();
		}
		
	}
		
	
	// jQuery plugin implementation
	$.fn.peKenburnsImg = function(conf) {
		// return existing instance
		
		var api = this.data("peKenburnsImg");
		
		if (api) { 
			api.start();
			return api; 
		}

		conf = $.extend(true, {}, $.pixelentity.kenburnsImg.conf, conf);
		
		// install kb for each entry in jQuery object
		this.each(function() {
			api = new KenBurns($(this), conf); 
			$(this).data("peKenburnsImg", api); 
		});
		
		return conf.api ? api: this;		 
	};
		
})(jQuery);

		

 
(function ($) {

    $.pixelentity = $.pixelentity || { version: '1.0.0' };

    $.pixelentity.kenburnsSlider = {
        conf: {
            externalFont: false
        }
    };

    // common stuff

    function _rgb2hex(rgb_string, r, g, b) {
        var rgb = (1 << 24) | (parseInt(r, 10) << 16) | (parseInt(g, 10) << 8) | parseInt(b, 10);
        return '#' + rgb.toString(16).substr(1);
    }

    function KenBurnsSlider(t, conf) {

        /* private vars */
        var self = this;
        var target = t.addClass("peKenBurns").removeClass("peNoJs");
        var hoverMode = false;

        if (target.is("img")) {
            var hasLink = false;
            if (t.parent().is("a")) {
                hasLink = true;
            }
            var imgHtml = '<img src="' + t.attr("src") + '" data-src="' + (t.attr("data-src") || "") + '"/>';
            var newTarget = $('' +
'<div class="peKenBurns" data-autopause="none" data-controls="disabled" data-shadow="' + (t.attr("data-shadow") || "disabled") + '" data-logo="disabled">' +
		'<div class="peKb_slides" >' +
		'<div class="peKb_active" data-delay="' + (t.attr("data-delay") || "3") + '" data-duration="' + (t.attr("data-duration") || "10") + '">' +
			imgHtml +
			(t.attr("alt") ? '<h1>' + t.attr("alt") + '</h1>' : '') +
		'</div>' +
		'<div data-delay="' + (t.attr("data-delay") || "3") + '" data-duration="' + (t.attr("data-duration") || "15") + '">' +
			imgHtml +
		'</div>' +
	'</div>' +
'</div>' +
			'');

            t.replaceWith(newTarget);
            target = t = newTarget;
            t.data("peKenburnsSlider", this);

            if (hasLink) {
                t.css("cursor", "pointer");
            }

            hoverMode = true;
        } else {
            t.css({
                "background-color": "transparent",
                "-moz-border-radius": "0px",
                "-webkit-border-radius": "0px",
                "border-radius": "0px",
                "padding": "0px"
            });
        }

        var kenburns = $.pixelentity && $.pixelentity.kenburnsImg && (t.attr("data-mode") != "swipe");

        var pauseOnControls = false;
        var pauseOnImage = true;

        (function () {
            var pauseon = t.attr("data-autopause");
            if (pauseon) {
                pauseOnControls = pauseon.match(/controls/) !== null;
                pauseOnImage = pauseon.match(/image/) !== null;
            }
        })();

        var spinner = $('<div class="peKb_spinner"></div>');
        var videoOverlay = $('<div class="peKb_videooverlay"></div>');

        var captionOverlay = "";
        if (t.attr("data-captions") != "disabled") {
            captionOverlay = $('<div class="peKb_caption"></div>');
        }

        var thumbOverlay = false;
        if (t.attr("data-thumb") != "disabled") {
            thumbOverlay = $('<div class="peKb_Thumb"><div>');
            var thumbDiv = thumbOverlay.find("div");
            var thumbImg = thumbOverlay.find("img");
            var thumbActive = false;
        }
        var timerWidget = $('<div class="peKb_timer"><div class="peKb_overlay"></div></div>');
        var timerWidgetCanvas;
        var timerWidgetSprite;
        var timerWidgetSize;
        var timerWidgetColor;
        var timerControllerInterval;

        var transitionSpeed = 800;
        var currentSlide = 0;
        var currentSlideEl;
        var currentSlideA;
        var previousSlide = -1;
        var previusCaption;
        var slides = [];
        var locked = false;
        var timerWidgetLocked = false;
        var w = t.width();
        var h = t.height();

        var thumbUseFade = !($.browser.msie && $.browser.version >= 7 && $.browser.version < 9);

        var videoPlayback = false;
        var videoPlayer;
        var countMax = 0;
        var countdown = -1;
        var paused = false;
        var focused = false;
        var panelDisabled = false;
        var hideControlsOnFirst = false;
        var hideControlsOnFirstTimer = 0;
        var captionsResized = false;
        var captionDelayedResize = false;
        var hasActiveThumb = false;

        var useShadow = (t.attr("data-shadow") != "disabled");
        var useControls = (t.attr("data-controls") != "disabled");
        var innerControls = (t.attr("data-controls") == "inner");

        var useLabel = (t.attr("data-logo") == "enabled");
        var iDev = navigator.userAgent.toLowerCase().match(/(iphone|ipod|ipad)/);

        if (useLabel) {
            // set overflow back
            t.css("overflow", "visible");
        }

        if (hoverMode && useShadow) {
            h -= 36;
        }

        if (!hoverMode && useShadow && !useControls) {
            h -= 50;
        }

        if (!hoverMode && !useShadow && innerControls) {
            h += 50;
        }

        var allSlides = t.find("div.peKb_slides");
        if (allSlides.length === 0) {
            t.wrapInner('<div class="peKb_slides"></div>');
            allSlides = t.find("div.peKb_slides");
        }

        var padding = parseInt(allSlides.css("padding-left").replace(/px/, ""), 10) || 0;

        var controlsHTML = '';

        if (useControls) {
            controlsHTML +=
'<div class="peKb_controls">' +
	'<div class="peKb_holder">' +
		'<div class="peKb_mainPanel">' +
			'<div class="peKb_iebg">' +
				'<ul class="peKb_slideBtns">' +
					'<li><a href="#" class="peKb_currentSlide">1</a></li>' +
				'</ul>' +
				'<div class="peKb_arrows">' +
					'<a class="peKb_prev" href="#">p</a>' +
					'<a class="peKb_next" href="#">n</a>' +
				'</div>' +
				'<span class="peKb_iebgRight"></span>' +
			'</div>' +
		'</div>' +
		'<div class="peKb_videoClose">' +
			'<a href="#">close</a>' +
		'</div>' +
    '</div>' +
'</div>';
        }

        if (useLabel) {
            controlsHTML +=
'<div class="peKb_logoLabel">' +
    '<a href="' + (t.attr("data-logo-link") || "#") + '" target="' + (t.attr("data-logo-target") || "_self") + '" >logo</a>' +
'</div>';
        }

        if (useShadow) {
            controlsHTML +=
'<div class="peKb_shadow">' +
    '<div class="peKb_left"></div>' +
    '<div class="peKb_middle"></div>' +
    '<div class="peKb_right"></div>' +
'</div>';
        }

        var controls = controlsHTML ? $(controlsHTML) : false;
        var controlsHeight = 0;

        if (controls) {

            if ($.browser.msie) {
                var ieCssFix = "";
                if ($.browser.version < 10) {
                    t.wrap('<div class="ie' + Math.floor($.browser.version) + '"></div>');
                }
            }

            allSlides.after(controls);
            if (innerControls) {
                var controlsMarkup = controls.filter(".peKb_controls");

                controls.addClass("peKb_controlsInner");

                controlsHeight = controls.height();
                //controlsMarkup.css("margin-top", "0px"); // _JK
                controlsMarkup.css("margin-top", -controlsHeight - padding + 10 + (iDev ? 1 : 0));


            } else if (padding != 15) {
                controls.filter(".peKb_controls").css("margin-top", -(padding + 1));
            }

            if (useShadow) {
                var sh = controls.filter(".peKb_shadow").css("z-index", "0");
                allSlides.before(sh);
            }

        }

        function prevNextHandler(e) {
            direction = $(e.currentTarget).hasClass("peKb_next") ? "next" : "prev";
            showSlide(prevNextIndex(currentSlide, direction));
            return false;
        }

        function buttonCloseVideo() {
            stopVideo();
            return false;
        }

        if (useControls) {
            allSlides.before(timerWidget.hide());
            timerWidgetColor = timerWidget.css("color").replace(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/g, _rgb2hex);


            var overlay = timerWidget.find(".peKb_overlay");
            timerWidgetSize = (overlay.width() || 22);

            if (document.createElement('canvas').getContext) {
                timerWidgetCanvas = $('<canvas width="' + timerWidgetSize + '" height="' + timerWidgetSize + '"></canvas>');

                overlay.after(timerWidgetCanvas);
                timerWidgetCanvas = timerWidgetCanvas[0].getContext('2d');
            } else {
                timerWidgetSprite = $('<div class="peKb_sprite"></div>');
                timerWidget.find(".peKb_overlay").after(timerWidgetSprite);
            }

            controls.find(".peKb_prev, .peKb_next")
				.click(prevNextHandler)
			.end();

            controlsHeight = controls.height();

            var pager = controls.find("ul.peKb_slideBtns").empty();
            var closeVideo = controls.find(".peKb_videoClose");
            var mainPanel = controls.find(".peKb_mainPanel");

            var closeVideoHideProp = ($.browser.msie && $.browser.version >= 8 && $.browser.version < 9) ? "top" : "margin-top";

            closeVideo.find("a").click(buttonCloseVideo).end();

            if (innerControls) {
                closeVideo.fadeOut(0);
            } else {
                closeVideo.css(closeVideoHideProp, -controlsHeight);
            }
        }

        var rw = w - 2 * padding;
        var rh = h - 2 * padding - controlsHeight;

        if (useShadow) {
            var shadow = t.find(".peKb_shadow");
            shadow.width(w).find(".peKb_middle").width(w - shadow.find(".peKb_left").width() - shadow.find(".peKb_right").width());
        }

        //allSlides.after(thumbOverlay)
        t.append(thumbOverlay);

        if (thumbOverlay) {
            var offs = t.offset();
            offs.top = offs.top + rh + padding - thumbOverlay.height() + 13;
            if (innerControls) {
                offs.top -= controlsHeight - 10;
            }
            thumbOverlay.data("top", offs.top);
            thumbOverlay.offset(offs);
            thumbOverlay.hide();
        }

        //flashEnabled = $.flash.available;
        flashEnabled = true;

        var box = {
            width: rw,
            height: rh,
            left: 0,
            overflow: "hidden",
            visible: true,
            display: "block",
            opacity: 0
        };

        var direction = "next";

        var jqSlides = allSlides.width(rw).height(rh).find(" > div");
        var frame = $('<div class="peKb_frame"></div>').width(rw).height(rh);
        //allSlides.prepend(frame);

        function eventHandler(e) {
            hideControlsOnFirst = false;
            if (hideControlsOnFirstTimer) {
                clearTimeout(hideControlsOnFirstTimer);
            }

            if (e.currentTarget == t[0]) {
                switch (e.type) {
                    case "mouseenter":
                        if (pauseOnControls) {
                            paused = true;
                        }
                        showControls();
                        break;
                    case "mouseleave":
                        if (!videoPlayback && pauseOnControls) {
                            paused = false;
                        }
                        hideControls();
                        break;
                }
            } else {
                switch (e.type) {
                    case "mouseenter":
                        if (hoverMode) {
                            paused = false;
                            kbProxy().resume();
                            showCaption(0);
                        } else {
                            if (pauseOnImage) {
                                paused = true;
                            }
                        }
                        focused = true;
                        break;
                    case "mouseleave":
                        if (hoverMode) {
                            paused = true;
                            kbProxy().pause();
                            showCaption(1);
                        } else {
                            if (!videoPlayback && pauseOnImage) {
                                paused = false;
                            }
                        }
                        focused = false;
                        break;
                }
            }
        }

        t
			.find("div.peKb_slides")
				.append(spinner)
				.append(videoOverlay)
				.append(captionOverlay)
				.bind("mouseenter", eventHandler)
				.bind("mouseleave", eventHandler)
			.end();

        var captionMarginBottom = 0;
        var captionMarginLeft = 0;

        if (captionOverlay) {
            captionMarginBottom = parseInt(captionOverlay.css("margin-bottom").replace(/px/), 10);
            captionMarginLeft = parseInt(captionOverlay.css("margin-left").replace(/px/), 10);
        }


        if (!kenburns) {
            allSlides.wrapInner('<div class="peKb_slides"></div>');
            var inner = allSlides.find("> div");
            inner.width(rw).height(rh).css({
                position: "absolute",
                "border-width": 0,
                "border-radius": 0,
                "background-image": "none",
                "background-color": frame.css("background-color"),
                "z-index": 1,
                top: padding,
                left: padding,
                padding: "0px",
                margin: "0px"
            }).show();
            if (captionOverlay) {
                captionOverlay.width(rw).height(rh);
            }
        } else {
            jqSlides.css("margin-left", padding);
            if (captionOverlay) {
                captionOverlay.width(rw).height(rh).css("margin-top", padding).css("margin-left", padding);
            }
        }

        allSlides.prepend(frame);

        var bgcolor = frame.css("background-color").replace(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/g, _rgb2hex);

        function doTransition(from, to, tType) {
            tType = from ? tType : "fade";
            transitionSpeed = tType == "swipe" ? 700 : 1000;

            currentSlideEl = to;

            function reset() {
                unlock();
                if (from) {
                    from.fadeOut(0);
                    from.find("img:eq(0)").css("margin-left", 0);
                }
            }

            if (from) {
                var kb = from.find("img:eq(0)").data("peKenburnsImg");
                if (kb) {
                    kb.stop();
                }
            }

            var gotcha;

            if (to.find("a.video").length > 0) {
                videoOverlay.empty().removeClass("peKb_noBack").fadeIn(0);
                if (!flashEnabled) {
                    gotcha = $("<a>");
                    gotcha.attr("href", to.find("a.video").attr("href")).attr("target", "_blank");
                    gotcha.width(videoOverlay.width()).height(videoOverlay.height()).css("position", "absolute").show();
                    videoOverlay.empty().append(gotcha);
                } else if (to.find("a.video").hasClass("autostart")) {
                    if (videoPlayback) {
                        setTimeout(function () {
                            videoOverlay.triggerHandler("click");
                        }, 500);
                    } else {
                        videoOverlay.triggerHandler("click");
                    }
                }
            } else if (to.find("a").length > 0) {
                videoOverlay.fadeIn(0);

                gotcha = $("<a>");

                // copy event listeners attached to original element
                $.each(to.find("a").data("events"), function (type, event) {
                    $.each(event, function (j, h) {
                        gotcha.bind(type, h.handler);
                    });
                });

                gotcha.attr("href", to.find("a").attr("href")).attr("target", to.find("a").attr("target"));
                gotcha.width(videoOverlay.width()).height(videoOverlay.height()).css("position", "absolute").show();
                videoOverlay.empty().addClass("peKb_noBack").append(gotcha);
            } else {
                videoOverlay.empty().removeClass("peKb_noBack").fadeOut(0);
            }

            switch (tType) {
                case "fade":
                    if (from) {
                        from.css(box).css("opacity", 1).fadeTo(transitionSpeed, 0);
                    }
                    to.css(box).css("opacity", 0).fadeTo(transitionSpeed, 1, unlock);
                    break;
                case "whitefade":
                    to.css(box).css("opacity", 0);
                    from.css(box).css("opacity", 1).fadeTo(transitionSpeed / 2, 0, "easeOutQuad", function () {
                        to.fadeTo(transitionSpeed / 2, 1, "easeInQuad", unlock);
                    });
                    break;
                case "flyBy":
                    if (direction == "next") {
                        if (from) {
                            from.css(box).css("opacity", 1);
                        }
                        to.css(box).css("left", 50);
                        if (from) {
                            from.animate({ left: -100, opacity: 0 }, transitionSpeed, "easeOutCubic");
                        }
                        to.animate({ left: 0, opacity: 1 }, transitionSpeed, "easeOutCubic", unlock);
                    } else {
                        if (from) {
                            from.css(box).css("opacity", 1);
                        }
                        to.css(box).css("left", -50);
                        if (from) {
                            from.animate({ left: 100, opacity: 0 }, transitionSpeed, "easeOutCubic");
                        }
                        to.animate({ left: 0, opacity: 1 }, transitionSpeed, "easeOutCubic", unlock);
                    }
                    break;
                case "swipe":

                    var img;
                    var flyBy = 100;

                    to.css(box);
                    if (from) {
                        from.css(box).css("opacity", 1);
                    }

                    img = (direction == "next") ? to.find("img:eq(0)") : from ? from.find("img:eq(0)") : null;

                    function prevTransition(now, fx) {
                        var size = Math.round(now * rw);
                        var offs = Math.round(flyBy * (1 - now));
                        to.css("left", -offs).width(size + flyBy);
                        if (img) {
                            img.css("margin-left", -size);
                        }
                        if (from) {
                            from.css("opacity", 0.5 + 0.5 * (1 - now)).css("left", size + flyBy - offs).width(rw - size);
                        }

                    }

                    function nextTransition(now, fx) {
                        var size = Math.round(now * rw);
                        var offs = Math.round(flyBy * (1 - now));
                        to.css("left", rw - size + offs).width(size);
                        if (img) {
                            img.css("margin-left", size - rw);
                        }
                        if (from) {
                            from.css("opacity", 0.5 + 0.5 * (1 - now)).css("left", offs - flyBy).width(rw - size + flyBy);
                        }
                    }

                    to.animate({ opacity: 1 }, {
                        duration: transitionSpeed,
                        easing: "easeOutCubic",
                        complete: reset,
                        step: direction == "next" ? nextTransition : prevTransition

                    });



                    break;


            }
        }

        function resourceLoaded(e) {
            locked = false;
            showSlide(parseInt(e.target.id, 10), true);
        }

        function unlock() {
            locked = false;
        }

        function preloadResource(idx, cb) {
            var resource = slides[idx].resource;
            if (!resource) {
                return true;
            }
            var lazyLoadSrc = $(resource).attr("src") ? "" : $(resource).attr("data-src");
            if (lazyLoadSrc) {
                $(resource).attr("src", lazyLoadSrc);
            }
            if (!resource.complete) {
                if (cb) {
                    $(resource).one("error", cb).one("load", cb);
                }
            }
            return resource.complete;
        }

        function timerWidgetPosition() {
            if (!panelDisabled && currentSlideA && !timerWidgetLocked) {
                timerWidget.show().offset(currentSlideA.offset());
            }
        }

        function timerWidgetUnlock() {
            timerWidgetLocked = false;
            timerWidgetPosition();
        }

        function hilightButton(idx) {
            if (pager) {
                currentSlideA = pager.find("a").removeClass("peKb_currentSlide").eq(idx).addClass("peKb_currentSlide");

                timerWidgetUpdate(0);
                timerWidgetPosition();
            }
        }

        function showCaption(idx) {
            if (!captionsResized) {
                return;
            }

            var currentCaption = slides[idx].caption;
            var real;
            var back;

            if (currentCaption) {
                real = currentCaption.find(".peKb_real");
                back = currentCaption.find(".peKb_background");

                real.css("margin-left", 10).css("opacity", 0).width(0).show();
                back.css("margin-left", 100).css("opacity", 0).width(0).show();

                real.stop(true).delay(hoverMode ? 500 : 500).animate({ "margin-left": 0, opacity: 1, width: back.data("width") }, 1000, "easeOutCubic");
                back.stop(true).delay(hoverMode ? 0 : 200).animate({ "margin-left": 0, opacity: 0.5, width: back.data("width") }, 1000, "easeOutCubic");
            }

            if (previusCaption) {
                real = previusCaption.find(".peKb_real");
                back = previusCaption.find(".peKb_background");


                real.stop(true).fadeTo(hoverMode ? 0 : 500, 0);
                back.stop(true).fadeTo(hoverMode ? 0 : 500, 0);

            }

            previusCaption = currentCaption;

        }

        function showSlide(idx, loaded) {
            if (previousSlide != idx && !locked) {
                locked = true;

                if (!loaded && !preloadResource(idx, resourceLoaded)) {
                    spinner.fadeIn(500);
                    return;
                }

                var autostartVideo = jqSlides.eq(idx).find("a.video.autostart").length > 0;
                stopVideo(autostartVideo);

                preloadResource(prevNextIndex(idx, "next"));

                if (!hoverMode) {
                    hilightButton(idx);
                    showCaption(idx);
                }

                currentSlide = previousSlide = idx;
                if (!autostartVideo) {
                    spinner.fadeOut(100);
                }

                var from = jqSlides.filter(".peKb_active").removeClass("peKb_active");
                var to = jqSlides.eq(idx).addClass("peKb_active");

                var tType = to.attr("data-transition") || "swipe";
                var kbTarget;

                if (kenburns) {
                    kbTarget = to.find("img");
                    if (kbTarget) {
                        tType = "fade";
                    }
                }


                var delay = to.attr("data-delay");
                if (delay) {
                    countMax = countdown = parseFloat(delay) * 20;
                } else {
                    countMax = countdown = -1;
                    timerWidgetUpdate(360);
                }


                // msie bug fix ....
                to.show().fadeOut(0);

                if (kbTarget) {
                    kbTarget = kbTarget.peKenburnsImg({
                        zoom: to.attr("data-zoom"),
                        align: to.attr("data-align"),
                        pan: to.attr("data-pan"),
                        duration: to.attr("data-duration"),
                        paused: hoverMode,
                        api: true
                    });
                    if (hoverMode && focused) {
                        kbTarget.resume();
                    }
                }



                doTransition(from[0] ? from : null, to, tType);

                // hide panel on first time
                if (hideControlsOnFirst) {
                    hideControlsOnFirst = false;
                    hideControlsOnFirstTimer = setTimeout(hideControls, 1000);
                }


            }
        }

        function timerWidgetUpdate(angle) {

            if (!pager) {
                return;
            }

            if (timerWidgetCanvas) {

                var size = timerWidgetSize - 1;
                var cx = timerWidgetSize / 2;
                var cy = cx + 1;

                timerWidgetCanvas.clearRect(0, 0, timerWidgetSize, timerWidgetSize);
                if (angle > 0) {
                    timerWidgetCanvas.beginPath();
                    timerWidgetCanvas.moveTo(cx, cy);

                    timerWidgetCanvas.arc(cx, cy, size / 2, (270 / 360) * 2 * Math.PI, ((angle + 270) / 360) * 2 * Math.PI, false);

                    timerWidgetCanvas.lineTo(cx, cy);
                    timerWidgetCanvas.closePath();
                    timerWidgetCanvas.fillStyle = timerWidgetColor;
                    timerWidgetCanvas.fill();
                }

            } else {
                timerWidgetSprite.css("background-position-y", "-" + Math.round(12 - (12 * (angle / 360))) * timerWidgetSize + "px");
            }


        }

        function timerController() {
            if (paused || countdown < 0) {
                return;
            }
            timerWidgetUpdate(360 * (countMax - countdown) / countMax);

            if (countdown === 0) {
                showSlide(prevNextIndex(currentSlide, "next"));
            }
            countdown--;
        }

        function prevNextIndex(from, dir) {
            var nextIdx = from;
            nextIdx += (dir == "prev" ? -1 : 1);
            nextIdx %= slides.length;
            if (nextIdx < 0) {
                nextIdx += slides.length;
            }
            return nextIdx;
        }



        function navigatorHandler(e) {
            var idx = parseInt(e.currentTarget.id, 10);
            direction = idx >= currentSlide ? "next" : "prev";
            showSlide(idx);
            return false;
        }

        function resizeCaptions() {
            var caption;
            var animated;

            if (captionDelayedResize) {
                clearTimeout(captionDelayedResize);
            }
            for (var i = 0; i < slides.length; i++) {
                caption = slides[i].caption;
                if (caption) {
                    caption.width(rw);

                    animated = false;

                    var real = caption.find(".peKb_real");
                    var back = caption.find(".peKb_background");

                    if (caption == previusCaption) {
                        real.stop().css("margin-left", 0).css("opacity", 1);
                        back.stop().css("margin-left", 0).css("opacity", 0.5);
                        animated = true;

                    }

                    var cw;
                    var ch;

                    if (hoverMode) {
                        cw = rw - 2 * captionMarginBottom;
                    } else {
                        real.width("auto");
                        back.width("auto");
                        cw = real.outerWidth();
                    }

                    ch = real.outerHeight();

                    back.width(cw).height(ch).data("width", cw);

                    caption.width(cw).height(ch);

                    caption.css("margin-left", (rw - back.width()) / 2);
                    caption.css("margin-top", (rh - back.height() - captionMarginBottom - (innerControls ? (controlsHeight - 10) : 0)));

                    if (!animated) {
                        real.fadeOut(0);
                        back.fadeOut(0);

                    }
                }
            }
            captionsResized = true;
        }

        function parseSlide(idx, el) {
            var jqEl = $(el).attr("id", idx);
            var caption = jqEl.find(" > h1,h2,h3,h4,p").detach();

            if (captionOverlay && caption.length > 0) {
                caption.wrap('<div class="peKb_real" />');
                caption = caption.parent();
                caption.wrap('<div class="peKb_holder" />');
                caption = caption.parent();
                caption.append('<div class="peKb_background" />');

                captionOverlay.append(caption);

                caption.find(".peKb_real").fadeOut(0);
                caption.find(".peKb_background").fadeOut(0);

            } else {
                caption = false;
            }


            var resource = jqEl.find("img").attr({ id: idx })[0];
            var thumb = jqEl.attr("data-thumb");
            slides[idx] = { caption: caption, resource: resource, thumb: thumb };
            if (pager) {
                pager.append('<li><a href="#" ' + (idx === 0 ? 'class="peKb_currentSlide"' : '') + ' id="' + idx + '">1</a></li>');
            }
        }

        function clearVideo() {
            spinner.empty();
            videoPlayback = false;
            if (!focused) {
                paused = false;
            }
        }

        function showHideCloseButton(show) {
            if (innerControls) {
                if ($.browser.msie) {
                    closeVideo[show ? "show" : "hide"]();
                } else {
                    closeVideo.stop().fadeTo(300, show ? 1 : 0, "easeOutCubic");
                }
                showHideControls(!show);

            } else {
                var anim = {};
                anim[closeVideoHideProp] = (show ? 0 : -controlsHeight);
                closeVideo.stop().animate(anim, 300, "easeOutCubic");
            }
        }

        function showHideControls(show, speed) {
            if (!mainPanel) {
                return;
            }

            panelDisabled = !show;

            if (!show) {
                showHideThumb(false);
            }
            speed = speed == null ? 300 : speed;

            mainPanel.stop();
            if (!innerControls && videoPlayback) {
                showHideCloseButton(show);
            }

            timerWidget.hide();
            timerWidgetLocked = true;

            if (innerControls) {
                panelDisabled = false;
                if (!($.browser.msie && $.browser.version < 8)) {
                    controls.css("z-index", show ? 209 : 0);
                    if (show && useShadow) {
                        allSlides.before(controls.filter(".peKb_shadow").css("z-index", "0"));
                    }
                }

                if (show) {

                    controls.find(".peKb_holder").show();
                    timerWidgetUnlock();

                } else {
                    controls.find(".peKb_holder").hide();
                }

            } else {
                mainPanel.animate({ "margin-top": (show ? 0 : -controlsHeight) }, {
                    duration: speed,
                    easing: "easeOutCubic",
                    complete: timerWidgetUnlock
                });
            }
        }

        function showCloseButton() {
            showHideCloseButton(true);
        }

        function hideCloseButton() {
            showHideCloseButton(false);
        }

        function showControls(speed) {
            showHideControls(true, speed);
        }

        function hideControls(speed) {
            showHideControls(false, speed);
        }

        function stopVideo(anotherVideo) {
            if (videoPlayback) {
                if (videoPlayer) {
                    videoPlayer.destroy();
                    videoPlayer = undefined;
                }

                if (anotherVideo) {
                    spinner.empty();
                    videoPlayback = false;
                } else {
                    spinner.css("background-color", "none");
                    spinner.fadeOut(500, clearVideo);
                    videoOverlay.fadeIn(0);
                    hideCloseButton();
                }

                var kb = jqSlides.filter(".peKb_active").find("img:eq(0)").data("peKenburnsImg");
                if (kb) {
                    kb.resume();
                }
            }
            return false;
        }

        function loadResource(e) {
            var el = $(e.currentTarget);

            if (el.hasClass("video")) {
                loadVideo(el[0].href, el.hasClass("hd"), el.hasClass("autoplay"), el.hasClass("loop"), el.hasClass("skiptonext"));
                return false;
            }

            return true;
        }

        function loadVideo(url, hd, autoPlay, loop, skiptonext) {

            if (videoPlayback) {
                return false;
            }

            var id, type;

            if ((id = url.match(/http:\/\/www.youtube.com\/watch\?v=([\w|\-]+)/))) {
                type = "youtube";
            } else if ((id = url.match(/http:\/\/vimeo.com\/(\w+)/))) {
                type = "vimeo";
            }
            if (type) {

                stopVideo();

                videoPlayback = true;
                paused = true;

                var kb = jqSlides.filter(".peKb_active").find("img:eq(0)").data("peKenburnsImg");
                if (kb) {
                    kb.pause();
                }

                spinner.css("background-color", bgcolor);
                spinner.fadeIn(500);
                showCloseButton();
                videoOverlay.fadeOut(0);


                videoPlayer = spinner.peVideo({
                    api: true,
                    width: rw,
                    height: rh,
                    type: type,
                    videoId: id[1],
                    hd: hd,
                    autoPlay: autoPlay,
                    loop: loop
                });

                if (skiptonext) {
                    $(videoPlayer).bind("pixelentity.video_ended", videoEnded);
                }

            }
        }

        function videoEnded() {
            // yeah, i know but .once didn't work ....
            $(videoPlayer).bind("pixelentity.video_ended", videoEnded);
            showSlide(prevNextIndex(currentSlide, "next"));
        }

        function videoOverlayClick() {
            var videoLink = currentSlideEl.find("a.video");
            if (videoLink.length > 0) {
                videoLink.trigger("click");
            }
        }

        function thumbOverlayDisable() {
            thumbActive = false;
            thumbOverlay.hide();
        }

        function showHideThumb(show, delay) {
            if (!hasActiveThumb || !thumbOverlay) {
                return;
            }
            if (show) {
                thumbOverlay.stop(true);
                if (thumbUseFade) {
                    thumbOverlay.fadeTo(500, 1, "easeOutQuad");
                } else {
                    thumbOverlay.show();
                }
            } else {
                if (parseInt(delay, 10) > 0) {
                    thumbOverlay.delay(delay);
                } else {
                    thumbOverlay.stop(true);
                }
                if (thumbUseFade) {
                    thumbOverlay.fadeTo(300, 0, "easeOutQuad", thumbOverlayDisable);
                } else {
                    thumbOverlay.queue(thumbOverlayDisable);
                }
            }
        }

        function thumbImgLoaded(e) {

            if (e.type == "error") {
                thumbOverlayDisable();
                return;
            }

            thumbDiv.html(thumbImg);

            if (t.attr("data-thumb") != "fixed") {
                thumbImg.peKenburnsImg({
                    zoom: "in",
                    align: "top,center",
                    pan: "center,center",
                    duration: "10"
                });
            }


            thumbDiv.stop(true).fadeTo(0, 0).fadeTo(300, 1, "easeInQuad");



        }

        function thumbPreviewProxy(e) {
            if (currentSlideA) {
                currentSlideA.triggerHandler(e.type);
            }
        }

        function thumbPreview(e) {
            var idx = e.currentTarget.id;
            switch (e.type) {
                case "mouseenter":
                    var thumb = slides[idx].thumb;
                    if (!thumb) {
                        return;
                    }

                    hasActiveThumb = true;
                    showHideThumb(true);

                    var tw = $(e.currentTarget).width();

                    var offs = $(e.currentTarget).offset();

                    offs.top = thumbOverlay.data("top");

                    //offs.top = 0;  //_JK
                    offs.top = t.offset().top + rh + padding - thumbOverlay.height() + 13;
                    if (innerControls) {
                        offs.top -= controlsHeight - 10;
                    }

                    offs.left = offs.left - (thumbOverlay.width() - tw) / 2;

                    if (thumbActive != thumb) {
                        if (thumbImg.data("peKenburnsImg")) {
                            thumbImg.data("peKenburnsImg").destroy();
                        }
                        thumbImg = $("<img>");
                        thumbDiv.html("");
                        //thumbImg.load(thumbImgLoaded);
                        thumbImg.one("error", thumbImgLoaded).one("load", thumbImgLoaded);
                        thumbImg.attr("src", thumb);
                    }


                    thumbOverlay.offset(offs);
                    thumbActive = thumb;

                    break;
                case "mouseleave":
                    showHideThumb(false, 200);
                    break;
            }
        }

        function kbProxy() {
            var kbTarget;
            if (currentSlideEl) {
                kbTarget = currentSlideEl.find("img:eq(0)");
                if (kbTarget) {
                    kbTarget = kbTarget.data("peKenburnsImg");
                }
            }
            return kbTarget || false;
        }

        $.extend(self, {
            init: function (e) {

                // silly ie fix
                if ($.browser.msie) {
                    jqSlides
						.find("img[src*='blank.png']")
							.replaceWith(function () {
							    var ni = $("<img>");
							    return ni.attr("data-src", $(this).attr("data-src"))[0];
							})
						.end();
                }

                // silly ie9 fix
                if ($.browser.msie && $.browser.version > 8) {
                    jqSlides
						.find("img")
							.each(function () {
							    var jqImg = $(this);
							    if (!jqImg.attr("data-src")) {
							        jqImg.attr("data-src", jqImg.attr("src"));
							        jqImg.removeAttr("src");
							    }
							})
						.end();
                }

                spinner.width(rw).height(rh);
                videoOverlay.width(rw).height(rh);

                jqSlides
					.width(rw)
					.height(rh)
					.show()

					.fadeOut(0)
					.removeClass("peKb_active")

					.find("img[src*='blank.png']")
						.removeAttr("src")
					.end()
					.find("a")
						.click(loadResource)
					.end()
					.each(parseSlide)
				.end();


                if (useControls && mainPanel) {
                    mainPanel.css("margin-left", (w - mainPanel.width()) / 2);
                    if (innerControls) {
                        //ie shadow fix
                        if ($.browser.msie && $.browser.version < 8) {
                            controls.filter(".peKb_shadow").css("z-index", "-1");
                        }

                        closeVideo.css("z-index", 204);
                        closeVideo.css("position", "absolute");
                        closeVideo.css("margin-left", 0);
                        closeVideo.css("margin-top", -h + closeVideo.height() + padding);
                        closeVideo.css("margin-left", padding);
                        closeVideo.detach();

                        // bugger ??
                        //controls.after(closeVideo);
                        target.append(closeVideo);

                        closeVideo = target.find(".peKb_videoClose");
                        closeVideo.addClass("peKb_videoCloseInner");

                    }
                }

                if (conf.externalFont) {
                    captionDelayedResize = setTimeout(resizeCaptions, 10000);
                } else {
                    resizeCaptions();
                }

                if (pager) {
                    var allAs = pager.find("a");

                    allAs.click(navigatorHandler);

                    if (thumbOverlay) {
                        allAs
							.bind("mouseenter", thumbPreview)
							.bind("mouseleave", thumbPreview);

                        timerWidget
							.bind("mouseenter", thumbPreviewProxy)
							.bind("mouseleave", thumbPreviewProxy);
                    }

                }

                if (flashEnabled) {
                    videoOverlay.hide().click(videoOverlayClick);
                }


                var controlsEventHandler = true;

                var controlsMode = t.attr("data-controls");

                if (iDev) {
                    controlsMode = (controlsMode == "over" || controlsMode == "hideOnFirst") ? "always" : controlsMode;
                }

                switch (controlsMode) {
                    case "over":
                        hideControls(0);
                        break;
                    case "hideOnFirst":
                        hideControlsOnFirst = true;
                        break;
                    case "disabled":
                        hideControls(0);
                        controlsEventHandler = false;
                        break;
                    case "inner":
                        hideControls(0);
                        break;
                    default:
                        controlsEventHandler = false;
                        break;
                }

                if (controlsEventHandler) {
                    t
						.bind("mouseenter", eventHandler)
						.bind("mouseleave", eventHandler);
                }

                paused = true;
                timerControllerInterval = setInterval(timerController, 50);
                self.start();
            },


            start: function () {
                paused = hoverMode;
                showSlide(0);
            },

            fontsLoaded: function () {
                resizeCaptions();
                showCaption(currentSlide);
            },


            pauseTimer: function () {
                paused = true;
            },

            resumeTimer: function () {
                paused = false;
            },

            pause: function () {
                var kb = kbProxy();
                kb && kb.pause();
                self.pauseTimer();
            },

            resume: function () {
                var kb = kbProxy();
                kb && kb.resume();
                self.resumeTimer();
            },

            prev: function () {
                self.resumeTimer();
                showSlide(prevNextIndex(currentSlide, "prev"));
            },

            next: function () {
                self.resumeTimer();
                showSlide(prevNextIndex(currentSlide, "next"));
            },

            show: function (idx) {
                self.resumeTimer();
                idx = parseInt(idx, 10) - 1;
                if (idx >= 0 && idx < slides.length) {
                    showSlide(idx);
                }
            },

            length: function () {
                return (slides && slides.length) || 0;
            },

            destroy: function () {
                var kbTarget;

                stopVideo();
                jqSlides.each(function () {
                    kbTarget = $(this).find("img:eq(0)");
                    if ((kbTarget = kbTarget.data("peKenburnsImg"))) {
                        kbTarget.destroy();
                    }
                });
                kbTarget = undefined;
                clearInterval(timerControllerInterval);
                self = undefined;
                if (videoPlayer) {
                    videoPlayer.destroy();
                    videoPlayer = undefined;
                }
                target.data("peKenburnsSlider", null);
                target.remove();
                target = undefined;
            }



        });


        //if (t.width() == 0 && t[0].width == 0) {
        if ((!t.width()) && (!t[0].width)) {
            t.one("load", self.init);
        } else {
            self.init();
        }

    }


    // jQuery plugin implementation
    $.fn.peKenburnsSlider = function (conf) {
        // return existing instance

        var api = this.data("peKenburnsSlider");
        if (api) {
            api.start();
            return api;
        }

        conf = $.extend(true, {}, $.pixelentity.kenburnsSlider.conf, conf);

        // install kb for each entry in jQuery object
        this.each(function () {
            api = new KenBurnsSlider($(this), conf);
            $(this).data("peKenburnsSlider", api);
        });

        return conf.api ? api : this;
    };

})(jQuery); 

