$(document).ready(function() {
        if ($("#content-tabs").length){
           iniTabs();
        }
   
});


function iniTabs(){
var tabCookie = $("#content").attr('class') + 'tab';
var cookieVal = '';
$('#content-tabs').show();

//Find the content tab A tags and add ids and hide their relative divs that they are targeted for
$('#content-tabs a').each(function(i){
   $(this).attr('id',('tab-' + (i + 1)));
   var rel = '#' + $(this).attr('rel');
   if($(this).is('.selected')) {
      $(rel).show();
   }else{
      $(rel).hide();
   }
});

//Add onclicks to each A tag in the LI tags
$('#content-tabs a').click(function(){
   $('#content-tabs a').removeClass('selected');
   $(this).addClass('selected');
   $.cookie(tabCookie, '#' + this.id);
   $('#content-tabs a').each(function(){
      var rel = '#' + $(this).attr('rel');
      if($(this).is('.selected')) {
         $(rel).show();
      }else{
         $(rel).hide();
      }
   });
   return false;
});

//If a cookie is available, then activate the tab that the cookie value is for
if($.cookie(tabCookie) != '' || $.cookie(tabCookie) != null){
   cookieVal = $.cookie(tabCookie);
   $(cookieVal).trigger('click');
}

};
