if(typeof (Prototype)=="undefined"){throw"Twitter requires Prototype to be loaded."}var Twitter=Class.create();Twitter.prototype=Object.extend(new Request(),{initialize:function(){this.onSave=null;this.onCancel=null},checkSessionLogin:function(D,B){launchPopUp("social-services-post");var C=this;var A=base_url+"index.php/mywigix/checkTwitterSession";this.getRequestWithLogin(A,C.checkSessionLoginPost,[C,D,B])},checkSessionLoginPost:function(B,E,D,C){if(B.status=="-1"){launchPopUp("twitter-post-details");var A=document.getElementById("twitter-ok-button");A.onclick=function(){if(E.onSave){E.onSave(D,C,0)}}}else{E.onSave(D,C,1)}},isError:function(A){if(A=="200"){return false}else{return true}},getErrorMessage:function(A){var B=document.getElementById("twitter-error");if(A=="401"||A=="403"){B.style.display="block";B.innerHTML="Twitter user name or password is incorrect";B.style.display="block"}else{if(A=="400"||A=="404"){B.style.display="block";B.innerHTML="Invalid request sent to Twitter, please try again."}else{if(A=="500"||A=="502"||A=="503"){B.style.display="block";B.innerHTML="The Twitter servers are currently down, please try your request later."}else{if(A=="9999"){B.style.display="block";B.innerHTML="Wigix was unable to post your updates to Twitter, please try again later."}else{B.style.display="block";B.innerHTML="Wigix was unable to post your updates to Twitter, please try again later."}}}}}});var TwitterCard=Class.create();TwitterCard.prototype=Object.extend(new Twitter(),{initialize:function(){this.isSession=0},cardPostToTwitter:function(A,C){var B=this;var D=new Twitter();D.onSave=function(F,G,E){B.cardPostToTwitterRequest(F,G,E)};D.checkSessionLogin(A,C)},cardPostToTwitterSku:function(A,C){var B=this;var D=new Twitter();D.onSave=function(F,G,E){B.cardPostToTwitterSkuRequest(F,G,E)};D.checkSessionLogin(A,C)},wishlistPostToTwitter:function(D){var A=this;var C=new Twitter();var B=0;C.onSave=function(G,F,E){A.wishlistPostToTwitterRequest(G,F,E)};C.checkSessionLogin(D)},cardPostToTwitterRequest:function(B,E,A){var D=this;D.isSession=A;var C=base_url+"index.php/cardtrading/manageoffers/postToTwitter/"+B+"/"+E+"/"+A;this.postRequestFormWithLogin(C,this.cardCheckTwitter,"social_service",[D])},cardPostToTwitterSkuRequest:function(B,E,A){var D=this;D.isSession=A;var C=base_url+"index.php/cardtrading/manageoffers/postToTwitterSkuId/"+B+"/"+E+"/"+A;this.postRequestFormWithLogin(C,this.cardCheckTwitter,"social_service",[D])},wishlistPostToTwitterRequest:function(E,D,A){var C=this;C.isSession=A;var B=base_url+"index.php/campaign/wishlist/postToTwitter/"+E+"/"+A;this.postRequestFormWithLogin(B,this.cardCheckTwitter,"social_service",[C])},cardCheckTwitter:function(A,B){if(B.isError(A.status)){B.getErrorMessage(A.status)}else{closePopup()}}})
