// Колличество форм
var num_of_orders = 0;

var current_print=0;
var models=new Array();
var colors=new Array();
var colors_pr=new Array();
var cur_orders=new Array();
var final_orders=new Array();
var clicked_content;
var click_img;
var oopen;
var clicked_hr;
var opened_order;
var current_item;
var sp1_price;
var sp2_price;
var spnum_pric;
var prcolids=new Array();
var prcolvals=new Array();

var modelscolors=new Array();

var prcolnames=new Array();
var def_colors=new Array();
var order_text;



// Функция добавления
function AddOrder(image_id, sizes, sizesi, price)
{
	if(!colors_pr[current_print])colors_pr[current_print]=new Array();
	// Увеличиваем колличество форм
	num_of_orders = num_of_orders+1;
	
	sizemas=sizes.split(',');
	sizeids=sizesi.split(',');
	var	cop='';
	var	cp='';
	
	if(current_item=='tshirt'){
		cop=colors_pr[current_print][image_id];
		cp=current_print
	} 
	cur_orders[num_of_orders]=new Array(image_id, cp, colors[image_id], price, cop, current_item);
	
	//Меняем содержимое блока
	var orders = document.getElementById('orders');
	var old_orders = orders.innerHTML;
	orders.innerHTML = old_orders + order_text;
	
	// Меняем картинку
	var shirt_pic = document.getElementById('shirt_pic');
	var new_pic_id = shirt_pic.id+'_'+num_of_orders;
	shirt_pic.id = new_pic_id;
	var new_pic = document.getElementById(new_pic_id);
	new_pic.src = 'image.php?model=' + image_id + '&color=' + colors[image_id] + '&print=' +current_print + '&item=' + current_item + '&pr_color=' + colors_pr[current_print][image_id];
	
	// Меняем ID блока
	var block_ordering = document.getElementById('block_ordering');
	var block_ordering_id = block_ordering.id+'_'+num_of_orders;
	block_ordering.id = block_ordering_id;

	// Меняем ID кнопки "Удалить"
	var ordering = document.getElementById('ordering');
	var ordering_id = ordering.id+'_'+num_of_orders;
	ordering.id = ordering_id;
	ordering.name=num_of_orders;
	
	if(current_item=='tshirt'){
	var sp1=document.getElementById('spina1');
	var sp1_id = sp1.id+'_'+num_of_orders;
	sp1.id = sp1_id;
	
	var sp1=document.getElementById('spina2');
	var sp1_id = sp1.id+'_'+num_of_orders;
	sp1.id = sp1_id;
	
	var sp1=document.getElementById('spinanum');
	var sp1_id = sp1.id+'_'+num_of_orders;
	sp1.id = sp1_id;
	}
	
	if(current_item=='tshirt'){
	var sp1=document.getElementById('size');
	var sp1_id = sp1.id+'_'+num_of_orders;
	sp1.id = sp1_id;
	var objSel = document.getElementById("size"+'_'+num_of_orders);
	objSel.options[0] = new Option("Выбрать", 0);
	for(i=0;i<sizeids.length;i++){
		objSel.options[objSel.options.length] = new Option(sizemas[i], sizeids[i]);		
	}
	}
	


	var sp1=document.getElementById('amount');
	var sp1_id = sp1.id+'_'+num_of_orders;
	sp1.id = sp1_id;
	UpdZakncalc();
}

// Функция удаления
function DeleteOrder(delid)
{
	var qwer=delid.split('_');
	var deleting_but=qwer[1];
	cur_orders[deleting_but]=new Array();
	
	var ord_block_id = 'block_ordering_' + deleting_but;
	var ord_block = document.getElementById(ord_block_id);	
	ord_block.style.display = 'none';
	
	UpdZakncalc();
}
function UpdZakncalc(){
	
	document.getElementById("zakncalc").style.display="none";
	for(i=1;i<=num_of_orders;i++){
		if(cur_orders[i]&&cur_orders[i][0]){
			document.getElementById("zakncalc").style.display="block";
			return;
		}
	}
}

