jQuery.cookie=function(key,value,options){if(arguments.length>1&&String(value)!=="[object Object]"){options=jQuery.extend({},options);if(value===null||value===undefined){options.expires=-1;}
if(typeof options.expires==='number'){var days=options.expires,t=options.expires=new Date();t.setDate(t.getDate()+days);}
value=String(value);return(document.cookie=[encodeURIComponent(key),'=',options.raw?value:encodeURIComponent(value),options.expires?'; expires='+options.expires.toUTCString():'',options.path?'; path='+options.path:'',options.domain?'; domain='+options.domain:'',options.secure?'; secure':''].join(''));}
options=value||{};var result,decode=options.raw?function(s){return s;}:decodeURIComponent;return(result=new RegExp('(?:^|; )'+encodeURIComponent(key)+'=([^;]*)').exec(document.cookie))?decode(result[1]):null;};;(function($){var escapeable=/["\\\x00-\x1f\x7f-\x9f]/g,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};$.toJSON=typeof JSON==='object'&&JSON.stringify?JSON.stringify:function(o){if(o===null){return'null';}
var type=typeof o;if(type==='undefined'){return undefined;}
if(type==='number'||type==='boolean'){return''+o;}
if(type==='string'){return $.quoteString(o);}
if(type==='object'){if(typeof o.toJSON==='function'){return $.toJSON(o.toJSON());}
if(o.constructor===Date){var month=o.getUTCMonth()+1,day=o.getUTCDate(),year=o.getUTCFullYear(),hours=o.getUTCHours(),minutes=o.getUTCMinutes(),seconds=o.getUTCSeconds(),milli=o.getUTCMilliseconds();if(month<10){month='0'+month;}
if(day<10){day='0'+day;}
if(hours<10){hours='0'+hours;}
if(minutes<10){minutes='0'+minutes;}
if(seconds<10){seconds='0'+seconds;}
if(milli<100){milli='0'+milli;}
if(milli<10){milli='0'+milli;}
return'"'+year+'-'+month+'-'+day+'T'+
hours+':'+minutes+':'+seconds+'.'+milli+'Z"';}
if(o.constructor===Array){var ret=[];for(var i=0;i<o.length;i++){ret.push($.toJSON(o[i])||'null');}
return'['+ret.join(',')+']';}
var name,val,pairs=[];for(var k in o){type=typeof k;if(type==='number'){name='"'+k+'"';}else if(type==='string'){name=$.quoteString(k);}else{continue;}
type=typeof o[k];if(type==='function'||type==='undefined'){continue;}
val=$.toJSON(o[k]);pairs.push(name+':'+val);}
return'{'+pairs.join(',')+'}';}};$.evalJSON=typeof JSON==='object'&&JSON.parse?JSON.parse:function(src){return eval('('+src+')');};$.secureEvalJSON=typeof JSON==='object'&&JSON.parse?JSON.parse:function(src){var filtered=src.replace(/\\["\\\/bfnrtu]/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,'');if(/^[\],:{}\s]*$/.test(filtered)){return eval('('+src+')');}else{throw new SyntaxError('Error parsing JSON, source is not valid.');}};$.quoteString=function(string){if(string.match(escapeable)){return'"'+string.replace(escapeable,function(a){var c=meta[a];if(typeof c==='string'){return c;}
c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16);})+'"';}
return'"'+string+'"';};})(jQuery);;(function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){r||l(a());n()}).attr("src",r||"javascript:0").insertAfter("body")[0].contentWindow;h.onpropertychange=function(){try{if(event.propertyName==="title"){q.document.title=h.title}}catch(s){}}}};j.stop=k;o=function(){return a(q.location.href)};l=function(v,s){var u=q.document,t=$.fn[c].domain;if(v!==s){u.title=h.title;u.open();t&&u.write('<script>document.domain="'+t+'"<\/script>');u.close();q.location.hash=v}}})();return j})()})(jQuery,this);;
/*
 * jQuery Tools v1.2.5 - The missing UI library for the Web
 * 
 * overlay/overlay.js
 * toolbox/toolbox.expose.js
 * 
 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 * 
 * http://flowplayer.org/tools/
 * 
 */
