// motion.js

$(document).ready(function(){$('body').removeClass('noscript');$('textarea').addClass('ta');$(':text').addClass('ti');$(':file').addClass('fi');$('.close-me').click(function(){$(this).parent().hide();return false;});function oc(a){var o={};for(var i=0;i<a.length;i++){o[a[i]]='';};return o;}
formFieldFocus();$('#auth-options li').click(function(){authID=$(this).attr('id').replace("signin_option_","");authOption=$("#signin_option_"+authID);if(authOption){for(var i=0;i<auth_types.length;i++){var auth_type=auth_types[i];if(auth_type==authID){$('#signin_with_'+auth_type).show();$('#signin_option_'+auth_type).addClass('selected');}else{$('#signin_with_'+auth_type).hide();$('#signin_option_'+auth_type).removeClass('selected');}}};})
if($('#compose').size()){function fileExtensionCheck(filename,types){var ext=filename.match(/[^\.]+$/);if(!ext)return false;ext=ext.toString();var hash={};for(var i=0;i<types.length;i++)
hash[types[i]]=true;return hash[ext.toLowerCase()];}
var fieldTypes=['title','body','url',"photo",'audio','embed','tags'];var entryTypes={"entry-text":['title','body','tags'],"entry-photo":['title','body','tags','photo'],"entry-link":['title','body','tags','url'],"entry-embed":['title','body','tags','embed'],"entry-audio":['title','body','tags','audio']};var entryClasses={"entry-link":"link","entry-photo":"photo","entry-audio":"audio","entry-embed":"embed"};function updateEntryFields(entryType,speed){if(!entryType.length)return;var speed=(speed)?speed:'';$(entryType).addClass('active').siblings().removeClass('active');var parentID=$(entryType).attr("id");var entryClass=entryClasses[parentID]||'entry';$('#compose-class').val(entryClass);for(var i in fieldTypes){var fieldName="#field-"+fieldTypes[i];if(fieldTypes[i]in oc(entryTypes[parentID])){$(fieldName).fadeIn(speed);$(':input',fieldName).removeAttr('disabled');}else{$(fieldName).hide();$(':input',fieldName).attr('disabled','disabled');}}}
updateEntryFields($('#entry-text'));$('#entry-types li a').click(function(){updateEntryFields($(this).parent(),250);return false;})
$('.more-options').click(function(){$('#entry-fields-optional').fadeIn(450);$(this).hide();});$('.actions').before('<ul id="response-handler"></ul>');if($('.actions ul').size()==0)
$('.actions').append('<ul></ul>');$('#compose').append('<div id="spinner"></div><div id="spinner-status"></div>');$('#homepage-compose').submit(function(){var f=$("#homepage-compose").get(0);var post_type=f.customfield_post_type.value;$("#homepage-compose .default-value").each(function(){$(this).val('');});if(post_type=='audio'){var file_name=f.file_customfield_audio.value;if(!file_name){alert(mt.blog.phrase.fileRequired);return false;}else if(!fileExtensionCheck(file_name,['mp3'])){alert(mt.blog.phrase.invalidFileType);return false;}}else if(post_type=='photo'){var file_name=f.file_customfield_photo.value;if(!file_name){alert(mt.blog.phrase.fileRequired);return false;}else if(!fileExtensionCheck(file_name,['gif','png','jpg','jpeg'])){alert(mt.blog.phrase.invalidFileType);return false;}}
if(post_type=='audio'){f.type_customfield_audio.value='audio';f.ajax.value='';return true;}else if(post_type=='photo'){f.type_customfield_photo.value='image';f.ajax.value='';return true;}
f.ajax.value='1';$(this).ajaxSubmit({target:'#response-handler',beforeSubmit:beforeSubmit,contentType:'application/x-www-form-urlencoded; charset=utf-8',success:displayEntry});return false;});function beforeSubmit(){$('#quickpost-error').fadeOut().remove();$('#spinner, #spinner-status').fadeIn('fast').css('height',$('#compose').height());}
function displayEntry(){if($('#response-handler #quickpost-error').size()==0)
$('#homepage-compose').clearForm();$('#response-handler > li').hide().insertBefore('.actions ul:first li');$('.actions li:first').slideDown();$('#spinner, #spinner-status').fadeOut();formFieldFocus();initEntryHover();}};var flyOut;$(".userpic").hover(function(){$('.user-info').hide();var userInfo=$(this).children('.user-info');flyOut=$.timeout(function(){$(userInfo).fadeIn(200);},500);},function(){$.clear(flyOut);$(this).children('.user-info').fadeOut(200);});$(".userpic *").click(function(){$.clear(flyOut);$('.user-info').fadeOut(250);})
var commentDefaultVal=$('#comment-preview-comment .comment-content div').text();var authorDefaultVal=$("#comment-author").attr('title');var authorVal=$("#comment-author").val();var emailVal=$("#comment-email").val();var urlVal=$("#comment-url").val();if(mtGetUser()){authorVal=mtGetUser().name;emailVal=mtGetUser().email;urlVal=mtGetUser().url;}
$('#comment-preview-comment .author a').text(authorDefaultVal);$('#comment-preview, #comment-preview-comment, #comments-open-text .tip').hide();$('#comments-open-data label:not(:last)').hide();$('.reply-comment-link').hide();$('#comment-preview-comment a').click(function(){return false});$('#comments-form textarea, #comments-form input').focus(function(){showPreview();});$('#comment-text').keyup(function(){updatePreview($(this),$('#comment-preview-comment .comment-content-inner'),commentDefaultVal);});$('#comment-author').keyup(function(){updatePreview($(this),$('#comment-preview-comment .author a'),authorDefaultVal);});if(mt.blog.comments.accepted)
$('#comments-list .comment').each(function(){parentID=$(this).attr('id').replace("comment-","");$('.byline',this).append(' | <a href="#comment-'+parentID+'" title="Reply">Reply</a>');});$('[title="Reply"]').click(function(){if(mt.blog.registration.required){var u=mtGetUser();var loggedin=u&&u.is_authenticated;if(!loggedin)
mtSignInOnClick('comment-greeting');}
replyAuthor=$(this).parent().find('.author').html();$('#comment-preview-comment .reply-comment-link a span').html(replyAuthor);$('#comment-author').keyup(function(){updatePreview($(this),$('#comment-preview-comment .author a'),authorDefaultVal);});$('#comment-preview-comment .reply-comment-link').show();parent_id=this.hash.replace("#comment-","");mtReplyCommentOnClick(parent_id,replyAuthor);return false;});$('#comment-reply').click(function(){$('.reply-comment-link').toggle()});$("#comment-submit").click(function(){$('#comment-preview-comment').fadeOut(1000);$("#comment-submit, #comment-text").attr("disabled","disabled");if($('[name="armor"]')){$('[name="armor"]').val(mt.blog.comments.armor);}
$("#comments-form .default-value").each(function(){$(this).val('');});var staticVal=$('[name="static"]').val();var entryIdVal=$('[name="entry_id"]').val();var langVal=$('[name="lang"]').val();var parentIdVal=$('[name="comment_reply"]').val();var armorVal=$('[name="armor"]').val();var previewVal=$('[name="prev"]').val();var sidVal=$('[name="sid"]').val();var capthchaVal;var tokenVal;if($("#captcha_code")){capthchaVal=$('#captcha_code').val();tokenVal=$('input[name="token"]').val();}
var replyVal=$("#comment-reply").val();var textVal=$("#comment-text").val();var authorVal=$("#comment-author").val();var emailVal=$("#comment-email").val();var urlVal=$("#comment-url").val();if(mtGetUser()){authorVal=mtGetUser().name;emailVal=mtGetUser().email;if(emailVal==undefined)emailVal='';urlVal=mtGetUser().url;if(urlVal==undefined)urlVal='';}
var postData={static:staticVal,entry_id:entryIdVal,parent_id:parentIdVal,armor:armorVal,comment_reply:replyVal,author:authorVal,email:emailVal,url:urlVal,text:textVal,captcha_code:capthchaVal,token:tokenVal};$.ajax({type:"POST",url:mt.blog.comments.script,data:postData,contentType:'application/x-www-form-urlencoded; charset=utf-8',success:function(data){$("#comments-list").html(data);$("#comment-submit, #comment-text").removeAttr("disabled");if($('#comments-list #comment-error').size()>0){$("#comment-preview-comment").fadeIn(1000);}else if($('#comments-list #comment-exclamation').size()>0){$("#comment-text").val('');$("#comment-preview-comment").fadeIn(1000);mtFireEvent('commentposted',postData);}else{$('#comment-preview-comment .comment-content-inner').html(commentDefaultVal);$("#comment-text").val('');mtFireEvent('commentposted',postData);};}});return false;});$("#gall-prev").click(function(){var gall_position=$("#photo-gallery").position();if(gall_position.left<0){if((currentItem-1)>=1){$("#photo-gallery").animate({"left":"+=120px"},"slow","swing",function(){var gall_position_new=$("#photo-gallery").position();if(gall_position_new.left==0){$("#gall-prev").addClass("disabled");}});currentItem--;};$("#gall-next").removeClass("disabled");}});$("#gall-next").click(function(){if(lastItem>=(currentItem+1)){currentItem++;$("#photo-gallery").animate({"left":"-=120px"},"slow");$("#gall-prev").removeClass("disabled");}
if((currentItem)==lastItem){$("#gall-next").addClass("disabled");}});var changeUserpic=$('#userpic-field .field-content #change-userpic');var removeUserpic=$('#userpic-field .field-content #remove-userpic');$(changeUserpic).siblings("input").hide();if(changeUserpic.size()){$(changeUserpic).click(function(){var speed=500;$(this).hide(speed).siblings("img").hide(speed).siblings("input").show(speed);removeUserpic.hide(speed);return false;})};if(removeUserpic.size()){$(removeUserpic).click(function(){var id=$('[name="id"]').val();var token=$('[name="magic_token"]').val();var postData={__mode:'remove_userpic',user_id:id,magic_token:token};$.post(mt.blog.community.script,postData,function(data){var speed=500;$(removeUserpic).hide(speed).siblings("img").hide(speed).siblings("input").show(speed);changeUserpic.hide(speed);});return false;})};initEntryHover();composeMagic();personalizeEditor();personalizeCommentForm();});function initEntryHover(){$(".asset, .actions > ul > li").hover(function(){$(this).addClass('hover');},function(){$(this).removeClass('hover');});}
var commentDefaultVal,authorDefaultVal,authorVal,emailVal,urlVal;function updatePreviewTime(){$('#comment-preview-comment .byline a .published').html($.PHPDate("M d, Y g:i A",new Date()));}
function showPreview(){var u=mtGetUser();var loggedin=u&&u.is_authenticated;if(loggedin){var fooname=mtGetUser().name;$('#comment-preview-comment .byline .author a').html(fooname);}else{$('#comment-preview-comment .byline .author a').html(authorVal);}
$("#comment-preview-comment, #comments-open-text .tip").fadeIn(1000);updatePreviewTime();}
function updatePreview(id,target,defaultVal){v=$(id).val();v=(v.length?v:defaultVal)
v=v.replace(/\n/g,"<br />").replace(/\n\n+/g,'<br /><br />').replace(/(<\/?)script/g,"$1noscript");$(target).html(v);updatePreviewTime();}
function formFieldFocus(){$('input[type=text][value=""], textarea:empty').each(function(){$(this).addClass('default-value').val($(this).attr('title'));});$("input[type=text], textarea").bind('focus',function(){if($.trim($(this).val())==$(this).attr('title'))
$(this).removeClass('default-value').val('');}).bind('blur',function(){if($.trim($(this).val())=='')
$(this).addClass('default-value').val($(this).attr('title'));});}
function ifLoggedIn(){var u=mtGetUser();if(u&&u.is_authenticated&&u.is_author)
return true;}
function setCommenter(){if(mtGetUser()){var authorVal=mtGetUser().name;var emailVal=mtGetUser().email;var urlVal=mtGetUser().url;}}
function personalizeEditor(){var u=mtGetUser();if(u&&u.is_authenticated){if(u.userpic){$("#compose-userpic img").attr({src:u.userpic,alt:u.name});}else{$("#compose-userpic img").wrap('<a href="'+mt.blog.community.script+'?__mode=edit&blog_id='+mt.blog.id+'&return_to='+encodeURIComponent(document.URL)+'"></a>');$('#compose-userpic a').append('<span>Add userpic</span>');};};}
function personalizeCommentForm(){var u=mtGetUser();if(u&&u.is_authenticated){if(u.userpic){$("#commenter-userpic").attr({src:u.userpic,alt:u.name});};};}
function composeMagic(){var u=mtGetUser();if(ifLoggedIn()){if(u.can_post){$('#authenticate').fadeOut('fast');$('#compose').show();$('#compose-magic').val(u.sid);$('#cannot-post').hide();}else if(u.can_comment){$('#authenticate').hide();$('#compose').hide();$('#cannot-post').hide();}else{$('#authenticate').show();$('#compose').hide();$('#cannot-post').show();}}else if(!u){$('#authenticate').show();$('#cannot-post').hide();}else{$('#authenticate').hide();$('#compose').hide();$('#cannot-post').hide();}}
mtAttachEvent('usersignin',composeMagic);mtAttachEvent('usersignin',showPreview);$(document).ready(function(){if($.browser.mozilla){$(window).unload(function(){$(':text, textarea').val('');});}});





