/***** функции подсветки строк при наведении *****/

function tover(q)

{

	q.children.tags('a')[0].style.color = "#6ed77c";

	q.style.cursor = 'pointer';

}



function trtover(q)

{

	q.style.backgroundColor = '#6ed77c';

	q.style.cursor = 'pointer';

}



function tout(q)

{

	q.children.tags('a')[0].style.color = "#e9e9e9";

}



function trtout(q)

{

	q.style.backgroundColor = '#FFFFFF';

}



function vipover(q)

{

	q.style.backgroundColor = '#f7f7f7';

	q.style.cursor = 'pointer';

}



function vipout(q)

{

	q.style.backgroundColor = '#f7f7f7';

}



function LmUp(path)

{

	window.location.href = path;

}



/***** функция отправки письма (открывается новое окно) *****/

function openSend(type, id)

{

	myWin = open("sendusermail.php?mail="+type+"&id="+id, "displayWindow", "width=600,height=600,status=no,toolbar=no,menubar=no,location=no,resizable=no");

}



function admOpenSend(type, id)

{

	myWin = open("admsendusermail.php?mail="+type+"&id="+id, "displayWindow", "width=600,height=800,status=no,toolbar=no,menubar=no,location=no,resizable=no");

}



/***** Функция перезагрузки CKAPTCHA *****/

function reload()

{

	var mess;

	switch (getCookie('reml'))

	{

		case 'ua':

					mess = 'Натиснить, щоб обновити';

					break;

		case 'rus':

		default:

					mess = 'Нажмите, чтобы обновить';

					break;

	}		



	var rndval = new Date().getTime(); 

	document.getElementById('bot-img').innerHTML = '<a onclick="reload(); return false;" href="#"><img src="capt/capt.php?rndval=' + rndval + '" border="0" width="120" height="60" title="' + mess + '"></a>';

}



/***** Функция закрывает некоторые поля для редактирования (в админке, настройка VIP) *****/

function SelectShowVip()

{

  if (document.adminvip_edit.show_only_vip.value==1)

  {

     document.adminvip_edit.show_only_vip_perpage.readOnly=false;

     document.adminvip_edit.show_vipv_main_count.readOnly=true;

     document.adminvip_edit.show_vipr_main_count.readOnly=true;

     document.adminvip_edit.show_v_main_count.readOnly=true;

     document.adminvip_edit.show_r_main_count.readOnly=true;

  }

  else

  {

     document.adminvip_edit.show_only_vip_perpage.readOnly=true;

     document.adminvip_edit.show_vipv_main_count.readOnly=false;

     document.adminvip_edit.show_vipr_main_count.readOnly=false;

     document.adminvip_edit.show_v_main_count.readOnly=false;

     document.adminvip_edit.show_r_main_count.readOnly=false;

  }

}



/***** Функция расчитывает килобайты из байтов *****/

function ByteToKByte(b, id)

{

	kb = ((b * 1) / 1024).toFixed(1);

	//kb = kb.toFixed(1);

	document.getElementById(id).title = kb + ' Kb';

}



/***** Функция подтверждения удаления записей *****/

function ConfirmSubmit()

{

	var mess;

	switch (getCookie('reml'))

	{

		case 'ua':

					mess = 'Видалити помічені записи?';

					break;

		case 'rus':

		default:

					mess = 'Удалить помеченные записи?';

					break;

	}		



	if (window.confirm(mess))

	{

		return true;

	}

	else

	{

		return false;

	}

}



function ConfirmDelete()

{

	var mess;

	switch (getCookie('reml'))

	{

		case 'ua':

					mess = 'Ви упевнені?';

					break;

		case 'rus':

		default:

					mess = 'Вы уверены?';

					break;

	}		



	if (window.confirm(mess))

	{

		return true;

	}

	else

	{

		return false;

	}

}



function TextAreaLenght(t, c, n, mn)

{

    var s;

    var tfbt = tfet = '';

	var tc = t.value.length;

    var fr = true;



	var mess1;

	var mess2;

	switch (getCookie('reml'))

	{

		case 'ua':

					mess1 = 'Ви можете ввести не більше ';

					mess2 = ' символів!';

					break;

		case 'rus':

		default:

					mess1 = 'Вы можете ввести не более ';

					mess2 = ' символов!';

					break;

	}		



    if (tc > c)

    {

        s = t.value;

        s = s.substring(0, c);

        t.value = s;

        tc = t.value.length;



        alert(mess1 + c + mess2);



        fr = false;

    }



    if (tc > c - 15)

    {

        tfbt = '<font color="#ff0000">';

        tfet = '</font>';

    }

        
	if(mn==0){
    	document.getElementById(n).innerHTML = tfbt + tc + tfet + '/' + c;
	}else{
		__cnt=tfbt + tc + tfet;
		if(__cnt<mn)__cnt='<font color="#ff0000">'+__cnt+'</font>';
    	document.getElementById(n).innerHTML = __cnt + '/' + c;
	}



	return fr;

}



function chLang(lang)

{

	if (lang && getCookie('reml') !== lang)

	{

		switch (lang)

		{

			case 'ua':

					document.cookie = 'reml = ua'

					break;

			case 'rus':

			default:

					document.cookie = 'reml = rus'

					break;

		}



		location.reload();



		if (window.frames['agree'])

		{

			window.frames['agree'].location = 'template/pages/' + lang + '/agreement.html';

		}

	}

	else

	{

		return false;

	}



	return true;

}



function getCookie(name)

{

	var cookie = ' ' + document.cookie;

	var search = ' ' + name + '=';

	var setStr = null;

	var offset = 0;

	var end = 0;



	if (cookie.length > 0)

	{

		offset = cookie.indexOf(search);



		if (-1 !== offset)

		{

			offset += search.length;

			end = cookie.indexOf(';', offset)



			if (-1 === end)

			{

				end = cookie.length;

			}



			setStr = unescape(cookie.substring(offset, end));

		}

	}



	return(setStr);

}
