
    jQuery(document).ready(function($){
      $(".entry .tweet").each(function(){
        $(this).tweet({
            username: $(this).attr("id"),
            join_text: "auto",
            avatar_size: 32,
            count: 3,
            auto_join_text_default: "we said,",
            auto_join_text_ed: "we",
            auto_join_text_ing: "we were",
            auto_join_text_reply: "we replied to",
            auto_join_text_url: "we were checking out",
            loading_text: "loading tweets..."
        });
    });
	$.ajax({
	    url : "/wp/twitter.php",
	    dataType : "jsonp",
	    data : {
//	        q : "#farmersmarketjp",
//			rpp : "1"
	    },
	    jsonp : "callback",
	    success : function(json){
			var twhtml = '';
			if(json.results.length == undefined || json.results.length <= 0) {
//				$('#twitter').css("display", "none");
			} else {
			for(var i = 0; i < json.results.length; i++) {
				var viewtxt = fmscript.txtcut(json.results[i].text, 75, '...');
				twhtml += '<a href="http://twitter.com/' +  json.results[i].user.screen_name +'/status/'+ json.results[i].id  + '" target="_blank">' + viewtxt   + '</a>';
			}
			twhtml += "</ul>";
			$('#hdtwit').html(twhtml);
			}

	    },
	    error : function(){
	//        alert('error');
	    }
	});



   });




function addLinks() {
	$(".linkbox").hover(function(){
		$(this).addClass("box_hover");	
		},
		function(){
		$(this).removeClass("box_hover");	
	});
	$(".linkbox").click(function() {
		var links  = $(this).find("h2 a").attr("href");
		if(links == undefined || links == "") {
			links = $(this).find("h3 a").attr("href");
			if(links == undefined || links == "") {
			} else {
				window.location=links;
			}
		} else {
	    	window.location=links;
		}
		return false;
	});

}

var fmscript = {
	txtcut:function(text, len, truncation) {
		var count = 0;
		var str = '';
		for (i=0; i<text.length; i++) {
		n = escape(text.charAt(i));
		if (n.length < 4) count++; else count+=2;
		if (count>len) {return str+truncation;}
		str += text.charAt(i);
		}
		return text;
	}
}
