/**
This file is generated by a compression script.
Please DO NOT edit it directly or your changes may be lost.
See General Javascript Guidelines on the techwiki for more information.

Compressed by eshepher on Mon Sep 21 16:21:03 EDT 2009 
*/

/** START
  *    File: pluck/rating.js
  *    Last Updated: Mon Sep 21 16:17:36 2009
*/
function Rating(a,b){this.ratingDiv=document.getElementById(a);this.rating="";this.id=b;this.aAnchors=[];Rating.init=function(c){Rating.numberItems=c;};Rating.addSubmitListener=function(c){Rating.submitHandler=c;};Rating.prototype.initRating=function(){if(this.ratingDiv==null){return false;}var e=this.ratingDiv.childNodes;var d=0;for(var c=0;c<e.length;c++){if(e[c].nodeType==1){this.aAnchors.push(e[c].id);this.attachMouseEvents(e[c].id,d);d++;}}};Rating.prototype.setRating=function(d){this.rating=d;if(isNaN(this.rating)){this.rating=0;}if(this.rating>Rating.numberItems){this.rating=0;}for(var c=0;c<Rating.numberItems;c++){if(c+1<=d){jQuery("#"+this.aAnchors[c]).removeClass("inactive").addClass("active");}else{jQuery("#"+this.aAnchors[c]).removeClass("active").addClass("inactive");}}};Rating.prototype.fillRatings=function(d){for(var c=0;c<Rating.numberItems;c++){if(d>=c){jQuery("#"+this.aAnchors[c]).removeClass("inactive").removeClass("active").addClass("hover");}else{jQuery("#"+this.aAnchors[c]).removeClass("hover").removeClass("active").addClass("inactive");}}};Rating.prototype.resetRatings=function(){var d=this.rating-1;for(var c=0;c<Rating.numberItems;c++){if(d>=0&&c<=d){jQuery("#"+this.aAnchors[c]).removeClass("inactive").removeClass("hover").addClass("active");}else{jQuery("#"+this.aAnchors[c]).removeClass("active").removeClass("hover").addClass("inactive");}}};Rating.prototype.attachMouseEvents=function(e,d){var c=document.getElementById(e);var f=this;c.onclick=function(){Rating.submitHandler.submitRating(d+1,f.id,this);return false;};c.onmouseout=function(){f.resetRatings();};c.onmouseover=function(){f.fillRatings(d);};};}
/** END pluck/rating.js */

/** START
  *    File: pluck/cookies.js
  *    Last Updated: Mon Nov 12 14:28:14 2007
*/
function standardMagnetCookiesClass(){this.name="magnet";this.value="magnet";this.values=null;this.resetValues=true;this.duration=0.5;this.path="/";this.domain="";this.cookies=new Object();}var cookies=new standardMagnetCookiesClass();function setMagnetCookie(b,d,g,f,c){if(b==null){b=this.name;}if(d==null&&this.values!=null){d=this.values;}else{if(d==null){d=this.value;}}if(g==null){g=this.duration;}if(f==null){f=this.path;}if(c==null){c=this.domain;}var a=new Date((new Date()).getTime()+g*3600000);var e=b+"="+escape(d)+"; ";e+="expires="+a.toGMTString()+"; ";e+="path="+f+"; ";if(c!=null&&c!=""){e+="domain="+c+"; ";}else{if(this.domain!=null&&this.domain!=""){e+="domain="+this.domain+"; ";}}document.cookie=e;if(this.resetValues){this.values=null;}}standardMagnetCookiesClass.prototype.set=setMagnetCookie;function getMagnetCookie(b){if(b==null){b=this.name;}var f=0,a=0,d=0,c=document.cookie;var e=null;while(f<c.length){a=f+b.length;if(c.substring(f,a)==b){d=c.indexOf(";",a);if(d<0){d=c.length;}e=unescape(c.substring(a+1,d));}f=c.indexOf(" ",f)+1;if(f==0){break;}}return e;}standardMagnetCookiesClass.prototype.get=getMagnetCookie;function getMagnetCookiesHash(a){if(a==null){a=this.name;}var j=new Object();var c=0,h=0,g=0,b=document.cookie;var f=null;while(c<b.length){h=c+a.length;if(b.substring(c,h)==a){g=b.indexOf(";",h);if(g<0){g=b.length;}f=unescape(b.substring(h+1,g));}c=b.indexOf(" ",c)+1;if(c==0){break;}}if(f&&f.indexOf("|")>0){var e=f.split("|");var d=0;while(d<e.length){if(e[d]&&e[d+1]){j[e[d]]=e[d+1];}d=d+2;}}j[a]=f;return j;}standardMagnetCookiesClass.prototype.hash=getMagnetCookiesHash;function checkForMagnetCookieEligibility(a){if(a==null){a=this.name;}if(this.get(a)=="ineligible"){return false;}return true;}standardMagnetCookiesClass.prototype.eligibility=checkForMagnetCookieEligibility;function setMagnetCookiesHash(a){this.values=a;}standardMagnetCookiesClass.prototype.setValues=setMagnetCookiesHash;function setMagnetCookiesMinutes(a){this.duration=a/60;}standardMagnetCookiesClass.prototype.setMinutes=setMagnetCookiesMinutes;function setMagnetCookiesHours(a){this.duration=a;}standardMagnetCookiesClass.prototype.setHours=setMagnetCookiesHours;function setMagnetCookiesDays(a){this.duration=a*24;}standardMagnetCookiesClass.prototype.setDays=setMagnetCookiesDays;function setMagnetCookiesWeeks(a){this.duration=a*24*7;}standardMagnetCookiesClass.prototype.setMonths=setMagnetCookiesMonths;function setMagnetCookiesMonths(a){this.duration=a*24*30;}standardMagnetCookiesClass.prototype.setMonths=setMagnetCookiesMonths;function setMagnetCookiesYears(a){this.duration=a*24*365;}standardMagnetCookiesClass.prototype.setYears=setMagnetCookiesYears;function deleteMagnetCookie(a){if(a){this.name=a;}document.cookie=this.name+"=expired; expires=Fri, 02-Jan-1970 00:00:00 GMT; path=/;";}standardMagnetCookiesClass.prototype.expunge=deleteMagnetCookie;
/** END pluck/cookies.js */

