function delComment(Comment_Id)
{
	if( confirm("Вы уверены, что хотите удалить комментарий?") )
		document.location.href="comment_remove.asp?id=" + Comment_Id;
}

function SearchFormSubmit()
{
	
	if( document.frmSearch.q.value.length == 0 )
	{
		alert ("Вы забыли написать строку для поиска!");
		document.frmSearch.q.focus();
		return false;
	}
	return true;
}

function doIRT (irt_id) {
	irt_row0.style.display = "inline";
	//irt_row.style.display = "inline";
	document.CommentForm.irt.value = irt_id;

	var strObj;
	strObj = "ctext" + irt_id + ".innerHTML";
	
	//irt_text.innerHTML = eval(strObj) + "<br>(<a href='#cfrm' onClick='javascript:undoIRT();'>Отменить режим ответа</a>)";
	irt_text.innerHTML = document.getElementById("ctext" + irt_id).innerHTML + "<br>(<a href='#cfrm' onClick='undoIRT(); return false;'>Отменить режим ответа</a>)";

	strObj = "cuser" + irt_id + ".innerHTML";
	//irt_user.innerHTML = eval(strObj);
	irt_user.innerHTML = document.getElementById("cuser" + irt_id).innerHTML;
	
	document.CommentForm.Comment.focus();
}

function undoIRT() {
	document.CommentForm.irt.value=0;
	irt_row0.style.display = "none";

	irt_text.innerHTML = "";
	irt_user.innerHTML = "";

	//irt_row.style.display = "none";
	//location.href="#";
}

function validateCommentForm() {
	//document.CommentForm.SubmitButton.disabled = true;
	
	if (document.CommentForm.UserName.value.length == 0){
		alert("Вы зашли как незарегистрированный пользователь. Заполните хотя бы поле Имя.");
		document.CommentForm.UserName.focus();
		return false;
		}
	
	if (document.CommentForm.Comment.value.length == 0){
		alert ("Вы забыли написать комментарий!");
		document.CommentForm.Comment.focus();
		return false;
		}
		
	return true;
}

function changeLocalPreview() {
	//alert (document.picpost.file.value);
	if(document.picpost.filework.value.length!=0) {
		document.LocalPreview.src="file://" + document.picpost.filework.value;
	}
	else 
	{
		//alert ("empty!");
		document.LocalPreview.src="http://www.nerve.ru/img/1x1.gif";
	}
}

function validatePostForm() {
	
	if (document.picpost.filework.value.length==0){
		alert ("Выберите файл");
		document.picpost.filework.focus();
		return false;
	}
	
	if (document.picpost.Caption.value.length==0) {
		alert ("Укажите название работы");
		document.picpost.Caption.focus();
		return false;
	}
	
	if (document.picpost.Category.value.length==0) {
		alert ("Выберите жанр");
		document.picpost.Category.focus();
		return false;
	}
	
	if (document.picpost.Tech.value.length==0) {
		alert ("Выберите жанр");
		document.picpost.Tech.focus();
		return false;
	}
	
	document.picpost.SubmitButton.disabled=true;
	return true;
}

function validatePostFormEdit() {
	
	if (document.picpost.Caption.value.length==0) {
		alert ("Укажите название работы");
		document.picpost.Caption.focus();
		return false;
	}
	
	if (document.picpost.Category.value.length==0) {
		alert ("Выберите жанр");
		document.picpost.Category.focus();
		return false;
	}
	
	if (document.picpost.Tech.value.length==0) {
		alert ("Выберите жанр");
		document.picpost.Tech.focus();
		return false;
	}
	
	document.picpost.SubmitButton.disabled=true;
	return true;
}

function validateProfileForm () {
	if (document.update_profile.newpass.value.length!=0) 
		if (document.update_profile.newpass.value!=document.update_profile.newpass_re.value) {
			//alert (document.update_profile.newpass);
			//alert (document.update_profile.newpass_re);
			alert ("Вы неправильно повторно ввели пароль");
			document.update_profile.newpass.focus();
			return false;
		}
	
	if (document.update_profile.User_Name.value.length==0){
		alert ("Без имени нельзя!");
		document.update_profile.User_Name.focus();
		return false;
	}
	
	return true;
}

function sendPass() {
	document.location.replace("sendpass.asp?mode=send&login_name=" + document.getElementById("logname").value);
}

function delWork(work_id)
{
	if( confirm("Вы уверены, что хотите удалить работу?") )
		document.location.replace("remove_work.asp?id=" + work_id);
}

function goUrl(strUrl)
{
	document.location.href = strUrl;
}

function SelectSmile(strTxtSmile)
{
	var strText = "";
	var charLastPos = "";

	strText = document.getElementById("Comment").value;
	if( strText.length > 0 )
	{
		charLastPos = strText.substr(strText.length - 1, 1);
		if( charLastPos == " " || charLastPos == "\n" )
		{
			document.getElementById("Comment").value = strText + strTxtSmile;
		} else {
			document.getElementById("Comment").value = strText + " " + strTxtSmile;
		}
	} else {
		document.getElementById("Comment").value = strText + strTxtSmile;
	}
	document.getElementById("Comment").focus();
}

function checkPassForm()
{
	if (document.getElementById("passtd") && document.getElementById("passtext"))
	{
		if (document.getElementById("postLiveJournal"))
		{
			if (document.getElementById("postLiveJournal").checked)
			{
				document.getElementById("passtd").disabled = false;
				document.getElementById("passtext").disabled = false;
			}
			else
			{
				document.getElementById("passtd").disabled = true;
				document.getElementById("passtext").disabled = true;
			}
		}
	}
}
