$(function(){
	var path = window.location.pathname;
	$('#nav li a').each(function(){
		if (this.href.indexOf(path) != -1) {
			$(this).parent().addClass('selected').append( $('<strong/>').append($(this).contents()) );
			$(this).remove();
		}
	});
});

function openWindow(url, name, options){
	var nw = window.open(url, name, [
			'left='  +options.x,
			'top=' + options.y,
			'width=' + options.width,
			'height=' + options.height,
			'resizable=no',
			'toolbar=no',
			'scrollbars=no',
			'status=no'
		].join(', '));
	nw.focus();
	return nw;
}

var w1, w2; //открытые окна

function goToSecond() {
	w1.close();
	w2.close();
	location.href = '/death/';
}

function showEscape() {
	var wnd1 = {width: 930, height: 630},
		wnd2 = {width: 420, height:270};
	
	var pos_x = Math.round((window.screen.availWidth - wnd1.width) / 2);
	var pos_y = Math.round((window.screen.availHeight - wnd1.height) / 2);

	// сначала открываем маленькое окно
	w2 = openWindow('/escape/back.html', 'webweb2', {
		x: pos_x + 655, 
		y: pos_y + 141, 
		width: wnd2.width, 
		height: wnd2.height
	});
	
	w1 = openWindow('/escape/', 'webweb1', {
		x: pos_x, 
		y: pos_y, 
		width: wnd1.width, 
		height: wnd1.height
	});
}

var w1, w2; //открытые окна

$(function(){
	$('#nav li:first a, #open a').click(function(/* Event */ evt) {
		showEscape();
		evt.preventDefault();
		return false;
	});
});
