// ZSite widget library -- resizer widget routines
// (c) Zagorodnikov Anton 2007-2009

var zsite_scroll_control_size = 16;

//horizontal scrolling arrays
var zsite_canvas_scroll_h_pos = Array();	//position of horizontal scroller
var zsite_canvas_scroll_h_grip = Array();	//bool for dragging

//var zsite_scroll_thr_width = Array();		//width of scroller's thr
//var zsite_canvas_scroll_parth = Array();	//width of scroller

var zsite_canvas_scroll_h_left = Array();	//how much left to scroll for smooth scrolling
var zsite_canvas_scroll_h_speed = Array();	//current scroll speed for smooth scrolling

//vertical scrolling arrays
var zsite_canvas_scroll_v_pos = Array();	//position of vertical scroller
var zsite_canvas_scroll_v_grip = Array();	//bool for dragging

//var zsite_scroll_thr_height = Array();		//height of scroller's thr
//var zsite_canvas_scroll_partv = Array();	//height of scroller

var zsite_canvas_scroll_v_left = Array();	//how much left to scroll for smooth scrolling
var zsite_canvas_scroll_v_speed = Array();	//current scroll speed for smooth scrolling

//function pointers for scroll event handling
//handler format
// function(id, scrollvalue horizontal, scollvalue_vertical)
var zsite_canvas_scroll_h_handler = Array();
var zsite_canvas_scroll_v_handler = Array();

//real values 
var zsite_canvas_scroll_height = Array();	//canvas scrolling area (if not a frame)
var zsite_canvas_scroll_width = Array();	//canvas scrolling area (if not a frame)

//set scrolling area for vertical scrolling if not a frame
function zsite_control_scrollbar_setheight(id, height)
{
	zsite_canvas_scroll_height[id] = height;
}

//set scrolling area for horizontal scrolling if not a frame
function zsite_control_scrollbar_setwidth(id, width)
{
	zsite_canvas_scroll_width[id] = width;
}


function zsite_control_scrollbar_h_init(id, handler, width)
{
//	zsite_scroll_thr_width[id] = 0;

	zsite_canvas_scroll_h_pos[id] = 0;
	zsite_canvas_scroll_h_grip[id] = 0;

//	zsite_canvas_scroll_parth[id] = 0;

	zsite_canvas_scroll_h_left[id] = 0;
	zsite_canvas_scroll_h_speed[id] = 0;

	zsite_canvas_scroll_h_handler[id] = handler;
	zsite_canvas_scroll_width[id] = width;

	//add on mouseup document handler
	var oldmouseup = document.onmouseup;
	eval("\
	document.onmouseup = function(e)	\
	{					\
		end_h_scroll(id);		\
		oldmouseup(e);			\
	};");

	//add on mousemove document handler
	var oldmousemove = zsite_mousemove_handlers;
	eval("\
	zsite_mousemove_handlers = function(e)	\
	{					\
		if(zsite_canvas_scroll_h_grip['"+id+"'] == 1)		\
		{						\
			scroll_h('"+id+"', mousex - prevposx, 2);	\
		}						\
		oldmousemove();					\
	};");

	zsite_control_scrollbars_h_resize(id, 0, 0);
}

function zsite_control_scrollbar_v_init(id, handler, height)
{
//	zsite_scroll_thr_height[id] = 0;

	zsite_canvas_scroll_v_pos[id] = 0;  
	zsite_canvas_scroll_v_grip[id] = 0;

//	zsite_canvas_scroll_partv[id] = 0;

	zsite_canvas_scroll_v_left[id] = 0;
	zsite_canvas_scroll_v_speed[id] = 0;

	zsite_canvas_scroll_v_handler[id] = handler;
	zsite_canvas_scroll_height[id] = height;

	//add on mouseup document handler
	var oldmouseup = document.onmouseup;
	eval("\
	document.onmouseup = function(e)	\
	{					\
		end_v_scroll(id);		\
		oldmouseup(e);			\
	};");

	//add on mousemove document handler
	var oldmousemove = zsite_mousemove_handlers;
	eval("\
	zsite_mousemove_handlers = function(e)	\
	{					\
		if(zsite_canvas_scroll_v_grip['"+id+"'] == 1)		\
		{						\
			scroll_v('"+id+"', mousey - prevposy, 2);	\
		}						\
		oldmousemove();					\
	};");

	zsite_control_scrollbars_v_resize(id, 0, 0);
}

