// JavaScript Document
function showAbout($id)
	{
	
	$td_id = $id+'1';
	if  (document.getElementById($td_id).style.display == 'none')
		{
		if (window.navigator.appName != 'Microsoft Internet Explorer')	document.getElementById($td_id).style.display = 'table-row'
		else document.getElementById($td_id).style.display = 'block';
		document.getElementById($id).innerHTML = '<img src="http://www.tvoedelo.ru/plastcalc/images/arrow.gif" width="14" height="14"/>';
		}
	else
		{
		document.getElementById($td_id).style.display = 'none';
		document.getElementById($id).innerHTML = '<img src="http://www.tvoedelo.ru/plastcalc/images/q.jpg" width="14" height="14"/>';
		}
	}
var $time;
var $cost;
var $mult;
var $cost1;
var $time1;

function calculate()
	{
		$time = 0;
		$cost = 0;
		$time1 = 0;
		$cost1 = 0;
		
//press_number

		theGroup = document.form1.press_number;
		if (theGroup[0].checked) {
			$time += 0;
			$mult = 1;
		}
		if (theGroup[1].checked) {
			$time += 10;
			$mult = 2;
		}
//difficulty		
		if (document.form1.difficulty.checked) {
			$time +=14;
			$cost = 60000;
			document.form1.draw.disabled = false;
			$cost +=20000;
		}
		else {
			$cost = 45000;
			document.form1.draw.disabled = true;
			document.form1.draw.checked = false;
		}
//draw
		if (document.form1.draw.checked) {
			$cost -=10000;
		}
		else {
			$time +=21;
		}
//shine		
		theGroup = document.form1.shine;
		if (theGroup[2].checked || theGroup[1].checked) {
			$time += 3;
			$cost += 12000;
		}
//unit_number
		$x = document.form1.unit_number.value;
		document.getElementById('warning1').innerHTML = '';
		document.getElementById('warning2').innerHTML = '';
		document.getElementById('warning3').innerHTML = '';
		$cost1 = 0;	
		if ($x<=50)
			{
				$cost1 = 0;	
			}
		if ($x>50 && $x<=150)
			{
				$cost1 = $x*50-2500;	
			}
		if  ($x>150 && $x<=500)
			{
				$cost1 = $x*35;	
			}
		if ($x>500 && $x<=750)
			{
				$cost1 = $x*30;	
			}
		if ($x>750 && $x<=900)
			{
				$cost1 = $x*25;	
			}
		if ($x>900)
			{
				$cost1 = $x*20;	
			}
		document.form1.price_det.value = $cost1;
		if ($x>0) $time1 = Math.floor($x/201)+ 1;
//color
		theGroup = document.form1.color;
		if (theGroup[1].checked || theGroup[2].checked || theGroup[3].checked || theGroup[4].checked || theGroup[5].checked || theGroup[6].checked) {
			if ($x<2000) $cost1 += 2000;
		}
		if (theGroup[6].checked) {
			document.getElementById('warning3').innerHTML = 'Требуется дополнительное уточнение сроков.';
		}
		if (theGroup[1].checked || theGroup[2].checked || theGroup[3].checked || theGroup[4].checked || theGroup[5].checked || theGroup[0].checked) {
			document.form1.color_alt.value = '';
		}
//transp
		theGroup = document.form1.transp;
		if (theGroup[1].checked) {
			$cost1 += 3000;
		}
//vis
		theGroup = document.form1.vis;
		if (theGroup[1].checked || theGroup[2].checked) {
			$cost1 += 3000;
			document.getElementById('warning3').innerHTML = 'Требуется дополнительное уточнение сроков.';
		}
//result
		$cost*=$mult;
		document.getElementById('result_1').innerHTML = $cost;
		document.getElementById('time_1').innerHTML = $time;
		document.getElementById('result_2').innerHTML = $cost1;
		document.getElementById('time_2').innerHTML = $time1;
		document.getElementById('result_3').innerHTML = $cost1 + $cost;
		document.getElementById('time_3').innerHTML = $time1 + $time;
		document.getElementById('details_number').innerHTML = $x;
		document.form1.total_price.value = $cost1 + $cost;
		document.form1.total_time.value = $time1 + $time;
	}
function enableRadio ($x, $x1, $y)
	{	
		$z = document.form1.color;
		var $z1 = document.getElementById($x1).value
		if ($z1) $z[$y].checked = 'true'
			else $z[0].checked = 'true';
		calculate();
	}	
function clearText ($id)
	{
		if (!document.getElementById($id).innerHTML) document.getElementById($id).innerHTML = 'Впишите текст Вашего сообщения';
		if (document.getElementById($id).innerHTML == 'Впишите текст Вашего сообщения') document.getElementById($id).innerHTML = ''
	}
