scrollBar.prototype.innerJoinHTML = function(barID,width,height,direction)
{
var barHtml = barID.innerHTML;
var newHtml = "";
var maxValue = 0;
if ( direction == "upDown" )
{
barID.style.width = width;
barID.style.height = height;
maxValue = Math.max(barID.scrollHeight, height);
barID.style.overflowX = "visible";
barID.style.overflowY = "hidden";
newHtml = "<table border='0' cellspacing='0' cellpadding='0' width='100%'>\n";
newHtml += "  <tr>\n";
newHtml += "    <td height='" + maxValue + "' valign='top'>\n";
newHtml += barHtml + "\n";
newHtml += "    </td>\n";
newHtml += "  </tr>\n";
newHtml += "  <tr>\n";
newHtml += "    <td height='" + maxValue + "' valign='top'>\n";
newHtml += barHtml + "\n";
newHtml += "    </td>\n";
newHtml += "  </tr>\n";
newHtml += "</table>\n";
barID.innerHTML = newHtml;
//maxValue = 
alert(maxValue);
}
else
{
barID.style.width = width;
barID.style.height = height;
maxValue = Math.max(barID.scrollWidth, width);
barID.style.overflowX = "hidden";
barID.style.overflowY = "visible";
newHtml = "<table border='0' cellspacing='0' cellpadding='0' width='" + (maxValue * 2 ) + "'>\n";
newHtml += "  <tr>\n";
newHtml += "    <td width='" + maxValue + "' valign='top'>\n";
newHtml += barHtml + "\n";
newHtml += "    </td>\n";
newHtml += "    <td width='" + maxValue + "' valign='top'>\n";
newHtml += barHtml + "\n";
newHtml += "    </td>\n";
newHtml += "  </tr>\n";
newHtml += "</table>\n";
barID.innerHTML = newHtml;
} return maxValue;
}scrollBar.prototype.innerInitBar = function (index)
{
//get properties
var barID = this.barsArray[index].barID;
var width = this.barsArray[index].width;
var height = this.barsArray[index].height;
var interval = this.barsArray[index].interval;
var direction = this.barsArray[index].direction;
var maxValue = 0;

//set scrollBar's properties
switch( direction )
{
case "up":
maxValue = this.innerJoinHTML(barID,width,height,"upDown");
break;
case "down":
maxValue = this.innerJoinHTML(barID,width,height,"upDown");
barID.scrollTop = maxValue;
break;
case "left":
maxValue = this.innerJoinHTML(barID,width,height,"leftRight");
break;
case "right":
maxValue = this.innerJoinHTML(barID,width,height,"leftRight");
barID.scrollLeft = maxValue;
break;
default:
//throw "direction is inccorect!";
alert("ScrollBar[" + id + "]: direction is incorect!");
return;
}

//set mouse events
barID.onmouseover = new Function("__scrollBarControl.mouseEvt(" + index + ",true);");
barID.onmouseout = new Function("__scrollBarControl.mouseEvt(" + index + ",false);");
window.setInterval("__scrollBarControl.scroll(" + index + ");",interval);

//save maxValue
this.barsArray[index].maxValue = maxValue;
}scrollBar.prototype.mouseEvt = function(index, stop)
{
this.barsArray[index].stopScroll = stop;
}scrollBar.prototype.scroll = function(index)
{
//get properties
var barID = this.barsArray[index].barID;
var width = this.barsArray[index].width;
var height = this.barsArray[index].height;
var interval = this.barsArray[index].interval;
var direction = this.barsArray[index].direction;
var stopScroll = this.barsArray[index].stopScroll;
var preValue = this.barsArray[index].preValue;
var maxValue = this.barsArray[index].maxValue;

if ( stopScroll == true ) return;

switch(direction)
{
case "up":
preValue++;
if ( preValue >= maxValue )
{
preValue = 0;
}
barID.scrollTop = preValue;
break;
case "down":
preValue--;
if ( preValue <= 0 )
{
preValue = maxValue;
}
barID.scrollTop = preValue;
break;
case "left":
preValue++;
if ( preValue >= maxValue )
{
preValue = 0;
}
barID.scrollLeft = preValue;
break;
case "right":
preValue--;
if ( preValue <=0 )
{
preValue = maxValue;
}
barID.scrollLeft = preValue;
break;
}
this.barsArray[index].preValue = preValue;
}//=================end of file===========================