function replaceURLWithHTMLLinks(text) {
  var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@##\/%?=~_|!:,.;]*[-A-Z0-9+&@##\/%=~_|])/ig;
  return text.replace(exp,"<a target=\"_blank\" href='$1'>$1</a>"); 
}

function parseTwitterDate(text) {
  var newtext = text.replace(/(\+\S+) (.*)/, '$2 $1');
  return newtext;
}

function twitterDateTimeString(twitterDateTime) {
  var createdAt = new Date(twitterDateTime);
  var hours = createdAt.getHours();
  var minutes = createdAt.getMinutes();
  
  var ampm = ((hours >= 12) ? " PM" : " AM");
  var hoursString = ((hours == 0) ? "12" : (hours > 12) ? hours - 12 : hours);
  var minutesString = ((minutes < 10) ? "0" + minutes : minutes); 
  
  var createdAtString = createdAt.getMonth()+1 + '/' + createdAt.getDate() + ' at ' + hoursString + ':' + minutesString + ' ' + ampm;

  var retString = 'Posted: ' + createdAtString;
  return retString;
}

function isIE()  
{  
    if(navigator.userAgent.match(/MSIE \d\.\d+/))  
        return true;  
    return false;  
} 

function zIndexWorkaround()  
{  
    // If the browser is IE,  

    if(isIE())  

    {  
        /*  
        ** For each div with class menu (i.e.,  
        ** the thing we want to be on top),  
        */ 

        $(".mainmenu li").parents().each(function() {  
            var p = $(this);  
            var pos = p.css("position");  
            
            // If it's positioned,  
            if(pos == "relative" ||  
               pos == "absolute" ||  
               pos == "fixed")  
            {  

                /*  
                ** Add the "on-top" class name when the  
                ** mouse is hovering over it, and remove  
                ** it when the mouse leaves.  
                */ 

                p.hover(function() {  
                        $(this).addClass("on-top");  
                    },  
                    function() {  
                        $(this).removeClass("on-top");  
                    });  
            }  
        });  
    }  
} 

$(document).ready(function(){
  zIndexWorkaround();

  var fancyOpacity = "0.7";
  $(".fancyvideo").click(function() {
  	$.fancybox({
  		'padding'		: 0,
  		'autoScale'		: false,
  		'transitionIn'	: 'none',
  		'transitionOut'	: 'none',
      'overlayOpacity' : fancyOpacity,
  		'title'			: this.title,
  		'width'		: 600,
  		'height'		: 400,
  		'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
  		'type'			: 'swf',
      'swf'       : '{}'
  	});
  
  	return false;
  });
  $("a.group").attr('rel', 'gallery').fancybox({'overlayOpacity' : fancyOpacity, 'titlePosition':'inside'});


});  