// mt.js
var mt;mt={blog:{id:7,url:'http%3A%2F%2Flocalhost%3A8888%2Fgambaro.com%2F',staticWebPath:'http://localhost:8888/mt4-static/',adminScript:'mt.cgi',signInLink:'http://localhost:8888/cgi-bin/mt4/mt-cp.cgi?__mode=login&blog_id=7',signOutLink:'http://localhost:8888/cgi-bin/mt4/mt-cp.cgi?__mode=logout&static=0',comments:{script:'http://localhost:8888/cgi-bin/mt4/mt-comments.cgi',armor:'37bd9af687b4ca54cb24609251945b01550c2a00',accepted:1,captchaFields:''},community:{script:'http://localhost:8888/cgi-bin/mt4/mt-cp.cgi',ifAnonymousRecommendAllowed:0},pings:{accepted:1},registration:{required:1,allowed:1}}};mt.blog.phrase={fileRequired:'Please select a file to post.',invalidFileType:'You selected an unsupported file type.',relativeDate:{momentsAgo:'moments ago',minutesAgo:'1 minute ago',minutesAgoPlural:'2 minutes ago',hoursAgo:'1 hour ago',hoursAgoPlural:'2 hours ago',daysAgo:'1 day ago',daysAgoPlural:'2 days ago'},edit:'Edit',signingIn:'Signing in...',commenter:{auth:'\<a href=\"javas\cript:void(0)\" onclick=\"return mtSignInOnClick(\'comment-greeting\')\"\>Sign in\<\/a\> to comment.',authAnonyous:'\<a href=\"javas\cript:void(0)\" onclick=\"return mtSignInOnClick(\'comment-greeting\')\"\>Sign in\<\/a\> to comment, or comment anonymously.',authBanned:'You do not have permission to comment on this blog. (\<a href=\"javas\cript:void(0);\" onclick=\"return mtSignOutOnClick();\"\>sign out\<\/a\>)',authSuccess:'Thanks for signing in, __NAME__. (\<a href=\"javas\cript:void(0)\" onclick=\"return mtSignOutOnClick();\"\>sign out\<\/a\>)',sessionExpired:'Your session has expired. Please sign in again to comment.',replyingTo:'Replying to \<a href=\"#comment-__PARENT__\" onclick=\"location.href=this.href; return false\"\>comment from __AUTHOR__\<\/a\>'}};var mtCookieName="mt_blog_user";var mtCookieDomain=".localhost";var mtCookiePath="/";var mtCookieTimeout=14400;




