var lInit = false;
var l1, l2, l3;

myLines.prototype.init = function(){
	var _my = this;
	
	jQuery("#content .extend span.line").each(function(){
		_my.lines.push({ base: this});
	})
	
	this.createLine();
	
	jQuery(window).resize(function(){
		_my.draw();
	})
}

function isSwitch(status, before){
	switch(status){
		case '.short':
			if(before){
				il.hide();
			} else {
				if(!lInit){
					initLogisticLines();
				}
				showLogisticLines();
				Labirint.focus();
			}
			break;
		case '.extend':
			if(!before){
				if(!il){
					il = new myLines("#Lines");	
					il.init();
				}
				il.show();
			} else {
				Labirint.blur();
				hideLogisticLines();
			}
			break;
	}
	if(!before){
		updateNavigation(status)
	}
	
}


function initInnerLine(){
	if(jQuery("#content-layout .full").length != 0){
		il = new myLines("#Lines");
		il.init();
		il.show();
	}
}

Labirint.isInit = function(){
	if(jQuery("#content-layout .full").length == 0){
		initLogisticLines();
	}
}

function initLogisticLines(){
	lInit = true;
	
	l1 = new AdaptiveLine(function(){
		return { x: 0, y: 0 }
	}, function(){
		_o = $('#Labirint');
		_ofs = _o.offset()
		return { x: _ofs.left-50, y: _ofs.top+_o.height()-15 }
	}, '#Lines');
	
	l2 = new AdaptiveLine(function(){
		_o = $('#Labirint');
		_ofs = _o.offset()
		return { x: _ofs.left+_o.width()+20 }
	}, function(){
		_o = $('#Labirint');
		_ofs = _o.offset()
		return { x: $("#finish").offset().left-30, y: _ofs.top+Labirint.finishY*Labirint.blockHeight+5 }
	}, '#Lines');
	
	l3 = new AdaptiveLine(function(){
		_o = $('#finish .end');
		_ofs = _o.offset()
		return { x: _ofs.left+10 }
	}, function(){
		_o = $('#finish .end');
		_ofs = _o.offset()
		return { x: $("#bodywidth").width(), y: _ofs.top+Math.round(_o.height()/2) }
	}, '#Lines');
	
	
}

function hideLogisticLines(){
	l1.hide(); l2.hide(); l3.hide();
}

function showLogisticLines(){
	l1.draw(); l2.draw(); l3.draw();
	l1.show(); l2.show(); l3.show();
}

