Yox={addStylesheet:function(a,b){var c=a.createElement("link");c.setAttribute("rel","Stylesheet"),c.setAttribute("type","text/css"),c.setAttribute("href",b),a.getElementsByTagName("head")[0].appendChild(c)},compare:function(a,b){function c(a){var b=0;for(var c in a)c!=null&&b++;return b}if(typeof a!=typeof b)return!1;if(typeof a=="function")return a==b;if(c(a)!=c(b))return!1;for(var d in a){var e=a[d],f=b[d];if(typeof e!=typeof f)return!1;if(e&&e.length&&e[0]!==undefined&&e[0].tagName){if(!f||f.length!=e.length||!f[0].tagName||f[0].tagName!=e[0].tagName)return!1}else if(typeof e=="function"||typeof e=="object"){var g=Yox.compare(e,f);if(!g)return g}else if(e!=f)return!1}return!0},hasProperties:function(a){var b=!1;for(pName in a){b=!0;break}return b},dataSources:[],fitImageSize:function(a,b,c,d){var e={width:a.width,height:a.height};if(a.width>b.width||c&&a.width<b.width)e.height=Math.round(b.width/a.width*a.height),e.width=b.width;!d&&e.height>b.height?(e.width=Math.round(b.height/e.height*e.width),e.height=b.height):d&&e.height<b.height&&(b.height<=a.height||c)&&(e.height=b.height,e.width=Math.round(b.height/a.height*a.width));return e},flashVideoPlayers:{jwplayer:function(a,b,c,d,e){var f={swf:a||"/jwplayer/player.swf",flashVars:{file:b,image:c,stretching:"fill",title:d,backcolor:"000000",frontcolor:"FFFFFF"}};$.extend(f.flashVars,e);return f}},getDataSourceName:function(a){for(dataSourceIndex in Yox.Regex.data)if(a.match(Yox.Regex.data[dataSourceIndex]))return dataSourceIndex;return null},getPath:function(a){var b=document.getElementsByTagName("script");for(var c=0;c<b.length;c++){var d=b[c].src,e=d.match(a);if(e)return e[1]}return null},getTopWindow:function(){var a=window;if(window.top)a=window.top;else while(a.parent)a=a.parent;return a},getUrlData:function(a){var b=a.match(Yox.Regex.url);if(!b)return null;var c={path:b[1],anchor:b[3]};b[2]&&(c.queryFields=this.queryToJson(b[2]));return c},hex2rgba:function(a,b){a=parseInt(a.replace("#","0x"),16);var c=(a&16711680)>>16,d=(a&65280)>>8,e=a&255;return"rgba("+c+", "+d+", "+e+", "+(typeof b!="undefined"?b:"1")+")"},queryToJson:function(a){if(!a)return null;var b=a.split("&"),c={};for(var d=0;d<b.length;d++){var e=b[d].split("=");e.length==2&&(c[e[0]]=e[1])}return c},loadDataSource:function(options,callback){var dataSourceName;options.dataUrl&&(dataSourceName=Yox.getDataSourceName(options.dataUrl),dataSourceName&&$.extend(options,{dataSource:dataSourceIndex})),options.dataSource&&!Yox.dataSources[dataSourceName]?$.ajax({url:options.dataFolder+options.dataSource+".js",async:!1,dataType:"script",success:function(data){eval(data),eval("Yox.dataSources['"+options.dataSource+"'] = new yox_"+options.dataSource+"();"),callback(Yox.dataSources[options.dataSource])},error:function(a,b,c){console.log(a,b,c)}}):callback&&callback()},Regex:{data:{picasa:/http:\/\/(?:www\.)?picasaweb\.google\..*/i,flickr:/http:\/\/(?:www\.)?flickr.com/i,smugmug:/http:\/\/.*\.smugmug.com/i,youtube:/^http:\/\/(?:www\.)?youtube.com\//},flash:/^(.*\.(swf))(\?[^\?]+)?/i,flashvideo:/^(.*\.(flv|f4v|f4p|f4a|f4b|aac))(\?[^\?]+)?/i,image:/^[^\?#]+\.(?:jpg|jpeg|gif|png)$/i,url:/^([^#\?]*)?(?:\?([^\?#]*))?(?:#([A-Za-z]{1}[A-Za-z\d-_\:\.]+))?$/,video:{youtube:/.*youtube.com\/watch.*(?:v=[^&]+).*/i,vimeo:/vimeo.com\/\d+/i,hulu:/hulu.com\/watch\//i,viddler:/viddler.com\//i,flickr:/.*flickr.com\/.*/i,myspace:/.*vids.myspace.com\/.*/i,qik:/qik.com/i,revision3:/revision3.com/i,dailymotion:/dailymotion.com/i,"5min":/.*5min\.com\/Video/i}},Sprites:function(a,b,c){var d=new Image;d.src=b,this.spritesImage=b;var e=0;jQuery.each(a,function(a,b){b.top=e,e+=b.height}),this.getSprite=function(d,e,f){return jQuery("<img/>",{src:c,alt:e,title:f,css:{width:a[d].width,height:a[d].height,"background-image":"url("+b+")","background-repeat":"no-repeat","background-position":this.getBackgroundPosition(d,e)}})},this.getBackgroundPosition=function(b,c){var d=jQuery.inArray(c,a[b].sprites)*(a[b].width||0);return"-"+d+"px -"+a[b].top+"px"}},Support:{rgba:function(){if(!("result"in arguments.callee)){var a=document.createElement("div"),b="rgba(0, 0, 0, 0.5)",c=!1;try{a.style.color=b,c=/^rgba/.test(a.style.color)}catch(d){}a=null,arguments.callee.result=c}return arguments.callee.result}},urlDataToPath:function(a){var b=a.path||"";if(a.queryFields&&this.hasProperties(a.queryFields)){b+="?";for(field in a.queryFields)b+=field+"="+a.queryFields[field]+"&";b=b.substring(0,b.length-1)}a.anchor&&(b+="#"+a.anchor);return b}}
