/**
 * @version 3.0.1
 * @package embedia(formerly mosEasyMedia)
 * @copyright Copyright &copy; 2009, Brilaps LLC
 * @author Ozgur Cem Sen
 * @email code@brilaps.com
 * @link http://brilaps.com || http://wiki.brilaps.com
 * @license http://www.opensource.org/licenses/gpl-license.php GNU/GPL v.2 .
 */
var embedia=function(){var f={},d=[],a={},h,g,b,e,c;h=function(){return{item:null,popupStyle:"none",popupWindowParams:"",popupOverlayParams:{},overlay:null}};g=function(k,j){return[k[0]+j*60,Math.abs(k[1])+j*40]};b=function(j){j.Object.each(f,function(m,l,n){if((m.overlay!==null)){m.overlay.set("align",{points:["cc","cc"]})}})};e=function(k,j){b(k);var l=0;k.Object.each(f,function(n,m,p){if((n.overlay!==null)){if(n.overlay.get("visible")===true){xy=g(n.overlay.get("xy"),l);n.overlay.set("zIndex",l);n.overlay.set("xy",xy);l++}}});j.set("zIndex",l+1)};c=function(j){if(j!==null){j.hide();j.set("bodyContent","deleting...");j.destroy();j=null;return j}};return{addMedia:function(j,k){if(f[j]===undefined){f[j]=h()}f[j].value=k},setPopupStyle:function(j,k){if(f[j]===undefined){f[j]=h()}f[j].popupStyle=k},addMediaPopupWindowParams:function(k,j){if(f[k]===undefined){f[k]=h()}f[k].popupWindowParams=j},addMediaPopupOverlayParams:function(k,j){if(f[k]===undefined){f[k]=h()}f[k].popupOverlayParams=j},addCssUrl:function(j){d.push(j)},render:function(j){for(i=0;i<d.length;i++){j.Get.css(d[i],{onSuccess:function(){}})}j.Object.each(f,function(m,l,n){if((m.value!=="")&&(m.value!==undefined)&&(m.popupStyle==="none")){j.one("#"+l).setContent(m.value)}})},pop:function(l,k){if(f[k.get("rel")]!==undefined){if(f[k.get("rel")].popupStyle==="window"){var j=window.open("",k.get("rel"),'"'+f[k.get("rel")].popupWindowParams+'"');j.document.write(f[k.get("rel")].value)}else{if(f[k.get("rel")].overlay===null){f[k.get("rel")].overlay=new l.Overlay({width:f[k.get("rel")].popupOverlayParams.width+"px",height:f[k.get("rel")].popupOverlayParams.height+"px",align:{node:null,points:["cc","cc"]},visible:false,zIndex:900,headerContent:'<a id="overlay-title-close-'+k.get("rel")+'" class="overlay-title-close" href="#" rel="'+k.get("rel")+'">Media</a>',bodyContent:f[k.get("rel")].value});f[k.get("rel")].overlay.set("centered",true);f[k.get("rel")].overlay.render();l.one("#overlay-title-close-"+k.get("rel")).get("parentNode").on("click",function(m){embedia.onStackMouseDown(l,m.target.get("parentNode").get("parentNode"))});l.one("#overlay-title-close-"+k.get("rel")).on("click",function(m){f[k.get("rel")].overlay=c(f[k.get("rel")].overlay);m.target.get("parentNode").get("parentNode").get("parentNode").remove()})}else{if(f[k.get("rel")].overlay.get("visible")===true){f[k.get("rel")].overlay=c(f[k.get("rel")].overlay);return}}f[k.get("rel")].overlay.show();e(l,f[k.get("rel")].overlay)}}},onStackMouseDown:function(l,j){var k=l.Widget.getByNode(j);if(k&&k instanceof l.Overlay){e(l,k)}}}}();var YUIEMBEDIA=YUI({timeout:10000}).use("node","overlay",function(a){a.on("domready",function(){embedia.render(a);a.all(".moseasmedia-popup-link").on("click",function(b){b.preventDefault();embedia.pop(a,b.target)});a.all(".moseasmedia-popup-link img").on("click",function(b){b.preventDefault();embedia.pop(a,b.target.get("parentNode"))})})});