/* Выделение всех checkbox на странице 
Источник: http://css.yandex.net/css/mail/mail.js */
function CheckAll(Element,Name)
{
	if(typeof(document.getElementById) != 'undefined') 
	{		
		thisCheckBoxes = Element.parentNode.parentNode.parentNode.getElementsByTagName('input');
		for (i = 1; i < thisCheckBoxes.length; i++)
		{
			if (thisCheckBoxes[i].name == Name)
			{
				thisCheckBoxes[i].checked = Element.checked;
			}
			else if (thisCheckBoxes[i].id == Name)
			{
				thisCheckBoxes[i].checked = Element.checked;
			}			
		}
	}
}



/* Выделение всех checkbox и строк в таблице */
function check_all_checkbox_tr(Element,checkboxName,trName,trClassname,trStyleBgcolor)
{
	if(typeof(document.getElementById) != 'undefined') 
	{	
		/* Выделение всех checkbox в таблице */	
		thisCheckBoxes = Element.parentNode.parentNode.parentNode.getElementsByTagName('input');
		for (i = 1; i < thisCheckBoxes.length; i++)
		{
			if (thisCheckBoxes[i].name == checkboxName)
				thisCheckBoxes[i].checked = Element.checked;
			else if (thisCheckBoxes[i].id == checkboxName)
				thisCheckBoxes[i].checked = Element.checked;			
		}

		/* Выделение всех строк в таблице содержащих выделенные checkbox */
		thisTr = Element.parentNode.parentNode.parentNode.getElementsByTagName('tr');
		i2=1;
		for (i = 1; i < thisTr.length; i++)
		{	
			if (thisTr[i].id == trName)
			{
				if ((trClassname!='' && thisTr[i].className=='' && thisCheckBoxes[i2].checked!=false) || (trStyleBgcolor!='' && thisTr[i].style.backgroundColor=='' && thisCheckBoxes[i2].checked!=false) || thisCheckBoxes[i2].checked==true)
				{
					if(trClassname != '')
						thisTr[i].className = trClassname;
					else if(trStyleBgcolor != '')
						thisTr[i].style.backgroundColor = trStyleBgcolor;
				}
				else
				{
					if(trClassname != '')
						thisTr[i].className = '';
					else if(trStyleBgcolor != '')
						thisTr[i].style.backgroundColor = '';
				}
				i2++;
			}			
		}

	}
}



/* Ограничение количества введённых символов в textarea */
function textarea_maxlength(oTextarea,count)
{
	l=oTextarea.value.length;
	if((l)>count) oTextarea.value=oTextarea.value.substring(0,count);
}