var PintNewsPage = function(initObject) { this.init(initObject); };
var PintNewsGroup = function(initObject) { this.init(initObject); };
var PintNewsSection = function(initObject) { this.init(initObject); };

var PintNews = {
   sections : [],
   currentSection : null,
   cookieLifetime : 3, // minutes

   debug : function(data) {
      document.getElementById('newsDebug').innerHTML += '<span>' + data + '</span><br />';
   },

   init : function() {
      PintNews.cid = 33;
      PintNews.debugcid = 5353;
      PintNews.domain = PINT.domain;

      if(PINT.path.indexOf('news') == -1) {
         PintNews.deleteCookie('newsState', PintNews.path, PintNews.domain);
         return;
      }

      var currentSection = 0;
      var currentGroup = 0;
      var currentPage = 0;
      var state = PintNews.getCookie('newsState');

      if(state !== null && state !== undefined) {
         var pieces = state.split("&");
         currentSection = pieces[0].substr(pieces[0].indexOf('=')+1);
         currentGroup = pieces[1];
         currentPage = pieces[2];
         PintNews.setCookie('newsState', currentSection + "&" + currentGroup + "&" + currentPage, PintNews.cookieLifetime, PintNews.path, PintNews.domain);
      }

      if(PINT.cid != PintNews.cid && PINT.cid != PintNews.debugcid) {
         return;
      }

      if (YAHOO.util.Dom.get('twitter_update_list')) PintNews.sections.push(new PintNewsSection({id: 1, title: "Twitter"}));
      PintNews.sections.push(new PintNewsSection({id: 2, title: "Site Launches"}));
      PintNews.sections.push(new PintNewsSection({id: 3, title: "Industry With Thomas"}));
      PintNews.sections.push(new PintNewsSection({id: 4, title: "PINT Updates"}));

      PintNews.currentSection = PintNews.sections[currentSection];
      PintNews.currentSection.groups[currentGroup].currentPage = currentPage;

      PintNews.initMemoryLinks();

      var run = function() {
         if(state !== null && state !== undefined) {
            PintNews.currentSection.groups[0].pages[0].el.style.display = "none";
            PintNews.currentSection.el.style.height = "30px";
            PintNews.currentSection.hideOtherGroups(currentGroup);
            PintNews.currentSection.toggleGroups(currentGroup, false);
         } else {
            PintNews.animateBegin();
         }
      };

      setTimeout(run, 777);
   },

   initMemoryLinks : function() {
      var self = PintNews;
      var links = YAHOO.util.Dom.getElementsByClassName('newsItemDetailLink');

      for(var i=0; i<links.length; i++) {
         YAHOO.util.Event.addListener(links[i], 'click', function() {
            if(self.currentSection.viewState == "init") { return; }
            var section = self.currentSection.num;
            var group = self.sections[section].currentGroup;
            var page = self.sections[section].groups[group].currentPage;
            PintNews.saveState(section, group, page, true);
         });
      }
   },

   saveState : function(section, group, page, init) {
      var state = PintNews.getCookie('newsState');

      if(init || (state !== null && state !== undefined)) {
         PintNews.setCookie('newsState', section + '&' + group + '&' + page, PintNews.cookieLifetime, PintNews.path, PintNews.domain);  
      }
   },

   animateBegin : function() {
      for(var i=0; i<PintNews.sections.length; i++) {
         PintNews.sections[i].animateBegin();
      }
   },

   toggleSections : function(section) {
      var animOut = null;
      PintNews.currentSection = PintNews.sections[section];
      PintNews.currentSection.viewState = "init";
      
      for(i=0; i< PintNews.sections.length; i++) {
         if(i == section) { continue; }
         var nextSection = PintNews.sections[i];
         nextSection.changeGroupLinkClass(nextSection.currentGroup, 'newsSortLink');
         animOut = nextSection.animateOut();
      }

      return animOut;
   },

   enableGroupLinks : function() {
      var numSections = PintNews.sections.length;
      for(var i=0; i<numSections; i++) {
         PintNews.sections[i].enableGroupLinks();
      }

   },

   disableGroupLinks : function() {
      var numSections = PintNews.sections.length;
      for(var i=0; i<numSections; i++) {
         PintNews.sections[i].disableGroupLinks();
      }
   },

   getCookie : function(name) {
      var theCookies = document.cookie.split(/[; ]+/);
      for (var i = 0 ; i < theCookies.length; i++) {
         var aName = theCookies[i].substring(0,theCookies[i].indexOf('='));
         if (aName == name) {
            return theCookies[i];
         }
      }
   },

   setCookie : function(cookieName,cookieValue,nMinutes, path, domain) {
      var today = new Date();
      var expire = new Date();
      if (nMinutes===null || nMinutes===0) {
         nMinutes=1;
      }
      expire.setTime(today.getTime() + 60000*nMinutes);
      document.cookie = cookieName+"="+cookieValue+ "; expires="+expire.toGMTString() + "; path=/; domain=" + domain;
   },

   deleteCookie : function(name, path, domain) {
      if (PintNews.getCookie(name)) {
         document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
     }
   }
};