function ChangeImg(img, model, color){
	colors[model]=color;
	if(colors_pr[current_print]) addf=colors_pr[current_print][model]; else addf='0';
	document.getElementById(img).src="image.php?model="+model+"&color="+color+"&print="+current_print + '&item=' + current_item + '&pr_color=' + addf + '&hash='+Math.round(Math.random()*10000);
	SetPrCol(current_print,color,model);
}

function SetPrCol(pr, col, mod){
	if(!colors_pr[pr]) colors_pr[pr]=new Array();
	colors_pr[pr][mod]=col;
	UpdateAllModels();
}
function UpdateAllModels(){
	
	for(i=0;i<models.length;i++){
		SendPOST(colors[models[i]]+'_'+current_print+'_'+models[i])
		if(!colors_pr[current_print]) colors_pr[current_print]=new Array();
		if(!colors_pr[current_print][models[i]]) colors_pr[current_print][models[i]]=def_colors[current_print];		document.getElementById('img'+models[i]).src="image.php?model="+models[i]+"&color="+colors[models[i]]+"&print="+current_print + '&item=' + current_item + '&pr_color=' + colors[models[i]];
	}
}


function SendPOST(data){
	ajaxSendPOST('image.php','q='+encodeURI(data), SendCallback);
}
function SendCallback(answer) {
	var b = answer.split("_");
	var aaa = document.getElementById('img'+b['1']).src
	var a = aaa.replace(/color=[0-9]{1,2}/, 'color='+b['0']);
	document.getElementById('img'+b['1']).src = a
}

function ajaxSendPOST(xmlpage,data,callback){
	var xmlh = null;
	if(window.XMLHttpRequest){
		xmlh = new XMLHttpRequest();
	}
	else
	try{
		xmlh = new ActiveXObject('Msxml2.XMLHTTP');
	}
	catch(ex) {
		xmlh = new ActiveXObject('Microsoft.XMLHTTP');
	}
	if(xmlh){
		xmlh.open('post', xmlpage, true);
		xmlh.onreadystatechange = function(x) { if(xmlh.readyState==4) callback(xmlh.responseText); }
		xmlh.setRequestHeader("Accept-Charset", "windows-1251");
		xmlh.setRequestHeader("Accept-Language","ru, en");
		xmlh.setRequestHeader("Connection", "close");
		xmlh.setRequestHeader("Content-length", data.length); // Длинна отправляемых данных
		xmlh.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlh.send(data); // Именно здесь отправляются данные
	}
}


function setCurPrint(print){
	current_print=print;
	UpdPrColors(print);
	UpdateAllModels()
}

function UPCM(print,model){
	colids=prcolids[print].split(',');
	colvals=prcolvals[print].split(':');
	colnames=prcolnames[print].split(':');
	var inht='';
	for(j=0;j<colids.length;j++){
		ddivs=colvals[j].split(',');
		var mcolors = modelscolors[model].split(',');
		for(jj=0;jj<mcolors.length;jj++){
      if(mcolors[jj]==colids[j]){
      inht+='<a href="" onclick="ChangeImg(\'img'+model+'\', '+model+', '+colids[j]+'); return false;" title="' + colnames[j] + '"><div class="color_div" style="background-color:#'+colvals[j]+'"></div></a>';
      }
		}
		
		
	}
	return inht;
}
function UpdPrColors(print){

	for(i=0;i<models.length;i++){
    if(document.getElementById('tscolor'+models[i]))
        document.getElementById('tscolor'+models[i]).innerHTML=UPCM(print,models[i]);
        
		if(document.getElementById('colpr'+models[i]))
			document.getElementById('colpr'+models[i]).innerHTML=UPCM(print,models[i]);
	}
}

function ShowOpl(img,st){
	document.getElementById('opl_pic').innerHTML='<img id="imgid" src="images/oplata.png" border=0>';
	document.getElementById('fade_div').style.height=document.getElementById('wrapper_1').scrollHeight+'px';
	//document.body.style.overflow='hidden';
	//document.body.style.paddingRight='18px';
	document.getElementById('fade_div').style.visibility='visible';
	
	document.getElementById('opl_window').style.display="block";
	
}

