var diCanPost=true,diCanVote=true,diServer="http://account.discussit.com",diLangRef="en";function diPost(j){if(diCanPost){diCanPost=false;var a=[],d=jQuery("#txtdiNickname").attr("value"),c=jQuery("#txtdiEmail").attr("value"),h=jQuery("#txtdiURL").attr("value"),b=jQuery("#txtdiBody").attr("value"),g=false;if(j){b=jQuery("#txtdiReplyBody").attr("value");c=jQuery("#txtdiREmail").attr("value");d=jQuery("#txtdiRNickname").attr("value");h=jQuery("#txtdiRURL").attr("value")}if(b==""||b=="Enter text right here!")a[a.length]="Message has no content.";if(d=="")a[a.length]="Name required to post.";if(jQuery("#di-ealert").is(":checked")||jQuery("#di-eralert").is(":checked")){g=true;if(c=="")a[a.length]="Email required for notifications.";else if(!isEmail(c))a[a.length]="Valid email required for notifications."}if(a.length>0){for(var e="<ul>",f=0;f<a.length;f++)e+="<li>"+a[f]+"</li>";e+="</ul>";jQuery.diMsg({body:e});diCanPost=true}else{jQuery.diMsg({body:"Please wait...",title:"Posting message",hideButton:true});var i=typeof threadRef==="undefined"?"":threadRef;jQuery.ajax({type:"GET",url:diServer+"/Threads/PostMsg?callback=?",data:{WID:widgetID,diTI:jQuery("#diTI").attr("value"),diIdent:jQuery("#diIdent").attr("value"),txtdiNickname:d,txtdiEmail:c,txtdiURL:h,diMug:jQuery("#diMug").attr("value"),txtdiBody:b.replace(/\'/g,"&apos;"),diRT:jQuery("#diRT").attr("value"),diNotify:g,score:jQuery("td > .diStars a.solid").length,ThreadRef:i},dataType:"json",jsonp:"diPostSuccess",success:diPostSuccess})}}}function diPostSuccess(a){if(a[0].status.indexOf("Success")>-1){typeof pageTracker!="undefined"&&pageTracker._trackEvent("Comments","Post",jQuery("#txtdiNickname").attr("value"));typeof diPosted!="undefined"&&diPosted();diInject()}else if(a[0].status.indexOf("Awaiting moderation")>-1){jQuery("#txtdiBody").val("");jQuery("#txtdiReplyBody").val("");jQuery(".diPopHead").html("Message posted");jQuery(".diPopBody").html("Awaiting moderation.");jQuery(".diPopFoot").html('<a class="diBtn" href="Javascript:jQuery.diMsg.close();"><span>Ok</span></a>')}else{jQuery(".diPopHead").html("Problem!");jQuery(".diPopBody").html(a[0].status+".");jQuery(".diPopFoot").html('<a class="diBtn" href="Javascript:jQuery.diMsg.close();"><span>Ok</span></a>');diCanPost=true}}function diInject(){var b=typeof threadRef==="undefined"?"":threadRef,a=typeof diLangRef==="undefined"?"":diLangRef;jQuery.ajax({type:"GET",url:diServer+"/Threads/GetThreadJSON?callback=?",data:{ThreadRef:b,Logout:0,WidgetID:widgetID,LangShortCode:a},dataType:"json",jsonp:"diCb",success:diCb})}function diInjectReply(a){var b=typeof diLangRef==="undefined"?"":diLangRef;diCancelRep();jQuery.ajax({type:"GET",url:diServer+"/Threads/ReplyForm?callback=?",data:{ReplyID:a,allowAnon:jQuery("#diAnon").val(),Ident:jQuery("#diIdent").attr("value"),LangShortCode:b},dataType:"json",jsonp:"diReply",success:diReply})}function diReply(b){var a="#dim_"+jQuery("#diRT").attr("value");jQuery(a).append(jQuery(b[0].widget));jQuery("#direp").show("slow");jQuery("#direp").find(".diOAuth").text("Replying to: "+jQuery(a).find(".diAuth").text());jQuery("#txtdiRNickname").val(jQuery("#txtdiNickname").val());jQuery("#txtdiREmail").val(jQuery("#txtdiEmail").val());jQuery("#txtdiRURL").val(jQuery("#txtdiURL").val());jQuery("#txtdiReplyBody").focus()}function diCancelRep(){typeof jQuery("#direp")!="undefined"&&jQuery("#direp").remove()}function diShare(b){u=location.href;t=document.title;var a="http://twitter.com/share?original_referer="+encodeURIComponent(u)+"&source=DiscussIt&url="+encodeURIComponent(u);if(b=="facebook")a="http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t);window.open(a,"sharer","toolbar=0,status=0,width=726,height=436")}function diCb(c){jQuery("#diThr").html(c[0].widget);diCanPost=true;for(var b=0;b<jQuery(".di_Social").length;b++)jQuery(".di_Social:eq("+b+")").parent().find(".diAuth").text()==jQuery("#txtdiNickname").attr("value")&&jQuery(".di_Social:eq("+b+")").html("<div><span><style> html .tw_share_link { margin:4px; padding:0 0 0 20px; height:20px; background:url("+diServer+'/content/i/twitter_16.png) no-repeat top left; }</style><a href="#_" onclick="diShare(\'twitter\')" class="tw_share_link">Tweet this</a></span><span><style> html .fb_share_link { margin:4px; padding:0 0 0 20px; height:20px; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top left; }</style><a href="#_" onclick="diShare(\'facebook\')" class="fb_share_link">Share on Facebook</a></span></div>');jQuery.diMsg.close();jQuery(".diBody").lnks();var a=jQuery("#diEmb").val();jQuery(".diLnk").embMedia({img:Boolean(Number(a.substr(0,1))),vid:Boolean(Number(a.substr(1,1))),mus:Boolean(Number(a.substr(2,1))),doc:Boolean(Number(a.substr(3,1)))});!jQuery("#dilnkback").length&&jQuery("#diThr").append('<a id="dilnkback" href="http://www.discussit.com"><img border="0" src="http://account.discussit.com/content/i/di_poweredby_light.png" alt="Comments powered by DiscussIt" /></a>');if(window.location.hash.indexOf("comment")>-1)window.location=window.location.hash;typeof diCbEnd!="undefined"&&diCbEnd()}function diLogout(){var a=typeof diLangRef==="undefined"?"":diLangRef,b=typeof threadRef==="undefined"?"":threadRef;jQuery.ajax({type:"GET",url:diServer+"/Threads/GetThreadJSON?callback=?",data:{threadRef:b,logout:1,widgetID:widgetID,LangShortCode:a},dataType:"json",jsonp:"diCb",success:diCb})}function diVote(a,c){if(diCanVote){diCanVote=false;var b=Number(jQuery("#dim_"+a+" > .head > .diVote").html())+c;if(b=="")b="0";jQuery("#dim_"+a+" > .head > .diVote").html(b);var d=typeof diLangRef==="undefined"?"":diLangRef;jQuery.ajax({type:"GET",url:diServer+"/Threads/Vote?callback=?",data:{mID:a,vote:c,langShortCode:d},dataType:"json",jsonp:"diVoteCb",success:diVoteCb})}}function diVoteCb(a){if(a[0].status!="{Success}"){var b=Number(jQuery("#dim_"+a[0].messageID+" > .head > .diVote").html())-Number(a[0].vote);if(b=="")b="0";jQuery("#dim_"+a[0].messageID+" > .head > .diVote").html(b);jQuery.diMsg({body:a[0].status+"."})}diCanVote=true}function diReport(a){jQuery.diMsg({title:"Report Abusive Comment",body:"Are you sure you want to report this message to the site moderator(s)?",buttonText:"Cancel",button2Text:"Report",button2Function:"diReportGo('"+a+"');"})}function diReportGo(a){jQuery.diMsg.close();jQuery.ajax({type:"GET",url:diServer+"/Threads/Report?callback=?",data:{mID:a},dataType:"json",jsonp:"diReportCb",success:diReportCb})}function diReportCb(a){if(a[0].status=="Success")jQuery.diMsg({title:"Thanks",body:"Thanks for bringing this to our attention."});else jQuery.diMsg({body:a[0].status+"."})}function diLogin(){var a=typeof diLangRef==="undefined"?"":diLangRef;jQuery.diMsg({body:"<div id='di_rpx' style='height:290px;'><iframe src=\"https://dis-cuss-it.rpxnow.com/openid/embed?token_url="+encodeURIComponent(diServer+"/threads/userdetails?RetUrl="+encodeURIComponent(window.location))+"&language_preference="+a+'" scrolling="no" frameBorder="no" style="width:360px;height:240px;"></iframe></div>',title:"Login",buttonText:"Cancel",width:400})}function whySignin(){jQuery.diMsg({title:"Why Sign-In?",body:"<ul><li>Instant profile</li><li>Track your replies and responses with ease</li><li>Cross post comments with your social networks</li></ul>"})}function diReplyTo(a){jQuery("#diRT").val(a);diInjectReply(a)}function diClearText(){jQuery("#diRT").val("")}function showloading(){jQuery("#diThr").html("<div id='diLoading'>Loading comments...<br/><img src='"+diServer+"/content/i/processingbar.gif' alt='loading'></div>")}jQuery(document).ready(function(){showloading();diInject();typeof diLoaded!="undefined"&&diLoaded()});(function(a){a.diMsg=function(e){a.diMsg.close();var c={title:"Problem!",buttonText:"Ok",button2Text:"",button2Function:"",width:370,hideButton:false};a.extend(c,e);var d='<div class="diOverlay"></div><div class="diPop"><div class="diPopIn"><label class="diPopHead">'+c.title+'</label><div class="diPopBody">'+c.body+'</div><div class="diPopFoot">';if(!c.hideButton)d+='<a class="diBtn" href="Javascript:jQuery.diMsg.close();"><span>'+c.buttonText+"</span></a>";d+="</div></div></div>";a("body").append(d);c.button2Text!=""&&a(".diPopFoot").append('<a class="diBtn" href="Javascript:'+c.button2Function+'"><span>'+c.button2Text+"</span></a>");a(".diOverlay").css({height:a(window).height()+"px",display:"block"});a(".diPop").css({top:b()[1]+200+"px",width:c.width,left:a(window).width()/2-c.width/2,display:"block"});a(".diOverlay").click(function(){a.diMsg.close()})};function b(){var a,b;if(self.pageYOffset){b=self.pageYOffset;a=self.pageXOffset}else if(document.documentElement&&document.documentElement.scrollTop){b=document.documentElement.scrollTop;a=document.documentElement.scrollLeft}else if(document.body){b=document.body.scrollTop;a=document.body.scrollLeft}return[a,b]}a.diMsg.close=function(){a(".diPop").fadeOut(200,function(){a(".diPop").remove()});a(".diOverlay").fadeOut(200,function(){a(".diOverlay").remove()})}})(jQuery);(function(a){a.fn.lnks=function(){var b=/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;this.each(function(){a(this).html(a(this).html().replace(b,'<a class="diLnk" target="_blank" href="$1">$1</a>'))});return a(this)}})(jQuery);(function(a){a.fn.embMedia=function(c){var b={img:true,vid:true,mus:true,doc:true},d=a.extend(b,c);this.each(function(){var c=a(this).attr("href");switch(lnkType(c)){case"image":b.img&&a.ajax({type:"GET",url:diServer+"/threads/thumb?callback=?",data:{url:c,widgetID:widgetID},dataType:"json",jsonp:"diThumb",success:diThumb});break;case"youtube":if(b.vid){var d;if(c.indexOf("youtube.com/watch?v=")>-1)d=c.substr(c.indexOf("?v=")+3,c.length);else if(c.indexOf("youtube.com/watch?f")>-1)d=c.substr(c.indexOf("&v=")+3,c.length);else d=c.substr(c.indexOf("be/")+3,c.length);a(this).replaceWith("<embed src='http://www.youtube.com/v/"+d+"&rel=1' type='application/x-shockwave-flash' wmode='transparent' width='425' height='355'></embed>")}break;case"dailymotion":if(b.vid){var d=c.substr(c.indexOf("video/")+6,6);a(this).replaceWith("<embed src='http://www.dailymotion.com/swf/video/"+d+"' type='application/x-shockwave-flash' allowFullScreen='true' bgcolor='#666666' allowScriptAccess='always' width='480' height='379'></embed>")}break;case"metacafe":b.vid&&a(this).replaceWith('<embed src="http://www.metacafe.com/fplayer/'+c.substr(30,c.length)+'.swf" width="425" height="355" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>');break;case"seesmic":if(b.vid){var d;if(c.indexOf("http://seesmic.com/")>-1)d=c.substr(26,c.length);else d=c.substr(29,c.length);a(this).replaceWith("<object width='425' height='355'><param name='movie' value='http://seesmic.com/embeds/wrapper.swf'/><param name='bgcolor' value='#666666'/><param name='allowFullScreen' value='true'/><param name='allowScriptAccess' value='always'/><param name='flashVars' value='video="+d+"&amp;version=threadedplayer'/><embed src='http://seesmic.com/embeds/wrapper.swf' type='application/x-shockwave-flash' flashVars='video="+d+"&amp;version=threadedplayer' allowFullScreen='true' bgcolor='#666666' allowScriptAccess='always' width='425' height='355'></embed></object>")}break;case"vimeo":if(b.vid){var d;if(c.indexOf("http://vimeo.com/")>-1)d=c.substr(17,c.length);else d=c.substr(21,c.length);a(this).replaceWith("<object width='425' height='355'><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id="+d+"&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' /><embed src='http://vimeo.com/moogaloop.swf?clip_id="+d+"&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='425' height='355'></embed></object>")}break;case"audioboo":b.mus&&a(this).replaceWith('<object data="http://boos.audioboo.fm/player_mp3.swf" height="104" type="application/x-shockwave-flash" width="390"><param name="movie" value="http://boos.audioboo.fm/player_mp3.swf" /><param name="FlashVars" value="mp3='+c+'.mp3" /><param name="wmode" value="transparent" /><a href="'+c+'.mp3">Listen!</a></object>');break;case"mp3":b.mus&&a(this).replaceWith('<object type="application/x-shockwave-flash" data="'+diServer+'/Content/MP3player.swf" height="24" width="290"><param name="movie" value="'+diServer+'/Content/MP3player.swf"><param name="FlashVars" value="soundFile='+c+'"><param name="quality" value="high"><param name=\'menu\' value=\'false\'><param name="wmode" value="transparent"></object>');break;case"ebay":if(b.doc){var e=ETLD(c),f=c.substr(c.indexOf("?")-12,12);(e==".co.uk"||e==".com"||e==".de")&&a(this).replaceWith('<object height="300" width="355"><embed src="http://togo.ebay'+e+'/togo/togo.swf" type="application/x-shockwave-flash" flashvars="base=http://togo.ebay'+e+"/togo/&amp;lang=en-gb&amp;mode=normal&amp;itemid="+f+'&amp;query=ploping" height="300" width="355"></object>')}}});return a(this)}})(jQuery);function lnkType(a){var b=[];b[0]=".jpg";b[1]=".gif";b[2]=".png";b[3]=".jpeg";for(i=0;i<b.length;i++)if(a.length-b[i].length==a.indexOf(b[i]))return"image";return a.indexOf("youtube.com/watch?v=")>-1||a.indexOf("youtu.be/")>-1||a.indexOf("youtube.com/watch")>-1?"youtube":a.indexOf("http://www.dailymotion.com/video/")>-1||a.indexOf("http://www.dailymotion.com/embed/video/")>-1?"dailymotion":a.indexOf("http://www.metacafe.com/watch/")>-1?"metacafe":a.indexOf("http://www.vimeo.com/")>-1||a.indexOf("http://vimeo.com/")>-1?"vimeo":a.length-4==a.indexOf(".mp3")?"mp3":a.indexOf("http://audioboo.fm/boos/")>-1?"audioboo":a.indexOf("http://www.ebay.")>-1?"ebay":a.indexOf("http://seesmic.com/videos/")>-1||a.indexOf("http://www.seesmic.com/video/")>-1?"seesmic":void 0}function diThumb(a){jQuery(".diLnk:contains('"+a.url+"')").html(unescape(a.html))}function ETLD(a){var b=a.toString().indexOf("www.ebay.",0)+8,c=a.toString().indexOf("/",b);return a.toString().substring(b,c)}function isEmail(a){var b=/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;return b.test(a)};
