$(document).ready(function() {
			
			$("#visible").val("#homeDetails");
							   });
	      $(
          function()
          {
              setInterval("getSearch()",10000);
          getSearch();         
          }
      );
    TwitterCache = {};
  function getSearch()
  {
 
            var url = "http://search.twitter.com/search.json?callback=?&rpp=10&q=%23lwtweet"; // Change %22in+love%22 to your search. %22 is a qoute
            $.getJSON
            (
                url,
            function(data)
            {
				if(!Array.prototype.indexOf) {
   					 Array.prototype.indexOf = function(needle) {
      			     for(var i = 0; i < this.length; i++) {
           				 if(this[i] === needle) {
              		   return i;
            }
        }
        return -1;
    };
}
				var accounts = new Array("dallred","gallred1","vickid0", "heathdutton", "jenny0805", "ssshharvranek", "lfhicks", "qwertycamille", "creativemerritt", "mcinthehouse", "onelikeson", "creding", "brittney-o", "chargravescott", "bshoults", "mindfieldz" );
                if( data.results ) // Checks to see if you have any new tweets
                {
					
                    var i = -1, result, HTML='', HTML2='';
                    while( (result = data.results[++i]) && !TwitterCache[result.id] && i < 4 )
                    {
						var user = result.from_user.toLowerCase();
						var user = result.from_user.toLowerCase();
						for(var id in accounts){
						
							if (user == accounts[id])
							{
								verrified = true;
								break;
								}else{
								verrified = false;
							}
						}
						if(verrified){
                        TwitterCache[result.id] = result.from_user;
                        HTML += '<div class="tweet"><p>' + FormatIt(result.text) + '</p><p class="tweetInfo">by <a href="http://www.twitter.com/' + result.from_user + '" title="Go to profile"><strong class="User">@'+ result.from_user + '</strong> </a>' + relative_time(result.created_at) + ' <!--via ' + linkup(result.source) + '--></p></div>';
                       }
                    
					}
                    if( HTML !== '' )
                        $("#tweets").prepend( HTML ).find('div:hidden').slideToggle('slow');
 
                }
            }
        )   
  }
  
  
 function FormatIt(text_results)  // Formats the text. Makes In Love become bold
    {
      
        return text_results.linkify();
    }

    function linkup(link) // Makes the links linkable
    {
        link = link.replace('&lt;a href=&quot;','<a href="');
        link = link.replace('&quot;&gt;','">');
        link = link.replace('&lt;/a&gt;','</a>');
        return link;
    }

      String.prototype.linkify = function() {  //Also makes links linkable
            return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/~.=]+/g,
            function(m) {
        return m.link(m);
      });
    };



  function relative_time(time_value) { //Makes the time thing happen
        var values = time_value.split(" ");
        time_value = values[2] + " " + values[1] + ", " + values[3] + " " + values[4];
        var parsed_date = Date.parse(time_value);
        var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
        var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
        delta = delta + (relative_to.getTimezoneOffset() * 60);
       
        var r = '';
        if (delta < 60) {
          r = 'a minute ago';
        } else if(delta < 120) {
          r = 'couple of minutes ago';
        } else if(delta < (45*60)) {
          r = (parseInt(delta / 60)).toString() + ' minutes ago';
        } else if(delta < (90*60)) {
          r = 'an hour ago';
        } else if(delta < (24*60*60)) {
          r = '' + (parseInt(delta / 3600)).toString() + ' hours ago';
        } else if(delta < (48*60*60)) {
          r = '1 day ago';
        } else {
          r = (parseInt(delta / 86400)).toString() + ' days ago';
        }
       
        return r;
}
function twitter_callback ()
{
      return true;
}