function initLightbox()
{
   Lightbox.init();
}

function showAddFreindPopup()
{      
   Lightbox.showBoxByID('add_friend_popup');
   
   if(OMNITURE == true) createPageView('Quizfarm');
}

function hideAddFriendPopUp()
{
   Lightbox.hideBox();
}

function requestFriendship()
{
   var url        = '/run.php/UserProfile/';
   var requestMsg = escape($('request_message').value);
   var params     = 'cmd=request_friendship&request_message='+requestMsg+'&invitee_id='+$('invitee_id').value;
   
   new Ajax.Request(url,
       {
           method     : 'post'
          ,parameters : params
          ,onComplete : function()
          {
             Lightbox.hideBox();
             $('friendship_request_link').style.display = 'none';
             return;
          }
       })
}

function checkMessageLength(event)
{
   switch(event.type)
   {
      case 'keyup' :
      case 'focus' :
      case 'blur'  :
      {
         var remainingChars = 140 - parseInt($('request_message').value.strip().length);
         var statusDiv      = $('message_length_count'); 
         
         if(remainingChars < 0)
         {               
            statusDiv.innerHTML = '<font color="FF0000">' + remainingChars + '</font>';
            $('btn_send_msg').hide();
         }
         else
         {
            statusDiv.innerHTML = remainingChars;               
            $('btn_send_msg').show();
         }                                    
         break;
      }
   }      
   
}

function calculateMessageLength()
{
	 var statusDiv  = $('request_message');
	 var messageObj = $('message_length_count'); 
    var remainingChars = 140 - statusDiv.innerHTML.length;
    messageObj.innerHTML = remainingChars;	
    	
   if(remainingChars<0)
   {               
      statusDiv.innerHTML = '<font color="FF0000">' + remainingChars + '</font>';
      $('btn_send_msg').hide();
   }
   else
   {
      statusDiv.innerHTML =remainingChars;               
      $('btn_send_msg').show();
   } 	 
}