PintNewsPage.prototype = {
   items : [],
   rows : [],
   itemsPerRow : 3,
   itemsPerFullRow : 3,

   init : function(initObject) {
      this.rows = [];
      this.el = initObject.page;
      this.items = YAHOO.util.Dom.getElementsByClassName('newsContainer', 'div', this.el);
	  // Twitter HTML override
	  if (this.items.length==0) this.items = YAHOO.util.Dom.getChildren('twitter_update_list'); 
      this.itemsPerRow = this.items.length < this.itemsPerRow ? this.items.length : this.itemsPerRow;
      this.initItems();
   },

   initItems : function() {
      this.initRows();
      this.initItemStyles();
      this.initItemHandlers();
   },

   initRows : function() {
      var fullRows = Math.floor(this.items.length / this.itemsPerFullRow);
      var leftovers = this.items.length % this.itemsPerFullRow;

      for(var i=0; i<fullRows; i++) {
         this.rows.push({});
         this.rows[i].items = [];
         for(var j=i*this.itemsPerRow; j<this.itemsPerRow*(i+1); j++) {
            this.rows[i].items.push(this.items[j]);
         }
      }
      if(leftovers > 0) {
         this.rows.push({});
         this.rows[i].items = [];
      }
      for(var k=0; k<leftovers; k++) {
         this.rows[i].items.push(this.items[k]);
      }
   },

   initItemStyles : function() {
      for(var i=0; i<this.items.length; i++) {
         YAHOO.util.Dom.setStyle(this.items[i], 'opacity', 0);
		 YAHOO.util.Dom.setStyle(this.items[i], 'display', 'none');
      }
      
      for(i=0; i<this.itemsPerRow; i++) {
         this.items[i].style.visibility = 'visible';  
      }
   },

   initItemHandlers : function() {
      var self = this;

      for(var i=0; i<this.items.length; i++) {
         var item = this.items[i];
         this.items[i].onmouseover = function(e) { self.highlight(e, this); };
         this.items[i].onmouseout = function(e) { self.unhighlight(e, this); };
      }
   },

   highlight : function(e, target) {
      e = e || window.event;
      var oldtarget = e.relatedTarget || e.fromElement;
      
      var parentNode = oldtarget;
      while(parentNode !== null) {
         if (parentNode == target) {
            return false;
      }
         if(parentNode === undefined) { break; }
         parentNode = parentNode.parentNode;
      }

      var img = YAHOO.util.Dom.getElementsByClassName('newsItemImage', 'img', target)[0];
      var imgAnim = new YAHOO.util.ColorAnim(img,
         {borderTopColor: {to: '#ffffff'},
          borderRightColor: {to: '#ffffff'},
          borderBottomColor: {to: '#ffffff'},
          borderLeftColor: {to: '#ffffff'}},
         0.2);

      var anim = new YAHOO.util.ColorAnim(target, {backgroundColor: {to: '#e8f5f8'}}, 0.2);
      anim.animate(); 
      imgAnim.animate();
   },

   unhighlight : function(e, target) {
      e =  e || window.event;
      var newitem = e.relatedTarget || e.toElement;

      var parentNode = newitem;
      while(parentNode !== null) {
         if (parentNode == target) {
            return false;
         }
		
         if(parentNode === undefined) { break; }
         parentNode = parentNode.parentNode;
      }

      var img = YAHOO.util.Dom.getElementsByClassName('newsItemImage', 'img', target)[0];
      var imgAnim = new YAHOO.util.ColorAnim(img,
         {borderTopColor: {to: '#ededed'},
          borderRightColor: {to: '#ededed'},
          borderBottomColor: {to: '#ededed'},
          borderLeftColor: {to: '#ededed'}},
         0.2);
      var anim = new YAHOO.util.ColorAnim(target, {backgroundColor: {to: '#ffffff'}}, 0.2);
      anim.animate();
      imgAnim.animate();
   },

   hideAll : function() {
      for(var i=0; i<this.items.length; i++) {
         YAHOO.util.Dom.setStyle(this.items[i], 'opacity', 0);
      }
      for(i=0; i<this.rows.length; i++) {
        this.rows[i].viewState = "hidden";
      }
   },

   animateAllItemsIn : function() {
      var self = this;
      var anims = [];
      var delay = 300;
      this.el.style.display = "";
      for(var i=0; i<this.items.length; i++) {
         this.items[i].style.display = "";
         var animIn = new YAHOO.util.Anim(this.items[i], {opacity: {from:0, to: 1}}, 0.4, YAHOO.util.Easing.easeOutStrong);
         anims.push(animIn);
      }

      var currentIndex = 0;

      for(var k=0; k<anims.length; k++) {
         var funcObj = {
            init : function() {
               self.el.style.display = "";
               anims[currentIndex++].animate();
            }
         };
         setTimeout(funcObj.init, k*delay);
      }

      return anims;
   },

   animateAllRowsIn : function() {
      var anims = [];
      this.el.style.display = "";
      for(var i=0; i<this.rows.length; i++) {
         anims = anims.concat(this.animateRowIn(i));
      }
      return anims;
   },

   animateAllRowsOut : function(immediate) {
      var i = 0;
   
      if(immediate !== null && immediate !== undefined && immediate) {
         for(i=0; i<this.items.length; i++) {
            this.items[i].style.display = "none";
         }
         return [];
      }

      var self = this;
      var anims = [];
      for(i=0; i<this.rows.length; i++) {
         anims = anims.concat(this.animateRowOut(i));
      }
      
      anims[anims.length-1].onComplete.subscribe(function() {
         self.el.style.display = "none";
      });
   
      return anims;
   },

   animateRowIn : function(rowNumber) {
      var animations = [];
      var row = this.rows[rowNumber];
      if (!row) { return; }
      var animOut = null;   

      /*if(row.viewState == "visible") {
         animOut = this.animateRowOut(rowNumber);
      }*/

      for(var i=0; i<row.items.length; i++) {
         row.items[i].style.display = "";
         var animIn = new YAHOO.util.Anim(row.items[i], {opacity: {from:0, to: 1}}, 0.4, YAHOO.util.Easing.easeOutStrong);
         animIn.index = i;
         animations.push(animIn);
         animIn.onComplete.subscribe(function(e, obj) {
            animations[this.index+1].animate();
         });
      }
      if(animOut !== null) {
         animOut.onComplete.subscribe(function() { animations[0].animate(); });
      } else {
         animations[0].animate();
      }
      row.viewState = "visible";
      return animations;
   },

   animateRowOut : function(rowNumber) {
      var row = this.rows[rowNumber];
      var animations = []; 
      for(var i=0; i<row.items.length; i++) {
         var anim = new YAHOO.util.Anim(row.items[i], {opacity: {from:1, to: 0}}, 0.1, YAHOO.util.Easing.easeOutStrong);
         animations.push(anim);
         anim.animate();
      }
      row.viewState = "hidden";
      return animations;
   }
};

