var FLICKR_GROUP_ID = "41383883%40N00";

if($j.browser.msie && parseInt($j.browser.version) <= 6){
	if(window.location.pathname.indexOf("ie6upgrade") == -1){
		window.location = "/ie6upgrade.php";
	}
}

// temp functions to hide gads errors
function GA_googleFillSlot(){}
function GA_googleFetchAds(){}
function GA_googleAddSlot(){}
function GS_googleAddAdSenseService(){}
function GS_googleEnableAllServices(){}

var SubnavIE7Fix_Menus = [];

var currentBlogID = 2;

var bInfoBox_Hide = false;

function InfoBox_Hide(){
	if(bInfoBox_Hide){
		$j("#header .info").css({opacity: 0.9});
		$info_box.stop().animate({
			right: -($info_box.outerWidth())
		});
	}
}

// From now on, just do everything in jQuery and put the hooks inside this jQuery dom:ready function.
$j(function($) {
  // code to execute when the DOM is ready
	
	// Header photo info icon functionality
	$info_box = $("#header .info_box");
	
	$("#header .info").hover(
		function(){
			var iSpacing = $info_box.outerWidth() - $info_box.width();
			$(this).css({opacity: 1});
			$info_box.stop().animate({
				right: -(iSpacing)
			});
		},
		function(){
			bInfoBox_Hide = true;
			setTimeout(InfoBox_Hide, 500);
		}
	);
	
	$info_box.hover(
		function(){
			bInfoBox_Hide = false;
		},
		function(){
			bInfoBox_Hide = true;
			InfoBox_Hide();
		}
	);
	
	// Sign in
	$('.signin').live('click', function(){
	  mtSignIn();
	});
	
	// open external links in a new window
	$("a[href^=http]").each(function(){
		if(this.href.indexOf(location.hostname) == -1) {
				$(this).attr('target', '_blank');
		}
	});
	
	$j("#header .info").hover(
		function(){
			$j('#header .infobox').show();
		},
		function(){
			$j('#header .infobox').hide();
		}
	);
	
	ActivateNavMenu();
	
	// Set active class for current navigation link
	$j("#nav > li > a").each(function(){
		if(location.pathname.indexOf(this.pathname) == 0){
			$(this).parent("li").addClass("active");
			return false;
		}
	});
  
	// there are several <select> elements that contan links; this event handles em all
	// just add a class of 'links' to the selct and it will navigate to the selected link
	// on change.
	//   Class : newwindow - add this class to have the links pop open a new window
	$('select.links').live('change', function(e){		
		if(this.value != '') {
			$(this).hasClass('newwindow') ? 
				window.open(this.value) :
				window.location = this.value;
		}
	});

  $('#photooftheday').each(function(i,e){
    $this = $(this);        
    $j.getJSON(
      "http://api.flickr.com/services/feeds/groups_pool.gne?id=" + FLICKR_GROUP_ID + "&lang=en-us&format=json&jsoncallback=?",
      function(data){
        var $featured = $this.find('.featured');
        var featuredTitle = data.items[0].title;
        var featuredLink =  data.items[0].link;
        var featuredImgSrc = data.items[0].media.m.replace('_m.jpg','.jpg');

        var $thumbs = $this.find('.recent .thumbs');

		/*
        $featured
          .find('h2 a').append(featuredTitle)
          .andSelf().find('a').attr('href', featuredLink).attr('target','_blank').attr('title', featuredTitle)
          .andSelf().find('img').attr('src',featuredImgSrc).attr('alt',title);
		*/
		
        for(i=1;i<=8;i++){
          e = data.items[i];          
          var link = e.link;
          var title = e.title;
          var src = e.media.m.replace('_m.jpg','_s.jpg');
          var img = 
            '<li>' +
              '<a href="'+link+'" target="_blank" title="'+title+'">' +
                '<img src="'+src+'" alt="'+title+'"/>' +
              '</a>' +
            '</li>'
          ;
          $thumbs.append(img);
        };          
      }
    );

  });
	
	// set up the items for to controll the scroller.
	$('.up, .down', '.scroller_nav').live('click', scrollScroller );
	
	// footer links picker
	$('#link_picker').change( function(e){
    var linkList = $('#links_level_two');
    if (this.value !== "") {
			sData = {
				'cmd': 'getlinks',
				'category' : this.value
			};
      linkList
				.empty()
				.append("<strong><em>Loading...</em></strong>")
				.load('/php/ajax.php', sData);
    }
    else {
      linkList.empty();
    }
	});
	
	// little style faness for the comments
	$j("#post_comments .comment:nth-child(even)").addClass("comment-even");
	
	// footer email newsletter
	var emailPromptTxt = "Enter your email";
	$('#email')
		.focus(function(e){ if (this.value === emailPromptTxt) this.value = ""; })
		.blur(function(e){ if (this.value === "" ) this.value = emailPromptTxt; });
	
	if($j("#latest_reviews_widget").length != 0){
		$reviewFilters = $j('#latest_reviews_widget input.listingTypesCheck');
		$reviewFilters.change(UpdateLatestReviews);
		UpdateLatestReviews();
	}
  
  $('#ToggleListingTypes').change(function(e){
    var checked = (this.checked) ? "checked" : "";
    $reviewFilters.attr("checked", checked).change();
  });
  
  // sort comment order
  
  $('.commentorder a').live('click', function(e){
    $this = $(this);
    var orders = ['oldest', 'newest'];
    var commentOrder = $this.attr('href').replace('#','');
    if ( !$this.parents('#comments').hasClass(commentOrder) ) {
      $this.parents('#comments').removeClass(orders.join(' ')).addClass(commentOrder);
      
      if( $("#post_comments .comment").length == 0 ) return;
      
      $('#comments .comment').reverseOrder();
      
        
    }
    //console.log(commentOrder,$this.parents('#comments'));    
    
    return false;
  });
  
  // talk homepage recnet activity streams
  $('.tabs').tabs();
  
});
// jQuery dom:ready end