function zsite_control_scrollbars_v_resize(id, valx, valy)
{
	var scrolling_control_width = zsite_control_widths[id];
	var scrolling_control_height = zsite_control_heights[id];

	//todo: if we have control without frame, then we can get its scrolling boundaries,
	//	if we have iframe with scroll, we can get its scrolling boundaries too.
	var scrolling_height;
	var scrolling_width;


	if((zsite_canvas_scroll_height[id]=="auto")&&(dojo.byId(id+'_frame') != null))
	{
		//canvas with frame
		try
		{
			if(dojo.byId(id+'_frame').contentDocument != null)
			{
				if(dojo.byId(id+'_frame').contentDocument.body != null)
				{
					scrolling_height = zsite_get_frame_height(id+'_frame');
//					scrolling_height = dojo.byId(id+'_frame').contentDocument.body.scrollHeight;
//					scrolling_width = dojo.byId(id+'_frame').contentDocument.body.scrollWidth;
				}
			}
		}
		catch(e)
		{
			scrolling_height = 1;//dojo.byId(id+'_frame').contentDocument.body.scrollHeight;
			scrolling_width = 1;//dojo.byId(id+'_frame').contentDocument.body.scrollWidth;
		}
//		alert(dojo.byId(id+'_frame').contentDocument.body.scrollHeight);
//		canvas_height = dojo.byId(id+'_frame').contentDocument.body.scrollHeight;
//		canvas_width = dojo.byId(id+'_frame').contentDocument.body.scrollWidth;
	}
	else
	{
		//canvas without frame
		scrolling_height = zsite_canvas_scroll_height[id];
		scrolling_width = zsite_canvas_scroll_width[id];
	}

	//alert(dojo._abs(dojo.byId(id)).y);
	//dojo.byId(id+"_scroll_v").style.top = dojo._abs(dojo.byId(id)).y + "px";
	
	//todo: do not lose scrolling position on resize
	zsite_canvas_scroll_v_pos[id] = 0;

	dojo.byId(id+"_scroll_v").style.marginLeft = (scrolling_control_width-zsite_scroll_control_size) + "px";
//	dojo.byId(id+"_scroll_v").style.marginTop = (zsite_scroll_control_size) + "px";
	dojo.byId(id+"_scroll_v").style.height = (scrolling_control_height-zsite_scroll_control_size) + "px";
	dojo.byId(id+"_scroll_v_d_arrow").style.marginTop = (scrolling_control_height-zsite_scroll_control_size*2) + "px";

	//zsite_canvas_scroll_partv[id] = (canvas_control_height-32) * (canvas_control_height-32) / canvas_height;
	//if(zsite_canvas_scroll_partv[id] > canvas_control_height-49) zsite_canvas_scroll_partv[id] = (canvas_control_height-49);

	var scrolling_area_part = ((zsite_control_heights[id]-zsite_scroll_control_size)/scrolling_height);
	if(scrolling_area_part > 1.0)
		scrolling_area_part = 1.0;

	var scroll_throb_height = scrolling_area_part*(zsite_control_heights[id]-zsite_scroll_control_size*3);
	//throb must be at least 7 pixels height for user to conveniently grab it
	if(scroll_throb_height < 7)
		scroll_throb_height = 7;
		
	//scroll throb height
	dojo.byId(id+"_scroll_v_thr").style.height = scroll_throb_height + "px";

	//scroll throb position
	dojo.byId(id+"_scroll_v_thr").style.marginTop = zsite_scroll_control_size + (scrolling_area_part*zsite_canvas_scroll_v_pos[id])/scrolling_height + "px";


	dojo.byId(id+"_scroll_v_thr_img").style.marginTop = (scroll_throb_height/2-5) + "px";

	//reposition scrollers
	scroll_v(id,0,0);
}

