
/*
 * -------
 * :ATTRIBUTION NOTICE BEGINS
 *
 * The following JSMsg functions are:
 * 
 *    (C) Copyright 2002 - 2003, Creativyst, Inc.
 *               ALL RIGHTS RESERVED
 * 
 * For more information go to:
 *           http://www.Creativyst.com
 * or email:
 *           Support@Creativyst.com
 * 
 * Licensed under the Open Software License version 1.1
 *
 * END ATTRIBUTION NOTICE:
 * -------
 * These functions are free software; you can redistribute 
 * them and/or modify them under the terms of the Open 
 * Software License (OSL) version 1.1 as published by
 * the Open Source Initiative;
 * 
 * This program is distributed in the hope that it will 
 * be useful, but WITHOUT ANY WARRANTY; without even the 
 * implied warranty of MERCHANTABILITY or FITNESS FOR A 
 * PARTICULAR PURPOSE. See the Open Software License
 * version 1.1 for more details.
 * 
 * For the complete details of the Open Software License
 * please visit the Open Source Initiative website.
 *
 * 
 *
 * -------
 * These functions are part of a shared convention.
 * called JSMsg.  Please see the JSMsg document
 * for more details.
 *
 * www.creativyst.com/Doc/Std/JSMsg/JSMsg.htm
 *
 *
 * -------------------------------------------
 * Parts of this code were automatically
 * generated and may contain copyrighted
 * content from other sources as well.
 * Such content may not be used without
 * first obtaining explicit permissions
 * from its source.
 *
 *
*/

function sb_JSMsg() {

this.Title = Array([this.ShortListSize]);
this.Desc = Array([this.ShortListSize]);
this.Link = Array([this.ShortListSize]);





 this.ShortListSize = 10;
 this.BeenLoaded = 0;
 this.dispNumb;

 this.Msg = function(msgPart, msgOffset)
 {
    document.write( this.Get(msgPart, msgOffset) );
 }

 this.MsgDay = function(msgPart)
 {
    document.write( this.GetDay(msgPart) );
 }

 this.MsgN = function(msgPart, msgNumber)
 {
    document.write( this.GetN(msgPart, msgNumber) );
 }


 this.Get = function(msgPart, msgOffset)
 {
    if(!msgOffset) {
        msgOffset = 0;
    }
    if(!this.BeenLoaded) {
        this.BeenLoaded = 1;
        dispNumb = 
           this.getRandInt(this.ShortListSize);
    }
    return( this.GetN(msgPart, (dispNumb + msgOffset)) );
 }

 this.GetDay = function(msgPart)
 {
    var d = new Date();
    var x = d.getDate();
    return( this.GetN(msgPart, x) );
 }


 this.GetN = function(msgPart, msgNumber)
 {
    var myTmp;

    if(!msgPart) {
        msgPart = "Body";
    }
    if(!msgNumber) {
        msgNumber = 0;
    }

    if(msgNumber >= this.ShortListSize) {
        msgNumber = msgNumber % this.ShortListSize;
    }

    if(  this.ok(msgPart,"Type") ) {
        return(this.Type[msgNumber]);
    }
    if(  this.ok(msgPart,"Title") ) {
        return(this.Title[msgNumber]);
    }
    if(  this.ok(msgPart, "Desc Description Content") ) {
        return(this.Desc[msgNumber]);
    }
    if(  this.ok(msgPart,"Body") ) {
        return(this.Body[msgNumber]);
    }
    if(  this.ok(msgPart, "Attrib Attribute Source") ) {
        return(this.Attrib[msgNumber]);
    }
    if(  this.ok(msgPart, "Author") ) {
        if(!this.Author[msgNumber]) {
            return(this.Attrib[msgNumber]);
        }
        return(this.Author[msgNumber]);
    }

    if(  this.ok(msgPart,"DayN Day2N Day") ) {
        myTmp = this.DateN[msgNumber];
        if(myTmp.length) { 
          myTmp = myTmp.substr(6,2);
          if(  this.ok(msgPart,"Day2N") ) {
            return(myTmp);
          }
          if(myTmp.charAt(0) == "0") {
            return(myTmp.substr(1,1))
          }
          return(myTmp);
        }
    }
    if(  this.ok(msgPart, "MonthN Month2N") ) {
        myTmp = this.DateN[msgNumber];
        if(myTmp.length) {
          myTmp = myTmp.substr(4,2)
          if(  this.ok(msgPart,"Month2N") ) {
            return(myTmp);
          }
          if(myTmp.charAt(0) == "0") {
            return(myTmp.substr(1,1))
          }
          return(myTmp);
        }
    }
    if(  this.ok(msgPart, "Year2N Year4N YearN Year") ) {
        if(this.DateN[msgNumber].length) {
          if(  this.ok(msgPart,"Year4N") ) {
            return(this.DateN[msgNumber].substr(0,4));
          }
          return(this.DateN[msgNumber].substr(0,4));
        }
    }

    if(  this.ok(msgPart,"Link") ) {
        return(this.Link[msgNumber]);
    }
    if( this.ok(msgPart,"LinkTitle") ) {
        if(this.MetaMsg(msgPart,"Link") && this.MetaMsg(msgPart,"Title") ) {
          if( !this.Link[msgNumber] ) {
              return(this.Title[msgNumber]);
          }

          if( !this.Title[msgNumber] ) {
            this.Title[msgNumber] =  this.Link[msgNumber];              
          }
          myTmp = '<A TARGET="_blank" \n'; 
          myTmp = myTmp + 'HREF="' + this.Link[msgNumber] + '">\n';
          myTmp = myTmp + this.Title[msgNumber] + '</A>\n';

          return(myTmp);

        }
        if( this.MetaMsg(msgPart,"Title") ) {
          return(this.Title[msgNumber]);
        }
        if( this.MetaMsg(msgPart,"Link") ) {
          if( this.Link[msgNumber] ) {
            myTmp = "<A TARGET=\"_blank\" \n"; 
            myTmp = myTmp + "HREF=\"" + this.Link[msgNumber] + "\">\n";
            myTmp = myTmp + this.Link[msgNumber] + "</A>\n";
            return(myTmp);
          }
        }
        return("");
    }
    if( this.ok(msgPart,"Cat Category Subject") ) {
        return(this.Cat[msgNumber]);
    }
    if( this.ok(msgPart,"Thumb") ) {
        return(this.Thumb[msgNumber]);
    }
    if( this.ok(msgPart,"Alt") ) {
        return(this.Alt[msgNumber]);
    }

    return("");
 }




 this.getRandInt = function(RandSz)
 {
    var t, t2, t3;

    t = 0;
    while(t < .000001) {
        t = Math.random();
        t = Math.abs(t);
    }
    t2 = t * 1000000;
    t2 = Math.round(t2);
    t3 = t2 % RandSz;
    return(t3);
 }



 this.ok = function(a, b)
 {
    var t, t2;

    if(!this.is(a,b)) {
        return(0);
    }
    return(this.MetaMsg(a));
 }

 this.is = function(a, b)
 {
    var t, t2;

    t = a + " ";
    t2 = b + " ";
    t2 = t2.toUpperCase();
    t = t.toUpperCase();

    if(t2.indexOf(t) == -1) {
        return(0);
    }
    return(1);
 }


 this.MetaMsg = function(msgCmd)
 {
    if( this.is(msgCmd, "Title LinkTitle Desc Description Link LinkTitle ") ) {
         return(1);

    }
    else if( this.is(msgCmd, "MetaCount") ) {
        return(10);
    }
    else {
        return(0);
    }
 }


     

}

