function thumbsUp(a){$.getJSON("/ratings/add/"+a,function(c){if(c.status){var b;if(c.new_num_ratings==1){b="1 person likes this video"}else{if(c.new_num_ratings>1){b=c.new_num_ratings+" people like this video"}}$("#ratings").html(b);setRated()}else{}})}function postComment(a,d){$("#add_comment").hide();var c=$("#comment").val();var b="/comments/add/";$.postJSON(b,{comment:c,video_id:a},function(e){if(e.status){showComments(a,e.comments,e.limit,e.page,e.last_page,true);$("#comment").val("")}})}function loadComments(b,a,d){var c="/comments/getComments/"+b+"/limit:"+a+"/page:"+d;$.getJSON(c,function(e){if(e.status){showComments(b,e.comments,e.limit,e.page,e.last_page,false)}})}function showComments(f,g,b,j,h,a){if(g.length>0){var e="";for(var d=0;d<g.length;d++){var k=g[d];e+="<div class='comment'";if(d==0){e+=" id='new_comment'"}e+=">";e+="<h3><a href='/"+k.User.username+"' title="+k.User.username+"&#039;s kitchen'>"+k.User.username+"</a></h3>\n";e+="<p>"+k.Comment.date_ago+"</p>\n";e+="<p>"+k.Comment.comment+"</p>";e+="</div>"}if(j>1){e+="<a href='javascript: void(null);' onclick='loadComments("+f+", "+b+", "+(parseInt(j)-1)+");'>prev</a> "}if(!h){e+="<a href='javascript: void(null);' onclick='loadComments("+f+", "+b+", "+(parseInt(j)+1)+");'>next</a> "}$("#comments").html(e);if(a){$("#new_comment").effect("highlight",null,1500)}}else{$("#comments").text("There are no comments for this video yet.")}}function setRated(){$("#btnAddRating").attr("disabled",true);$("#btnAddRating").html("Thank you!")}function addFav(a){$.getJSON("/favourites/add/"+a,function(b){if(b.status){$("#fav").text("Remove from favourites");$("#fav").unbind();$("#fav").bind("click",function(){removeFav(a)});$("#fav").effect("highlight",1000)}})}function removeFav(a){$.getJSON("/favourites/remove/"+a,function(b){if(b.status){$("#fav").text("Add to favourites");$("#fav").unbind();$("#fav").bind("click",function(){addFav(a)});$("#fav").effect("highlight",1000)}})}function loginThenReturn(){top.location.href="/login?go="+top.location.href}function sendEmail(b){var a=[];$(":input",b).each(function(){a.push(this.name+"="+escape(this.value))});$("#send_email_status").removeClass();$("#send_email_status").html("Sending <img src='/img/clock-grey-16.gif' style='vertical-align: middle;' />");$("#send_email_status").show();$.postJSON(b.action,a.join("&"),function(c){if(c.status){$(":input",b).each(function(){if(this.type!="submit"){this.value=""}});$("#send_email_status").removeClass();$("#send_email_status").addClass("ok");$("#send_email_status").text("Message sent!");$("#send_email_status").effect("highlight",null,1500);setTimeout(function(){$("#send_email_status").fadeOut()},3000)}else{$("#send_email_status").removeClass();$("#send_email_status").addClass("err");$("#send_email_status").text(c.msg)}});return false}function printShoppingList(a,c){var b="/videos/shopping/"+a+"/"+c;openWin(b,"shopping-list",400,460,1)}function openWin(d,c,b,f,e){win_attrib="toolbar=no,location=no,directories=no,menubar=no,resizable,scrollbars="+e+",width="+b+",height="+f+",";win_left=(screen.width-b)/2;win_top=((screen.height-f)/2)-50;if(navigator.appName.indexOf("Microsoft")>=0){win_attrib+="left="+win_left+",top="+win_top}else{win_attrib+="screenX="+win_left+",screenY="+win_top}var a=window.open(d,c,win_attrib);a.focus()};