function t_calc(form)
{
   <!--   alert(form);-->
      form.Tw.value = form.Wd.options[form.Wd.selectedIndex].value;
      form.Tw1.value = form.Wdn.options[form.Wdn.selectedIndex].value;
      form.Tw2.value = form.Wdn.options[form.Wdn.selectedIndex].value-form.Wd.options[form.Wd.selectedIndex].value;

      form.Tr.value = Math.round(form.Rd.options[form.Rd.selectedIndex].value);
      form.Tr1.value =  Math.round(form.Rdn.options[form.Rdn.selectedIndex].value);
      form.Tr2.value =  Math.round(form.Rdn.options[form.Rdn.selectedIndex].value)-Math.round(form.Rd.options[form.Rd.selectedIndex].value);
      form.dTr1.value = Math.round(form.Rdn.options[form.Rdn.selectedIndex].value);

      form.Th.value = Math.round(form.Wd.options[form.Wd.selectedIndex].value*form.Hd.options[form.Hd.selectedIndex].value*2
      +form.Rd.options[form.Rd.selectedIndex].value*25.4);
      form.Th1.value = Math.round(form.Wdn.options[form.Wdn.selectedIndex].value*form.Hdn.options[form.Hdn.selectedIndex].value*2
      +form.Rdn.options[form.Rdn.selectedIndex].value*25.4);
      form.Th2.value = Math.round(form.Wdn.options[form.Wdn.selectedIndex].value*form.Hdn.options[form.Hdn.selectedIndex].value*2
      +form.Rdn.options[form.Rdn.selectedIndex].value*25.4)
      -Math.round(form.Wd.options[form.Wd.selectedIndex].value*form.Hd.options[form.Hd.selectedIndex].value*2
      +form.Rd.options[form.Rd.selectedIndex].value*25.4);

      form.Kl.value = (Math.round(form.Wdn.options[form.Wdn.selectedIndex].value*form.Hdn.options[form.Hdn.selectedIndex].value*2
      +form.Rdn.options[form.Rdn.selectedIndex].value*25.4)
      -Math.round(form.Wd.options[form.Wd.selectedIndex].value*form.Hd.options[form.Hd.selectedIndex].value*2
      +form.Rd.options[form.Rd.selectedIndex].value*25.4))/2;

      form.Sp1.value = Math.round((Math.round(form.Wdn.options[form.Wdn.selectedIndex].value*form.Hdn.options[form.Hdn.selectedIndex].value*2
      +form.Rdn.options[form.Rdn.selectedIndex].value*25.4)
      /Math.round(form.Wd.options[form.Wd.selectedIndex].value*form.Hd.options[form.Hd.selectedIndex].value*2
      +form.Rd.options[form.Rd.selectedIndex].value*25.4))*form.Sp.value*100)/100;

      form.Sp2.value = Math.round((form.Sp1.value-form.Sp.value)*100)/100


      form.Sp4.value = Math.round((1-form.Hdn.options[form.Hdn.selectedIndex].value*0.28)*form.Wdn.options[form.Wdn.selectedIndex].value/12.7)/2
}

function open_window(title, width, height, content)
{
    ScrWindow=window.open("","","toolbar=no,location=no,left=0,top=0,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,width="+width+",height="+height+"");
    if (ScrWindow != null && ScrWindow.opener == null) ScrWindow.opener=window;
    ScrWindow.document.open();
    ScrWindow.document.writeln ("<html><head><title>"+title+"</title></head><body>"+content+"</body></html>");
    ScrWindow.document.close();
}


function show_pr(n)
{
	if (n == 0)
	{
		$('co_act').className='invisible';
		$('de_act').className='visible marg_top_10';
		
		$('co_div').className='invisible';
		$('de_div').className='visible pad_left_20';
		
		$('chss').className='visible';
		
	}
	else
	{
		$('de_act').className='invisible';
		$('co_act').className='visible marg_top_10';
		
		$('de_div').className='invisible';
		$('co_div').className='visible pad_left_20';
		
		$('chss').className='invisible';
	}
	
}


function sh_par(n, b)
{
	if (n == 1)
	{
		$('label_div'+b).className='invisible';
		$('parametr_div'+b).className='visible';
		
		$('tt'+b).className='invisible';
		$('pp'+b).className='visible';
		
		$('act'+b).value=0;
	}
	else
	{
		$('label_div'+b).className='visible'
		$('parametr_div'+b).className='invisible'

		$('tt'+b).className='visible';
		$('pp'+b).className='invisible';
		
		$('act'+b).value=1;
	}
	
}

function buy(p_id, q)
{
	new Ajax.Request('/ajax.php', {method: 'post', parameters:'action=buy&product_id='+p_id+'&quantity='+q,
		onSuccess:function(req){
     	 var i;
			if(req.responseText)
			{
				i = $('basket_block');
				i.innerHTML = req.responseText;
				alert('Товар добавлен в корзину');
				
			}
    	}, 
		onFailure:function()
		{
			alert('error');
		}
		});
}

function show_models(label_id, sel_id, II)
{
	new Ajax.Request('/ajax.php', {method: 'post', parameters:'action=show_select&a=m&name='+sel_id+'&label_id='+label_id+'&ii='+II,
		onSuccess:function(req){
     	 var i;
			if(req.responseText)
			{
				i = $(sel_id+II);
				i.innerHTML = req.responseText;	
			}
    	}, 
		onFailure:function()
		{
			alert('error');
		}
		});
}

function show_engines(model_id, sel_id, II)
{
	new Ajax.Request('/ajax.php', {method: 'post', parameters:'action=show_select&a=e&name='+sel_id+'&model_id='+model_id+'&ii='+II,
		onSuccess:function(req){
     	 var i;
			if(req.responseText)
			{
				
				i = $(sel_id+II);
				i.innerHTML = req.responseText;	
			}
    	}, 
		onFailure:function()
		{
			alert('error');
		}
		});
}

function show_years(model_id, sel_id, II)
{
	new Ajax.Request('/ajax.php', {method: 'post', parameters:'action=show_select&a=y&name='+sel_id+'&model_id='+model_id+'&ii='+II,
		
		onSuccess:function(req){
     	 var i;
			if(req.responseText)
			{
				i = $(sel_id+II);
				i.innerHTML = req.responseText;
			}
    	},
    	
		onFailure:function()
		{
			alert('error');
		}
		
		});
}


