function Onmenu(obj) 
{        
	obj.style.backgroundColor="#2B81DA"
} 

function Offmenu(obj) 
{        
	obj.style.backgroundColor="#CCCCCC"                         
}

function menuOff(obj) 
{        
	obj.style.backgroundColor="#666666"                         
}


function getDiv(name)
{
	var table = document.getElementById(name);
	if(table.style.display == 'none')
		table.style.display = 'block';
	else
		table.style.display = 'none';
}

function hideDiv(name)
{
	if(name == 'd1')
	{
		document.getElementById('d1').style.display = 'block';
		document.getElementById('d2').style.display = 'none';
		document.getElementById('d3').style.display = 'none';
		document.getElementById('d4').style.display = 'none';
		document.getElementById('d5').style.display = 'none';
	}
	else if(name == 'd2')
	{
		document.getElementById('d1').style.display = 'none';
		document.getElementById('d2').style.display = 'block';
		document.getElementById('d3').style.display = 'none';
		document.getElementById('d4').style.display = 'none';
		document.getElementById('d5').style.display = 'none';
	}
	else if(name == 'd3')
	{
		document.getElementById('d1').style.display = 'none';
		document.getElementById('d2').style.display = 'none';
		document.getElementById('d3').style.display = 'block';
		document.getElementById('d4').style.display = 'none';
		document.getElementById('d5').style.display = 'none';
	}
	else if(name == 'd4')
	{
		document.getElementById('d1').style.display = 'none';
		document.getElementById('d2').style.display = 'none';
		document.getElementById('d3').style.display = 'none';
		document.getElementById('d4').style.display = 'block';
		document.getElementById('d5').style.display = 'none';
	}
	else if(name == 'd5')
	{
		document.getElementById('d1').style.display = 'none';
		document.getElementById('d2').style.display = 'none';
		document.getElementById('d3').style.display = 'none';
		document.getElementById('d4').style.display = 'none';
		document.getElementById('d5').style.display = 'block';
	}
	
}


function go2(link)
{
	window.open(link,"2")
}

function go(link)
{
	window.location = link;
}

function validComm()
{
	var email = new String(document.comment.email.value);
	if (email.indexOf("@") == -1)
	{
		alert("Введите пожалуйста правильный адрес электронной почты.");
		document.comment.email.select();
		return false;
	}
	
	var field01 = new String(document.comment.autor.value);
	var field02 = new String(document.comment.text.value);
	var pass = true;
	if (field01.length == 0) {
		pass = false;
	}
	if (field02.length == 0) {
		pass = false;
	}
	if (pass == false)
	{
		alert ("Заполните пожалуйста все поля.");
		return false;
	}
}

function validForm()
{
	var email = new String(document.feedback.email.value);
	if (email.indexOf("@") == -1)
	{
		alert("Введите пожалуйста правильный адрес электронной почты.");
		document.feedback.email.select();
		return false;
	}
	
	var field01 = new String(document.feedback.subj.value);
	var field02 = new String(document.feedback.bodytxt.value);
	var pass = true;
	if (field01.length == 0) {
		pass = false;
	}
	if (field02.length == 0) {
		pass = false;
	}
	if (pass == false)
	{
		alert ("Заполните пожалуйста все поля.");
		return false;
	}
}


function validReg()
{
	var field01 = new String(document.regist.nick.value);
	var field02 = new String(document.regist.pass.value);
	var field03 = new String(document.regist.passtoo.value);
	var field04 = new String(document.regist.name.value);
	var pass = true;
	if (field01.length == 0) {
		pass = false;
	}
	if (field02.length == 0) {
		pass = false;
	}
	if (field03.length == 0) {
		pass = false;
	}
	if (field04.length == 0) {
		pass = false;
	}
	if (pass == false)
	{
		alert ("Ошибка! Заполните пожалуйста все поля.");
		return false;
	}
	
	var nick = new String(document.regist.nick.value);
	for (var x = 0; x < nick.length; x++)
	{
		if (nick.charCodeAt(x) < 48 
		|| (nick.charCodeAt(x) > 57 && nick.charCodeAt(x) < 65)
		|| (nick.charCodeAt(x) >90 && nick.charCodeAt(x) < 97)
		|| nick.charCodeAt(x) > 122)
		{
			alert ("Ошибка! Вводимая запись содержит символы отличные от букв и цифр.");
			document.regist.nick.value = "";
			document.regist.nick.select();
			return false;
		}
	}
	
	var porol = new String(document.regist.pass.value);
	for (var x = 0; x < porol.length; x++)
	{
		if (porol.charCodeAt(x) < 48 
		|| (porol.charCodeAt(x) > 57 && porol.charCodeAt(x) < 65)
		|| (porol.charCodeAt(x) >90 && porol.charCodeAt(x) < 97)
		|| porol.charCodeAt(x) > 122)
		{
			alert ("Ошибка! Вводимая запись содержит символы отличные от букв и цифр.");
			document.regist.pass.value = "";
			document.regist.pass.select();
			return false;
		}
	}
	
	var name = new String(document.regist.name.value);
	for (var x = 0; x < porol.length; x++)
	{
		if (name.charCodeAt(x) < 48 
		|| (name.charCodeAt(x) > 57 && name.charCodeAt(x) < 65)
		|| (name.charCodeAt(x) >90 && name.charCodeAt(x) < 97)
		|| name.charCodeAt(x) > 122)
		{
			alert ("Ошибка! Вводимая запись содержит символы отличные от букв и цифр.");
			document.regist.name.value = "";
			document.regist.name.select();
			return false;
		}
	}
	
	var password = new String(document.regist.pass.value);
	var retype = new String(document.regist.passtoo.value);
	if (password.valueOf() != retype.valueOf())
	{
		alert("Ошибка! Поля паролей не совпадают.");
		document.regist.passtoo.value ="";
		document.regist.pass.select();
		return false;
	}
	var email = new String(document.regist.email.value);
	if (email.indexOf("@") == -1)
	{
		alert("Ошибка! Введите пожалуйста правильный адрес электронной почты.");
		document.regist.email.select();
		return false;
	}
	if (document.regist.agree.checked == false)
	{
		alert("Ошибка! Необходимо подтвердить принятие условий, прежде чем продолжить.");
		return false;
	}
}


