

/* this file expects that you have some divs.class = info that contains titles
as well as a "what's this" div". also include container.css for the dialogs */

TSCM.ratings.Help = {
   timer:null,
   whatsthis:{},
   foo:1,
   offset:6,
   wt_hoffset:20,
   wt_voffset:-6,
   toffset:80,
   help_voffset:50,
   help_hoffset:-50,
   delay:3500,
   help:{},

   init:function(){


      this.help =  new YAHOO.widget.SimpleDialog("help",  
                  { width: "370px", fixedcenter: false, 
                    visible: false, draggable: true, 
                    close: true, text: "Help for something.", 
                    /*icon: YAHOO.widget.SimpleDialog.ICON_HELP,  */
                    buttons: [ { text:"done", handler:function () { this.hide(); } , isDefault:false } ] ,
                    effect:[{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.1 },  
                            {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.2 }],
                    constraintoviewport: true  
                  } ); 

      this.help.setHeader("What's this?");
      this.help.setFooter(" <a href=''>more information</a> asdf");
      this.help.render(document.body);
      this.help.oldshow = this.help.show;
      this.help.oldhide = this.help.hide;
      this.help.mhide = function(){ this.ds = false; this.oldhide(); }
      this.help.mshow = function(){ this.ds = true; this.oldshow(); }


      this.whatsthis = new YAHOO.widget.Dialog("whatsthis", {
         /* effect : [{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.2}, {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.2}] */
         }
      );

      this.whatsthis.hide();
      YAHOO.util.Event.addListener("whatsthis", "click", function(){TSCM.ratings.Help.help.show();}, TSCM.ratings.Help.help, true);

      var modules = YAHOO.util.Dom.getElementsByClassName('info', 'div');

      YAHOO.util.Dom.batch(modules, function(module,o) {

         YAHOO.util.Event.addListener(module, "mouseover", function () { 
               var xy = YAHOO.util.Dom.getXY(this);
               xy[0]+= o.wt_hoffset;
               xy[1]+= o.wt_voffset;
               o.whatsthis.cfg.setProperty("xy", xy); 
               o.whatsthis.tg = this; // this = the clicked on div [?]
               var ds = o.help.cfg.getProperty("visible"); 
               o.whatsthis.show();
               o.title = o.whatsthis.tg.title;
               o.itemid = o.whatsthis.tg.id;
               setTimeout("TSCM.ratings.Help.whatsthis.hide()",3000); // seems good to hide it if nothign ahppens in 3 secs
               //if(!ds) o.help.title = o.whatsthis.tg.title;
               if(!ds) TSCM.ratings.Help.help.title = o.whatsthis.tg.title;
               } ,this,false); 

         YAHOO.util.Event.addListener(module, "click", function (o) { 
                  var xy = YAHOO.util.Dom.getXY(this);
                  var ds = TSCM.ratings.Help.help.cfg.getProperty("visible"); 
                  //TSCM.ratings.Help.help.hide();
                  if(!ds) this.toffset=80;
                  else this.toffset = 0;
                  xy[0]+= TSCM.ratings.Help.help_voffset;
                  xy[1]+= TSCM.ratings.Help.help_hoffset;
                  TSCM.ratings.Help.help.cfg.setProperty("xy", xy); 
                  //console.log("this id " + this.id);
                  var helpob = TSCM.ratings.Help.entries.get(this.id);
                  var thebody = helpob.bd;
                  var thehead = helpob.hd;
                  TSCM.ratings.Help.help.setBody(thebody);
                  TSCM.ratings.Help.help.setHeader(thehead);
                  TSCM.ratings.Help.help.show();
                  //TSCM.ratings.Help.help.parentNode.innerHTML = TSCM.ratings.Help.help.parentNode.innerHTML; 

               } ,this,false); 


           },this,true);



      YAHOO.util.Event.addListener("whatsthis", "click", function (o) { 
            var xy = YAHOO.util.Dom.getXY(this);
            var ds = TSCM.ratings.Help.help.cfg.getProperty("visible"); 

            if(!ds) this.toffset=80;
            else this.toffset = 0;
            xy[0]+= TSCM.ratings.Help.help_voffset;
            xy[1]+= TSCM.ratings.Help.help_hoffset;
            TSCM.ratings.Help.help.cfg.setProperty("xy", xy); 
            var helpob = TSCM.ratings.Help.entries.get(TSCM.ratings.Help.itemid);
            //console.log(TSCM.ratings.Help.itemid);
            var thebody = helpob.bd;
            var thehead = helpob.hd;
            TSCM.ratings.Help.help.setBody(thebody);
            TSCM.ratings.Help.help.setHeader(thehead);
            this.timer = setTimeout("TSCM.ratings.Help.whatsthis.hide()",this.delay);
            },this,false); 

      YAHOO.util.Event.addListener("whatsthis", "mouseover", function () { 
            YAHOO.util.Dom.setStyle(this, 'background-color', '#ffffdf'); 
            clearTimeout(this.timer);
            }); 

      // pseudoclass instead
      YAHOO.util.Event.addListener("whatsthis", "mouseout", function () { 
            var t = this.delay;
            YAHOO.util.Dom.setStyle(this, 'background-color', '#ffffcf'); 
            if(TSCM.ratings.Help.help.cfg.getProperty("visible") ) t = 200;
            this.timer = setTimeout("TSCM.ratings.Help.whatsthis.hide()",t);
         }); 



   } // end init function

};


