			
			$(function() {
				var tip = 0;
				$('.tip').each(function() {
					var $this = $(this);
					var comments = parseInt($this.attr('comments'));
					var rating = parseInt($this.attr('rating'));
					var href = $('H2 A', $this).attr('href');
					var title = $('H2 A', $this).text();
					var tipid = parseInt($this.attr('tipid'));
					$this
						.addClass('color' + (tip++ % 3 + 1))
						.wrapInner('<DIV class="body"></DIV>')
						.prepend('<DIV class="meme"></DIV>')
						.prepend('<DIV class="header"></DIV>')
						.append('<DIV class="footer"></DIV>')
						.find('.header')
							.append('<DIV class="left"></DIV>')
						.end()
						.find('.footer')
							.append('<DIV class="left"></DIV>')
							.append('<DIV class="social"></DIV>')
							.append('<DIV class="rating"><a href="#" class="ratebutton hateit" title="I Hate This Tip"><img src="/images/spacer.gif" height="35" width="35" border="0"></a><a href="#" class="ratebutton loveit" title="I Love This Tip"><img src="/images/spacer.gif" height="35" width="33" border="0"></a><br><img src="/images/visor/icons/pr' + rating + '.png" height="8"><br> <span class="rateMessage">Rating</span> </DIV>')
							//.append('<DIV class="comments"><A href="' + href + '#comments">' + comments + '<br>Comments</A></DIV>')
							.append('<DIV class="comments"><A href="' + href + '#comments" class="commentbutton" title="Add/View Comments"><img src="/images/spacer.gif" height="35" width="35" border="0"></A></DIV>')
						.end()
						
						//.find('.meme')
						//	.html('<IFRAME src="http://api.tweetmeme.com/button.js?url=' + encodeURI(href) + '&style=normal&source=lifetips" height="61" width="50" frameborder="0" scrolling="no"></IFRAME>')
						//.end()
						
						//.find('.body H2')
						//	.wrapInner('<A href="' + href + '"></A>')
						//.end()
						
						.find('P:not(.byline):last')
							//.append(link_read_more ? ' <A href="' + href + '"><nobr>read more</nobr></A>' : '')
							.append(link_read_more ? ' <A href="' + href + '"><nobr>' + (typeof(link_read_more_text) == 'undefined' ? 'read more' : link_read_more_text) + '</nobr></A>' : '')
						.end()
						
						/*
						.find('.social')
							.append('<A href="#digg" class="digg"></A>')
							.append('<A href="#delicious" class="delicious"></A>')
							.append('<A href="#twitter" class="twitter"></A>')
							.append('<A href="#stumble" class="stumble"></A>')
							.append('<A href="#reddit" class="reddit"></A>')
							.append('<A href="#facebook" class="facebook"></A>')
						.end()
						*/
					;

					// ratings
					var rating = getCookie('t' + tipid);
					switch (rating) {
						case '-1':
							$this
								.find('.hateit')
									.addClass('hatedit')
								.end()
								.find('.ratebutton')
									.click(function() {
										return false;
									})
								.end()
								.find('.rateMessage').html('Rated');
								;
							break;
						case '1':
							$this
								.find('.loveit')
									.addClass('lovedit')
								.end()
								.find('.ratebutton')
									.click(function() {
										return false;
									})
								.end()
								.find('.rateMessage').html('Rated');
								;
							break;
						default:
							$this.find('.ratebutton')
								.click(function() {
									var $thisButton = $(this);
									var url = $thisButton.hasClass('hateit') ? '/images/visor/icons/hateit.asp' : '/images/visor/icons/loveit.asp';
									var val = $thisButton.hasClass('hateit') ? -1 : 1;
									if (null == getCookie('t' + tipid)) {
										setCookie('t' + tipid, val);
										$.ajax({
											type: 'GET',
											url: url,
											data: { tipId: tipid },
											dataType: 'html',
											success: function() {
												$this.find('.rateMessage').html('Rated');
												$thisButton.addClass(val == 1 ? 'lovedit' : 'hatedit');
											}
										});
									} else {
										$this.find('.rateMessage').html('Rated');
									}
									return false;
								})
							.end()
					}
					// social
					$this.find('.social .digg').click(function() {
						window.open("http://digg.com/submit?url=" + encodeURIComponent(href) + "&title=" + encodeURIComponent(title), 'socialdigg');
					});
					$this.find('.social .delicious').click(function() {
						window.open("http://del.icio.us/post?url=" + encodeURIComponent(href) + "&title=" + encodeURIComponent(title), 'socialdelicious');
					});
					$this.find('.social .twitter').click(function() {
						//alert(isgd(href));
						//return false;
						//window.open("http://digg.com/submit?url=" + encodeURIComponent(href) + "&title=" + encodeURIComponent(title), 'socialtwitter');
						$win = window.open("about:blank", 'socialtwitter');
						$.ajax({
							type: "GET",
							url: "http://api.bit.ly/shorten",
							data: {
								version: "2.0.1",
								login: "lifetips",
								apiKey: "R_e9502bc8d2c9c6fef12c1350048c53a2",
								format: "json",
								history: 0,
								longUrl: href
							},
							dataType: "jsonp",
							success: function(data){
								window.open("http://twitter.com/home?status=" + encodeURIComponent(data.results[href].shortUrl + " - " + title), 'socialtwitter', "", true);
							}
						});
						return false;
					});
					$this.find('.social .stumble').click(function() {
						window.open("http://www.stumbleupon.com/submit?url=" + encodeURIComponent(href) + "&title=" + encodeURIComponent(title), 'socialstumble');
					});
					$this.find('.social .reddit').click(function() {
						window.open("http://reddit.com/submit?url=" + encodeURIComponent(href) + "&title=" + encodeURIComponent(title), 'socialreddit');
					});
					$this.find('.social .facebook').click(function() {
						window.open("http://www.facebook.com/sharer.php?u=" + encodeURIComponent(href) + "&t=" + encodeURIComponent(title), 'socialfacebook');
					});
				});
				$('.firsttip .social').append('<g:plusone href="http://' + document.location.hostname + '/"></g:plusone>');
				(function() {
					var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
					po.src = 'https://apis.google.com/js/plusone.js';
					var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
				})();
			});
			
			$(function() {
				var theframes = document.getElementsByTagName('iframe');
				for(var i = 0; i < theframes.length; i++) {
					theframes[i].setAttribute("allowTransparency","true");
				}
			});

