function select_count(key,cnt) {
cnt = cnt.replace(",",".");
cnt = cnt.replace(/\.+/g,".");
cnt = cnt.replace(/\,+/g,".");
cnt = cnt.replace(/\s+/g, '');
var ed = document.formgoods['edizm'+key+''].value;
	if(ed > 0) {
	var prc = document.formgoods['prc'+key+'_'+ed+''].value
	var bnd = document.formgoods['bnd'+key+'_'+ed+''].value
	prc = prc.split(',')
	bnd = bnd.split(',')
	var st = 1
	var cn = 0
		if(bnd.length > 0) {
			for (var i=0;i<bnd.length;i++) {
				if(st == 1) {
					if(i >= (bnd.length - 1)) {
					cn = prc[i]
					st = 2
					}
					else if (cnt < (bnd[i]*100)/100) {
					cn = prc[i]
					st = 2
					}
				}
			}
		}
	document.getElementById("cena" + key).innerHTML = Math.round(cn)
	var stoim = ''+Math.round(cn*cnt*100)/100+''
		if(isNaN(stoim) == true) {
		document.formgoods['count'+key+''].value = '1';
		document.getElementById("stoim" + key).innerHTML = ''+Math.round(cn*100)/100+''
		}
		else {
		stoim = stoim.replace(".",",")
		document.formgoods['count'+key+''].value = cnt;
		document.getElementById("stoim" + key).innerHTML = stoim
		}
	}
}
function send_order(i) {
var c = document.formgoods['count'+i+''].value;
c = c.replace(",",".");
c = c.replace(/\s+/g, '');
var e = document.formgoods['edizm'+i+''].value;
var u = document.formgoods['url'].value;
var link = '/send_order.php?a=1&c='+c+'&e='+e+'&i='+i+'&u='+u+'';
window.location.href=link;
}
function del_order(i) {
var u = document.formgoods['url'].value;
var link = '/send_order.php?a=2&i='+i+'&u='+u+'';
window.location.href=link;
}
function getXmlHttp() {
var xmlhttp;
try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } }
	if(!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); }
return xmlhttp;
}
function ajgetxmlfopt() {
var sa = document.otbor['selarr'].value
var idg = document.otbor['idgroup'].value
var fid = document.otbor['form_id'].value
var saval = new Array()
var selid = new Array()
var selopt = new Array()
var selname = new Array()
var pid = ''
sa = sa.split(',')
	if(sa.length > 0) {
		for (var i=0;i<sa.length;i++) {
		selopt[sa[i]] = document.getElementById('selopt_'+sa[i]+'');
		selid[sa[i]] = document.getElementById('selid_'+sa[i]+'');
		selname[sa[i]] = document.getElementById('seloptname_'+sa[i]+'');	
			if(selid[sa[i]].options[selid[sa[i]].selectedIndex].value != 'undefined') {	
			saval[sa[i]] = selid[sa[i]].options[selid[sa[i]].selectedIndex].value
				if(saval[sa[i]] != '') {
				saval[sa[i]] = selid[sa[i]].options[selid[sa[i]].selectedIndex].value
				pid += ''+saval[sa[i]]+','
				}
			selname[sa[i]].style.color = '#999';
			selopt[sa[i]].innerHTML = '<select id="selid_'+sa[i]+'" name="'+sa[i]+'" style="width:200px;" OnChange="javascript:ajgetxmlfopt();"><option value=""></option></select>';
			}
		}
	}
	if(sa != '' && idg != '' && fid != '') {
	var http = getXmlHttp();
	http.open('get', '/service/modules/ajgetxmlfopt.php?sa='+sa+'&pid='+pid+'&idg='+idg+'&fid='+fid+'', true);
		http.onreadystatechange=function() {
			if(http.readyState != 4) {
			return
			}
		clearTimeout(timeout)
			if(http.readyState == 4 && http.status == 200) {
			var response=http.responseXML
			var feeditems=response.getElementsByTagName("item")
			var countitem=response.getElementsByTagName("countitem")
				if(countitem.length > 0) {
				var hgfhfg = countitem[0].firstChild.nodeValue
				document.otbor['getitem'].value = 'Выбрать '+hgfhfg+' товаров'
				}
			var selindexval;
			var selindextxt;
				if(feeditems.length > 0) {
				var con = '';
				var s = '';
				selindexval = '';
				selindextxt = '';
				var seloptdicid;
				var sid;
					for (var i=0;i<feeditems.length;i++) {
					seloptdicid = feeditems[i].getElementsByTagName("seloptdicid")
						if(seloptdicid.length > 0) {
						sid = seloptdicid[0].firstChild.nodeValue
						selindexval = feeditems[i].getElementsByTagName("selindexval")
						selindextxt = feeditems[i].getElementsByTagName("selindextxt")
							if(selindexval.length > 0) {
							con = '<option value=""></option>'
								for (var j=0;j<selindexval.length;j++) {
								sval = selindexval[j].firstChild.nodeValue
								stxt = selindextxt[j].firstChild.nodeValue
									if(saval[sid] == sval) {
									con += '<option value="'+sval+'" selected>'+stxt+'</option>'
									}
									else {
									con += '<option value="'+sval+'">'+stxt+'</option>'
									}
								}
							}
						selopt[sid].innerHTML = '<select id="selid_'+sid+'" name="'+sid+'" style="width:200px;" OnChange="javascript:ajgetxmlfopt();">'+con+'</select>'
						selname[sid].style.color = '#000';
						}
					}
				}
			}
			else {
			handleError("Соединение отсутствует")
			}
		}
	var timeout = setTimeout( function() { http.abort(); }, 10000);
	http.send(null);
	}
}
function handleError(message) {
alert("Ошибка: "+message)
}