TSCM.ratings.Help.entries = {

   eq_info_ticker:{hd:"Ticker Symbol",bd:"You can enter a partial ticker symbol, for example enter the letter 'A' and see all tickers that start with the letter 'A'"},
   eq_info_rating2:{hd:"Rating",bd:"This is a measure of how well we expect a stock to perform in the coming 12 months. TheStreet.com Ratings' stock model looks at over 62 metrics to gauge a stock's total return potential (both price appreciation and dividends) vs. a general benchmark of the equities market, interest rates and other companies in its sector. We then apply a letter grade on the stock, A+ being the highest.The stock's rating corresponds to our recommendation: stocks rated between A+ and B- are buys; stocks rated between C+ and C- are holds; stocks rated between D+ and F are sells. Although the model is quantitative, it utilizes both subjective and objective elements. Among others, subjective elements include expected equity market returns, future interest rates, implied industry outlook and forecasted company earnings. Some of the objective elements include volatility of past operating revenue, financial strength and company cash flows. We don't look at just a stock's potential to rise; we also examine risks that could pummel the stock. We do this by dissecting metrics such as the current valuation as compared to projected earnings growth; the financial strength of the underlying company as compared to its stock's valuation as compared to projected earnings growth; and the financial strength of the underlying company compared to its stock's performance."},
   eq_info_rec:{hd:"Recommendation",bd:"TheStreet.com Ratings' recommendations of buy, hold or sell correspond to the letter grade assigned to the stock. The letter grade is a measure of how well we expect a stock to perform in the coming 12 months. TheStreet.com Ratings' stock model looks at over 62 metrics to gauge a stock's total return potential (both price appreciation and dividends) vs. a general benchmark of the equities market, interest rates and other companies in its sector. We then apply a letter grade on the stock, A+ being the highest. The stock's rating corresponds to our recommendation: stocks rated between A+ and B- are buys; stocks rated between C+ and C- are holds; stocks rated between D+ and F are sells. Although the model is quantitative, it utilizes both subjective and objective elements. For example, subjective elements include expected equity market returns, future interest rates, implied industry outlook and forecasted company earnings. Objective elements include volatility of past operating revenue, financial strength and company cash flows.However, we don't look at just a stock's potential to rise; we also examine risks that could pummel the stock. We do this by dissecting metrics such as the current valuation as compared to projected earnings growth; the financial strength of the underlying company as compared to its stock's valuation as compared to projected earnings growth; and the financial strength of the underlying company compared to its stock's performance."},
   fund_info_ticker:{hd:"Ticker Symbol",bd:"You can enter a partial ticker symbol, for example enter the letter 'A' and see all tickers that start with the letter 'A'"},
   fund_info_invrat:{hd:"Investment Rating",bd: " TheStreet.com Ratings condense the available mutual fund performance and risk data into a single composite measure of each fund's risk-adjusted performance. This process identifies funds that have historically done well and those that have underperformed the market.  We apply a letter grade rating to each fund based on its performance, A+ being the highest. The fund's rating corresponds to our recommendation: funds rated between A+ and B- are buys; funds rated between C+ and C- are holds; funds rated between D+ and E- are sells.   Although the rating and recommendations are not a prediction of future performance, they do provide a framework for making informed, timely investment decisions. "},
   fund_info_rec:{hd:"Recommendation",bd: "TheStreet.com Ratings' recommendations of buy, hold or sell correspond to the letter grade assigned to the fund.  TheStreet.com Ratings condenses the available mutual fund performance and risk data into a single composite measure of each fund's risk-adjusted performance. This process identifies funds that have historically done well and those that have underperformed the market. We apply a letter grade rating to each fund based on its performance, A+ being the highest. The fund's rating corresponds to our recommendation: funds rated between A+ and B- are buys; funds rated between C+ and C- are holds; funds rated between D+ and E- are sells. Although the rating and recommendations are not a prediction of future performance, they do provide a framework for making informed, timely investment decisions."},
   fund_info_riskrat:{hd:"Risk Rating",bd: "The risk rating is a measure of the volatility of fund returns over time. The overall rating we give a fund is comprised of this Risk Rating, as well as a performance rating. Excess volatility in a fund is generally regarded as a red flag. "},
   fund_info_starrat:{hd:"Star Rating",bd: "The star rating rates funds from one to five stars. The numbers of stars a fund receives correlates to the rating assigned to the fund."},
   etf_info_ticker:{hd:"Ticker Symbol",bd:"You can enter a partial ticker symbol, for example enter the letter 'A' and see all tickers that start with the letter 'A'"},
   etf_info_rec:{hd:"Recommendation",bd:"TheStreet.com Ratings' recommendations of buy, hold or sell correspond to the letter grade assigned to the ETF. TheStreet.com Ratings condenses the available ETF performance and risk data into a single composite measure of each ETF's risk-adjusted performance. This identifies ETFs that have historically done well and those that have underperformed the market. We apply a letter grade rating to each ETF based on its performance, A+ being the highest. The ETF's rating corresponds to our recommendation: ETFs rated between A+ and B- are buys; ETFs rated between C+ and C- are holds; ETFs rated between D+ and E- are sells.  Although the rating and recommendations are not a prediction of future performance, they do provide a framework for making informed, timely investment decisions."},
   etf_info_invrat:{hd:"Investment Rating",bd:"TheStreet.com Ratings condenses the available ETF performance and risk data into a single composite measure of each ETF's risk-adjusted performance. This identifies ETFs that have historically done well as well as those that have underperformed the market. We apply a letter grade rating to each ETF based on its performance, A+ being the highest. The ETF's rating corresponds to our recommendation: ETFs rated between A+ and B- are buys; ETFs rated between C+ and C- are holds; ETFs rated between D+ and E- are sells.Although the rating and recommendations are not a prediction of future performance, they do provide a framework for making informed, timely investment decisions."},
   etf_info_riskrat:{hd:"Risk Rating",bd:"The risk rating is a measure of the volatility of an ETF's returns over time. The overall rating we give an ETF is comprised of this Risk Rating, as well as a performance rating. Excess volatility in a fund is generally regarded as a red flag."},
   etf_info_starrat:{hd:"Star Rating",bd:"The star rating rates ETFs from one to five stars. The numbers of stars an ETF receives correlates to the rating assigned to the ETF."},

 get:function(item){
      return eval("this." + item);
   }


};