function ActivateNavMenu(){
	var bIE7 = false;
	if($j.browser.msie){
		if(parseInt($j.browser.version) <= 7){
			bIE7 = true;
		}
	}
	
	if(bIE7){
		SubnavIE7Fix();
	}
	else{
		// enhance the css menu dropdown with the Superfish jQuery plugin (see notes below inthe plugins section)
		$j('#nav').superfish({
		hoverClass:    'hover',           // the class applied to hovered list items 
		delay:         100,               // the delay in milliseconds that the mouse can remain outside a submenu without it closing 
		animation:     {opacity:'show'},  // an object equivalent to first parameter of jQuery’s .animate() method 
		speed:         'fast',            // speed of the animation. Equivalent to second parameter of jQuery’s .animate() method 
		autoArrows:    false,              // if true, arrow mark-up generated automatically = cleaner source code at expense of initialisation performance 
		dropShadows:   false              // completely disable drop shadows by setting this to false 
		});
	}
}

function SubnavIE7Fix(){
	$j("#nav > li ul.subnav").each(function(){
		var $tab = $j(this).parent("li");
		var sTabID = $tab.attr("id");
		SubnavIE7Fix_Menus[sTabID] = this.innerHTML;
		$j(this).remove();
		$tab.hover(
			function(){
				var $tab = $j(this);
				var $subnav = $j("#subnavie7fix").html("<ul class=\"subnav\">" + SubnavIE7Fix_Menus[this.id] + "</ul>").show().find("ul").show();
				var iLeft = $tab.offset().left - $subnav.outerWidth(true);
				var iTop = $tab.offset().top + $tab.height();
				$subnav.css({
					left: iLeft + "px",
					top: iTop + "px"
				});
			},
			function(){
				$j("#subnavie7fix").hide();
			}
		);
	});
}

function UpdateLatestReviews(e){    
	var resultsPanel = $j('#latest_reviews_widget .results');
	var loadingLabel = $j('#latest_reviews_widget .loading');
	listingTypesFilter = $j.map($reviewFilters, function(checkbox){
	  if (checkbox.checked) return checkbox.value;
	});
	resultsPanel.hide();
	loadingLabel.show();
	var query = "cmd=load-latest-reviews&types=" + listingTypesFilter.join(",");
	$j.get("/php/ajax.php",
	  query,
	  function(response){
		loadingLabel.hide();
		resultsPanel.html("<ul>" + response + "</ul>").show();
	  }
	);    
}

