var scrollamariollo_seleccionMouse = false;
var scrollamariollo_posicMouse = 0;
var scrollamariollo_id;
var scrollamariollo_ini;
var scrollamariollo_size;
var scrollamariollo_sizebtn;
var scrollamariollo_id_pant;
var scrollamariollo_height_pant;
function getMouseUp(event)
{
	scrollamariollo_seleccionMouse=false;
	document.onmousedown = null;
	document.onmouseup =  null;
}
function moveScroll(event,id_pant_,id_,ini_,size_,sizebtn_,height_pant_)
{

	var IE = document.all?true:false;

	//if (!IE) document.captureEvents(Event.MOUSEMOVE)

	var tempX = 0;
	var tempY = 0;

	if(IE)
	{ //para IE
		tempX = window.event.clientX + document.body.scrollLeft;
		tempY = window.event.clientY + document.body.scrollTop;
	}else{ //para netscape
		tempX = event.pageX;
		tempY = event.pageY;
	}
	if (tempX < 0){tempX = 0;}
	if (tempY < 0){tempY = 0;}

	var top_px = document.getElementById(id_).style.top;
	var top = 0;
	if(top_px.indexOf('px')>0) top = new Number(top_px.substring(0,top_px.indexOf('px')));
	else top = new Number(top_px);

	scrollamariollo_posicMouse = tempY-top;

	scrollamariollo_id_pant=id_pant_;
	scrollamariollo_id=id_;
	scrollamariollo_ini=ini_;
	scrollamariollo_size=size_;
	scrollamariollo_sizebtn=sizebtn_;
	scrollamariollo_height_pant=height_pant_;

	scrollamariollo_seleccionMouse=true;
	document.onmousemove = getMouseXY;
	document.onmouseup =  getMouseUp;
}
function getMouseXY(event)
{
	if(scrollamariollo_seleccionMouse)
	{
		var IE = document.all?true:false;

		//if (!IE) document.captureEvents(Event.MOUSEMOVE)

		var tempX = 0;
		var tempY = 0;

		if(IE)
		{ //para IE
			tempX = window.event.clientX + document.body.scrollLeft;
			tempY = window.event.clientY + document.body.scrollTop;
		}else{ //para netscape
			tempX = event.pageX;
			tempY = event.pageY;
		}
		if (tempX < 0){tempX = 0;}
		if (tempY < 0){tempY = 0;}

		var top_px = document.getElementById(scrollamariollo_id).style.top;
		var top = 0;
		if(top_px.indexOf('px')>0) top = new Number(top_px.substring(0,top_px.indexOf('px')));
		else top = new Number(top_px);
	
		var mov = 0;
		if((tempY-scrollamariollo_posicMouse)>(scrollamariollo_size-scrollamariollo_sizebtn)) mov = (scrollamariollo_size-scrollamariollo_sizebtn);
		else mov = (tempY-scrollamariollo_posicMouse);
		if(mov<=1) mov = 1;
		document.getElementById(scrollamariollo_id).style.top='' + mov + 'px';

		var tam_scroll = scrollamariollo_size-scrollamariollo_sizebtn;

		var scrollHeight = document.getElementById(scrollamariollo_id_pant).scrollHeight;

		var size_sch = ((scrollHeight-scrollamariollo_height_pant)*mov)/tam_scroll;
		document.getElementById(scrollamariollo_id_pant).style.top = '-' + size_sch + 'px';
	}
}
function paintScroll(id,left,top,width,height,btnsize,parameters,height_pant)
{
	var aleat = ''+Math.random();
	aleat = aleat.substring(3);
	document.write('<div id="super_' + id + '_amarillo_' + aleat + '" style="position:absolute;top:'+top+'px;left:'+left+'px;width:'+width+'px;height:'+height+'px;background-color:white;" '+ parameters + ' >');
	document.write('<div id="' + id + '_amarillo_' + aleat + '" style="user-select:none;position:absolute;top:1px;left:1px;width:'+(width-2)+'px;height:'+((height*btnsize)/100)+'px;background-color:#ff9900;-moz-user-focus: ignore; -moz-user-input: disabled; -moz-user-select: none;" onselectstart="return false;" onMouseOver="document.getElementById(\'' + id + '_amarillo_' + aleat + '\').style.backgroundColor=\'#cd7b00\';" onMouseOut="document.getElementById(\'' + id + '_amarillo_' + aleat + '\').style.backgroundColor=\'#ff9900\';" '+ parameters + ' onMouseDown="moveScroll(event,\'' + id + '\',\'' + id + '_amarillo_' + aleat + '\',1,'+(height-2)+','+((height*btnsize)/100)+',' + height_pant + ');">');
//	//document.write('<img id="img_' + id + '_amarillo_' + aleat + '" src="Images/trans.gif" width="'+(width-2)+'px" height="'+((height*btnsize)/100)+'px style="-moz-user-focus: ignore; -moz-user-input: disabled; -moz-user-select: none;" '+ parameters + ' onMouseDown="moveScroll(event,\'' + id + '\',\'' + id + '_amarillo_' + aleat + '\',1,'+(height-2)+','+((height*btnsize)/100)+',' + height_pant + ');">');
	//document.write('</div>');
	document.write('</div>');
	document.write('</div>');
}
function paintScrollText(id,left,top,width,height,btnsize,parameters,height_pant)
{
	var retorno = '';
        var aleat = ''+Math.random();
        aleat = aleat.substring(3);
        retorno += '<div id="super_' + id + '_amarillo_' + aleat + '" style="position:absolute;top:'+top+'px;left:'+left+'px;width:'+width+'px;height:'+height+'px;background-color:white;" '+ parameters + ' >';
        retorno += '<div id="' + id + '_amarillo_' + aleat + '" style="user-select:none;position:absolute;top:1px;left:1px;width:'+(width-2)+'px;height:'+((height*btnsize)/100)+'px;background-color:#ff9900;-moz-user-focus: ignore; -moz-user-input: disabled; -moz-user-select: none;" onselectstart="return false;" onMouseOver="document.getElementById(\'' + id + '_amarillo_' + aleat + '\').style.backgroundColor=\'#cd7b00\';" onMouseOut="document.getElementById(\'' + id + '_amarillo_' + aleat + '\').style.backgroundColor=\'#ff9900\';" '+ parameters + ' onMouseDown="moveScroll(event,\'' + id + '\',\'' + id + '_amarillo_' + aleat + '\',1,'+(height-2)+','+((height*btnsize)/100)+',' + height_pant + ');">';
//      //document.write('<img id="img_' + id + '_amarillo_' + aleat + '" src="Images/trans.gif" width="'+(width-2)+'px" height="'+((height*btnsize)/100)+'px style="-moz-user-focus: ignore; -moz-user-input: disabled; -moz-user-select: none;" '+ parameters + ' onMouseDown="moveScroll(event,\'' + id + '\',\'' + id + '_amarillo_' + aleat + '\',1,'+(height-2)+','+((height*btnsize)/100)+',' + height_pant + ');">');
        //document.write('</div>');
        retorno += '</div>';
        retorno += '</div>';
	return retorno;
}							
