function dropLine(btn,tip){
	if(document.getElementById) {
		tr = btn;
		while (tr.tagName != 'DIV') tr = tr.parentNode;
		tr.parentNode.removeChild(tr);
		checkForLastLine(tip);
	}	
}
function addLine(btn,tip){
	if(document.getElementById) {
		tr = btn;
		while (tr.tagName != 'DIV') tr = tr.parentNode;
		var idSuffix = Math.round(Math.random()*1000);
		var newTr = tr.parentNode.insertBefore(tr.cloneNode(true),tr.nextSibling);
		checkForLastLine(tip);
	}	
}
function checkForLastLine(tip){
	btns = document.getElementsByName('drop'+tip);
	for (i = 0; i < btns.length; i++){
		btns[i].disabled = (btns.length == 1) ? true : false;
	}
}


function ListAnyIsChecked(list_name)
{ 
 var aa=false;
  for (i = 0; i < document.forms['anketa'].elements.length; i++)
   {
    var item = document.forms['anketa'].elements[i];
    if (item.name == list_name)
     {  if (item.checked) { aa=true; }  }
   }
  if (aa == false) {
  return false;
  } else {
  return true
  }
}

function checkListIsChecked(listname, light_switch){
	if (ListAnyIsChecked(listname)) { document.getElementById(light_switch).className='ok'; } else { document.getElementById(light_switch).className='error'; }
	checkAllFormFilled();
}

function checkInputHasValue(thisvalue, light_switch){
	if (thisvalue) { document.getElementById(light_switch).className='ok'; } else { document.getElementById(light_switch).className='error'; }
	checkAllFormFilled();
}

function to_click(){
	var o1=document.getElementById('opalubka_checkbox_id');
	var o2=document.getElementById('lesa_checkbox_id');
	var d1=document.getElementById('opalubka_div_id');
	var d2=document.getElementById('lesa_div_id');
	var light_switch='trebuemoe_oborudovanie_id';
	if(o1.checked) { d1.style.display="block"; } else { d1.style.display="none"; }
	if(o2.checked) { d2.style.display="block"; } else { d2.style.display="none"; }
	if ((o1.checked)||(o2.checked)) { document.getElementById(light_switch).className='ok'; } else { document.getElementById(light_switch).className='error'; }
	checkAllFormFilled();
}

function checkAllFormFilled(){
	var submitbutton = document.getElementById('submit_id');
	var submitswitchlight = document.getElementById('submit_id_2');
	var errorfound=false;
	var bbarray=document.getElementsByTagName('TD');
  for (i = 0; i < bbarray.length; i++)
   {
    var item = bbarray[i];
    if ((item.className == "error") & (item!=submitswitchlight)) { errorfound=true; }
   }
  if (errorfound == false) {
  submitbutton.disabled=false;
  submitswitchlight.className='ok';
  } else {
   //submitbutton.disabled=true;
   submitswitchlight.className='error';
  }
}

