YUI.add("aui-image-viewer-media",function(e,t){var n=e.Lang,r=e.Do,i="about:blank",s="body",o="href",u="iframe",a="image",f="loading",l="providers",c="src",t="mediaViewerPlugin",h="data-options",p={height:360,width:640,wmode:"embed"},d="https?://(?:www\\.)?{domain}",v="(?:[\\?&]|^){param}=([^&#]*)",m=e.Component.create({NAME:t,NS:"media",ATTRS:{providers:{validator:n.isObject,value:{flash:{container:'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}"><param name="wmode" value="{wmode}" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{media}" /><embed src="{media}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{width}" height="{height}" wmode="{wmode}"></embed></object>',matcher:/\b.swf\b/i,options:p,mediaRegex:/([^?&#]+)/},youtube:{container:'<iframe width="{width}" height="{height}" src="http://www.youtube.com/embed/{media}" frameborder="0" allowfullscreen></iframe>',matcher:new RegExp(n.sub(d,{domain:"youtube.com"}),"i"),options:p,mediaRegex:/[\?&]v=([^&#]*)/i},vimeo:{container:'<iframe src="http://player.vimeo.com/video/{media}?title=0&amp;byline=0&amp;portrait=0&amp;color=ffffff" width="{width}" height="{height}" frameborder="0"></iframe>',matcher:new RegExp(n.sub(d,{domain:"vimeo.com"}),"i"),options:p,mediaRegex:/\/(\d+)/}}}},EXTENDS:e.Plugin.Base,prototype:{initializer:function(e){var t=this,n=t._handles;n.changeReqeust=t.afterHostMethod("_changeRequest",t._restoreMedia),n.close=t.beforeHostMethod("close",t.close),n.loadMedia=t.beforeHostMethod("loadImage",t.loadMedia),n.preloadImage=t.beforeHostMethod("preloadImage",t.preloadImage)},close:function(){var e=this,t=e.get("host"),n=t.getCurrentLink(),r=e._getMediaType(n.attr("href"));r!=a&&(e._redirectIframe(i),t.setStdModContent(s,""))},loadMedia:function(t){var o=this,u=o.get("host"),c=o._getMediaType(t),h=!0;o._redirectIframe(i);if(c!=a){var p=o.get(l)[c],d=u.getCurrentLink(),v=o._updateOptions(d,e.clone(p.options)),m=p.mediaRegex.exec(t);m&&(v.media=m[1]);var g=n.sub(p.container,v);u.setStdModContent(s,g),u._syncImageViewerUI(),o._uiSetContainerSize(v.width,v.height),u._setAlignCenter(!0),u.set(f,!1),u.fire("load",{media:m});if(u.get("preloadNeighborImages")){var y=u.get("currentIndex");u.preloadImage(y+1),u.preloadImage(y-1)}h=new r.Prevent}return h},preloadImage:function(e){var t=this,n=t.get("host"),i=n.getLink(e),s=new r.Prevent;if(i){var u=i.attr(o),f=t._getMediaType(u);f==a&&(s=!0)}return s},_getMediaType:function(t){var n=this,r=n.get(l),i=a;return e.some(r,function(e,n,r){return e.matcher.test(t)&&(i=n)}),i},_redirectIframe:function(e){var t=this,n=t.get("host.bodyNode");if(n){var r=n.one(u);r&&r.attr(c,e)}},_restoreMedia:function(e){var t=this,n=t.get("host"),r=n.getCurrentLink(),i=r.attr("href"),o=t._getMediaType(i);o!=a&&!n.getStdModNode(s).html()&&n._processChangeRequest()},_uiSetContainerSize:function(e,t){var n=this,r=n.get("host"),i=r.bodyNode,s=r.footerNode;s.setStyle("width",e),i.setStyles({height:t,width:e})},_updateOptions:function(t,r){var i=t.attr(h),s=t.attr(o);return e.each(r,function(e,t,o){var u=new RegExp(n.sub(v,{param:t})),a=u.exec(i)||u.exec(s);a&&(r[t]=a[1])}),r},_handles:{}},DATA_OPTIONS:h,DEFAULT_OPTIONS:p,REGEX_DOMAIN:d,REGEX_PARAM:v});e.MediaViewerPlugin=m,e.MediaViewer=e.ImageViewer},"2.0.0",{requires:["plugin","aui-image-viewer-base","aui-pagination","aui-toolbar"]});
