var marqueeArray = new Array();


var timer;           
var amount = 1;      
var stoped = false;
function initMarquee(marId){
	if(document.getElementById(marId)){
		if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 3)){		
		   document.getElementById(marId).scrollAmount=document.getElementById(marId).clientWidth;
		 }
		 else{
		   document.getElementById(marId).scrollAmount=amount;
		 }
	}
}

	
function startMarquee(marId){    
   document.getElementById(marId).start();
   clearTimeout(timer)
   stoped = true;
}

	
function scrollMarquee(marObj, waitTime){
 if(!stoped && marObj.scrollLeft <= marObj.clientWidth){
   marObj.stop();
   marObj.scrollAmount = 3;
   timer = setTimeout("startMarquee('"+marObj.id+"')", waitTime);  
 }
}


function Marquee(obj1,obj2){

	this.icefable1 = obj1;
	this.icefable2 = obj2;
	this.marqueesHeight = 0;
	this.stopscroll = false;
	this.preTop = 0;
	this.currentTop = 0;
	this.stoptime = 0;
	

	this.init_srolltext = init_srolltext;
	this.scrollUp = scrollUp;
	this.setTimer = setTimer;
	this.setStopScroll = setStopScroll;
	

	var index = marqueeArray.length;
	marqueeArray[index] = this;	
	

	this.icefable1.scrollTop = 0;
	with(this.icefable1){
		style.width = 0;
		style.height = this.marqueesHeight;
		style.overflowX = "visible";
		style.overflowY = "hidden";
		noWrap=true;
		onmouseover=new Function("marqueeArray[" + index + "].setStopScroll(true)");
		onmouseout=new Function("marqueeArray[" + index + "].setStopScroll(false)");
	}	
}			
			


			
function init_srolltext(){
  this.icefable2.innerHTML = "";
  this.icefable2.innerHTML += this.icefable1.innerHTML;
  this.icefable1.innerHTML = this.icefable2.innerHTML + this.icefable2.innerHTML;
  this.setTimer();
}



function setTimer(){

	var index = marqueeArray.length - 1;

	setInterval("marqueeArray[" + index + "].scrollUp()",50);
}


function setStopScroll(flag){
	this.stopscroll = flag; 
}


function scrollUp(){
	if(this.stopscroll) return;
	
	this.currentTop += 1;
	if(this.currentTop == 20){
		this.stoptime   += 1;
		this.currentTop -= 1;
		if(this.stoptime == 50){
			this.currentTop = 0;
			this.stoptime = 0;
		}
	}
	else {
		this.preTop = this.icefable1.scrollTop;
		this.icefable1.scrollTop += 1;
		if(this.preTop == this.icefable1.scrollTop){
			this.icefable1.scrollTop = this.icefable2.offsetHeight - this.marqueesHeight;
			this.icefable1.scrollTop += 1;
		}
	}
}	  

