/*
$Id: activities.build.js 21119 2009-06-26 22:16:31Z santep $
(c) 2008 The New York Times Company
*/

/*
Determining page group, type, title and descriptions based on META tags
*/
TimesPeople.Config.Page = {                                                                           
    Group:
    [
        { value: 'articleid', alias: 'article' },
        { value: 'PT' },
        { value: 'WT.z_gpt',  alias: 'article' }
    ],
    Type:
    {
        "article": 
        {
            "tom" :
            [
                { value: "biography"      },
                { value: "editor's note"  },
                { value: "editorial"      },
                { value: "interview"      },
                { value: "recipe"         },
                { value: "special report" },
                { value: "review"         }
            ]
        },
        "topic": 
        {
            "SCG":
            [ 
                { value: "movie pages", alias: "movie guide" },
                { value: "destinations", alias: "destination" }
            ],
            "PST":
            [ 
                { value: "movie details", alias: "movie guide" },
                { value: "health guide" },
                { value: "travel guide" }
            ]
        },
        "community":
        {
            "PST":
            [ 
                { value: "comments overflow", alias: "article" },
                { value: "rate-review",       alias: "movie guide" }
            ]
        },
        "multimedia": 
        {
            "SCG":
            [
                { value: "election guide" }
            ],
            "PST":
            [
                { value: "interactive", alias: "interactive graphic" },
                { value: "interactive features", alias: "interactive feature" },
                { value: "image",       alias: "graphic"},
                { value: "video" }
            ],
            "tom":
            [
                { value: "slideshow",  alias: "slide show" }
            ]
        },
        "blogs":
        {
            "PST":
            [
                { value: "blog main",   alias: "blog" },
                { value: "blog post" }
            ]
        },
        "venue": 
        {
            "tom":
            [
                { value: "attraction" },
                { value: "dining",        alias: "restaurant" },
                { value: "accommodation", alias: "hotel"      },
                { value: "shopping",      alias: "attraction" },
                { value: "night life",    alias: "attraction" } 
            ]
        }
    },
    Title:
    {
        "article":
        {
            "default":      [ "meta[name='hdl']", "div.header h1:not(h1.movie)", "div.header h1", "#aColumn #article h1", "title"],
            "article":      [ "meta[name='hdl']", "div.header h1:not(h1.movie)", "div.header h1", "#aColumn #article h1"]
        },
        "topic":
        {
            "default"     : [ "meta[name='name']",    "meta[name='GTN']", "#subHdr h1", "title" ],
            "topic"       : [ "meta[name='name']",    "meta[name='GTN']", "#subHdr h1" ],
            "movie guide" : [ "#header div.title h1", "meta[name='MTI']" ],
            "health guide": [ "meta[name='HGSN']" ],
            "travel guide": [ "h5.fn", "meta[name='name']" ]
        },
        "multimedia":
        {
            "default":      [ "meta[name='hdl']",     "title" ],
            "interactive graphic": [ "meta[name='hdl']" , "title" ],
            "interactive feature": [ "meta[name='hdl']" , "title" ],
            "slide show":   [ "meta[name='hdl']",     "title" ],
            "graphic":      [ "meta[name='dsk']",     "title" ],
            "election guide": [ "h1",                 "#masthead h2 a", "title" ],
            "video":        [ "#libraryPlayerTitleName h1" ]
        },
        "blogs":
        {
            "default":      [ "h2.entry-title", "title" ],
            "blog post":    [ "h2.entry-title" ]
        }   ,
        "venue":
        {
            "default":      [ "meta[name='name']", "title" ],
            "hotel":        [ "meta[name='name']" ],
            "restaurant":   [ "meta[name='name']" ],
            "attraction":   [ "meta[name='name']" ]
        },
        "community":
        {
            "default":      [ "#header div.title h1", "meta[name='MTI']", "title" ],
            "movie guide":  [ "#header div.title h1", "meta[name='MTI']" ]
        }
    },
    Description:
    {
        "article":
        {
            "default":      [ "#aColumn #article p:not(p:empty)", "meta[name='description']", "meta[name='lp']" ],
            "article":      [ "#aColumn #article p:not(p:empty)", "meta[name='description']", "meta[name='lp']" ],
            "editorial":    [ "#aColumn #article p:not(p:empty)", "meta[name='description']", "meta[name='lp']" ]
        },
        "topic":
        {
            "default":      [ "meta[name='description']" ],
            "topic"       : [ "div.companyInformation", "meta[name='description']", "meta[name='summary']" ],
            "movie guide" : [ "p[class='review']",      "meta[name='description']" ],
            "health guide": [ "#definition p",          "meta[name='Description']" ],
            "travel guide": [ "#topStoryHorizontal p",  "meta[name='description']" ]
        },
        "multimedia":
        {
            "default":      [ "meta[name='description']" ],
            "interactive graphic": [ "meta[name='description']" ],
            "interactive feature": [ "meta[name='description']" ],
            "slide show":   [ "div.story", "div[class='caption']", "meta[name='description']" ],
            "graphic":      [ "td font[size='-1']", "meta[name='byl']", "meta[name='description']" ],
            "election guide": [ "meta[name='description']" ],
            "video":        [ "#libraryPlayerDesc p" ]
        },
        "blogs":
        {
            "default":      [ "meta[name='description']" ],
            "blog post":    [ "div.entry-content p", "meta[name='description']" ]
        }   ,
        "venue":
        {
            "default":      [ "meta[name='description']" ],
            "hotel":        [ "p.description", "span.description", "meta[name='description']" ],
            "restaurant":   [ "p.description", "span.description", "meta[name='description']" ],
            "attraction":   [ "p.description", "span.description", "meta[name='description']" ]
        },
        "community":
        {
            "default":      [ "meta[name='description']" ],
            "movie guide" : [ "div.result]",      "meta[name='description']" ]
        }
    }
};