PintNewsGroup.prototype = {
   perPage : 6,
   pages : [],
   currentPage : 0,

   init : function(initObject) {
      this.pages = [];
      this.currentPage = 0;
      this.el = initObject.group;
      this.state = "init";
      this.animIns = [];
      this.animOuts = [];
      this.id = initObject.id;
      this.pagerDiv = YAHOO.util.Dom.getElementsByClassName('pagination', 'div', this.el)[0];
      this.pagerLinks = YAHOO.util.Dom.getElementsByClassName('newsPaginationLink', 'a', this.el);
      var pageElements = YAHOO.util.Dom.getElementsByClassName('newsPage', 'div', this.el);
      for(var i=0; i<pageElements.length; i++) {
         this.pages.push(new PintNewsPage({page: pageElements[i]}));
      }
	  // Twitter HTML override
	  if (initObject.id == 0) this.pages.push(new PintNewsPage({page: document.getElementById('twitter_update_list')}));
      this.initPaging();
   },

   hideAll : function(index) {
      for(var i=0; i<this.pages.length; i++) {
         if(index !== null && index == i) { continue; }
         this.pages[i].hideAll();
      }
   },

   initPaging : function() {
      var self = this;
      this.pagerAnimIns = [];
      this.pagerAnimOuts = [];

      if(this.pagerLinks !== null && this.pagerLinks.length > 0) {
         this.pagerLinks[0].style.backgroundColor = "#ededed";
      }

      for(var i=0; i<this.pagerLinks.length; i++) {
         this.initPaginationAnims(i);
         this.initPaginationHandlers(i);
      }

      if(this.pagerAnimOuts.length > 0) {
         this.pagerAnimOuts[this.pagerAnimOuts.length-1].onComplete.subscribe(function() {
            if(self.pagerDiv !== undefined) { self.pagerDiv.style.display = "none"; }
         });
      }

      if(this.pagerAnimIns.length > 0) {
         this.pagerAnimIns[this.pagerAnimIns.length-1].onComplete.subscribe(function() {
            self.pagerLinks[self.currentPage].style.backgroundColor = "#ededed";
         });
      }
   },

   initPaginationHandlers : function(index) {
      var self = this;

      YAHOO.util.Event.addListener(this.pagerLinks[index], 'click', function(e, pageNum) {
         YAHOO.util.Event.preventDefault(e);
         if(self.currentPage == pageNum) { return; }
         var animOuts = self.animateOut();
         self.pagerLinks[self.currentPage].style.backgroundColor = "#ffffff";
         this.style.backgroundColor = "#ededed";
         if(animOuts.length > 0) {
            animOuts[animOuts.length-1].onComplete.subscribe(function() {
               self.currentPage = pageNum;
               self.animateIn();
            });
         }
      }, index);

      YAHOO.util.Event.addListener(this.pagerLinks[index], 'mouseover', function(e, pageNum) {
         YAHOO.util.Event.preventDefault(e);
         self.pagerLinks[pageNum].style.backgroundColor = "#ededed";
      }, index);

      YAHOO.util.Event.addListener(this.pagerLinks[index], 'mouseout', function(e, pageNum) {
         YAHOO.util.Event.preventDefault(e);
         if(pageNum == self.currentPage) { return; }
         self.pagerLinks[pageNum].style.backgroundColor = "#ffffff";
      }, index);
   },

   resetPaginationLinks : function(index) {
      if(this.pagerLinks.length > index) { this.pagerLinks[index].style.backgroundColor = "#ededed"; }
      for(var i=0; i<this.pagerLinks.length; i++) {
         if(i == index) { continue; }
         this.pagerLinks[i].style.backgroundColor = "#ffffff";
      }
   },

   initPaginationAnims : function(index) {
      var self = this;

      YAHOO.util.Dom.setStyle(this.pagerLinks[index], 'opacity', 0);
      var animIn = new YAHOO.util.Anim(this.pagerLinks[index], {opacity: {from:0, to: 1}}, 0.2, YAHOO.util.Easing.easeOutStrong);
      var animOut = new YAHOO.util.Anim(this.pagerLinks[index], {opacity: {from:1, to: 0}}, 0.1, YAHOO.util.Easing.easeOutStrong);
      animIn.index = animOut.index = index;
      animIn.target = animOut.target = this.pagerLinks[index];
      animIn.onStart.subscribe(function() {
         if(self.pagerDiv !== undefined) { self.pagerDiv.style.display = ""; }
      });
      animIn.onComplete.subscribe(function() {
         self.pagerAnimIns[this.index+1].animate();
      });
      animOut.onComplete.subscribe(function() {
         self.pagerAnimOuts[this.index+1].animate();
      });
      this.pagerAnimIns.push(animIn);
      this.pagerAnimOuts.push(animOut);
   },

   animateIn : function(kill) {
      var self = this;

      if(this.state == "animating" || this.state == "visible") { return; }

      this.state = "animating";
      this.el.style.display = "";

      //this.animIns = this.pages[this.currentPage].animateAllRowsIn();
      this.animIns = this.pages[this.currentPage].animateAllItemsIn();
      this.animIns[this.animIns.length-1].onComplete.subscribe(function(e, obj) {
         self.state = "visible";
         if(self.pagerAnimIns.length > 0) {
            self.pagerAnimIns[0].animate();
         } else {
            if(self.pagerDiv !== undefined) { self.pagerDiv.style.display = ""; }
         }
      });

      return this.animIns;
   },

   animateOut : function(kill, immediate) {
      var self = this;

      if(immediate !== null && immediate !== undefined && immediate) {
         this.pages[this.currentPage].el.style.display = "none";
         //this.state = "hidden";
         //this.pages[this.currentPage].animateAllRowsOut();
         //this.pagerDiv.style.display = "none";
      }

      if(kill && (this.animIns.length > 0 || this.animOuts.length > 0) && this.state == "animating") {
         this.killAnimation();
         return;
      }

      if(this.state == "animating" || this.state == "hidden") { return; }
      this.state = "animating";

      this.animOuts = this.pages[this.currentPage].animateAllRowsOut(immediate);

      if(self.pagerDiv !== undefined) { this.pagerDiv.style.display = "none"; }

      if(this.pagerAnimOuts.length > 0) {
         this.pagerAnimOuts[0].animate();
      }
      if(this.animOuts !== null && this.animOuts !== undefined && this.animOuts.length > 0) {
         this.animOuts[this.animOuts.length-1].onComplete.subscribe(function() {
            self.state = "hidden";
         });
      } else {
         this.state = "hidden";
      }

      return this.animOuts;
   },

   killAnimation : function() {
      for(var i=0; i<this.animIns.length; i++) {
         this.animIns[i].stop();
      }
      this.pages[this.currentPage].hideAll();
      this.animIns = [];
      this.state = "hidden";
      this.el.style.display = "none";
   }
};

