var HighlanderComments=jQuery.extend(HighlanderComments,{autosaveInterval:false,commentList:null,cookies:{facebook:'wpc_fbc',twitter:'wpc_tc',wordpress:'wpc_wpc'},popups:{facebook:',height=400,width=600',twitter:',height=515,width=600',wordpress:',height=500,width=500'},currentParent:false,currentParentId:false,currentParentMargins:{},init:function(){jQuery('#respond').addClass('js');HighlanderComments.commentList=jQuery('#thecomments, .thecomments, #commentlist, #comment-list, #comments-list, .commentlist, .comment-list, .comments-list, .com-list').last();jQuery('#comment-form-nascar a').click(HighlanderComments.clickService);jQuery('#postas-wordpress').click(HighlanderComments.clickExternalTab);jQuery('#postas-facebook, #labelto-facebook').click(HighlanderComments.clickExternalTab);jQuery('#postas-twitter, #labelto-twitter').click(HighlanderComments.clickExternalTab);jQuery('#labelto-wordpress').click(HighlanderComments.checkPostToWordPress);jQuery('#comment-form-post-to-edit a').click(HighlanderComments.editShareText);jQuery(window).resize(HighlanderComments.toggleShareLabels);HighlanderComments.toggleShareLabels();HighlanderComments.restoreComment();jQuery.each(jQuery('.comment-form-field input, textarea#comment'),function(){if(jQuery(this).val()!==''){HighlanderComments.hideLabels(jQuery(this));}});jQuery('div.comment-form-fields input').change(function(){HighlanderComments.toggleLabel(jQuery(this));}).focus(function(){HighlanderComments.hideLabels(jQuery(this));}).blur(function(){HighlanderComments.showLabels(jQuery(this));});jQuery('div.comment-form-fields label').click(function(){HighlanderComments.hideLabels(jQuery(this).parent().children('.comment-form-input input'));});jQuery('#email').blur(function(){HighlanderComments.updateAvatarWithGravatar('#email');if(!jQuery('#author').val()){Gravatar.autofill(jQuery(this).val(),{'displayName':'author','profileUrl':'url','url':'link'});var afd=Gravatar.autofill_data;Gravatar.autofill_data=function(hash){afd.call(Gravatar,hash);jQuery('input#url').change();jQuery('input#author').change().click();};}});jQuery('textarea#comment') .autoResize({animate:false}) .trigger('change.dynSiz') .focus(function(){HighlanderComments.hideLabels(jQuery(this));}) .blur(function(){HighlanderComments.showLabels(jQuery(this));}) .keydown(function(e){if('undefined'!=typeof e.keyCode&&9==e.keyCode){e.preventDefault();if('guest'==jQuery('#hc_post_as').val()){if(1==HighlanderComments.comment_registration) jQuery('#postas-wordpress').focus();else jQuery('#email').focus();}else{jQuery('#comment-submit').focus();}}}) .keyup(function(e){HighlanderComments.fillShareText(jQuery(this));});jQuery('#commentform').submit(function(){var verified=true,email,author;if(''===jQuery('textarea#comment').val()){jQuery('label[for="comment"]').fadeOut('fast',function(){jQuery(this).text(HighlanderComments.enterACommentError).fadeIn('fast').addClass('error');});jQuery('#comment-form-comment').addClass('error');jQuery('textarea#comment').focus(function(){jQuery(this).parent('#comment-form-comment').removeClass('error');});verified=false;} if('guest'==jQuery('#hc_post_as').val()&&(jQuery('#comment-form-guest label span[class="required"]').size()||jQuery('#comment-form-guest label[class="error"]').size())){email=jQuery('#email').val();if(''===email||!email.match(/^.*@.*\..*$/)){jQuery('label[for="email"]').fadeOut('fast',function(){var error;if(''==email){error=HighlanderComments.enterEmailError;}else{error=''+HighlanderComments.invalidEmailError+'';} jQuery(this).html(error).css('opacity',1).fadeIn('fast').addClass('error');});jQuery('div.comment-form-email .comment-form-input').addClass('error');jQuery('input#email').focus(function(){jQuery(this).parent().removeClass('error');});verified=false;} author=jQuery('#author').val();if(''===author){jQuery('label[for="author"]').fadeOut('fast',function(){jQuery(this).text(HighlanderComments.enterAuthorError).fadeIn('fast').addClass('error');});jQuery('div.comment-form-author .comment-form-input').addClass('error');jQuery('input#author').focus(function(){jQuery(this).parent().removeClass('error');});verified=false;}} if('1'==HighlanderComments.comment_registration&&'guest'==jQuery('#hc_post_as').val()){jQuery('#comment-form-nascar > p').addClass('error').fadeOut('fast',function(){jQuery(this).fadeIn('fast');});verified=false;} HighlanderComments.writeCookie('hc_post_as',jQuery('#hc_post_as').val(),7,'.wordpress.com');if(!verified){return false;} HighlanderComments.clickSubmit();return true;});if('1'==HighlanderComments.comment_registration){if(!HighlanderComments.userIsLoggedIn){HighlanderComments.clickGuestTab();jQuery('#comment-form-wordpress').removeClass('selected');jQuery('#hc_post_as').val('guest');}}else{if(HighlanderComments.userIsLoggedIn&&jQuery('#comment-form-wordpress.selected').length){jQuery('#comment-form-guest').slideUp('fast',function(){HighlanderComments.clickExternalTab('wordpress');});}} if(jQuery('.comment-form-service.selected').not('#comment-form-guest.selected').length){jQuery('#comment-form-nascar').hide();} if('undefined'!==typeof addComment){HighlanderComments._moveForm=addComment.moveForm;addComment.moveForm=HighlanderComments.moveForm;} jQuery('#comment-form-guest .comment-form-avatar').hover(function(){pos=jQuery(this).offset();style='top:'+(pos.top-10)+'px;left:'+(pos.left+35)+'px;';jQuery('body').append('
'+HighlanderComments.gravatarFromEmail+'
');},function(){jQuery('#hltt-grav').fadeOut('fast',function(){jQuery(this).remove();jQuery('.highlander-tooltip').remove();});});jQuery('#comment-form-nascar ul').hover(function(){pos=jQuery(this).offset();style='top:'+(pos.top-12)+'px;left:'+(pos.left-125)+'px;';jQuery('body').append('
'+HighlanderComments.logInToExternalAccount+'
');},function(){jQuery('#hltt-auth').fadeOut('fast',function(){jQuery(this).remove();jQuery('.highlander-tooltip').remove();});});},_moveForm:null,moveForm:function(commId,parentId,respondId,postId){if(null===HighlanderComments._moveForm){return;} var t=this,r=false,respond=jQuery('#'+respondId).css({marginLeft:0,marginRight:0}),w,wTop,commElement,rHeight,cTop,rTop;if(HighlanderComments.currentParent){if(parentId===HighlanderComments.currentParentId){return false;} w=jQuery(window);wTop=w.scrollTop();commElement=jQuery('#'+commId);cTop=commElement.offset().top;rTop=respond.offset().top;if(rTop<=cTop){rHeight=respond.outerHeight(true);respond.before(jQuery('
').css({margin:0,padding:0,border:0,height:rHeight,visibility:'hidden',position:respond.css('position')}));} r=HighlanderComments._moveForm.call(t,commId,parentId,respondId,postId);if(false!==r){return r;} HighlanderComments.currentParent.stop(true,true).css(HighlanderComments.currentParentMargins);jQuery('#highlander-placeholder').remove();if(rTop<=cTop){jQuery(window).scrollTop(wTop-rHeight);} HighlanderComments.moveFormNow.call(t,commId,parentId,respondId);}else{r=HighlanderComments._moveForm.call(t,commId,parentId,respondId,postId);if(false===r){HighlanderComments.moveFormNow.call(t,commId,parentId,respondId);}} return r;},moveFormNow:function(commId,parentId,respondId){HighlanderComments.currentParent=jQuery('#comment-'+parentId).parents('.highlander-comment').andSelf().filter('.highlander-comment').last();if(!HighlanderComments.currentParent.size()){HighlanderComments.currentParent=jQuery('#comment-'+parentId).parents('.comment').andSelf().filter('.comment').last();} HighlanderComments.currentParentId=parentId;var respond=jQuery('#'+respondId);if(!HighlanderComments.currentParent.find(respond).size()){var betterParent=HighlanderComments.currentParent.parents('.children:first');if(!betterParent.size()){betterParent=HighlanderComments.currentParent.parents('.highlander-comment:first');if(!betterParent.size()){betterParent=HighlanderComments.currentParent.parents('.comment:first');}} if(betterParent.size()){HighlanderComments.currentParent=betterParent;}} HighlanderComments.currentParentMargins={backgroundColor:HighlanderComments.currentParent.css('backgroundColor'),marginLeft:HighlanderComments.currentParent.css('marginLeft'),marginRight:HighlanderComments.currentParent.css('marginRight')};var oldOff,newOff,offOrder,autoWidth=false;if('ltr'===HighlanderComments.currentParent.css('direction')){offOrder=['Right','Left'];}else{offOrder=['Left','Right'];} jQuery.each(offOrder,function(i,v){if('0px'===HighlanderComments.currentParentMargins['margin'+v]){oldOff=HighlanderComments.currentParent.offset().left;if('Right'===v){oldOff+=HighlanderComments.currentParent.outerWidth();} HighlanderComments.currentParent.css('margin'+v,0);newOff=HighlanderComments.currentParent.offset().left;if('Right'===v){newOff+=HighlanderComments.currentParent.outerWidth();} if(oldOff!==newOff){newOff='Right'===v?newOff-oldOff:oldOff-newOff;HighlanderComments.currentParent.css('margin'+v,newOff);HighlanderComments.currentParentMargins['margin'+v]=newOff;autoWidth=true;}}});if(autoWidth){HighlanderComments.currentParent.css('width','auto');HighlanderComments.currentParentMargins.width='auto';} var rgbaTransparent=/rgba.*,\s*0\s*\)/,cp,bg,bgi;if('transparent'===HighlanderComments.currentParentMargins.backgroundColor||HighlanderComments.currentParentMargins.backgroundColor.match(rgbaTransparent)){cp=HighlanderComments.currentParent.get(0);bg='transparent';bgi=HighlanderComments.currentParent.css('backgroundImage');while('none'===bgi&&cp.parentNode&&cp.parentNode!=document&&('transparent'===bg||bg.match(rgbaTransparent))){cp=cp.parentNode;bg=jQuery(cp);bgi=bg.css('backgroundImage');bg=bg.css('backgroundColor');} HighlanderComments.currentParent.css('backgroundColor',bg);} var cancel=document.getElementById('cancel-comment-reply-link'),listOffsetSource=HighlanderComments.commentList,listOffset,parentOffset=HighlanderComments.currentParent.offset(),currentParentMargins=HighlanderComments.currentParentMargins,redoMargins=false,grandWidth;cp=HighlanderComments.currentParent;while(!cp.is(HighlanderComments.commentList)&&!cp.is(document)){if('hidden'===cp.css('overflow')||'hidden'===cp.css('overflow-x')){listOffsetSource=cp;break;} cp=cp.parent();} listOffset=listOffsetSource.offset();HighlanderComments._unmoveForm=cancel.onclick;cancel.onclick=function(){return HighlanderComments.unmoveForm.call(this);};if(-1
');});},_unmoveForm:null,unmoveForm:function(){var r=HighlanderComments._unmoveForm.call(this);if(false!==r){return r;} HighlanderComments.currentParent.stop(true,true).animate(HighlanderComments.currentParentMargins,350,function(){HighlanderComments.currentParent.css(HighlanderComments.currentParentMargins);HighlanderComments.currentParent=HighlanderComments.currentParentId=false;});jQuery('#respond').stop(true,true).show();jQuery('#respond div#threaded-clear').remove();return r;},HTMLToText:function(string){return jQuery('').html(string).text();},autosaveComment:function(){var oneDay=new Date();oneDay.setTime(oneDay.getTime()+86400000);document.cookie='comment-'+HighlanderComments.postID+'='+encodeURIComponent(jQuery('#comment').val())+'; expires='+oneDay.toGMTString()+'; path=/';},unsaveComment:function(){var oneDay=new Date();oneDay.setTime(oneDay.getTime()-86400000);document.cookie='comment-'+HighlanderComments.postID+'= ; expires='+oneDay.toGMTString()+'; path=/';},restoreComment:function(){var parts=document.cookie.split(';'),part;jQuery.each(parts,function(i){part=parts[i].split('=');if('comment-'+HighlanderComments.postID===jQuery.trim(part[0])){if('undefined'!==typeof part[1]&&'undefined'!==part[1]&&''!==decodeURIComponent(part[1])){jQuery('#comment').val(decodeURIComponent(part[1]));} return;}});},switchAccount:function(){jQuery('.comment-form-service').removeClass('selected').hide();jQuery('#hc_post_as').val('guest');jQuery('#comment-form-nascar > p').removeClass('error');if('1'==HighlanderComments.comment_registration){jQuery('#comment-form-nascar').show();jQuery('#comment-form-guest').hide();}else{jQuery('#comment-form-nascar').show();jQuery('#comment-form-guest').slideDown('fast');HighlanderComments.clickGuestTab();}},clickService:function(e){e.preventDefault();var tab=this.href.replace(/^.*#/,'#').split(':');if('#comment-form-load-service'===tab[0]&&tab[1]){jQuery('#comment-form-load-service p').text(HighlanderComments.connectingToText.replace('%s',tab[1]));}else{jQuery('#hc_post_as').val(tab[0].split('-').pop());} jQuery('.comment-form-service') .css('visibility','hidden') .show() .removeClass('selected') .filter(tab[0]) .css('visibility','visible') .fadeIn('fast') .end() .not(tab[0]) .hide() .css('visibility','visible');jQuery('#comment-form-nascar li.selected').removeClass('selected');jQuery(this).parent().addClass('selected');},clickGuestTab:function(e){if('1'==HighlanderComments.comment_registration) jQuery('#comment-form-guest').hide();if(-1');}else{jQuery('#comment-form-'+service+' .comment-form-avatar img') .attr('src',('https:'===location.protocol?'https://s-ssl.wordpress.com/':'http://s.wp.com/')+'imgpress?url='+encodeURIComponent(data.avatar)+'&resize=25,25');} jQuery('#email').val(data.email).change();jQuery('#author').val(data.name).change();jQuery('#url').val(data.link).change().click();jQuery('#'+service+'-avatar').val(data.avatar);jQuery('#'+service+'-user_id').val(data.uid);jQuery('#'+service+'-access_token').val(data.access_token);jQuery('#hc_post_as').val(service);if(service==jQuery('#comment-form-nascar li.selected a').attr('id').replace('postas-','')){jQuery('#comment-form-load-service').hide();jQuery('#comment-form-'+service).show();jQuery('#comment-form-'+service+' .comment-form-posting-as strong').text(data.name+':');}},doExternalCanceled:function(service,from_tab){if(from_tab){jQuery('#comment-form-'+service+' .comment-form-avatar img').attr('src',('https:'===location.protocol?'https://secure':'http://www')+'.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25&d='+encodeURIComponent(HighlanderComments.gravDefault));jQuery('.comment-meta-'+service).val('');jQuery('#postas-'+service+' span').html('     ');jQuery('#comment-form-'+service).hide();HighlanderComments.switchAccount();} jQuery('#postto-'+service).prop('checked',false);},doExternalLogout:function(service){var hostname;if(-1!==document.location.hostname.indexOf('.wordpress.com')){hostname='wordpress.com';}else{hostname=document.location.hostname;} HighlanderComments.writeCookie(HighlanderComments.cookies[service],'',-10,hostname);HighlanderComments.doExternalCanceled(service,true);if('wordpress'==service){HighlanderComments.userIsLoggedIn=false;jQuery('body').append('