function CloseOpl(){
	document.getElementById('opl_window').style.display="none";
	if(!opened_order){
		document.getElementById('fade_div').style.height=0;
		document.getElementById('fade_div').style.visibility='hidden';
		//document.body.style.overflow='scroll';
		document.body.style.paddingRight='0px';
	}
}

function ShowInfo(img,st){
	if(opened_order){
		CloseOrdWnd();
		opened_order=1;
	}
	document.getElementById('info_pic').innerHTML='<img id="imgid" src="http://tvoyshop.com.ua/mother_folder_for_sites/pictures/' + img + '" border=0>';
	document.getElementById('fade_div').style.height=document.getElementById('wrapper_1').scrollHeight+'px';
	//window.style.overflow='hidden';
	//document.body.style.paddingRight='18px';
	
	document.getElementById('fade_div').style.visibility='visible';
	document.getElementById('fade_div').style.backgroundImage='none';
	document.getElementById('info_window').style.display="block";
	if(img=='ibox_big.png'){
		document.getElementById('ibox_hr').innerHTML='<a href="http://ukrbuy.com/misc/ibox.html" target=_blank><img id="imgid" src="pictures/ibox_sm.png" border=0></a>';
	}
	
}



function ShowShirt(img){
	document.getElementById('info_pic').innerHTML='<img id="imgid" src="' + img + '" border=0>';
	document.getElementById('fade_div').style.height=document.getElementById('wrapper_1').scrollHeight+'px';
	//document.body.style.overflow='hidden';
	//document.body.style.paddingRight='18px';
	document.getElementById('fade_div').style.visibility='visible';
	
	document.getElementById('info_window').style.display="block";
	
}

function CloseInfo(){
	document.getElementById('info_window').style.display="none";
	if(!opened_order){
		document.getElementById('fade_div').style.height=0;
		document.getElementById('fade_div').style.visibility='hidden';
		document.getElementById('fade_div').style.backgroundImage='url(../images/ajax-loader.gif)';
		//window.style.overflow='scroll';
		document.body.style.paddingRight='0px';
	}
	if(opened_order){
		ShowOrdWnd();
	}
	document.getElementById('ibox_hr').innerHTML='';
	if(oopen==1) {ShowOpl(); oopen=0;}
	
}

function ShowCont(img){
	document.getElementById('cont_pic').innerHTML='<img id="imgid" src="pictures/' + img + '" border=0>';
	document.getElementById('fade_div').style.height=document.getElementById('wrapper_1').scrollHeight+'px';
	//document.body.style.overflow='hidden';
	//document.body.style.paddingRight='18px';
	document.getElementById('fade_div').style.visibility='visible';
	
	document.getElementById('cont_window').style.display="block";
	
	
}

function CloseCont(){
	document.getElementById('cont_window').style.display="none";
	document.getElementById('fade_div').style.height=0;
	document.getElementById('fade_div').style.visibility='hidden';
	//document.body.style.overflow='scroll';
	document.body.style.paddingRight='0px';
}

function DoOrder(){
	for(i=1;i<=num_of_orders;i++){
		if(cur_orders[i][0]){
			var sp1='';
			var sp2='';
			var spnum='';
			var size='';
			if(cur_orders[i][5]=='tshirt'){
				sp1=document.getElementById('spina1_'+i).value;
				sp2=document.getElementById('spina2_'+i).value;
				spnum=document.getElementById('spinanum_'+i).value;
			}
			amount=document.getElementById('amount_'+i).value;
			if(cur_orders[i][5]=='tshirt'){
				var objSel = document.getElementById("size"+'_'+i);
				size=objSel.options[objSel.selectedIndex].value;
				if(size==0){alert('Не выбран размер!'); return;}
			}
			
					
			final_orders.push(new Array(cur_orders[i][0], cur_orders[i][1], cur_orders[i][2], sp1, sp2, spnum, amount, size, cur_orders[i][4], cur_orders[i][5]));
		}
		
	}
	
	if(final_orders.length) ShowOrdWnd(); else alert("Ничего не выбрано");
}

function ShowOrdWnd(){
	opened_order=1;
	document.getElementById('order_window').style.display="block";
	document.getElementById('fade_div').style.height='0px';
	//document.body.style.overflow='hidden';
	//document.body.style.paddingRight='18px';
	document.getElementById('fade_div').style.visibility='visible';
}

