/**
* New Javascript classes
**/
var RC = {

  Pricing: {

    expandRelated: function(iMenuId, iTopicId, iCategoryId, iItemId, sKeyword, iFeedCatType, sFeedCatId) {
      var sUrl = 'http://'+rcCfg.HTTP_HOST+'/modules/expandRelated.php?kwd='+encodeURIComponent(sKeyword)+'&menuId=' +iMenuId+'&topicId='+iTopicId+'&catId='+iCategoryId+'&itemId='+iItemId+'&expand=1';
      sUrl += '&fct='+iFeedCatType+'&fci='+sFeedCatId;
      req = loadXMLDoc(sUrl, RC.Pricing.expandCollpaseRelatedCallback, false, true);
    },
    
    collapseRelated: function(iMenuId, iTopicId, iCategoryId, iItemId, sKeyword, iFeedCatType, sFeedCatId) {
      var sUrl = 'http://'+rcCfg.HTTP_HOST+'/modules/expandRelated.php?kwd='+encodeURIComponent(sKeyword)+'&menuId=' +iMenuId+'&topicId='+iTopicId+'&catId='+iCategoryId+'&itemId='+iItemId+'&collapse=1';
      sUrl += '&fct='+iFeedCatType+'&fci='+sFeedCatId;
      req = loadXMLDoc(sUrl, RC.Pricing.expandCollpaseRelatedCallback, false, true);
    },
    
    expandCollpaseRelatedCallback: function() {
      if (req.readyState == 4){
        if (req.status == 200){
          PRdoc = req.responseText;
          var pit = getById('pr1');
          if(!pit){    return;  }
          pit.innerHTML=PRdoc;
          var objScroll = getById('pr1');
          scroll(0, getOffsetTop(objScroll));
          /**
          * Allow the linkify code to do it's stuff
          **/
          setLinks();
        }
      }
    }
  },
  
  Track: {
    sTrackingBreadcrumb: null,
    
    /**
    * Track the click with Google Analytics
    **/
    click: function(sTrackingLabel) {
      if (sTrackingLabel != null && this.sTrackingBreadcrumb != null) {
        // Google analytics tracking
        try {
          pageTracker._trackEvent(sTrackingLabel, 'Click', this.sTrackingBreadcrumb);
        } catch (oException) {
          // Do nothing
        }
      }
    }
  },
  
  Log: {
    /**
    * Use the internal click-tracker
    **/
    click: function(oEvent, sUrl) {
      /**
      * Ignore mouseup events from the right button
      * All others are counted a a click
      **/
      if (oEvent.which == null) {
        /* IE case */
        sButton= (oEvent.button < 2) ? "LEFT" : ((oEvent.button == 4) ? "MIDDLE" : "RIGHT");
      } else {
        /* All others */
        sButton= (oEvent.which < 2) ? "LEFT" : ((oEvent.which == 2) ? "MIDDLE" : "RIGHT");
      }
      if(sButton == 'RIGHT') {
        return;
      }
      var oTracker = document.getElementById('rc-click-tracker');
      if(oTracker) {
        document.body.removeChild(oTracker);
      }
      oTracker = document.createElement('img');
      oTracker.id='rc-click-tracker';
      oTracker.width = 1;
      oTracker.height = 1;
      oTracker.src = sUrl;
      document.body.appendChild(oTracker);
    }
  }
}
