var t;
var pos_box = 0;
var scroll_in_progress=0;

function start_scroll(direction,img_name,img_src){
	//alert(direction + ' ' + scroll_in_progress);
	if (scroll_in_progress!=1) {
		
		scroll_in_progress=1;
		document[img_name].src=img_src;
		scroll(direction);
	}
}

function scroll(direction)
//direction: up=1, down=0;
// up and down are relative to what u want
{
	if (scroll_in_progress == 0){
		return;
		}
	v=document.getElementById('container');
	w=document.getElementById('container_list');
	delay = 1;
	// alert(pos_box);
	if (w.style.top.length > 0){
		pos_box = w.style.top.substring(0,w.style.top.length-2) * 1;
		// top_data = w.style.top;
		// if(top_data=='') pos_box = 0;
		// else pos_box = top_data.substring(0,w.style.top.length-2) * 1;
	}
	if (direction == 0){
		// alert('pos_box:'+pos_box+', '+(pos_box + w.clientHeight) + '>' + (v.clientHeight + 1));
		if (pos_box + w.clientHeight > v.clientHeight + 1){
			pos_box -= 2;
			w.style.top = pos_box;
			t=setTimeout("scroll("+direction+")",delay);
		} else
			clearTimeout(t);
	}
	else if (direction == 1){
		if (pos_box < 0){
			pos_box += 2;
			w.style.top = pos_box;
			t=setTimeout("scroll("+direction+")",delay);
		} else
			clearTimeout(t);
	}
}

function stop_scroll(img_name,img_src){
	clearTimeout(t);
	document[img_name].src=img_src;
	scroll_in_progress=0;
}

//-------------------------------------------------------horizontális scrollozás-------------------------------------------------------

var t_horizontal;
var pos_horizontal = 0;
var scroll_in_progress_horizontal=0;

function start_scroll_horizontal(direction,img_name,img_src){
	//alert(direction + ' ' + scroll_in_progress_horizontal);
	if (scroll_in_progress_horizontal!=1) {
		
		scroll_in_progress_horizontal=1;
		document[img_name].src=img_src;
		scroll_horizontal(direction);
	}
}

function scroll_horizontal(direction){
	// direction: left=1, right=0;
	// left and right are relative to what u want
	if (scroll_in_progress_horizontal == 0){
		return;
		}
	v=document.getElementById('container_horizontal');
	w=document.getElementById('container_list_horizontal');
	delay = 1;
	if (w.style.left.length > 0)
		pos_horizontal = w.style.left.substring(0,w.style.left.length-2) * 1;
	if (direction == 0){
		if (pos_horizontal + w.clientWidth > v.clientWidth + 1){
			pos_horizontal -= 2;
			w.style.left = pos_horizontal;
			t_horizontal=setTimeout("scroll_horizontal("+direction+")",delay);
		} else
			clearTimeout(t_horizontal);
	}
	else if (direction == 1){
		if (pos_horizontal < 0){
			pos_horizontal += 2;
			w.style.left = pos_horizontal;
			t_horizontal=setTimeout("scroll_horizontal("+direction+")",delay);
		} else
			clearTimeout(t_horizontal);
	}
}

function stop_scroll_horizontal(img_name,img_src){
	clearTimeout(t_horizontal);
	document[img_name].src=img_src;
	scroll_in_progress_horizontal=0;
}

function selectProductColor(p_color_id,p_max_color_count,p_id_front){
	//alert(p_color_id+'-'+p_max_color_count+'-'+p_id_front);
	var i;
	for (i=1;i<=p_max_color_count;i=i+1){
		if(i==p_color_id){
			document.getElementById(p_id_front+i).style.display = "inline";
		}
		else{
			document.getElementById(p_id_front+i).style.display = "none";
		}
	}
}