/*
	Config Actions
	- condition to satisfy, location in page, element type, element style, position (first/last), HTML for action within element
*/

TimesPeople.Config.HTML = {
	Recommend:
	{
		standard  : "<a class='timespeople_recommend_link' href='javascript:void(0);' style='background-image:url(__ICON__); background-repeat:no-repeat; padding:2px 0 3px 20px; font-size:1em; display:block;'><span>__LABEL__</span></a>",
		uppercase : "<a class='timespeople_recommend_link' href='javascript:void(0);' style='background-image:url(__ICON__); background-repeat:no-repeat; padding:1px 0 3px 20px; font-size:1em; color:#333333; text-transform:uppercase;'>__LABEL__</a>",
		blog      : "<a class='timespeople_recommend_link' href='javascript:void(0);' style='background-image:url(__ICON__); background-repeat:no-repeat; padding:1px 0 3px 20px; color:#004276;'>__LABEL__</a>"
	}
};

TimesPeople.Config.Style = {
	Recommend:
	{
		 standard   : "padding-right:10px;border-right:1px solid #CCCCCC;margin-right:10px"
	}
};

/*
	Structure:
		btnConfig = {
			PAGE_GROUP: {
				PAGE_TYPE: { key: IF_THIS_ELM_EXISTS, target: PLACE_HERE, type: TAG, style: CSS, position: first_OR_last, html: BUTTON_HTML }
				...
		where key and target are are prototpe css selectors, and evaluates as $$(IF_THIS_ELM_EXISTS)[0]
*/
TimesPeople.Config.Action = {
	Recommend:
	{
		"article": 
		{
			"article":      { key: "#toolsList", target: "#toolsList", type: "li", style: {}, position: "first", html: TimesPeople.Config.HTML.Recommend.standard },
			"editorial":    { key: "#toolsList", target: "#toolsList", type: "li", style: {}, position: "first", html: TimesPeople.Config.HTML.Recommend.standard },
			"default":      { key: "#toolsList", target: "#toolsList", type: "li", style: {}, position: "first", html: TimesPeople.Config.HTML.Recommend.standard }
		},
		"topic":
		{
			"topic"       : { key: "#tools", target: "#tools", type: "span", style: 'padding-right:10px;border-right:1px solid #CCCCCC;margin-right:10px', position: "first", html: TimesPeople.Config.HTML.Recommend.uppercase },
			"movie guide" : { key: "#tools", target: "#menu",  type: "span", style: 'float: right; margin: 5px 0 0 4px; padding-left: 2px;', position: "last", html: TimesPeople.Config.HTML.Recommend.uppercase },
			"destination" : { key: "#tools", target: "#menu",  type: "span", style: 'float: right; margin: 5px 0 0 4px; padding-left: 2px;', position: "last", html: TimesPeople.Config.HTML.Recommend.uppercase },
			"health guide": { key: "#tools", target: "#breadcrumb", type: "span", style: 'float:right;', position: "first", html: TimesPeople.Config.HTML.Recommend.uppercase },
			"travel guide": { key: "#tools", target: "#tools", type: "span", style: TimesPeople.Config.Style.Recommend.standard, position: "first", html: TimesPeople.Config.HTML.Recommend.uppercase },
			"default"     : { key: "#tools", target: "#tools", type: "span", style: 'padding-right:10px;border-right:1px solid #CCCCCC;margin-right:10px', position: "first", html: TimesPeople.Config.HTML.Recommend.uppercase }
		},
		"multimedia":
		{
			"interactive graphic": { key: "#articleTools", target: "#articleTools", type: "li", style: '', position: "last", html: TimesPeople.Config.HTML.Recommend.standard },
			"slide show":     { key: "#toolsList", target: "#toolsList", type: "li",  style: TimesPeople.Config.Style.Recommend.standard, position: "first", html: TimesPeople.Config.HTML.Recommend.uppercase },
			"graphic":        { key: "table", target: "font[size='-2']", type: "div", style: 'padding-top:4px; font-family:Arial,Helvetica;', position: "last", html: TimesPeople.Config.HTML.Recommend.uppercase },
			"election guide": { key: "#toolsList", target: "#toolsList", type: "li",  style: '', position: "first", html: "<a class='timespeople_recommend_link' href='javascript:void(0);' style='color:#333; background-position:4px; font-size:1em; text-transform:uppercase; background-image:url(__ICON__); background-repeat:no-repeat;'>__LABEL__</a>" },
			"default":        { key: "#toolsList", target: "#toolsList", type: "li",  style: TimesPeople.Config.Style.Recommend.standard, position: "first", html: TimesPeople.Config.HTML.Recommend.uppercase }
		},
		"blogs":
		{
			"blog post": { key: "#content", target: "ul.entry-tools", type: "li", style: "padding-right:10px; margin-right:10px", position: "last", html: TimesPeople.Config.HTML.Recommend.blog },
			"default"  : { key: "#content", target: "ul.entry-tools", type: "li", style: "padding-right:10px; margin-right:10px", position: "last", html: TimesPeople.Config.HTML.Recommend.blog }
		},
		"venue":
		{
			"hotel":      { key: "#tools", target: "#tools", type: "span", style: TimesPeople.Config.Style.Recommend.standard, position: "first", html: TimesPeople.Config.HTML.Recommend.uppercase },
			"restaurant": { key: "#tools", target: "#tools", type: "span", style: TimesPeople.Config.Style.Recommend.standard, position: "first", html: TimesPeople.Config.HTML.Recommend.uppercase },
			"attraction": { key: "#tools", target: "#tools", type: "span", style: TimesPeople.Config.Style.Recommend.standard, position: "first", html: TimesPeople.Config.HTML.Recommend.uppercase },
			"default":    { key: "#tools", target: "#tools", type: "span", style: TimesPeople.Config.Style.Recommend.standard, position: "first", html: TimesPeople.Config.HTML.Recommend.uppercase }
		}
	}
};/*
$Id: activities.build.js 21119 2009-06-26 22:16:31Z santep $
(c) 2008 The New York Times Company
*/

