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();
});  
