function checkOwnerLogin() {
	var login = document.getElementById('ownerLogin');
	var passw =	document.getElementById('ownerPassw');

    if (login.value.length == 0) {
		login.focus()
		alert("Поле <Логін> порожнє!");
		return false;
	}

    if (passw.value.length == 0) {
		passw.focus()
		alert("Поле <Пароль> порожнє!");
		return false;
	}

	return true;
}

function checkAnnouncementField() {
	var descShort = document.getElementById('tfDescShort');
	var descLong = document.getElementById('tfDescLong');
	var dateStart =	document.getElementById('tfStartDate');
	var dateEnd = document.getElementById('tfEndDate');

    if (descShort.value.length == 0) {
		descShort.focus()
		alert("Поле <Короткий зміст> порожнє!");
		return false;
	}

    if (descLong.value.length == 0) {
		descLong.focus()
		alert("Поле <Детальний зміст> порожнє!");
		return false;
	}

    if (dateStart.value.length == 0) {
		dateStart.focus()
		alert("Поле <Дата початку дії об'яви> порожнє!");
		return false;
	}

    if (dateEnd.value.length == 0) {
		dateEnd.focus()
		alert("Поле <Дата завершення дії об'яви> порожнє!");
		return false;
	}

	return true;
}

function delAnnounImg(idAnnoun, fileImg) {
    $.ajax({
        url: '/announcement/delimg/',
        type: 'POST',
        data: 'idannoun='+idAnnoun+'&file='+fileImg,
        success: function(msg) {
            $('#imgAnnoun').slideUp();
        }
    });

    return false;
}

function validateFloat(e) {
    var theEvent = e || window.event;
    var key = theEvent.keyCode || theEvent.which;
    key = String.fromCharCode( key );
    var regex = /[^A-Za-z,]/;
    if( !regex.test(key) ) {
        theEvent.returnValue = false;
        theEvent.preventDefault();
    }
}

function checkFeedback()
{
  if ( document.frm.frmName.value.length == 0 )
  {
    document.frm.frmName.style.backgroundColor = "#FFCCCC";
    document.frm.frmName.focus()
    alert("Поле Ім'я  порожнє!");
    return false;
  }

  pattern = /^[\w\-\.\_]{1,100}\@[\w\-\.]{1,100}\.\w{2,5}$/i;
  email = document.frm.frmEMail.value;
  if ( pattern.exec(email) == null )
  {
    document.frm.frmEMail.style.backgroundColor = "#FFCCCC";
    document.frm.frmEMail.focus()
    alert('Поле E-Mail містить некоректний адрес!');
    return false;
  }

  if ( document.frm.frmContent.value.length == 0 )
  {
    document.frm.frmContent.style.backgroundColor = "#FFCCCC";
    document.frm.frmContent.focus()
    alert("Поле Текст повідомлення порожнє!");
    return false;
  }

  return true;
}

