function popimg(url, title, width, height)
{
	str="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"><html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\">\n<title>Для себя только Best.</title>\n</head>\n<body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>\n<img src='"+url+"' alt='"+title+"'>\n</body>\n</html>";
	f_win = window.open(url ,"BigImage" ,'width='+width+',height='+height+',top='+((screen.height/2)-(height/2))+',left='+((screen.width/2)-(width/2))+',toolbar=no,scrollbars=no,resizable=yes,menubar=no,status=no,directories=no,location=no');
	f_win.document.writeln(str);
	f_win.focus();
	f_win.document.close();
}

function popup(url, title, width, height)
{
	f_win = window.open(url ,"" ,'width='+width+',height='+height+',top='+((screen.height/2)-(height/2))+',left='+((screen.width/2)-(width/2))+',toolbar=no,scrollbars=yes,resizable=yes,menubar=no,status=no,directories=no,location=no');
	f_win.focus();
}

function show_ps_size(id)
{
  var i=0;
  if(document.getElementById(id).style.display == 'none')
  {
    document.getElementById(id).style.display = 'block';
    for(i=1; i<=3; i++)
    {
      if(('p'+i) != id)
        document.getElementById('p'+i).style.display = 'none';
    }
  }
}

function show_ps_motor(id)
{
  var i=0;
  if(document.getElementById(id).style.display == 'none')
  {
    document.getElementById(id).style.display = 'block';
    for(i=4; i<=6; i++)
    {
      if(('p'+i) != id)
        document.getElementById('p'+i).style.display = 'none';
    }
  }
}


// Menu
var click_history = new Array;

Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};

function on(it) {
	var block = it.getElementsByTagName("ul")[0];

	//alert(click_history.length);
	
	if(block) {
		click_history.push([block.id, block.getAttribute("lev")]);		
		
		if(block.offsetHeight == 0) {
			close_menu();
			block.style.display='block';
		} else {
			if (((click_history[click_history.length-1] >= click_history[click_history.length-2]) || (click_history.length == 1)) && (click_history.length < 3 )) {
				block.style.display='none';
			}
		}
	}
}

function close_menu() {
	var i, j;
	var nar = new Array;
	
	if (click_history.length > 1) {
		for (j=1; click_history[click_history.length-j][1] != 1; j++) {
			nar.push(click_history[click_history.length-j][0]);
		}
		nar.push(click_history[click_history.length-j][0]);
	}
	
	for(i = 1; document.getElementById('u' + i); i++) {
		if(!nar.inArray('u' + i)) document.getElementById('u' + i).style.display = 'none';
	}
}