// for the verticle scrollers like Recent Comments etc.
// requires, at the minimum, the following html structure:
// 
// <div class="scroller_container">
// 	<div class="scroller">
// 		<ul class="items">
// 			<li></li>
// 		</ul>
// 	</div>
// 	<div class="scroller_nav">
// 		<a class="down"></a>
// 		<a class="up"></a>
// 	</div>
// </div>
//
//  Settings:
// itemsPerPage: how many li elements to scroll by.
function scrollScroller(e) {
	// a 'page' is defined in the function as the number of li items we are moving up or down by in a single scroll.
	var itemsPerPage = 3;
	var scroller = $j(this).parents('.scroller_container').children('.scroller'); 
	// store the visible page in the the element as a prop
	if( !scroller[0].page) {
		scroller[0].page = 1;
	}
	// if we are scrolling up decrement the page, if we are scrolling down, increment it.
	scroller[0].page += $j(this).hasClass('up') ? -1 : 1;
	// check some bounds: don't scroll past the first or last page
	if ( scroller[0].page < 1) {
		scroller[0].page = 1;
		return false;
	}
	else if ( scroller[0].page > $j('ul li', scroller).length / itemsPerPage ) {
		scroller[0].page = 1;
	}
	// we want to target the li at the top of the page
	var targetItem = ( (scroller[0].page - 1) * itemsPerPage) + 1;				
	targetItemTop = $j("ul li:nth-child(" + targetItem + ")", scroller ).position().top;		
	// scroll the ul so that the target li is at the top of the container .scroller
	$j('ul.items', scroller).animate({'top': targetItemTop * -1 });
	
	return false;
}

	
// some helper functions
// function to load data from a bunch of JSON calls and fireoff a single callback
// when all AJAX responses have returned.
// returns a collection of JSON responses indexed by request URL.
$j.getConcurrentJSON =  new function(){
  this.loadAll = function( urls, callback) {
    var outstanding = urls.length;
    var results =  {};
    $j.each(urls, function(i, url){
      $j.getJSON(url,{},function(r){
        outstanding--;
        results[url]=r;
        if (outstanding === 0) { callback.call(null, results);}
      });
    });
  };
};
// a rudimentary tab changer function.
// should be improved to work with an options array for the activeClass, panelSuffix, $tabs etc
(function($){$.fn.tabs = function(){  
//console.log(this);
  return this.each(function(){
    $this = $(this);

    $this.data('activeClass', 'active');
    $this.data('panelSuffix', '_pane');
    $this.data('$tabs', $('li', this) );
    
    //console.log($this.data('$tabs'));
    
    $this.data('$tabs').live('click', function(e){
      //console.log(this);
      activateTab(this);
      activePanel(this);
    });
    
    function activateTab(tab) {
      $this.data('$tabs').removeClass( $this.data('activeClass') );
      $(tab).addClass($this.data('activeClass'));
    };
    function activePanel(tab) {
      $this.data('$tabs').each(function(){
        $('#'+this.id+$this.data('panelSuffix')).removeClass($this.data('activeClass'));
      });
      $( '#'+tab.id+$this.data('panelSuffix') ).addClass( $this.data('activeClass') );
    };
    
  });
    
};})(jQuery);
/* reverseOrder : jQuery order reverser plugin
 * Written by Corey H Maass for Arc90
 * (c) Arc90, Inc.
 * 
 * Licensed under:Creative Commons Attribution-Share Alike 3.0 http://creativecommons.org/licenses/by-sa/3.0/us/
 */
(function($){$.fn.reverseOrder=function(){return this.each(function(){$(this).prependTo($(this).parent());});};})(jQuery);
/* Superfish v1.4.8 - jQuery menu widget
 *
 * http://users.tpg.com.au/j_birch/plugins/superfish/
 * Copyright (c) 2008 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt
 */