TimesPeople.Page = {

	initialize: function() {
	/*
		Run standard presets for the current page.
	*/
    // FIXME what happens if it's not ready?
		TimesPeople.console.log("Has init. Doing presets");

		this.getType();
		this.section     = this.getSection();
		this.subsection  = this.getSubSection();
		this.title       = this.getTitle();
		this.description = this.getDescription();

		return true;
	},
	
  isRecommendable: function() {
    if (this.isGetStarted()) {
      return false;
    }
    if (!this.group) this.getType();
    var recommendableGroups = {'article': true, 'topic': true, 'multimedia': true, 'venue': true, 'community': true, 'blogs': true};
    return this.group in recommendableGroups;
  },
  
  isGetStarted: (function() {
    var pattern = new RegExp(TimesPeople.Config.get_started_uri);
    var result = pattern.test(window.location.href);
    return function(){
      return result;
    };
  })(),
	
	getSection: function() {
		var section = $$('meta[name="CG"]')[0];
		if (section)
		{
			return section.getAttribute("content").toLowerCase();
		}
		return '';
	},

	getSubSection: function() {
		if (this.type == "article" || this.type == "multimedia")
		{
			var subsection = $$('meta[name="SCG"]')[0];
			if (subsection)
			{
				return subsection.getAttribute("content").toLowerCase();
			}
		}
		return '';
	},

	getType: function() {

		var metaSearch, metaExists;
		var mList, mTagPage;
		var keepGoing = true;
		var pos = 0;
	/*
		Get the top level page type
	*/
		while (keepGoing && (pos < TimesPeople.Config.Page.Group.length))
		{
			metaSearch = TimesPeople.Config.Page.Group[pos];
			metaExists = $$('meta[name="' + metaSearch.value + '"]')[0];

			if (metaExists != undefined)
			{
				keepGoing  = false;
				this.group = (metaSearch.alias != undefined) ? metaSearch.alias : metaExists.getAttribute("content").toLowerCase();
				this.type  = this.group; 
				mList      = TimesPeople.Config.Page.Type[TimesPeople.Page.group];

				$H(mList).keys().each(function(key)
				{
					mTagPage = $$('meta[name="' + key + '"]')[0];

					if (mTagPage != undefined)
					{
						mList[key].each(function(mItem, index) {

							if (mItem.value == mTagPage.getAttribute("content").toLowerCase())
							{
								TimesPeople.Page.type = (mItem.alias != undefined) ? mItem.alias : mItem.value;
								return this.type;
							}
						});
					}
				});
			}
			pos++;
		}
		this.group = this.group || 'article';
    this.type = this.type || 'article';
		return this.type;
	},

    getTitle:  function () {
    /*
        Get the standard page title depending on what group and type it belongs to.
    */
        var title = '';

        if (TimesPeople.Config.Page.Description[this.group] != undefined)
        {
            if (TimesPeople.Config.Page.Title[this.group][this.type] != undefined)
            {
                title = this.getEmbeddedValue(TimesPeople.Config.Page.Title[this.group][this.type]);
            }
            else
            {
                title = this.getEmbeddedValue(TimesPeople.Config.Page.Title[this.group]['default']);
            }
        }

    //  Failsafe
        if (title == undefined || title == '') {
            title =  document.title;

            var removeThese = [' - NYTimes.com', ' - The New York Times', ' - New York Times', 
                               ' - NY Times Health Information', ' - NY Times Health' ];

            removeThese.all(function(removeThis) {
                title = title.replace(removeThis, '');
            });
        }

        return title;
    },

	getDescription: function() {
	/*
		Get the standard page description depending on what group and type it belongs to.
	*/
		var description = '';

		if (TimesPeople.Config.Page.Description[this.group] != undefined)
		{
			if (TimesPeople.Config.Page.Description[this.group][this.type] != undefined)
			{
				description = this.getEmbeddedValue(TimesPeople.Config.Page.Description[this.group][this.type]);
			}
			else
			{
				description = this.getEmbeddedValue(TimesPeople.Config.Page.Description[this.group]['default']);
			}
			description = (description == undefined) ? '' : description;
		}	
		return description;
	},
	
	getEmbeddedValue: function(cssSelectorList) {
		var result = '';
		if (cssSelectorList)
		{
			cssSelectorList.each(function(trySelector){
				var embDesc = $$(trySelector)[0];
				if (embDesc != undefined)
				{
					var embValue;
					if (trySelector.indexOf("meta")>-1)
					{
						embValue = embDesc.getAttribute("content");
					}
					else
					{
						embValue = embDesc.innerHTML;
					}

					if (embValue != "")
					{
						result = embValue.stripTags().replace(/\n/g,'').strip().truncate(250);
						throw $break;
					}
				}
			});
		}
		return result;
	}
	
};
/*
$Id: activities.build.js 21119 2009-06-26 22:16:31Z santep $
(c) 2008 The New York Times Company
*/

