function sliderMousePos(e)
{
	//get the position of the mouse
	if( !e ) { e = window.event; } if( !e || ( typeof( e.pageX ) != 'number' && typeof( e.clientX ) != 'number' ) ) { return [0,0]; }
	if( typeof( e.pageX ) == 'number' ) { var xcoord = e.pageX; var ycoord = e.pageY; } else {
		var xcoord = e.clientX; var ycoord = e.clientY;
		if( !( ( window.navigator.userAgent.indexOf( 'Opera' ) + 1 ) || ( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) || window.navigator.vendor == 'KDE' ) ) {
			if( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft ) ) {
				xcoord += document.documentElement.scrollLeft; ycoord += document.documentElement.scrollTop;
			} else if( document.body && ( document.body.scrollTop || document.body.scrollLeft ) ) {
				xcoord += document.body.scrollLeft; ycoord += document.body.scrollTop; } } }
	return [xcoord,ycoord];
}

function slideIsDown(e) {
	//make note of starting positions and detect mouse movements
	window.msStartCoord = sliderMousePos(e); window.lyStartCoord = this.style?[parseInt(this.style.left),parseInt(this.style.top)]:[parseInt(this.left),parseInt(this.top)];
	if( document.captureEvents && Event.MOUSEMOVE ) { document.captureEvents(Event.MOUSEMOVE); document.captureEvents(Event.MOUSEUP); }
	window.storeMOUSEMOVE = document.onmousemove; window.storeMOUSEUP = document.onmouseup; window.storeLayer = this;
	document.onmousemove = slideIsMove; document.onmouseup = slideIsMove; return false;
}

function slideIsMove(e) {
	//move the slider to its newest position
	var msMvCo = sliderMousePos(e); if( !e ) { e = window.event ? window.event : ( new Object() ); }
	var theLayer = window.storeLayer.style ? window.storeLayer.style : window.storeLayer; var oPix = document.childNodes ? 'px' : 0;

	var theNewPos = window.lyStartCoord[0] + ( msMvCo[0] - window.msStartCoord[0] );

	// Specific Code
	if (window.storeLayer.id=="playlist_editClipSlider_END")   // If end, don't move past start
	{
		var startPX=document.getElementById("playlist_editClipSlider").offsetLeft;
		if (theNewPos < startPX)
			theNewPos=startPX;
	}
	else if (window.storeLayer.id=="playlist_editClipSlider")
	{
		var endPX=document.getElementById("playlist_editClipSlider_END").offsetLeft;
		if (theNewPos > endPX)
		theNewPos=endPX;
	}

	var maxLength=window.storeLayer.getAttribute("maxLength");
	
	if( theNewPos < 0 ) { theNewPos = 0; } 
	if( theNewPos > maxLength ) { theNewPos = maxLength; }

	theLayer.left = theNewPos + oPix;

	//run the user's functions and reset the mouse monitoring as before
	if( e.type && e.type.toLowerCase() == 'mousemove' ) {
		if( window.storeLayer.moveFunc ) { window.storeLayer.moveFunc(theNewPos/maxLength,window.storeLayer.id); }
	} else {
		document.onmousemove = storeMOUSEMOVE; document.onmouseup = window.storeMOUSEUP;
		if( window.storeLayer.stopFunc ) { window.storeLayer.stopFunc(theNewPos/maxLength,window.storeLayer.id); }
	}
}

function setSliderPosition(oPortion)
{
	if( isNaN( oPortion ) || oPortion < 0 ) { oPortion = 0; } if( oPortion > 1 ) { oPortion = 1; }
	var theDiv = document.getElementById(this.id); if( theDiv.style ) { theDiv = theDiv.style; }
	oPortion = Math.round( oPortion * this.maxLength ); var oPix = document.childNodes ? 'px' : 0;
	if( this.hor ) { theDiv.left = oPortion + oPix; } else { theDiv.top = oPortion + oPix; }
}
