var webroot= "http://" + window.location.host + "/";
if ((webroot == "http://nysdnes01/")||(webroot == "http://151.108.224.193/")) webroot = webroot + "webtest/";     //ONLY USED WHEN SITE NOT SERVED FROM WEB ROOT

      //prototype for the Is containing user agent information
      function Is ()
      {   // convert all characters to lowercase to simplify testing
        var agt=navigator.userAgent.toLowerCase();

        // browser version
        // Note: On IE5, these return 4, so use is.ie5up to detect IE5.
        this.major  = parseInt(navigator.appVersion);
        this.minor  = parseFloat(navigator.appVersion);

        this.nav    = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                   && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                   && (agt.indexOf('webtv')==-1));
        this.nav4   = (this.nav && (this.major == 4));
        this.nav4up = (this.nav && this.minor > 4.03)
        this.nav5   = (this.nav && (this.major == 5));
        this.nav5up = (this.nav && (this.major >= 5));

        this.ie     = (agt.indexOf("msie") != -1);
        this.ie4    = (this.ie  && (this.major == 4));
        this.ie4up  = (this.ie  && (this.major >= 4));
        this.ie5    = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
        this.ie5up  = (this.ie  && !this.ie3 && !this.ie4);

        this.ver4up = (this.ie4up || this.nav4up);

        //platform
        this.mac    = (agt.indexOf("mac")!=-1);
      }

      //create the is.user agent object
      var is = new Is();

      function getSection()
      {
        var js_hrefstring = window.location.href;
        var iloop = webroot.length;
        var sectname = "";
        while (iloop<js_hrefstring.length)
        {
           if (js_hrefstring.charAt(iloop) == '/') break;
           else sectname += js_hrefstring.charAt(iloop);
           iloop++;
        }
        //window.alert(webroot + "\n" + js_hrefstring + "\n" + webroot.length + "\n" + sectname);
        if ((sectname == "sp_products") || (sectname == "ProductsAndServices")) return 1; else{
          if ((sectname == "sp_aboutus") || (sectname == "AboutUs")) return 2; else{
            if ((sectname == "sp_careers") || (sectname == "Careers")) return 3; else{
              if ((sectname == "sp_forum") || (sectname == "Forum")) return 4; else{
                if ((sectname == "sp_news") || (sectname == "NewsBriefs")) return 5; else{
                  if ((sectname == "sp_contact") || (sectname == "ContactUs")) return 6; else{
                    if ((sectname == "sp_ratingsactions") || (sectname == "RatingsActions")) return 7; else{
                      if ((sectname == "sp_calendar") || (sectname == "Events")) return 8; else{
                        if ((sectname == "sp_resource_center") || (sectname == "ResourceCenter")) return 9; else{
                          if ((sectname == "sp_press_room") || (sectname == "PressRoom")) return 10; else{
                            if ((sectname == "sp_ratings_criteria") || (sectname == "RatingsCriteria")) return 11; else{
                              if ((sectname == "sitemap") || (sectname == "SiteMap")) return 12; else{
                               if (sectname == "SPIndices") return 14; else{
                                if ((sectname == "sp_search") || (sectname == "search97cgi")) return 13; else return 0;
        } } } } } } } } } } } } }
      }

      function graphSwitch(i)
      {
         if (i == -1)
         {
            makeRemote(2,Graphs[graphChoice].linkpath,'SP_500',607,510,6,6,0);
         }
         else
         {
            document.images['Graphimage'].src = Graphs[i].imageref;
            graphChoice = i;
         }
      }

      //create an array object supported in js 1.0
      function makeArray (i)
      {
        this.length = i;
        for (index = 0;index < i;index++)
        {
          this[index] = null;
        }
        return this;
      }

      //open multiple windows
      //define an array so only one open window function is necessary
      windowContainer = new makeArray(10);

      /*parameters are the window number (index in the array) starting with 1,
        url, name of the window, width, height, x position, y position, turn scrollbars on/off */

      function makeRemote (indx,url,winName,x,y,sX,sY,scroll)
      {
        if (!windowContainer[indx] || windowContainer[indx].closed)
        {
          if (is.ver4up) windowContainer[indx]=window.open(url,winName,"width=" + x + ",height=" + y + ",screenX=" + sX + ",screenY=" + sY + ",left=" + sX + ",top=" + sY + ",scrollbars=" + scroll );
          else windowContainer[indx]=window.open(url,winName,"width=" + x + ",height=" + y + ",scrollbars=" + scroll );
        }
        else
        {   //check if a new url is to loaded
            windowContainer[indx].location = url;
        }
        if (window.focus) windowContainer[indx].focus();
      return;
      }

      //change the window statusbar content
      function showStatus (msg)
      {
        window.status = msg;
        return true;
      }

      //choose a random image for the featured product

      //generate random numbers
      function rand(mod)
      {
        var now = new Date();
        var seed =  now.getTime() % 0x7fffffff;
        seed = (0x015a4e35 * seed) % 0x7fffffff;
        return(seed >> 16) % mod;
      }

      //obj to hold images to choose from
      function imageList()
      {
        var index = 0;
        var count = 0;
        i = arguments.length;
        this.length = i/3;
        while (count < i)
        {
          this[count] = new imageLink(arguments[index],arguments[index+1],arguments[index+2]);
          count++;
          index = index+3;
        }
        return this;
      }

      //prototype for object to hold information for random image
      function imageLink(imageref,linkpath,popup)
      {
        this.imageref = imageref;
        this.linkpath = linkpath;
        this.popup = popup;
      }