function CloseOrdWnd(){
	opened_order=0;
	//document.getElementById('order_window').style.display="none";
	document.getElementById('fade_div').style.height=0;
	document.getElementById('fade_div').style.visibility='hidden';
	//document.body.style.overflow='scroll';
	document.body.style.paddingRight='0px';
	final_orders=new Array();
}

function CrAjax()
{
    if (window.XMLHttpRequest) {
        try {
            return new XMLHttpRequest();
        } catch (e){}
    } else if (window.ActiveXObject) {
        try {
            return new ActiveXObject('Msxml2.XMLHTTP');
        } catch (e){
          try {
              return new ActiveXObject('Microsoft.XMLHTTP');
          } catch (e){}
        }
    }
    return null;
}

function getRequestBody(oForm, wt) {
   var aParams = new Array();
   for(var i = 0; i < oForm.elements.length; i++) {
   		if((!oForm.elements[i].value||oForm.elements[i].value=='0')&&oForm.elements[i].id!='user_dop'&&oForm.elements[i].id!='gettown'&&oForm.elements[i].id!='user_zip'&&oForm.elements[i].id!='user_kupon') return;
       var sParam = encodeURIComponent(oForm.elements[i].id);
       sParam += "=";
       sParam += encodeURIComponent(oForm.elements[i].value);
       aParams.push(sParam);
   }
  if(!wt) {
   for(i=0;i<final_orders.length;i++){
   	var sParam = encodeURIComponent("order"+i);
   	sParam += "=";
   	sParam += encodeURIComponent(final_orders[i].join('::'));
   	aParams.push(sParam);
   }
   var sParam = encodeURIComponent("amountoforders");
   sParam += "=";
   sParam += final_orders.length;
   aParams.push(sParam);
	}
   return aParams.join("&");
}

function FinOrder(){
	var oForm=document.getElementById('finorder_form');
	var sBody = getRequestBody(oForm,0);

	if(!sBody){alert('Все поля обязательны для заполнения!'); return false;}
	
	document.getElementById('fade_div').style.height="100%";
	
	var ajax=CrAjax();
	ajax.open("POST","ajax.php", true);
    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax.onreadystatechange = function() {
          if(ajax.readyState == 4) {
            if(ajax.status == 200) {
            	CloseOrdWnd();
              ShowWnd(ajax.responseText);
            } 
          }
        };
        
    ajax.send(sBody);
    document.getElementById('order_content').style.backgroundImage="none";
    document.getElementById('order_content').innerHTML='<table width=100% height=100%><tr><td valign="middle" align="center"><img src="images/ajax-loader.gif"></td></tr></table>';
}

function ContForm(){
	var oForm=document.getElementById('contact_form');
   	var sBody = getRequestBody(oForm,1);	
   	if(!sBody){
   		alert("Все поля обязательны к заполнению!");
   		return;
   	}
	var ajax=CrAjax();
	ajax.open("POST","contact.php", true);
    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax.onreadystatechange = function() {
          if(ajax.readyState == 4) {
            if(ajax.status == 200) {
              ContRes(ajax.responseText);
              CloseOrdWnd();
            } 
          }
        };
        
    ajax.send(sBody);	
}

function ChangeGoods(item){
	var ajax=CrAjax();
	ajax.open("GET","mainajax.php?item="+item, true);
    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    ajax.onreadystatechange = function() {
          if(ajax.readyState == 4) {
            if(ajax.status == 200) {
            	var code=ajax.responseText.split("::sep::");
            	eval(code[0]);
            	document.getElementById('main_content').innerHTML=code[1]; 
            	current_print='';            
            } 
          }
        };
        
    ajax.send(null);	
}


function ContRes(text){
	//document.getElementById('cont_form').style.display="none";
	document.getElementById('contact_form').reset();
	document.getElementById('cont_result').innerHTML=text;
}

