/**
   Javascript code from Xtenit
   - sidebar tab
   @author Paulo Bongato
   @lastmod January 20, 2011
*/

// article view - comment format 
function formatComment(form,field){
   var obj= form[field];

   str = obj.value;
   var re=/\n/g;
   str = str.replace(re, "<br/>");
   obj.value = str;

   return postForm(form, false);
}

// article view - limit the number of character for the comment
function limitText(limitField, limitCount, limitNum) {
   if (limitField.value.length > limitNum) {
      limitField.value = limitField.value.substring(0, limitNum);
   } else {
   limitCount.value = limitNum - limitField.value.length;
   }
}

$(document).ready(function() {
      
   // tabs for sidebar, off the wire, most read, blogs
   $("#countrytabs a").click(function() {
      // off the wire link
      if($(this).text() == "This Just In") {
         $("#countrydivcontainer .countrydivcontainer[id!='offthewiredivcontainer']").hide();
         $("#countrydivcontainer .countrydivcontainer[id='offthewiredivcontainer']").show();
         $("#countrytabs a[class='selected']").removeClass("selected");
         $("#countrytabs a:eq(0)").addClass("selected");
      } 
      // most read link
      else if($(this).text() == "Most Read") {
         $("#countrydivcontainer .countrydivcontainer[id!='mostreaddivcontainer']").hide();
         $("#countrydivcontainer .countrydivcontainer[id='mostreaddivcontainer']").show();
         $("#countrytabs a[class='selected']").removeClass("selected");
         $("#countrytabs a:eq(1)").addClass("selected");
      } 
      // blog link   
      else {
         $("#countrydivcontainer .countrydivcontainer[id!='blogsdivcontainer']").hide();
         $("#countrydivcontainer .countrydivcontainer[id='blogsdivcontainer']").show();
         $("#countrytabs a[class='selected']").removeClass("selected");
         $("#countrytabs a:eq(2)").addClass("selected");
      }
   });
});

