function s_click(subtype,id){
	if(subtype.match('_'+id)==null){
		sel[subtype]=id;
//		price=document.getElementById(name).value;
		$("input[name='"+subtype+"']").each(function(i, sel){
			newprice=$('#'+sel.id+'_cost').val()-$('#'+subtype+'_'+id+'_cost').val();
			if(newprice<0)
				$('#'+sel.id+'_price').html('<b>'+newprice+'</b>');
			else
				$('#'+sel.id+'_price').html('<b>+'+newprice+'</b>');
		});
	}else{
		if($('#'+subtype+'_'+id).attr('checked'))
			sel[subtype]=id;
		else
			sel[subtype]=null;
	}
	total=0;

// clearing summary blocks
	$("#summary_top").html('');
	$("#summary_bottom").html('');
	for(s in sel){
		if(sel[s] != null){
			subject=s.replace(/_/g,' ');
			choice=$("#"+s+"_"+sel[s]+"_name").html();

		// summary at top
			$("#summary_top").append(
				'<b>'+subject+'</b>:'
			);
			$("#summary_top").append(
				'&nbsp;&nbsp;'+choice+'<br>'
			);

		// summary at bottom
			$("#summary_bottom").append(
				'<b>'+subject+'</b>:'
			);
			$("#summary_bottom").append(
				'&nbsp;&nbsp;'+choice+'<br>'
			);

			total+=parseFloat($("#"+s+"_"+sel[s]+"_cost").val());
		}
	}
// filling totals at top & bottom
	$("#total_top").html(total);
	$("#total_bottom").html(total);
}
function toggle_order(mode){
	switch(mode){
		case 1: // show order form
			window.scrollTo(0,350);
			$("#configuration").hide();
			$("#configuration_complete").hide();
			descr=$("#summary_bottom").html();
			total=$("#total_bottom").html();
			$("#configuration_descr1").val(descr);
			$("#configuration_descr2").html(descr);
			$("#configuration_descr3").html(descr);
			$("#configuration_total1").val(total);
			$("#configuration_total2").html(total);
			$("#configuration_total3").html(total);
			$("#configuration_order").show();
			break;
		case 2: // show order confirmation
			window.scrollTo(0,350);
			var fail=0;
			if(!$("#_name").val().length){
				fail++;
				$("#_name").css("background-color","#F40000");
			}
			if(!$("#_email").val().length){
				fail++;
				$("#_email").css("background-color","#F40000");
			}
			if(fail)
				break;
			$.post("/ru/order.php",
				{
					_name: $("#_name").val(),
					_email: $("#_email").val(),
					_icq: $("#_icq").val(),
					_memo: $("#_memo").val(),
					description: $("#configuration_descr1").val(),
					price: $("#configuration_total1").val()
				}
			);
			$("#configuration").hide();
			$("#configuration_order").hide();
			$("#configuration_complete").show();
			break;
		case 0:	// return to configuration
		default:
			window.scrollTo(0,350);
			$("#configuration_order").hide();
			$("#configuration_complete").hide();
			$("#configuration").show();
			break;
	}
}
function openwindow(){
	wnd=window.open();
	descr=$("#summary_bottom").html();
	total=$("#total_bottom").html();
// header	
	wnd.document.write(' \
<html><head><title>Advanced Hosters :: Выделенные сервера : Оформление заказа</title><link rel="stylesheet" type="text/css" href="/ru/css/style.css" /></head> \
<body> \
	<div id=content> \
	<form method=post action=order.php> \
	<fieldset><legend>Контактная информация</legend> \
		<table border=0 width=100%> \
			<tr> \
				<td width=1><b>name</b></td> \
				<td><input type=text name=_name style="width:100%"></td> \
			</tr> \
			<tr> \
				<td><b>e-mail</b></td> \
				<td><input type=text name=_email style="width:100%"></td> \
			</tr> \
			<tr> \
				<td><b>icq</b></td> \
				<td><input type=text name=_icq style="width:100%"></td> \
			</tr> \
			<tr> \
				<td valign=top><b>comment</b></td> \
				<td><textarea name=_memo rows=5 style="width:100%"></textarea></td> \
			</tr> \
		</table> \
	</fieldset> \
	<input type=hidden name=description value="'+descr+'"> \
	<input type=hidden name=price value="'+total+'"> \
	');
	wnd.document.write('<fieldset><legend>Описение заказа</legend>');
	wnd.document.write(descr);
// bottom
	wnd.document.write('<div align=left><b>Итого</b>:&nbsp;'+total+'&nbsp;$&nbsp;</div>');
	wnd.document.write(' \
	</fieldset> \
	<div align=left>&nbsp;&nbsp;<input type=submit value="Заказать"></div> \
	</form> \
	</div> \
</body> \
</html> \
');
//	wnd.focus();
}