function zsite_control_scrollbars_h_resize(id, valx, valy)
{
	var scrolling_control_width = zsite_control_widths[id];
	var scrolling_control_height = zsite_control_heights[id];

	//todo
	var scrolling_height;
	var scrolling_width;

	if((zsite_canvas_scroll_height[id]=="auto")&&(dojo.byId(id+'_frame') != null))
	{
		//canvas with frame
		try
		{
			if(dojo.byId(id+'_frame').contentDocument != null)
			{
				if(dojo.byId(id+'_frame').contentDocument.body != null)
				{
//					scrolling_height = dojo.byId(id+'_frame').contentDocument.body.scrollHeight;
					scrolling_width = zsite_get_frame_width(id+'_frame');
				}
			}
		}
		catch(e)
		{
			scrolling_height = 1;//dojo.byId(id+'_frame').contentDocument.body.scrollHeight;
			scrolling_width = 1;//dojo.byId(id+'_frame').contentDocument.body.scrollWidth;
		}
	}
	else
	{
		//canvas without frame
		scrolling_height = zsite_canvas_scroll_height[id];
		scrolling_width = zsite_canvas_scroll_width[id];
	}





	//todo: do not lose scrolling position on resize
	zsite_canvas_scroll_v_pos[id] = 0;

	dojo.byId(id+"_scroll_h").style.marginTop = (scrolling_control_height-zsite_scroll_control_size) + "px";
	dojo.byId(id+"_scroll_h").style.width = (scrolling_control_width-zsite_scroll_control_size) + "px";
	dojo.byId(id+"_scroll_h_r_arrow").style.marginLeft = (scrolling_control_width-zsite_scroll_control_size*2) + "px";

	var scrolling_area_part = (parseFloat(zsite_control_widths[id]-zsite_scroll_control_size)/parseFloat(scrolling_width));
	if(scrolling_area_part > 1.0)
		scrolling_area_part = 1.0;

	var scroll_throb_width = scrolling_area_part*(zsite_control_widths[id]-zsite_scroll_control_size*3);
	//throb must be at least 7 pixels height for user to conveniently grab it
	if(scroll_throb_width < 7)
		scroll_throb_width = 7;
		
	//scroll throb width
	dojo.byId(id+"_scroll_h_thr").style.width = scroll_throb_width + "px";

	//scroll throb position
	dojo.byId(id+"_scroll_h_thr").style.marginLeft = zsite_scroll_control_size + (scrolling_area_part*zsite_canvas_scroll_h_pos[id])/scrolling_width + "px";

	dojo.byId(id+"_scroll_h_thr_img").style.marginLeft = (scroll_throb_width/2-5) + "px";

	//reposition scrollers
	scroll_h(id,0,0);
}






function begin_v_scroll(id)
{
//	dojo.byId(id+"_scroll_v").onclick = null;

	zsite_canvas_scroll_v_grip[id] = 1;

	return false;
}

function end_v_scroll(id)
{
	zsite_canvas_scroll_v_grip[id] = 0;
}


function begin_h_scroll(id)
{
//	dojo.byId(id+"_scroll_v").onclick = null;

	zsite_canvas_scroll_h_grip[id] = 1;

	return false;
}

function end_h_scroll(id)
{
	zsite_canvas_scroll_h_grip[id] = 0;
}