// motion_mt.js

$(document).ready(function(){initClickHandlers();mtAttachEvent('load',mtUpdateScores);mtAttachEvent('usersignin',mtUpdateScores);});function initClickHandlers(){$('.favtog').click(function(){var id=$(this).attr('id').replace("favtog","");if($(this).hasClass('scored')){mtMarkScore(id,0,'scored','scored');}else{mtMarkScore(id,1,'scored','scored');}});$('.unpublish').click(function(){var id=$(this).attr('id').replace("unpublish","");mtUnpublishPost(id);});}
function mtUnpublishPost(obj_id){var el=$('#unpublish'+obj_id);if(!el)return false;var u=mtGetUser();if(!u||!u.name)return;$.ajax({type:"POST",url:mt.blog.community.script,data:'__mode=unpublish&jsonp=mtUnpublishPost_cb&id='+obj_id+'&magic_token='+u.sid,success:function(r){var entry=$('#entry-'+obj_id);if(entry.size())entry.hide("slow");$('.comment-entry-'+obj_id).each(function(){$(this).hide("slow");});}});}
function mtMarkScore(obj_id,score,pending,complete){var el=$('#favtog'+obj_id);if(!el)return false;if(score){$(el).addClass(pending);}else{$(el).removeClass(pending);};$.ajax({type:"POST",url:mt.blog.community.script,data:'__mode=vote&ow=1&f=sum&jsonp=mtMarkScore_cb&id='+obj_id+'&score='+score,success:function(r){var sum=eval(r);if(sum==undefined)sum=0;mtMarkScoreResponse(obj_id,score,sum,pending,complete);}});}
function mtMarkScore_cb(s_hash){for(var id in s_hash){return s_hash[id].sum;}}
function mtMarkScoreResponse(obj_id,score,count,pending,complete){var el=$('#favtog'+obj_id);if(!el.size())return false;if(score){$(el).removeClass(pending).addClass(complete).html(count+'');}else{$(el).removeClass(pending).removeClass(complete).html(count+'');};}
function mtUpdateScores(){var u=mtGetUser();if(!mt.blog.community.ifAnonymousRecommendAllowed&&!u)return false;var entry_ids='';var scores=$('.favtog');if(scores.size()){for(var i=0;i<scores.length;i++){var id=$(scores[i]).attr('id').replace("favtog","");if(entry_ids!='')entry_ids+=",";entry_ids+=id;}}else{return false;};$.ajax({type:"POST",url:mt.blog.community.script,data:'__mode=score&blog_id='+mt.blog.id+'&f=scored,count,authored&jsonp=mtScore_cb&id='+entry_ids,success:function(r){eval(r);}});return false;}
function mtScore_cb(s_hash){for(var id in s_hash){if(parseInt(s_hash[id].scored)){var el=$('#favtog'+id);if(el.size()){$(el).addClass('scored').html(s_hash[id].count+'');}}
if(parseInt(s_hash[id].authored)){var el=$('#unpublish'+id);if(el.size()){$(el).addClass('entry-author');}}}}
function mtShowPage(element){var url=element.href;var script_params=url.split('?');var script=script_params[0];var params=script_params[1].split(/\&(?:amp;)?/);var query=new Array();for(var i=0;i<params.length;++i){query[params[i]]=params[i+1];++i;}
$('.content-nav').html('<img src="'+mt.blog.staticWebPath+'images/indicator.white.gif" height="16" width="16" alt="Fetching..." />');$.get(url,query,function(result){$('.actions').replaceWith(result);window.scroll(0,0);initEntryHover();initClickHandlers();mtUpdateScores();});return false;}
function script_follow(id){var u=mtGetUser();if(!u||!u.name)return;$.ajax({type:"POST",url:mt.blog.community.script,data:'__mode=follow&id='+id+'&magic_token='+u.sid+'&jsonp=follow',success:function(r){eval(r);}});$('#following_'+id+'_else').hide();$('#following-status').html('<img src="'+mt.blog.staticWebPath+'images/indicator.white.gif" height="10" width="10" alt="Following..." />');}
function script_leave(id){var u=mtGetUser();if(!u||!u.name)return;$.ajax({type:"POST",url:mt.blog.community.script,data:'__mode=leave&id='+id+'&magic_token='+u.sid+'&jsonp=leave',success:function(r){eval(r);}});$('#following_'+id).hide();$('#following-status').html('<img src="'+mt.blog.staticWebPath+'images/indicator.white.gif" height="10" width="10" alt="Leaving..." />');}
function follow(user_info){conditional_block(true,'following_'+user_info['id']);$('#following-status').html('');}
function leave(user_info){conditional_block(false,'following_'+user_info['id']);$('#following-status').html('');}
function conditional_block(cond,id){var true_block=$('#'+id);var false_block=$('#'+id+'_else');if(cond){$(false_block).hide();if($(true_block).size()){var display=$(true_block).attr('mt:display_style');if(!display&&$(false_block).size())
display=$(false_block).attr('mt:display_style');if(!display)display='';$(true_block).show();}}else{$(true_block).hide();if($(false_block).size()){var display=$(false_block).attr('mt:display_style');if(!display&&$(true_block).size())
display=$(false_block).attr('mt:display_style');if(!display)display='';$(false_block).show();}}}
function mtHide(id){var el=(typeof id=="string")?document.getElementById(id):id;if(el)el.style.display='none';}
function mtShow(id){var el=(typeof id=="string")?document.getElementById(id):id;if(el)el.style.display='block';}
function mtAttachEvent(eventName,func){var onEventName='on'+eventName;var old=window[onEventName];if(typeof old!='function')
window[onEventName]=func;else{window[onEventName]=function(evt){old(evt);return func(evt);}}}
function mtFireEvent(eventName,param){var fn=window['on'+eventName];if(typeof fn=='function')return fn(param);return;}
function mtRelativeDate(ts,fds){var now=new Date();var ref=ts;var delta=Math.floor((now.getTime()-ref.getTime())/1000);var str;if(delta<60){str=mt.blog.phrase.relativeDate.momentsAgo;}else if(delta<=86400){var hours=Math.floor(delta/3600);var min=Math.floor((delta%3600)/60);if(hours==1)
str=mt.blog.phrase.relativeDate.hoursAgo;else if(hours>1)
str=mt.blog.phrase.relativeDate.hoursAgoPlural.replace(/2/,hours);else if(min==1)
str=mt.blog.phrase.relativeDate.minutesAgo;else
str=mt.blog.phrase.relativeDate.minutesAgoPlural.replace(/2/,min);}else if(delta<=604800){var days=Math.floor(delta/86400);var hours=Math.floor((delta%86400)/3600);if(days==1)
str=mt.blog.phrase.relativeDate.daysAgo;else if(days>1)
str=mt.blog.phrase.relativeDate.daysAgoPlural.replace(/2/,days);else if(hours==1)
str=mt.blog.phrase.relativeDate.hoursAgo;else
str=mt.blog.phrase.relativeDate.hoursAgoPlural.replace(/2/,hours);}
return str?str:fds;}
function mtEditLink(entry_id,author_id){var u=mtGetUser();if(!u)return;if(!entry_id)return;if(!author_id)return;if(u.id!=author_id)return;var link='<a href="'+mt.blog.adminScript+'?__mode=view&amp;_type=entry&amp;id='+entry_id+'">'+mt.blog.phrase.edit+'</a>';document.write(link);}
function mtCommentFormOnFocus(){mtShowCaptcha();}
var mtCaptchaVisible=false;function mtShowCaptcha(){var u=mtGetUser();if(u&&u.is_authenticated)return;if(mtCaptchaVisible)return;var div=document.getElementById('comments-open-captcha');if(div){div.innerHTML=mt.blog.comments.captchaFields;mtCaptchaVisible=true;}}
var is_preview;var user;function mtSetUser(u){if(u){user=u;mtSaveUser();mtFireEvent('usersignin');}}
function mtEscapeJS(s){s=s.replace(/'/g,"&apos;");return s;}
function mtUnescapeJS(s){s=s.replace(/&apos;/g,"'");return s;}
function mtBakeUserCookie(u){var str="";if(u.name)str+="name:'"+mtEscapeJS(u.name)+"';";if(u.url)str+="url:'"+mtEscapeJS(u.url)+"';";if(u.email)str+="email:'"+mtEscapeJS(u.email)+"';";if(u.is_authenticated)str+="is_authenticated:'1';";if(u.profile)str+="profile:'"+mtEscapeJS(u.profile)+"';";if(u.userpic)str+="userpic:'"+mtEscapeJS(u.userpic)+"';";if(u.sid)str+="sid:'"+mtEscapeJS(u.sid)+"';";str+="is_trusted:'"+(u.is_trusted?"1":"0")+"';";str+="is_author:'"+(u.is_author?"1":"0")+"';";str+="is_banned:'"+(u.is_banned?"1":"0")+"';";str+="can_post:'"+(u.can_post?"1":"0")+"';";str+="can_comment:'"+(u.can_comment?"1":"0")+"';";str=str.replace(/;$/,'');return str;}
function mtUnbakeUserCookie(s){if(!s)return;var u={}
var m;while(m=s.match(/^((name|url|email|is_authenticated|profile|userpic|sid|is_trusted|is_author|is_banned|can_post|can_comment):'([^']+?)';?)/)){s=s.substring(m[1].length);if(m[2].match(/^(is|can)_/))
u[m[2]]=m[3]=='1'?true:false;else
u[m[2]]=mtUnescapeJS(m[3]);}
if(u.is_authenticated){u.is_anonymous=false;}else{u.is_anonymous=true;u.can_post=false;u.is_author=false;u.is_banned=false;u.is_trusted=false;}
return u;}
function mtGetUser(){if(!user){var cookie=mtGetCookie(mtCookieName);if(!cookie)return;user=mtUnbakeUserCookie(cookie);if(!user){user={}
user.is_anonymous=true;user.can_post=false;user.is_author=false;user.is_banned=false;user.is_trusted=false;}}
return user;}
var mtFetchedUser=false;if(mt.blog.id){function mtFetchUser(cb){if(!cb)cb='mtSetUser';if((cb=='mtSetUser')&&mtGetUser()){var url=document.URL;url=url.replace(/#.+$/,'');url+='#comments-open';location.href=url;}else{mtFetchedUser=true;var script=document.createElement('script');var ts=new Date().getTime();script.src=mt.blog.comments.script+'?__mode=session_js&blog_id='+mt.blog.id+'&jsonp='+cb+'&ts='+ts;(document.getElementsByTagName('head'))[0].appendChild(script);}}}
function mtRememberMeOnClick(b){if(!b.checked)
mtClearUser(b.form);return true;}
if(mt.blog.id){var mtRequestSubmitted=false;function mtCommentOnSubmit(f){if(!mtRequestSubmitted){mtRequestSubmitted=true;if(f.armor)
f.armor.value=mt.blog.comments.armor;if(f.bakecookie&&f.bakecookie.checked)
mtSaveUser(f);if(f.preview_button)f.preview_button.disabled=true;if(f.post)f.post.disabled=true;var u=mtGetUser();if(!is_preview&&(u&&u.is_authenticated)){mtFetchedUser=false;mtFetchUser('mtCommentSessionVerify');return false;}
return true;}
return false;}
function mtCommentSessionVerify(app_user){var u=mtGetUser();var f=document['comments_form'];if(u&&app_user&&app_user.sid&&(u.sid==app_user.sid)){f.submit();}else{alert(mt.blog.phrase.commenter.sessionExpired);mtClearUser();mtFireEvent('usersignin');if(mt.blog.registration.required){mtShow('comments-form');mtHide('comments-open-footer');}}}
function mtUserOnLoad(){var u=mtGetUser();if(document.getElementById('comments-form')){if(u&&u.is_authenticated){mtShow('comments-form');mtHide('comments-open-data');if(mtCaptchaVisible)
mtHide('comments-open-captcha');}else{if(mt.blog.registration.required){mtHide('comments-form');}}
if(u&&u.is_banned)
mtHide('comments-form');if(is_preview)
mtShowCaptcha();else
mtShowGreeting();var cf=document['comments_form'];if(cf){if(u&&u.is_anonymous){if(u.email)cf.email.value=u.email;if(u.name)cf.author.value=u.name;if(u.url)cf.url.value=u.url;if(cf.bakecookie)
cf.bakecookie.checked=u.name||u.email;}else{if(u&&u.sid&&cf.sid)
cf.sid.value=u.sid;}
if(cf.post.disabled)
cf.post.disabled=false;if(cf.preview_button.disabled)
cf.preview_button.disabled=false;mtRequestSubmitted=false;}}}}
if(mt.blog.id){function mtEntryOnLoad(){if(!mt.blog.pings.accepted)
mtHide('trackbacks-info');if(!mt.blog.comments.accepted)
mtHide('comments-open');mtFireEvent('usersignin');}
function mtEntryOnUnload(){if(mtRequestSubmitted){var cf=document['comments_form'];if(cf){if(cf.post&&cf.post.disabled)
cf.post.disabled=false;if(cf.preview_button&&cf.preview_button.disabled)
cf.preview_button.disabled=false;}
mtRequestSubmitted=false;}
return true;}
mtAttachEvent('usersignin',mtUserOnLoad);}
function mtSignIn(){var doc_url=document.URL;doc_url=doc_url.replace(/#.+/,'');var url=mt.blog.signInLink;if(is_preview){if(document['comments_form']){var entry_id=document['comments_form'].entry_id.value;url+='&entry_id='+entry_id;}else{url+='&return_url='+mt.blog.url;}}else{url+='&return_url='+encodeURIComponent(doc_url);}
mtClearUser();location.href=url;}
function mtSignInOnClick(sign_in_element){var el;if(sign_in_element){el=document.getElementById(sign_in_element);if(!el)
el=document.getElementById('comment-form-external-auth');}
if(el)
el.innerHTML=mt.blog.phrase.signingIn+' <span class="status-indicator">&nbsp;</span>';mtClearUser();mtFetchUser('mtSetUserOrLogin');return false;}
function mtSetUserOrLogin(u){if(u&&u.is_authenticated){mtSetUser(u);}else{mtSignIn();}}
function mtSignOut(entry_id){mtClearUser();var doc_url=document.URL;doc_url=doc_url.replace(/#.+/,'');var url=mt.blog.signOutLink;if(is_preview){if(document['comments_form']){var entry_id=document['comments_form'].entry_id.value;url+='&entry_id='+entry_id;}else{url+='&return_url='+mt.blog.url;}}else{url+='&return_url='+encodeURIComponent(doc_url);}
location.href=url;}
function mtSignOutOnClick(){mtSignOut();return false;}
if(mt.blog.id){function mtShowGreeting(){if(mt.blog.registration.allowed){var cf=document['comments_form'];if(!cf)return;var el=document.getElementById('comment-greeting');if(!el)
el=document.getElementById('comment-form-external-auth');if(!el)return;var eid=cf.entry_id;var entry_id;if(eid)entry_id=eid.value;var phrase;var u=mtGetUser();if(u&&u.is_authenticated){if(u.is_banned){phrase=mt.blog.phrase.commenter.authBanned;}else{var user_link;user_link='<a href="'+mt.blog.community.script+'?__mode=view&amp;blog_id='+mt.blog.id+'">'+u.name+'</a>';phrase=mt.blog.phrase.commenter.authSuccess;phrase=phrase.replace(/__NAME__/,user_link);}}else{if(mt.blog.registration.required){phrase=mt.blog.phrase.commenter.auth;}else{phrase=mt.blog.phrase.commenter.authAnonyous;}}
el.innerHTML=phrase;}else{mtShowCaptcha();}}}
function mtReplyCommentOnClick(parent_id,author){mtShow('comment-form-reply');var checkbox=document.getElementById('comment-reply');var label=document.getElementById('comment-reply-label');var text=document.getElementById('comment-text');var reply_text=mt.blog.phrase.commenter.replyingTo;reply_text=reply_text.replace(/__PARENT__/,parent_id);reply_text=reply_text.replace(/__AUTHOR__/,author);label.innerHTML=reply_text;checkbox.value=parent_id;checkbox.checked=true;try{text.focus();}catch(e){}
mtSetCommentParentID();}
function mtSetCommentParentID(){var checkbox=document.getElementById('comment-reply');var parent_id_field=document.getElementById('comment-parent-id');if(!checkbox||!parent_id_field)return;var pid=0;if(checkbox.checked==true)
pid=checkbox.value;parent_id_field.value=pid;}
function mtSaveUser(f){if(is_preview)return;var u=mtGetUser();if(f&&(!u||u.is_anonymous)){if(!u){u={}
u.is_authenticated=false;u.can_comment=true;u.is_author=false;u.is_banned=false;u.is_anonymous=true;u.is_trusted=false;}
if(f.author!=undefined)u.name=f.author.value;if(f.email!=undefined)u.email=f.email.value;if(f.url!=undefined)u.url=f.url.value;}
if(!u)return;var cache_period=mtCookieTimeout*1000;if(u.is_anonymous&&f&&f.bakecookie&&f.bakecookie.checked)
cache_period=365*24*60*60*1000;var now=new Date();mtFixDate(now);now.setTime(now.getTime()+cache_period);var cmtcookie=mtBakeUserCookie(u);mtSetCookie(mtCookieName,cmtcookie,now,mtCookiePath,mtCookieDomain,location.protocol=='https:');}
function mtClearUser(){user=null;mtDeleteCookie(mtCookieName,mtCookiePath,mtCookieDomain,location.protocol=='https:');}
function mtSetCookie(name,value,expires,path,domain,secure){if(domain&&domain.match(/^\.?localhost$/))
domain=null;var curCookie=name+"="+escape(value)+
(expires?"; expires="+expires.toGMTString():"")+
(path?"; path="+path:"")+
(domain?"; domain="+domain:"")+
(secure?"; secure":"");document.cookie=curCookie;}
function mtGetCookie(name){var prefix=name+'=';var c=document.cookie;var cookieStartIndex=c.indexOf(prefix);if(cookieStartIndex==-1)
return'';var cookieEndIndex=c.indexOf(";",cookieStartIndex+prefix.length);if(cookieEndIndex==-1)
cookieEndIndex=c.length;return unescape(c.substring(cookieStartIndex+prefix.length,cookieEndIndex));}
function mtDeleteCookie(name,path,domain,secure){if(mtGetCookie(name)){if(domain&&domain.match(/^\.?localhost$/))
domain=null;document.cookie=name+"="+
(path?"; path="+path:"")+
(domain?"; domain="+domain:"")+
(secure?"; secure":"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";}}
function mtFixDate(date){var skew=(new Date(0)).getTime();if(skew>0)
date.setTime(date.getTime()-skew);}
function mtGetXmlHttp(){if(!window.XMLHttpRequest){window.XMLHttpRequest=function(){var types=["Microsoft.XMLHTTP","MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP"];for(var i=0;i<types.length;i++){try{return new ActiveXObject(types[i]);}catch(e){}}
return undefined;}}
if(window.XMLHttpRequest)
return new XMLHttpRequest();}
function mtInit(){if(arguments.callee.done)return;arguments.callee.done=true;if(window._timer)clearInterval(window._timer);if(window.onload&&(window.onload!==window.mtInit)){window.onload();window.onload=function(){}}}
if(document.addEventListener){document.addEventListener("DOMContentLoaded",mtInit,false);}
if(/WebKit/i.test(navigator.userAgent)){_timer=setInterval(function(){if(/loaded|complete/.test(document.readyState)){mtInit();}},10);}
window.onload=mtInit;if(mt.blog.id&&mt.blog.registration.allowed){var clearCookie=(window.location.hash&&window.location.hash.match(/^#_log(in|out)/))?true:false;if(clearCookie){mtClearUser();if(RegExp.$1=='in')
mtFetchUser();}else{if(is_preview&&!user)
mtFetchUser();}}