PintNewsSection.prototype = {
   title : "",
   groups : [],
   sorters : [],

   init : function(initObject) {
      this.groups = [];
      this.sorters = [];
      this.sorterClicks = [];
      this.currentGroup = 0;
      this.viewState = "init";
      this.num = initObject.id - 1;
      this.id = "n_section" + (initObject.id - 1);
      this.el = document.getElementById(this.id);
      this.title = initObject.title;
      var newsGroups = YAHOO.util.Dom.getElementsByClassName('newsYear', 'div', this.id);
	  // Twitter HTML override
	  if (this.id == 'n_section0') newsGroups = [YAHOO.util.Dom.get('twitter_update_list')];
      for(var i=0; i < newsGroups.length; i++) {
         this.groups.push(new PintNewsGroup({id:this.num, group: newsGroups[i]}));
      }
      this.sorters = YAHOO.util.Dom.getElementsByClassName('newsSortLink', 'a', this.id);
      this.initSortHandlers();
      this.resetClicks(null);
   },

   initSortHandlers : function() {
      this.enableGroupLinks();
   },

   toggleGroups : function(index, resetPage) {
      var self = this;
      var animOut = PintNews.toggleSections(self.num);
      this.groups[this.currentGroup].resetPaginationLinks(0);
      
      if(animOut !== null && animOut !== undefined) {
         animOut.onComplete.subscribe(function() {
            self.finishToggle(index, resetPage);
         });
      } else {
         this.finishToggle(index, resetPage);
      }
   },

   finishToggle : function(index, resetPage) {
      var self = this;
      var group = this.groups[this.currentGroup];
      var animOuts = [];
      var animIn = null;
      var timeout = 0;

      if(self.viewState == "init") {
         animIn = self.animateIn();
      }

      if(animIn !== null) {
         timeout = 400;
      }

      var wait = function() {
         animOuts = group.animateOut(true);
         group = self.groups[index];
         if(animOuts !== undefined && animOuts.length > 0) {
            animOuts[animOuts.length-1].onComplete.subscribe(function() {
               self.sorters[self.currentGroup].className = 'newsSortLink';
               self.sorters[index].className = 'newsSortLinkOn';
               self.currentGroup = index;
               self.resetClicks(self.currentGroup);
               if(resetPage) { group.currentPage = 0; }
               else { group.resetPaginationLinks(group.currentPage); }
               group.animateIn(true);
            });
         } else {
            self.sorters[self.currentGroup].className = 'newsSortLink';
            self.sorters[index].className = 'newsSortLinkOn';
            self.currentGroup = index;
            self.resetClicks(self.currentGroup);
            if(resetPage) { group.currentPage = 0; }
            else { group.resetPaginationLinks(group.currentPage); }
            group.animateIn(true);
         }
   
         self.viewState = "open";
      };

      setTimeout(wait, timeout);
   },

   hideOtherGroups : function(index, immediate) {
      var i = 0;
      
      if(immediate !== null && immediate !== undefined && immediate) {
         for(i=0; i<this.groups.length; i++) {
            if(i == index) { continue; }
            this.groups[i].animateOut(true, true);
         }
         return;
      }

      for(i=0; i<this.groups.length; i++) {
         if(i == index) { continue; }
         this.groups[i].animateOut(true);
         this.groups[i].state = "hidden";
      }
   },

   animateBegin : function() {
      if(this.groups[this.currentGroup] && this.groups[this.currentGroup].pages){
         this.groups[this.currentGroup].pages[this.groups[this.currentGroup].currentPage].animateRowIn(0);
      }
   },

   animateIn : function() {
      this.hideOtherGroups(this.currentGroup);
      PintNews.disableGroupLinks();
      var self = this;
      var h = 380;
	  if (this.el.id == 'n_section0') h = 240;
      var header = YAHOO.util.Dom.getElementsByClassName('header', 'div', this.el)[0];

      var animHeight = new YAHOO.util.Anim(this.el, {height: {to:h}}, 0.7, YAHOO.util.Easing.easeOutStrong);
      var animBGColor = new YAHOO.util.ColorAnim(header, {backgroundColor: {to: '#ededed'}}, 0.7);
      YAHOO.util.Dom.replaceClass(header, 'header', 'headerOn');
      animHeight.onComplete.subscribe(function() {
         self.viewState = "open";
         animBGColor.animate();
         PintNews.enableGroupLinks();
      });
      animHeight.animate();
      return animHeight;
   },

   animateOut : function() {
      if(this.viewState == "closed" || this.viewState == "closing") { return; }
      PintNews.disableGroupLinks();
      this.viewState = "closing";
      var self = this;
      var h = 30;
      var header = YAHOO.util.Dom.getElementsByClassName('headerOn', 'div', this.el)[0];

      var group = this.groups[this.currentGroup];
      var groupAnims = null;

      if(group !== undefined) { groupAnims = group.animateOut(true); }

      for(var i=0; i<this.groups.length; i++) {
         this.groups[i].state = "hidden";
      }

      var animHeight = new YAHOO.util.Anim(this.el, {height: {to:h}}, 0.7, YAHOO.util.Easing.easeOutStrong);
      var animBGColor = new YAHOO.util.ColorAnim(header, {backgroundColor: {to: '#d3ecf1'}}, 0.7);
      YAHOO.util.Dom.replaceClass(header, 'headerOn', 'header');
      animHeight.onComplete.subscribe(function() {
         self.resetClicks(null);
         self.viewState = "closed";
         animBGColor.animate();
         PintNews.enableGroupLinks();
      });

      var continueAnim = function() {
         animHeight.animate();
      };

      setTimeout(continueAnim, 100);

      return animHeight;
   },

   enableGroupLinks : function() {
      var self = this;
      for(var i=0; i<this.sorters.length; i++) {
         YAHOO.util.Event.addListener(this.sorters[i], 'click', function(e, index) {
            YAHOO.util.Event.preventDefault(e);
            if(self.sorterClicks[index] > 0) { return; }
            self.sorterClicks[index]++;
            PintNews.deleteCookie('newsState', "/", PINT.domain);
            self.toggleGroups(index, true);
         }, i);
      }
   },

   disableGroupLinks : function() {
      var self = this;
      for(var i=0; i<this.sorters.length; i++) {
         YAHOO.util.Event.removeListener(this.sorters[i], 'click');
         YAHOO.util.Event.addListener(this.sorters[i], 'click', function(e, index) {
            YAHOO.util.Event.preventDefault(e);
         });
      }
   },

   changeGroupLinkClass : function(index, className) {
      if(index == -1) { index = 0; }

      this.sorters[index].className = className;
   },

   resetClicks : function(index) {
      this.sorterClicks = [];
      for(var i=0; i<this.sorters.length; i++) {
         this.sorterClicks.push(0);
      }
      if(index !== null && index !== undefined) { this.sorterClicks[index]++; }
   }
};

YAHOO.util.Event.onDOMReady(PintNews.init);
