
ImgPlayer = function(className,speed) {
    this.length 	= this.count=0;
    this.speed		= speed;
    this.iLayer		= null;
    this.tLayer		= null;
	this.imgUrl		= [];
	this.imgLink	= [];
	this.imgDescript= [];
    this.intervalId = null;
    this.className 	= className;
}

ImgPlayer.prototype.open = function() {
	window.open(this.imgLink[this.count],'_blank','')	
}

ImgPlayer.prototype.init = function() {

	with (this){
	    iLayer = document.getElementById("ImgPlayer_"+ className);
	    tLayer = document.getElementById("ImgPlayerText_"+ className);
	
		if ( iLayer != null && tLayer != null  )
		{
		    length = imgDescript.length;
			iLayer.style.backgroundImage	= "url('"+imgUrl[0]+"')";
			tLayer.innerHTML				= imgDescript[0];
			intervalId						= setInterval(className+".move()", speed);
			iLayer.style.backgroundImage	= "url('"+imgUrl[0]+"')";
			tLayer.innerHTML				= imgDescript[0];
	    }
	    else
	    {
	    	alert("ImgPlayer.prototype.init:this.iLayer »òthis.tLayerÎª¿Õ");
	    }
    }
}
ImgPlayer.prototype.move = function() {
	with (this)
	{
	    if(iLayer.filters){
		    iLayer.filters.revealTrans.Transition=23;
		    iLayer.filters.revealTrans.apply();
		    iLayer.filters.revealTrans.play();
		}
		count = (count+1) % length;
		iLayer.style.backgroundImage	= "url('"+imgUrl[count]+"')";
		tLayer.innerHTML				= imgDescript[count];
	}
}

ImgPlayer.prototype.pause = function() {clearInterval(this.intervalId);}
ImgPlayer.prototype.unpause = function() {this.intervalId = setInterval(this.className+".move()", this.speed);}



Slider = function(className) {
	if(document.getElementById("SliderPLayer_"+ className)==null)
		document.write("<script src='/bbs/Dv_News.asp?GetName="+className+"'></script>");
    this.width = this.height = this.speed = this.pixel = this.interval =
        this.size = this.moveCount = this.X = this.Y = this.length= 0;
    this.scrollcount=1;
    this.direction = "";
    this.pLayer= null;
    this.layer = null;
    this.align = "left";
    this.intervalId = null;
    this.className = className;
    this.isPause = false;
}

