function temporarilyNoLink() {
	alert("Sorry - New feature coming October 2011 - check back later!");
}

$(document).ready(function() {

	// Calibrate the Blogger paragraph
	
	$(".workContainer").hover( function() {
		$(this).addClass("workContainerHover");
	},
	function() {
		$(this).removeClass("workContainerHover");
	});
	
	$(".workContainer").click( function() {
		var whichWork = $(this).attr("rel");
		if (whichWork != "") {
			window.location = ""+whichWork+".php";
		}
	});

	$(".moreWorksButton").click( function() {
		temporarilyNoLink();
	});

	
	// TWITTER	
	$("#twitter").tweet({
		username: "theladdschool",
		join_text: "auto",
		avatar_size: 32,
		count: 4,
		//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..."
	});		
});

// BLOGGER	
function showrecentposts(json) {
  // start a loop
  // in this loop we get the entry from the feed and parse it
  for (var i = 0; i < numposts; i++) {
    // get entry i from feed
    var entry = json.feed.entry[i];
    // get the posttitle
    var posttitle = entry.title.$t;
    // get the post url
    // check all links for the link with rel = alternate
    var posturl;
    if (i == json.feed.entry.length) break;
    for (var k = 0; k < entry.link.length; k++) {
      if (entry.link[k].rel == 'alternate') {
        posturl = entry.link[k].href;
        break;
      }
    }
    // get the postdate, take only the first 10 characters
    var postdate = entry.published.$t.substring(0,10);
    // get the post author
    var postauthor = entry.author[0].name.$t;
    // get the postcontent
    // if the Blogger-feed is set to FULL, then the content is in the content-field
    // if the Blogger-feed is set to SHORT, then the content is in the summary-field
    if ("content" in entry) {
      var postcontent = entry.content.$t;}
    else
    if ("summary" in entry) {
      var postcontent = entry.summary.$t;}
    else var postcontent = "";
    // strip off all html-tags
    
	var re = /<(?!img)[^>]+>/g;
	var reTwo = "»";
	var reThree = "Read more";
	var reFour = "&raquo;";
    postcontent = postcontent.replace(re, " ");
	postcontent = postcontent.replace(reTwo, "");
	postcontent = postcontent.replace(reThree, "");
	postcontent = postcontent.replace(reFour, "");
    // reduce postcontent to numchar characters
    if (postcontent.length > numchars) postcontent = postcontent.substring(0,numchars);
    // display the results
	document.write('<div class="postContainer">')
	document.write('<div class="postTitle">')
	if (i == 0) {
		document.write('<img src="images/bloggerIcon.png" class="bloggerIcon" />')
	}
	else {
	}	
	document.write('<a class="fogartyOrange" href="'+posturl+'" title="http://theladdschool.blogspot.com/" alt="http://theladdschool.blogspot.com/" target="_blank">'+ posttitle + '</a></div>')
	document.write('<div class="postdate grassGreen">Posted '+postdate+'</div>')
	document.write('<div class="postContent">'+ postcontent + ' <span class="readMoreContainer"><a href="'+posturl+'" class="readMore">read more</a> <span class="ivory">&raquo;</span></span></div>')	
	// END POST CONTAINER
	document.write('</div>')
	if (i != 2) {
		document.write('<hr />')
	}
	else {
	}
  }
}


