// JavaScript Document
var buttonTexts = {opened: "Dodaj wpis <span style='font-weight: normal; font-size: 90%'>▼</span> ", closed: "Dodaj wpis <span style='font-weight: normal; font-size: 90%'>▼</span>"} 

// current animated collapsible panel content
var currentContent = null;

function togglePannelAnimatedStatus(content, interval, step)
{
    // wait for another animated expand/collapse action to end
    if (currentContent==null)
    {
        currentContent = content;
        var expand = (content.style.display=="none");
        if (expand)
            content.style.display = "block";
        var max_height = content.offsetHeight;

        var step_height = step + (expand ? 0 : -max_height);
                
        // schedule first animated collapse/expand event
        content.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus("
            + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);
    }
}

function togglePannelAnimatingStatus(interval,
    step, max_height, step_height)
{
    var step_height_abs = Math.abs(step_height);

    // schedule next animated collapse/expand event
    if (step_height_abs>=step && step_height_abs<=(max_height-step))
    {
        step_height += step;
        currentContent.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus("
            + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);
    }
    // animated expand/collapse done
    else
    {
        if (step_height_abs<step)
        {
            currentContent.style.display = "none";
        }
        else
        {
					document.getElementById('gbMessage').style.visibility = "visible";
					document.getElementById('gbName').style.visibility = "visible";
					document.getElementById('gbMessage').focus();
				}
        currentContent.style.height = "";
        currentContent = null;
    }
}

blinkBorder = function(obj) {
	obj.style.backgroundColor = "#FF99AA";
}
normalBorder = function(obj) {
	obj.style.backgroundColor = "transparent";
}



validateForm = function(obj) {
	var isValid = true;
	if(messageField.value == "") {
		isValid = false;
		setTimeout('blinkBorder(messageField)', 100);
		setTimeout('normalBorder(messageField)', 200);
		setTimeout('blinkBorder(messageField)', 300);
		setTimeout('normalBorder(messageField)', 400);
	}
	if(nameField.value == "") {
		isValid = false;
		setTimeout('blinkBorder(nameField)', 100);
		setTimeout('normalBorder(nameField)', 200);
		setTimeout('blinkBorder(nameField)', 300);
		setTimeout('normalBorder(nameField)', 400);
	}
	return isValid;
}
