// JavaScript Document
$(document).ready(function(){
	$('#rightCol #icl_container_all ul:gt(9)').each(function(){
		if (this.className != "subscribeAll") $(this).hide();
	});
});
function blogClean() {
	this.goClean = function() {
			$('#recentPosts ul:gt(9)').each(function(){
				if (this.className != "subscribeAll") $(this).hide();
			});
			$('#recentPosts a').each(function(){
				if ($.trim($(this).text()) == $.trim($('#blogL_1 #icl_container .icl_title').text())) {
					$('#blogL_1 #icl_container .icl_more a')[0].href = this.href;
				}
				if ($.trim($(this).text()) == $.trim($('#blogL_2 #icl_container .icl_title').text())) {
					$('#blogL_2 #icl_container .icl_more a')[0].href = this.href;
				}
			});
			//add class of name to subtitle
			var titles = $("#blogL_1 #icl_container .icl_title, #blogL_2 #icl_container .icl_title");
			
			var subtitlesid1 = "#blogL_1 #icl_container .icl_subtitle";
			var subtitlesid2 = "#blogL_2 #icl_container .icl_subtitle";
			
			var subtitles = $(subtitlesid1+", "+subtitlesid2);
			
			$.each($("#blogL_1 #icl_container .icl_more a, #blogL_2 #icl_container .icl_more a"), function(x,obj) {
				var name = '';
				if (x == 0 & $(subtitlesid1+' a').length>0)
					name = $(subtitlesid1+' a')[x].innerHTML.split(" ")[0].toLowerCase();
				else {
					if (x == 1 & $(subtitlesid2+' a').length>0)
						name = $(subtitlesid2+' a')[0].innerHTML.split(" ")[0].toLowerCase();
					else
						name = subtitles[x].innerHTML.split(" ")[0].toLowerCase();
				}
				var li = document.createElement("li");
				li.className = "icl_image " + name;
				li.innerHTML = "&nbsp;";
				subtitles[x].parentNode.insertBefore(li, subtitles[x].parentNode.firstChild);
				subtitles[x].parentNode.className = "icl_"+name;
				var li = document.createElement("li");
				li.className = "icl_other";
				var content = '';
				//content = '<a class="Delicious" href="http://del.icio.us/post?url='+URLEncode(obj.href)+'&title='+obj.innerHTML+'" target="_delicious">Del.icio.us</a>';
				//content += '<a class="Digg" href="http://digg.com/submit?phase=2&url='+URLEncode(obj.href)+'&title='+obj.innerHTML+'" target="_digg">Digg</a>';
				//content += '<a class="Facebook" href="http://www.facebook.com/sharer.php?u='+URLEncode(obj.href)+'&t='+obj.innerHTML+'" target="_facebook">Facebook</a>';
				content += '<a href="http://www.addthis.com/bookmark.php?v=250&pub=xa-4a5289f47f7eb098" onmouseover="return addthis_open(this, \'\', \'[URL]\', \'[TITLE]\')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/static/btn/sm-share-en.gif" width="83" height="16" alt="Bookmark and Share" style="border:0"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a5289f47f7eb098"></script>';
				//content += '<a class="Technorati" href="http://technorati.com/cosmos/search.html?url='+URLEncode(obj.href)+'">Technorati</a>';
				li.innerHTML = content;
				subtitles[x].parentNode.appendChild(li);
			});

			var img = document.createElement("img");
			img.src = "/atf/cf/{C77FCA17-4996-4A6E-9EBD-49502EF9581F}/blank.gif";
			img.className = "imgblank";
			$(img).insertBefore($(".icl_title"));
			/* ADD HEADER IMAGE TO INTERIOR POSTS			
			//$(img).insertBefore($("#leftcol #blogL_2 .icl_title"));	
			if (!$('#listingPagination')[0]) {
				var subtitles = $(".NLsubtitle");
				$.each($(".NLtitle"), function(x,obj) {
					var name = subtitles[x].innerHTML.split(" ")[0].toLowerCase();
					var img = document.createElement("img");
					img.src = "/atf/cf/{C77FCA17-4996-4A6E-9EBD-49502EF9581F}/blank.gif";
					img.className = "imgblank NL"+name;
					$(img).insertBefore(obj);
				});
			}
			*/
			$('li.icl_summary:eq(0) p:last').each(function(index){
				$('.icl_title')[0].innerHTML = "<a href='"+$('.icl_more a')[0].href+"'>"+$('.icl_title')[0].innerHTML+"</a>";
				this.innerHTML += "&nbsp;"+$('.icl_more')[0].innerHTML;
				$('.icl_more:eq(0)').hide();
			});
			$('li.icl_summary:eq(1) p:last').each(function(index){
				$('.icl_title')[1].innerHTML = "<a href='"+$('.icl_more a')[1].href+"'>"+$('.icl_title')[1].innerHTML+"</a>";
				this.innerHTML += "&nbsp;"+$('.icl_more')[1].innerHTML;
				$('.icl_more:eq(1)').hide();
			});
		}

	this.addToBlogEntry = function() {
			if ($('#FormCommentingRating')[0]) {
				//add class of name to subtitle
				var loc = document.location.href;
				var title= $(".NLtitle")[0].innerHTML.replace(/\<br\>/g,"");
				var span = document.createElement("span");
				span.className = "item_social";
				var content = '';
				content += '<p><a href="http://www.addthis.com/bookmark.php?v=250&pub=xa-4a5289f47f7eb098" onmouseover="return addthis_open(this, \'\', \'[URL]\', \'[TITLE]\')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/static/btn/sm-share-en.gif" width="83" height="16" alt="Bookmark and Share" style="border:0"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a5289f47f7eb098"></script></p>';
				span.innerHTML = content;
				$(span).insertAfter($('#content table td p:last'));
			}
		}

	this.getCommentCount = function() {
			//add class of name to subtitle
			var titles = $("#blogL_1 #icl_container .icl_title a, #blogL_2 #icl_container .icl_title a");
			var subtitles = $("#blogL_1 #icl_container .icl_subtitle, #blogL_2 #icl_container .icl_subtitle");
			//get all titles from blog and open page to get comment count
			for (var x=0;x<titles.length;x++) {
				disqus_url="http://www.netwitsthinktank.com/"+trim(titles[x].innerHTML).replace(/ /g,"_");
				disqus_title=titles[x].innerHTML;

				/*$.get('http://www.kintera.org/site/apps/rss/getpage.aspx?url=http://disqus.com/forums/thinktank/thread.js'+URLEncode('?url='+disqus_url+'&title=x'),function(data){;
					var comblock = new RegExp('id="comment-',"g");
					if (comblock.test($(data).text())) {
						//if com-block found then split into array to get count of how many comments there are
						var comlength = $(data).text().split('id="comment-').length-1;
						if (comlength > 0) {
							var li = document.createElement("li");
							li.className = "comments";
							li.innerHTML = "<a href='"+titles[x].href+"' title='Comments Found'>"+comlength + " comments - (Click to join the discussion)</a>";
							subtitles[x].parentNode.appendChild(li);
						}
					}
				});*/
			}
		}
	
	this.setupRSSLink = function() {
			//add class of name to subtitle
			var feed = $(".rss");
			for (x=0;x<feed.length;x++) {
				//grab first title href and parse to get c and b vars
				var title1 = $('#'+feed[x].parentNode.id+' .icl_title a');
				if (title1.length > 0) {
					if (title1[0].href.match("content.aspx")) {
						var linker = '/site/apps/nl/rss.asp?';
					}
					if (title1[0].href.match("content2.aspx")) {
						var linker = '/site/apps/nl/rss2.asp?';
					}
					if (title1[0].href.match("content3.aspx")) {
						var linker = '/site/apps/nl/rss3.asp?';
					}
					var findid = title1[0].href.match(".aspx?");
					var bin = title1[0].href.substr(findid.index+6,title1[0].href.length);
					feed[x].url = ""+(linker + bin);
					feed[x].onclick = function() {
						document.location.href = this.url;
					}
				}
			}
		}
	
	this.addCommentInput = function() {
			var self = this;
			if ($('#pagination2')[0]) {
				var span = document.createElement("span");
				span.className = "com_additional";
				var content = '<h6 class="postcomment">Leave a comment</h6><p><input name="author" id="author" class="textarea" value="" size="28" tabindex="1" type="text">';
				content += '&nbsp;<label for="author">Name</label> (required)	</p>';
				content += '<p><input name="email" id="email" value="" size="28" tabindex="2" class="textarea" type="text">';
				content += '&nbsp;<label for="email">E-mail</label> (required)	</p>';
				content += '<p><input name="url" id="url" value="" size="28" tabindex="3" class="textarea" type="text">';
				content += '&nbsp;<label for="url"><acronym title="Uniform Resource Identifier">URI</acronym></label></p>';
				span.innerHTML = content;
				$('#pagination2').after(span);
				$('#PostingCommentsForm_TextBoxCommentPost')[0].tabIndex=4;
			}
			//override current comment button 
			if ($('#PostingCommentsForm_ButtonAddComment')[0]) {
				if ($('#PostingCommentsForm_HyperLinkLogin')[0]) $('#PostingCommentsForm_HyperLinkLogin')[0].style.display="none";
				$('#PostingCommentsForm_ButtonAddComment')[0].removeAttribute("disabled");
				$('#PostingCommentsForm_ButtonAddComment')[0].removeAttribute("onclick");
				$('#PostingCommentsForm_ButtonAddComment')[0].onclick = function() {
					$('#PostingCommentsForm_ButtonAddComment:eq(0)').attr("disabled","disabled");
					if ($('#author')[0].value == '') {
						alert("Please enter your name");
						$('#author')[0].focus();
						return false;
					}
					if ($('#email')[0].value == '') {
						alert("Please enter your email address");
						$('#email')[0].focus();
						return false;
					}
					var tbComments = $("#PostingCommentsForm_TextBoxCommentPost")[0];
					if (tbComments.value.length > 1000) {
						return confirm("Only the first 1000 characters will be displayed.");
					} else if (tbComments.value.length == 0) {
						alert("Please enter comments");
						return false;
					}
					
					//try logout
					$.get("/site/c.ifINKZOzFmG/b.4485459/k.96AD/Logout_Link/apps/kb/home/logout.asp",function() {
						
						var posturl = "/site/apps/kb/home/login.asp?signinreq=1";
						posturl += "&targetURL=http%3a%2f%2fwww.netwitsthinktank.com%2fsite%2fapps%2fnlnet%2fcontent3.aspx%3fc%3difINKZOzFmG%26b%3d4426447";
						posturl += "%26content_id%3d%257BA34A318B-4F9F-45EE-AAF5-B5506518FE25%257D%26notoc%3d1&c=ifINKZOzFmG&b=4426447";
						
						var targeturl = "/site/apps/nlnet/content3.aspx?c=ifINKZOzFmG&b=4426447&content_id={A34A318B-4F9F-45EE-AAF5-B5506518FE25}&notoc=1";
						//try logging in
						$.post(posturl, {LoginName:"tt-"+$('#email')[0].value, Password:"kintera", remember_me:"yes", targetURL:targeturl}, function(data) { 
							//if login fails
							if (data.indexOf("Invalid") > 0) {
								//post contact form with supplied last name and supporter id
								var objparams = "last_name="+$('#author')[0].value; 																	//add 1 to last name
								objparams    += "&LoginName=tt-"+$('#email')[0].value;
								objparams    += "&Password=kintera";
								objparams    += "&VerifyPassword=kintera";
								objparams    += "&Caller=/site/apps/ka/ct/contactus.asp?c=ifINKZOzFmG&b=4486235";  //change & to %26
								//create userid				
								$.post("http://www.netwitsthinktank.com/site/apps/ka/ct/contactadd.asp?c=ifINKZOzFmG&b=4486235", objparams, function(data) {
									//try logging in again
									$.post(posturl, {LoginName:"tt-"+$('#email')[0].value, Password:"kintera", remember_me:"yes", targetURL:targeturl}, function(data) { 
										//after creating user and password
										var geturl = "http://www.netwitsthinktank.com/site/apps/rss/getpage.aspx?url=http://www.kinteratools.com/util/emailComments.php?";
										var location = document.location.href;
										location = location.replace(/&/g,'__')
										var postparms = "caller="+location;
										postparms += "%26target=test";
										postparms += "%26comment="+tbComments.value;
										geturl += postparms;
										//send email
										$.get(geturl, function(data) {
											$('#DivContentCommenting').ajaxStop(function(){setTimeout(function(){self.addCommentInput()},1000)});
											__doPostBack("PostingCommentsForm$ButtonAddComment", "");
										});
									 });
								});
							} else {
								//if login succeeds
								var geturl = "http://www.netwitsthinktank.com/site/apps/rss/getpage.aspx?url=http://www.kinteratools.com/util/emailComments.php?";
								var location = document.location.href;
								location = location.replace(/&/g,'__')
								var postparms = "caller="+location;
								postparms += "%26target=test";
								postparms += "%26comment="+tbComments.value;
								geturl += postparms;
								$.get(geturl, function(data) {
									//setup comment section update tracking
									$('#DivContentCommenting').ajaxStop(function(){setTimeout(function(){self.addCommentInput()},1000)});
									__doPostBack("PostingCommentsForm$ButtonAddComment", "");
									//setTimeout(function() {$.get("http://www.kintera.org/site/c.ifINKZOzFmG/b.4485459/k.96AD/Logout_Link/apps/kb/home/logout.asp"); },5000); //delay logout
									//setTimeout(function() {self.addCommentInput()},1000);
								});
							}
							
						});
					});
					//return false;
					return false;
				};
			}
		}

	this.init = function() {
		var self = this;
		//clean up blog and add comment count
		if (document.location.href.indexOf("b.4425985") > 0) this.goClean();
		//add social links to individual blog entry
		//this.addToBlogEntry();
		//find subscribe links and add rss link
		this.getCommentCount();
		//find subscribe links and add rss link
		//this.setupRSSLink();
		//add addl input fields to comment
		//this.addCommentInput();
	}
	
	this.init();
}

