var Pluck = function () {
	var _requestUrl = "";

	return {

		GetRecentBlogPosts: function (sPluckId, bDoNotHide) {
			sBlogKey = "Blog:" + sPluckId;
			rb = new RequestBatch();
			rb.AddToRequest(new BlogPostPage(new BlogKey(sBlogKey),3,0,'TimeStampDescending'));
			rb.BeginRequest(_requestUrl,function(data) {
				PostHTML = "";
				if (data.Responses.length > 0 && data.Responses[0].BlogPostPage.BlogPosts.length > 0) {
					BlogPostPage = data.Responses[0].BlogPostPage;

					for (i=0;i < BlogPostPage.BlogPosts.length;i++) {
						Post = BlogPostPage.BlogPosts[i];
						PostHTML += '<li class="first"><a href="' + Post.Url + '" class="title">' + Post.PostTitle + '</a><br/>' + '<p>' + Post.PostBody + '</p>' + '<span class="comment_date">' + Post.PostDate + '| <a href="' + Post.Url + '">' + Post.NumberOfComments + ' Comments</a></span>' + '</li>';
					}

					$('#pluck_blog').html(PostHTML);
				}
				else {
					if (!bDoNotHide) {
						$('#blog_box').hide();
					//	$('#tertiary_nav li:nth-child(3)').hide();
					}
				}

			});

		},

		GetUserPhotos: function (sPluckId, bDoNotHide) {
			rb = new RequestBatch();
			rb.AddToRequest(new RecentUserPhotoPage(new UserKey(sPluckId), 4, 1));
			rb.BeginRequest(_requestUrl, function(data) {
				PhotoHTML = "";
				Photos = data.Responses[0].RecentUserPhotoPage.Photos;
				for (i = 0; i < Photos.length; i++) {
					PhotoHTML += '<div class="ad flc">' +  '<a href="' + Photos[i].PhotoUrl + '"><img src="' + Photos[i].Image.Small + '" class="image" /></a>' + '<a href="' + Photos[i].PhotoUrl + '" class="title">' + Photos[i].Title + '</a>' + '</div>';
				}

				if (Photos.length > 0) {
					$('#recent_photos').html(PhotoHTML);
				}
				else {
					if (bDoNotHide == 0) {
						$('#photo_box').hide();
					//	$('#tertiary_nav li:nth-child(2)').hide();
						$('#photo_link').hide();
					}
				}
			});
		},

		RegisterUser: function (sPluckId) {
			rb = new RequestBatch();
			rb.AddToRequest(new UserKey(sPluckId));
			rb.BeginRequest(_requestUrl, function(data){});
		},

		BlogUrlStatus: function (sPluckId) {
			sBlogKey = "Blog:" + sPluckId;
			rb = new RequestBatch();
			rb.AddToRequest(new BlogPostPage(new BlogKey(sBlogKey),3,0,'TimeStampDescending'));
			rb.BeginRequest(_requestUrl, function(data) {
				if (data.Responses.length == 0 || data.Responses[0].BlogPostPage.BlogPosts.length == 0) {
				//	$('#tertiary_nav li:nth-child(3)').hide();
				}
			});
		},

		PhotoUrlStatus: function (sPluckId) {
			rb = new RequestBatch();
			rb.AddToRequest(new RecentUserPhotoPage(new UserKey(sPluckId), 3, 1));
			rb.BeginRequest(_requestUrl, function(data) {
				if (data.Responses[0].RecentUserPhotoPage.Photos.length == 0) {
				//	$('#tertiary_nav li:nth-child(2)').hide();
				}
			});
		},

		SetRequestUrl: function (sRequestUrl) {
			_requestUrl = sRequestUrl;
		}
	};

}();

