/*
================================================================================================================================================
Title:				Javascript - 	General			
File:					general.js
JS version:		1.0
Author:				Roman Leinwather
E-mail:				r.leinwather@thrusites.com
Website:			Cozy Tweetup
URI:				  http://cozytweetup.com
Copyright:		Copyright (c) 2009 Thrudigitala
==============================================================================================================================================

TABLE OF CONTENT


I.		Grab the last link in the tweet which is twitter name	
II.   Quotes

================================================================================================================================================
*/

$(function(){
  // Execute the getTwiiterName function after 5 secs
  // The reason being the content is brought with js after the page loads so it can't be manipulated straight away
  
  setTimeout(getTwitterName, 5000);
});

// Grab the last link in the tweet which is twitter name
function getTwitterName (){
  
  $('#attendees .tweet .text').hide(); 
  
  // Loop through all classes text
  $('#attendees .tweet .text').each(
    function (){
      // cash "this" element
      $text = $(this); 
      
      // find all links and assign class to them
      $link = $(this).find("a").addClass("tlinks");
      
      // cash the last link (the twitter name)
      $lastLink = $('.tlinks:last');       
      
      // insert the last link after the text
      $($lastLink).insertAfter($($text));
  }); 
}


// Quotes 
$(function (){

  // Quotes
  // How many paragraphs we have
  $quotes = $('#quotes p');
  $quotesSize = $($quotes).length;

  // Loop through quotes 
  $n=0;
  $interval = 5000;
  $hideInterval = 300;
  $showInterval = 500;
  
  
  function loopQuotes (){
   
   $actual_quote = $quotes[$n];
   
   $($quotes).hide($hideInterval).filter($($actual_quote).show($showInterval));
    
    $n++;
 	  if($n == $quotesSize) $n = 0;
 	  setTimeout(loopQuotes,$interval);
  }
  
  // call the looping animation
  loopQuotes();
});