TimesPeople.ActivityCollectionController = {

    initialize: function() {
      var pageLoaded;

      Event.observe(window, 'load', function() {
        var pageLoaded = true;
      });

      this.user = TimesPeople.User.getInstance();
      if(this.user.isLoaded()) {
        this.listen();
      }
      else {
        this.user.register(TimesPeople.ActivityCollectionController);
      }
    },

    update: function(msg) {
      this.listen();
      this.user.unregister(TimesPeople.ActivityCollectionController);
    },

    assign: function(activity, fn) {
      if (Object.isFunction(fn)) {
        fn = fn.wrap(function(proceed){
          new TimesPeople.Activity('recommended', TimesPeople.Page.title);
          proceed();
        });
      }
    },

    listen: function() {
      if (this.listening) return;
      this.listening = true;
      TimesPeople.Page.initialize();
      this.draw();
    },

    draw: function() {
/*
    Common across page groups
*/
        if (TimesPeople.Page.group!=undefined) {

            switch (TimesPeople.Page.group){
                case "article": 
                    this.addRecommend();
                    this.addRecommend({key: "div.nextArticleLink", target: "div.nextArticleLink", type: "span", style: "float:right;", position: "first", html: "<a class='timespeople_recommend_link' href='javascript:void(0);' style='background-image:url(__ICON__); background-repeat:no-repeat; padding:0 0 3px 20px; font-size:1em;'>__LABEL__</a>"});
                    this.addComments();
                    break;
                case "topic":
                    if (TimesPeople.Page.section == "business") {
                        this.addRecommend({ key: "#breadcrumbs", target: "#breadcrumbs", type: "span", style: "float:right", position: "first", html: "<a class='timespeople_recommend_link' style='color:#333; padding:1px 0 3px 20px; font-size:1em; text-transform:uppercase; background-image:url(__ICON__); background-repeat: no-repeat;' href='javascript:void(0);'>__LABEL__</a>" });       //  Verifed on Dev for: regular, travel, health (has issues on some + potential ad conflict)
                    } else  {
                        this.addRecommend();
                    }
                    break;
                case "multimedia":
                    this.addRecommend();
                    break;
                case "venue":   
                    this.addRecommend();
                    this.addRate();
                    this.addComments();
                    break;
                case "community":
                    this.addRecommend();
                    this.addRate();
                    this.addComments();
                    break;
                default :
                //  nothing
            }
/*
        Unique to specific pages
*/
            switch (TimesPeople.Page.type) {
                case "blog post":   
                    this.addRecommend();
                    this.addComments();
                    break;
                case "travel guide":
                    this.addComments();
                    break;
                case "movie guide":
                    this.addRate();
                    break;
            }

            return true;
        }
        return false;
    },

    addRecommend: function(button) {

        var icon_host    = TimesPeople.Config.image_host + "/images/global/icons/";
        var icon         = (TimesPeople.Page.type == 'slide show' || TimesPeople.Page.type == 'video') ? icon_host + "recommend_dark.gif" : icon_host + "recommend.gif";
        var label        = this.user.isTimesPeopleMember() ? 'Recommend' : 'Sign in to Recommend';
        var user         = this.user;
        var btnRecommend;
    
        if (button) {
            btnRecommend = button;
        } else {
            if (TimesPeople.Config.Action.Recommend[TimesPeople.Page.group] != undefined) {
                if (TimesPeople.Config.Action.Recommend[TimesPeople.Page.group][TimesPeople.Page.type] != undefined) {
                    btnRecommend = TimesPeople.Config.Action.Recommend[TimesPeople.Page.group][TimesPeople.Page.type];
                } else  {
                    btnRecommend = TimesPeople.Config.Action.Recommend[TimesPeople.Page.group]['default'];
                }
            }
        }

        TimesPeople.console.log("Trying to add Recommend button");

    //  Attach event
        function onClickRecommend(e) {

            if (!user.isTimesPeopleMember()) {
                window.location = TimesPeople.Config.get_started_uri + '?url=' + encodeURIComponent(window.location.href);
                return;
            }

            var btnTarget = e.target;
            btnTarget.innerHTML = 'Thanks!';

            if (TimesPeople.Page.type=='video') {
                new TimesPeople.Activity('recommended', getShareHeadline(), getShareDescription(), getShareURL());
                window.setTimeout(restoreRecommendButtons, 5000);
            } else {
                new TimesPeople.Activity('recommended', TimesPeople.Page.title);
                Event.stopObserving(btnTarget,'click', onClickRecommend, true);
                window.setTimeout(removeRecommendButtons, 3000);
            }

            return false;
        }

        function removeRecommendButtons() {
            var recommend_btns = $$('a.timespeople_recommend_link').invoke('remove');
        }

        function restoreRecommendButton() {
            var recommend_btns = $$('a.timespeople_recommend_link')[0];
            if (recommend_btns) {
                recommend_btns.innerHTML = 'Recommend';
            }
        }

        if (btnRecommend) {
            if ($$(btnRecommend.key)[0]) {
                var btnTarget = $$(btnRecommend.target)[0];
                if (btnTarget) {
                    var btn = new Element(btnRecommend.type, {style: btnRecommend.style});
                    btn.innerHTML = btnRecommend.html.replace(/__ICON__/g, icon).replace(/__LABEL__/g, label);
                    btn.className = "timespeople_btn_recommend";

                    if (btnRecommend.position == "first") {
                        btnTarget.insert({top:btn});
                    } else {
                        btnTarget.insert({bottom:btn});
                    }

                    Event.observe(btn, 'click', onClickRecommend, true);
                }
            }

        }
        return;
    },

    addRate: function() {
        TimesPeople.console.log("Trying to add Ratings");

        var isRatable  = ($$('div.readerRating')[0]) ? true : false;
        var hasRateDiv = ($$('div.subListB')[0])     ? true : false;

        if (isRatable && hasRateDiv)    {
            var title  = '';
            var review = '';

            if (TimesPeople.Page.section=='movies') {
                switch(TimesPeople.Page.group) {
                    case 'article':
                        title  = TimesPeople.Page.getEmbeddedValue(['div.header h1']);
                        review = TimesPeople.Page.getEmbeddedValue(['p:not(p:empty)']);
                        break;
                    case 'topic':
                        title  = TimesPeople.Page.getEmbeddedValue(["meta[name='MTI']"]);
                        review = TimesPeople.Page.getEmbeddedValue(["p.review"]);
                        break;
                    case 'community':
                        title  = TimesPeople.Page.getEmbeddedValue(["meta[name='MTI']"]);
                        review = TimesPeople.Page.getEmbeddedValue(['div.reviewText']);
                }
            } else if (TimesPeople.Page.section=='travel') {
                title  = TimesPeople.Page.getEmbeddedValue(["div.bColumn h5"]);
                review = TimesPeople.Page.getEmbeddedValue(['div.bColumn p']);
            }

            if (title!='' && review!='') {
                TimesPeople.console.log("Adding events to images");
                var imageList = $$('div.subListB')[0].select('img');
                imageList.each(function(img){
                    Event.observe(img, 'click', function(event) {
                        new TimesPeople.Activity('rated', title, review.stripTags().truncate(250));
                    });
                }); 
            }
        }
    },

    addComments: function() {

        TimesPeople.console.log("Trying to add for Comments");

        if (TimesPeople.Page.type=="article") {
        //  Comment Overflow page
            var metaPST    = $$("meta[name='PST']")[0];
            if (metaPST != undefined) {

                var contentPST = metaPST.getAttribute('content');
                if (contentPST=="Comments Overflow") {

                //  Article Comments
                    if ($('comment')) {
                        var submitButton  = $$('input[alt="submit"]')[0];
                        Event.observe(submitButton, 'click', function(event) {
                            var comment = $$('#comment textarea')[0].value;
                            new TimesPeople.Activity('commented', TimesPeople.Page.title, comment);
                        });
                    }

                //  Recommend an Article Comment
                    var allComments = $$('div.sequence');

                    if (allComments.length>0) {
                        $$('a[href="#"]').each(function(button){
                            if (button.innerHTML.toLowerCase()=="recommend") {
                                var divBody   = button.up('div.body');
                                var comment   = divBody.innerHTML.truncate(140).stripTags();
                                var commentNo = divBody.down('span.feedback').id;
                                var url       = location.href.split('?')[0]+"?permid="+commentNo+"&src=tp#comment"+commentNo;

                                Event.observe(button, 'click', function(event) {
                                    new TimesPeople.Activity('recommended', TimesPeople.Page.title, comment, url, '', 'comment');
                                });
                            }
                        });
                    }
                } else if (contentPST=="Blog Post") {
                //  Blog: Comments
                    if ($('submit-comment')) {
                        $('submit-comment').observe('click', function(e) {
                            new TimesPeople.Activity('commented', TimesPeople.Page.title, $('comment').value);
                        }, true);
                    }
                }
            }
        }

        if (TimesPeople.Page.type=="blog post") {
        //  Blog: Comments
            if ($('submit-comment')) {
                $('submit-comment').observe('click', function(e) {
                    new TimesPeople.Activity('commented', TimesPeople.Page.title, $('comment').value);
                }, true);
            }
        }

//  Check in Travel Topics and on Venues
        if (TimesPeople.Page.group=="topic" || TimesPeople.Page.group=="venue") {
        //  Comment: Travel Topic (aka suggestion)
            TimesPeople.console.log("Adding for " + TimesPeople.Page.group);

            if ($('shareSuggestions')) {
                var form = $$('#shareSuggestions form')[0];
                if (form) {
                    form.observe("submit",  function(e) {
                        if ($F('suggestion')){
                            new TimesPeople.Activity('reviewed', TimesPeople.Page.title, $('suggestion').value.stripTags().truncate(250));
                        }
                    }, true);
                }
            }
        }

//  Movie Reviews
        if (TimesPeople.Page.group=="community") {
            if ($('submitReviews')) {
                var movieForm = $$('#submitReviews form')[0];
                if (movieForm) {
                    movieForm.observe("submit",  function(e) {
                        var movTitle  = $('reviewtitle').value;
                        var movText   = $('suggestion').value;
                        new TimesPeople.Activity('reviewed', movTitle, movText);
                    }, true);
                } else {
                    TimesPeople.console.log("Movie Review: No form found");
                }
                return false;
            }
        }
    },

    addOthers:function() {
        // ndy
    }
};

TimesPeople.ActivityCollectionController.initialize();
// Fri Jun 26 18:15:31 EDT 2009