;(function($){$.fn.superfish=function(op){var sf=$.fn.superfish,c=sf.c,$arrow=$(['<span class="',c.arrowClass,'"> &#187;</span>'].join('')),over=function(){var $$=$(this),menu=getMenu($$);clearTimeout(menu.sfTimer);$$.showSuperfishUl().siblings().hideSuperfishUl();},out=function(){var $$=$(this),menu=getMenu($$),o=sf.op;clearTimeout(menu.sfTimer);menu.sfTimer=setTimeout(function(){o.retainPath=($.inArray($$[0],o.$path)>-1);$$.hideSuperfishUl();if(o.$path.length&&$$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}},o.delay);},getMenu=function($menu){var menu=$menu.parents(['ul.',c.menuClass,':first'].join(''))[0];sf.op=sf.o[menu.serial];return menu;},addArrow=function($a){$a.addClass(c.anchorClass).append($arrow.clone());};return this.each(function(){var s=this.serial=sf.o.length;var o=$.extend({},sf.defaults,op);o.$path=$('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){$(this).addClass([o.hoverClass,c.bcClass].join(' ')).filter('li:has(ul)').removeClass(o.pathClass);});sf.o[s]=sf.op=o;$('li:has(ul)',this)[($.fn.hoverIntent&&!o.disableHI)?'hoverIntent':'hover'](over,out).each(function(){if(o.autoArrows)addArrow($('>a:first-child',this));}).not('.'+c.bcClass).hideSuperfishUl();var $a=$('a',this);$a.each(function(i){var $li=$a.eq(i).parents('li');$a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});});o.onInit.call(this);}).each(function(){var menuClasses=[c.menuClass];if(sf.op.dropShadows&&!($.browser.msie&&$.browser.version<7))menuClasses.push(c.shadowClass);$(this).addClass(menuClasses.join(' '));});};var sf=$.fn.superfish;sf.o=[];sf.op={};sf.IE7fix=function(){var o=sf.op;if($.browser.msie&&$.browser.version>6&&o.dropShadows&&o.animation.opacity!=undefined)
this.toggleClass(sf.c.shadowClass+'-off');};sf.c={bcClass:'sf-breadcrumb',menuClass:'sf-js-enabled',anchorClass:'sf-with-ul',arrowClass:'sf-sub-indicator',shadowClass:'sf-shadow'};sf.defaults={hoverClass:'sfHover',pathClass:'overideThisToUse',pathLevels:1,delay:800,animation:{opacity:'show'},speed:'normal',autoArrows:true,dropShadows:true,disableHI:false,onInit:function(){},onBeforeShow:function(){},onShow:function(){},onHide:function(){}};$.fn.extend({hideSuperfishUl:function(){var o=sf.op,not=(o.retainPath===true)?o.$path:'';o.retainPath=false;var $ul=$(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass).find('>ul').hide().css('visibility','hidden');o.onHide.call($ul);return this;},showSuperfishUl:function(){var o=sf.op,sh=sf.c.shadowClass+'-off',$ul=this.addClass(o.hoverClass).find('>ul:hidden').css('visibility','visible');sf.IE7fix.call($ul);o.onBeforeShow.call($ul);$ul.animate(o.animation,o.speed,function(){sf.IE7fix.call($ul);o.onShow.call($ul);});return this;}});})(jQuery);
/**
  * hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
  * <http://cherne.net/brian/resources/jquery.hoverIntent.html>
  * 
  * @param  f  onMouseOver function || An object with configuration options
  * @param  g  onMouseOut function  || Nothing (use configuration options object)
  * @author    Brian Cherne <brian@cherne.net>
  */
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);
/**
 * ugly mt:ifLoggedIn required function
 */
function ifLoggedIn( isLoggedIn, domId ) {
  //console.log(isLoggedIn, domId);
  if (isLoggedIn) {
   $j('#'+domId).show();
  } else {
   $j('#'+domId + "_else").show();
  }
}; 


// some oldschool stuff that may be eliminatable
$j(function(){
	try{
		Sidebar_Buzz_Load();
	}
	catch(e){}
});
var aEntries = [];

function Go2Category(sCategoryName, sCategoryID){
	var sPage = "";
	if(sCategoryID == "") return;
	if(sCategoryID == "weather"){
		sPage = '/weather/?display=fc';
	}
	if(sCategoryID == "restaurantlistings"){
		sPage = '/restaurants.php';
	}
	else sPage = "/" + escape(sCategoryID);
	window.location = sPage;
	return false;
}

function AuthorSearch(sAuthor){
	if(sAuthor == "") return;
	window.location = "/author/" + sAuthor.toLowerCase();
}

function BookmarkPage(sURL, sTitle){
	if(sURL == null){
		sURL = window.location.href;
		sTitle = document.title;
	}
	if(document.all){
		window.external.AddFavorite(sURL, sTitle);
	}
	else{
		alert("Sorry, automatic adding of this page to your favorites is not supported by your web browser.\n\nTo add this page to your favorites, just use the \"Bookmarks\" menu in your browser."); 
	}
	return false;
}

function PrintEntry(iEntryID){
	var sPage = "/print/" + iEntryID;
	var iHeight = 500;
	var iWidth = 700;
	var iLeft = Math.round(screen.width / 2) - Math.round(iWidth / 2);
	var iTop = Math.round(screen.height / 2) - Math.round(iHeight / 2);
	var Popup = window.open(sPage, "", "left=" + iLeft + ",top=" + iTop + ",height=" + iHeight + ",width=" + iWidth + ",scrollbars=1");
	return false;
}

function ToggleDisplay(sLayerID){
	var Layer = document.getElementById(sLayerID);
	if(Layer.style.display == "none"){
		Layer.style.display = "block";
	}
	else{
		Layer.style.display = "none";
	}
}

function Trim(sText){
	return sText.replace(/^\s*|\s*$/g, "");
}

function IsEmail(sAddress){
	if(sAddress == "") return false;
	var objRegExp = new RegExp("^[a-z0-9_.\-]{3,}@[a-z0-9.\-]{3,}\.[a-z]{2,3}$", "i");
	return objRegExp.test(sAddress);
}

function CurrentDateTime(){
	var dNow = new Date();
	var iDay = dNow.getDate();
	var iMonth = dNow.getMonth();
	var aMonths = new Array();
	aMonths[0] = "January";
	aMonths[1] = "February";
	aMonths[2] = "March";
	aMonths[3] = "April";
	aMonths[4] = "May";
	aMonths[5] = "June";
	aMonths[6] = "July";
	aMonths[7] = "August";
	aMonths[8] = "September";
	aMonths[9] = "October";
	aMonths[10] = "November";
	aMonths[11] = "December";
	var iYear = dNow.getFullYear();
	var iHour = dNow.getHours();
	if (iHour >= 12) sTime = "PM";
	else sTime = "AM";
	if (iHour > 12) iHour -= 12;
	if (iHour == 0) iHour = 12;
	var iMinutes = dNow.getMinutes();
	if (iMinutes < 10) iMinutes = "0" + iMinutes;
	return aMonths[iMonth] + " " + iDay + ", " + iYear + " " + iHour + ":" + iMinutes + " " + sTime;
}

function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") +
        (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
    document.cookie = curCookie;
}

function getCookie (name) {
    var prefix = name + '=';
    var c = document.cookie;
    var nullstring = '';
    var cookieStartIndex = c.indexOf(prefix);
    if (cookieStartIndex == -1)
        return nullstring;
    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = c.length;
    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function rememberMe(){
}

function ToggleDisplay(sLayerID){
	var Layer = document.getElementById(sLayerID);
	if(Layer.style.display == "none"){
		Layer.style.display = "block";
	}
	else{
		Layer.style.display = "none";
	}
}

function PreloadImage(sFile){
	var objImage = new Image();
	objImage.src = sFile;
}

function SwapImage(objImage, sNewImage){
	if(document.images){
		objImage.src = sNewImage;
	}
}

function Sidebar_Links_Category_Change(){
	var Form = document.forms.frmSidebarLinks;
	var objLayer = document.getElementById("Sidebar_Links_Layer");
	if(Form.Category.value != ""){
		objLayer.innerHTML = "<img src=\"/site/images/ajax-loader2.gif\" align=\"absmiddle\" /><strong> Loading...</strong>";
		sData = "cmd=getlinks&category=" + Form.Category.value;
		AJAXRequest("/php/ajax.php", "POST", sData, function(sResponse, aError){
			if(!aError){
				objLayer.innerHTML = sResponse;
			}
		});
	}
	else{
		objLayer.innerHTML = "";
	}
}

function Sidebar_Links_List_Change(sURL){
	if(sURL != ""){
		window.open(sURL);
	}
}

var objBuzzItems;
var iBuzzListSize = 10;
var sBuzzTab = "mostcommented";

function Sidebar_Buzz_ChangeType(sType){
	var sFolder = "/site/images/buzz/";
	var sMostCommentedMode = "off";
	var sMostRecommendedMode = "off";
	var sMostViewedMode = "off";
	sBuzzTab = sType;
	if(sType == "mostcommented") sMostCommentedMode = "on";
	if(sType == "mostrecommended") sMostRecommendedMode = "on";
	if(sType == "mostviewed") sMostViewedMode = "on";
	document.images.imgSidebarBuzz_MostCommented.src = sFolder + "mostcommented-" + sMostCommentedMode + ".jpg";
	document.images.imgSidebarBuzz_MostRecommended.src = sFolder + "mostrecommended-" + sMostRecommendedMode + ".jpg";
	document.images.imgSidebarBuzz_MostViewed.src = sFolder + "mostviewed-" + sMostViewedMode + ".jpg";
	Sidebar_Buzz_Display();
}

function Sidebar_Buzz_Load(){
	var Form = document.forms.frmSidebarBuzz;
	var Layer = document.getElementById("Sidebar_Buzz_Results");
	Layer.innerHTML = "<img src=\"/site/images/ajax-loader2.gif\" align=\"absmiddle\" style=\"margin-right: 5px;\"><strong>Loading...</strong>";
	var sData = "cmd=getbuzz&post_age=" + Form.PostAge.value;
	AJAXRequest("/php/ajax.php", "POST", sData, function(sResponse, aError){
		if(!aError){
			objBuzzItems = eval(sResponse);
			Sidebar_Buzz_Display();
		}
	});
}

function Sidebar_Buzz_Display(){
	var sHTML = "";
	if(sBuzzTab == "mostcommented"){
		objList = objBuzzItems.mostcommented;
	}
	else if(sBuzzTab == "mostrecommended"){
		objList = objBuzzItems.mostrecommended;
	}
	else if(sBuzzTab == "mostviewed"){
		objList = objBuzzItems.mostviewed;
	}
	iListItems = iBuzzListSize;
	if(iListItems > objList.length) iListItems = objList.length;
	for(i=0; i<iListItems; i++){
		sHTML += "<p><a href=\"" + objList[i].url + "\">" + unescape(objList[i].title) + "</a></p><div class=\"line\"></div>";
	}
	var Layer = document.getElementById("Sidebar_Buzz_Results");
	Layer.innerHTML = sHTML;
}

function Sidebar_Buzz_Size(){
	if(iBuzzListSize == 10){
		iBuzzListSize = 20;
		document.getElementById("Sidebar_Buzz_SizeLink").innerHTML = "Less";
	}
	else{
		iBuzzListSize = 10;
		document.getElementById("Sidebar_Buzz_SizeLink").innerHTML = "Expand";
	}
	Sidebar_Buzz_Display();
}

function BookmarkPage(sURL, sTitle){
	if(sURL == null){
		sURL = window.location.href;
		sTitle = document.title;
	}
	if(document.all){
		window.external.AddFavorite(sURL, sTitle);
	}
	else{
		alert("Sorry, automatic adding of this page to your favorites is not supported by your web browser.\n\nTo add this page to your favorites, just use the \"Bookmarks\" menu in your browser."); 
	}
	return false;
}

function PrintEntry(iEntryID){
	var sPage = "/print/" + iEntryID;
	var iHeight = 500;
	var iWidth = 700;
	var iLeft = Math.round(screen.width / 2) - Math.round(iWidth / 2);
	var iTop = Math.round(screen.height / 2) - Math.round(iHeight / 2);
	var Popup = window.open(sPage, "", "left=" + iLeft + ",top=" + iTop + ",height=" + iHeight + ",width=" + iWidth + ",scrollbars=1");
	return false;
}

function Sidebar_Links_Category_Change(){
	var Form = $("frmSidebarLinks");
	var objLayer = document.getElementById("Sidebar_Links_Layer");
	if(Form.Category.value != ""){
		objLayer.innerHTML = "<img src=\"/site/images/ajax-loader2.gif\" align=\"absmiddle\" /><strong> Loading...</strong>";
		sData = "cmd=getlinks&category=" + Form.Category.value;
		AJAXRequest("/php/ajax.php", "POST", sData, function(sResponse, aError){
			if(!aError){
				objLayer.innerHTML = sResponse;
			}
		});
	}
	else{
		objLayer.innerHTML = "";
	}
}

function Sidebar_Links_List_Change(sURL){
	if(sURL != ""){
		window.open(sURL);
	}
}

var RecentComments_ItemsPerPage = 3;
var RecentComments_Page = 1;

var MostCommented_ItemsPerPage = 3;
var MostCommented_Page = 1;

function RecentComments_Scroll(iDirection){
	if($("#recentcomments ul li").length == 0) return;
	RecentComments_Page += iDirection;
	if(RecentComments_Page < 1){
		RecentComments_Page = 1;
		return;
	}
	else if(RecentComments_Page > ($$("#recentcomments ul li").length / RecentComments_ItemsPerPage)){
		RecentComments_Page = 1;
	}
	Position.prepare();
	var iContainerY = Position.cumulativeOffset($("recentcomments"))[1];
	var iPositionY = Position.cumulativeOffset($$("#recentcomments ul li:nth-child(" + (((RecentComments_Page - 1) * RecentComments_ItemsPerPage) + 1) + ")")[0]).top - iContainerY;
	new Effect.Scroll($("recentcomments"), {x:0, y:iPositionY});
}

var GMAPS_DEFAULT_ZOOM = 12;

function GMAPS_POINT_TORONTO(){
	return new GLatLng(43.67016874852075, -79.38682079315186);
}

function GMaps_FocusMap(objMap, aPoints){
	if(aPoints.length == 0) return;
	var fSumX = 0, fSumY = 0;
	var iPoints = aPoints.length;
	for(i=0; i<iPoints; i++){
		fSumX += aPoints[i].lat();
		fSumY += aPoints[i].lng();
	}
	var fAverageX = fSumX / iPoints;
	var fAverageY = fSumY / iPoints;
	fSumX = 0;
	fSumY = 0;
	for(i=0; i<iPoints; i++){
		fSumX += Math.pow((aPoints[i].lat() - fAverageX), 2);
		fSumY += Math.pow((aPoints[i].lng() - fAverageY), 2);
	}
	var fDeviationX = Math.sqrt(fSumX / (iPoints - 1));
	var fDeviationY = Math.sqrt(fSumY / (iPoints - 1));
	var iDeviationRadius = Math.sqrt(Math.pow((fDeviationX * -1), 2) + Math.pow((fDeviationY * -1), 2));	
	
	if(isNaN(iDeviationRadius)){
		var iZoom = 16;
	}
	else{
		var PointNE = new GLatLng((fAverageX + iDeviationRadius), (fAverageY + iDeviationRadius));
		var PointSW = new GLatLng((fAverageX - iDeviationRadius), (fAverageY - iDeviationRadius));
		var iZoom = objMap.getBoundsZoomLevel(new GLatLngBounds(PointSW, PointNE));
	}
	
	if(iZoom < GMAPS_DEFAULT_ZOOM) iZoom = GMAPS_DEFAULT_ZOOM;
	
	if(objMap.getZoom() == iZoom){
		objMap.panTo(new GLatLng(fAverageX, fAverageY));
	}
	else{
		objMap.setCenter(new GLatLng(fAverageX, fAverageY), iZoom);
	}
}