function ImgShw(ID, width, height, alt)
{
	var scroll = "no";
	var top=0, left=0;
	if(width > screen.width-10 || height > screen.height-28) scroll = "yes";
	if(height < screen.height-28) top = Math.floor((screen.height - height)/2-14);
	if(width < screen.width-10) left = Math.floor((screen.width - width)/2-5);
	width = Math.min(width, screen.width-10);
	height = Math.min(height, screen.height-28);
	var wnd = window.open("","","scrollbars="+scroll+",resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
	wnd.document.write(
		"<html><head>"+
		"<"+"script type=\"text/javascript\">"+
		"function KeyPress()"+
		"{"+
		"	if(window.event.keyCode == 27) "+
		"		window.close();"+
		"}"+
		"</"+"script>"+
		"<title>"+(alt == ""? "Картинка":alt)+"</title></head>"+
		"<body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" onKeyPress=\"KeyPress()\">"+
		"<img src=\""+ID+"\" border=\"0\" alt=\""+alt+"\" />"+
		"</body></html>"
	);
	wnd.document.close();
}

function AddToCompareList(code,selecthtmlelmname,addbtn)
{
 var req = new JsHttpRequest();
 req.onreadystatechange = function() {
        if (req.readyState == 4) {
           document.getElementById(selecthtmlelmname).bgColor = '#ccffcc';
           document.getElementById(addbtn).innerHTML =
           "<button onclick='DelFromCompareList("+code.toString( )+",\"elm"+code+"\",\"btn"+code+"\");return false'>Удалить</button>"+
           " Этот товар вами отложен <a href=\"/selecteditems.php\">перейти в список всех отложенных товаров</a>";
           }
     }
    req.open(null, 'addtocompare.php', true);
    req.send( {param: code.toString( )} );

}

function DelFromCompareList(code,selecthtmlelmname,addbtn)
{
 var req = new JsHttpRequest();
 req.onreadystatechange = function() {
        if (req.readyState == 4) {
           document.getElementById(selecthtmlelmname).bgColor = '#eeeeee';
           document.getElementById(addbtn).innerHTML =
           "<button onclick='AddToCompareList("+code+",\"elm"+code+"\",\"btn"+code+"\");return false'>Отложить</button>";
        }
    }
    req.open(null, 'delfromcompare.php', true);
    req.send( {param: code} );
}
