function getClientWidth() {return document.compatMode == 'CSS1Compat' && !window.opera ? document.documentElement.clientWidth : document.body.clientWidth;}
function getClientHeight() {return document.compatMode=='CSS1Compat' && !window.opera ? document.documentElement.clientHeight : document.body.clientHeight;}

function showImage(src, 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>\n");
	wnd.document.write("<"+"script language='JavaScript'>\n");
	wnd.document.write("<!--\n");
	wnd.document.write("function KeyPress(event)\n");
	wnd.document.write("{\n");
	wnd.document.write("	if(event.keyCode == 27)\n");
	wnd.document.write("		window.close();\n");
	wnd.document.write("}\n");
	wnd.document.write("//-->\n");
	wnd.document.write("</"+"script>\n");
	wnd.document.write("<title>Схема проезда</title></head>\n");
	wnd.document.write("<body onClick=\"window.close();\" topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" onKeyPress=\"KeyPress(event)\">\n");
	wnd.document.write("<img src=\""+src+"\" border=\"0\" alt=\""+alt+"\">");
	wnd.document.write("</body>");
	wnd.document.write("</html>");
	wnd.document.close();
}


function openLinkInNewWindow(link) {
	var href = link.href;
	var width = 800;
	var height = 800;
	var left = 200;
	var top = 50;
	window.open(link.href,"","scrollbars=yes,resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
	return false;
}

function selectPayTypes() {
	var selShippingType = document.getElementById('buy_inp_shipping_type');
	var selPayType = document.getElementById('buy_inp_pay_type');
	if(selShippingType.selectedIndex != -1) {
		if(selShippingType.options[selShippingType.selectedIndex].value == 'self') {
			selPayType.options[2] = new Option ("Наличными в офисе компании", "cache");
		}
		else if(selShippingType.options[selShippingType.selectedIndex].value == 'inMoscow') {
			selPayType.options[2] = new Option("Наличный расчет","nal");
		}
		else {
			selPayType.options[2] = null;
		}
	}
}