//misc functions
function toggleAddImage2() {
	$('#contentform')[0].className = ($('#contentform')[0].className== "showImgForm" ) ? "hideImgForm" : "showImgForm";
}
	
function toggleSection(id) {
	$(id).style.display = ($(id).style.display == "none" ) ? "block" : "none";
	modular.saveOrder();
}
	
function showSection(url, href) {
	this.getSection = function(url,href) {
		$('#blogL_1_data')[0].innerHTML = "<img src='/atf/cf/{6D23CFF1-8D91-4B15-83BC-DA817771056D}/ajax-loader.gif' />";
		//get data
		var obj = new AjaxRequest();
		obj.rss = url;
		obj.count = url;
		obj.dataonly=true;
		obj.Async = false;
		obj.init();
		
		this.checkStatus(url);
	}
	
	this.checkStatus = function(url) {
		var self = this;
		if (statusobj[url] == "running") {
			setTimeout(function(){self.checkStatus(url)}, 200); /* check status every 2 seconds */
		} else {
			if (href.innerHTML == "All") 
				$('#blogL_1_data')[0].innerHTML = xhrsobj[url];
			else
				$('#blogL_1_data')[0].innerHTML = "<h1>" + href.innerHTML + "</h1>" + xhrsobj[url];
	
			var blogx = new blogClean();
		}
	}
	
	this.getSection(url, href);
}
	
