function textCounter(field,cf,maxlimit) {

if (field.value.length > maxlimit)

{

field.value = field.value.substring(0, maxlimit);

}



else

{

if((maxlimit - field.value.length)<10){

 document.getElementById(cf).style.color = "red";

}else{

 document.getElementById(cf).style.color = "black";

}

document.getElementById(cf).innerHTML = maxlimit - field.value.length;

}

}







function checkForm(t){



f = document.forms[0];



if(f.cost.value < 0.10){

f.cost.style.bgColor = "red";

}



}



function costP(){



var cur = document.forms[0].cost.value;

var Num = parseFloat(cur) + 1;

document.forms[0].cost.value = Num;

document.getElementById('cost').innerHTML = "0."+Num;



}



function costM(){



var cur = document.forms[0].cost.value;

if(cur > 10){

var Num = parseFloat(cur) - 1;

document.forms[0].cost.value = Num;

document.getElementById('cost').innerHTML = "0."+Num;

}



}






function CheckAll(Element,Name){
if(document.getElementById) {
	thisCheckBoxes = Element.parentNode.parentNode.parentNode.getElementsByTagName('input');
	for (i = 1; i < thisCheckBoxes.length; i++){
		if (thisCheckBoxes[i].name == Name){
			thisCheckBoxes[i].checked = Element.checked;
			Colorize(document.getElementById(thisCheckBoxes[i].id.replace('cb','tr')), thisCheckBoxes[i]);
		}
	}
	}
}

function Colorize(Element, CBElement){
if(document.getElementById) {
	if(Element && CBElement){
		Element.className = ( CBElement.checked ? 'selected' : 'default' );
	}
}
}

function CheckRadioTR(Element){
if(document.getElementById) {
	CheckTR(Element);
	thisTRs = Element.parentNode.getElementsByTagName('tr');
	for (i = 0; i < thisTRs.length; i++){
		if (thisTRs[i].id != Element.id && thisTRs[i].className != 'header') thisTRs[i].className = 'default';
	}
}
}

function CheckTR(Element){
if(document.getElementById) {
	thisCheckbox = document.getElementById(Element.id.replace('tr','cb'));
	thisCheckbox.checked = !thisCheckbox.checked;
	Colorize(Element, thisCheckbox);
}
}

function CheckCB(Element){
if(document.getElementById) {
	if(document.getElementById(Element.id.replace('cb','tr'))){Element.checked = !Element.checked;}
}
}


function check10(){

if(document.forms[0].cost.value < 0.10){
alert('Минимум - 0.10');
document.getElementById('addst').disabled = 'true';
document.getElementById('clickcost').style.color='red';
return false;
}else{
document.getElementById('addst').disabled = false;
document.getElementById('clickcost').style.color='#6B6B6B'

}

}


function getSelectedCheckbox(buttonGroup) {
   // Go through all the check boxes. return an array of all the ones
   // that are selected (their position numbers). if no boxes were checked,
   // returned array will be empty (length will be zero)
   var retArr = new Array();
   var lastElement = 0;
   if (buttonGroup[0]) { // if the button group is an array (one check box is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            retArr.length = lastElement;
            retArr[lastElement] = i;
            lastElement++;
         }
      }
   } else { // There is only one check box (it's not an array)
      if (buttonGroup.checked) { // if the one check box is checked
         retArr.length = lastElement;
         retArr[lastElement] = 0; // return zero as the only array value
      }
   }
   return retArr;
} // Ends the "getSelectedCheckbox" function

function getSelectedCheckboxValue(buttonGroup) {
   // return an array of values selected in the check box group. if no boxes
   // were checked, returned array will be empty (length will be zero)
   var retArr = new Array(); // set up empty array for the return values
   var selectedItems = getSelectedCheckbox(buttonGroup);
   if (selectedItems.length != 0) { // if there was something selected
      retArr.length = selectedItems.length;
      for (var i=0; i<selectedItems.length; i++) {
         if (buttonGroup[selectedItems[i]]) { // Make sure it's an array
            retArr[i] = buttonGroup[selectedItems[i]].value;
         } else { // It's not an array (there's just one check box and it's selected)
            retArr[i] = buttonGroup.value;// return that value
         }
      }
   }
   return retArr;
} // Ends the "getSelectedCheckBoxValue" function