/** START
  *    File: pluck/pluck.js
  *    Last Updated: Tue Jul 21 10:13:54 2009
*/
/**
 * Pluck handler. This file handles calls to Pluck. Callbacks are handed off to a this.callbackHandler object. 
 * Pass in a callback object. Expect that the following methods are implemented in the callback object:
 * setViewType
 * suppressPluck
 * renderReviewPage
 * updateAbuse
 * updateRecommendation
 * @version 2.0: This version assumes comments as the default. Reviews are supported, but need to be explicitly called. 
 */
//Check for MAGNET namespace
if (typeof MAGNET == "undefined") {
var MAGNET = {};
}
// Adds pluck to the magnet Namespace
MAGNET.pluck = MAGNET.pluck || {};



function Pluck(callbackHandler) {
// instance properties
// Allows you to override the callback object. By default it's the 
// PluckMarkupGenerator, but you can pass in other objects. 
if (typeof(callbackHandler) != "undefined") {
  this.callbackHandler = callbackHandler;
} else {
  this.callbackHandler = PluckMarkupGenerator;
}
this.callbackHandler.parentHandler=this;
this.serverUrl = ""; // Pluck server url. 
this.commentForm = new Object();
this.crLogicHelper = new Object();
this.crTitle = {};
this.programUrl = ""; // Used by the private comments. 
this.artId = "";
this.pluckBatchSize = 10; // Max number of requests pluck can handle. 
this.currentPage = 1;
this.numberPerPage = ""; 
this.currentRating = -1;
this.isLoggedIn = "";
this.loginUrl = "";
this.pluckActive = true;
this.requestBatch = "";
this.gatewayHandler = ""; // Object used for guest state. 


/**
 * Initializes the server and article id.  
 * @param {String} serverUrl URL of the Pluck server
 * @param {Number} numberPerPage Number of Pluck items to display per pages. 
 * @param {String} loginUrl URL user goes to when they need to log in.
 */
Pluck.prototype.init= function(serverUrl, numberPerPage, loginUrl) {
  // see if pluck is responding.
  try {
    this.requestBatch = new RequestBatch();
  } 
  catch (ex) {
    this.pluckActive = false;
  }
  
  this.numberPerPage = numberPerPage;
  this.loginUrl = loginUrl;
  this.isLoggedIn = this.LoggedIn();// was userLoggedIn;

  var domain = location.host.toString();
  var domainSplit = domain.split(".");
  domain = domainSplit[domainSplit.length-2] + "." + domainSplit[domainSplit.length-1];
  var removePort = domain.split(":");
  domain = removePort[0];
  document.domain=domain;
  this.serverUrl = serverUrl;
}

Pluck.prototype.LoggedIn = function () {
        var cookie_name="amg_user";
        var nameEQ = cookie_name + "=";
        var ca = document.cookie.split(';');
        for (var i=0; i<ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0)==' ') c = c.substring(1,c.length);
            if (c.indexOf(nameEQ) == 0) return true;
        }
        return false;
}

// Listener that will handle case when user is not logged in. 
Pluck.prototype.addGatewayListener = function(gatewayListener) {
  this.gatewayHandler = gatewayListener;
}

// Attach onsubmit to the comment form. 
// By default, we assume comments. Can be overridden by passing in a type. 
Pluck.prototype.initCommentForm = function(frmId, artId, frmDiv, type) {
  if (type === undefined) { type = "comment"; }
  if (document.getElementById(frmId)) {
  this.commentForm[artId] = document.getElementById(frmId);
  if (this.commentForm[artId] == null) { return false; }
   
  if (this.pluckActive) {
    var oThis = this;
	this.commentForm[artId].name = frmId;
    if (type == "comment") {
		this.commentForm[artId].onsubmit = function(){
			return oThis.submitComment(artId);
		}
	} else {
		this.commentForm[artId].onsubmit = function(){
			return oThis.submitReview(artId);
		}
		
	}

//Form gateway events
if(!this.isLoggedIn){
	//Get the form button
	oThis = this;
	oTarget = document.getElementById("frmPostBtn_" + artId);
	oTarget.disabled = "true";
	oTarget.onmousedown = function () {return oThis.gatewayHandler.loginHandler('comment', oTarget);}
  	//Get the form text
  	oTarget = document.getElementById("commentText_" + artId);
  	oTarget.onblur= function () {oTarget.value='';}
  	oTarget.onfocus= function () {oTarget.focus='off'; return oThis.gatewayHandler.loginHandler('comment', oTarget);}
  }
  } else {
    document.getElementById(frmDiv).style.display = "none";
  }
  }
}


