
SL.Video=(function(){var that={};function _rateVideo(videoId,score)
{$.ajax({type:'POST',url:'/videos/rate/',dataType:'json',data:{video_id:videoId,value:score},success:function(data){$('#checkVideoRating').html(data=='0'?'<span style="color: green;">Problem with rating?</span>':'<span style="color: blue;">Thank you for rating.</span>');}});};$(document).ready(function(){var checkVideoRating=$('#checkVideoRating');checkVideoRating.find('img[data-score]').each(function(){var imageRating=$(this);imageRating.hover(function(){checkVideoRating.find('img[data-score]:lt('+imageRating.attr('data-score')+')').attr('src','http://img.scionlane.com/misc/star_on.gif');},function(){checkVideoRating.find('img[data-score]:lt('+imageRating.attr('data-score')+')').attr('src','http://img.scionlane.com/misc/star_off.gif');});imageRating.click(function(){_rateVideo(checkVideoRating.attr('data-video-id'),imageRating.attr('data-score'));});});});return that;})();;(function(c){var a=c.scrollTo=function(f,e,d){c(window).scrollTo(f,e,d)};a.defaults={axis:"xy",duration:parseFloat(c.fn.jquery)>=1.3?0:1};a.window=function(d){return c(window)._scrollable()};c.fn._scrollable=function(){return this.map(function(){var e=this,d=!e.nodeName||c.inArray(e.nodeName.toLowerCase(),["iframe","#document","html","body"])!=-1;if(!d){return e}var f=(e.contentWindow||e).document||e.ownerDocument||e;return c.browser.safari||f.compatMode=="BackCompat"?f.body:f.documentElement})};c.fn.scrollTo=function(f,e,d){if(typeof e=="object"){d=e;e=0}if(typeof d=="function"){d={onAfter:d}}if(f=="max"){f=9000000000}d=c.extend({},a.defaults,d);e=e||d.speed||d.duration;d.queue=d.queue&&d.axis.length>1;if(d.queue){e/=2}d.offset=b(d.offset);d.over=b(d.over);return this._scrollable().each(function(){var l=this,j=c(l),k=f,i,g={},m=j.is("html,body");switch(typeof k){case"number":case"string":if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(k)){k=b(k);break}k=c(k,this);case"object":if(k.is||k.style){i=(k=c(k)).offset()}}c.each(d.axis.split(""),function(q,r){var s=r=="x"?"Left":"Top",u=s.toLowerCase(),p="scroll"+s,o=l[p],n=a.max(l,r);if(i){g[p]=i[u]+(m?0:o-j.offset()[u]);if(d.margin){g[p]-=parseInt(k.css("margin"+s))||0;g[p]-=parseInt(k.css("border"+s+"Width"))||0}g[p]+=d.offset[u]||0;if(d.over[u]){g[p]+=k[r=="x"?"width":"height"]()*d.over[u]}}else{var t=k[u];g[p]=t.slice&&t.slice(-1)=="%"?parseFloat(t)/100*n:t}if(/^\d+$/.test(g[p])){g[p]=g[p]<=0?0:Math.min(g[p],n)}if(!q&&d.queue){if(o!=g[p]){h(d.onAfterFirst)}delete g[p]}});h(d.onAfter);function h(n){j.animate(g,e,d.easing,n&&function(){n.call(this,f,d)})}}).end()};a.max=function(j,i){var h=i=="x"?"Width":"Height",e="scroll"+h;if(!c(j).is("html,body")){return j[e]-c(j)[h.toLowerCase()]()}var g="client"+h,f=j.ownerDocument.documentElement,d=j.ownerDocument.body;return Math.max(f[e],d[e])-Math.min(f[g],d[g])};function b(d){return typeof d=="object"?d:{top:d,left:d}}})(jQuery);(function($){$.fn.slimg=function(args)
{var settings=$.extend({},$.fn.slimg.defaults,args);var parent=$(this);parent.find(settings.images).each(function(){var that=this;var original=$(this);var imageSrc=original.attr('src');if(settings.loadingImage)
{original.attr('src',settings.loadingImage);}
if(settings.loadingWidth)
{original.css({width:settings.loadingWidth});}
var img=$('<img />');img.bind('load',function(){original.removeAttr('style').removeAttr('src').removeAttr('width');original.attr('src',imageSrc);if(settings.maxWidth!==false)
{var maxWidth=(settings.maxWidth===true)?parent.width():settings.maxWidth;(img.attr('width')>maxWidth)?original.attr('width',maxWidth):original.removeAttr('width');}
settings.postResize(that);});img.bind('error abort',function(){original.removeAttr('style').attr('src',imageSrc);if(settings.missingImage!==false)
{original.attr('src',settings.missingImage);}
settings.postError(that);});original.data('slimg-image',img);img.attr('src',imageSrc);});};$.fn.slimg.defaults={images:'img',loadingWidth:false,loadingImage:false,missingImage:false,maxWidth:true,postResize:$.noop,postError:$.noop};})(jQuery);SL.Comments=(function(){var that={};function _bindCommentSubmit(commentBlock)
{commentBlock.find('button[name=addComment]').bind('click',function(){var textArea=commentBlock.find('textarea[name=commentContent]');var content=textArea.val();textArea.val('');if(!content)
{return;}
$.ajax({type:'POST',url:'/comments/ajaxAdd/',dataType:'json',data:{resource_alias:commentBlock.data('resourceAlias'),resource_id:commentBlock.data('resourceId'),comment:content},success:function(data){$.scrollTo(commentBlock,500);commentBlock.find('.pageSectionTop, .pageSectionBottom').html(data.pages);var newComment=$('<div />',{'class':'pageComment',html:data.comment}).css('display','none');newComment.attr('data-comment-block-id',data.id);commentBlock.find('.pageSectionComments').prepend(newComment);newComment.fadeIn(500);_refreshCommentBlock(commentBlock);}});});};function _bindPageButtons(commentBlock)
{commentBlock.find('.pageSectionTop *[data-page], .pageSectionBottom *[data-page]').each(function(){var button=$(this);var pageNumber=button.attr('data-page');button.unbind('click.changePage');button.bind('click.changePage',function(){_changePage(commentBlock,pageNumber);});});};function _changePage(commentBlock,pageNumber)
{$.ajax({type:'POST',url:'/comments/ajaxList/',data:{resource_alias:commentBlock.data('resourceAlias'),resource_id:commentBlock.data('resourceId'),page:pageNumber},success:function(data){commentBlock.data('page',pageNumber);commentBlock.find('.commentHookList').html(data);_refreshCommentBlock(commentBlock);$.scrollTo(commentBlock,500);}});};function _bindDeleteButtons(commentBlock)
{commentBlock.find('.delete').each(function(){var deleteContainer=$(this);var commentId=deleteContainer.attr('data-comment-id');var originalHtml=deleteContainer.html();var deleteAction=deleteContainer.find('*[data-action=delete]');deleteAction.unbind('click.delete');deleteAction.bind('click.delete',function(){deleteContainer.fadeOut(200,function(){deleteContainer.html('Are you sure? '+'<a class="deletePromptYes" data-action="delete-confirm">Yes</a> '+'<a class="deletePromptNo" data-action="delete-cancel">No</a>');deleteContainer.fadeIn(200,function(){deleteContainer.find('*[data-action=delete-confirm]').click(function(){deleteAction.fadeOut(200);$.ajax({type:'POST',url:'/comments/ajaxDelete/',dataType:'json',data:{resource_alias:commentBlock.data('resourceAlias'),resource_id:commentBlock.data('resourceId'),commentId:commentId,page:commentBlock.data('page')},success:function(data){commentBlock.find('*[data-comment-block-id='+commentId+']').slideUp(500,function(){$(this).remove();commentBlock.find('.pageSectionTop, .pageSectionBottom').html(data.pages);if(data.id&&commentBlock.find('*[data-comment-block-id='+data.id+']').size()==0)
{var oldComment=$('<div />',{'class':'pageComment',html:data.comment});oldComment.attr('data-comment-block-id',data.id);commentBlock.find('.pageSectionComments').append(oldComment);oldComment.css({display:'none'}).slideDown(500);}
if(commentBlock.find('*[data-comment-block-id]').size()==0)
{_changePage(commentBlock,commentBlock.data('page')-1);};_refreshCommentBlock(commentBlock);});}});});deleteContainer.find('*[data-action=delete-cancel]').click(function(){deleteContainer.fadeOut(200,function(){deleteContainer.html(originalHtml).fadeIn(200,function(){_bindDeleteButtons(commentBlock);});});});});});});});};function _removeExcessComments(commentBlock)
{commentBlock.find('.pageComment:gt(9)').each(function(){var comment=$(this);comment.fadeOut(500,function(){comment.remove();});});};function _refreshCommentBlock(commentBlock)
{_removeExcessComments(commentBlock);_bindPageButtons(commentBlock);_bindDeleteButtons(commentBlock);commentBlock.slimg({images:'.bbcodeImg',loadingWidth:60,maxWidth:commentBlock.find('li.message:eq(1)').width(),missingImage:'http://img.scionlane.com/icons/delete.gif'});};$(document).ready(function(){$('*[data-module=comments]').each(function(){var commentBlock=$(this);commentBlock.data({page:1,resourceAlias:commentBlock.attr('data-resource-alias'),resourceId:commentBlock.attr('data-resource-id')});_bindCommentSubmit(commentBlock);_refreshCommentBlock(commentBlock);});});return that;})();