function region(e){
	arr=Array(0,250,450,0,100,250,280,380);
	dst=document.getElementById("dost");
	if(e<8&&e!=0){
		document.getElementById("tphtxt_"+4).innerHTML='';
		document.getElementById("tpht_"+1).style.display="block";
		document.getElementById("tphe_"+1).style.display="block";
		document.getElementById("tpht_"+2).style.display="block";
		document.getElementById("tphe_"+2).style.display="block";
		document.getElementById("tpht_"+3).style.display="block";
		document.getElementById("tphe_"+3).style.display="block";
		document.getElementById("tpht_"+4).style.display="none";
		document.getElementById("tphe_"+4).style.display="none";
		document.getElementById("tpht_"+5).style.display="none";
		document.getElementById("tphe_"+5).style.display="none";
		document.getElementById("tpht_"+6).style.display="none";
		document.getElementById("tphe_"+6).style.display="none";
money=document.getElementsByName("mail_money")[0];
		clearSelect(money);
var opt=document.createElement("option");
var opt1=document.createElement("option");
var opt2=document.createElement("option");
opt.text="Наличными курьеру";
opt.value=0;
opt1.text="Яндекс money";
opt1.value=2;
opt2.text="Оплата через Банк";
opt2.value=3;
try{
money.add(opt,money.options[null]);
money.add(opt1,money.options[null]);
money.add(opt2,money.options[null]);
}
catch (x){
money.add(opt,null);
money.add(opt1,null);
money.add(opt2,null);
}
		dst.innerHTML=arr[e]+" руб.";
		document.getElementById("price").innerHTML=parseInt(dst.innerHTML)-(-parseInt(document.forms["f_mail"].elements["price"].value))+" руб.";
	}
	else if(e>8){
		document.getElementById("tpht_"+1).style.display="none";
		document.getElementById("tphe_"+1).style.display="none";
		document.getElementById("tpht_"+2).style.display="none";
		document.getElementById("tphe_"+2).style.display="none";
		document.getElementById("tpht_"+3).style.display="none";
		document.getElementById("tphe_"+3).style.display="none";
		if(e>8){
		document.getElementById("tpht_"+3).style.display="block";
		document.getElementById("tphe_"+3).style.display="block";
		document.getElementById("tpht_"+4).style.display="block";
		document.getElementById("tphe_"+4).style.display="block";
		document.getElementById("tpht_"+5).style.display="block";
		document.getElementById("tphe_"+5).style.display="block";
		document.getElementById("tpht_"+6).style.display="block";
		document.getElementById("tphe_"+6).style.display="block";
		money=document.getElementsByName("mail_money")[0];
		clearSelect(money);
var opt=document.createElement("option");
var opt1=document.createElement("option");
var opt2=document.createElement("option");
opt.text="Наличными курьеру";
opt.value=0;
opt1.text="Яндекс money";
opt1.value=2;
opt2.text="Оплата через Банк";
opt2.value=3;
try{
money.add(opt1,money.options[null]);
money.add(opt2,money.options[null]);
}
catch (x){
money.add(opt1,null);
money.add(opt2,null);
}	
		v=document.forms["f_mail"].elements["mail_index"].value;
		if(v>0)delivery(v);
		}
	}
if(e==0||e==8){
		document.getElementById("tpht_"+1).style.display="none";
		document.getElementById("tphe_"+1).style.display="none";
		document.getElementById("tpht_"+2).style.display="none";
		document.getElementById("tphe_"+2).style.display="none";
		document.getElementById("tpht_"+3).style.display="none";
		document.getElementById("tphe_"+3).style.display="none";
		document.getElementById("tpht_"+4).style.display="none";
		document.getElementById("tphe_"+4).style.display="none";
		document.getElementById("tpht_"+5).style.display="none";
		document.getElementById("tphe_"+5).style.display="none";
		document.getElementById("tpht_"+6).style.display="none";
		document.getElementById("tphe_"+6).style.display="none";
}
}
function delivery(e){
	ar1=Array('Агинский Бурятский АО','Амурская область','Бурятия Республика','Еврейская АО','Иркутская область','Камчатская область','Приморский край','Саха (Якутия) Республика','Сахалинская область','Усть-Ордынский Бурятский АО','Хабаровский край','Читинская область');
	ar2=Array('Корякский авт. окр.','Магаданская область','Ненецкий АО','Таймырский (Долгано-Ненецкий АО)','Чукотский авт. окр.','Эвенкийский АО');
	dst=document.getElementById("dost");
	k=160;
	v=document.forms["f_mail"].elements["mail_region"].value;
	v=document.forms["f_mail"].elements["mail_region"].options[v].text;
	v=v.substring(2);
	if(in_array(v,ar1))k=195;
	else if(in_array(v,ar2))k=270;
	col1=document.getElementById("col").innerHTML;
	price1=parseInt(document.forms["f_mail"].elements["price"].value);
	if(e==2){
money=document.getElementsByName("mail_money")[0];
clearSelect(money);
var opt=document.createElement("option");
opt.text="Наложенный платеж";
opt.value=1;
try{
money.add(opt,money.options[null]);
}
catch (x){
money.add(opt,null);
}
	document.getElementById("tphtxt_"+4).innerHTML='Оплата при получении заказа на почте (наложенный платеж).<br>Внимательно изучите информацию про сбор <a target="_blank" href="http://durmanoff.ru/index.php?id=8">наложенного платежа</a><br>Срок доставки: 3-14 дней';}
	else {
		money=document.getElementsByName("mail_money")[0];
		clearSelect(money);
var opt=document.createElement("option");
var opt1=document.createElement("option");
var opt2=document.createElement("option");
opt.text="Наличными курьеру";
opt.value=0;
opt1.text="Яндекс money";
opt1.value=2;
opt2.text="Оплата через Банк";
opt2.value=3;
try{
money.add(opt1,money.options[null]);
money.add(opt2,money.options[null]);
}
catch (x){
money.add(opt1,null);
money.add(opt2,null);
}
}
	if(e==1)document.getElementById("tphtxt_"+4).innerHTML='Предоплата <br>Срок доставки: 7-21 дней';
	if(e==0)document.getElementById("tphtxt_"+4).innerHTML='';
	if(e==2)dst.innerHTML=Math.round(price1*(4/100)-(-190)-(-10*col1))+" руб.";
	if(e==1)dst.innerHTML=Math.round(price1*(4/100)-(-k)-(-10*col1))+" руб.";
	document.getElementById("price").innerHTML=parseInt(dst.innerHTML)-(-parseInt(document.forms["f_mail"].elements["price"].value))+" руб.";
}
function in_array(wh, wher) {
    for(var i=0; i<wher.length; i++)
        if(wh == wher[i]) 
            return true;
    return false;
}
function clearSelect(oListbox)
{
  for (var i=oListbox.options.length-1; i >= 0; i--)
  {
      oListbox.remove(i);
  }
}

