// ------------[+]-- JavaScript Typewriter
// ------------[+]-- Copyright (C) 2003 HP-DESIGN.NET. 
// ------------[+]-- Takeru [ http://hp-design.net/ ] 
// No reproduction , no republication without written permission of HP-DESIGN.NET 
// Must not delete this copyright in order to use this script 


function TypewriterJ_initAddon() {
	this.timerID = 1 ;
	this.array = 0 ; this.string = 0 ; 
	this.loop = 0 ; this.loopnum = 0 ; 
	this.nowspeed = 0 ;

	this.id = getFormObjectByName( this.formname , this.targetframe ) ;
	return this ;
}

var oTypewriterJ ; 
function startTypewriterJ( num1 , num2 ) {
		oTypewriterJ = new initTypewriterJ ; 
		var pal = oTypewriterJ ; pal.addon() ; 
		if( pal.timerID ) { clearTimeout( pal.timerID ) }
		if( !pal.follow ) { 
			pal.array = num1 ; pal.loop = ( num2 ) ? num2 : Infinity 
		} else { pal.loop = ( num1 ) ? num1 : Infinity }
		TypewriterJ() ;
}

function TypewriterJ() { var pal = oTypewriterJ ;
	if( pal.loopnum < pal.loop ) {
		pal.nowspeed = pal.speed ; 
		var last = ( pal.string >= pal.msg[pal.array].length ) ? '' : pal.last ;
		var text = pal.msg[pal.array].substring(0,pal.string++) + last ; 
	
		setTextToFormObj( pal.id , text ) ;
	
		if( ( pal.string - 1 ) == pal.msg[pal.array].length ) { 
			pal.nowspeed = pal.stopspeed ; pal.string = 0 ; 
			if( pal.follow ) { pal.array++ ; pal.loopnum++ ;
				if( pal.array == pal.msg.length ) { pal.array = 0 }
			} else { pal.loopnum++ }
		} pal.timerID = setTimeout("TypewriterJ()",pal.nowspeed);
	}
}

function clearTypewriterJ() {
	var pal = oTypewriterJ ;
		var text = ( pal.mout ) ? pal.mout : '' ;
		setTextToFormObj( pal.id , text ) ; 
		clearTimeout( pal.timerID ) ;
}

function getFormObjectByName() {
	var temp = ''; 
	if( arguments[1] ) { temp = arguments[1] + '.document.' + arguments[0] }
		else { temp = 'document.' + arguments[0] }
	return eval( temp ) ;
}

function setTextToFormObj( id , text ) {
	id.value = text ;
}