//*************** Homepage Banner Code ***************

      //list of possible options for featured product
      //groups of 3 relating to the properties of the imageLink object (image path, link, show in popup)
      /* comment this out since the images do not exist and its causing web server errors
      var imagelist = new imageList(
      '/standardandpoors/images/homepage/MarketingBlock/SFBanner20020602.jpg',
      '/standardandpoors//Events/index.html#SF0206',
      '',

      '/standardandpoors/images/homepage/MarketingBlock/CVCBanner.jpg',
      '/standardandpoors//ProductsAndServices/CorporateValueConsulting/index.html',
      '',

      '/standardandpoors/images/homepage/MarketingBlock/RDbanner_A.jpg',
      '/standardandpoors//ProductsAndServices/CreditMarketServices/RatingsDirect/index.html',
      '',

      '/standardandpoors/images/homepage/MarketingBlock/SeminarAtSeaBanner.jpg',
      '/standardandpoors//Events/index.html#Sept18ISAS',
      '',

      '/standardandpoors/images/homepage/MarketingBlock/RiskSolutionsBanner.jpg',
      '/standardandpoors//ProductsAndServices/RiskManagementSolutions/RiskSolutions.html',
      '',

      '/standardandpoors/images/homepage/MarketingBlock/SPLevelsBanner.jpg',
      '/standardandpoors//ProductsAndServices/StructuredFinance/LEVELs/index.html',
      '',

      '/standardandpoors/images/homepage/MarketingBlock/CorporateProfilesBanner.jpg',
      '/standardandpoors//ProductsAndServices/InformationServices/CorporateProfiles.html',
      '',

      '/standardandpoors/images/homepage/MarketingBlock/ses.jpg',
      '/standardandpoors//ProductsAndServices/CreditMarketServices/SchoolEvaluationServices/School.html',
      '',

      '/standardandpoors/images/homepage/MarketingBlock/AdvantageBanner.jpg',
      '/standardandpoors//ProductsAndServices/InformationServices/Advantage.html',
      '');*/
      var imagelist = new imageList();
      

      var choice = rand(9);

      var speed = 5000;
	var rotateI = 0;
      var bannerLink = imagelist[rotateI].linkpath;
      var intInterval;

      function rotateImageOne()
	{

            intInterval = setInterval("rotateImage()",speed);

	}
	function rotateImage()
	{

  		if (rotateI == imagelist.length)
            {
		    rotateI	= 0;
            }

		document.images['bannerimage'].src = imagelist[rotateI].imageref;
		bannerLink = imagelist[rotateI].linkpath;
		rotateI++;
	}

      function startRotate()
	{

            intInterval = setInterval("rotateImage()",speed);

	}

      function stopRotate()
	{

            clearInterval(intInterval);

	}

//*************** End Homepage Banner Code ***************


      var forumFocus1 = new imageList(
      '/standardandpoors/images/homepage/forumfocus/CDOs_01.gif','javascript:openArticle(\'Forum/RatingsCommentaries/StructuredFinance/Articles/080701_cdomidyear.html\')',''
      );
      var forumChoice1 = rand(1);

      var forumFocus2 = new imageList(
      '/standardandpoors/images/homepage/forumfocus/GlobalCreditMarketTrends_02.gif','javascript:openArticle(\'Forum/RatingsCommentaries/CorporateFinance/Articles/pdf/081701_credit.pdf\')',''
      );
      var forumChoice2 = rand(1);


      var careerQuote = new imageList(
      '/standardandpoors/images/homepage/careerquote/quoteramesh.jpg','Careers/CareerProfiles.html#ramesh','','images/homepage/careerquote/quotejay.jpg','Careers/CareerProfiles.html#jay','', 'images/homepage/careerquote/quotelaney.jpg','Careers/CareerProfiles.html#laney','', 'images/homepage/careerquote/quotemartin.jpg','Careers/CareerProfiles.html#martin',''
      );
      var careerChoice = rand(4);

      var Graphs = new imageList(
      '/standardandpoors/images/homepage/comparegraph/SP.gif','graph_SP.html','',
      '/standardandpoors/images/homepage/comparegraph/GOLD.gif','graph_GOLD.html','',
      '/standardandpoors/images/homepage/comparegraph/Topix.gif','graph_Topix.html','',
      '/standardandpoors/images/homepage/comparegraph/DAX.gif','graph_DAX.html','',
      '/standardandpoors/images/homepage/comparegraph/TBills.gif','graph_TBills.html','',
      '/standardandpoors/images/homepage/comparegraph/Goldman.gif','graph_Goldman.html','');
      var graphChoice = 0;


      //start cookie functions
      //set the cookie expiration date to x day(s) from now in GMT
      var expires = new Date();
      expires.setTime(expires.getTime() + 24 * 60 * 60 * 1 * 1000);//add 1 day
      var expDate = expires.toGMTString();

      //bake a cookie
      function putCookie(name,value)
      {
        document.cookie = name + "=" + value + "; expires=" + expDate;
      }

      //helper method to return the value of a cookie to getCookie
      function getCookieVal(offset)
      {
        var endstr = document.cookie.indexOf(";",offset);
        if (endstr == -1)
          endstr = document.cookie.length;
        return document.cookie.substring(offset,endstr);
      }


      //parses the entire cookie string and returns the value from the name=value pair
      //matching the parameter name or false
      function getCookie(name)
      {
        var arg = name + "=";
        var alen = arg.length;
        var clen = document.cookie.length;
        var i = 0;
        while(i < clen)
        {
          var j = i + alen;
          if(document.cookie.substring(i,j) == arg)
            return getCookieVal(j);
          i = document.cookie.indexOf(" ",i) + 1;
          if(i == 0) break
        }
        return false;
      }

      function cookieInit()
      {
        var thisCookie = getCookie('visited');
        if(!thisCookie)
        {
          putCookie('visited',true);
        }
      }
      //end cookie functions


