var cdpVoteCount;var targetDivId="thumbs_count";var cdpVoted=false;function ShowRateIt(){if(!cdpVoted){cdpVoteCount=document.getElementById(targetDivId).innerHTML;document.getElementById(targetDivId).innerHTML="Rate it"}}function HideRateIt(){if(!cdpVoted){document.getElementById(targetDivId).innerHTML=cdpVoteCount}}function ShowHellYa(){if(!cdpVoted){cdpVoteCount=document.getElementById(targetDivId).innerHTML;document.getElementById(targetDivId).innerHTML="Hell ya"}}function HideHellYa(){if(!cdpVoted){document.getElementById(targetDivId).innerHTML=cdpVoteCount}}function ShowHellNo(){if(!cdpVoted){cdpVoteCount=document.getElementById(targetDivId).innerHTML;document.getElementById(targetDivId).innerHTML="Hell no"}}function HideHellNo(){if(!cdpVoted){document.getElementById(targetDivId).innerHTML=cdpVoteCount}}function breakRatingClass(f,e){var d=this;var a=false;var c;var b=e;this.contentId=f;this.isUserLoggedIn=false;this.showText=false;this.isOwnerWatching=false;this.starOutDiv;this.messageOutDiv;this.thumbDivId=targetDivId;this.currentRating;this.ratingCallback;this.saveContentRating=function(k){a=true;cdpVoted=true;try{if(cdpVoteCount!=undefined){document.getElementById(targetDivId).innerHTML=cdpVoteCount}}catch(i){}var g=document.cookie;var h=g.search(/MemberId=/gi);if(h!=-1){g=g.substr(h+9,g.length);h=g.search(/;/gi);if(h!=-1){g=g.substr(0,h)}}var j=new BreakJSON();j.sendBegin("http://websvc.break.com/CMS/handlers/ContentFeedback/ContentFeedbackHandler.ashx?invoke=rate&memberid="+g+"&contentid="+d.contentId+"&vote="+k,d.ratingCallback)};this.getContentRating=function(){var g=new BreakJSON();g.sendBegin("http://websvc.break.com/CMS/handlers/Ratings/ratingsandrecommendationshandler.ashx?invoke=getrate&contentid="+d.contentId,d.updateRateCallback)}}function rate(a){if(!ratingObj.isUserLoggedIn&&!newCdp){GoLogin()}if(!ratingObj.voted){ratingval=a;ratingObj.saveContentRating(a);ratingObj.voted=true}}function publishRatingsCommentsToThirdParty(){var a=ThirdPartyMember.getThirdPartyName();if(a.toLowerCase()==="facebook"){ThirdPartyMember.getName(sendFacebookRatingsComments)}}function sendFacebookRatingsComments(b){hideRatingsCommentBox();var c=b[0];var e=(ratingval.toString()==="1")?"thumbs up":"thumbs down";var h=document.getElementById("rating_thirdparty_comment").value;if(h===""||h===null){h=(ratingval.toString()==="1")?"I liked this video":"I disliked this video"}var f=getMetaDataByName("embed_video_title")+" video";var g=c.first_name+" rated this video "+e;var a={name:f,href:window.location.href,caption:g,description:getMetaDataByName("embed_video_description"),media:[{type:"video",video_src:window.location.href,preview_img:getMetaDataByName("embed_video_thumb_url"),video_title:getMetaDataByName("embed_video_title")}]};var d=[{text:"Watch Video",href:window.location.href}];mcs.postCommentToThirdParty(f,g,ThirdPartyMember.getThirdPartyName(),h,window.location.href,getMetaDataByName("embed_video_description"),getMetaDataByName("embed_video_url"),getMetaDataByName("embed_video_thumb_url"),getMetaDataByName("embed_video_title"),thirdPartRatingsCallback)}function thirdPartRatingsCallback(a){}function getMetaDataByName(b){var a=document.getElementsByName(b);if(a&&a.length>0){return a[0].content}return null}function callBack(a){hideRatingsCommentBox()}function thumbsRatingCallBack(a){if(a.Response.Code==0){ratingObj.currentRating=parseInt(document.getElementById(ratingObj.thumbDivId).innerHTML);if(ratingval>0){rating=parseInt(ratingObj.currentRating)+ratingval;if(rating>=0){ratingObj.currentRating=rating;document.getElementById(ratingObj.thumbDivId).innerHTML=displayThumbCount(rating)}}jQuery("#thumbs_container").fadeOut("slow",function(){document.getElementById("thumbs_container").innerHTML="<span style='font-size:95%;font-weight:bold;color:#336699;'>Thanks</span>";jQuery("#thumbs_container").fadeIn("slow")})}}function GoLogin(){document.location="http://my.break.com/Member/Authentication/Login.aspx?AppRedirect="+location.href}function displayThumbCount(e){var c="",d=String(e),a=d.length-1,g,b,f=d.indexOf(".")-1;if(f<0){f=a}for(b=0;b<=a;b++){c+=g=d.charAt(b);if(b<f&&(f-b)%3==0&&g!="-"){c+=","}}return c}function getThirdPartyRatingCommentOverlay(){return('<style type="text/css">.fb_header{margin-top:5px;margin-left:19px;float:left;width:260px;color:#336699;font-family:Arial;font-size:14px;font-weight:bold;}.fb_mini_header{font-size:14px;}.fb_close{float:right;width:24px;}.fb_register_msg{clear:both;padding:10px 0px 0px;width:260px;margin-left:17px;} .fb_primary_submit {background-color:#3B5998; margin:5px 0px 0px 5px;border-color:#D9DFEA #0E1F5B #0E1F5B #D9DFEA;border-style:solid;border-width:1px;color:#FFFFFF;font-family:"lucida grande",tahoma,verdana,arial,sans-serif;font-size:11px;padding:2px 15px 3px;text-align:center;}.fb_opt_submit {background:#F0F0F0 none repeat scroll 0 0;border-color:#E7E7E7 #666666 #666666 #E7E7E7;color:#000000;}\n\nbody > #fb_rating_box{visibility:hidden;position:absolute;z-index:1000;width:310px;height:200px;border:4px solid #3B5998;}</style><div id="fb_rating_box" style="border:4px solid #3B5998;"><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top"><div class="fb_header">Publish this Rating to Facebook!</div><div class="fb_close"><a href="javascript:void(0);" onclick="hideRatingsCommentBox();return false;" class="regthis_closebox"><img alt="Close" src="http://media1.break.com/static/live/v1/img/site/regthis/regthis_close.gif"/></a></div><div class="register_msg fb_register_msg" style="">Why did you rate the video "thumbs up"?</div><div style="padding:4px 0px 0px 17px;"><table cellspacing="0" cellpadding="0" border="0"><tbody> <tr><td><textarea id="rating_thirdparty_comment" cols="30" rows="6"></textarea></td></tr><tr><td align="right"><input type="button" value="Publish" onclick="publishRatingsCommentsToThirdParty()" name="pub_fb" id="pub_fb" class="fb_primary_submit" /><input type="button" onclick="hideRatingsCommentBox();" value="Skip" name="skip_fb" id="skip_fb" class="fb_primary_submit fb_opt_submit" /></td></tr></tbody></table></div></td></tr></tbody></table></div>')}window.mouseClickX=null;window.mouseClickY=null;function showRatingsCommentBox(a){ThirdPartyMember.showHiddenDiv();if(a!==null){if(a.toString()==="0"||a.toString()==="false"){return}var d=ThirdPartyMember.getThirdPartyName();if(d.toLowerCase()==="facebook"){jQuery("body").append(getThirdPartyRatingCommentOverlay());jQuery("#fb_rating_box").css("position","absolute");jQuery("#fb_rating_box").css("left",mouseClickX);var e=window.location.href;var b=jQuery("#fb_rating_box").height();var c=(parseInt(mouseClickY)-b)-10;if(e.indexOf("/crackle-originals/")!=-1||e.indexOf("/crackle-minisodes/")!=-1){c=parseInt(mouseClickY)}jQuery("#fb_rating_box").css("top",c);jQuery("#fb_rating_box").css("visibility","visible");jQuery("#fb_rating_box").css("background","#FFFFFF url('http://media1.break.com/static/live/v1/img/site/regthis/regthis_bg_cnt_tile.png') repeat-x scroll left bottom");jQuery("#fb_rating_box").css("padding","5px 0px 10px 0px")}}}function hideRatingsCommentBox(){jQuery("#fb_rating_box").css("visibility","hidden")}jQuery(document).ready(function(){jQuery("#thumb_up").click(function(a){mouseClickX=parseInt(a.pageX)-5;mouseClickY=parseInt(a.pageY);if(thirdPartyIsLoggedIntoBreak()){ThirdPartyMember.checkPermissions(showRatingsCommentBox,"publish_stream","playerwrap")}});jQuery("#thumb_down").click(function(a){mouseClickX=parseInt(a.pageX)-5;mouseClickY=parseInt(a.pageY)+10;if(thirdPartyIsLoggedIntoBreak()){ThirdPartyMember.checkPermissions(showRatingsCommentBox,"publish_stream")}})});