// Make request for multiple articles from an array of ids. 
// Used on the list page. 
Pluck.prototype.doMultArticleRequest = function(aIds) {
	/*
  var useRatings = false;
  if (this.pluckActive) {
	   for (var j=0; j<aIds.length; j++) {
   			var multRequest = new RequestBatch();
  			if (this.crLogicHelper[aIds[j]].indexOf('R') != "-1") {
				useRatings = true;
    			var articleKey = new ArticleKey(aIds[j]);
    			multRequest.AddToRequest(articleKey);
       			multRequest.BeginRequest(this.serverUrl, this.callbackHandler.renderReviewPage);
       			multRequest = new RequestBatch();
                this.callbackHandler.initRatings(aIds[j], this.isLoggedIn);
			  } 
			if (this.crLogicHelper[aIds[j]].indexOf('V') != "-1") {
    			if (this.crLogicHelper[aIds[j]].indexOf('R') == "-1") {var articleKey = new ArticleKey(aIds[j]);}
    			var reviewPage = new ReviewPage(articleKey, this.numberPerPage, this.currentPage, "TimeStampDescending");
				multRequest.AddToRequest(reviewPage);
       			multRequest.BeginRequest(this.serverUrl, this.callbackHandler.renderReviewPage);
  			}
			if (this.crLogicHelper[aIds[j]].indexOf('C') != "-1") {
    			if (this.crLogicHelper[aIds[j]].indexOf('V') == "-1") {var articleKey = new ArticleKey(aIds[j]);}
    			var commentPage = new CommentPage(articleKey, this.numberPerPage, this.currentPage, "TimeStampDescending");
				multRequest.AddToRequest(commentPage);
       			multRequest.BeginRequest(this.serverUrl, this.callbackHandler.renderReviewPage);
  			}
			
			if (this.crLogicHelper[aIds[j]].indexOf('A') != "-1") {
			  var articleKey = new ArticleKey(aIds[j]);
    		  multRequest.AddToRequest(articleKey);
       		  multRequest.BeginRequest(this.serverUrl, this.callbackHandler.renderReviewPage);
       		  multRequest = new RequestBatch();
			}
		}
	
	
  } else {
   this.callbackHandler.suppressPluck(aIds);
  }
  */

}

// Make request for multiple articles from an id. 
// Used on the detail page. 
Pluck.prototype.doArticleRequest = function(aId) {
  // Store the article id for later use. 
  /*
  if (this.pluckActive) {
    this.requestBatch = new RequestBatch();
    if (this.crLogicHelper[aId].indexOf('R') != "-1") {
	  this.addToRequest(aId, "article");
      this.callbackHandler.initRatings(aId, this.isLoggedIn);
    }
    if (this.crLogicHelper[aId].indexOf('V') != "-1") {this.addToRequest(aId, "review");}
	if (this.crLogicHelper[aId].indexOf('C') != "-1") {this.addToRequest(aId, "comment");}
    if (this.crLogicHelper[aId].indexOf('A') != "-1") {this.addToRequest(aId, "article");}
   

	this.submitRequest(); 
  } else {
    this.callbackHandler.suppressPluck(aId);
  }
  */
}

//Requests a new batch of reviews
//Used on the list page
Pluck.prototype.updateMultReviews = function(aIds, type) {
  // Store the article id for later use. 

  if (this.pluckActive) {
    this.requestBatch = new RequestBatch();
	for (var j=0; j<aIds.length; j++) {
	this.artId = aids[j];
      this.addToRequest(aIds[j], "rewiew");
    }
    //this.submitRequest(); 
    var oThis = this;
    if (this.commentForm[aIds[j]] != null) {
	for (var j=0; j<aIds.length; j++) {

      this.commentForm[aids[j]].onsubmit = function () { return oThis.submitComment(aIds[j]); }
	}
    }
    this.callbackHandler.setViewType(type);
  } else {
    this.callbackHandler.suppressPluck(aIds);
  }
}
/**
 * Requests a new batch of reviews. 
 * Used on a detail type page. 
 * @param {String} aId
 * @param {String} type
 */
Pluck.prototype.updateReviews = function(aId, type) {
  // Store the article id for later use. 
  this.artId = aId;
  if (this.pluckActive) {
    this.requestBatch = new RequestBatch();
    //this.addToRequest(aId, "review");
    //this.submitRequest(); 
    var oThis = this;
    if (this.commentForm[aId] != null) {
      this.commentForm[aId].onsubmit = function () { return oThis.submitComment(aId); }
    }
    this.callbackHandler.setViewType(type);
  } else {
    this.callbackHandler.suppressPluck(aId);
  }
}

/**
 * Grabs the next x number of comments. 
 * @param {Object} target
 * @param {Object} aId
 */
Pluck.prototype.getNextPage = function(aId) {
   //this.currentPage++;
   //this.requestBatch = new RequestBatch();
   //this.doArticleRequest(aId);
}

/**
 * Grabs the previous x number of comments. 
 * @param {Object} aId
 */
Pluck.prototype.getPrevPage = function(aId) {
  //this.currentPage--;
  //if (this.currentPage < 1) { this.currentPage = 1; }
  //this.requestBatch = new RequestBatch();
  //this.doArticleRequest(aId);
    
}