function ShowWnd(text, offset){	
	if(!offset) offset=0;
	wnd=document.getElementById('success_wnd_content');
	pars=text.split(':');
	var uemail = document.getElementById('user_email').value
	if(pars[0]=='ibox'){
		wnd.innerHTML='<span style="color:#b99e00;">Спасибо за покупку!</span><br><br>Номер вашего заказа '+pars[1]+'<br>На е-мейл '+uemail+' выслана информация о заказе.<br><br>Приходите к нам еще :)<a href="/" style="position:absolute;top:5px;right:5px;"><img src="images/to_delete.png"/></a>';
	} else if(pars[0]=='nalikom'){
		wnd.innerHTML='<span style="color:#b99e00;">Спасибо за покупку!</span><br><br>Номер вашего заказа '+pars[1]+'<br>На е-мейл '+uemail+' выслана информация о заказе.<br><br>Приходите к нам еще :)<a href="/" style="position:absolute;top:5px;right:5px;"><img src="images/to_delete.png"/></a>';
	} else if(pars[0]=='bp'){
		wnd.innerHTML='<span style="color:#b99e00;">Спасибо за покупку!</span><br><br>Номер вашего заказа '+pars[1]+'<br>На е-мейл '+uemail+' выслана информация о заказе.<br><br>Приходите к нам еще :)<a href="/" style="position:absolute;top:5px;right:5px;"><img src="images/to_delete.png"/></a>';
	} else {
		wnd.innerHTML=text;
	}
	document.getElementById('fade_div').style.height=0+'px';
	document.location="#begin";
	wnd=document.getElementById("success_wnd")
	wnd.style.display="block";	
	
	document.getElementById('fade_div').style.height='0px';
	//document.body.style.overflow='hidden';
	//document.body.style.paddingRight='18px';
	document.getElementById('fade_div').style.visibility='visible';
	
}

function getKvit(id,sum){
	newWin=window.open('bp.php?id='+id+'&sum='+sum,'printWindow','Toolbar=0,Location=0,Directories=0,Status=0,Menubar=0,Scrollbars=0,Resizable=0');
	
	newWin.print();
}
/*
function doPrint(){
	document.getElementById("wrapper").style.display="none";
	document.getElementById("fade_div").style.display="none";
	var bg=document.body.backgroundImage;
	document.body.style.backgroundImage='';
	document.body.style.backgroundColor="#ffffff";
	print();
	document.body.backgroundImage=bg;
	document.getElementById("fade_div").style.display="block";
	document.getElementById("wrapper").style.display="block";
}*/
var oldIn;
function prepare(hide){
	if(hide){
		oldIn=document.body.innerHTML;
		document.body.style.backgroundImage='url()';
		document.body.innerHTML=document.getElementById('success_wnd').innerHTML;
		document.getElementById("prnbtn").style.display="none";
	} else {
		document.body.style.backgroundImage='url(images/fon_main.png)';
		document.body.innerHTML=oldIn;
		document.getElementById("prnbtn").style.display="block";		
	}
}
function doPrint(){
	pr = document.getElementById('success_wnd').innerHTML; 
	newWin=window.open('','printWindow','Toolbar=0,Location=0,Directories=0,Status=0,Menubar=0,Scrollbars=0,Resizable=0');
	newWin.document.open();
	newWin.document.write(pr);
	newWin.document.getElementById("prnbtn").style.display="none";
	newWin.document.close(); 
	
	newWin.print();
	

}

function CloseWnd(){
	wnd=document.getElementById('success_wnd');
	if(wnd.style.display=="block")
		document.location.href="index.php?nocount=1";
		
	
	wnd.style.display="none";	
	document.getElementById('fade_div').style.height=0;
	document.getElementById('fade_div').style.visibility='hidden';
	//document.body.style.overflow='scroll';
	document.body.style.paddingRight='0px';
	
}