function scroll_v(id, value, smooth)
{
	var scrolling_height = zsite_canvas_scroll_height[id];
	var scrolling_width = zsite_canvas_scroll_width[id];
	if((zsite_canvas_scroll_height[id]=="auto")&&(dojo.byId(id+'_frame') != null))
	{
		//canvas with frame
		try
		{
			if(dojo.byId(id+'_frame').contentDocument != null)
			{
				if(dojo.byId(id+'_frame').contentDocument.body != null)
				{
					scrolling_height = dojo.byId(id+'_frame').contentDocument.body.scrollHeight;
					scrolling_width = dojo.byId(id+'_frame').contentDocument.body.scrollWidth;
				}
			}
		}
		catch(e)
		{
			scrolling_height = 1;//dojo.byId(id+'_frame').contentDocument.body.scrollHeight;
			scrolling_width = 1;//dojo.byId(id+'_frame').contentDocument.body.scrollWidth;
		}
	}
	else
	{
		//canvas without frame
		scrolling_height = zsite_canvas_scroll_height[id];
		scrolling_width = zsite_canvas_scroll_width[id];
	}

	var scrolling_control_width = zsite_control_widths[id];//dojo.html.getContentWidth(id);
	var scrolling_control_height = zsite_control_heights[id];//dojo.html.getContentHeight(id);

	//if mousemove, then recalculate value in 1 px dragged
	if(smooth == 2)
	{
		value = value / ((zsite_control_heights[id]-zsite_scroll_control_size*3)/(scrolling_height));
		smooth = 0;
	}

	if(smooth == 0)
	{
		zsite_canvas_scroll_v_pos[id] = zsite_canvas_scroll_v_pos[id] + value;

		//if we reach top or bottom
		if(zsite_canvas_scroll_v_pos[id] < 0)
		{
			//value = zsite_canvas_scroll_v_pos[id] - value;
			value = value - zsite_canvas_scroll_v_pos[id];
			zsite_canvas_scroll_v_pos[id] = 0;
		}
		else if(zsite_canvas_scroll_v_pos[id] > (scrolling_height-(scrolling_control_height-zsite_scroll_control_size)))
		{
			value = (scrolling_height-(scrolling_control_height-zsite_scroll_control_size))-zsite_canvas_scroll_v_pos[id];
			zsite_canvas_scroll_v_pos[id] = scrolling_height-(scrolling_control_height-zsite_scroll_control_size);

			//if actually no scroll area
			if(zsite_canvas_scroll_v_pos[id] < 0)
				zsite_canvas_scroll_v_pos[id] = 0;
		}
		//     //value = zsite_canvas_scroll_v_pos[id] - value;
		
/*
		var scrolling_area_part = ((zsite_control_heights[id]-zsite_scroll_control_size)/scrolling_height);
		if(scrolling_area_part > 1.0)
			scrolling_area_part = 1.0;
*/
		var thrpos = (zsite_control_heights[id]-zsite_scroll_control_size*3)*(zsite_canvas_scroll_v_pos[id])/(scrolling_height)

		//if(zsite_canvas_scroll_v_pos[id] < 0) alert(zsite_canvas_scroll_v_pos[id]);
		
//		alert((scrolling_area_part*zsite_canvas_scroll_v_pos[id])/(scrolling_height-zsite_control_heights[id]-zsite_scroll_control_size));

		//scroll throb position
		dojo.byId(id+"_scroll_v_thr").style.marginTop = zsite_scroll_control_size + thrpos + "px";
	}
	else
	{
		zsite_canvas_scroll_v_left[id] = zsite_canvas_scroll_v_left[id] + value;
		zsite_canvas_scroll_v_speed[id] = zsite_canvas_scroll_v_left[id]*0.35;
		scroll_v_smooth(id);
	}

	//var real_value = value* (canvas_height-canvas_control_height) / (canvas_control_height-34-zsite_scroll_thr_height[id])

	//scroll handler
	eval(zsite_canvas_scroll_v_handler[id]+"('"+id+"', "+0+", "+zsite_canvas_scroll_v_pos[id]+");");
	//canvas_scroll(id, 0, 0);
}




function scroll_h(id, value, smooth)
{
	var scrolling_height = zsite_canvas_scroll_height[id];
	var scrolling_width = zsite_canvas_scroll_width[id];
	if((zsite_canvas_scroll_height[id]=="auto")&&(dojo.byId(id+'_frame') != null))
	{
		//canvas with frame
		try
		{
			if(dojo.byId(id+'_frame').contentDocument != null)
			{
				if(dojo.byId(id+'_frame').contentDocument.body != null)
				{
					scrolling_height = dojo.byId(id+'_frame').contentDocument.body.scrollHeight;
					scrolling_width = dojo.byId(id+'_frame').contentDocument.body.scrollWidth;
				}
			}
		}
		catch(e)
		{
			scrolling_height = 1;//dojo.byId(id+'_frame').contentDocument.body.scrollHeight;
			scrolling_width = 1;//dojo.byId(id+'_frame').contentDocument.body.scrollWidth;
		}
	}
	else
	{
		//canvas without frame
		scrolling_height = zsite_canvas_scroll_height[id];
		scrolling_width = zsite_canvas_scroll_width[id];
	}

	var scrolling_control_width = zsite_control_widths[id];//dojo.html.getContentWidth(id);
	var scrolling_control_height = zsite_control_heights[id];//dojo.html.getContentHeight(id);

	if(smooth == 0)
	{
		zsite_canvas_scroll_h_pos[id] = zsite_canvas_scroll_h_pos[id] + value;
		if(zsite_canvas_scroll_h_pos[id] < 0)
		{
//			value = zsite_canvas_scroll_h_pos[id] - value;
			zsite_canvas_scroll_h_pos[id] = 0;
//			value = zsite_canvas_scroll_h_pos[id] - value;
		}
//		if(zsite_canvas_scroll_h_pos[id] > (canvas_control_width-34 - zsite_scroll_thr_width[id]))
//		{
//		     value = zsite_canvas_scroll_h_pos[id] - value;
//		     zsite_canvas_scroll_h_pos[id] = canvas_control_width-34 - zsite_scroll_thr_width[id];
//		     value = zsite_canvas_scroll_h_pos[id] - value;
//		}

		var scrolling_area_part = (parseFloat(zsite_control_widths[id]-zsite_scroll_control_size)/parseFloat(scrolling_width));
		if(scrolling_area_part > 1.0)
			scrolling_area_part = 1.0;
	
		//scroll throb position
		dojo.byId(id+"_scroll_h_thr").style.marginLeft = zsite_scroll_control_size + (scrolling_area_part*zsite_canvas_scroll_h_pos[id])/scrolling_width + "px";
	
	}
	else
	{
		zsite_canvas_scroll_h_left[id] = zsite_canvas_scroll_h_left[id] + value;
		zsite_canvas_scroll_h_speed[id] = zsite_canvas_scroll_h_left[id]*0.35;
		scroll_h_smooth(id);
	}

//	var real_value = value*(canvas_width-canvas_control_width)/(canvas_control_width-34-zsite_scroll_thr_width[id])

	//scroll handler
	eval(zsite_canvas_scroll_h_handler[id]+"('"+id+"', "+value+", 0);");
	//canvas_scroll(id, 0, 0);
}




















