/*

	Scrolling Text , download from www.jsworld.com

*/
// used to track position in message
   var i = 0; 
// used to cycle thru messages                                          
   var TextNumber = 0;
// array of messages                        
   var TextInput = new Object();
// used to load manipulate message          
   var HelpText="";                              
// used to load message
   var Text = "";  
// length of timeout (smaller is faster)                                  
   var Speed=50;
// added to end of each message to create a pause
   var WaitSpace="             "
// used to position text in ver 2.0
   var addPadding="\r\n";

// Each element of TextInput represents a single message.

TextInput[0] = "Recognizing our responsibilities as industrialists, we will devote ourselves to the progress and development of society and the well-being of people through our business activities, thereby enhancing the quality of life throughout the world.               ";
//TextInput[1] = "1. Contribution to Society.";
//TextInput[2] = "2. Fairness and Honesty.";
//TextInput[3] = "3. Cooperation and Team Spirit.";
//TextInput[4] = "4. Untiring Effort for Improvement.";
//TextInput[5] = "5. Courtesy and Humility.";
//TextInput[6] = "6. Adaptability.";
//TextInput[7] = "7. Gratitude.";

TotalTextInput = 0; // (0, 1, 2, 3, 4, 5, 6, 7)

// Positioning and speed vary between versions.
var Version =  navigator.appVersion;  
if (Version.substring(0, 1)==3)
   {
   Speed=200;
   addPadding="";
   }

for (var addPause = 0; addPause <= TotalTextInput; addPause++) 
   {TextInput[addPause]=TextInput[addPause]+WaitSpace+addPadding;}


var TimerId
var TimerSet=false;


// Called by the Start button.

function startMessage() 
   {
   if (!TimerSet)
      {
      TimerSet=true;
      teletype();
      }
   }


// Gets and displays character from rollMessage() . 
// Variable Speed controls length of timeout and thus the speed of typing.

function teletype() 
   {
   Text=rollMessage();
   TimerId = setTimeout("teletype()", Speed)
   document.forms[0].elements[0].value=Text;
   }


// Pulls one character at a time from string and returns (as Text) to function teletype() for displaying.

function rollMessage () 
   {
//   Wait_yn=false;
   i++;
   var CheckSpace = HelpText.substring(i-1, i);
   CheckSpace = "" + CheckSpace;
   if (CheckSpace == " ") 
      {i++;}
   if (i >= HelpText.length+1) 
      {
      i=0; 
      if (TextNumber < TotalTextInput) 
         {TextNumber++;} 
      else {TextNumber = 0;} 
      initMessage();
      }
   Text = HelpText.substring(0, i);
   return (Text);
   }


// Sets Text & HelpText equal to messages for use in rollMessage ().
function initMessage() 
   {
   	Text = TextInput[TextNumber]
   	HelpText = Text;
   	startMessage()
   }