Slider.prototype.init = function() {
    this.pLayer = document.getElementById("SliderPLayer_"+ this.className);
    this.layer = document.getElementById("SliderLayer_"+ this.className);

    with (this.pLayer.style) {
        width = this.width+"px";
        height = this.height+"px";
        overflow = "hidden";
    }

	with (document.getElementById("SliderTable_"+this.className))
	{
//modified by ILC 10km 2007/05/16 
//	    this.length = rows.length*rows(0).cells.length;
//modified by ILC 10km 2008/04/18
//	    this.length = this.direction=='up' || this.direction=='down' ? rows.length: rows(0).cells.length;
	    this.length = this.direction=='up' || this.direction=='down' ? rows.length: rows[0].cells.length;

	}
    with (this.layer.style) {
		width = this.direction=='up' || this.direction=='down' ? this.width+"px" : this.size*(this.length)+"px";
        height = this.direction=='up' || this.direction=='down' ? this.size*this.length+"px" : this.height+"px";
        top = 0;
        left = 0;
        position = "relative";
    }
    if (this.direction=='up' || this.direction=='down') 
	{
		setTDsize(document.getElementById("SliderTable_"+this.className),this.layer.style.width,this.size,this.align);
		setImgSize(document.getElementById("SliderTable_"+this.className),this.layer.style.width,this.size);
	}
	else
	{
		setTDsize(document.getElementById("SliderTable_"+this.className),this.size,this.layer.style.height,this.align);
		setImgSize(document.getElementById("SliderTable_"+this.className),this.size,this.layer.style.height);

	}


    switch (this.direction) {
        case "up": this.X = this.Y = 0; break;
//modified by ILC 10km 2007/05/16        
//      case "down": this.X = 0; this.layer.style.top = this.Y = -this.size*(this.item.length-1); break;
        case "down": this.X = 0; this.layer.style.top = this.Y = -this.size*(this.length-1); break;
        case "left": this.X = this.Y = 0; break;
//modified by ILC 10km 2007/05/16        
//      case "right": this.Y = 0; this.layer.style.left = this.X = -this.size*(this.item.length-1); break;
        case "right": this.Y = 0; this.layer.style.left = this.X = -this.size*(this.length-1); break;
    }
    this.start();
}
Slider.prototype.start = function() {
    switch (this.direction) {
    case "up":
        if (Math.abs(this.Y) >= parseInt(this.layer.style.height,10)-this.height) this.Y = this.layer.style.top = 0;
        break;

    case "down":
        if (Math.abs(this.Y) <= 0) this.Y = this.layer.style.top = -this.size*(this.length-1);
        break;

    case "left":
        if (Math.abs(this.X) >= parseInt(this.layer.style.width,10)-this.width) this.X = this.layer.style.left = 0;
        break;

    case "right":
        if (Math.abs(this.X) <= 0) this.X = this.layer.style.left = -this.size*(this.length-1);
        break;
    }

    this.intervalId = setInterval(this.className+".move()", this.speed);
}
Slider.prototype.move = function() {
    if (this.isPause) return;
    switch (this.direction) {
        case "up": this.Y -= this.pixel; break;
        case "down": this.Y += this.pixel; break;
        case "left": this.X -= this.pixel; break;
        case "right": this.X += this.pixel; break;
    }
    if (this.direction=='up' || this.direction=='down') {
        if (Math.abs(this.Y)%(this.size*this.scrollcount)==0) this.stop();
       	this.layer.style.top = this.Y;
   } else {
        if (Math.abs(this.X)%(this.size*this.scrollcount)==0) this.stop();
        this.layer.style.left = this.X;
    }
}
Slider.prototype.stop = function() {
    clearInterval(this.intervalId);
    setTimeout(this.className+".start()", this.interval);
}
Slider.prototype.pause = function() {this.isPause = true;}
Slider.prototype.unpause = function() {this.isPause = false;}

function NewSlider(className)
{
document.write("<script language='javascript'>var "+className+"= new Slider('"+className+"');</script>");

}

function setTDsize(tabobj,tdwidth,tdheight,tdalign) 
{
var elementInTD;
	for (i=0; i < tabobj.rows.length; i++) 
	{
//modified by ILC 10km 2008/04/18
//		for (j=0; j < tabobj.rows(i).cells.length; j++)
		for (j=0; j < tabobj.rows[i].cells.length; j++)
		{
//modified by ILC 10km 2008/04/18
//			with (tabobj.rows(i).cells(j))
			with (tabobj.rows[i].cells[j])
			{
				width = tdwidth;
				height= tdheight;
				style.overflow ="hidden";
				align = tdalign;

			}
		}
	}
}


function setImgSize(tabobj,maxwidth,maxheight)
{
var elementsInTD;
	if ( tabobj == null) return;
//modified by ILC 10km 2008/04/18	
//	elementsInTD = tabobj.all.tags("IMG");
	elementsInTD = tabobj.getElementsByTagName("IMG");
	if(elementsInTD !=null  )
	{
		for (var e=0;e<elementsInTD.length;e++ )
		{
//modified by ILC 10km 2008/04/18
//			smallImgZoom(elementsInTD(e),maxwidth,maxheight);
			smallImgZoom(elementsInTD[e],maxwidth,maxheight);
		}
	}

}

function smallImgZoom(picobj,max_width,max_height)
{
	var a=new Image();
	a.src=picobj.src;
	with(a)
	{
		if((width>max_width) || (height>max_height))
		{
			if ((width*max_height)>=(height*max_width))
			{
				picobj.width=max_width;
			}
			else 
			{
				picobj.height=max_height;
			}
		}
	}
	return false;
}



