/*------------------------------------------------------------------------------------------------*\
|                                                                                                  |
| Slider Bar Form Element Script copywrite David Harrison and Dynamic Drive (www.dynamicdrive.com) |
| For support regarding this script contact me via e-mail at d_s_h2@hotmail.com                    |
|                                                                                                  |
| For full source code, usage terms, and 100's more DHTML scripts, visit http://dynamicdrive.com   |
|                                                                                                  |
| Modified for the WVC Finding Aids by Michael Bond                                                |
|                                                                                                  |
| This notice MUST stay intact for use.                                                            |
|                                                                                                  |
\*------------------------------------------------------------------------------------------------*/

function sliderForm(form) {

	//WVU Edit
    window.location = "/w/wvcguide/browse/"+form.pageNumDisplay.value+".html";
    return(false);
    
    
}

var x, lgap, pel_name, pel_wid;
var pel="";

document.onmousemove=function (event){

    if(!event){event=window.event;}
    x=event.clientX;

    if(pel!="") {
        pel.style.marginLeft=(((lgap+x)>pel_wid)?pel_wid:(((lgap+x)<0)?0:lgap+x))+"px";
        var temp = pel.style.marginLeft.replace(/\D/g,"") * (pel_maxVal/pel_wid);
		//WVU Edit
        if (temp == 1) {
            document.getElementById(pel_name).value = "index"
        }
        else {
            document.getElementById(pel_name).value = Math.round(temp);
        }

		document.getElementById("callNumbers").value = Math.round(Math.round(temp)*25) + " - " + Math.round((Math.round(temp)*25)+25) + " (page "+Math.round(temp)+")";

    }

}

function track(el,el_name,el_wid,el_maxVal){

pel=el;
pel_name=el_name;
pel_wid=el_wid;
pel_maxVal=el_maxVal
lgap=parseInt(pel.style.marginLeft.replace(/\D/g,""))-x;

}

function stop(){pel="";}

function form_slider(slider_name,wid,maxValue){

document.write('<div class="move" style="width:'+(wid+11)+'px">');
document.write('<div class="move2"></div>');
document.write('<div class="slider" onmousedown="track(this,\''+slider_name+'\','+wid+','+maxValue+');" onmouseup="stop();" style="margin-left:0;">&nbsp;</div>');
document.write('</div></div>');


}

//WVU Edit:
//Move the slider to the proper location on the current page load
function setSlider() {
	x = parseInt(document.getElementById("pageNumDisplay").value);
	x = Math.round(x * (350/140.4));

	document.getElementById("sliderObj").style.marginLeft= x+"px";
}