function displayAddImage(url, name) {
	//check login
	if (getLoginStatus()) {
		var dt_datetime = new Date();
		var rndTime = new String (dt_datetime.getHours()+dt_datetime.getMinutes()+dt_datetime.getSeconds());
		properties = "toolbar=0,location=0,menubar=0,scrollbars=1,resizable=0,height=350,width=370";
		//# causes page popup errors if found
		while (url.indexOf( "#" ) != -1) {
			url = url.replace("#", "%23" );
		}
		addimageHandle = open(url, name+rndTime, properties);
	} else {
		$('#login').slideDown('slow');
	}
}

function loginCheck(params) {
		this.performLogin = function() {
			$('#btnLogin')[0].disabled=true;
			$('#btnstat')[0].innerHTML = "<img src='/atf/cf/{C77FCA17-4996-4A6E-9EBD-49502EF9581F}/loading.gif' />";
			var postparms = "i="+$("#lid")[0].value;
			postparms += "%26p="+$("#pswd")[0].value;
			var obj = new AjaxRequest();
			obj.rss = "http://www.netwitsthinktank.com/site/apps/rss/getpage.aspx?url=http://www.kinteratools.com/checklogin.php?"+postparms;
			obj.count = 0;
			obj.dataonly=true;
			//obj.Params = "calledfrom=kintera";
			obj.init();
			
			this.checkStatus();
		}
		
		this.checkStatus = function() {
			var self = this;
			if (statusobj[0] == "running") {
				setTimeout(function() {self.checkStatus()},200);
			} else {
				if (xhrs[0] == 'Successful') {
					//good login - store cookie
					var cookie_data = 'login'+dateKey(new Date());
					var expdate = new Date();
					expdate.setDate(expdate.getDate()+365);
					Set_Cookie("loginstatus", cookie_data, expdate, '/');
					//store login id
					var cookie_data = $('#lid')[0].value;
					Set_Cookie("loginid", cookie_data, expdate, '/');
					window.location.reload(true); //force refresh
					//this.writeLogin();
				} else {
					//alert error message
					alert(xhrs[0]);
					$('#btnLogin')[0].disabled=false;
					$('#lid')[0].focus();
				}
			}
		}
		
		this.logOut = function() {
			Delete_Cookie("loginstatus", "/");
			Delete_Cookie("loginid", "/");
			window.location.reload(true); //force refresh
		}
		
		this.loginStatus = function() {
			var self = this;
			if (Get_Cookie("loginstatus") != 'null') {
				if ( Get_Cookie("loginstatus") == ("login"+dateKey(new Date())) ) {
					this.writeLogin();
				}
			}
		}

		this.writeLogin = function() {
			var self = this;
			$('#loginstatus')[0].innerHTML = '';
			//write login status
				var span = document.createElement("span");
				span.innerHTML = "Logged In as: "+Get_Cookie("loginid")+"&nbsp;&nbsp;&nbsp;";
			$('#loginstatus')[0].appendChild(span);
				var span = document.createElement("a");
				span.innerHTML = "Logout";
				span.href = "javascript:void(0)";
				span.onclick = function() {
					self.logOut();
				}
			$('#loginstatus')[0].appendChild(span);
			//change upper nav link
			$('#loginlink')[0].innerHTML = '';
				var href = document.createElement("a");
				href.innerHTML = "Logout";
				href.href = "javascript:void(0)";
				href.onclick = function() {
					self.logOut();
				}
			$('#loginlink')[0].appendChild(href);
		}
		
		this.init = function(params) {
			switch (params) {
				case "check" : this.loginStatus();break;
				default : this.performLogin();
			}
		}
		
		this.init(params);
}

