﻿
/********************************************

	Home Marquee Show
	Jx_Home_Marq.js
	version date: 2009-9				
	This code is from POWERON.COM.TW (9xSoft)
	http://www.poweron.com.tw/
	Copyright 2001-02 by JasonX

*********************************************/

function HomeMarqCreate(ObjName,MarqId,MsgArr,MarqW,MarqH,MarqBgURL,MarqBgColor)
{
	this.CurLyrNo=1
	//if(MsgArr.length>1)
	//	this.CurLyrNo=2;

	this.bDOM = (document.getElementById ? true : false);
	this.bIE4 = ((document.all && !this.bDOM) ? true : false);

	this.bNS4 = (document.layers ? true : false);
	this.bNS = navigator.appName == "Netscape";

	this.FirstDivObj;
	this.SecondDivObj;
	this.CursorOn=false;

	this.theLyrNo='1';

	this.StartScroll=function(){
		
		if(this.bNS4) {
			if(document.getElementById(MarqId+"_L"+this.theLyrNo).top==0)
			{
				if(parseInt(this.theLyrNo)==1)
				{
					this.TimeID1=window.setTimeout (ObjName+".StartScroll()", 3000);
					document.getElementById(MarqId+"_L2").top=MarqH;
					this.SecondDivObj.innerHTML=MsgArr[this.CurLyrNo];
					document.getElementById(MarqId+"_L"+this.theLyrNo).top-=1;
					this.theLyrNo='2';
				}
				else
				{
					this.TimeID2=window.setTimeout (ObjName+".StartScroll()", 3000);
					document.getElementById(MarqId+"_L1").top=MarqH;
					this.FirstDivObj.innerHTML=MsgArr[this.CurLyrNo];
					document.getElementById(MarqId+"_L"+this.theLyrNo).top-=1;
					this.theLyrNo='1';
				}

				this.CurLyrNo+=1;
				if(this.CurLyrNo>MsgArr.length-1)
					this.CurLyrNo=0;
			}
			else if((parseInt(document.getElementById(MarqId+"_L"+this.theLyrNo).top)+parseInt(MarqH))<=0)
			{
				document.getElementById(MarqId+"_L"+this.theLyrNo).top=MarqH;
				if(parseInt(this.theLyrNo)==1)
				{
					window.clearTimeout(this.TimeID1);
				}
				else
				{
					window.clearTimeout(this.TimeID2);
				}
			}
			else
			{
				if(!this.CursorOn)
				{
					document.getElementById(MarqId+"_L1").top--;
					document.getElementById(MarqId+"_L2").top--;
				}

				window.setTimeout (ObjName+".StartScroll()", 10);
			}
		} else if (this.bDOM) {

			if(parseInt(document.getElementById(MarqId+"_L"+this.theLyrNo).style.top)==0)
			{
				if(parseInt(this.theLyrNo)==1)
				{
					window.setTimeout (ObjName+".StartScroll()", 3000);
					document.getElementById(MarqId+"_L2").style.top=MarqH+'px';
					this.SecondDivObj.innerHTML=MsgArr[this.CurLyrNo];
					document.getElementById(MarqId+"_L1").style.top=
					(parseInt(document.getElementById(MarqId+"_L1").style.top)-1)+'px';
					this.theLyrNo='2';
				}
				else
				{
					window.setTimeout (ObjName+".StartScroll()", 3000);
					document.getElementById(MarqId+"_L1").style.top=MarqH+'px';
					this.FirstDivObj.innerHTML=MsgArr[this.CurLyrNo];
					document.getElementById(MarqId+"_L2").style.top=
					(parseInt(document.getElementById(MarqId+"_L2").style.top)-1)+'px';
					this.theLyrNo='1';
				}
				this.CurLyrNo+=1;
				if(this.CurLyrNo>MsgArr.length-1)
					this.CurLyrNo=0;
			}
			else
			{
				if(!this.CursorOn)
				{
					document.getElementById(MarqId+"_L1").style.top=
					(parseInt(document.getElementById(MarqId+"_L1").style.top)-1)+'px';
					document.getElementById(MarqId+"_L2").style.top=
					(parseInt(document.getElementById(MarqId+"_L2").style.top)-1)+'px';
				}
				window.setTimeout (ObjName+".StartScroll()", 10);
			}

		}

	}

	this.InitObj=function(){
		var DocContent='<table width="'+MarqW+'" border="0" cellspacing="0" cellpadding="0"><tr><td height="'+MarqH+'" valign="middle"><span id="'+MarqId+'" style="position:relative;width:'+MarqW+';height:'+MarqH+';overflow:hiden;background-color:'+MarqBgColor+' ;background-image:url('+MarqBgURL+')">';
		DocContent=DocContent+'<div style="top:-'+MarqH/2+' !important;position:absolute;width:'+MarqW+';height:'+MarqH+';clip:rect(0 '+MarqW+' '+MarqH+' 0);left:0;top:0">';
		DocContent=DocContent+'<div id="'+MarqId+'_L1" style="position:absolute;width:'+MarqW+';left:0;top:0;OVERFLOW: hidden; WHITE-SPACE: nowrap; TEXT-OVERFLOW: ellipsis" onmouseover="'+ObjName+'.CursorOn=true" onmouseout="'+ObjName+'.CursorOn=false">';
		DocContent=DocContent+MsgArr[0];
		DocContent=DocContent+'</div>';
		DocContent=DocContent+'<div id="'+MarqId+'_L2" style="position:absolute;width:'+MarqW+';left:0;top:-'+MarqH+';OVERFLOW: hidden; WHITE-SPACE: nowrap; TEXT-OVERFLOW: ellipsis" onmouseover="'+ObjName+'.CursorOn=true" onmouseout="'+ObjName+'.CursorOn=false">';
		DocContent=DocContent+MsgArr[1];
		DocContent=DocContent+'</div></div></span></td></tr></table>';

		document.write(DocContent);
		
		this.FirstDivObj=document.getElementById(MarqId+"_L1");
		this.SecondDivObj=document.getElementById(MarqId+"_L2");

		this.StartScroll();
	}
}