(function(a){a.tools=a.tools||{version:"v1.2.5"},a.tools.overlay={addEffect:function(a,b,d){c[a]=[b,d]},conf:{close:null,closeOnClick:!0,closeOnEsc:!0,closeSpeed:"fast",effect:"default",fixed:!a.browser.msie||a.browser.version>6,left:"center",load:!1,mask:null,oneInstance:!0,speed:"normal",target:null,top:"10%"}};var b=[],c={};a.tools.overlay.addEffect("default",function(b,c){var d=this.getConf(),e=a(window);d.fixed||(b.top+=e.scrollTop(),b.left+=e.scrollLeft()),b.position=d.fixed?"fixed":"absolute",this.getOverlay().css(b).fadeIn(d.speed,c)},function(a){this.getOverlay().fadeOut(this.getConf().closeSpeed,a)});function d(d,e){var f=this,g=d.add(f),h=a(window),i,j,k,l=a.tools.expose&&(e.mask||e.expose),m=Math.random().toString().slice(10);l&&(typeof l=="string"&&(l={color:l}),l.closeOnClick=l.closeOnEsc=!1);var n=e.target||d.attr("rel");j=n?a(n):null||d;if(!j.length)throw"Could not find Overlay: "+n;d&&d.index(j)==-1&&d.click(function(a){f.load(a);return a.preventDefault()}),a.extend(f,{load:function(d){if(f.isOpened())return f;var i=c[e.effect];if(!i)throw"Overlay: cannot find effect : \""+e.effect+"\"";e.oneInstance&&a.each(b,function(){this.close(d)}),d=d||a.Event(),d.type="onBeforeLoad",g.trigger(d);if(d.isDefaultPrevented())return f;k=!0,l&&a(j).expose(l);var n=e.top,o=e.left,p=j.outerWidth({margin:!0}),q=j.outerHeight({margin:!0});typeof n=="string"&&(n=n=="center"?Math.max((h.height()-q)/2,0):parseInt(n,10)/100*h.height()),o=="center"&&(o=Math.max((h.width()-p)/2,0)),i[0].call(f,{top:n,left:o},function(){k&&(d.type="onLoad",g.trigger(d))}),l&&e.closeOnClick&&a.mask.getMask().one("click",f.close),e.closeOnClick&&a(document).bind("click."+m,function(b){a(b.target).parents(j).length||f.close(b)}),e.closeOnEsc&&a(document).bind("keydown."+m,function(a){a.keyCode==27&&f.close(a)});return f},close:function(b){if(!f.isOpened())return f;b=b||a.Event(),b.type="onBeforeClose",g.trigger(b);if(!b.isDefaultPrevented()){k=!1,c[e.effect][1].call(f,function(){b.type="onClose",g.trigger(b)}),a(document).unbind("click."+m).unbind("keydown."+m),l&&a.mask.close();return f}},getOverlay:function(){return j},getTrigger:function(){return d},getClosers:function(){return i},isOpened:function(){return k},getConf:function(){return e}}),a.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(b,c){a.isFunction(e[c])&&a(f).bind(c,e[c]),f[c]=function(b){b&&a(f).bind(c,b);return f}}),i=j.find(e.close||".close"),!i.length&&!e.close&&(i=a("<a class=\"close\"></a>"),j.prepend(i)),i.click(function(a){f.close(a)}),e.load&&f.load()}a.fn.overlay=function(c){var e=this.data("overlay");if(e)return e;a.isFunction(c)&&(c={onBeforeLoad:c}),c=a.extend(!0,{},a.tools.overlay.conf,c),this.each(function(){e=new d(a(this),c),b.push(e),a(this).data("overlay",e)});return c.api?e:this}})(jQuery);(function(a){a.tools=a.tools||{version:"v1.2.5"};var b;b=a.tools.expose={conf:{maskId:"exposeMask",loadSpeed:"slow",closeSpeed:"fast",closeOnClick:!0,closeOnEsc:!0,zIndex:9998,opacity:.8,startOpacity:0,color:"#fff",onLoad:null,onClose:null}};function c(){if(a.browser.msie){var b=a(document).height(),c=a(window).height();return[window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,b-c<20?c:b]}return[a(document).width(),a(document).height()]}function d(b){if(b)return b.call(a.mask)}var e,f,g,h,i;a.mask={load:function(j,k){if(g)return this;typeof j=="string"&&(j={color:j}),j=j||h,h=j=a.extend(a.extend({},b.conf),j),e=a("#"+j.maskId),e.length||(e=a("<div/>").attr("id",j.maskId),a("body").append(e));var l=c();e.css({position:"absolute",top:0,left:0,width:l[0],height:l[1],display:"none",opacity:j.startOpacity,zIndex:j.zIndex}),j.color&&e.css("backgroundColor",j.color);if(d(j.onBeforeLoad)===!1)return this;j.closeOnEsc&&a(document).bind("keydown.mask",function(b){b.keyCode==27&&a.mask.close(b)}),j.closeOnClick&&e.bind("click.mask",function(b){a.mask.close(b)}),a(window).bind("resize.mask",function(){a.mask.fit()}),k&&k.length&&(i=k.eq(0).css("zIndex"),a.each(k,function(){var b=a(this);/relative|absolute|fixed/i.test(b.css("position"))||b.css("position","relative")}),f=k.css({zIndex:Math.max(j.zIndex+1,i=="auto"?0:i)})),e.css({display:"block"}).fadeTo(j.loadSpeed,j.opacity,function(){a.mask.fit(),d(j.onLoad),g="full"}),g=!0;return this},close:function(){if(g){if(d(h.onBeforeClose)===!1)return this;e.fadeOut(h.closeSpeed,function(){d(h.onClose),f&&f.css({zIndex:i}),g=!1}),a(document).unbind("keydown.mask"),e.unbind("click.mask"),a(window).unbind("resize.mask")}return this},fit:function(){if(g){var a=c();e.css({width:a[0],height:a[1]})}},getMask:function(){return e},isLoaded:function(a){return a?g=="full":g},getConf:function(){return h},getExposed:function(){return f}},a.fn.mask=function(b){a.mask.load(b);return this},a.fn.expose=function(b){a.mask.load(b,this);return this}})(jQuery);;Onone.Model.Base=function(){this.cookie=Onone.Util.cookie;this.jsonCookie=Onone.Util.jsonCookie;};Onone.Model.Base.prototype={onError:function(){},_ajax:function(url,params,callback,opts){var obj=this;opts=(typeof opts=='object'?opts:{});$.ajax($.extend({},{url:url,data:params,timeout:10000,success:function(data){if(typeof callback=='function'){callback(data);}},error:function(xhr,text_status,error){if(xhr.getAllResponseHeaders()&&text_status!='abort'){obj.onError('Ajax error fetching '+this.url);}}},opts));}};;Onone.Model.CascadingDropdowns=function(opts){Onone.Model.Base.call(this,opts);this._opts=opts;this._cache={category:{},common:{}};this._use_cookies=(typeof opts.use_cookies=='boolean'?opts.use_cookies:false);this._id=(typeof opts!='undefined'&&opts.id!='undefined'?opts.id:'1');};Onone.Model.CascadingDropdowns.prototype=$.extend({},Onone.Model.Base.prototype,{saveByCategory:function(data,category){if(this._use_cookies){this.jsonCookie(this._getCategoryCookieName(category),data);}else{this._cache.category[category]=data;}},saveCommon:function(data){if(this._use_cookies){this.jsonCookie(this._getCommonCookieName(),data);}else{this._cache.common=data;}},getByCategory:function(category){if(this._use_cookies){var cat_values=this.jsonCookie(this._getCategoryCookieName(category)),common_values=this.jsonCookie(this._getCommonCookieName());return $.extend({},cat_values,common_values);}else{return $.extend({},this._cache.category[category],this._cache.common);}},_getCategoryCookieName:function(category){return cookie_name='cdd-'+this._id+'-'+category;},_getCommonCookieName:function(){return common_cookie_name='cddc-'+this._id;}});;Onone.Lib.CascadingDropdowns=function(el,use_cookies,id){this._el=el;this._values={common:{},by_category:{}};this._exclude_from_reset={};this._category='';this._use_cookies=(use_cookies&&Onone.Util.cookiesEnabled());this._model=new Onone.Model.CascadingDropdowns({use_cookies:(use_cookies&&Onone.Util.cookiesEnabled()),id:id});};Onone.Lib.CascadingDropdowns.prototype={setCategory:function(category){this._category=category;},excludeFromReset:function(el){this._exclude_from_reset=$(el);},onChange:function(el,callback){this.saveValues();callback();},reset:function(el,callback){$(el).prev().val('');this.saveValues();callback();},resetAll:function(callback){var reset=this._el.not(this._exclude_from_reset).not('[value=""]').length;if(reset!==0){this._el.not(this._exclude_from_reset).val('');this.saveValues();}
callback();},disableAll:function(){this._el.attr('disabled',true);},enableAll:function(){this._el.attr('disabled',false);},saveValues:function(){var obj=this;var data={common:{},category:{}};this._el.each(function(){var id=$(this).attr('id'),val=$(this).val();if($(this).hasClass('common')){data.common[id]=val;}else{data.category[id]=val;}});this._model.saveCommon(data.common);this._model.saveByCategory(data.category,this._category);},getValues:function(){return this._model.getByCategory(this._category);},populate:function(data,callback){var obj=this;var saved_values=this.getValues();this._el.each(function(){var sel=$(this),val=sel.val(),id=$(this).attr('id');sel.children().remove();var opts=data[id].options;var saved_value=(typeof saved_values=='object'&&typeof saved_values[id]!='undefined'?saved_values[id]:null);$.each(opts,function(k,v){var opt=$('<option>').val(k).text(v);if(saved_value==k){opt.attr('selected',true);}
sel.append(opt);});});callback();},resettable:function(el){return $(el).prev().val().length;},allResettable:function(){return this._el.not(this._exclude_from_reset).not('[value=""]').length;}};;Onone.Lib.Facebook={getLikeButton:function(params){params=$.extend({send:false,layout:'box_count',show_faces:false,action:'like',colorscheme:'light',href:window.location.href.replace(/\/\#!/,'')},params);params.href=encodeURI(params.href);var src='http://www.facebook.com/plugins/like.php?'+
$.param(params);return $('<iframe>').attr({src:src,scrolling:'no',frameBorder:'0'});}};;Onone.Lib.Twitter={getTweetButton:function(params){params=$.extend({count:'vertical',url:window.location.href.replace(/\/\#!/,'')},params);params.url=encodeURI(params.url);var src='http://platform.twitter.com/widgets/tweet_button.html?'+
$.param(params);return $('<iframe>').attr({src:src,scrolling:'no',frameBorder:'0'});}};;Onone.Lib.PlusOne={init:function(){window.___gcfg={parsetags:'explicit'};},renderPlusOneButton:function(container,params){params=(typeof params=='object'?params:{});var el=$('<g:plusone></g:plusone>').attr({size:'tall',href:encodeURI(window.location.href)});container.children().remove().end().append(el);gapi.plusone.go();}};;Onone.Lib.Dialog={overlay:function(contents,close_callback){close_callback=(typeof close_callback=='function'?close_callback:function(){});contents.addClass('__dialog').prependTo('body');contents.overlay({mask:{color:'#555',loadSpeed:800,opacity:0.7},load:true,top:'20%',onClose:close_callback});}};;Onone.View.Dialog={getGenericError:function(){return $('<div>').addClass('error-dialog').append($('<h3>An error has occurred</h3>'),$('<p>If this problem persists, please contact customer service.</p>'),$('<a>Close</a>').addClass('close'));}};;Onone.Lib.BigTabs=function(container_el,use_cookies,id){this._container_el=container_el;this._use_cookies=(use_cookies&&Onone.Util.cookiesEnabled());this._id=id;};Onone.Lib.BigTabs.prototype={update:function(el){el=$(el);this._container_el.removeClass('left right');switch(this._container_el.children('li').index(el.parent())){case 0:this._container_el.addClass('left');break;case 1:this._container_el.addClass('right');break;}
this._container_el.children('li').removeClass('on').addClass('off');el.parent().addClass('on');if(this._use_cookies){Onone.Util.cookie('bt-'+this._id,this.getCurrentTabName());}},restore:function(){if(this._use_cookies){var saved_tab_name=Onone.Util.cookie('bt-'+this._id);if(saved_tab_name!==null){this.update(this._container_el.find('li a.'+saved_tab_name));}}},getCurrentTabName:function(){return this._container_el.find('li.on a').attr('class');}};;Onone.Lib.ZendPaginator=function(opts,el){this._view=new Onone.View.ZendPaginator(opts,el);this._opts=opts;this._el=el;}
Onone.Lib.ZendPaginator.prototype={init:function(){var obj=this;this._el.on('click','.first a',function(){obj.first();return false;});this._el.on('click','.previous a',function(){obj.previous();return false;});this._el.on('click','.page a',function(){obj.page(this);return false;})
this._el.on('click','.next a',function(){obj.next();return false;});this._el.on('click','.last a',function(){obj.last();return false;});},build:function(data){this._view.build(this._el,data);},first:function(){},previous:function(){},page:function(){},next:function(){},last:function(){}};;Onone.View.ZendPaginator=function(opts){this._opts=opts;};Onone.View.ZendPaginator.prototype={build:function(el,data){var obj=this;el.children().remove();var ul=$('<ul>').addClass('pagination');if(data.current==1){ul.append($('<li>').addClass('disabled text-link').text('First'),$('<li>').addClass('disabled prev-next').text('< Previous'));}else{ul.append($('<li>').addClass('first text-link').append($('<a>').attr('href','#').text('First')),$('<li>').addClass('previous prev-next').append($('<a>').attr('href','#').text('< Previous')));}
$.each(data.pagesInRange,function(page){if(page==data.current){ul.append($('<li>').addClass('current').text(page));}else{ul.append($('<li>').addClass('page').append($('<a>').attr('href','#').text(page)));}});if(data.current==data.last){ul.append($('<li>').addClass('disabled prev-next').text('Next >'),$('<li>').addClass('disabled text-link').text('Last'));}else{ul.append($('<li>').addClass('next prev-next').append($('<a>').attr('href','#').text('Next >')),$('<li>').addClass('last text-link').append($('<a>').attr('href','#').text('Last')));}
el.append(ul).css('visibility','visible');}};;Onone.View.Videos=function(opts,el){this._opts=opts;this._$=Onone.Lib.ElementCache;this._results_li_clone=this._$('.results-list li:first').clone();};Onone.View.Videos.prototype={populateSearchResults:function(data){this._$('.results-list').hide().children().remove();for(var v in data){var id=data[v]._id;var thumb=$('<img>').hide().load(function(){$(this).fadeIn(200);}).attr('src',data[v].thumbnail);var href=this._opts.video_hash_url+data[v].slug;var temp_li=this._results_li_clone.clone().attr('id',id).find('.thumb').append($('<a>').attr('href',href).append(thumb)).end().find('.info h4 a').text(data[v].title).attr('href',href).end().find('.stats .instructors').text(data[v].instructors.join(', ')).end().find('.stats .runtime').text(data[v].runtime).end().find('.stats .likes').text(data[v].likes).end().find('.stats .likes-label').text(data[v].likes===1?'Like':'Likes').end().find('.stats .views').text(data[v].views).end().find('.stats .views-label').text(data[v].views===1?'time':'times').end().find('.stats .upload-date').text(data[v].upload_date).end().find('.info .description').text(data[v].description).end();this._$('.results-list').append(temp_li);}},fadeInSearchResults:function(){this._$('.results-list').fadeIn(200);},updateVideoCount:function(count){this._$('.showing .filtered-video-count').text(count);},populateVideo:function(video){var obj=this,h=500,w=800;if(video.host=='vimeo'){var src=this._opts.vimeo_iframe_url.replace('%d',video.remote_id);}else if(video.host=='youtube'){var src=this._opts.youtube_iframe_url+video.remote_id+'?wmode=transparent';h=480;}
var iframe=$('<iframe>').height(h).width(w).attr({src:src,frameBorder:0}).hide();iframe.load(function(){$(this).fadeIn(200);});this._$('.video').children().remove().end().append(iframe);this._$('.video-stats .runtime-value').text(video.runtime);if($.trim(video.download_url)){this._$('.video-stats .download a').attr('href',video.download_url).parent().css('visibility','visible');}else{this._$('.video-stats .download a').attr('href','#').parent().css('visibility','hidden');}
this._$('.video-stats .likes-value').text(video.likes);this._$('.video-info .desc h3').text(video.title);this._$('.video-info .desc p').text(video.description);},unloadVideo:function(){this._$('.video').children().fadeOut(200,function(){$(this).remove();});},updateMetaInfo:function(video){$('meta[name=title], meta[name=description]').remove();$('link[rel=canonical]').remove();var title=video.title+' - onOne Software';$('head').prepend($('<meta>').attr({name:'title',content:title}),$('<meta>').attr({name:'description',content:video.description}),$('<link>').attr({rel:'canonical',href:window.location.href.replace(/\/\#/,'')}));document.title=title;},scrollToVideo:function(callback){callback=(typeof callback=='function'?callback:function(){});var video_top=parseInt(this._$('.video').position().top);var scroll_top=$(window).scrollTop();if(scroll_top<video_top){callback();return;}
var c=0;this._$('body, html').animate({scrollTop:video_top},450,function(){if(c){return;}
c++;callback();});},hideVideoIframe:function(){this._$('.video iframe').css('visibility','hidden');},showVideoIframe:function(){this._$('.video iframe').css('visibility','visible');},toggleVideoDescription:function(state){var inner=this._$('.video-info-inner');var inner_h=inner.height();if(state){this._$('.video-info').animate({height:inner_h+'px'},400,function(){$(this).removeClass('hidden');});}else{this._$('.video-info').animate({height:0},400,function(){$(this).addClass('hidden');});}},updateLikeLink:function(is_liked){if(is_liked){this._$('.like a').addClass('disabled');}else{this._$('.like a').removeClass('disabled');}},updateBookmarkLink:function(is_bookmarked){if(is_bookmarked){this._$('.bookmark a').addClass('disabled');}else{this._$('.bookmark a').removeClass('disabled');}},populateBookmarks:function(bookmarks){var obj=this;var list=$('<ul>');if(bookmarks.length){for(var i in bookmarks){var href=this._opts.video_hash_url+bookmarks[i].slug;list.append($('<li>').attr('id','bookmark_'+bookmarks[i]._id).append($('<a>').addClass('remove').attr('href','#').append($('<span>').text('Remove')),$('<a>').addClass('load').attr('href',href).text(bookmarks[i].title)));}}else{list.append($('<li>').text('You have no bookmarked videos.'));}
this._$('.bookmarked-videos').children().remove().end().append($('<h5>').text('My bookmarked videos'),$('<ul>').append(list));},updateLikeButton:function(){this._$('.social-links .fb').children().remove().end().append(Onone.Lib.Facebook.getLikeButton());},updateTweetButton:function(){this._$('.social-links .twitter').children().remove().end().append(Onone.Lib.Twitter.getTweetButton());}};;Onone.Model.Videos=function(opts){Onone.Model.Base.call(this,opts);this._opts=opts;this._cached_search_data=null;this._cached_video=null;};Onone.Model.Videos.prototype=$.extend({},Onone.Model.Base.prototype,{getSearchData:function(video_type,params,page,callback){var obj=this;params=(typeof params=='object'?params:{});if(typeof page=='number'){params.page=page;}
if(typeof video_type!='undefined'){params.video_type=video_type;}
this._ajax(this._opts.search_data_url,params,function(data){if(typeof data!='undefined'){obj._cached_search_data=data;callback(data);}else{obj.onError('data not defined in getSearchData()');}});},getCachedSearchData:function(){return this._cached_search_data;},getCachedSearchOptions:function(name){try{if(typeof this._cached_search_data.search[name].options=='undefined'){throw'_cached_search_data.search.'+name+'.options is undefined';}
return this._cached_search_data.search[name].options;}catch(e){this.onError(e);}},getCachedCurrentPage:function(){try{if(typeof this._cached_search_data.videos.pages.current=='undefined'){throw'_cached_search_data.videos.pages.current is undefined';}
return this._cached_search_data.videos.pages.current;}catch(e){this.onError(e);}},getCachedLastPage:function(){try{if(typeof this._cached_search_data.videos.pages.last=='undefined'){throw'_cached_search_data.videos.pages.last is undefined';}
return this._cached_search_data.videos.pages.last;}catch(e){this.onError(e);}},getVideoBySlug:function(slug,callback){var obj=this;this._ajax(this._opts.video_url,{slug:slug},function(data){if(typeof data!='undefined'&&typeof data.video!='undefined'){obj._cached_video=data.video;callback(data.video);}else{obj.onError('data not defined in ModelVideo.getVideoBySlug()');}});},getCachedVideo:function(){return this._cached_video;},setCachedVideo:function(video){this._cached_video=video;},getCachedVimeoId:function(){try{if(typeof this._cached_video.vimeo_id!='number'){throw'_cached_video.vimeo_id is not a number';}else{return this._cached_video.vimeo_id;}}catch(e){this.onError(e);}},getCachedId:function(){try{if(typeof this._cached_video._id!='string'){throw'_cached_video._id is not a string';}else{return this._cached_video._id;}}catch(e){this.onError(e);}},getCachedSlug:function(){try{if(typeof this._cached_video.slug!='string'){throw'_cached_video.slug is not a string';}else{return this._cached_video.slug;}}catch(e){this.onError(e);}},isLiked:function(id){var likes=this.cookie('vl');likes=(likes===null?[]:likes.split('|'));for(var i in likes){if(likes[i]==id){return true;}}
return false;},incrementLikes:function(id,callback){var obj=this;var params={id:id};this._ajax(this._opts.inc_likes_url,params,function(data){if(typeof data!='undefined'&&typeof data.status!='undefined'&&data.status){callback(data);}else{obj.onError('ModelVideo.incrementLikes() failed');}});},saveLike:function(id){var likes=this.cookie('vl');likes=(likes===null?[]:likes.split('|'));likes.push(id);this.cookie('vl',likes.join('|'),{expires:365});},isBookmarked:function(id){var bookmarks=this.cookie('bm');bookmarks=(bookmarks===null?[]:bookmarks.split('|'));for(var i in bookmarks){if(bookmarks[i]==id){return true;}}
return false;},getBookmarkTitles:function(callback){var obj=this;var params='ids='+this.cookie('bm');this._ajax(this._opts.bookmarks_url,params,function(data){if(typeof data!='undefined'&&typeof data.bookmarks!='undefined'){callback(data.bookmarks);}else{obj.onError('data not defined in getBookmarkTitles()');}});},addBookmark:function(id){var bm_ids=this.cookie('bm');bm_ids=(!bm_ids?[]:bm_ids.split('|'));bm_ids.push(id);this.cookie('bm',bm_ids.join('|'),{expires:365});},removeBookmark:function(id){var bookmarks=this.cookie('bm');bookmarks=(bookmarks===null?[]:bookmarks.split('|'));for(var i in bookmarks){if(bookmarks[i]==id){bookmarks.splice(i,1);}}
this.cookie('bm',bookmarks.join('|'),{expires:365});},addView:function(id){this._ajax(this._opts.inc_views_url,{id:id},function(data){if(typeof data!='undefined'&&typeof data.status!='undefined'&&data.status){callback(data);}else{obj.onError('ModelVideo.addView() failed');}});},getSlugFromHash:function(){return window.location.hash.replace(/^.*\//,'');},isDescriptionStateSet:function(){if(this.cookie('ds')===null){return false;}
return true;},saveDescriptionState:function(state){this.cookie('ds',Number(state),{expires:365});},getDescriptionState:function(default_state){var ds=this.cookie('ds');return Boolean(Number(ds));}});;Onone.App.FilteredSearch=function(opts){this._$=Onone.Lib.ElementCache;this._paginator=new Onone.Lib.ZendPaginator(opts,this._$('.pagination'));this._busy=false;this._error=false;};Onone.App.FilteredSearch.prototype={_initTabs:function(){var obj=this;this._tabs.restore();this._$('.tabs ul a').click(function(){if($(this).parent().hasClass('on')||obj._busy){return false;}
obj._busy=true;obj._tabs.update(this);obj._dropdowns.setCategory(obj._tabs.getCurrentTabName());obj._search();return false;});},_initSearchDropdowns:function(){var obj=this;this._dropdowns.setCategory(this._tabs.getCurrentTabName());this._$('.filtered-search .filters select').change(function(){if(obj._busy){return false;}
obj._busy=true;obj._dropdowns.onChange(this,function(){obj._search();});});this._$('.filtered-search .filters .reset').click(function(){if(obj._busy||!obj._dropdowns.resettable(this)){return false;}
obj._busy=true;obj._dropdowns.reset(this,function(){obj._search();});return false;});this._$('.filtered-search .filters .reset-all a').click(function(){if(obj._busy||!obj._dropdowns.allResettable()){return false;}
obj._busy=true;obj._dropdowns.resetAll(function(){obj._search();});return false;});},_initPagination:function(){var obj=this;this._paginator.init();this._paginator.first=function(){if(obj._busy){return false;}
obj._busy=true;obj._search(1);return false;};this._paginator.previous=function(){if(obj._busy){return false;}
obj._busy=true;obj._search(obj._model.getCachedCurrentPage()-1);return false;};this._paginator.page=function(el){if(obj._busy){return false;}
obj._busy=true;obj._search(parseInt($(el).text()));return false;};this._paginator.next=function(){if(obj._busy){return false;}
obj._busy=true;obj._search(obj._model.getCachedCurrentPage()+1);return false;};this._paginator.last=function(){if(obj._busy){return false;}
obj._busy=true;obj._search(obj._model.getCachedLastPage());return false;};},_showError:function(e){console.log(e);return;var obj=this;if(!this._error){this._error=true;if(typeof console!='undefined'){console.log(e);}
Onone.Lib.Dialog.overlay(Onone.View.Dialog.getGenericError(),function(){window.location.reload();});}}};;Onone.App.University=function(opts){Onone.App.FilteredSearch.call(this,opts);var obj=this;this._opts=opts;this._model=new Onone.Model.Videos(opts);this._model.onError=function(e){obj._showError(e);};this._view=new Onone.View.Videos(opts);this._plusone=Onone.Lib.PlusOne;this._plusone.init();this._dropdowns=new Onone.Lib.CascadingDropdowns(this._$('.filters select'),false,'univ');this._dropdowns.excludeFromReset(this._$('.filters #sort'));this._dropdowns.saveValues();this._tabs=new Onone.Lib.BigTabs(this._$('.video-types'),false,'univ');};Onone.App.University.prototype=$.extend({},Onone.App.FilteredSearch.prototype,{init:function(){var obj=this;this._busy=true;try{if(!this._hashCheck()){return;}
this._model.setCachedVideo(this._opts.video);this._initTabs();this._initPagination();this._initSearchDropdowns();this._initSearchVideoLinks();this._initLikeLink();this._initBookmarkLink();this._initLoadBookmarkLinks();this._initRemoveBookmarkLinks();this._initVideoDescriptionLink();this._initDownloadLink();this._initHashChange();$(window).hashchange();this._model.getBookmarkTitles(function(bookmarks){try{obj._view.populateBookmarks(bookmarks);}catch(e){obj._showError(e);}});var is_liked=this._model.isLiked(this._model.getCachedId());this._view.updateLikeLink(is_liked);var is_bookmarked=this._model.isBookmarked(this._model.getCachedId());this._view.updateBookmarkLink(is_bookmarked);this._search(null,function(){obj._restoreVideoDescriptionState();});}catch(e){this._showError(e);}},_hashCheck:function(){var url=/university\/video\/([^\/]*)\/?/.exec(window.location.href);if(url!==null&&typeof url=='object'&&typeof url[1]!='undefined'){window.location.replace(this._opts.video_hash_url+url[1]);return false;}
return true;},_initHashChange:function(){var obj=this;$(window).hashchange(function(){try{var slug=obj._model.getSlugFromHash();if(slug.length){obj._loadVideoBySlug(slug);}else{var default_slug=obj._model.getCachedSlug();window.location.href=obj._opts.video_hash_url+
default_slug;}}catch(e){obj._showError(e);}});},_initSearchVideoLinks:function(){var obj=this;var sel='.results-list .info h4 a, .results-list .thumb a';this._$(document).on('click',sel,function(){var link=$(this),id=link.parents('li').attr('id');window.setTimeout(function(){if(id==obj._model.getCachedId()){obj._view.scrollToVideo();}else{obj._view.scrollToVideo(function(){obj._view.unloadVideo();window.location.href=link.attr('href');});}},200);return false;});},_initLikeLink:function(){var obj=this;this._$('.like a').click(function(){try{var id=obj._model.getCachedId();if(!obj._model.isLiked(id)){obj._model.incrementLikes(id,function(){try{obj._model.saveLike(id);obj._view.updateLikeLink(true);}catch(e){obj._showError(e);}});}}catch(e){obj._showError(e);}
return false;});},_initBookmarkLink:function(){var obj=this;this._$('.bookmark a').click(function(){var id=obj._model.getCachedId();if(!obj._model.isBookmarked(id)){try{obj._model.addBookmark(id);obj._model.getBookmarkTitles(function(bookmarks){try{obj._view.populateBookmarks(bookmarks);}catch(e){obj._showError(e);}});obj._view.updateBookmarkLink(true);}catch(e){obj._showError(e);}}
return false;});},_initLoadBookmarkLinks:function(){var obj=this;this._$('.bookmarked-videos').on('click','.load',function(){var link=$(this),id=link.parents('li').attr('id').replace(/^bookmark_/,'');if(id==obj._model.getCachedId()){obj._view.scrollToVideo();}else{obj._view.unloadVideo();obj._view.scrollToVideo(function(){window.location.href=link.attr('href');});}
return false;});},_initRemoveBookmarkLinks:function(){var obj=this;this._$(document).on('click','.bookmarked-videos .remove',function(){var id=$(this).parent().attr('id').replace(/bookmark_/,'');obj._model.removeBookmark(id);$(this).parent().fadeOut(300,function(){try{$(this).remove();obj._model.getBookmarkTitles(function(bookmarks){try{obj._view.populateBookmarks(bookmarks);obj._view.updateBookmarkLink(false);}catch(e){obj._showError(e);}});}catch(e){obj._showError(e);}});return false;});},_initVideoDescriptionLink:function(){var obj=this;this._$('.video-stats .description a').click(function(){var state=obj._model.getDescriptionState();obj._view.toggleVideoDescription(!state);obj._model.saveDescriptionState(!state);return false;});},_initDownloadLink:function(){this._$('.download a').click(function(){window.open($(this).attr('href'));return false;});},_restoreVideoDescriptionState:function(){if(!this._model.isDescriptionStateSet()){var state=true;this._model.saveDescriptionState(true);}else{var state=this._model.getDescriptionState();}
this._view.toggleVideoDescription(state);},_loadVideoBySlug:function(slug){var obj=this;this._view.unloadVideo();this._model.getVideoBySlug(slug,function(video){if(typeof video!='undefined'){obj._view.scrollToVideo(function(){try{obj._view.populateVideo(video);obj._view.updateMetaInfo(video);var is_liked=obj._model.isLiked(obj._model.getCachedId());obj._view.updateLikeLink(is_liked);var is_bookmarked=obj._model.isBookmarked(obj._model.getCachedId());obj._view.updateBookmarkLink(is_bookmarked);obj._view.updateLikeButton();obj._view.updateTweetButton();obj._updateSocialLinks();}catch(e){obj._showError(e);}});}else{obj._showError('Video not found');}});},_search:function(page,callback){callback=(typeof callback=='function'?callback:function(){});var obj=this;this._busy=true;this._dropdowns.disableAll();var params=this._dropdowns.getValues();var video_type=this._tabs.getCurrentTabName();this._model.getSearchData(video_type,params,page,function(data){try{obj._paginator.build(data.videos.pages);obj._view.populateSearchResults(data.videos.data);Cufon.replace('.results-list h4',{fontFamily:'Akagi',hover:true});obj._view.fadeInSearchResults();obj._view.updateVideoCount(data.videos.pages.totalItemCount);obj._dropdowns.populate(data.search,function(){try{obj._dropdowns.enableAll();obj._busy=false;callback(data);}catch(e){obj._showError(e);}});}catch(e){obj._showError(e);}});},_updateSocialLinks:function(){this._view.updateLikeButton();this._view.updateTweetButton();this._plusone.renderPlusOneButton(this._$('.social-links .google'));}});
