var AJAXComments_Enabled=true;var AJAXComments_IsPosting=false;$(document).ready(function(){InitAJAXComments();});function InitAJAXComments()
{$('#post-comment-form').submit(function(){return AJAXComments_Submit();});$('#post-comment-button').click(function(){$('#post-comment-form').submit()});}
function AJAXComments_Submit()
{if(AJAXComments_IsPosting)
return false;if(!AJAXComments_Enabled)
return true;AJAXComments_IsPosting=true;$('#post-comment-status')[0].innerHTML='<img src="'+TEMPLATE_HREF+'/images/spinner.gif" alt="" />';$('#post-comment-status').css('display','block');$('#post-comment-button').toggle("drop",{direction:"up"},500);$.ajax({type:"POST",url:TEMPLATE_HREF+"/comments-ajax.php",data:$('#post-comment-form').serialize(),success:function(responseData){AJAXComments_Response(responseData);},error:function(responseData){AJAXComments_Error(responseData);}});return false;}
function AJAXComments_Response(responseData)
{var htmlData=$("<ol>").html(responseData);var lastComment=htmlData.find('li.last-comment');$('#new-comment').attr('id',"new-comment-old");$('#commentlist').append("<li id=\"new-comment\" style=\"display:none;\">"+lastComment.html()+"</li>");$('#new-comment').toggle('blind',{direction:"vertical"},500);$('#post-comment-status')[0].innerHTML='<p class="success">Your comment has been posted.</p>';$('#post-comment-button').toggle("drop",{direction:"up"},500);AJAXComments_IsPosting=false;$('.flag-comment a').each(function(){$(this).click(function(){AJAXFlagComments_LoadButton($(this));centerPopup('FlagComment');loadPopup('FlagComment');return false;});});}
function AJAXComments_Error(request)
{var responseData=request.responseText;var error=responseData;if(responseData.search(/<title>WordPress &rsaquo; Error<\/title>/)!=-1)
{var errorTemp=responseData.match(/<p>(.*)<\/p>/);error=errorTemp[1];}
$('#post-comment-status')[0].innerHTML='<p class="error">'+error+'</p>';$('#post-comment-button').toggle("drop",{direction:"up"},500);AJAXComments_IsPosting=false;}
var AJAXFLAGCOMMENTS_LAST_FLAG_COMMENT_URL;var AJAXFLAGCOMMENTS_LAST_BUTTON;function InitAJAXFlagComments()
{$('#popupFlagComment_Continue').click(function(){return AJAXFlagComments_Go();});}
function AJAXFlagComments_LoadButton(sender)
{AJAXFLAGCOMMENTS_LAST_FLAG_COMMENT_URL=sender.attr('href');AJAXFLAGCOMMENTS_LAST_BUTTON=sender;}
function AJAXFlagComments_Go()
{var nonce=FLAG_COMMENTS_NONCE;var nonce_key=FLAG_COMMENTS_NONCE_KEY;var re=new RegExp(nonce_key,'gi');re.exec(AJAXFLAGCOMMENTS_LAST_FLAG_COMMENT_URL);AJAXFLAGCOMMENTS_LAST_FLAG_COMMENT_URL=AJAXFLAGCOMMENTS_LAST_FLAG_COMMENT_URL.replace(re,nonce);$.ajax({type:"GET",url:AJAXFLAGCOMMENTS_LAST_FLAG_COMMENT_URL,success:function(responseData){AJAXFlagComments_Response(responseData);},error:function(responseData){AJAXFlagComments_Error(responseData);}});$('#popupFlagComment_ContinueParent')[0].innerHTML='<img src="'+TEMPLATE_HREF+'/images/spinner.gif" alt="" />';return false;}
function AJAXFlagComments_Response(responseData)
{AJAXFLAGCOMMENTS_LAST_BUTTON.parent()[0].innerHTML='<label class="already-flagged">Comment has been flagged.</label>';$('#popupFlagComment_ContinueParent')[0].innerHTML='<a href="#" id="popupFlagComment_Continue">Yes, flag this comment.</a>';disablePopup();InitAJAXFlagComments();}
function AJAXFlagComments_Error(responseData)
{alert('error');alert(responseData.responseText);$('#popupFlagComment_ContinueParent')[0].innerHTML='<a href="#" id="popupFlagComment_Continue">Yes, flag this comment.</a>';disablePopup();InitAJAXFlagComments();}
$(document).ready(function(){InitAJAXFlagComments();});var AJAX_SEARCH_IS_SEARCHING=false;var AJAX_SEARCH_IS_ACTIVE=false;var AJAX_SEARCH_IS_CLOSING=false;var AJAXSEARCH_ORIGINAL_CONTENT="";var AJAXSEARCH_NEW_CONTENT="";$(document).ready(function(){Init_AJAXSearch();});function Init_AJAXSearch()
{var options={callback:function(){AJAXSearch_Go($("#main-search-input")[0]);},wait:1000,highlight:true,enterkey:true,captureLength:2}
$("#main-search-input").typeWatch(options);$("#main-search-input").focus(function(){AJAXSearch_FieldFocus($('#main-search-input')[0])});$("#main-search-input").blur(function(){AJAXSearch_FieldBlur($('#main-search-input')[0])});$("#main-search-input").mousemove(function(){DropdownMenu_Hide()});$("#main-search-input")[0].value="";AJAXSearch_FieldBlur($("#main-search-input")[0]);$("#main-search-button").mousedown(function(){AJAXSearch_Go($('#main-search-input')[0])});var options={callback:function(){AJAXSearch_Go($("#footer-search-input")[0]);},wait:1000,highlight:true,enterkey:true,captureLength:2}
$("#footer-search-input").typeWatch(options);$("#footer-search-input").focus(function(){AJAXSearch_FieldFocus($('#footer-search-input')[0])});$("#footer-search-input").blur(function(){AJAXSearch_FieldBlur($('#footer-search-input')[0])});$("#footer-search-input")[0].value="";AJAXSearch_FieldBlur($("#footer-search-input")[0]);$("#footer-search-button").mousedown(function(){AJAXSearch_Go($('#footer-search-input')[0])});}
function AJAXSearch_FieldFocus(sender)
{sender.style.color='#000000';if(sender.value=='Type and Wait to Search')
{sender.value='';DropdownMenu_Hide();}}
function AJAXSearch_FieldBlur(sender)
{if(sender.value=='')
{sender.style.color='#cacaca';sender.value='Type and Wait to Search';}}
function AJAXSearch_NewContent_Transition()
{$('#contentInner').html(AJAXSEARCH_NEW_CONTENT);AJAX_ShowMainContent();Blockquote_CurlyQuotes();if(AJAX_SEARCH_IS_CLOSING&&!AJAX_SEARCH_IS_ACTIVE)
AJAXSearch_ToggleButton_Search();else
AJAXSearch_ToggleButton_Close();}
function AJAXSearch_Close()
{AJAX_SEARCH_IS_CLOSING=true;AJAX_SEARCH_IS_SEARCHING=false;AJAX_SEARCH_IS_ACTIVE=false;AJAX_HideMainContent();AJAXSEARCH_NEW_CONTENT=AJAXSEARCH_ORIGINAL_CONTENT;setTimeout('AJAXSearch_NewContent_Transition()',1000);$("#main-search-input")[0].value="";$("#footer-search-input")[0].value="";AJAXSearch_FieldBlur($("#main-search-input")[0]);AJAXSearch_FieldBlur($("#footer-search-input")[0]);}
function AJAXSearch_Go(sender)
{if(search_query=="")
return;if(AJAX_SEARCH_IS_SEARCHING||AJAX_SEARCH_IS_CLOSING)
return;if(AJAXSEARCH_ORIGINAL_CONTENT=="")
{AJAXSEARCH_ORIGINAL_CONTENT=$('#contentInner').html();}
DropdownMenu_Hide();var search_query=sender.value;$.ajax({type:"GET",url:BASE_HREF+"/index.php",data:"AJAX=1&s="+search_query,success:function(responseData){Sidebar_AJAXSearch_Results(responseData);}});AJAX_SEARCH_IS_SEARCHING=true;AJAXSearch_ToggleButton_Loading();if(sender.id=="footer-search-input")
{$('html,body').animate({scrollTop:0},500);document.getElementById('main-search-input').value=sender.value;AJAXSearch_FieldFocus($('#main-search-input')[0]);}
if(sender.id=="main-search-input")
{document.getElementById('footer-search-input').value=sender.value;}}
function Sidebar_AJAXSearch_Results(dataHTML)
{AJAX_SEARCH_IS_SEARCHING=false;AJAX_SEARCH_IS_ACTIVE=true;AJAX_HideMainContent();AJAXSEARCH_NEW_CONTENT=dataHTML;setTimeout('AJAXSearch_NewContent_Transition()',1000);}
function AJAXSearch_NewContent_Transition()
{$('#contentInner')[0].innerHTML=AJAXSEARCH_NEW_CONTENT;AJAX_ShowMainContent();Blockquote_CurlyQuotes();if(AJAX_SEARCH_IS_CLOSING&&!AJAX_SEARCH_IS_ACTIVE)
{AJAXSearch_ToggleButton_Search();InitPopupLink();InitPopupMail();InitPopupSubmitStory();InitAJAXComments();InitShareThis();}
else
AJAXSearch_ToggleButton_Close();}
function AJAXSearch_ToggleButton_Loading()
{$('#main-search-button').css('backgroundImage',"url('"+BASE_HREF+"/wp-content/themes/newmedici/images/spinner.gif')");$('#main-search-button').css('backgroundPosition',"7px 4px");$('#footer-search-button').css('backgroundImage',"url('"+BASE_HREF+"/wp-content/themes/newmedici/images/spinner.gif')");$('#footer-search-button').css('backgroundPosition',"4px 1px");}
function AJAXSearch_ToggleButton_Close()
{$('#main-search-button').css('backgroundImage',"url('"+BASE_HREF+"/wp-content/themes/newmedici/images/search_button_active.jpg')");$('#main-search-button').css('backgroundPosition',"left top");$("#main-search-button").unbind('mousedown');$("#main-search-button").mousedown(function(){AJAXSearch_Close()});$('#footer-search-button').css('backgroundImage',"url('"+BASE_HREF+"/wp-content/themes/newmedici/images/search_button_active.jpg')");$('#footer-search-button').css('backgroundPosition'," -4px -3px");$("#footer-search-button").unbind('mousedown');$("#footer-search-button").mousedown(function(){AJAXSearch_Close()});}
function AJAXSearch_ToggleButton_Search()
{AJAX_SEARCH_IS_CLOSING=false;$('#main-search-button').css('backgroundImage',"url('"+BASE_HREF+"/wp-content/themes/newmedici/images/search_button.jpg')");$('#main-search-button').css('backgroundPosition',"left top");$("#main-search-button").unbind('mousedown');$("#main-search-button").mousedown(function(){AJAXSearch_Go($('#main-search-input')[0])});$('#footer-search-button').css('backgroundImage',"url('"+BASE_HREF+"/wp-content/themes/newmedici/images/search_button.jpg')");$('#footer-search-button').css('backgroundPosition'," -4px -3px");$("#footer-search-button").unbind('mousedown');$("#footer-search-button").mousedown(function(){AJAXSearch_Go($('#main-search-input')[0])});}
var AJAXTABS_TRANSITIONS_ENABLED=false;var AJAXTABS_IS_LOADING=false;$(document).ready(function(){Init_AJAXTabs();});function Init_AJAXTabs()
{$("#tab-read").mousedown(function(sender){AJAXTabs_LoadTab('most-read','sidebar-block1-list',$("#tab-read")[0])});$("#tab-emailed").mousedown(function(){AJAXTabs_LoadTab('most-emailed','sidebar-block1-list',$("#tab-emailed")[0])});$("#tab-discussed").mousedown(function(){AJAXTabs_LoadTab('most-discussed','sidebar-block1-list',$("#tab-discussed")[0])});$("#tab-recent").mousedown(function(){AJAXTabs_LoadTab('recent-posts','sidebar-block2-list',$("#tab-recent")[0])});$("#tab-editors").mousedown(function(){AJAXTabs_LoadTab('editors-picks','sidebar-block2-list',$("#tab-editors")[0])});}
function AJAXTabs_LoadTab(query,destinationElementID,senderElement)
{if(AJAXTABS_IS_LOADING)
return;$.ajax({type:"GET",url:BASE_HREF+"/index.php",data:"AJAX=1&query="+query,success:function(responseData){AJAXTabs_TabLoaded(responseData,destinationElementID,senderElement);}});AJAXTabs_Transition(senderElement,'out');AJAXTABS_IS_LOADING=true;}
function AJAXTabs_TabLoaded(responseData,destinationElementID,senderElement)
{var destinationElement=$('#'+destinationElementID)[0];destinationElement.innerHTML=responseData;AJAXTabs_ChooseTab(senderElement);AJAXTabs_Transition(senderElement,'in');AJAXTABS_IS_LOADING=false;}
function AJAXTabs_Transition(tab,mode)
{if(!AJAXTABS_TRANSITIONS_ENABLED)
return;var containerElement;var containerOuterElement;switch(tab.id)
{case"tab-read":containerOuterElement=$('#sidebar-block1-list-container-outer');containerElement=$('#sidebar-block1-list-container');break;case"tab-emailed":containerOuterElement=$('#sidebar-block1-list-container-outer');containerElement=$('#sidebar-block1-list-container');break;case"tab-discussed":containerOuterElement=$('#sidebar-block1-list-container-outer');containerElement=$('#sidebar-block1-list-container');break;case"tab-recent":containerOuterElement=$('#sidebar-block2-list-container-outer');containerElement=$('#sidebar-block2-list-container');break;case"tab-editors":containerOuterElement=$('#sidebar-block2-list-container-outer');containerElement=$('#sidebar-block2-list-container');break;}
if(mode=='out')
{containerElement.toggle("drop",{direction:"right"},800);}
if(mode=='in')
{containerElement.toggle("drop",{direction:"right"},300);}}
function AJAXTabs_ChooseTab(tab)
{setElementClass(tab,'tab-item tab-item-active');var tabSiblings=new Array();switch(tab.id)
{case"tab-read":tabSiblings.push($('#tab-emailed')[0]);tabSiblings.push($('#tab-discussed')[0]);break;case"tab-emailed":tabSiblings.push($('#tab-read')[0]);tabSiblings.push($('#tab-discussed')[0]);break;case"tab-discussed":tabSiblings.push($('#tab-read')[0]);tabSiblings.push($('#tab-emailed')[0]);break;case"tab-recent":tabSiblings.push($('#tab-editors')[0]);break;case"tab-editors":tabSiblings.push($('#tab-recent')[0]);break;}
for(var i=0;i<tabSiblings.length;i++)
{setElementClass(tabSiblings[i],'tab-item');}}
var AJAX_ORIGINAL_CONTENT="";var AJAX_NEW_CONTENT="";var AJAX_NEW_CONTENT_TRANSITION_ANIMATED=true;var AJAX_CONTENT_TRANSITION_EFFECT='blind';var AJAX_CONTENT_TRANSITION_EFFECT_DIRECTION='vertical';var AJAX_CONTENT_TRANSITION_EFFECT_DURATION_MS=800;function AJAX_ShowMainContent()
{$('body,html').css('height','auto');$('body,html').css('min-height','0');if(AJAX_NEW_CONTENT_TRANSITION_ANIMATED)
{$("#contentInner").toggle(AJAX_CONTENT_TRANSITION_EFFECT,{direction:'vertical'},800);}
else
$('#contentInner').show();}
function AJAX_HideMainContent()
{$('body,html').css('height',$('body').height()+'px');$('body,html').css('min-height',$('body').height()+'px');if(AJAX_NEW_CONTENT_TRANSITION_ANIMATED)
{$("#contentInner").toggle(AJAX_CONTENT_TRANSITION_EFFECT,{direction:'vertical'},800);}
else
$('#contentInner').hide();}
function AJAX_NewContent_Transition()
{$('#contentInner').html(AJAX_NEW_CONTENT);AJAX_ShowMainContent();Blockquote_CurlyQuotes();if(AJAX_SEARCH_IS_CLOSING&&!AJAX_SEARCH_IS_ACTIVE)
AJAXSearch_ToggleButton_Search();else
AJAXSearch_ToggleButton_Close();}
var PAGE_LOADED=false;function setElementClass(element,className)
{element.setAttribute('class',className);element.setAttribute('className',className);}
function Init_Page()
{try{PAGE_LOADED=true;Blockquote_CurlyQuotes();AutoImageCitations();Fix_MoreLinkInsideParagraph();}catch(ex){alert(ex);}}
function Fix_MoreLinkInsideParagraph()
{$('.entry p:last').css('margin-bottom','0px');}
function Blockquote_CurlyQuotes()
{$('blockquote p:last-child').css('background-image','url('+TEMPLATE_HREF+'/images/blockquote_quote_close.jpg)');$('blockquote p:last-child').css('background-repeat','no-repeat');$('blockquote p:last-child').css('background-position','bottom right');$('blockquote p:last-child').css('padding-top','22px');$('blockquote p:last-child').css('padding-bottom','22px');}
function AutoImageCitations()
{var postEntries=$(document).find('.entry');$.each(postEntries,function(){var postCites=$(this).find('cite');if(postCites.length>0)
{var postImgs=$(this).find('img');for($i=0;$i<postCites.length;$i++)
{if($i>=postImgs.length)
break;}}});}
$(document).ready(function(){Init_Page();});var MENU_OPEN=false;var MENU_CLOSING=false;$(document).ready(function(){Init_DropdownMenu();});function Init_DropdownMenu()
{$("#nav-more").hover(DropdownMenu_Show,DropdownMenu_Show);$("#headerDropdownContainer").hover(DropdownMenu_Show,DropdownMenu_Hide);}
function DropdownMenu_Show(ev){if(MENU_OPEN||MENU_CLOSING)
return;var pos=$("#nav-more").offset();var width=$("#nav-more").width();var height=$("#nav-more").height();$("#headerDropdownContainer").css({"left":(pos.left-12)+"px","top":(pos.top+height-32)+"px"});$("#headerDropdownContainer").fadeIn(500);setElementClass($("#nav-more")[0],"link nav-more nav-more-active");MENU_OPEN=true;}
function DropdownMenu_Hide(ev){if(!MENU_OPEN||MENU_CLOSING)
return;$("#headerDropdownContainer").fadeOut(500);setElementClass($("#nav-more")[0],"link nav-more");MENU_CLOSING=true;setTimeout("MENU_OPEN = false; MENU_CLOSING = false;",500);}
var POPUPMAIL_IS_SUBMITTING=false;function PopupMail_AJAXSubmit()
{if(POPUPMAIL_IS_SUBMITTING)
return false;POPUPMAIL_IS_SUBMITTING=true;$.ajax({type:"POST",url:$('#popupMailForm').attr('action'),data:$("#popupMailForm").serialize(),success:function(responseData){PopupMail_AJAXResponse(responseData);}});$('#popupMailSubmitButton').toggle("drop",{direction:"up"},500);return false;}
function PopupMail_AJAXResponse(responseData)
{eval(responseData);POPUPMAIL_IS_SUBMITTING=false;$('#popupMailSubmitButton').toggle("drop",{direction:"up"},500);}
var POPUPSUBMITSTORY_IS_SUBMITTING=false;function PopupSubmitStory_AJAXSubmit()
{if(POPUPSUBMITSTORY_IS_SUBMITTING)
return false;POPUPSUBMITSTORY_IS_SUBMITTING=true;$.ajax({type:"POST",url:$('#popupSubmitStoryForm').attr('action'),data:$("#popupSubmitStoryForm").serialize(),success:function(responseData){PopupSubmitStory_AJAXResponse(responseData);}});$('#popupSubmitStorySubmitButton').toggle("drop",{direction:"up"},500);return false;}
function PopupSubmitStory_AJAXResponse(responseData)
{eval(responseData);POPUPSUBMITSTORY_IS_SUBMITTING=false;$('#popupSubmitStorySubmitButton').toggle("drop",{direction:"up"},500);}
var LAST_POPUP=null;function InitPopupFlagComment()
{try{$('.flag-comment a').each(function(){$(this).click(function(){AJAXFlagComments_LoadButton($(this));centerPopup('FlagComment');loadPopup('FlagComment');return false;});});$("#popupFlagCommentClose").click(function(){disablePopup();});$("#popupBackground").click(function(){disablePopup();});$(document).keypress(function(e){if(e.keyCode==27&&popupStatus==1){disablePopup();}});}catch(ex){alert(ex);}}
function InitPopupLink()
{try{$("#popupLinkTextbox").focus(function(){this.select();});$("#link-button-top").click(function(){centerPopup('Link');loadPopup('Link');return false;});$("#link-button-bottom").click(function(){centerPopup('Link');loadPopup('Link');return false;});$("#popupLinkClose").click(function(){disablePopup();});$("#popupBackground").click(function(){disablePopup();});$(document).keypress(function(e){if(e.keyCode==27&&popupStatus==1){disablePopup();}});}catch(ex){alert(ex);}}
function InitPopupMail()
{try{$("#email-button-top").click(function(){centerPopup('Mail');loadPopup('Mail');return false;});$("#email-button-bottom").click(function(){centerPopup('Mail');loadPopup('Mail');return false;});$("#popupMailClose").click(function(){disablePopup();});$("#popupBackground").click(function(){disablePopup();});$(document).keypress(function(e){if(e.keyCode==27&&popupStatus==1){disablePopup();}});}catch(ex){alert(ex);}}
function InitPopupSubmitStory()
{try{$("#submit-story-button").click(function(){centerPopup('SubmitStory');loadPopup('SubmitStory');return false;});$("#popupSubmitStoryClose").click(function(){disablePopup();});$("#popupBackground").click(function(){disablePopup();});$(document).keypress(function(e){if(e.keyCode==27&&popupStatus==1){disablePopup();}});}catch(ex){alert(ex);}}
$(document).ready(function(){InitPopupFlagComment();InitPopupLink();InitPopupMail();InitPopupSubmitStory();});var popupStatus=0;function loadPopup(subID){if(popupStatus==0){DropdownMenu_Hide();LAST_POPUP=$("#popup"+subID);$("#popupBackground").css({"opacity":"0.7"});$("#popupBackground").fadeIn("slow");var contentPosition=$('#content').position();var baseTop=$(document).scrollTop()-(contentPosition.top+23);var baseLeft=0-(contentPosition.left-17);$("#popup"+subID).css('top',baseTop+($(window).height()/2-$("#popup"+subID).height()/2));$("#popup"+subID).css('left',baseLeft+($(window).width()/2-$("#popup"+subID).width()/2));$("#popup"+subID).fadeIn("slow");popupStatus=1;}}
function disablePopup(){if(popupStatus==1){$("#popupBackground").fadeOut("slow");LAST_POPUP.fadeOut("slow");LAST_POPUP=null;popupStatus=0;}}
function centerPopup(subID){var windowWidth=$(document).width();var windowHeight=$(document).height();var popupHeight=$("#popup"+subID).height();var popupWidth=$("#popup"+subID).width();$("#popup"+subID).css({"position":"absolute","top":windowHeight/2-popupHeight/2,"left":windowWidth/2-popupWidth/2});var contentPosition=$('#content').position();var baseTop=0-(contentPosition.top+23);var baseLeft=0-(contentPosition.left+17);$("#popupBackground").css({"left":baseLeft,"top":baseTop,"width":windowWidth+(-baseLeft),"height":windowHeight});}