// Adds either an article or review to the request batch. 
Pluck.prototype.addToRequest = function(aid, ftype) {
// create and submit a request for info
// articleKey will be the uniq identifier of the TIP that being 'reviewed' by the users.

  if (ftype == "article") {
    var articleKey = new ArticleKey(aid);
    //this.requestBatch.AddToRequest(articleKey);
  } else if (ftype == "review") {
    // articleKey will be the uniq identifier of the TIP that being 'reviewed' by the users.
    var articleKey = new ArticleKey(aid);
    // request the reviews that are associated with the TIP by using the articleKey, sort order if desired.
    var reviewPage = new ReviewPage(articleKey, this.numberPerPage, this.currentPage, "TimeStampDescending");
    //this.requestBatch.AddToRequest(reviewPage);
   } else if (ftype == "comment") {
  	var articleKey = new ArticleKey(aid);
	var commentPage = new CommentPage(articleKey, this.numberPerPage, this.currentPage, "TimeStampDescending");
    //this.requestBatch.AddToRequest(commentPage);
  }

}
// this call to the Pluck server returns the comments/reviews associated with an article (TIP)
Pluck.prototype.submitRequest = function() {
  this.requestBatch.BeginRequest(this.serverUrl, this.callbackHandler.renderReviewPage);
}

// Submits a rating. 
Pluck.prototype.submitRating = function(rating, artId, target) {
  if (this.isLoggedIn) {
    this.currentRating = rating;
    this.requestBatch = new RequestBatch();
    var articleKey = new ArticleKey(artId);
    var rateAction = new RateAction(articleKey, rating);
    //this.requestBatch.AddToRequest(rateAction);
    //this.requestBatch.AddToRequest(articleKey);
    //this.requestBatch.BeginRequest(this.serverUrl, this.callbackHandler.renderReviewPage);
  } else {
    this.loginHandler(target, "rating");
  }
}




// Bumps a user to the log in page.
Pluck.prototype.loginHandler = function(target, mId) {
  if (this.gatewayHandler != "") {
    this.gatewayHandler.loginHandler(mId, target);
  }
}

/**
/**
 * Submit a review. Reset the page number because we want to take the user back to the first comment. 
 * pass in the article id. 
 * By default title is document.title. 
 * @param {Object} artId
 * @param {Object} titleOverride
 */
Pluck.prototype.submitReview = function(artId, titleOverride) {
  var cmt=this.commentForm[artId]["commentText_" + artId].value;
  if (cmt == "" || cmt == null) {
    alert("You must enter comment text.");
    return false;
  }
 this.currentPage = 1;
  // get form elements and page info
  var articleKey = new ArticleKey(artId);
  var artIdString = artId + "";
  var pageUrl = "http://" + location.host.toString() + "/services/lookup/" + artIdString.substring(artIdString.indexOf('_')+1,artIdString.length); //was document.href
  var pageTitle = this.crTitle[artId] || document.title;

  var title = document.title;
  var body = cmt;
  var pros = "";  // intentionally left blank as we are not using them
  var cons = "";  // intentionally left blank as we are not using them
  var currentRating = 0;
  
  if (this.crLogicHelper[artId].indexOf('R') != "-1") {
  	currentRating = this.callbackHandler.articleRating;
  	if (this.currentRating != currentRating && this.currentRating != -1) {
  		currentRating = this.currentRating;
  	}
  }
  // create and send request
  this.requestBatch = new RequestBatch();
  var reviewAction = new ReviewAction(articleKey, pageUrl, pageTitle, title, currentRating, body, pros, cons);
  //this.requestBatch.AddToRequest(reviewAction);
  //this.addToRequest(artId, "review",this.requestBatch);
  //this.callbackHandler.setComment(reviewAction);
  //this.requestBatch.BeginRequest(this.serverUrl, this.callbackHandler.renderReviewPage);
  var cmt=this.commentForm[artId]["commentText_" + artId];
  cmt.value=""; 
  return false;
}

/**
 * Submit a Comment. Reset the page number because we want to take the user back to the first comment. 
 * pass in the article id. 
 * By default title is document.title. 
 * @param {Object} artId
 * @param {Object} titleOverride
 */
Pluck.prototype.submitComment = function(artId, titleOverride) {
  var cmt=this.commentForm[artId]["commentText_" + artId].value;
  if (cmt == "" || cmt == null) {
    alert("You must enter comment text.");
    return false;
  }

 this.currentPage = 1;
  // get form elements and page info
  var articleKey = new ArticleKey(artId);
  var artIdString = artId + "";
  var pageType = "article";
  try {
  pageType = this.commentForm[artId]["commentPageType_" + artId].value;
  } catch (e) {
  }
   
  if (pageType == 'blog'){
    var pageUrl = "http://" + location.host.toString() + location.pathname.toString(); //was document.href
  } else{
    var pageUrl = "http://" + location.host.toString() + "/services/lookup/" + artIdString.substring(artIdString.indexOf('_')+1,artIdString.length); //was document.href
  }
  var pageTitle;
  //incase form field is missing (backwards compatibiity)
  if(this.commentForm[artId]["commentPageTitle_" + artId]){
  pageTitle = this.commentForm[artId]["commentPageTitle_" + artId].value;
  }
  
  if (pageTitle == "" || pageTitle == null){
  	pageTitle= this.crTitle[artId] || document.title;
  }
  
  var pageSection = location.pathname.split('/')[1];
  var title = document.title;
  var body = cmt;
  
  // create and send request
  //this.requestBatch = new RequestBatch();
  var updateArticle = new UpdateArticleAction(articleKey, pageUrl, pageTitle, pageSection, pageType);
  //this.requestBatch.AddToRequest(updateArticle);
  var commentAction = new CommentAction(articleKey, pageUrl, pageTitle, body);
  //this.requestBatch.AddToRequest(commentAction);
  //this.addToRequest(artId, "comment",this.requestBatch);
  //this.callbackHandler.setComment(commentAction);
  //this.requestBatch.BeginRequest(this.serverUrl, this.callbackHandler.renderReviewPage);
  var cmt=this.commentForm[artId]["commentText_" + artId];
  cmt.value=""; 
  return false;
}
// This is the individuals reviews on the TIP.
// has the individuals rating on the TIP plus the comments entered for the tip.
Pluck.prototype.ReviewPageHandler = function(reviewPage) {
	this.callbackHandler.drawReview(reviewPage);
}