function scroll_v_smooth(id)
{
//	dojo.byId("debug").innerHTML = Math.random()+"   "+scroll_h_left+"    "+scroll_h_speed;

	if((zsite_canvas_scroll_v_left[id] > 0)&&(zsite_canvas_scroll_v_speed[id] > 0)&&((zsite_canvas_scroll_v_left[id] - zsite_canvas_scroll_v_speed[id]) < 0))
	{
		scroll_v(id, zsite_canvas_scroll_v_left[id], 0);
		zsite_canvas_scroll_v_left[id] = 0;
		zsite_canvas_scroll_v_speed[id] = 0;
		return;
	}
	else if((zsite_canvas_scroll_v_left[id] < 0)&&(zsite_canvas_scroll_v_speed[id] < 0)&&((zsite_canvas_scroll_v_left[id] - zsite_canvas_scroll_v_speed[id]) > 0))
	{
		scroll_v(id, zsite_canvas_scroll_v_left[id], 0);
		zsite_canvas_scroll_v_speed[id] = 0;
		zsite_canvas_scroll_v_left[id] = 0;
		return;
	}
	else
	{
		zsite_canvas_scroll_v_left[id] = zsite_canvas_scroll_v_left[id] - zsite_canvas_scroll_v_speed[id];
		scroll_v(id, zsite_canvas_scroll_v_speed[id], 0);
		zsite_canvas_scroll_v_speed[id] = zsite_canvas_scroll_v_speed[id] * 0.8;
		if(Math.abs(zsite_canvas_scroll_v_speed[id]) < 1)
		{
			if(zsite_canvas_scroll_v_speed[id] < 0) zsite_canvas_scroll_v_speed[id] = -1;
			else zsite_canvas_scroll_v_speed[id] = 1;
		}
	}

	if(zsite_canvas_scroll_v_left[id] != 0) setTimeout("scroll_v_smooth('"+id+"');", 10);
	return false;
}

function scroll_v_click(id)
{
	if((prevposy-dojo._docScroll().top > dojo._abs(dojo.byId(id+"_scroll_v_thr")).y)&&
		(prevposy-dojo._docScroll().y < (dojo._abs(dojo.byId(id+"_scroll_v_thr")).y+dojo._getContentBox(dojo.byId(id+"_scroll_v_thr")).h)))
	{       
		//click is somehow passed if clicking on scroll grip
		return;
	}

	if(prevposy > dojo._abs(dojo.byId(id+"_scroll_v_thr_img")).y)
	{
		scroll_v(id, 50, 0/*1*/);
	}
	else
	{
		scroll_v(id, -50, 0/*1*/);
	}
}






