function show_form(id)
{
    var hiddenField = document.createElement("input");
    hiddenField.setAttribute("name", "comment[parent_id]");
    hiddenField.setAttribute("type", "hidden");
    hiddenField.setAttribute("value", id);
    hiddenField.setAttribute("id", "hidden_field");
    var commentForm = $('comment_form');
    if($('hidden_field'))
    {
        $('hidden_field').remove();
    }
    commentForm.appendChild(hiddenField);
    $$("a#"+id)[0].up().appendChild(commentForm);

    if(id==0)
    {
        $('comment_all').innerHTML = "Leave comment";
        $('comment_all').appendChild(commentForm);
    }
    else    
    {
        var returnLink = document.createElement("a");
        returnLink.setAttribute("href","javascript: show_form('0')");
        returnLink.setAttribute("id","0");
        returnLink.innerHTML="Leave comment";
        $('comment_all').innerHTML = "";    
        $('comment_all').appendChild(returnLink);
    }
}

function submit_form()
{
    new Ajax.Updater("comments", "blog/get_comments", 
        {
        parameters:$('comment_form').serialize(),
        onComplete: function(){
        	new Effect.Highlight("comments", {startcolor: '#FFC8C8', duration: 1.0})
        }

        });
}

function submit_command(form_id)
{
   $(form_id).submit();
}

function submit_survey()
{
    new Ajax.Updater("survey_field",
        "/main/show_results/" + $$('form#survey_form input#survey_id').first().value, 
        {
        parameters:$('survey_form').serialize(),
        onComplete: function(){
            new Effect.Highlight("survey_field", {startcolor: '#FFC8C8', duration: 1.0})
            }

        });
}

function show_attachment() 
{ 
    $('attachment_field').toggle(); 
    $('show_attachment').up().innerHTML="Attach file"
    $('show_attachment').remove();
}

function download(){
    $('download_form').submit();
}

function register(){
	var answer = confirm('You have to be authorized to leave a comment. Do you want to authorize now?')
	if (answer)
	{
		var arr = window.location.toString().split('/').reverse()
		var id = arr.first()
		window.location="/login?id="+id
	}
		
		
}
function submit_feedback()
{
    new Ajax.Updater("feedback_field",
        "contact/add_feedback", 
        {
        parameters:$('feedback_form').serialize()

        });
}
function submit_estimate()
{
    

        $('estimation_form').submit();
}
