﻿$(document).ready(function() {
    //    showErrorMsg();
    guestBook();
})

function inpFocus(e, msg) {
    if (e.value == msg) e.value = '';
}

function inpBlur(e, msg) {
    if (e.value == '') e.value = msg
}

function showErrorMsg() {
    var errorMsg = $('.popup-error');
    var parent = errorMsg.closest('.form');
    var parentOffset = parent.offset();
    var parentLocation = errorMsg.parent();

    if (errorMsg.length) {
        errorMsg.appendTo('body')
		.css({
		    'left': parentOffset.left + parent.width() - errorMsg.width() - 10,
		    'top': parentOffset.top - errorMsg.height() - 7
		})
		.fadeIn(200);

        $('.inp-error').each(function() {
            $(this).click(function() {
                $(this).removeClass('inp-error');
                errorMsg
					.fadeOut(200)
                //.delay(200, $(this).appendTo(parentLocation))
            })
        })
    }
}

function guestBook() {
    var guestBook = $('.guest-book');

    guestBook.find('.head-link').each(function() {
        $(this).click(function() {
            $('.descr').slideUp(50);

            if ($('.descr').is(':hidden')) {
                $('.descr').slideDown(50);
            } else {
                $('.descr').slideUp(50);
            }

            return false;
        })
    })
}
