home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
3D World Atlas (GSP)
/
GSPCD1046A.iso
/
HTML
/
Slider.JS
< prev
next >
Wrap
Text File
|
2001-01-27
|
2KB
|
80 lines
// X_SLIDER
function Slider (left, top, initial_position, width, height, flag)
{
this.m_left = left;
this.m_top = top;
this.m_width = width;
this.m_height = height;
this.m_position = initial_position;//0 - 1
this.SetValue = _xslider_setValue;
this.Create = _xslider_create;
this.m_offset = flag;
return this;
}
function _xslider_setValue(pos)
{
document.images.left_part.width = this.m_width*pos;
document.images.right_part.width = this.m_width*(1.0-pos);
}
function _xslider_create(d)
{
doc = d || document;
_xslider_buildReg (this, doc);
}
function _xslider_buildReg (g, doc)
{
var str_top = parseInt(g.m_top);
var str_left = parseInt(g.m_left);
var str_width = parseInt(g.m_width);
var str_height = parseInt(g.m_height);
var str_lwidth = parseInt(g.m_width*g.m_position);
var str_rwidth = parseInt(g.m_width - g.m_width*g.m_position);
var str_par0 = parseInt(g.m_left);
var str_par1 = parseInt(g.m_width);
var str_par2 = parseInt(g.m_offset);
var str = "";
str += "<DIV style=\"position: absolute; top: " + str_top + "px; left: " + str_left + "px\">\n";
str += "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td valign=\"top\">\n";
str += "<IMG height=" + str_height + " name=\"left_part\" src=\"main.gif\" width=" + str_lwidth +
" ondblclick=\"adjust(" + str_par0 + "," + str_par1 + "," + str_par2 + ")\"" +
" onmouseup=\"adjust(" + str_par0 + "," + str_par1 + "," + str_par2 + ")\"\n";
str += "><IMG height=" + str_height + " name=\"right_part\" src=\"back.gif\" width=" + str_rwidth +
" ondblclick=\"adjust(" + str_par0 + "," + str_par1 + "," + str_par2 + ")\"" +
" onmouseup=\"adjust(" + str_par0 + "," + str_par1 + "," + str_par2 + ")\">\n";
str += "</td></table>";
str += "</DIV>\n";
doc.write(str);
} //function _xslider_buildReg (g, doc)
function adjust (slider_left, total_width, offset)
{
//alert(event.srcElement.name);
var x = event.x - offset;
var hor = 1000*(x - slider_left)/total_width;
window.external.SetSliderPos(hor);
}