function getLoginStatus() {
	var self = this;
	if (Get_Cookie("loginstatus") != 'null') {
		if ( Get_Cookie("loginstatus") == ("login"+dateKey(new Date())) ) {
			return true;
		} else {
			return false;
		}
	}
}


function addOptionalData() {
	if (!$('#listingPagination')[0]) {
		//get comment count
		if ($('.NLtitle')[0]) {
			$.event.add(window,'load',function(){getCountComments()});

			//var tweethtml = '<div id="tweetmeme_button" style="float: right; margin-right: 10px;"></div>';
			//$('.NLsummary p:eq(0)').prepend(tweethtml);
			var title= $(".NLtitle")[0].innerHTML.replace(/\<br\>/g,"");
			
			title= title.replace(/\<BR\>/g,"");
			var dtitle = title + " - " + (document.title.split("-")[1]);
		    dtitle = dtitle.replace(/&amp;/g,'&');
			dtitle = dtitle.replace(/&lt;/g,'<');
			dtitle = dtitle.replace(/&gt;/g,'>'); 			
			document.title = dtitle;
			disqus_url="http://www.netwitsthinktank.com/"+trim(title).replace(/ /g,"_");
			disqus_title=title;
			var endhtml = '<p class="call_to_sub">If you enjoyed this post, please consider <a href="'+document.location.href+'#comments">leaving a comment</a> and <a href="http://feeds2.feedburner.com/kintera/thinktank/blogposts">subscribing to the RSS feed</a> to have future articles delivered to your feed reader. You can also click here to <a href="http://feedburner.google.com/fb/a/mailverify?uri=kintera/thinktank/blogposts&loc=en_US">Get Email Updates</a>.</p>';
			$('#recentPosts p:last').append(endhtml);
			$('.NLsummary p:eq(0)').prepend('<p style="float:right;text-align:right"><span style="padding-right:0px"><iframe src="http://api.tweetmeme.com/widget.js?url='+escape(document.location.href)+'&amp;style=compact" width="83" frameborder="0" height="22" scrolling="no"></iframe></span><br /><a href="http://www.addthis.com/bookmark.php?v=250&pub=xa-4a5289f47f7eb098" onmouseover="return addthis_open(this, \'\', \'[URL]\', \''+title+'\')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="http://s7.addthis.com/static/btn/sm-share-en.gif" width="83" height="16" alt="Bookmark and Share" style="border:0"/></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a5289f47f7eb098"></script></p>');
			//add rating option
			var OutbrainPermaLink=disqus_url;
			var OB_demoMode = false;
			var OB_langJS ='http://widgets.outbrain.com/lang_en.js';
			if ( typeof(OB_Script)!='undefined' )
				OutbrainStart();
			else {
				var OB_Script = true;
				var str = '<script type="text/javascript" src="http://widgets.outbrain.com/OutbrainRater.js"><\/script>';
				document.write(str);
			}
			//add commenting
			document.write('<scr'+'ipt type="text/javascript" src="http://disqus.com/forums/thinktank/embed.js"></scr'+'ipt>'); 
		}
	}
}