//initialize the menu
      function init ()
      {
        if (is.ver4up)
        {
          menuInit ();
          isLoaded = true;
	  onresize = resetLayout;
          // This next line should correct the Netscape event.RESIZE non-terminating loop bug.  If problem persists, try increasing the Timeout value.  [PRU]
          (is.nav) ? setTimeout('onresize=resetLayout',500) : onresize = resetLayout;
        }
        cookieInit()
      }

      function openPDF(filename)
      {
        if (is.nav)
        {
          window.location.href=filename;
        }
        else makeRemote(4, filename, 'pdf', 500, 400, 40, 40, '1,resizable');
      }

      function openArticle(filename)
      {
        //windowContainer[4].window.close;
        (is.nav) ? makeRemote(4, filename, 'article', 720, 450, 30, 30,'1,toolbar,menubar,resizable') : makeRemote(4, filename, 'article', 720, 450, 30, 30,'1,toolbar,menubar,resizable');
      }
      function openArticleAdvance(filename)
      {

        (is.nav) ? makeRemote(4, filename, 'article', 720, 450, 30, 30,'1,toolbar') : makeRemote(4, filename, 'article', 720, 450, 30, 30,'1,toolbar');

            if (windowContainer[4].opener == null) {
                windowContainer[4].opener = self;
            }
      }

      function openContact(filename)
      {
        (is.nav) ? makeRemote(2, filename, 'contactinfo', 336, 350, 250, 150, 'yes,resizable,status') : makeRemote(2, filename, 'contactinfo', 336, 350, 250, 150, '1,resizable,status');
      }

      function openCompustatContact(filename)
      {
        (is.nav) ? makeRemote(2, filename, 'contactinfo', 650, 500, 250, 150, 'yes,resizable,status') : makeRemote(2, filename, 'contactinfo', 660, 500, 20, 20, '1,resizable,status');
      }

      function openMarketAnalysis(filename)
      {
        (is.nav) ? makeRemote(5, filename, 'article', 645, 500, 30, 30, 1) : makeRemote(5, filename, 'article', 645, 500, 30, 30, '1,resizable');
      }

      function openOrderDPL(filename)
      {
        (is.nav) ? makeRemote(5, filename, 'article', 660, 420, 30, 30, '1,toolbar,menubar,resizable') : makeRemote(5, filename, 'article', 675, 420, 30, 30, '1,toolbar,menubar,resizable');
      }

      function openWebSolutions(filename)
      {
        (is.nav) ? makeRemote(5, filename, 'article', 745, 500, 30, 30, 1) : makeRemote(5, filename, 'article', 745, 500, 30, 30, '1,resizable');
      }

      function openAsianRatings(filename)
      {
        (is.nav) ? makeRemote(5, filename, 'article', 745, 415, 15, 15, '1,toolbar,menubar,resizable') : makeRemote(5, filename, 'article', 745, 415, 15, 15, '1,toolbar,menubar,resizable');
      }

      function openJumpPage(filename)
      {
        (is.nav) ? makeRemote(5, filename, 'JumpPage', 510, 245, 30, 30, '0,noresize') : makeRemote(5, filename, 'JumpPage', 510, 245, 30, 30, '0,noresize');
      }

      function openJumpPageLinkRestrict(url)
      {

        window.open(url,"FT","status=no,noresize,height=350,width=650,menubar=no,titlebar=no,toolbar=no,scrollbars=yes");
        parent.window.close();

      }
      function openJumpPageLink(url)
      {

        window.open(url);
        parent.window.close();

      }
  function openWinView(url)
		{
			winview=window.open(url, 'winview', 'toolbar=yes,location=yes,directories=no,status=yes,menubar=yes,resizable=yes,width=600,height=500,scrollbars=yes');
			winview.focus();
		}

