var stopLineAnimation2 = false;
var tps2;
var listLines2;

function ClearLines2 (lines) {
	if (lines)
		for (var i=0; i<lines.length; ++i) {
			document.getElementById (lines[i][0]).style.left = '0px';
			document.getElementById (lines[i][0]).style.top = '0px';
			document.getElementById (lines[i][0]).style.width = '1px';
			document.getElementById (lines[i][0]).style.height = '1px';
		}
}

function HideLines2 (lines) {
	if (lines)
		for (var i=0; i<lines.length; ++i)
			document.getElementById (lines[i][0]).style.visibility = 'hidden';
}

function ShowLines2 (lines) {
	if (lines)
		for (var i=0; i<lines.length; ++i)
			document.getElementById (lines[i][0]).style.visibility = 'visible';
}
		
function InitMenuLines2 (left, top, top0) {
	window.clearInterval (tps2);
	
	ClearLines2 (listLines2);
	
	document.getElementById ('page-lines').style.left = left + 'px';
	document.getElementById ('page-lines').style.top = top + 'px';
	
	listLines2 = Array (Array ('line-page-01', 0, top0, 8, 'X'),
					   Array ('line-page-02', 8, top0, (top0<200?80:0), 'Y'),
					   Array ('line-page-03', 8, top0, top0-13, 'Y', -1),
					   Array ('line-page-04', 8, 21, 60, 'X'),
					   Array ('line-page-05', 260, 21, 360, 'X'),
					   Array ('line-page-06', 620, 18, 38, 'Y'));
	
	document.getElementById ('line-page-01').style.left = listLines2[0][1] + 'px';
	document.getElementById ('line-page-01').style.top = listLines2[0][2] + 'px';
	
	ShowLines2 (listLines2);
	
	tps2 = window.setInterval ('DrawLines2 (listLines2, 0)', 20);
}

function DrawLines2 (lines, current_id) {
	if (!lines || stopLineAnimation2)
		return;
		
	var line = lines[current_id];
		
	var obj = document.getElementById (line[0]);
	var current = parseInt ((line[4] == 'X' ? obj.style.width : obj.style.height));

	if (current <= line[3]) {
		if (line[4] == 'X') {
			obj.style.width = current + 10 + 'px';
			
			if (line[5] == -1)
				obj.style.left = parseInt (obj.style.left) - 10 + 'px';
		}
		else {
			obj.style.height = current + 10 + 'px';
			
			if (line[5] == -1)
				obj.style.top = parseInt (obj.style.top) - 10 + 'px';
		}
	}
	else {
		if (line[4] == 'X')
			obj.style.width = line[3] + 'px';
		else {
			obj.style.height = line[3] + 'px';
			if (line[5] == -1)
				obj.style.top = line[2]-line[3] + 'px';
		}
			
		window.clearInterval (tps2);
		if (current_id < lines.length-1) {
			++current_id;
			
			document.getElementById (lines[current_id][0]).style.left = lines[current_id][1] + 'px';
			document.getElementById (lines[current_id][0]).style.top = lines[current_id][2] + 'px';
			tps2 = window.setInterval ('DrawLines2 (listLines2, '+current_id+')', 20);
		}
	}
}