/**
 * Submits Pluck recommendations. 
 * @param {Object} contentKey
 * @param {Object} target
 * @param {String} type Optional param. Defaults to comments, but can override by passing
 * in different types. Will need to add code to create proper Pluck key. 
 */
Pluck.prototype.submitRecommendation = function(contentKey, target, type) {
  if (this.isLoggedIn) {
    var pluckKey;
	if (type === undefined || type === "") { type = "comment"; } // Default behavior. 
	if (type == "comment") {
      pluckKey = new CommentKey(contentKey);	  
	} else {
	  pluckKey = new ReviewKey(contentKey);
	}
    this.requestBatch = new RequestBatch();
	
    //this.requestBatch.AddToRequest(new RecommendAction(pluckKey));
    //this.callbackHandler.setLastRecommendation(contentKey);
    //this.requestBatch.BeginRequest(this.serverUrl,this.callbackHandler.updateRecommendation);
  } else {
    //this.loginHandler(target, "recommendation");
  }
  return false;
}


/**
 * User clicks report abuse. Need to pass in a reason and desc of abuse. 
 * @param {Object} contentKey
 * @param {Object} reason
 * @param {Object} desc
 * @param {String} type Optional param. Defaults to comments, but can override by passing
 * in different types. Will need to add code to create proper Pluck key. 
 */
Pluck.prototype.submitReportAbuse = function(contentKey, reason, desc, type) {
  if (type === undefined || type === "") { type = "comment"; } // Default behavior. 
	if (type == "comment") {
      pluckKey = new CommentKey(contentKey);	  
	} else {
	  pluckKey = new ReviewKey(contentKey);
  }
  this.requestBatch = new RequestBatch();
  //this.requestBatch.AddToRequest(new ReportAbuseAction(pluckKey, reason, desc));
  //this.requestBatch.BeginRequest(this.serverUrl, this.callbackHandler.updateAbuse);
  //return false;
}

}
        

                


/** END pluck/pluck.js */