function scroll_h_smooth(id)
{
//	dojo.byId("debug").innerHTML = Math.random()+"   "+scroll_h_left+"    "+scroll_h_speed;

	if((zsite_canvas_scroll_h_left[id] > 0)&&(zsite_canvas_scroll_h_speed[id] > 0)&&((zsite_canvas_scroll_h_left[id] - zsite_canvas_scroll_h_speed[id]) < 0))
	{
		scroll_h(id, zsite_canvas_scroll_h_left[id], 0);
		zsite_canvas_scroll_h_left[id] = 0;
		zsite_canvas_scroll_h_speed[id] = 0;
		return;
	}
	else if((zsite_canvas_scroll_h_left[id] < 0)&&(zsite_canvas_scroll_h_speed[id] < 0)&&((zsite_canvas_scroll_h_left[id] - zsite_canvas_scroll_h_speed[id]) > 0))
	{
		scroll_h(id, zsite_canvas_scroll_h_left[id], 0);
		zsite_canvas_scroll_h_speed[id] = 0;
		zsite_canvas_scroll_h_left[id] = 0;
		return;
	}
	else
	{
		zsite_canvas_scroll_h_left[id] = zsite_canvas_scroll_h_left[id] - zsite_canvas_scroll_h_speed[id];
		scroll_h(id, zsite_canvas_scroll_h_speed[id], 0);
		zsite_canvas_scroll_h_speed[id] = zsite_canvas_scroll_h_speed[id] * 0.8;
		if(Math.abs(zsite_canvas_scroll_h_speed[id]) < 1)
		{
			if(zsite_canvas_scroll_h_speed[id] < 0) zsite_canvas_scroll_h_speed[id] = -1;
			else zsite_canvas_scroll_h_speed[id] = 1;
		}
	}

	if(zsite_canvas_scroll_h_left[id] != 0) setTimeout("scroll_h_smooth('"+id+"');", 10);
	return false;
}

function scroll_h_click(id)
{
	if((prevposx > dojo._abs(dojo.byId(id+"_scroll_h_thr")).x)&&
		(prevposx < (dojo._abs(dojo.byId(id+"_scroll_h_thr")).x+dojo._getContentBox(dojo.byId(id+"_scroll_h_thr")).w)))
	{
		//click is somehow passed if clicking on scroll grip
		return;
	}

	if(prevposx > dojo._abs(dojo.byId(id+"_scroll_h_thr_img")).x)
	{
		scroll_h(id, 50, 1);
	}
	else
	{
		scroll_h(id, -50, 1);
	}
}




/*
function zsite_control_scroll(id, valx, valy)
{
	var canvas_height = zsite_control_heights[id];
	var canvas_width = zsite_control_widths[id];

	if(zsite_canvas_scrollx[id] == null)
	{
		zsite_canvas_scrollx[id] = 0;
		zsite_canvas_scrolly[id] = 0;
	}

	zsite_canvas_scrollx[id] += valx;
	zsite_canvas_scrolly[id] += valy;

	var scr_width = zsite_control_widths[id] - 32 -16 - ((zsite_control_widths[id]-32) * (zsite_control_widths[id]-32) / canvas_width);
	var scr_height = zsite_control_heights[id] - 32 -16 - ((zsite_control_heights[id]-32) * (zsite_control_heights[id]-32) / canvas_height);

	dojo.byId(id).scrollLeft = zsite_canvas_scrollx[id];
	dojo.byId(id).scrollTop = zsite_canvas_scrolly[id];

//	alert(id);

	//draw in status bar information
//	dojo.byId("debug").innerHTML = "Scroll to L:"+Math.ceil((0-((canvas_scroll_h_pos-15)*(canvas_width-canvas_control_width+18)/scr_width)))+"px H:"+Math.ceil(0-((canvas_scroll_v_pos-15)*(canvas_height-canvas_control_height+18)/scr_height))+"px";

//    alert(valy);

	//reposition objects
//	for(var a = 0; a < canvas_objects.length; a++)
//	{
//		var cobject = canvas_objects[a];
//		cobject['top'] += valy;
//		cobject['left'] += valx;
//	}


//	dojo.byId("object1").style.background="url(shot.png) "+Math.ceil(0-((canvas_scroll_h_pos-15)*(canvas_width-canvas_control_width+18)/scr_width))+"px "+Math.ceil(0-((canvas_scroll_v_pos-15)*(canvas_height-canvas_control_height+18)/scr_height))+"px no-repeat";

	return false;
}
*/