function getCountComments() {
		
			var div = document.createElement("div");
			div.id="dsc_count";
			$(div).insertBefore($(".NLtitle"));
	
			var comblock = new RegExp('id="comment-',"g");
			if (comblock.test($('#contentData')[0].innerHTML)) {
				//if com-block found then split into array to get count of how many comments there are
				var comlength = $('#contentData')[0].innerHTML.split('id="comment-').length-1;
				if (comlength > 0) {
					$('#dsc_count')[0].innerHTML = "<a href='#comments' class='commentcount' title='Jump to Comments'>"+comlength+"</a>";
					var span = document.createElement("span");
					span.innerHTML = "<a name='comments'></a>";
					$(span).insertAfter($('#contentData table'));
				}
			} else {
				$('#dsc_count')[0].innerHTML = "<a href='#comments' class='commentcount'>0</a>";
				var span = document.createElement("span");
				span.innerHTML = "<a name='comments'></a>";
				$(span).insertAfter($('#contentData table'));
			}
			
}

function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}

var decHTML = function() { 
  return this.each(function(){ 
    var me   = jQuery(this); 
    var html = me.html(); 
    me.html(html.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>')); 
  }); 
};

function doSearch(twitsrch) {
	$('#twitter').html('<img src="/atf/cf/{C77FCA17-4996-4A6E-9EBD-49502EF9581F}/loading.gif" alt="Loading Feed" />');
	
	$.getJSON("http://search.twitter.com/search.json?rpp=10&q="+twitsrch+"&callback=?",function(data) {
		//console.log(data);
		$('#twitter').html('');
		for (x=0;x<data.results.length;x++) {
			var twit = '<div style="top: 0px; left: 0px; height: 72px; width: 430px;position:relative;font-size:12px"><a href="http://twitter.com/'+data.results[x].from_user+'" target="_blank"><img src="'+data.results[x].profile_image_url+'" alt="'+data.results[x].from_user+'" style="border: 0px none ; position: absolute; top: 5px; left: 9px; height: 48px; width: 48px;"></a><div style="padding: 5px; position: absolute; top: 5px; left: 65px; height: 54px; width: 420px;">';
			twit += '<a href="http://twitter.com/'+data.results[x].from_user+'" target="_blank">'+data.results[x].from_user+'</a>: '+data.results[x].text+'<br>'+data.results[x].created_at+' · <a href="http://twitter.com/home?status=@'+data.results[x].from_user+'" target="_blank">Reply</a> · <a href="http://twitter.com/'+data.results[x].from_user+'/statuses/'+data.results[x].id+'" target="_blank">View Tweet</a>';
			twit += '</div></div>';
			$('#twitter').append(twit);
		}
        $('#twitter').append($("<div><a href='http://search.twitter.com/search?q="+twitsrch+"'>more...</a></div>"));
	});
}