/** START
  *    File: pluck/pluckMarkupGenerator.js
  *    Last Updated: Tue Aug 11 15:03:40 2009
*/
function PluckMarkupGenerator(){PluckMarkupGenerator.ratings="";PluckMarkupGenerator.currentView="";PluckMarkupGenerator.abuseThreshold=3;PluckMarkupGenerator.numberOfComments=0;PluckMarkupGenerator.userId="";PluckMarkupGenerator.parentHandler="";PluckMarkupGenerator.setViewType=function(type){PluckMarkupGenerator.currentView=type;};PluckMarkupGenerator.initRatings=function(aIds,loggedIn){PluckMarkupGenerator.isLoggedIn=loggedIn;PluckMarkupGenerator.articleRating=0;if(typeof aIds!="object"){var temp=aIds;aIds=new Array();aIds.push(temp);}PluckMarkupGenerator.aRatings=new Array();for(var j=0;j<aIds.length;j++){PluckMarkupGenerator.aRatings[aIds[j]]=new Rating("ratingGroup_"+aIds[j],aIds[j]);PluckMarkupGenerator.aRatings[aIds[j]].initRating();}};PluckMarkupGenerator.suppressPluck=function(aIds){if(typeof aIds!="object"){var temp=aIds;aIds=new Array();aIds.push(temp);}try{for(j=0;j<aIds.length;j++){document.getElementById("totalComments_"+aIds[j]).style.display="none";}}catch(e){}try{for(var j=0;j<aIds.length;j++){document.getElementById("rating_"+aIds[j]).style.display="none";}}catch(e){}};PluckMarkupGenerator.drawArticle=function(Article){var artKey=Article.ArticleKey.Key;if(PluckMarkupGenerator.parentHandler.crLogicHelper[artKey].indexOf("R")!="-1"){var rating=(Article.Ratings.AverageRating!=null?Math.round(Article.Ratings.AverageRating*10)/10:0);if(rating>=0){if(document.getElementById("ratingAverageTxtshort_"+artKey)){document.getElementById("ratingAverageTxtshort_"+artKey).innerHTML="<span>(Avg "+rating+")</span>";}if(document.getElementById("ratingAverageTxt_"+artKey)){document.getElementById("ratingAverageTxt_"+artKey).innerHTML="Average rating ";if(rating==1){rating=rating+' <span class="startxt">star</span>';}else{rating=rating+' <span class="startxt">stars</span>';}document.getElementById("ratingAverage_"+artKey).innerHTML=rating;}}PluckMarkupGenerator.articleRating=rating;if(Article.Ratings.CurrentUserRating!=null){PluckMarkupGenerator.articleRating=Article.Ratings.CurrentUserRating;PluckMarkupGenerator.aRatings[artKey].setRating(Article.Ratings.CurrentUserRating);}else{PluckMarkupGenerator.aRatings[artKey].setRating(rating);}}};PluckMarkupGenerator.drawComments=function(commentPage){PluckMarkupGenerator.aData=new Array();PluckMarkupGenerator.aLookup=new Array();PluckMarkupGenerator.numberOfComments=0;if(PluckMarkupGenerator.parentHandler.crLogicHelper[commentPage.ArticleKey.Key].indexOf("C")!="-1"){if(commentPage.NumberOfComments!=null&&document.getElementById("commentAnchor_"+commentPage.ArticleKey.Key)){var insertPoint=document.getElementById("commentAnchor_"+commentPage.ArticleKey.Key);insertPoint.innerHTML="";for(var i=0;i<commentPage.Comments.length;i++){var comment=commentPage.Comments[i];if(PluckMarkupGenerator.isUnderAbuseCount(comment)){PluckMarkupGenerator.aLookup[comment.CommentKey.Key]=i;PluckMarkupGenerator.aData[i]=comment;insertPoint.appendChild(PluckMarkupGenerator.getCommentDiv(comment,i,commentPage.ArticleKey.Key));PluckMarkupGenerator.numberOfComments++;}}insertPoint.appendChild(PluckMarkupGenerator.getAbuseDiv(commentPage.ArticleKey.Key));if(commentPage.NumberOfComments>(commentPage.NumberPerPage*commentPage.OnPage)){var imgLink=PluckMarkupGenerator.createButton("next_ten_"+commentPage.ArticleKey.Key,"/css/i/pluck/next_ten.gif",commentPage.ArticleKey.Key);imgLink.onclick=function(){return pluckHandler.getNextPage(commentPage.ArticleKey.Key);};imgLink.className="right";if(commentPage.OnPage>1){imgLink.className+=(imgLink.className==""?"":" ")+"moreLink";}insertPoint.appendChild(imgLink);}if(commentPage.OnPage>1){var imgLink=PluckMarkupGenerator.createButton("prev_ten_ "+commentPage.ArticleKey.Key,"/css/i/pluck/prev_ten.gif",commentPage.ArticleKey.Key);imgLink.onclick=function(){return pluckHandler.getPrevPage(commentPage.ArticleKey.Key);};imgLink.className="right";insertPoint.appendChild(imgLink);}}if(PluckMarkupGenerator.parentHandler.crLogicHelper[commentPage.ArticleKey.Key].indexOf("S")!="-1"){var strComments='<a href="#" onclick="return PluckMarkupGenerator.toggleComments(\'comments_'+commentPage.ArticleKey.Key+"')\">Comments <span>("+commentPage.NumberOfComments+")</span></a>";}else{var strComments="Comments <span>("+commentPage.NumberOfComments+")</span>";}if(document.getElementById("totalCommentsshort_"+commentPage.ArticleKey.Key)){document.getElementById("totalCommentsshort_"+commentPage.ArticleKey.Key).innerHTML=strComments;document.getElementById("totalCommentsshort_"+commentPage.ArticleKey.Key).style.display="";}if(document.getElementById("totalComments_"+commentPage.ArticleKey.Key)){var strComments="<span>"+commentPage.NumberOfComments+" comment"+(commentPage.NumberOfComments!="1"?"s":"")+'</span> <span class="sepr">|</span> <a href="#frmSubmitComment_'+commentPage.ArticleKey.Key+'">Add your comments</a>';document.getElementById("totalComments_"+commentPage.ArticleKey.Key).innerHTML=strComments;document.getElementById("totalComments_"+commentPage.ArticleKey.Key).style.display="";}}};PluckMarkupGenerator.toggleComments=function(cmtId,caller){jQuery("div#"+cmtId).slideToggle("fast");return false;};PluckMarkupGenerator.isUnderAbuseCount=function(comment){if(comment.Author.IsBlocked=="False"&&(parseInt(comment.AbuseReportCount)<PluckMarkupGenerator.abuseThreshold)){return true;}else{if(comment.Author.IsBlocked=="True"&&(comment.Author.UserKey.Key==PluckMarkupGenerator.userId)&&(parseInt(comment.AbuseReportCount)<PluckMarkupGenerator.abuseThreshold)){return true;}else{return false;}}};PluckMarkupGenerator.getCommentDiv=function(comment,index,artId){var commentRating="";if(comment.CommentRating>0){commentRating='<div class="commented">';for(var i=0;i<comment.CommentRating;i++){commentRating+='<img class="commentRating" src="/css/i/pluck/star_b.gif" alt="" />';}commentRating+="</div>";}var commentDiv=document.createElement("div");commentDiv.id="commentContainer_"+artId+"_"+index;commentDiv.className="entry";if(PluckMarkupGenerator.currentView=="privatecomments"){commentDiv.className+=" private";}var authorName="";if(typeof(comment.Author)!="undefined"){authorName=" "+comment.Author.DisplayName;}var contributorClass="";if(MAGNET.data.userInfo.userAccount.IsUserEditor(comment.Author.DisplayName)){contributorClass="cflag";}commentDiv.innerHTML='<dl><dd class="report">'+PluckMarkupGenerator.getAbuseHTML(comment,index,artId)+'</dd><dd class="body">'+comment.CommentBody+'</dd><dd class="dated">Posted '+PluckMarkupGenerator.formatTimeString(comment.PostedAtTime.toLowerCase())+' by <span class="author '+contributorClass+'">'+authorName+"</span></dd></dl>";return commentDiv;};PluckMarkupGenerator.formatTimeString=function(rt){var rtTok=rt.split(" ");return rtTok[0]+","+rtTok[1]+rtTok[2];};PluckMarkupGenerator.getAbuseDiv=function(artId){var abuseDiv=document.createElement("div");abuseDiv.id="abuseForm_"+artId;abuseDiv.className="aform";abuseDiv.style.display="none";abuseDiv.innerHTML='<form id="reportAbuseForm_'+artId+'"><input type="hidden" id="ReportAbuseKey_'+artId+'" value="" /><input type="hidden" id="ReportAbuseReason_'+artId+'" value="Report Abuse on Gourmet"/><div class="row"><a href="#" class="closebtn" onclick="return PluckMarkupGenerator.hideAbuseForm(\''+artId+'\')">X</a></div><div class="row"><label>Comment</label><span class="formw"><textarea id="ReportAbuseCommentText_'+artId+'" cols=16 rows=4></textarea></span></div><input type="image" src="/css/i/pluck/report_btn.gif" value="Report" onclick="return PluckMarkupGenerator.errCheckAbuseForm(document.getElementById(\'ReportAbuseKey_'+artId+"').value,document.getElementById('ReportAbuseReason_"+artId+"').value,document.getElementById('ReportAbuseCommentText_"+artId+"').value,'"+artId+'\')" value="Report" /></form>';return abuseDiv;};PluckMarkupGenerator.getAbuseHTML=function(comment,id,artId){var rKey=comment.CommentKey.Key;if(PluckMarkupGenerator.parentHandler.LoggedIn()){fCall="PluckMarkupGenerator.showAbuseForm('"+id+"','"+rKey+"','"+artId+"'); return false	";}else{fCall="PluckMarkupGenerator.parentHandler.gatewayHandler.loginHandler('abuse', document.getElementById('report_"+artId+"_"+id+"'));return false;";}var html='<span id="report_'+artId+"_"+id+'"><a class="reportlink" href="#" onclick="'+fCall+'">Report abuse</a></span>';return html;};PluckMarkupGenerator.getRecommendationHTML=function(comment,id){if(comment.CurrentUserHasRecommended=="False"){var html='<span id="commentRecommendation_'+id+'" class="commend">('+comment.NumberOfRecommendations+") ";html+='<a href="#" onclick="return pluckHandler.submitRecommendation(\''+comment.CommentKey.Key+"', this)\">recommend this comment</a></span>";}else{var html='<span id="commentRecommendation_'+id+'" class="commended">('+comment.NumberOfRecommendations+") ";html+="recommended</span>";}return html;};PluckMarkupGenerator.setLastRecommendation=function(commentKey){PluckMarkupGenerator.lastItem=commentKey;};PluckMarkupGenerator.updateRecommendation=function(responseBatch){if(responseBatch.Messages[0].Message=="ok"){var index=PluckMarkupGenerator.aLookup[PluckMarkupGenerator.lastItem];divId="commentRecommendation_"+index;var comment=PluckMarkupGenerator.aData[index];var updatedCount=parseInt(comment.NumberOfRecommendations)+1;var html="("+updatedCount+") recommended</span>";document.getElementById(divId).innerHTML=html;document.getElementById(divId).className="commended";}};PluckMarkupGenerator.setComment=function(comment){PluckMarkupGenerator.lastComment=comment;};PluckMarkupGenerator.showAbuseForm=function(id,key,artId){var cmd=eval("document.getElementById('reportAbuseForm_"+artId+"').ReportAbuseKey_"+artId);cmd.value=key;var newTop=document.getElementById("commentContainer_"+artId+"_"+id).offsetTop+document.getElementById("commentContainer_"+artId+"_"+id).offsetHeight+document.getElementById("abuseForm_"+artId).offsetHeight;document.getElementById("abuseForm_"+artId).style.top=newTop+"px";jQuery("div#abuseForm_"+artId).show("fast");return false;};PluckMarkupGenerator.hideAbuseForm=function(artId){jQuery("div#abuseForm_"+artId).hide("fast");jQuery("div#abuseForm_"+artId+" :input").val("");document.getElementById("ReportAbuseReason_"+artId).selectedIndex=0;return false;};PluckMarkupGenerator.errCheckAbuseForm=function(key,reason,desc,artId){pluckHandler.submitReportAbuse(key,reason,desc);PluckMarkupGenerator.hideAbuseForm(artId);return false;};PluckMarkupGenerator.drawNotes=function(){var numPerPage=10;var notes=PluckMarkupGenerator.aNotes;if(PluckMarkupGenerator.currentNotesPage<=0){PluckMarkupGenerator.currentNotesPage=1;}document.getElementById("totalComments").style.display="none";insertPoint=document.getElementById("commentAnchor");insertPoint.innerHTML="";var startPoint=numPerPage*(PluckMarkupGenerator.currentNotesPage-1);var stopPoint=(numPerPage*PluckMarkupGenerator.currentNotesPage)-1;if(stopPoint>=notes.length){stopPoint=notes.length-1;}for(var i=startPoint;i<=stopPoint;i++){var comment=new Object();comment.CommentBody=notes[i].note;var displayDate=new Date();displayDate.setTime(Date.parse(notes[i].creationDate));var time=PluckMarkupGenerator.formatTime(displayDate);comment.PostedAtTime=displayDate.getMonth()+1+"/"+displayDate.getDate()+"/"+displayDate.getFullYear()+" "+time;insertPoint.appendChild(PluckMarkupGenerator.getCommentDiv(comment,i));PluckMarkupGenerator.aData[i]=comment;}if(PluckMarkupGenerator.currentNotesPage>1){var imgLink=PluckMarkupGenerator.createButton("prev_ten","/css/tipsy/i/prev_ten.gif");imgLink.onclick=function(){PluckMarkupGenerator.currentNotesPage--;PluckMarkupGenerator.drawNotes();return false;};insertPoint.appendChild(imgLink);}if(PluckMarkupGenerator.aNotes.length>(numPerPage*PluckMarkupGenerator.currentNotesPage)){var imgLink=PluckMarkupGenerator.createButton("next_ten","/css/tipsy/i/next_ten.gif");imgLink.onclick=function(){PluckMarkupGenerator.currentNotesPage++;PluckMarkupGenerator.drawNotes();return false;};insertPoint.appendChild(imgLink);}};PluckMarkupGenerator.createButton=function(imgId,imgPath,aId){var imgLink=document.createElement("a");imgLink.href="#commentAnchor_"+aId;var img=document.createElement("img");img.id=imgId;img.className="pageButton";img.src=imgPath;imgLink.appendChild(img);return imgLink;};PluckMarkupGenerator.formatTime=function(timeObj){var hours=timeObj.getHours();var minutes=timeObj.getMinutes();var seconds=timeObj.getSeconds();var timeValue=""+((hours>12)?hours-12:hours);if(timeValue=="0"){timeValue=12;}timeValue+=((minutes<10)?":0":":")+minutes;timeValue+=((seconds<10)?":0":":")+seconds;timeValue+=(hours>=12)?"PM":"AM";return timeValue;};PluckMarkupGenerator.updateAbuse=function(responseBatch){if(responseBatch.Messages[0].Message=="ok"){}};PluckMarkupGenerator.renderReviewPage=function(responseBatch){for(var i=0;i<responseBatch.Responses.length;i++){var response=responseBatch.Responses[i];if(response.Article!=null&&PluckMarkupGenerator.parentHandler.crLogicHelper[response.Article.ArticleKey.Key].indexOf("R")!="-1"){PluckMarkupGenerator.drawArticle(response.Article);}else{if(response.CommentPage!=null&&PluckMarkupGenerator.parentHandler.crLogicHelper[response.CommentPage.ArticleKey.Key].indexOf("C")!="-1"){PluckMarkupGenerator.drawComments(response.CommentPage);}else{if(response.User!=null){PluckMarkupGenerator.userId=response.User.UserKey.Key;}}}}};}PluckMarkupGenerator.renderNotes=function(b){PluckMarkupGenerator.aNotes=b;PluckMarkupGenerator.currentNotesPage=1;if(b.length==1){var a=b.length+" comment";}else{var a=b.length+" comments";}document.getElementById("totalComments").innerHTML=a;PluckMarkupGenerator.drawNotes();};
/** END pluck/pluckMarkupGenerator.js */