sb = new sb_JSMsg();

/* how slow is the with statement */

with( sb ) {
Title[0] = "Summer program restores isles\' natural beauty";
Desc[0] = "Travis Voeller carefully planted an aalii shrub Wednesday in the bank of Kapakahi Stream in Waipahu. The native plant had been taken from Kuaokala Ridge near Kaena Point, where it had trouble surviving, and might eventually produce red flowers in its new home.";
Link[0] = "http://www.staradvertiser.com/news/20110725_Summer_program_restores_isles_natural_beauty.html";

Title[1] = "Teacher evaluations get overhaul";
Desc[1] = "Without union agreement, the state is forging ahead on a pilot program in the coming school year that will substantially change how some public school teachers are evaluated, basing their rating in part on the academic growth of their students.";
Link[1] = "http://www.staradvertiser.com/news/20110725__Teacher_evaluations_get_overhaul.html";

Title[2] = "Photo of nebula stirs debate over dead stars";
Desc[2] = "A striking image of a planetary nebula taken by the Gemini Observatory on Mauna Kea is adding fuel to a fiery debate about the last gasps of dying stars.";
Link[2] = "http://www.staradvertiser.com/news/20110725__Photo_of_nebula_stirs_debate_over_dead_stars.html";

Title[3] = "Mentally disabled kids\' test scores plummet";
Desc[3] = "The Department of Education is trying to determine why reading and math test scores for students with severe cognitive disabilities dropped so dramatically this year with the introduction of a more academically rigorous annual assessment.";
Link[3] = "http://www.staradvertiser.com/news/20110725__Mentally_disabled_kids_test_scores_plummet.html";

Title[4] = "2 down, 48 to go for riderpedaling bike in 50 states";
Desc[4] = "Max McManus arrived from Alaska on Sunday, rode a rental bike around the Pearl Harbor Visitor Center, then got back on a plane for the mainland to begin logging 7,500 miles on bicycle, covering 50 states in 50 days.";
Link[4] = "http://www.staradvertiser.com/news/20110725_2_down_48_to_go_for_riderpedaling_bike_in_50_states.html";

Title[5] = "Charity pooh-poohs probe";
Desc[5] = "A Maui-based veterans charity called \"highly questionable\" by a watchdog group and now under review by the state attorney general\'s office has dropped its website, but the organization\'s president vows to resume operations.";
Link[5] = "http://www.staradvertiser.com/news/20110725__Charity_pooh-poohs_probe.html";

Title[6] = "Harley crash injures man";
Desc[6] = "A 55-year-old man was in critical condition Sunday after his motorcycle crashed on the H-3 freeway.";
Link[6] = "http://www.staradvertiser.com/news/20110725_Harley_crash_injures_man.html";

Title[7] = "Not all state laws make it into Hawaii Revised Statutes";
Desc[7] = "Q: Can you please direct me to where in the Hawaii Revised Statutes it states that electric vehicles may park for free?";
Link[7] = "http://www.staradvertiser.com/news/20110725_Not_all_state_laws_make_it_into_Hawaii_Revised_Statutes.html";

Title[8] = "Snatching lunch from water, ospreys put on a talons show";
Desc[8] = "Last week, while preparing my sailboat for Mexico\'s hurricane season, I heard a squeaky, high-pitched bird sound, sort of a cross between a mynah and sparrow. This, though, was no songbird.";
Link[8] = "http://www.staradvertiser.com/news/20110725__Snatching_lunch_from_water__ospreys_put_on_a_talons_show.html";

Title[9] = "Newswatch";
Desc[9] = "Human Society receives small ball python &amp;bull; UH-Hilo gears up to unveil $25M SciTech building";
Link[9] = "http://www.staradvertiser.com/news/20110725_newswatch.html";

} // end with block

