
var oDIVComments;
var oTXTComment;

function addComment(idFoto, oDIVCommentsAux, oTXTCommentAux)
{
    oDIVComments = document.getElementById(oDIVCommentsAux);
    oTXTComment = document.getElementById(oTXTCommentAux);

    var sParams = "idFoto=" + idFoto + 
                  "&nome=" + document.all.txtName.value +
                  "&local=" + document.all.txtLocation.value +
                  "&comentario=" + oTXTComment.value;

    ExecutarXMLHttpForm("/Comments/Comments.aspx", sParams, addComment_CallBack);
}

function addComment_CallBack(XML)
{
	resposta = XML.responseText;
	
	var msgs = resposta.split("|");
	
	if (msgs[0] == "err")
	{
	    alert(msgs[1])
	}
	else if (msgs[0] == "ok")
	{
	    var nome = document.all.txtName.value
	    var local = document.all.txtLocation.value
	    var comentario = document.all.txtComment.value
	    
	    oDIVComments.innerHTML = "<div class='bubble'><blockquote><p>" + comentario + "</p></blockquote><cite><strong>" + nome + "</strong> - " + local + "</cite></div>" + document.all.comments.innerHTML;
	    
	    oTXTComment.value = ""

	    alert(nome + ", thank you for your comment.")
	    
	    document.cookie = "nome=" + escape(nome)
	    document.cookie = "local=" + escape(local)
	}
}

