﻿// Setup.
var isMouseDown = 0;
//var wmp = document.getElementById('vi_VIDEO');
//var slider = document.getElementById('slider');
//var slider = document.getElementById('scrubKnob');




// adjust the widthOfScrub value to set the slot width. 
var widthOfScrub = 290;
// adjust the ratio to fit the widthOfScrub length.
var ratio = 2.9;

//var isScrubbing;
var isScrubbing = false;
function vi_setSliderPosition()
{
    if (!isScrubbing)
    {
        wmp = document.getElementById('vi_VIDEO');
        
        if (wmp!=null)
        {
            var movieLength = wmp.controls.currentItem.duration;
            slider1.setMax(movieLength * 100);
            //document.getElementById("playPercentValue3").value = movieLength * 100;

            slider1.setValue(wmp.controls.currentPosition * 100);
                        
            String.prototype.pad = function(l, s){ return (l -= this.length) > 0         ? (s = new Array(Math.ceil(l / s.length) + 1).join(s)).substr(0, s.length) + this + s.substr(0, l - s.length) : this;};
            
            var TimePosition = (wmp.controls.currentPosition * 60);
            
            // Current Time Position.
            var tmp = document.getElementById('time');
            
            var Mins = Math.floor(TimePosition/60);
            
            
                        tmp.value = Math.floor(Mins / 60).toFixed().pad(2, "0") + ":" + (Mins % 60).toFixed().pad(2, "0");
   

            document.getElementById('vi_movieLengthDisplay').value = Math.floor(wmp.controls.currentItem.duration / 60).toFixed().pad(2, "0") + ":" + (wmp.controls.currentItem.duration % 60).toFixed().pad(2, "0");
            
        }  // EOIf
        
    }  //EOIf
    
} // EOF.


function vi_moveScrub(vi_scrubPos)
{
wmp = document.getElementById('vi_VIDEO');

//var tmp = document.getElementById('playPercentValue');
//tmp.value = vi_scrubPos;

var newPosition = (vi_scrubPos / widthOfScrub)
wmp.controls.currentPosition = ((newPosition / wmp.controls.currentItem.duration) * widthOfScrub);
  
    
}

function vi_scrubMouseDown()
{
    isScrubbing=true;
    vi_pause();
}

function vi_scrubMouseUp()
{
    var wmp = document.getElementById('vi_VIDEO');
    var scrubPosition = slider1.getValue() / 100;
    
      wmp.controls.currentPosition = scrubPosition;
//    document.getElementById('playPercentValue').value = scrubPosition;
   
    vi_continue();
}

function vi_scrubChange()
{


}






































//// Find mouse click position relative to scrub control position on screen.
//function findPos(obj) {
//	var curleft = curtop = 0;
//	if (obj.offsetParent) {
//        do {
//			curleft += obj.offsetLeft;
//			curtop += obj.offsetTop;
//            } while (obj = obj.offsetParent);
//            
//            var posLeft = curleft;
//        // Return position-left relative to the scrub controls 'slot' position-left on the page.
//        // This can change if the player and the controls are moved on the page.
//        // The left position of the slot is worked out in relation to the left edge of the screen.
//        // This gives us a value of 0 for the left edge of the slot which is used in conjunction with the length of the slot to work out a ratio to move the movie along when the user clicks on the slot / scrub. 
//        return [posLeft];
//    }
//   
//} // EOF


//slot.addEvent('mouseleave',function(){alert('stop');});


