function User(){this.id="";this.username="";this.nickname="";this.email="";this.password="";this.avatar="";this.active=false;this.country="";this.city="";this.state="";this.birthDate="";this.gender="";this.about=""}User.prototype.getId=function(){return this.id};User.prototype.setId=function(id){this.id=id};User.prototype.getUsername=function(){return this.username};User.prototype.setUsername=function(username){this.username=username};User.prototype.getNickname=function(){return this.nickname};User.prototype.setNickname=function(nickname){this.nickname=nickname};User.prototype.getEmail=function(){return this.email};User.prototype.setEmail=function(email){this.email=email};User.prototype.getPassword=function(){return this.password};User.prototype.setPassword=function(password){this.password=password};User.prototype.getPasswordConfirmation=function(){return this.passwordConfirmation};User.prototype.setPasswordConfirmation=function(passwordConfirmation){this.passwordConfirmation=passwordConfirmation};User.prototype.getAvatar=function(){return this.avatar};User.prototype.setAvatar=function(avatar){this.avatar=avatar};User.prototype.isActive=function(){return this.active};User.prototype.setActive=function(active){this.active=active};User.prototype.getCountry=function(){return this.country};User.prototype.setCountry=function(country){this.country=country};User.prototype.getCity=function(){return this.city};User.prototype.setCity=function(city){this.city=city};User.prototype.getState=function(){return this.state};User.prototype.setState=function(state){this.state=state};User.prototype.getBirthDate=function(){return this.birthDate};User.prototype.setBirthDate=function(birthDate){this.birthDate=birthDate};User.prototype.getGender=function(){return this.gender};User.prototype.setGender=function(gender){this.gender=gender};User.prototype.getAbout=function(){return this.about};User.prototype.setAbout=function(about){this.about=about};User.prototype.saveToXML=function(){var xmlUser='<?xml version="1.0" encoding="UTF-8" ?><user><id>[id]</id><username>[username]</username><nickname>[nickname]</nickname><email>[email]</email><password>[password]</password><avatar>[avatar]</avatar><active>[active]</active><country>[country]</country><city>[city]</city><state>[state]</state><birthDate>[birthDate]</birthDate><gender>[gender]</gender><about>[about]</about></user>';xmlUser=xmlUser.replace("[id]",this.id);xmlUser=xmlUser.replace("[username]",this.username);xmlUser=xmlUser.replace("[nickname]",this.nickname);xmlUser=xmlUser.replace("[email]",this.email);xmlUser=xmlUser.replace("[password]",this.password);xmlUser=xmlUser.replace("[avatar]",this.avatar);xmlUser=xmlUser.replace("[active]",this.active);xmlUser=xmlUser.replace("[country]",this.country);xmlUser=xmlUser.replace("[city]",this.city);xmlUser=xmlUser.replace("[state]",this.state);xmlUser=xmlUser.replace("[birthDate]",this.birthDate);xmlUser=xmlUser.replace("[gender]",this.gender);xmlUser=xmlUser.replace("[about]",this.about);return xmlUser};function Grudi(){this.title="";this.description="";this.idCategory="";this.publicGrudi="";this.keywords=""}Grudi.prototype.getTitle=function(){return this.title};Grudi.prototype.setTitle=function(title){this.title=title};Grudi.prototype.getDescription=function(){return this.description};Grudi.prototype.setDescription=function(description){this.description=description};Grudi.prototype.getIdCategory=function(){return this.idCategory};Grudi.prototype.setIdCategory=function(idCategory){this.idCategory=idCategory};Grudi.prototype.isPublicGrudi=function(){return this.publicGrudi};Grudi.prototype.setPublicGrudi=function(publicGrudi){this.publicGrudi=publicGrudi};Grudi.prototype.getKeywords=function(){return this.keywords};Grudi.prototype.setKeywords=function(keywords){this.keywords=keywords};Grudi.prototype.saveToXML=function(){var xmlGrudi='<?xml version="1.0" encoding="UTF-8" ?><grudi><title>[title]</title><description>[description]</description><idCategory>[idCategory]</idCategory><publicGrudi>[publicGrudi]</publicGrudi><keywords>[keywords]</keywords></grudi>';xmlGrudi=xmlGrudi.replace("[title]",this.title);xmlGrudi=xmlGrudi.replace("[description]",this.description);xmlGrudi=xmlGrudi.replace("[idCategory]",this.idCategory);xmlGrudi=xmlGrudi.replace("[publicGrudi]",this.publicGrudi);xmlGrudi=xmlGrudi.replace("[keywords]",this.keywords);return xmlGrudi};function SentGrudi(){this.id=-1;this.idGrudi=-1;this.senderIPAddress="";this.sentDate="";this.recipientName="";this.recipientEmail="";this.recipientPhone="";this.senderName="";this.senderEmail="";this.sendSMS=false;this.bodyMessage="";this.grudiURL="";this.grudiEmbedCode="";this.sendCopy=false;this.readConfirmation=false;this.readed=false}SentGrudi.prototype.getId=function(){return this.id};SentGrudi.prototype.setId=function(id){this.id=id};SentGrudi.prototype.getIdGrudi=function(){return this.idGrudi};SentGrudi.prototype.setIdGrudi=function(idGrudi){this.idGrudi=idGrudi};SentGrudi.prototype.getSenderIPAddress=function(){return this.senderIPAddress};SentGrudi.prototype.setSenderIPAddress=function(senderIPAddress){this.senderIPAddress=senderIPAddress};SentGrudi.prototype.getSentDate=function(){return this.sentDate};SentGrudi.prototype.setSentDate=function(sentDate){this.sentDate=sentDate};SentGrudi.prototype.getRecipientName=function(){return this.recipientName};SentGrudi.prototype.setRecipientName=function(recipientName){this.recipientName=recipientName};SentGrudi.prototype.getRecipientEmail=function(){return this.recipientEmail};SentGrudi.prototype.setRecipientEmail=function(recipientEmail){this.recipientEmail=recipientEmail};SentGrudi.prototype.getRecipientPhone=function(){return this.recipientPhone};SentGrudi.prototype.setRecipientPhone=function(recipientPhone){this.recipientPhone=recipientPhone};SentGrudi.prototype.getSenderName=function(){return senderName};SentGrudi.prototype.setSenderName=function(senderName){this.senderName=senderName};SentGrudi.prototype.getSenderEmail=function(){return senderEmail};SentGrudi.prototype.setSenderEmail=function(senderEmail){this.senderEmail=senderEmail};SentGrudi.prototype.isSendSMS=function(){return this.sendSMS};SentGrudi.prototype.setSendSMS=function(sendSMS){this.sendSMS=sendSMS};SentGrudi.prototype.getBodyMessage=function(){return bodyMessage};SentGrudi.prototype.setBodyMessage=function(bodyMessage){this.bodyMessage=bodyMessage};SentGrudi.prototype.getGrudiURL=function(){return this.grudiURL};SentGrudi.prototype.setGrudiURL=function(grudiURL){this.grudiURL=grudiURL};SentGrudi.prototype.getGrudiEmbedCode=function(){return this.grudiEmbedCode};SentGrudi.prototype.setGrudiEmbedCode=function(grudiEmbedCode){this.grudiEmbedCode=grudiEmbedCode};SentGrudi.prototype.isSendCopy=function(){return this.sendCopy};SentGrudi.prototype.setSendCopy=function(sendCopy){this.sendCopy=sendCopy};SentGrudi.prototype.isReadConfirmation=function(){return readConfirmation};SentGrudi.prototype.setReadConfirmation=function(readConfirmation){this.readConfirmation=readConfirmation};SentGrudi.prototype.isReaded=function(){return readed};SentGrudi.prototype.setReaded=function(readed){this.readed=readed};SentGrudi.prototype.saveToXML=function(){var xmlSentGrudi='<?xml version="1.0" encoding="UTF-8" ?><sentGrudi>	<id>[id]</id>	<idGrudi>[idGrudi]</idGrudi>	<senderIPAddress>[senderIPAddress]</senderIPAddress>	<sentDate>[sentDate]</sentDate>	<recipientName>[recipientName]</recipientName>	<recipientEmail>[recipientEmail]</recipientEmail>	<recipientPhone>[recipientPhone]</recipientPhone>	<senderName>[senderName]</senderName>	<senderEmail>[senderEmail]</senderEmail>	<sendSMS>[sendSMS]</sendSMS>	<bodyMessage>[bodyMessage]</bodyMessage>	<grudiURL>[grudiURL]</grudiURL>	<grudiEmbedCode>[grudiEmbedCode]</grudiEmbedCode>	<sendCopy>[sendCopy]</sendCopy></sentGrudi>';xmlSentGrudi=xmlSentGrudi.replace("[id]",this.id);xmlSentGrudi=xmlSentGrudi.replace("[idGrudi]",this.idGrudi);xmlSentGrudi=xmlSentGrudi.replace("[senderIPAddress]",this.senderIPAddress);xmlSentGrudi=xmlSentGrudi.replace("[sentDate]",this.sentDate);xmlSentGrudi=xmlSentGrudi.replace("[recipientName]",this.recipientName);xmlSentGrudi=xmlSentGrudi.replace("[recipientEmail]",this.recipientEmail);xmlSentGrudi=xmlSentGrudi.replace("[recipientPhone]",this.recipientPhone);xmlSentGrudi=xmlSentGrudi.replace("[senderName]",this.senderName);xmlSentGrudi=xmlSentGrudi.replace("[senderEmail]",this.senderEmail);xmlSentGrudi=xmlSentGrudi.replace("[bodyMessage]",this.bodyMessage);xmlSentGrudi=xmlSentGrudi.replace("[grudiURL]",this.grudiURL);xmlSentGrudi=xmlSentGrudi.replace("[grudiEmbedCode]",this.grudiEmbedCode);xmlSentGrudi=xmlSentGrudi.replace("[sendCopy]",this.sendCopy);return xmlSentGrudi};function ControllerComment(){this.DEFAULT_SERVLET_NAME="site.grudi";this.responseXML;this.messageArray=new Array()}ControllerComment.prototype.setResponseXML=function(responseXML){this.responseXML=responseXML};ControllerComment.prototype.onComplete=function(functionHandler){functionHandler()};ControllerComment.prototype.onError=function(functionHandler){functionHandler()};ControllerComment.prototype.onLoadComplete=function(functionHandler){functionHandler()};ControllerComment.prototype.onLoadError=function(functionHandler){functionHandler()};ControllerComment.prototype.post=function(idGrudi,comment){completeFunction=this.onComplete;errorFunction=this.onError;http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("ADD_GRUDI_COMMENT");var commentText="";if((navigator.appName.indexOf("Explorer")>-1)){commentText=escape(comment)}else{commentText=encodeURIComponent(comment)}var parameters="command="+command+"&grudi="+idGrudi+"&comment="+commentText;http_request.onreadystatechange=this.postComplete;http_request.open("POST",this.DEFAULT_SERVLET_NAME,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(parameters)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel adicionar o coment\u00E1rio.<br> Tente novamente mais tarde.")}};ControllerComment.prototype.load=function(idGrudi,quantity,skip){completeFunction=this.onLoadComplete;errorFunction=this.onLoadError;http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("GET_GRUDI_COMMENTS");var parameters="command="+command+"&quantity="+parseInt(quantity)+"&skip="+parseInt(skip)+"&grudi="+idGrudi;http_request.onreadystatechange=this.loadComplete;http_request.open("GET",this.DEFAULT_SERVLET_NAME+"?"+parameters,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(null)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel carregar os coment\u00E1rios.<br> Tente novamente mais tarde.")}};ControllerComment.prototype.postComplete=function(){if((http_request.readyState==4)&&(http_request.status==200)){http_request.responseXML;if(http_request.responseXML.getElementsByTagName("error")[0]){var message=http_request.responseXML.getElementsByTagName("message")[0].firstChild.nodeValue+"";var code=http_request.responseXML.getElementsByTagName("code")[0].firstChild.nodeValue+"";errorFunction(message,code)}else{var xml=http_request.responseXML;completeFunction(xml)}}else{if((http_request.readyState==4)&&(http_request.status!=200)){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel adicionar o coment\u00E1rio.<br> Tente novamente mais tarde.")}}};ControllerComment.prototype.loadComplete=function(){if((http_request.readyState==4)&&(http_request.status==200)){http_request.responseXML;if(http_request.responseXML.getElementsByTagName("error")[0]){var message=http_request.responseXML.getElementsByTagName("message")[0].firstChild.nodeValue+"";var code=http_request.responseXML.getElementsByTagName("code")[0].firstChild.nodeValue+"";errorFunction(message,code)}else{var xml=http_request.responseXML;completeFunction(xml)}}else{if((http_request.readyState==4)&&(http_request.status!=200)){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel carregar os coment\u00E1rios.<br> Tente novamente mais tarde.")}}};function addGrudiComment(logged,idGrudi){if(logged){var commentTextArea=document.getElementById("commentText");var commentValue=(commentTextArea.value+"");if(trim(commentValue).length>0){var commentMessage=document.getElementById("comment_message");commentMessage.innerHTML="";var image=document.createElement("IMG");image.src="images/ajax_loading.gif";image.style.width="32px";image.style.height="32px";var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var message=document.getElementById("grudi_info_message");message.innerHTML="";message.appendChild(image);var controller=new ControllerComment();controller.onComplete=commentComplete;controller.onError=commentError;controller.post(idGrudi,commentValue)}else{var commentMessage=document.getElementById("comment_message");commentMessage.innerHTML="Digite um coment\u00E1rio.";alert("Digite um coment\u00E1rio.")}}else{var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var message=document.getElementById("grudi_info_message");message.innerHTML="Acesse ou crie sua conta para adicionar coment\u00E1rios à este grudi."}}function commentError(message,code){if(parseInt(code)>800){var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var messageLayer=document.getElementById("grudi_info_message");messageLayer.innerHTML=message}}function commentComplete(xml){var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var messageLayer=document.getElementById("grudi_info_message");messageLayer.innerHTML="Seu coment\u00E1rio foi adicionado";var idGrudi=xml.getElementsByTagName("id")[0].firstChild.nodeValue+"";var commented=xml.getElementsByTagName("commented")[0].firstChild.nodeValue+"";var countCommentsSpan=document.getElementById("commentsSpan");countCommentsSpan.innerHTML="("+commented+")";if(parseInt(commented)>0){var mainContainerBottom=document.getElementById("mainPageContainerBottom");mainContainerBottom.style.display="block"}var pageCount=Math.ceil(parseInt(commented)/5);var commentsField=document.getElementById("hiddenCommented");commentsField.value=commented;loadCommentPage(1,idGrudi);var commentTextArea=document.getElementById("commentText");commentTextArea.value="";location.href="#info_message"}function commentLoadComplete(xml){var container=document.getElementById("divCommentsList");container.style.width="";container.style.height="";for(i=(container.childNodes.length-1);i>=0;i--){container.removeChild(container.childNodes[i])}var comments=xml.getElementsByTagName("grudiComment");for(i=0;i<comments.length;i++){if(i>0){container.appendChild(document.createElement("HR"))}var divComment=document.createElement("DIV");divComment.className="post";var idGrudi=comments[i].getElementsByTagName("idGrudi")[0].firstChild.nodeValue;var userAvatar="";if(comments[i].getElementsByTagName("userAvatar")[0].firstChild){userAvatar=comments[i].getElementsByTagName("userAvatar")[0].firstChild.nodeValue;if(trim(userAvatar).length==0){userAvatar="images/avatar_padrao.gif"}}else{userAvatar="images/avatar_padrao.gif"}var userNickname=comments[i].getElementsByTagName("userNickname")[0].firstChild.nodeValue;var createdAgo=comments[i].getElementsByTagName("createdAgo")[0].firstChild.nodeValue;var comment=comments[i].getElementsByTagName("comment")[0].firstChild.nodeValue;imgAvatar=document.createElement("IMG");imgAvatar.src=userAvatar;imgAvatar.align="left";imgAvatar.className="avatar";imgAvatar.alt="Avatar";imgAvatar.style.width="70px";imgAvatar.style.height="70px";userParagraph=document.createElement("P");userLink=document.createElement("A");userLink.href="#";userLink.className="link_user";userLink.appendChild(document.createTextNode(userNickname));infoSpan=document.createElement("SPAN");infoSpan.className="time";infoSpan.appendChild(document.createTextNode("\u00a0"+getTimeAgo(parseInt(createdAgo))));userParagraph.appendChild(userLink);userParagraph.appendChild(infoSpan);commentParagraph=document.createElement("P");commentParagraph.appendChild(document.createTextNode(comment));divComment.appendChild(imgAvatar);divComment.appendChild(userParagraph);divComment.appendChild(commentParagraph);container.appendChild(divComment)}}function loadCommentPage(page,idGrudi){var container=document.getElementById("divCommentsList");containerHeight=Math.max(container.clientHeight,container.offsetHeight);containerWidth=Math.max(container.clientWidth,container.offsetWidth);for(i=(container.childNodes.length-1);i>=0;i--){container.removeChild(container.childNodes[i])}container.style.width=containerWidth+"px";container.style.height=containerHeight+"px";mountPagination("pageContainer",page,5,"hiddenCommented","#comments",function(){loadCommentPage(arguments[0],idGrudi)});mountPagination("pageContainerBottom",page,5,"hiddenCommented","#comments",function(){loadCommentPage(arguments[0],idGrudi)});var image=document.createElement("IMG");image.src="images/ajax_loading.gif";image.style.position="relative";image.style.left=parseInt((containerWidth/2)-16)+"px";image.style.top=parseInt((containerHeight/2)-16)+"px";image.style.width="32px";image.style.height="32px";container.appendChild(image);var controller=new ControllerComment();controller.onLoadComplete=commentLoadComplete;controller.onLoadError=commentError;controller.load(idGrudi,5,(parseInt(page)-1)*5)}function commentTextChange(){var commentTextArea=document.getElementById("commentText");if(commentTextArea.value){var commentValue=(commentTextArea.value+"");if(commentValue.length>600){commentValue=commentValue.substr(0,600);commentTextArea.value=commentValue;var selection=new Selection(commentTextArea);var s=selection.getCaret();selection.setCaret(+599||0,+600||0);commentTextArea.focus()}var spanLettersCount=document.getElementById("lettersCount");spanLettersCount.innerHTML=commentValue.length}}function ControllerFavorite(){this.DEFAULT_SERVLET_NAME="site.grudi";this.responseXML;this.messageArray=new Array()}ControllerFavorite.prototype.setResponseXML=function(responseXML){this.responseXML=responseXML};ControllerFavorite.prototype.onComplete=function(functionHandler){functionHandler()};ControllerFavorite.prototype.onError=function(functionHandler){functionHandler()};ControllerFavorite.prototype.post=function(idGrudi){completeFunction=this.onComplete;errorFunction=this.onError;http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("SET_GRUDI_FAVORITE");var parameters="command="+command+"&grudi="+idGrudi;http_request.onreadystatechange=this.postComplete;http_request.open("POST",this.DEFAULT_SERVLET_NAME,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(parameters)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel adicionar aos favoritos.<br> Tente novamente mais tarde.")}};ControllerFavorite.prototype.postComplete=function(){if((http_request.readyState==4)&&(http_request.status==200)){http_request.responseXML;if(http_request.responseXML.getElementsByTagName("error")[0]){var message=http_request.responseXML.getElementsByTagName("message")[0].firstChild.nodeValue+"";var code=http_request.responseXML.getElementsByTagName("code")[0].firstChild.nodeValue+"";errorFunction(message,code)}else{completeFunction()}}else{if((http_request.readyState==4)&&(http_request.status!=200)){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel adicionar aos favoritos.<br> Tente novamente mais tarde.")}}};var grudiAlreadyFavorited=false;function addFavoriteGrudi(logged,idGrudi){if(logged){var image=document.createElement("IMG");image.src="images/ajax_loading.gif";image.style.width="32px";image.style.height="32px";var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var message=document.getElementById("grudi_info_message");message.innerHTML="";message.appendChild(image);var controller=new ControllerFavorite();controller.onComplete=favoriteComplete;controller.onError=favoriteError;controller.post(idGrudi)}else{var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var message=document.getElementById("grudi_info_message");message.innerHTML="Acesse ou crie sua conta para adicionar este grudi à sua lista de favoritos."}}function favoriteError(message,code){if(parseInt(code)>800){var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var messageLayer=document.getElementById("grudi_info_message");messageLayer.innerHTML=message;grudiAlreadyFavorited=(parseInt(code)==802)}}function favoriteComplete(){var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var messageLayer=document.getElementById("grudi_info_message");messageLayer.innerHTML="Este grudi foi adicionado à sua lista de favoritos";grudiAlreadyFavorited=true}function ControllerGrudiInfo(){this.DEFAULT_SERVLET_NAME="site.grudi";this.DEFAULT_SERVLET_ACTION_NAME="action.grudi";this.DEFAULT_SEARCH_SERVLET_NAME="search.grudi";this.responseXML;this.messageArray=new Array()}ControllerGrudiInfo.prototype.setResponseXML=function(responseXML){this.responseXML=responseXML};ControllerGrudiInfo.prototype.onComplete=function(functionHandler){functionHandler()};ControllerGrudiInfo.prototype.onError=function(functionHandler){functionHandler()};ControllerGrudiInfo.prototype.loadByUser=function(nickname,quantity,skip){completeFunction=this.onComplete;errorFunction=this.onError;http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("GET_GRUDI_BY_USER");var parameters="command="+command+"&user="+nickname+"&quantity="+parseInt(quantity)+"&skip="+parseInt(skip);http_request.onreadystatechange=this.loadComplete;http_request.open("GET",this.DEFAULT_SERVLET_NAME+"?"+parameters,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(null)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel carregar os grudis do usu\u00E1rio.<br> Tente novamente mais tarde.")}};ControllerGrudiInfo.prototype.loadFavorite=function(nickname,quantity,skip){completeFunction=this.onComplete;errorFunction=this.onError;http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("GET_GRUDI_FAVORITES");var parameters="command="+command+"&user="+nickname+"&quantity="+parseInt(quantity)+"&skip="+parseInt(skip);http_request.onreadystatechange=this.loadComplete;http_request.open("GET",this.DEFAULT_SERVLET_NAME+"?"+parameters,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(null)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel carregar os favoritos.<br> Tente novamente mais tarde.")}};ControllerGrudiInfo.prototype.loadSearch=function(servletCommand,query,quantity,skip){completeFunction=this.onComplete;errorFunction=this.onError;http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent(servletCommand);var parameters="command="+command+"&p="+escape(query)+"&quantity="+parseInt(quantity)+"&skip="+parseInt(skip);http_request.onreadystatechange=this.loadComplete;http_request.open("GET",this.DEFAULT_SEARCH_SERVLET_NAME+"?"+parameters,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(null)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel carregar a pesquisa.<br> Tente novamente mais tarde.")}};ControllerGrudiInfo.prototype.deleteGrudi=function(grudi){completeFunction=this.onComplete;errorFunction=this.onError;http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("GRUDI_DELETE");var parameters="command="+command+"&grudi="+grudi;http_request.onreadystatechange=this.loadComplete;http_request.open("GET",this.DEFAULT_SERVLET_ACTION_NAME+"?"+parameters,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(null)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel deletar o grudi.<br> Tente novamente mais tarde.")}};ControllerGrudiInfo.prototype.updateGrudi=function(grudi,idMD5){completeFunction=this.onComplete;errorFunction=this.onError;http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("GRUDI_UPDATE");var xmlText="";if((navigator.appName.indexOf("Explorer")>-1)){xmlText=escape(grudi.saveToXML())}else{xmlText=encodeURIComponent(grudi.saveToXML())}var parameters="command="+command+"&grudi="+idMD5+"&xmlText="+xmlText;http_request.onreadystatechange=this.loadComplete;http_request.open("POST",this.DEFAULT_SERVLET_ACTION_NAME,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(parameters)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel atualizar o grudi.<br> Tente novamente mais tarde.")}};ControllerGrudiInfo.prototype.deleteFavorite=function(grudi){completeFunction=this.onComplete;errorFunction=this.onError;http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("DELETE_GRUDI_FAVORITE");var parameters="command="+command+"&grudi="+grudi;http_request.onreadystatechange=this.loadComplete;http_request.open("GET",this.DEFAULT_SERVLET_NAME+"?"+parameters,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(null)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel deletar o grudi.<br> Tente novamente mais tarde.")}};ControllerGrudiInfo.prototype.sendGrudi=function(sentGrudi,grudi){completeFunction=this.onComplete;errorFunction=this.onError;http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("GRUDI_SEND");var xmlText="";if((navigator.appName.indexOf("Explorer")>-1)){xmlText=escape(sentGrudi.saveToXML())}else{xmlText=encodeURIComponent(sentGrudi.saveToXML())}var parameters="command="+command+"&grudi="+grudi+"&xmlText="+xmlText;http_request.onreadystatechange=this.loadComplete;http_request.open("POST",this.DEFAULT_SERVLET_ACTION_NAME,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(parameters)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel deletar o grudi.<br> Tente novamente mais tarde.")}};ControllerGrudiInfo.prototype.loadComplete=function(){if((http_request.readyState==4)&&(http_request.status==200)){http_request.responseXML;if(http_request.responseXML.getElementsByTagName("error")[0]){var message=http_request.responseXML.getElementsByTagName("message")[0].firstChild.nodeValue+"";var code=http_request.responseXML.getElementsByTagName("code")[0].firstChild.nodeValue+"";errorFunction(message,code)}else{var xml=http_request.responseXML;completeFunction(xml)}}else{if((http_request.readyState==4)&&(http_request.status!=200)){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel adicionar o coment\u00E1rio.<br> Tente novamente mais tarde.")}}};var grudiInfoEdit=null;function mountGrudiGrid(container,xml,columnCount){container.style.height="";for(i=(container.childNodes.length-1);i>=0;i--){container.removeChild(container.childNodes[i])}var grudis=xml.getElementsByTagName("grudi");var tableGrudi=document.createElement("TABLE");if(grudis.length>=4){tableGrudi.width="100%"}var tableBody=document.createElement("TBODY");var rowGrudi=document.createElement("TR");for(i=0;i<grudis.length;i++){var grudiID=grudis[i].getElementsByTagName("id")[0].firstChild.nodeValue;var grudiThumbnail=grudis[i].getElementsByTagName("screenshotThumbnail")[0].firstChild.nodeValue;var grudiTitle=grudis[i].getElementsByTagName("title")[0].firstChild.nodeValue+"";var createdAgo=grudis[i].getElementsByTagName("createdAgo")[0].firstChild.nodeValue;if(grudiTitle.length>19){grudiTitle=grudiTitle.substring(0,19)+"..."}var cellGrudi=document.createElement("TD");var divGrudi=document.createElement("DIV");divGrudi.className="profile_box";divGrudi.id="divGrudiUser";var imgThumbnail=document.createElement("IMG");imgThumbnail.src=grudiThumbnail;imgThumbnail.border="0";imgThumbnail.alt=grudiTitle;var thumbnailLink=document.createElement("A");thumbnailLink.href="view.grudi?grudi="+grudiID;thumbnailLink.appendChild(imgThumbnail);var strongText=document.createElement("strong");var titleLink=document.createElement("A");titleLink.href="view.grudi?grudi="+grudiID;titleLink.appendChild(document.createTextNode(grudiTitle));strongText.appendChild(titleLink);divGrudi.appendChild(thumbnailLink);divGrudi.appendChild(document.createElement("BR"));divGrudi.appendChild(strongText);var timeParagraph=document.createElement("P");timeParagraph.appendChild(document.createTextNode("Adicionado: "+getTimeAgo(parseInt(createdAgo))));divGrudi.appendChild(timeParagraph);container.appendChild(divGrudi);cellGrudi.appendChild(divGrudi);if(((i%columnCount)==0)&&(i>0)){tableBody.appendChild(rowGrudi);rowGrudi=document.createElement("TR");rowGrudi.appendChild(cellGrudi)}else{rowGrudi.appendChild(cellGrudi)}}tableBody.appendChild(rowGrudi);tableGrudi.appendChild(tableBody);container.appendChild(tableGrudi)}function mountGrudiList(container,xml,edit,deleteFunction,editFunction,isInappropriatePage){container.style.height="";for(i=(container.childNodes.length-1);i>=0;i--){container.removeChild(container.childNodes[i])}var grudis=xml.getElementsByTagName("grudi");for(i=0;i<grudis.length;i++){var grudiID=grudis[i].getElementsByTagName("id")[0].firstChild.nodeValue;var grudiThumbnail=grudis[i].getElementsByTagName("screenshotThumbnail")[0].firstChild.nodeValue;var grudiTitle=grudis[i].getElementsByTagName("title")[0].firstChild.nodeValue+"";var grudiDescription=grudis[i].getElementsByTagName("description")[0].firstChild.nodeValue+"";var grudiPublic=grudis[i].getElementsByTagName("publicGrudi")[0].firstChild.nodeValue+"";var grudiIDCategory=grudis[i].getElementsByTagName("idCategory")[0].firstChild.nodeValue+"";var grudiKeywords=grudis[i].getElementsByTagName("keywords")[0].firstChild.nodeValue+"";var createdAgo=grudis[i].getElementsByTagName("createdAgo")[0].firstChild.nodeValue;var userNickname=grudis[i].getElementsByTagName("userNickname")[0].firstChild.nodeValue+"";var grudiViewd=grudis[i].getElementsByTagName("viewd")[0].firstChild.nodeValue+"";var grudiRate=grudis[i].getElementsByTagName("grudiRate")[0].firstChild.nodeValue+"";var grudiRated=grudis[i].getElementsByTagName("rated")[0].firstChild.nodeValue+"";var grudiFavorited=grudis[i].getElementsByTagName("favorited")[0].firstChild.nodeValue+"";var grudiCommentd=grudis[i].getElementsByTagName("commented")[0].firstChild.nodeValue+"";var grudiInappropriatedCommentd=grudis[i].getElementsByTagName("inappropriated")[0].firstChild.nodeValue+"";var divResultSearch=document.createElement("DIV");if(edit){if((i%2)==0){divResultSearch.className="logado_lista"}else{divResultSearch.className="logado_lista2"}}else{divResultSearch.className="result_search"}var tableGrudi=document.createElement("TABLE");if(edit){tableGrudi.style.width="100%"}var tableBody=document.createElement("TBODY");var rowHeader=document.createElement("TR");var rowDescription=document.createElement("TR");var rowKeywords=document.createElement("TR");var rowEditButton=document.createElement("TR");var rowStats=document.createElement("TR");var divThumbnail=document.createElement("DIV");divThumbnail.className="result_thumb";var thumbLink=document.createElement("A");if(isInappropriatePage){thumbLink.href="javascript:void(0);";thumbLink.id=grudiID;var openGrudiFunction=function(){openGrudi(this.id)};thumbLink.onclick=openGrudiFunction}else{thumbLink.href="view.grudi?grudi="+grudiID}var thumbImage=document.createElement("IMG");thumbImage.src=grudiThumbnail;thumbLink.appendChild(thumbImage);divThumbnail.appendChild(thumbLink);var cellThumb=document.createElement("TD");cellThumb.vAlign="top";if(edit){cellThumb.rowSpan="5"}else{cellThumb.rowSpan="2"}cellThumb.appendChild(divThumbnail);if(grudiPublic=="false"){var divPrivate=document.createElement("DIV");divPrivate.className="private_grudi";var privateImage=document.createElement("IMG");privateImage.src="images/padlock.gif";divPrivate.appendChild(privateImage);divPrivate.appendChild(document.createTextNode("Grudi Privado."));cellThumb.appendChild(divPrivate)}var headerTitle=null;if(edit){headerTitle=document.createElement("H2")}else{headerTitle=document.createElement("H3")}headerTitle.appendChild(document.createTextNode(grudiTitle));var cellTitle=document.createElement("TD");cellTitle.colSpan="2";cellTitle.appendChild(headerTitle);rowHeader.appendChild(cellThumb);rowHeader.appendChild(cellTitle);if(edit){var cellDescription=document.createElement("TD");cellDescription.colSpan="2";cellDescription.appendChild(document.createTextNode("\u00a0"));cellDescription.appendChild(document.createElement("BR"));var strongDescription=document.createElement("STRONG");strongDescription.appendChild(document.createTextNode("Descri\u00e7\u00E3o:"));cellDescription.appendChild(strongDescription);cellDescription.appendChild(document.createTextNode("\u00a0"+grudiDescription));var cellKeywords=document.createElement("TD");cellKeywords.colSpan="2";cellKeywords.appendChild(document.createTextNode("\u00a0"));cellKeywords.appendChild(document.createElement("BR"));var strongKeywords=document.createElement("STRONG");strongKeywords.appendChild(document.createTextNode("Palavras Chave:"));cellKeywords.appendChild(strongKeywords);cellKeywords.appendChild(document.createTextNode("\u00a0"+grudiKeywords));cellKeywords.appendChild(document.createElement("BR"));cellKeywords.appendChild(document.createTextNode("\u00a0"));var cellEditButton=document.createElement("TD");cellEditButton.colSpan="2";var divEditButton=document.createElement("DIV");var listEditButton=document.createElement("UL");listEditButton.className="edit";var listItemEdit=null;var listItemDelete=null;if(editFunction){listItemEdit=document.createElement("LI");var linkEdit=document.createElement("A");linkEdit.href="javascript:void(0);";linkEdit.appendChild(document.createTextNode("Editar Grudi"));linkEdit.id=grudiID+"|"+grudiTitle+"|"+grudiDescription+"|"+grudiKeywords+"|"+grudiThumbnail+"|"+grudiPublic+"|"+grudiIDCategory;var grudiEditFunction=function(){editFunction(this.id)};linkEdit.onclick=grudiEditFunction;listItemEdit.appendChild(linkEdit)}if(deleteFunction){listItemDelete=document.createElement("LI");var linkDelete=document.createElement("A");linkDelete.href="javascript:void(0);";if(editFunction){linkDelete.appendChild(document.createTextNode("Remover Grudi"))}else{linkDelete.appendChild(document.createTextNode("Remover da Lista"))}linkDelete.id=grudiID;var grudiDeleteFunction=function(){deleteFunction(this.id)};linkDelete.onclick=grudiDeleteFunction;listItemDelete.appendChild(linkDelete)}if(listItemEdit!=null){listEditButton.appendChild(listItemEdit)}if(listItemDelete!=null){listEditButton.appendChild(listItemDelete)}divEditButton.appendChild(listEditButton);cellEditButton.appendChild(divEditButton);rowEditButton.appendChild(cellEditButton);rowDescription.appendChild(cellDescription);rowKeywords.appendChild(cellKeywords)}var divGrudiInfo=document.createElement("DIV");var fromParagraph=document.createElement("P");var fromStrong=document.createElement("STRONG");var fromLink=document.createElement("A");fromLink.className="link_user";if(isInappropriatePage){fromLink.href="javascript:void(0);";fromLink.id=userNickname;var openProfileFunction=function(){openProfile(this.id)};fromLink.onclick=openProfileFunction}else{fromLink.href=userNickname}fromLink.appendChild(document.createTextNode(userNickname));fromStrong.appendChild(fromLink);fromParagraph.appendChild(document.createTextNode("De: "));fromParagraph.appendChild(fromStrong);var createdAgoParagraph=document.createElement("P");createdAgoParagraph.appendChild(document.createTextNode("Adicionado: "+getTimeAgo(parseInt(createdAgo))));var viewdStrong=document.createElement("STRONG");viewdStrong.appendChild(document.createTextNode(grudiViewd));var viewdParagraph=document.createElement("P");viewdParagraph.appendChild(document.createTextNode("Visualiza\u00E7\u00F5es: "));viewdParagraph.appendChild(viewdStrong);divGrudiInfo.appendChild(fromParagraph);divGrudiInfo.appendChild(createdAgoParagraph);divGrudiInfo.appendChild(viewdParagraph);var divGrudiStats=document.createElement("DIV");var rateParagraph=document.createElement("P");var rateImage=document.createElement("IMG");rateImage.src="images/stars"+grudiRate+".gif";rateParagraph.appendChild(rateImage);rateParagraph.appendChild(document.createTextNode("\u00a0"+grudiRated+"\u00a0Avalia\u00E7\u00F5es"));var favoriteParagraph=document.createElement("P");var favoriteImage=document.createElement("IMG");favoriteImage.src="images/heart.gif";favoriteParagraph.appendChild(favoriteImage);favoriteParagraph.appendChild(document.createTextNode("\u00a0"+grudiFavorited+"\u00a0Favoritos"));var commentParagraph=document.createElement("P");var commentImage=document.createElement("IMG");commentImage.src="images/comments_ballon.gif";var inappropriateImage=document.createElement("IMG");inappropriateImage.src="images/inappropriated.gif";if(isInappropriatePage){commentParagraph.appendChild(inappropriateImage);commentParagraph.appendChild(document.createTextNode("\u00a0"+grudiInappropriatedCommentd+"\u00a0Denúncias"))}else{commentParagraph.appendChild(commentImage);commentParagraph.appendChild(document.createTextNode("\u00a0"+grudiCommentd+"\u00a0Coment\u00E1rios"))}divGrudiStats.appendChild(rateParagraph);divGrudiStats.appendChild(favoriteParagraph);divGrudiStats.appendChild(commentParagraph);var divLine=document.createElement("DIV");divLine.className="linha_result";var cellInfo=document.createElement("TD");cellInfo.width="50%";cellInfo.appendChild(divGrudiInfo);var cellStats=document.createElement("TD");cellStats.width="50%";cellStats.appendChild(divGrudiStats);rowStats.appendChild(cellInfo);rowStats.appendChild(cellStats);tableBody.appendChild(rowHeader);if(edit){tableBody.appendChild(rowDescription);tableBody.appendChild(rowKeywords)}tableBody.appendChild(rowStats);if(edit){tableBody.appendChild(rowEditButton)}if(isInappropriatePage){var rowInappropriate=document.createElement("TR");var cellInappropriate=document.createElement("TD");cellInappropriate.colSpan="3";var divInappropriate=document.createElement("DIV");var listInappropriateButton=document.createElement("UL");listInappropriateButton.className="edit";var listItemInappropriate=document.createElement("LI");var linkInappropriate=document.createElement("A");linkInappropriate.href="javascript:void(0);";linkInappropriate.appendChild(document.createTextNode("Denúncias"));linkInappropriate.id=grudiID;var grudiInappropriateFunction=function(){Abrir(this.id)};linkInappropriate.onclick=grudiInappropriateFunction;listItemInappropriate.appendChild(linkInappropriate);listInappropriateButton.appendChild(listItemInappropriate);divInappropriate.appendChild(listInappropriateButton);cellInappropriate.appendChild(divInappropriate);rowInappropriate.appendChild(cellInappropriate);tableBody.appendChild(rowInappropriate)}tableGrudi.appendChild(tableBody);if((!edit)&&(i>0)){divResultSearch.appendChild(divLine)}divResultSearch.appendChild(tableGrudi);container.appendChild(divResultSearch)}}function loadGrudiUserPage(page,nickname,edit){var container=document.getElementById("divGrudiUserList");containerHeight=Math.max(container.clientHeight,container.offsetHeight);containerWidth=Math.max(container.clientWidth,container.offsetWidth);for(i=(container.childNodes.length-1);i>=0;i--){container.removeChild(container.childNodes[i])}container.style.width=containerWidth+"px";container.style.height=containerHeight+"px";if(edit){mountPagination("pageContainer",page,4,"hiddenGrudiCount","#grudis",function(){loadGrudiUserPage(arguments[0],nickname,true)},true);mountPagination("pageContainerBottom",page,4,"hiddenGrudiCount","#grudis",function(){loadGrudiUserPage(arguments[0],nickname,true)})}else{mountPagination("pageContainer",page,8,"hiddenGrudiCount","#grudis",function(){loadGrudiUserPage(arguments[0],nickname)},true);mountPagination("pageContainerBottom",page,8,"hiddenGrudiCount","#grudis",function(){loadGrudiUserPage(arguments[0],nickname)})}var image=document.createElement("IMG");image.src="images/ajax_loading.gif";image.style.position="relative";image.style.left=parseInt((containerWidth/2)-16)+"px";image.style.top=parseInt((containerHeight/2)-16)+"px";image.style.width="32px";image.style.height="32px";container.appendChild(image);var controller=new ControllerGrudiInfo();controller.onError=grudiLoadError;if(edit){controller.onComplete=function(xml){grudiUserLoadComplete(xml,true)};controller.loadByUser(nickname,4,(parseInt(page)-1)*4)}else{controller.onComplete=function(xml){grudiUserLoadComplete(xml,false)};controller.loadByUser(nickname,8,(parseInt(page)-1)*8)}}function loadGrudiFavoritePage(page,nickname,edit){var container=document.getElementById("divGrudiFavoriteList");containerHeight=Math.max(container.clientHeight,container.offsetHeight);containerWidth=Math.max(container.clientWidth,container.offsetWidth);for(i=(container.childNodes.length-1);i>=0;i--){container.removeChild(container.childNodes[i])}container.style.width=containerWidth+"px";container.style.height=containerHeight+"px";if(edit){mountPagination("pageContainerFavorite",page,4,"hiddenGrudiFavorites","#favorites",function(){loadGrudiFavoritePage(arguments[0],nickname,true)},true);mountPagination("pageContainerFavoriteBottom",page,4,"hiddenGrudiFavorites","#favorites",function(){loadGrudiFavoritePage(arguments[0],nickname,true)})}else{mountPagination("pageContainerFavorite",page,8,"hiddenGrudiFavorites","#favorites",function(){loadGrudiFavoritePage(arguments[0],nickname)},true);mountPagination("pageContainerFavoriteBottom",page,8,"hiddenGrudiFavorites","#favorites",function(){loadGrudiFavoritePage(arguments[0],nickname)})}var image=document.createElement("IMG");image.src="images/ajax_loading.gif";image.style.position="relative";image.style.left=parseInt((containerWidth/2)-16)+"px";image.style.top=parseInt((containerHeight/2)-16)+"px";image.style.width="32px";image.style.height="32px";container.appendChild(image);var controller=new ControllerGrudiInfo();controller.onError=grudiLoadError;if(edit){controller.onComplete=function(xml){grudiFavoriteLoadComplete(xml,true)};controller.loadFavorite(nickname,4,(parseInt(page)-1)*4)}else{controller.onComplete=function(xml){grudiFavoriteLoadComplete(xml,false)};controller.loadFavorite(nickname,8,(parseInt(page)-1)*8)}}function grudiUserLoadComplete(xml,edit){var container=document.getElementById("divGrudiUserList");if(edit){mountGrudiList(container,xml,edit,grudiDelete,editGrudi)}else{mountGrudiGrid(container,xml,4)}}function grudiFavoriteLoadComplete(xml,edit){var container=document.getElementById("divGrudiFavoriteList");if(edit){mountGrudiList(container,xml,edit,favoriteDelete)}else{mountGrudiGrid(container,xml,4)}}function grudiLoadError(message,code){if(parseInt(code)>800){var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var messageLayer=document.getElementById("grudi_info_message");messageLayer.innerHTML=message}}function loadGrudiSearchPage(page,query,servletCommand,quantity){var container=document.getElementById("divResultList");containerHeight=Math.max(parseInt(container.clientHeight),parseInt(container.offsetHeight));containerWidth=Math.max(parseInt(container.clientWidth),parseInt(container.offsetWidth));for(i=(container.childNodes.length-1);i>=0;i--){container.removeChild(container.childNodes[i])}container.style.width=containerWidth+"px";container.style.height="";quantity=((!quantity)||(null==quantity))?10:parseInt(quantity);mountPagination("pageContainer",page,parseInt(quantity),"hiddenGrudiCount","#result",function(){loadGrudiSearchPage(arguments[0],query,servletCommand,parseInt(quantity))},true);mountPagination("pageContainerBottom",page,parseInt(quantity),"hiddenGrudiCount","#result",function(){loadGrudiSearchPage(arguments[0],query,servletCommand,parseInt(quantity))});var image=document.createElement("IMG");image.src="images/ajax_loading.gif";image.style.position="relative";image.style.left=parseInt((containerWidth/2)-16)+"px";image.style.width="32px";image.style.height="32px";container.appendChild(image);var countFirst=document.getElementById("spanCountFirst");countFirst.innerHTML=((parseInt(page)-1)*parseInt(quantity))+1;var controller=new ControllerGrudiInfo();if(servletCommand.indexOf("INAPPROPRIATE")>=0){controller.onComplete=grudiInappropriateLoadComplete}else{controller.onComplete=grudiSearchLoadComplete}controller.onError=grudiLoadError;controller.loadSearch(servletCommand,query,parseInt(quantity),(parseInt(page)-1)*parseInt(quantity))}function grudiSearchLoadComplete(xml){var container=document.getElementById("divResultList");var countFirst=document.getElementById("spanCountFirst");var countLast=document.getElementById("spanCountLast");var grudis=xml.getElementsByTagName("grudi");if((countFirst)&&(grudis)){countLast.innerHTML=parseInt(countFirst.firstChild.nodeValue)+(grudis.length-1)}mountGrudiList(container,xml)}function grudiInappropriateLoadComplete(xml){var container=document.getElementById("divResultList");var countFirst=document.getElementById("spanCountFirst");var countLast=document.getElementById("spanCountLast");var grudis=xml.getElementsByTagName("grudi");if((countFirst)&&(grudis)){countLast.innerHTML=parseInt(countFirst.firstChild.nodeValue)+(grudis.length-1)}mountGrudiList(container,xml,false,null,null,true)}function confirmDelete(dialogObject,grudi){if(dialogObject.optionResult==1){var controller=new ControllerGrudiInfo();controller.onComplete=grudiDeleteComplete;controller.onError=grudiDeleteError;controller.deleteGrudi(grudi)}}function grudiDelete(grudi){var dialogConfim=new Dialog();dialogConfim.showConfirmDialog("Deletar Grudi","Deseja remover o grudi selecionado ?",1,function(dialogObject){confirmDelete(dialogObject,grudi)})}function grudiDeleteComplete(xml){var page=1;var currentPage=document.getElementById("pageContainerPage");if(currentPage){page=parseInt(currentPage.value)}var hiddenGrudiCount=document.getElementById("hiddenGrudiCount");if(hiddenGrudiCount){hiddenGrudiCount.value=(parseInt(hiddenGrudiCount.value)-1)}var userNickname=xml.getElementsByTagName("userNickname")[0].firstChild.nodeValue+"";loadGrudiUserPage(page,userNickname,true)}function grudiDeleteError(message,code){var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var messageLayer=document.getElementById("grudi_info_message");messageLayer.innerHTML=message}function editGrudiDialog(){var layer=document.getElementById("divEditGrudiDialog");var closeButton=document.getElementById("closeEditGrudiDialog");var loadGrudiLink=document.getElementById("loadGrudiLink");var loadGrudi=loadGrudiLink.onclick;loadGrudi();(new Dialog()).showLayerDialog(layer,layer.offsetParent,closeButton,false,null,null,null)}function editGrudi(grudi,title,description,keywords,thumbnail){closeLayerInfo();var grudiInfo=grudi.split("|");grudiInfoEdit=grudiInfo;editGrudiDialog()}function confirmDeleteFavorite(dialogObject,grudi){if(dialogObject.optionResult==1){var controller=new ControllerGrudiInfo();controller.onComplete=favoriteDeleteComplete;controller.onError=favoriteDeleteError;controller.deleteFavorite(grudi)}}function favoriteDeleteComplete(xml){var page=1;var currentPage=document.getElementById("pageContainerFavoritePage");if(currentPage){page=parseInt(currentPage.value)}var hiddenGrudiFavorites=document.getElementById("hiddenGrudiFavorites");if(hiddenGrudiFavorites){hiddenGrudiFavorites.value=(parseInt(hiddenGrudiFavorites.value)-1)}var userNickname=xml.getElementsByTagName("nickname")[0].firstChild.nodeValue+"";loadGrudiFavoritePage(page,userNickname,true)}function favoriteDeleteError(message,code){var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var messageLayer=document.getElementById("grudi_info_message");messageLayer.innerHTML=message}function favoriteDelete(grudi){var dialogConfim=new Dialog();dialogConfim.showConfirmDialog("Deletar Favorito","Deseja remover este grudi da sua lista de favoritos ?",1,function(dialogObject){confirmDeleteFavorite(dialogObject,grudi)})}function sentGrudiValidateName(name){var resultValue=null;if((trim(name).length==0)){resultValue="Digite um nome."}return resultValue}function sentGrudiValidateEmail(email){var resultValue=null;if(email.length==0){resultValue="E-mail inv\u00E1lido."}else{if(email.indexOf("@")==-1){resultValue="E-mail inv\u00E1lido"}else{if(email.indexOf(".")==-1){resultValue="E-mail inv\u00E1lido"}}}return resultValue}function sentGrudiValidate(){var txtSendName=document.getElementById("txtSendName");var txtSendEmail=document.getElementById("txtSendEmail");var info_grudi_textarea=document.getElementById("info_grudi_textarea");var info_message_sendgrudi=document.getElementById("info_message_sendgrudi");info_message_sendgrudi.innerHTML="\u00a0";if(trim(txtSendName.value)==trim(txtSendName.title)){info_message_sendgrudi.innerHTML="Digite um nome.";txtSendName.focus();return false}var message=sentGrudiValidateName(txtSendName.value);if(message!=null){info_message_sendgrudi.innerHTML=message;txtSendName.focus();return false}if(trim(txtSendEmail.value)==trim(txtSendEmail.title)){info_message_sendgrudi.innerHTML="E-mail inv\u00E1lido";txtSendEmail.focus();return false}var message=sentGrudiValidateEmail(txtSendEmail.value);if(message!=null){info_message_sendgrudi.innerHTML=message;txtSendEmail.focus();return false}return true}function showSendMailMessage(msg){var txtSendName=document.getElementById("txtSendName");var txtSendEmail=document.getElementById("txtSendEmail");var info_grudi_textarea=document.getElementById("info_grudi_textarea");txtSendName.value="";txtSendEmail.value="";info_grudi_textarea.value="";blurLabledField(txtSendName);blurLabledField(txtSendEmail);blurLabledField(info_grudi_textarea);var send_grudi_email=document.getElementById("send_grudi_email");send_grudi_email.style.display="block";var send_email_info=document.getElementById("send_email_info");var message=document.getElementById("send_email_info_msg");send_email_info.style.display="block";message.innerHTML=msg}function sendGrudiComplete(xml){showSendMailMessage("E-mail enviado com sucesso!")}function sendGrudiError(message,code){showSendMailMessage("N\u00E3o foi poss\u00EDvel enviar o e-mail.")}function sendGrudiEmail(grudi,logged){if(logged){if(sentGrudiValidate()){var txtSendName=document.getElementById("txtSendName");var txtSendEmail=document.getElementById("txtSendEmail");var info_grudi_textarea=document.getElementById("info_grudi_textarea");var name=txtSendName.value;var email=txtSendEmail.value;var message=info_grudi_textarea.value;var sentGrudi=new SentGrudi();sentGrudi.setRecipientName(name);sentGrudi.setRecipientEmail(email);sentGrudi.setBodyMessage(message);var send_grudi_email=document.getElementById("send_grudi_email");send_grudi_email.style.display="none";var send_email_info=document.getElementById("send_email_info");var message=document.getElementById("send_email_info_msg");send_email_info.style.display="block";var image=document.createElement("IMG");image.src="images/ajax_loading.gif";image.style.width="32px";image.style.height="32px";message.appendChild(image);var controller=new ControllerGrudiInfo();controller.onComplete=sendGrudiComplete;controller.onError=sendGrudiError;controller.sendGrudi(sentGrudi,grudi)}}else{showSendMailMessage("Acesse ou crie sua conta.")}}function ControllerGrudiRate(){this.DEFAULT_SERVLET_NAME="site.grudi";this.responseXML;this.messageArray=new Array()}ControllerGrudiRate.prototype.setGrudiRate=function(grudiRate){this.grudiRate=grudiRate};ControllerGrudiRate.prototype.setResponseXML=function(responseXML){this.responseXML=responseXML};ControllerGrudiRate.prototype.onComplete=function(functionHandler){functionHandler()};ControllerGrudiRate.prototype.onError=function(functionHandler){functionHandler()};ControllerGrudiRate.prototype.post=function(idGrudi,rate){completeFunction=this.onComplete;errorFunction=this.onError;http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("SET_GRUDI_RATE");var parameters="command="+command+"&rate="+rate+"&grudi="+idGrudi;http_request.onreadystatechange=this.postComplete;http_request.open("POST",this.DEFAULT_SERVLET_NAME,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(parameters)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel realizar a avalia\u00E7\u00E3o.<br> Tente novamente mais tarde.")}};ControllerGrudiRate.prototype.postComplete=function(){if((http_request.readyState==4)&&(http_request.status==200)){http_request.responseXML;if(http_request.responseXML.getElementsByTagName("error")[0]){var message=http_request.responseXML.getElementsByTagName("message")[0].firstChild.nodeValue+"";var code=http_request.responseXML.getElementsByTagName("code")[0].firstChild.nodeValue+"";errorFunction(message,code)}else{var rate=http_request.responseXML.getElementsByTagName("grudiRate")[0].firstChild.nodeValue+"";completeFunction(rate)}}else{if((http_request.readyState==4)&&(http_request.status!=200)){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel realizar a avalia\u00E7\u00E3o.<br> Tente novamente mais tarde.")}}};var rating=false;var grudiAlreadyRated=false;function changeRateStars(imageStar,logged,out){if(((logged==true)&&(!grudiAlreadyRated))||(out)){if(!out){rating=true;if(imageStar.src){var imageSource=imageStar.src+"";var imageRate=getNumbers(imageStar.id);var imageID=imageStar.id.substring(0,imageStar.id.indexOf(imageRate));if(imageSource.lastIndexOf("off")>-1){for(var i=1;i<=parseInt(imageRate);i++){var rateStar=document.getElementById(imageID+i);if(rateStar){if(rateStar.src.lastIndexOf("off")>-1){rateStar.src=imageSource.replace("off","on")}}}}else{for(var i=5;i>parseInt(imageRate);i--){var rateStar=document.getElementById(imageID+i);if(rateStar){if(rateStar.src.lastIndexOf("on")>-1){rateStar.src=imageSource.replace("on","off")}}}}}else{var starsContainer=document.getElementById("img_stars");var imageRate=parseInt(getNumbers(imageStar.title));for(i=(starsContainer.childNodes.length-1);i>=0;i--){var divStar=starsContainer.childNodes[i];var starRate=getNumbers(divStar.title+"");starRate=isNaN(parseInt(starRate))?0:parseInt(starRate);if(starRate>0){if(starRate<=imageRate){if(divStar.id.lastIndexOf("off")>-1){divStar.id=(divStar.id+"").replace("off","on")}}else{if(divStar.id.lastIndexOf("on")>-1){divStar.id=(divStar.id+"").replace("on","off")}}}}}}else{if((document.getElementById("rated"))&&(!rating)){currentRate=parseInt(document.getElementById("rated").value);imageID="star";var starsContainer=document.getElementById("img_stars");if(starsContainer){for(i=(starsContainer.childNodes.length-1);i>=0;i--){var divStar=starsContainer.childNodes[i];var starRate=getNumbers(divStar.title+"");starRate=isNaN(parseInt(starRate))?0:parseInt(starRate);if(starRate>0){if(starRate<=currentRate){if(divStar.id.lastIndexOf("off")>-1){divStar.id=(divStar.id+"").replace("off","on")}}else{if(divStar.id.lastIndexOf("on")>-1){divStar.id=(divStar.id+"").replace("on","off")}}}}}else{for(var i=1;i<=5;i++){var rateStar=document.getElementById(imageID+i);if(rateStar){if(i<=currentRate){rateStar.src=rateStar.src.replace("off","on")}else{rateStar.src=rateStar.src.replace("on","off")}}}}}}}}function rateComplete(rate){var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var messageLayer=document.getElementById("grudi_info_message");messageLayer.innerHTML="Obrigado por sua avalia\u00E7\u00E3o";var ratedSpan=document.getElementById("spanGrudiRated");if(ratedSpan){var ratedCount=parseInt(ratedSpan.outterHTML);alert(ratedSpan.outterHTML);ratedCount++;ratedSpan.innerHTML=ratedCount}grudiAlreadyRated=true;document.getElementById("rated").value=rate}function rateError(message,code){if(parseInt(code)>800){var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var messageLayer=document.getElementById("grudi_info_message");messageLayer.innerHTML=message;if(parseInt(code)==801){grudiAlreadyRated=(parseInt(code)==801);rating=false;changeRateStars(null,true,true)}}}function rateGrudi(imageStar,logged,idGrudi){if((logged)&&(!grudiAlreadyRated)){var imageRate=getNumbers(imageStar.id);imageRate=isNaN(parseInt(imageRate))?parseInt(getNumbers(imageStar.title)):parseInt(imageRate);var image=document.createElement("IMG");image.src="images/ajax_loading.gif";image.style.width="32px";image.style.height="32px";var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var message=document.getElementById("grudi_info_message");message.innerHTML="";message.appendChild(image);var controller=new ControllerGrudiRate();controller.onComplete=rateComplete;controller.onError=rateError;controller.post(idGrudi,imageRate)}else{if(!grudiAlreadyRated){var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var message=document.getElementById("grudi_info_message");message.innerHTML="Acesse ou crie sua conta para avaliar este grudi."}}}function ControllerInappropriate(){this.DEFAULT_SERVLET_NAME="site.grudi";this.responseXML;this.messageArray=new Array()}ControllerInappropriate.prototype.setResponseXML=function(responseXML){this.responseXML=responseXML};ControllerInappropriate.prototype.onComplete=function(functionHandler){functionHandler()};ControllerInappropriate.prototype.onError=function(functionHandler){functionHandler()};ControllerInappropriate.prototype.onLoadComplete=function(functionHandler){functionHandler()};ControllerInappropriate.prototype.onLoadError=function(functionHandler){functionHandler()};ControllerInappropriate.prototype.post=function(idGrudi,comment){completeFunction=this.onComplete;errorFunction=this.onError;http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("ADD_GRUDI_INAPPROPRIATE");var commentText="";if((navigator.appName.indexOf("Explorer")>-1)){commentText=escape(comment)}else{commentText=encodeURIComponent(comment)}var parameters="command="+command+"&grudi="+idGrudi+"&comment="+commentText;http_request.onreadystatechange=this.postComplete;http_request.open("POST",this.DEFAULT_SERVLET_NAME,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(parameters)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel enviar sua denúncia.<br> Tente novamente mais tarde.")}};ControllerInappropriate.prototype.postComplete=function(){if((http_request.readyState==4)&&(http_request.status==200)){http_request.responseXML;if(http_request.responseXML.getElementsByTagName("error")[0]){var message=http_request.responseXML.getElementsByTagName("message")[0].firstChild.nodeValue+"";var code=http_request.responseXML.getElementsByTagName("code")[0].firstChild.nodeValue+"";errorFunction(message,code)}else{var xml=http_request.responseXML;completeFunction(xml)}}else{if((http_request.readyState==4)&&(http_request.status!=200)){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel enviar sua denúncia.<br> Tente novamente mais tarde.")}}};function showInappropriateBox(logged){if(logged){var commentTextArea=document.getElementById("inappropriateText");commentTextArea.value="";var message=document.getElementById("inappropriate_message");message.innerHTML="";var inappropriateBox=document.getElementById("inappropriate_layer");if(inappropriateBox.style.display){inappropriateBox.style.display="block"}}else{var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var message=document.getElementById("grudi_info_message");message.innerHTML="Acesse ou crie sua conta para denunciar este grudi."}}function addGrudiInappropriate(logged,idGrudi){if(logged){var commentTextArea=document.getElementById("inappropriateText");var commentValue=(commentTextArea.value+"");if(trim(commentValue).length>0){closeLayerInfo("inappropriate_layer");var image=document.createElement("IMG");image.src="images/ajax_loading.gif";image.style.width="32px";image.style.height="32px";var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var message=document.getElementById("grudi_info_message");message.innerHTML="";message.appendChild(image);var controller=new ControllerInappropriate();controller.onComplete=inappropriateComplete;controller.onError=inappropriateError;controller.post(idGrudi,commentValue)}else{var message=document.getElementById("inappropriate_message");message.innerHTML="Por favor, escreva o motivo pelo qual deseja denunciar este grudi.";alert("Por favor, escreva o motivo pelo qual deseja denunciar este grudi.")}}else{var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var message=document.getElementById("grudi_info_message");message.innerHTML="Acesse ou crie sua conta para denunciar este grudi."}}function inappropriateError(message,code){var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var messageLayer=document.getElementById("grudi_info_message");messageLayer.innerHTML=message}function inappropriateComplete(xml){var info=document.getElementById("grudi_layer_info");info.style.height="50px";info.style.display="block";var messageLayer=document.getElementById("grudi_info_message");messageLayer.innerHTML="Sua denúncia foi enviada e ser\u00E1 analisada pela equipe do myGrudi.";var commentTextArea=document.getElementById("inappropriateText");commentTextArea.value="";location.href="#info_message"}function inappropriateTextChange(){var commentTextArea=document.getElementById("inappropriateText");if(commentTextArea.value){var commentValue=(commentTextArea.value+"");if(commentValue.length>600){commentValue=commentValue.substr(0,600);commentTextArea.value=commentValue;var selection=new Selection(commentTextArea);var s=selection.getCaret();selection.setCaret(+599||0,+600||0);commentTextArea.focus()}var spanLettersCount=document.getElementById("lettersCountInappropriate");spanLettersCount.innerHTML=commentValue.length}}function ControllerLogin(user){this.DEFAULT_SERVLET_NAME="action";this.user=user;this.responseXML}ControllerLogin.prototype.setUser=function(user){this.user=user};ControllerLogin.prototype.setResponseXML=function(responseXML){this.responseXML=responseXML};ControllerLogin.prototype.onComplete=function(functionHandler){functionHandler()};ControllerLogin.prototype.onLoginError=function(functionHandler){functionHandler()};ControllerLogin.prototype.post=function(remember){http_request=getXMLHTTPObject();completeFunction=this.onComplete;errorFunction=this.onLoginError;try{if(http_request){var command=encodeURIComponent("USER_LOGIN");var xmlText="";if((navigator.appName.indexOf("Explorer")>-1)){xmlText=escape(this.user.saveToXML())}else{xmlText=encodeURIComponent(this.user.saveToXML())}var parameters="command="+command+"&xmlText="+xmlText;if(remember){parameters=parameters+"&remember=true"}http_request.onreadystatechange=this.postComplete;http_request.open("POST","action.grudi",true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.send(parameters)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel realizar o login.<br> Tente novamente mais tarde.")}};ControllerLogin.prototype.logout=function(){http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("USER_LOGOUT");var parameters="command="+command;http_request.onreadystatechange=this.logoutComplete;http_request.open("POST","action.grudi",true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.send(parameters)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel realizar o login.<br> Tente novamente mais tarde.")}};ControllerLogin.prototype.resetPassword=function(email){http_request=getXMLHTTPObject();completeFunction=this.onComplete;errorFunction=this.onLoginError;try{if(http_request){var command=encodeURIComponent("USER_RESET_PASSWORD");var pEmail="";if((navigator.appName.indexOf("Explorer")>-1)){pEmail=escape(email)}else{pEmail=encodeURIComponent(email)}var parameters="command="+command+"&email="+pEmail;http_request.onreadystatechange=this.postComplete;http_request.open("POST","action.grudi",true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.send(parameters)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi redefinir a senha.<br> Tente novamente mais tarde.")}};ControllerLogin.prototype.postComplete=function(){if((http_request.readyState==4)&&(http_request.status==200)){if(http_request.responseXML.getElementsByTagName("error")[0]){var message=http_request.responseXML.getElementsByTagName("message")[0].firstChild.nodeValue+"";errorFunction(message)}else{var username=http_request.responseXML.getElementsByTagName("nickname")[0].firstChild.nodeValue+"";completeFunction()}}else{if((http_request.readyState==4)&&(http_request.status!=200)){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel realizar o login.<br> Tente novamente mais tarde.")}}};ControllerLogin.prototype.logoutComplete=function(){if((http_request.readyState==4)&&(http_request.status==200)){if((http_request.responseXML)&&(http_request.responseXML.getElementsByTagName("error")[0])){var message=http_request.responseXML.getElementsByTagName("message")[0].firstChild.nodeValue+"";(new Dialog()).showMessageDialog("myGrudi",message)}else{window.setTimeout("refresh();",250)}}else{if((http_request.readyState==4)&&(http_request.status!=200)){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel realizar o logout.<br> Tente novamente mais tarde.")}}};function ControllerUser(user){this.DEFAULT_SERVLET_NAME="action.grudi";this.user=user;this.responseXML;this.messageArray=new Array()}ControllerUser.prototype.setUser=function(user){this.user=user};ControllerUser.prototype.setResponseXML=function(responseXML){this.responseXML=responseXML};ControllerUser.prototype.onComplete=function(functionHandler){functionHandler()};ControllerUser.prototype.onError=function(functionHandler){functionHandler()};ControllerUser.prototype.validateNickname=function(nickname){var resultValue=null;if((nickname.length==0)){resultValue="Digite um apelido."}else{for(i=0;i<(nickname.length-1);i++){charCode=nickname.charCodeAt(i);if(!((codeIsLetter(charCode))||(codeIsNumber(charCode))||(charCode==95))){resultValue='Car\u00E1cter inv\u00E1lido "'+nickname.charAt(i)+'"';break}}}return resultValue};ControllerUser.prototype.validateEmail=function(email){var resultValue=null;if(email.length==0){resultValue="Digite seu endere\u00E7o de e-mail."}else{if(email.indexOf("@")==-1){resultValue="Falta o sinal @ no seu e-mail."}else{if(email.indexOf(".")==-1){resultValue='Falta um dom\u00EDnio v\u00E1lido ex "netcartas.com.br".'}}}return resultValue};ControllerUser.prototype.validatePassword=function(passwordField,passwordMatch){var resultValue=null;if(passwordField.length==0){resultValue="Escolha uma senha."}else{if(passwordField.length<6){resultValue="Sua senha deve ter no m\u00EDnimo 6 caracteres."}else{if(passwordMatch.length==0){resultValue="Confirme sua senha."}else{if(passwordMatch!=passwordField){resultValue="Senha e confirma\u00E7\u00E3o de senha n\u00E3o s\u00E3o iguais."}}}}return resultValue};ControllerUser.prototype.validate=function(checkPassword,update){if(!update){(this.validateNickname(this.user.getNickname())!=null)?this.messageArray.push(this.validateNickname(this.user.getNickname())):null;(this.validateEmail(this.user.getEmail())!=null)?this.messageArray.push(this.validateEmail(this.user.getEmail())):null}if(checkPassword){(this.validatePassword(this.user.getPassword(),this.user.getPasswordConfirmation())!=null)?this.messageArray.push(this.validatePassword(this.user.getPassword(),this.user.getPasswordConfirmation())):null}return(this.messageArray.length==0)};ControllerUser.prototype.post=function(){completeFunction=this.onComplete;errorFunction=this.onError;if(this.validate(true,false)){http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("USER_CREATE_ACCOUNT");var xmlText="";if((navigator.appName.indexOf("Explorer")>-1)){xmlText=escape(this.user.saveToXML())}else{xmlText=encodeURIComponent(this.user.saveToXML())}var parameters="command="+command+"&xmlText="+xmlText;http_request.onreadystatechange=this.postComplete;http_request.open("POST","action.grudi",true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(parameters)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel realizar o cadastro.<br> Tente novamente mais tarde.")}}else{var fullMessage="";fullMessage=(this.messageArray.length>0)?this.messageArray[0]:"";errorFunction(fullMessage)}};ControllerUser.prototype.update=function(changePassword,oldPassword){completeFunction=this.onComplete;errorFunction=this.onError;if(this.validate(changePassword,true)){http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("USER_UPDATE");var xmlText="";if((navigator.appName.indexOf("Explorer")>-1)){xmlText=escape(this.user.saveToXML())}else{xmlText=encodeURIComponent(this.user.saveToXML())}var parameters="command="+command+"&xmlText="+xmlText;if(changePassword){parameters=parameters+"&changePassword=1&oldPassword="+oldPassword}http_request.onreadystatechange=this.postComplete;http_request.open("POST","action.grudi",true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(parameters)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel realizar o cadastro.<br> Tente novamente mais tarde.")}}else{var fullMessage="";fullMessage=(this.messageArray.length>0)?this.messageArray[0]:"";errorFunction(fullMessage)}};ControllerUser.prototype.postComplete=function(){if((http_request.readyState==4)&&(http_request.status==200)){http_request.responseXML;if(http_request.responseXML.getElementsByTagName("error")[0]){var message=http_request.responseXML.getElementsByTagName("message")[0].firstChild.nodeValue+"";errorFunction(message)}else{var nickname=http_request.responseXML.getElementsByTagName("nickname")[0].firstChild.nodeValue+"";completeFunction()}}else{if((http_request.readyState==4)&&(http_request.status!=200)){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel realizar o cadastro.<br> Tente novamente mais tarde.")}}};ControllerUser.prototype.updateComplete=function(){if((http_request.readyState==4)&&(http_request.status==200)){http_request.responseXML;if(http_request.responseXML.getElementsByTagName("error")[0]){var message=http_request.responseXML.getElementsByTagName("message")[0].firstChild.nodeValue+"";errorFunction(message)}else{var nickname=http_request.responseXML.getElementsByTagName("nickname")[0].firstChild.nodeValue+"";completeFunction()}}else{if((http_request.readyState==4)&&(http_request.status!=200)){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel atualizar o cadastro.<br> Tente novamente mais tarde.")}}};function ControllerReportBug(){this.DEFAULT_SERVLET_NAME="site.grudi";this.responseXML;this.messageArray=new Array()}ControllerReportBug.prototype.setResponseXML=function(responseXML){this.responseXML=responseXML};ControllerReportBug.prototype.onComplete=function(functionHandler){functionHandler()};ControllerReportBug.prototype.onError=function(functionHandler){functionHandler()};ControllerReportBug.prototype.onLoadComplete=function(functionHandler){functionHandler()};ControllerReportBug.prototype.onLoadError=function(functionHandler){functionHandler()};ControllerReportBug.prototype.post=function(comment,emailFrom,messageSubject){completeFunction=this.onComplete;errorFunction=this.onError;http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("REPORT_BUG");var commentText="";if((navigator.appName.indexOf("Explorer")>-1)){commentText=escape(comment);emailFrom=escape(emailFrom);messageSubject=escape(messageSubject)}else{commentText=encodeURIComponent(comment);emailFrom=encodeURIComponent(emailFrom);messageSubject=encodeURIComponent(messageSubject)}var parameters="command="+command+"&email="+emailFrom+"&subject="+messageSubject+"&comment="+commentText;http_request.onreadystatechange=this.postComplete;http_request.open("POST",this.DEFAULT_SERVLET_NAME,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(parameters)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel enviar seu coment\u00E1rio.<br> Tente novamente mais tarde.")}};ControllerReportBug.prototype.postComplete=function(){if((http_request.readyState==4)&&(http_request.status==200)){http_request.responseXML;if(http_request.responseXML.getElementsByTagName("error")[0]){var message=http_request.responseXML.getElementsByTagName("message")[0].firstChild.nodeValue+"";var code=http_request.responseXML.getElementsByTagName("code")[0].firstChild.nodeValue+"";errorFunction(message,code)}else{var xml=http_request.responseXML;completeFunction(xml)}}else{if((http_request.readyState==4)&&(http_request.status!=200)){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel enviar sua coment\u00E1rio.<br> Tente novamente mais tarde.")}}};function sendReportBug(){var commentTextArea=document.getElementById("txtReportComment");var emailFrom=document.getElementById("txtEmailReport").value+"";var messageSubject=document.getElementById("txtSubjectReport").value+"";var commentValue=(commentTextArea.value+"");if(trim(commentValue).length>0){var image=document.createElement("IMG");image.src="images/ajax_loading.gif";image.style.width="32px";image.style.height="32px";image.style.top="25%";var info=document.getElementById("layer_info");info.innerHTML="";info.appendChild(image);info.style.height="50px";info.style.display="block";var reportForm=document.getElementById("reportForm");reportForm.style.display="none";var controller=new ControllerReportBug();controller.onComplete=reportBugComplete;controller.onError=reportBugError;controller.post(commentValue,emailFrom,messageSubject)}}function reportBugError(message,code){var layer_info=document.getElementById("layer_info");layer_info.style.height="50px";layer_info.style.display="block";layer_info.innerHTML=message}function reportBugComplete(xml){var info=document.getElementById("layer_info");info.style.display="none";var reportForm=document.getElementById("reportForm");reportForm.style.display="none";var reportMessage=document.getElementById("reportMessage");reportMessage.style.display="block"}function ControllerValidate(){this.DEFAULT_SERVLET_NAME="action.grudi";this.responseXML;this.messageArray=new Array()}ControllerValidate.prototype.setResponseXML=function(responseXML){this.responseXML=responseXML};ControllerValidate.prototype.onComplete=function(functionHandler){functionHandler()};ControllerValidate.prototype.onError=function(functionHandler){functionHandler()};ControllerValidate.prototype.onLoadComplete=function(functionHandler){functionHandler()};ControllerValidate.prototype.onLoadError=function(functionHandler){functionHandler()};ControllerValidate.prototype.post=function(){completeFunction=this.onComplete;errorFunction=this.onError;http_request=getXMLHTTPObject();try{if(http_request){var command=encodeURIComponent("USER_RESEND_ACTIVATION");var parameters="command="+command;http_request.onreadystatechange=this.postComplete;http_request.open("POST",this.DEFAULT_SERVLET_NAME,true);http_request.setRequestHeader("Content-type","application/x-www-form-urlencoded");http_request.setRequestHeader("Charset","UTF-8");http_request.send(parameters)}}catch(e){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel enviar o e-mail de valida\u00E7\u00E3o.<br> Tente novamente mais tarde.")}};ControllerValidate.prototype.postComplete=function(){if((http_request.readyState==4)&&(http_request.status==200)){http_request.responseXML;if(http_request.responseXML.getElementsByTagName("error")[0]){var message=http_request.responseXML.getElementsByTagName("message")[0].firstChild.nodeValue+"";var code=http_request.responseXML.getElementsByTagName("code")[0].firstChild.nodeValue+"";errorFunction(message,code)}else{var xml=http_request.responseXML;completeFunction(xml)}}else{if((http_request.readyState==4)&&(http_request.status!=200)){(new Dialog()).showMessageDialog("myGrudi","N\u00E3o foi poss\u00EDvel enviar o e-mail de valida\u00E7\u00E3o.<br> Tente novamente mais tarde.")}}};function validateAccount(){var message=null;var command="action.grudi?command=USER_ACTIVATE&email=[email]&code=[code]";var homePage=(window.location+"");homePage=homePage.substr(0,(homePage.lastIndexOf("/")+1));var emailValidate=document.getElementById("txtEmailValidate").value;var validationCode=document.getElementById("txtValidationCode").value;if(trim(validationCode).length==0){message="Digite o c\u00F3digo de valida\u00E7\u00E3o."}else{if(trim(validationCode).length!=32){message="O c\u00F3digo de valida\u00E7\u00E3o digitado n\u00E3o \u00E9 v\u00E1lido."}}if(null==message){command=command.replace("[email]",emailValidate);command=command.replace("[code]",validationCode);window.location=homePage+command}else{document.getElementById("validate_layer_message").innerHTML=message}}function resendValidation(){var image=document.createElement("IMG");image.src="images/ajax_loading.gif";image.style.width="32px";image.style.height="32px";image.style.top="25%";var info=document.getElementById("validate_layer_info");info.innerHTML="";info.appendChild(image);info.style.height="50px";info.style.display="block";var reportForm=document.getElementById("validateForm");reportForm.style.display="none";var controller=new ControllerValidate();controller.onComplete=resendValidationComplete;controller.onError=resendValidationError;controller.post()}function resendValidationError(message,code){var info=document.getElementById("validate_layer_info");info.style.height="50px";info.style.display="block";info.innerHTML=message}function resendValidationComplete(xml){var info=document.getElementById("validate_layer_info");info.style.display="none";var reportForm=document.getElementById("validateForm");reportForm.style.display="none";var reportMessage=document.getElementById("validateMessage");reportMessage.style.display="block"};
