$(document).ready(function()
{
	$(".media-block-item.active .images").cycle('fade');
	twitter();
});


function twitterSearch(obj) 
{
    var tDiv = document.getElementById("tweets");	
    var user, bgcolor, tweet, postedAt, icon, userURL;	

    tDiv.innerHTML = "<ul>"	
    for (i=0;i<obj.results.length;i++) {	

      	if(i % 2) {
        	style="odd"
        } else {
       		style="even"	
        }

        user = obj.results[i].from_user;
        userURL = "http://twitter.com/"+user;
		userImg	= obj.results[i].profile_image_url;
        tweet = obj.results[i].text;
        postedAt = obj.results[i].created_at;
	    //and here I mash it all up into a fancy li
   		tDiv.innerHTML +="<li class='"+style+"'><a href='"+userURL+"'><div class='twitteruser'><img src='"+userImg+"' width=\"48\" height=\"48\"></a></div><strong><a href='"+userURL+"'>"+user+"</a></strong> "+tweet+" <span class='time'>("+postedAt+" GMT)</span> </li><div style=\"clear:both\"></div>";
	}	

    tDiv.innerHTML += "</ul>";
}
function twitterSearchDblColumn(obj) {	
	var countit = 0;
    //this is the div I'm writing the content to	
    var tDiv_left = document.getElementById("tweets-left");
	var tDiv_right = document.getElementById("tweets-right");
    var user, bgcolor, tweet, postedAt, icon, userURL;	
    //start the ul	
    tDiv_left.innerHTML = "<ul>";
	tDiv_right.innerHTML = "<ul>";	
    for (i=0;i<obj.results.length;i++) {	
		if(countit < 10)
		{
			user = obj.results[i].from_user;
			userURL = "http://twitter.com/"+user;
			userImg	= obj.results[i].profile_image_url;
			tweet = obj.results[i].text;
			postedAt = obj.results[i].created_at;

			if(i % 2) {
				tDiv_left.innerHTML +="<li><a href='"+userURL+"'><div class='twitteruser'><img src='"+userImg+"' width=\"48\" height=\"48\"></a></div><strong><a href='"+userURL+"'>"+user+"</a></strong> "+tweet+" <span class='time'>("+postedAt+" GMT)</span> </li><div style=\"clear:both\"></div>";
			} else {
				tDiv_right.innerHTML +="<li><a href='"+userURL+"'><div class='twitteruser'><img src='"+userImg+"' width=\"48\" height=\"48\"></a></div><strong><a href='"+userURL+"'>"+user+"</a></strong> "+tweet+" <span class='time'>("+postedAt+" GMT)</span> </li><div style=\"clear:both\"></div>";
			}
		}

		countit++;
	}	
    //and close the UL
    tDiv_left.innerHTML += "</ul>";
	tDiv_right.innerHTML += "</ul>";
}
//this is basically the same function I was using before
//with the changed search URL
function twitter() { 
    var twitterJSON = document.createElement("script"); 
    twitterJSON.type="text/javascript" 
    //here's the search URL
    twitterJSON.src="http://search.twitter.com/search.json?callback=twitterSearch&q=%23mars"
    document.getElementsByTagName("head")[0].appendChild(twitterJSON);
    return false;
}

