var COMMENT_SERVICE="/services/Comments";var SOCIAL_SERVICE="/services/Social";var working=false;function flagItem(C,B,A){establishActiveUser(function(){if(working){return }working=true;var D="event=saveFlag&item="+C+"&type="+B;YAHOO.util.Connect.asyncRequest("POST",SOCIAL_SERVICE,{success:function(E){var F=JSON.parse(E.responseText);if(F.result&&F.result=="OK"){A.innerHTML="Flagged!";A.style.backgroundImage="none"}working=false},failure:function(E){}},D)})}function voteThumbsUp(D,C,B,A){establishActiveUser(function(){if(working){return }working=true;var E="event=voteThumbsUp&item="+D+"&type="+C+"&vote="+A;E+="&"+getSessionParams();YAHOO.util.Connect.asyncRequest("POST",SOCIAL_SERVICE,{success:function(F){var G=JSON.parse(F.responseText);if(G.result&&G.result=="OK"){B.parentNode.innerHTML="Voted!"}else{if(G.error){var H=G.error.replace(/-/," ");showPrompt("Voting Failed",H)}}working=false},failure:function(F){}},E)})}function addComment(D,B,A,F){var C=document.getElementById("commentText"+D)||document.getElementById("commentText");var E=C.value;if(!E||E.length<3){showPrompt("Please type something longer");return }A.disabled=true;saveComment(D,B,E,function(H){var G=JSON.parse(H.responseText);var J=$("commentCount");if(J){J.innerHTML=parseInt(J.innerHTML)+1;J.parentNode.style.display=""}var I=document.createElement("DIV");$("commentArea").appendChild(I);I.innerHTML=G.html;displaySuccessBox(D);A.disabled=false;if(F){F(G.html)}})}function saveComment(B,A,C,D){establishActiveUser(function(){if(working){return }working=true;var E="event=addComment&text="+encode(C)+"&type="+A+"&item="+B;E+="&forGecko=true";E+="&"+getSessionParams();YAHOO.util.Connect.asyncRequest("POST",COMMENT_SERVICE,{success:function(F){if(D){D(F)}working=false},failure:function(F){}},E)},"Please login to comment")}function deleteComment(C,A,B,D){establishActiveUser(function(){if(working){return }working=true;var E="event=deleteComment&type="+A+"&item="+C;E+="&"+getSessionParams();YAHOO.util.Connect.asyncRequest("POST",COMMENT_SERVICE,{success:function(F){if(F.responseText.indexOf("OK")>=0){var G=$("commentCount");if(G){G.innerHTML=parseInt(G.innerHTML)-1}B=YAHOO.util.Dom.getAncestorByClassName(B,"comment");if(B){B.style.display="none"}}working=false},failure:function(F){}},E)})}var rtes=[];var tempRte;var iconText=new Array("Random note","I like!...","Muchos appreciation","Keep'em coming","Great writing","I like your thinking","You helped a brother out","You cracked me up","Holy street cred!","You're hardcore","Scary stuff","What the...?");var iconBody=new Array("","You very good for make information.  Tzequi!","Danke. Thank-you. Merci. Gracias. Arigato!","Just keep writing, just keep writing, I`ll keep reading. :)","Your writing is a work of art.","I find myself strangely attracted to your brain.","If it weren`t for you I would have fallen into a pit of snakes and died a slow horrible death.  Instead I got all my travel expenses paid for, found the love of my life and lived happily ever after.","You so funny when you say stuff.","Thugs and gang leaders from around the world wish they were you right now.","Holy moly you`re one tough cookie!","How`d you keep it together?  I would`ve peed myself silly if I`d been in your boots!","?...");var iconImages=new Array("compliment_random.png","compliment_like.png","compliment_appreciation.png","compliment_coming.png","compliment_great.png","compliment_thinking.png","compliment_helped.png","compliment_crackup.png","compliment_street.png","compliment_hardcore.png","compliment_scary.png","compliment_whatthe.png");function isNewText(B){if(B=="<br>"){return false}for(var A=0;A<iconBody.length;A++){if(iconBody[A]==B){return false}}return true}function displayComplimentBox(D){var C=document.getElementById("rte"+D);document.getElementById("box"+D).style.display="";tempRte=new WYSIWYG_Editor("tempRte",C,"","http://ui.geckogo.com/ui/editor",392,100);tempRte.setModeToggle(hasUserPriv());tempRte.setAllowAnchors(hasUserPriv());rtes[D]=tempRte;rtes[D].display();var B="<form name='form"+D+"'>";for(var A=0;A<iconText.length;A++){if(A%2==0){B+="<div>"}B+="<div class='compliment-box'><input type='radio' class='compliment-radio' name='icons' value='"+A+"' onclick='if(!isNewText(rtes["+D+"].getContent().toString())) { rtes["+D+'].setContent("'+iconBody[A]+"\") }'><img src='http://ui.geckogo.com/ui/media/"+iconImages[A]+"'><span class='compliment-text'>"+iconText[A]+"</span></div>";if((A+1)%2==0||A==iconText.length-1){B+="</div>"}}B+="</form>";document.getElementById("icons"+D).innerHTML=B}function closeComplimentBox(A){document.getElementById("box"+A).style.display="none"}var reviewId=null;function sendItemCompliment(H){reviewId=H;if(!loggedIn){establishActiveUser(complimentCallback);return }var F=null;var B=document.forms;var D=0;for(var C=0;!F&&C<B.length;C++){if(B[C].name.indexOf(H+"")>0){F=B[C]}}for(var C=0;C<F.icons.length;C++){if(F.icons[C].checked){D=F.icons[C].value}}var E=document.getElementById("box"+H);var A=rtes[H].getContent();while(A.indexOf("<br>")==0){A=A.replace("<br>","")}for(var C=A.toString().length-4;C>0;C-=4){if(A.substring(C,C+4)=="<br>"){A=A.substring(0,C)}else{break}}A=encode(A)||"";var G="event=addCompliment&relatedId="+H+"&text="+A+"&type="+D;YAHOO.util.Connect.asyncRequest("POST","/services/Compliments",{success:function(I){var J=I.responseText;if(J=="OK"){E.innerHTML="<b>Thank you, your compliment is posted!</b>";setTimeout("location.reload(true);",3000)}else{alert(J)}},failure:function(I){reportAjaxFailure()}},G)}function complimentCallback(A){if(A!="cancel"){loggedIn=true;sendItemCompliment(reviewId)}}function toggleCompliments(B){var A=document.getElementById("comments"+B);A.style.display=(A.style.display=="none")?"":"none"}function toggleInputBox(B){var A=document.getElementById("input"+B);A.style.display=(A.style.display=="none")?"":"none"}function displaySuccessBox(A){inputElem=document.getElementById("input"+A)||document.getElementById("inputBox");inputElem.style.display="none";succElem=document.getElementById("success"+A)||document.getElementById("successBox");succElem.style.display="";setTimeout("succElem.style.display='none';",4000)}function toggleCommentBox(D){var B=document.getElementById("comments"+D);var C=(B.style.display=="none")?"":"none";B.style.display=C;var A=document.getElementById("link"+D);if(A){A.style.display=C}};