function go2edit(link, w, h)
{
	window.open(link,"2","width="+w+",height="+h+",resizable=no,scrollbars=no,dependent=yes")
}

function go2rest(link, w, h)
{
	window.open(link,"2","width="+w+",height="+h+",resizable=yes,scrollbars=yes,dependent=yes")
}

function deleteSubMenu(title, id)
{
	if(confirm ("ВНИМАНИЕ!\nВсе подразделы и объявления данного раздела будут удалены!\nВы действительно хотите удалить раздел " + title + "?"))
	{
		window.location='razdel.php?delSubRaz=true&id='+id;
	}
}

function toArchiv(title, id)
{
	if(confirm ("ВНИМАНИЕ!\nВы уверены, что хотите поместить новость \"" + title + "\" в архив?"))
	{
		window.location='news.php?toArchiv=true&id='+id;
	}
}

function toArchivOf(title, id)
{
	if(confirm ("ВНИМАНИЕ!\nВы уверены, что хотите поместить новость \"" + title + "\" в архив?"))
	{
		window.location='press_admin.php?toArchiv=true&id='+id;
	}
}

function delComm(title, id)
{
	if(confirm ("ВНИМАНИЕ!\nВы уверены, что хотите удалить коментарий " + title + " ?"))
	{
		window.location='?delComm=true&id='+id;
	}
}

function delNews(title, id)
{
	if(confirm ("ВНИМАНИЕ!\nВы уверены, что хотите удалить новость " + title + " ?"))
	{
		window.location='?delNews=true&id='+id;
	}
}

function delTopic(title, id)
{
	if(confirm ("ВНИМАНИЕ!\nВсе данные в базе будут уничтожены.\nВы уверены, что хотите удалить тему \"" + title + "\"?"))
	{
		window.location='forum_admin.php?delTopic=true&id='+id;
	}
}

function delPress(title, id)
{
	if(confirm ("ВНИМАНИЕ!\nВсе данные в базе будут уничтожены.\nВы уверены, что хотите удалить пресс-релиз \"" + title + "\"?"))
	{
		window.location='press_admin.php?delPress=true&id='+id;
	}
}

function delGal(title, id)
{
	if(confirm ("ВНИМАНИЕ!\nВсе данные в базе будут уничтожены.\nВы уверены, что хотите удалить галерею \"" + title + "\"?"))
	{
		window.location='gallery_admin.php?delGal=true&id='+id;
	}
}

function deleteCot(title, id)
{
	if(confirm ("ВНИМАНИЕ!\nВсе объявления данного раздела будут удалены!\nВы действительно хотите удалить раздел " + title + "?"))
	{
		window.location='razdel.php?delCot=true&id='+id;
	}
}


function getCurrentData()
{
	var theDate = new Date();
	document.addNews.month.value = theDate.getMonth() + 1;
	document.addNews.year.value = theDate.getYear();
	document.addNews.date.value = theDate.getDate();
	document.addNews.hour.value = theDate.getHours();
	document.addNews.minute.value = theDate.getMinutes();
}

function getDiv(name)
{
	var table = document.getElementById(name);
	if(table.style.display == 'none')
		table.style.display = 'block';
	else
		table.style.display = 'none';
	
}

function SelectGroup(course, curGroupe)
{
	var id, option, i = 0;
	var grSelect = document.getElementById('selectGroup');
	while(grSelect.options.length)
	{
		grSelect.options[0] = null;
	}
	i = 0;
	option = new Option('Подраздел','');
	grSelect.options[i] = option;
	i++;
	if(course != '')
	{
		if(grArray.length > 0 && grArray[course] && grArray[course].length > 0)
		{
			for(id in grArray[course])
			{
				option = new Option(grArray[course][id],id);
				grSelect.options[i] = option;
				if(id == curGroupe)
					grSelect.options[i].selected = true;
				i++;
			}
		}
	}
}

function SelectPred(groupe, curPred)
{
	var id, option, i = 0;
	var prSelect = document.getElementById('selectPred');
	while(prSelect.options.length)
	{
		prSelect.options[0] = null;
	}
	i = 0;
	option = new Option('Котерет','');
	prSelect.options[i] = option;
	i++;
	if(groupe != '')
	{
		if(prArray.length > 0 && prArray[groupe] && prArray[groupe].length > 0)
		{
			for(id in prArray[groupe])
			{
				option = new Option(prArray[groupe][id],id);
				prSelect.options[i] = option;
				if(id == curPred)
					prSelect.options[i].selected = true;
				i++;
			}
		}
	}
}

function showDate()
{
	var d;
	d = new Date('month dd, yyyy hh:mm:ss');
	document.write(temp.toLocaleString());
}