function Calc(){
	var sum=0;
	for(i=1;i<=num_of_orders;i++){
		var psum=0;
		
		if(cur_orders[i][0]){
			psum=cur_orders[i][3];
			//alert(cur_orders[i][3]);
			if(cur_orders[i][5]=='tshirt'){
			sp1=document.getElementById('spina1_'+i).value;			
			sp2=document.getElementById('spina2_'+i).value;
			
			var objSel = document.getElementById("spinanum_"+i);
			spnum=objSel.options[objSel.selectedIndex].value;			
					
			if(sp1.length) psum+=sp1_price;
			if(sp2.length) psum+=sp2_price;
			if(spnum!='no') psum+=spnum_price;
			
			
			}
			amount=document.getElementById('amount_'+i).value;
			psum*=amount;
			sum+=psum;
			
		}
		
	}
	return sum;
}

 function dostavka_oplata(){
  var v = document.getElementById("dostavka").value
  
  switch(v){
    case '3':
      document.getElementById("oplata").innerHTML = "";
      
      objSelect1=document.createElement("option");
      objSelect1.innerHTML = 'Выбрать';
      objSelect1.value = '0';
      
      objSelect2=document.createElement("option");
      objSelect2.innerHTML = 'Наличными курьеру';
      objSelect2.value = 'nalikom';
      
      objSelect3=document.createElement("option");
      objSelect3.innerHTML = 'WebMoney';
      objSelect3.value = 'WebMoney';
      
      objSelect4=document.createElement("option");
      objSelect4.innerHTML = 'Банковский перевод';
      objSelect4.value = 'bp';
      
      objSelect5=document.createElement("option");
      objSelect5.innerHTML = 'iBox';
      objSelect5.value = 'iBox';
      
      document.getElementById("oplata").appendChild(objSelect1);
      document.getElementById("oplata").appendChild(objSelect2);
      document.getElementById("oplata").appendChild(objSelect3);
      document.getElementById("oplata").appendChild(objSelect4);
      document.getElementById("oplata").appendChild(objSelect5);
      
      document.getElementById('user_city').value = 'Харьков'
      document.getElementById('gettown').value = 'Харьков'
      document.getElementById('user_city').style.display = 'block'
      document.getElementById('gettown').style.display = 'none'
    break;
    case '4':
      document.getElementById("oplata").innerHTML = "";
      
      objSelect1=document.createElement("option");
      objSelect1.innerHTML = 'Выбрать';
      objSelect1.value = '0';
      
      objSelect2=document.createElement("option");
      objSelect2.innerHTML = 'Наличными курьеру';
      objSelect2.value = 'nalikom';
      
      objSelect3=document.createElement("option");
      objSelect3.innerHTML = 'WebMoney';
      objSelect3.value = 'WebMoney';
      
      objSelect4=document.createElement("option");
      objSelect4.innerHTML = 'Банковский перевод';
      objSelect4.value = 'bp';
      
      objSelect5=document.createElement("option");
      objSelect5.innerHTML = 'iBox';
      objSelect5.value = 'iBox';
      
      document.getElementById("oplata").appendChild(objSelect1);
      document.getElementById("oplata").appendChild(objSelect2);
      document.getElementById("oplata").appendChild(objSelect3);
      document.getElementById("oplata").appendChild(objSelect4);
      document.getElementById("oplata").appendChild(objSelect5);
      
      document.getElementById('user_city').value = ''
      document.getElementById('gettown').value = ''
      document.getElementById('user_city').style.display = 'none'
      document.getElementById('gettown').style.display = 'block'
    break;
    case '5':
      document.getElementById("oplata").innerHTML = "";
      
      objSelect1=document.createElement("option");
      objSelect1.innerHTML = 'Выбрать';
      objSelect1.value = '0';
      
      objSelect2=document.createElement("option");
      objSelect2.innerHTML = 'iBox';
      objSelect2.value = 'iBox';
      
      objSelect3=document.createElement("option");
      objSelect3.innerHTML = 'WebMoney';
      objSelect3.value = 'WebMoney';
      
      objSelect4=document.createElement("option");
      objSelect4.innerHTML = 'Банковский перевод';
      objSelect4.value = 'bp';
      
      document.getElementById("oplata").appendChild(objSelect1);
      document.getElementById("oplata").appendChild(objSelect2);
      document.getElementById("oplata").appendChild(objSelect3);
      document.getElementById("oplata").appendChild(objSelect4);
      
      document.getElementById('user_city').value = 'Харьков'
      document.getElementById('gettown').value = 'Харьков'
      document.getElementById('user_city').style.display = 'block'
      document.getElementById('gettown').style.display = 'none'
    break;
    case '6':
      document.getElementById("oplata").innerHTML = "";
      
      objSelect1=document.createElement("option");
      objSelect1.innerHTML = 'Выбрать';
      objSelect1.value = '0';
      
      objSelect2=document.createElement("option");
      objSelect2.innerHTML = 'iBox';
      objSelect2.value = 'iBox';
      
      objSelect3=document.createElement("option");
      objSelect3.innerHTML = 'WebMoney';
      objSelect3.value = 'WebMoney';
      
      objSelect4=document.createElement("option");
      objSelect4.innerHTML = 'Банковский перевод';
      objSelect4.value = 'bp';
      
      document.getElementById("oplata").appendChild(objSelect1);
      document.getElementById("oplata").appendChild(objSelect2);
      document.getElementById("oplata").appendChild(objSelect3);
      document.getElementById("oplata").appendChild(objSelect4);
      
      document.getElementById('user_city').value = '';
      document.getElementById('gettown').value = '';
      document.getElementById('user_city').style.display = 'block';
      document.getElementById('gettown').style.display = 'none';
    break;
    case '7':      
      document.getElementById("oplata").innerHTML = "";
      
      objSelect1=document.createElement("option");
      objSelect1.innerHTML = 'Выбрать';
      objSelect1.value = '0';
      
      objSelect2=document.createElement("option");
      objSelect2.innerHTML = 'iBox';
      objSelect2.value = 'iBox';
      
      objSelect3=document.createElement("option");
      objSelect3.innerHTML = 'WebMoney';
      objSelect3.value = 'WebMoney';
      
      objSelect4=document.createElement("option");
      objSelect4.innerHTML = 'Банковский перевод';
      objSelect4.value = 'bp';
      
      objSelect5=document.createElement("option");
      objSelect5.innerHTML = 'Оплата на почте';
      objSelect5.value = 'post';
      
      document.getElementById("oplata").appendChild(objSelect1);
      document.getElementById("oplata").appendChild(objSelect2);
      document.getElementById("oplata").appendChild(objSelect3);
      document.getElementById("oplata").appendChild(objSelect4);
      document.getElementById("oplata").appendChild(objSelect5);
      
      document.getElementById('user_city').value = ''
      document.getElementById('gettown').value = ''
      document.getElementById('user_city').style.display = 'block'
      document.getElementById('gettown').style.display = 'none'
    break;
    case '8':
      document.getElementById("oplata").innerHTML = "";
      
      objSelect1=document.createElement("option");
      objSelect1.innerHTML = 'Выбрать';
      objSelect1.value = '0';
      
      objSelect2=document.createElement("option");
      objSelect2.innerHTML = 'iBox';
      objSelect2.value = 'iBox';
      
      objSelect3=document.createElement("option");
      objSelect3.innerHTML = 'WebMoney';
      objSelect3.value = 'WebMoney';
      
      document.getElementById("oplata").appendChild(objSelect1);
      document.getElementById("oplata").appendChild(objSelect2);
      document.getElementById("oplata").appendChild(objSelect3);
      
      document.getElementById('user_city').value = ''
      document.getElementById('gettown').value = ''
      document.getElementById('user_city').style.display = 'block'
      document.getElementById('gettown').style.display = 'none'
    break;
  }
  return true
 }
 
 function get_town(a){
  document.getElementById('user_city').value = a.value
  if(a.value == 'enother'){
    document.getElementById('dostavka').value = '7'
    document.getElementById('user_city').style.display = 'block'
    a.style.display = 'none';
    a.value = '';
    document.getElementById('user_city').value = ''
  }
 }



function UpdSum(){
	document.getElementById('calc').innerHTML="<table align='center' width='648' style='background-image: url('../images/kalk.png') repeat-x;height:88px; '><tr><td style='color: #000000;'>Сумма заказа: "+Calc().toString()+" грн.</td><td><a onclick='DoOrder();' href='#ord_butt' name='ord_butt'><img alt='ОФОРМИТЬ ЗАКАЗ' src='images/qwerty.png'/></a></td><td align='center' valign='middle' width=80><img src='images/strelka.gif'></td></tr></table>";
}