/** START
  *    File: pluck/registeredGateway.js
  *    Last Updated: Wed Jan 9 15:43:48 2008
*/
function RegisteredGateway(b,d,c){var a=this;this.boxWidth="";this.aLoginMessages=new Array();this.aLoginMessages.log='<a href="'+b+'">Login</a> or <a href="'+d+'">register</a> to log this tip.';this.aLoginMessages.rating='<a href="'+b+'">Login</a> or <a href="'+d+'">register</a> to post your rating.';this.aLoginMessages.comment='<a href="'+b+'">Login</a> or <a href="'+d+'">register</a> to post your comment.';this.aLoginMessages.favorites='<a href="'+b+'">Login</a> or <a href="'+d+'">register</a> now to add this tip to your favorites.';this.aLoginMessages.recommendation='<a href="'+b+'">Login</a> or <a href="'+d+'">register</a> to recommend this tip.';this.aLoginMessages.abuse='<a href="'+b+'">Login</a> or <a href="'+d+'">register</a> to report this comment.';this.aLoginMessages["default"]='<a href="'+b+'">Login</a> or <a href="'+d+'">register</a> to use this program.';this.signinUrl=b;this.gatewayUrl=d;RegisteredGateway.prototype.init=function(){a.createRegisterDiv();jQuery("div.regblurb a.closebtn").click(function(e){jQuery("div.regblurb").hide("fast");return false;});};RegisteredGateway.prototype.createRegisterDiv=function(){var e=document.createElement("div");e.id="reglayer";e.className="regblurb";e.innerHTML='<dd><a href="#" class="closebtn">X</a> <p id="regtxt"></p></span></dd>';document.body.appendChild(e);this.boxWidth=e.offsetWidth;e.style.display="none";};RegisteredGateway.prototype.getGatewayUrl=function(){return this.gatewayUrl;};RegisteredGateway.prototype.setLoginText=function(e){if(document.getElementById("regtxt")==null){return false;}document.getElementById("regtxt").innerHTML=e;return true;};RegisteredGateway.prototype.loginHandler=function(f,j){var g=this.getY(j);var e=this.aLoginMessages[f];var h=this.setLoginText(e);if(!h){return false;}jQuery("div.regblurb").css("top",g[1]);var i=g[0];i+=this.boxWidth/2;jQuery("div.regblurb").css("left",i);jQuery("div.regblurb").show("fast");return false;};RegisteredGateway.prototype.getY=function(e){var f=curtop=0;if(e.offsetParent){f=e.offsetLeft;curtop=e.offsetTop;while(e=e.offsetParent){f+=e.offsetLeft;curtop+=e.offsetTop;}}return[f,curtop];};}
/** END pluck/registeredGateway.js */


