var nodes = new Array();
var nodep = 0;
var node;
var node_style;
var pnode;
var pnode_style;
var ileft;
var ileftmax;

var NODENAME = "marquee";//マーキーとして操作する要素のID名
var STEPINTERVAL = 1;    //一回の処理における移動距離幅(pixcel)
var TIMEINTERVAL = 22;   //スクロールスピード(mm-second)

//[EventHandler]
//開始処理（※移動開始）
function stt(marqueecontents){
	//HTML-DOM＋CSS
	pnode=document.getElementById(NODENAME);
	
	pnode.innerHTML=marqueecontents;
	
	if(pnode!=null && pnode.hasChildNodes()){
		//各オブジェクト、スタイルオブジェクトのアドレスを取得し変数に記憶
		pnode_style=pnode.style;
		node=document.createElement("div");
		node_style=node.style;		
		while(pnode.hasChildNodes()){
			var cnode = pnode.firstChild;
			node.appendChild(cnode);
			if(cnode.nodeType==3){
				var ncnode = document.createElement("div");
				ncnode.appendChild(cnode);
				cnode = node.appendChild(ncnode);
			}
			nodes[nodes.length] = cnode;
			cnode.style.display = "none";
		}
		pnode.appendChild(node);
		//初期化1
		node_style.whiteSpace = "nowrap";//一行表示にさせる処理
		node_style.position = "relative";//格納されたオブジェクトとして正しく認識させる処理
		//初期化2
		pnode_style.position = "relative";//格納されたオブジェクトとして正しく認識させる処理
		pnode_style.width = "424"; //領域幅
		pnode_style.overflow = "hidden";//scrollバー防止
		pnode_style.color = "#333333";//marquee文字色
		//初期化3
		nodes[0].style.display = "inline";
		ileft=pnode.offsetWidth;
		ileftmax=-(node.offsetWidth);
		//処理開始
		ftt();
	}
}

//[EventHandler]
//継続処理（※一回移動）
function ftt(){
	if(ileft>ileftmax && ileftmax != 0){
		ileft-=STEPINTERVAL;
		node_style.left = ileft;
		setTimeout("ftt()",TIMEINTERVAL);
	}else{
		nodes[nodep].style.display = "none";
		nodep++;
		if(nodep == nodes.length)
			nodep = 0;
		nodes[nodep].style.display = "inline";
		ileft=pnode.offsetWidth;
		ileftmax=-(node.offsetWidth);
		ftt();
	}
}

//[StartCode]
//ブラウザがHTMLDOMに対応している場合のみ、
//[window.onload]イベントへ[stt]イベントハンドラをセットする仕掛け
//if(document.getElementById!=null)
//	window.onload = stt();


