function showCountry(d,b){load("countrySelect");var a="/remote.do?action=loadCountry.do";var c="";if(d){c="countrySelected="+d}if(b){c+="&stateSelected="+b}sendRequest(a,c,"get",onShowCountry)}function onShowCountry(b){var c=b.data;var f=c.listCountry;var e=0;var a='<select name="fCountry" id="fCountry" onChange="showState(this.options[this.selectedIndex].value);">';for(i=0;i<f.length;i++){var d=f[i];if(c.countrySelected==d.name){e=d.idCountry;a+='<option value="'+d.idCountry+'" selected="selected">'}else{a+='<option value="'+d.idCountry+'">'}a+=d.name;a+="</option>"}a+="</select>";document.getElementById("countrySelect").innerHTML=a;if(e!=0){showState(e,c.stateSelected)}}function showState(c,a){load("stateSelect");var b="/remote.do?action=loadState.do";var d="idCountry="+c;if(a){d+="&stateSelected="+a}sendRequest(b,d,"get",onShowState)}function onShowState(d){var c=d.data;var a=c.listStates;var b="";b+='<select id="fState" name="fState">';b+='<option value=""></option>';for(i=0;i<a.length;i++){var e=a[i];if(c.stateSelected==e.name){b+='<option value="'+e.idState+'" selected="selected">'}else{b+='<option value="'+e.idState+'">'}b+=e.name;b+="</option>"}b+="</select>";document.getElementById("stateSelect").innerHTML=b}function loadFriends(a,c){var b="/loadFriends.do";var d="ajax=true&max=15&login="+a+"&page="+c;sendRequest(b,d,"get",onLoadFriends);$("#friendsBox").modal({position:["10%","24%"]});$("#friendsBox").modal();$("#simplemodal-container").css({height:"470",width:"560"});load("friendsContent")}function onLoadFriends(d){var h=d.data;var f="";var c=h.listFriends;for(i=0;i<c.length;i++){var g=c[i];f+='<div id="" class="profile" style="">';f+='<div id="pBox" class="pBox">';f+='<div id="imgProfile" class="imgProfile" align="center">';f+='<a href="/'+g.login+'">';f+='<img src="'+g.imageSmall+'"></a>';f+="</div>";f+='<div id="nameProfile" class="nameProfile" align="center">';f+='<a href="/'+g.login+'">'+g.name+"</a>";f+="</div>";f+="</div>";f+="</div>"}var b="";var a="";if(h.previous){var e=h.page-1;a+="<a href=\"javascript:loadFriends('"+h.profile.login+"',"+e+');"><img src="/images/previus_on.png"/></a>'}else{a+='<img src="/images/previus_off.png"/>'}if(h.next){e=h.page+1;b+="<a href=\"javascript:loadFriends('"+h.profile.login+"',"+e+');"><img src="/images/next_on.png"/></a>'}else{b+='<img src="/images/next_off.png"/>'}document.getElementById("friendsContent").innerHTML=f;document.getElementById("friendsPagPrevius").innerHTML=a;document.getElementById("friendsPagNext").innerHTML=b}function showInvite(a){var b=document.getElementById("boxProfile_"+a).innerHTML;document.getElementById("friendsContent").innerHTML=b;document.getElementById("boxInvite_"+a).style.display="block";document.getElementById("invite_"+a).style.display="none"}function inviteFriendEx(){var d=document.getElementById("frmInviteFriendEx");if(!d.mail.value||!validateEmail(d.mail.value)){d.mail.focus();return false}load("inviteFriendExStatus");var b=d.login.value;var a=d.mail.value;var c="/remote.do?action=inviteFriendEx.do";var e="login="+b+"&mail="+a;sendRequest(c,e,"get",onInviteFriendEx)}function onInviteFriendEx(a){document.getElementById("inviteFriendExStatus").innerHTML=""}function removeFriend(a,b){load("removeLoad_"+a);var c="/removeFriend.do";var d="loginFriend="+b;sendRequest(c,d,"get",onRemoveFriend)}function onRemoveFriend(b){var a=b.data;document.getElementById("friend_"+a).style.display="none"}function handleKeyPress(b,a){alert(b);a.keyword.value=""}function validateUrl(a){var b=a.substr(0,7);if(b=="http://"||b=="https:/"){return true}else{return false}}function validateEmail(b){var a=b.lastIndexOf("@");if(a<1||(a+1)===b.length){return false}if(/(\.{2,})/.test(b)){return false}var c=b.substring(0,a);var d=b.substring(a+1);if(c.length<1||c.length>64||d.length<4||d.length>255){return false}if(/(^\.|\.$)/.test(c)||/(^\.|\.$)/.test(d)){return false}if(!/^"(.+)"$/.test(c)){if(!/^[-a-zA-Z0-9!#$%*\/?|^{}`~&'+=_\.]*$/.test(c)){return false}}if(!/^[-a-zA-Z0-9\.]*$/.test(d)||d.indexOf(".")===-1){return false}return true}function DataReturn(a,b){this.code=a;this.data=b}function sendRequest(b,d,c,e){var a=b;$.ajax({url:a,dataType:"json",type:c,data:d,success:function(g){var f=new DataReturn(200,g);e(f)},error:e})}function load(b){var a=document.getElementById(b).style.height;var c='<div align="center" style="line-height: '+a+";height: "+a+';">';c+='<img src="/images/ajax-loader.gif" style="vertical-align: middle;">';c+="</div>";document.getElementById(b).innerHTML=c}function visualMaxLen(c,b,a){if(c.value.length>b){c.value=c.value.substring(0,b)}document.getElementById(a).innerHTML=b-c.value.length}function maxLength(b,a){if(b.value.length>=a){b.value=b.value.substring(0,a-1)}}function formatHtml2Text(a){if(!a){return""}return a.replace(/\&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function getRadioValue(c){for(var b=0;b<c.length;b++){if(c[b].checked){var a=c[b].value}}return a}function showWindows(d,e,b){var c=function(){if(!window.open(d,"t","scrollbars=yes,toolbar=0,resizable=0,status=0,width="+e+",height="+b)){document.location.href=d}};if(/Firefox/.test(navigator.userAgent)){setTimeout(c,0)}else{c()}}function loadTopOfferGames(){load("topOfferGamesContent");var a="/loadTopGames.do";var b="gameList=1";sendRequest(a,b,"get",onLoadTopOfferGames)}function onLoadTopOfferGames(a){var b=a.data;viewTopGames(b,"topOfferGamesContent")}function loadTopWishGames(){load("topWishGamesContent");var a="/loadTopGames.do";var b="gameList=2";sendRequest(a,b,"get",onLoadTopWishGames)}function onLoadTopWishGames(a){var b=a.data;viewTopGames(b,"topWishGamesContent")}function viewTopGames(e,d){var a="";var b=e.listGames;for(i=0;i<b.length;i++){var c=b[i];a+='<div style="float:left; height: 96px;padding-right: 10px;">';a+='<a href="/games/'+c.gameKey+'">';a+='<img src="'+c.imageSmall+'" title="'+c.name+'" border=0 align="center"/>';a+="</a>";a+="</div>"}document.getElementById(d).innerHTML=a}function loadGame4Genre(a){load("gameGenreContent");var b="/loadGame4Genre.do";var c="&idGame="+a;sendRequest(b,c,"get",onLoadGame4Genre)}function onLoadGame4Genre(d){var e=d.data;var b=e.listGames;var a="";for(i=0;i<b.length;i++){var c=b[i];a+='<div class="gameImgSmall">';a+='<a href="/games/'+c.gameKey+'">';a+='<img src="'+c.imageSmall+'" title="'+c.name+'"/></a>';a+="</div>"}document.getElementById("gameGenreContent").innerHTML=a}var boFilter=true;function showFilter(){if(boFilter){document.getElementById("filterImg").src="/images/filter_up.png";document.getElementById("divFilter").style.display="block";showCountry("Brazil")}else{document.getElementById("filterImg").src="/images/filter_down.png";document.getElementById("divFilter").style.display="none";cleanFilterForm()}boFilter=!boFilter}function cleanFilterForm(){var a=document.getElementById("frmFilter");if(a){a.reset();if(a.fCountry){a.fCountry.selectedIndex=-1}if(a.fState){a.fState.selectedIndex=-1}}}function cleanFilter(a){var b=tabActive;hasLoad0=false;hasLoad1=false;hasLoad2=false;cleanFilterForm();loadGameProfiles(a,b,0);document.getElementById("filterDisplay").style.display="none"}function filterProfiles(a){var b=tabActive;hasLoad0=false;hasLoad1=false;hasLoad2=false;loadGameProfiles(a,b,0);document.getElementById("divFilter").style.display="none";document.getElementById("filterImg").src="/images/filter_down.png"}function loadGameProfiles(h,j,f){if(!f){f=0}var c="/remote.do?action=loadGameProfiles.do";var b="idGame="+h+"&gameList="+j+"&page="+f;var g=document.getElementById("frmFilter");if(g.fCountry){var d=g.fCountry.value;var e=g.fState.value;if(d&&d!=0){b+="&idCountry="+d}if(e&&e!=0){b+="&idState="+e}}var a;if(j==1){load("gameProfilesContent");a=onLoadGameProfiles}else{if(j==2){load("gameProfilesWishContent");a=onLoadGameProfilesWish}else{if(j==3){load("gameProfilesCollectionContent");a=onLoadGameProfilesCollection}}}sendRequest(c,b,"get",a)}function onLoadGameProfiles(a){var b=a.data;showGameProfiles(1,b,"gameProfilesContent","gameProfilesPagePrevius","gameProfilesPageNext")}function onLoadGameProfilesWish(a){var b=a.data;showGameProfiles(2,b,"gameProfilesWishContent","gameProfilesWishPagePrevius","gameProfilesWishPageNext")}function onLoadGameProfilesCollection(a){var b=a.data;showGameProfiles(3,b,"gameProfilesCollectionContent","gameProfilesCollectionPagePrevius","gameProfilesCollectionPageNext")}function showGameProfiles(n,e,m,a,b){var h="";var c=e.listProfiles;for(i=0;i<c.length;i++){var g=c[i];h+='<div class="profile">';h+='<div id="pBox" class="pBox" OnMouseOver="showProfileInfo('+g.idProfile+',true);" OnMouseOut="showProfileInfo('+g.idProfile+',false);">';var d="/"+g.login;if(n==1){d="/profileGame.do?gameKey="+e.gameKey+"&login="+g.login}h+='<div id="imgProfile" class="imgProfile" align="center">';h+='<a href="'+d+'">';h+='<img src="'+g.imageSmall+'"></a>';h+="</div>";h+='<div id="nameProfile" class="nameProfile" align="center">';h+='<a href="'+d+'">';h+=g.name+"</a>";h+="</div>";h+="</div>";h+='<div id="profileInfo_'+g.idProfile+'" class="box-border profileInfo">';h+='<div id="profileInfoStats_'+g.idProfile+'" style="text-align: center;"></div>';h+='<div class="hrLine"></div>';h+='<div class="texto" style="text-align: left;padding-left: 2px;">'+fCountry+":<b> "+g.country+"</b></div>";h+='<div class="texto" style="text-align: left;padding-left: 2px;">'+fState+":<b> "+g.state+"</b></div>";h+='<div class="texto" style="text-align: left;padding: 1px;width: 130px;overflow: hidden;">'+fCity+":<b> "+g.city+"</b></div>";h+="</div>";h+='<div style="clear: both;"></div>';h+="</div>"}if(n==1&&c.length<=0){h+='<div class="texto" style="text-align: center;">';h+=noPeopleGame+"<br><br>";if(boLogin==true){h+='<div id="divRemind"><a href="javascript:remindGame();">'+remindMsg+"</a></div>"}else{h+='<div id="divRemind"><a href="javascript:showLoginModal();">'+remindMsg+"</a></div>"}h+="</div>"}var k="";var f="";if(e.previous){var j=e.page-1;f+="<a href=\"javascript:loadGameProfiles('"+e.idGame+"',"+n+","+j+');"><img src="/images/previus_on.png"/></a>'}else{f+='<img src="/images/previus_off.png"/>'}if(e.next){j=e.page+1;k+="<a href=\"javascript:loadGameProfiles('"+e.idGame+"',"+n+","+j+');"><img src="/images/next_on.png"/></a>'}else{k+='<img src="/images/next_off.png"/>'}if(e.filter){var l="";if(e.country!=""){l+=e.country}if(e.state!=""){l+=" >> "+e.state}document.getElementById("filterText").innerHTML=l;document.getElementById("filterDisplay").style.display="block"}else{document.getElementById("filterDisplay").style.display="none"}document.getElementById(m).innerHTML=h;document.getElementById(a).innerHTML=f;document.getElementById(b).innerHTML=k}function showProfileInfo(c,a){var b="none";if(a){b="block";loadProfileStats(c)}document.getElementById("profileInfo_"+c).style.display=b}function loadProfileStats(b){var a=document.getElementById("profileInfoStats_"+b).innerHTML;if(!a){load("profileInfoStats_"+b);var c="/remote.do?action=loadProfileStats.do";var d="idProfile="+b;sendRequest(c,d,"get",onLoadProfileStats)}}function onLoadProfileStats(c){var b=c.data;var a='<img src="/images/star'+b.reputation+'.png">';document.getElementById("profileInfoStats_"+b.idProfile).innerHTML=a}function remindGame(){load("divRemind");var a="/remote.do?action=remindGame.do";var b="idGame="+idGame+"&idProfile="+idProfile;sendRequest(a,b,"get",onRemindGame)}function onRemindGame(a){document.getElementById("divRemind").innerHTML=""}function showGameComments(a){if(a){document.getElementById("postNew").style.display="block"}else{document.getElementById("postNew").style.display="none"}}function sendGameComments(){var d=document.getElementById("frmPostNew");var a=getRadioValue(d.rating);if(!a){a=0}if(!d.comments.value){alert("The field must be filled!");d.comments.focus();return}document.getElementById("btnPostNew").style.display="none";load("postLoad");var c="/addGameRating.do";var b={idGame:idGame,gameKey:gameKey,rating:a,comments:d.comments.value};sendRequest(c,b,"post",onSendGameComments)}function onSendGameComments(a){document.getElementById("postNew").style.display="none";document.getElementById("btnPostNew").style.display="block";document.getElementById("postLoad").innerHTML="";document.getElementById("frmPostNew").comments.value="";loadGameComments(0)}function loadGameComments(b){load("divComments");var a="/remote.do?action=loadGameRating.do";var c="idGame="+idGame+"&page="+b+"&lang="+lang;sendRequest(a,c,"get",onGameLoadComments)}function onGameLoadComments(d){var g=d.data;var h=document.getElementById("tableComments");while(h.rows.length>0){h.deleteRow(0)}var a="";var f=g.listGameRatingBean;for(i=0;i<f.length;i++){var b=f[i];var c=h.insertRow(h.rows.length);newCell=c.insertCell(0);newCell.innerHTML="<hr/>";c=h.insertRow(h.rows.length);c.style.bgcolor="#e9e9e9";newCell=c.insertCell(0);var e='<a href="/profile.do?idProfile='+b.idProfile;e+='" target="_top">'+b.login+"</a>";newCell.innerHTML=e+" on "+b.date;c=h.insertRow(h.rows.length);newCell=c.insertCell(0);newCell.innerHTML='<img src="/images/star_'+b.rating+'.png" />';c=h.insertRow(h.rows.length);newCell=c.insertCell(0);newCell.innerHTML='<div style="overflow:hidden; width:500px">'+formatHtml2Text(b.comments)+"</div>"}document.getElementById("divComments").innerHTML=""}function loadViewGames(d,a){load("viewGamesContent");btnClear();if(a){var b=document.getElementById("btn"+a);btnChange(2,b)}else{var b=document.getElementById("btnAll");b.className="btnGreen_active"}var c="/remote.do?action=loadGames.do";var e="page="+d+"&max=18";var f=document.getElementById("frmSearch");f.console.value="";if(a){e+="&console="+a;f.console.value=a}sendRequest(c,e,"get",onLoadViewGames)}function onLoadViewGames(c){var h=c.data;var b="";var j=h.listGames;for(i=0;i<j.length;i++){var e=j[i];b+='<div id="">';b+='<div class="gameBox" OnMouseOut="this.className=\'gameBox\'" OnMouseOver="this.className=\'gameBox_Hover\'">';b+='<div align="center" class="gameImgSmall">';b+='<a href="/games/'+e.gameKey+'"> <img src="'+e.imageSmall+'" border=0 align="center"></a>';b+="</div>";b+='<div class="gameName" style="">';b+=e.name;b+="</div>";b+="</div>";b+="</div>"}var g="";var d="";var f;var a;if(h.previous){f=h.page-1;if(h.search){if(h.console){a="javascript:searchViewGames('"+h.keyword+"',"+f+",'"+h.console+"');"}else{a="javascript:searchViewGames('"+h.keyword+"',"+f+");"}}else{if(h.console){a="javascript:loadViewGames("+f+",'"+h.console+"');"}else{a="javascript:loadViewGames("+f+");"}}d+='<a href="'+a+'"><img src="/images/previus_on.png"></a>'}else{d+='<img src="/images/previus_off.png">'}if(h.next){f=h.page+1;if(h.search){if(h.console){a="javascript:searchViewGames('"+h.keyword+"',"+f+",'"+h.console+"');"}else{a="javascript:searchViewGames('"+h.keyword+"',"+f+");"}}else{if(h.console){a="javascript:loadViewGames("+f+",'"+h.console+"');"}else{a="javascript:loadViewGames("+f+");"}}g+='<a href="'+a+'"><img src="/images/next_on.png"></a>'}else{g+='<img src="/images/next_off.png">'}document.getElementById("viewGamesContent").innerHTML=b;document.getElementById("pag_previus").innerHTML=d;document.getElementById("pag_next").innerHTML=g;if(j.length<=0){document.getElementById("noResults").style.display="block"}else{document.getElementById("noResults").style.display="none"}}function btnChange(b,a){if(b==0&&a.className!="btnGreen_active"){a.className="btnGreen"}else{if(b==1&&a.className!="btnGreen_active"){a.className="btnGreen_hover"}else{if(b==2){a.className="btnGreen_active"}}}}function btnClear(){var a=document.getElementById("btnAll");a.className="btnGreen";a=document.getElementById("btnPS3");a.className="btnGreen";a=document.getElementById("btnPSP");a.className="btnGreen";a=document.getElementById("btnXbox");a.className="btnGreen";a=document.getElementById("btnWii");a.className="btnGreen";a=document.getElementById("btnDS");a.className="btnGreen";a=document.getElementById("btnSearch");a.className="btnGreen"}function btViewSearch(){var c=document.getElementById("frmSearch");var a=c.keyword.value;if(!a){c.keyword.focus();return false}btnClear();var b=document.getElementById("btnSearch");b.className="btnGreen_active";b=document.getElementById("btn"+c.console.value);if(b){b.className="btnGreen_active"}searchViewGames(a,0,c.console.value)}function searchViewGames(b,d,a){load("viewGamesContent");if(!b){alert("Keyword")}var c="/remote.do?action=searchGames.do";var e="page="+d+"&max=8&keyword="+b;if(a){e+="&console="+a}sendRequest(c,e,"get",onLoadViewGames)}function modalClose(){$.modal.close()}function modalCancel(){$.modal.close()}function loginCheck(a){if(!a.login.value){a.login.focus();return false}if(!a.passwd.value){a.passwd.focus();return false}return true}function resetCheck(){var a=document.getElementById("frmReset");if(!a.email.value||!validateEmail(a.email.value)){a.email.focus();return false}return true}function loadNofitications(a){var b="/remote.do?action=loadNotifications.do";var c="login="+a;sendRequest(b,c,"get",onLoadNofitications)}function onLoadNofitications(a){var b=a.data;if(b.boOffer){document.getElementById("offerCountValue").style.display="block";document.getElementById("offerCountValue").innerHTML=b.offerCount}if(b.boFriends){document.getElementById("friendsCountValue").style.display="block";document.getElementById("friendsCountValue").innerHTML=b.friendsCount}}function showLoginModal(){$("#divLogin").modal({position:["30%","35%"],onClose:modalClose});$("#divLogin").modal();$("#simplemodal-container").css({height:"190",width:"280"})}function loadWebEvents(b){if(!b){b=0}load("updatesContent_p"+b);var a="/loadWebEvents.do";var c="page="+b;sendRequest(a,c,"get",onLoadWebEvents)}function onLoadWebEvents(b){var f=b.data;var d=f.page;var c="";var a=f.listEventsWeb;for(i=0;i<a.length;i++){var e=a[i];c+='<div class="texto" style="padding: 3px;">';c+="<div>";c+=e.message;c+="</div>";c+='<div style="color: gray">';c+=e.date;c+="</div>";c+="</div>";c+='<div class="hrLine2" style="margin-right: 5px;margin-left: 5px;"></div>'}document.getElementById("updatesContent_p"+d).innerHTML=c;d+=1;var g='<div id="updatesContent_p'+d+'">';g+='<div style="text-align: center;"><a href="javascript:void(0);" onClick="loadWebEvents('+d+');">'+msgMoreUpdate+"</a></div>";g+="</div>";document.getElementById("updatesContent").innerHTML+=g}function showMakeOffer(){if(document.getElementById("divMakeOffer").style.display=="block"){document.getElementById("divMakeOffer").style.display="none"}else{document.getElementById("divMakeOffer").style.display="block"}}function sendOffer(){var c=document.getElementById("formMakeOffer");if(!c.message.value){alert("The field must be filled!");c.message.focus();return}document.getElementById("duplicateMsg").style.display="none";document.getElementById("msgOfferOK").style.display="none";load("offerStatus");var b="/remote.do?action=makeOffer.do&method=post";var a={idProfileFrom:c.idProfileFrom.value,idProfile:c.idProfile.value,idGame:c.idGame.value,message:c.message.value,lang:c.lang.value};sendRequest(b,a,"post",onSendOffer)}function onSendOffer(a){var b=a.data;if(b=="501"){document.getElementById("duplicateMsg").style.display="block"}else{document.getElementById("msgOfferOK").style.display="block"}document.getElementById("offerStatus").innerHTML="";location.reload(true)}function makeOffer(c,b,e,a){var d=document.getElementById("formMakeOffer");d.idGame.value=b;d.idProfile.value=c;document.getElementById("gameName").innerHTML=e;document.getElementById("gameConsole").innerHTML=a;$("#offer-modal").modal({position:["17%","26%"]});$("#offer-modal").modal();$("#simplemodal-container").css({height:"220",width:"400"})}function sendProfileGame(){load("sendStatus");var k=document.getElementById("frmProfileGame");var l=k.idGame.value;var c=k.gameName.value;var e=k.idConsole.value;var f=k.console.value;var m=getRadioValue(k.gameList);var b=getRadioValue(k.midiaRating);var j=getRadioValue(k.manualRating);var a=getRadioValue(k.boxRating);if(!m){m=0}if(!b){b=0}if(!j){j=0}if(!a){a=0}var h=k.comments.value;var d="/addProfileGame.do";var g={idGame:l,idConsole:e,console:f,gameName:c,gameList:m,midiaRating:b,manualRating:j,boxRating:a,comments:h};sendRequest(d,g,"post",onSendProfileGame)}function onSendProfileGame(a){var b=a.data;document.getElementById("sendStatus").innerHTML="";if(b&&b=="3"){document.getElementById("msgError").style.display="block"}else{if(b&&b=="4"){document.getElementById("btnAdd").style.display="none";document.getElementById("msgOK").style.display="block";showBoxOAuth()}else{document.getElementById("btnAdd").style.display="none";document.getElementById("msgOK").style.display="block"}}}function boxChange(){var b=document.getElementById("frmProfileGame");var a=getRadioValue(b.gameList);if(a==1){document.getElementById("boxAvaliacao").style.display="block"}else{document.getElementById("boxAvaliacao").style.display="none"}}function removeGame(c,b,a){load("action_"+b);var d="/removeProfileGame.do";var e="type="+c+"&idProfileGame="+b+"&idGame="+a;sendRequest(d,e,"get",onRemoveGame)}function onRemoveGame(b){var a=b.data;document.getElementById("idProfileGame_"+a).style.display="none"}function loadTopUsers(){load("topUsersContent");var a="/loadTopUsers.do";var b="";sendRequest(a,b,"get",onLoadTopUsers)}function onLoadTopUsers(c){var a=c.data;var b="";var e=a.listProfiles;for(i=0;i<e.length;i++){var d=e[i];b+='<div style="text-align: center;">';b+='<a href="/'+d.login+'">';b+='<img src="'+d.imageSmall+'" border=0 align="center" style="margin-left: 0px;padding: 6px;"/>';b+="</a>";b+='<div class="profileName">';b+='<a href="/'+d.login+'">';b+=d.name+"</div>";b+="</a>";b+="</div>"}document.getElementById("topUsersContent").innerHTML=b}function gameListChange(b,a){var c=document.getElementById("idConsoleFilter").innerHTML;loadProfileGames(b,1,c,a,0)}function loadProfileGames(b,c,h,a,f){var e="/remote.do?action=loadProfileGames.do";var g="idProfile="+b+"&type="+c+"&idConsole="+h+"&gameList="+a+"&next="+f;var d;if(c==1){load("profileGamesContent");d=onLoadProfileGames}else{if(c==2){load("profileGamesWishContent");d=onLoadProfileGamesWish}}sendRequest(e,g,"get",d)}function onLoadProfileGames(a){var b=a.data;showProfileGames(1,b,"profileGamesContent","profileGamesPag_previus","profileGamesPag_next")}function onLoadProfileGamesWish(a){var b=a.data;showProfileGames(2,b,"profileGamesWishContent","profileGamesPagWish_previus","profileGamesWishPag_next")}function showProfileGames(n,f,c,a,d){var e="";var l=f.listProfileGames;for(i=0;i<l.length;i++){var k=l[i].gameDetailBean;var b=l[i].idProfileGame;var p="/games/"+k.gameKey;if(l[i].gameList==1){p="/profileGame.do?gameKey="+k.gameKey+"&login="+f.login}e+='<div id="idProfileGame_'+b+'" class="gameProfile">';e+='<div class="gameProfileBox box-border" OnMouseOver="showGameInfo('+b+',true);" OnMouseOut="showGameInfo('+b+',false);">';e+='<div align="center" class="gameImgSmall">';e+='<a href="'+p+'">';e+='<img src="'+k.imageSmall+'" title="'+k.name+'" border=0></a>';e+="</div>";e+="</div>";if(n==1){e+='<div id="gameInfo_'+b+'" class="box-border gameProfileInfo">';e+='<div class="box-title3" style="text-align: center;">'+k.name+"</div>";e+='<div class="hrLine"></div>';if(l[i].gameList==3){e+='<div class="texto" style="text-align: justify;padding:5px;">'+collectionText+"</div>"}else{e+='<div class="texto" style="text-align: right;margin-right: 20px;">'+fMidia+'<img src="/images/star_'+l[i].midiaRating+'.png" style="margin-left: 10px;"/></div>';e+='<div class="texto" style="text-align: right;margin-right: 20px;">'+fManual+'<img src="/images/star_'+l[i].manualRating+'.png" style="margin-left: 10px;"/></div>';e+='<div class="texto" style="text-align: right;margin-right: 20px;">'+fBox+'<img src="/images/star_'+l[i].boxRating+'.png" style="margin-left: 10px;"/></div>';e+='<div class="hrLine2"></div>';var j=l[i].comments;if(!j){j=""}else{if(j.length>40){j=j.substring(0,40)+" ..."}}e+='<div class="texto" style="padding:3px;padding-top:0px;text-align: justify;">'+j+"</div>"}e+="</div>";e+='<div style="clear: both;"></div>'}if(myProfile=="true"){e+='<div id="action_'+b+'" style="width:25px; height:15px;  display:inline; position:relative;top:-18px;left: 62px;">';e+='<a href="javascript:removeGame('+n+","+b+","+k.idGame+');"> <img src="/images/delete.png"/></a>';e+="</div>"}e+="</div>"}if(n==1){var g="none";if(f.filter&&f.idConsole!=0){g="block"}if(f.gameList==0){document.getElementById("selectGameList").selectedIndex=0}document.getElementById("consoleFilter").style.display=g;document.getElementById("consoleName").innerHTML=f.consoleFilter;document.getElementById("idConsoleFilter").innerHTML=f.idConsole}var o="";var h="";if(f.previous){var m=f.page-1;h+='<a href="javascript:void(0);" onClick="loadProfileGames(\''+f.idProfile+"',"+n+",'"+f.idConsole+"','"+f.gameList+"',"+m+');"><img src="/images/previus_on.png"></a>'}else{h+='<img src="/images/previus_off.png">'}if(f.next){m=f.page+1;o+='<a href="javascript:void(0);" onClick="loadProfileGames(\''+f.idProfile+"',"+n+",'"+f.idConsole+"','"+f.gameList+"',"+m+');"><img src="/images/next_on.png"></a>'}else{o+='<img src="/images/next_off.png">'}document.getElementById(c).innerHTML=e;document.getElementById(a).innerHTML=h;document.getElementById(d).innerHTML=o}function showGameInfo(c,a){var b="none";if(a){b="block"}if(document.getElementById("gameInfo_"+c)){document.getElementById("gameInfo_"+c).style.display=b}}function loadProfileComments(b){load("divComments");var a="/remote.do?action=loadProfileRating.do";var c="idProfile="+idProfile+"&page="+b+"&lang="+lang;sendRequest(a,c,"get",onLoadProfileComments)}function onLoadProfileComments(e){hasComments=true;var h=e.data;var g=document.getElementById("tableComments");var a="";var b=h.listProfileRating;for(i=0;i<b.length;i++){var d=b[i];var c=g.insertRow(g.rows.length);newCell=c.insertCell(0);newCell.colSpan=2;var f='<a href="/profile.do?idProfile='+d.idProfileFrom;f+='" target="_top">'+d.profileFromName+"</a>";newCell.innerHTML=f+" on "+d.date;c=g.insertRow(g.rows.length);newCell=c.insertCell(0);if(d.rating==1){newCell.innerHTML='<img src="/images/good-mark.gif"/>'}else{if(d.rating==3){newCell.innerHTML='<img src="/images/bad-mark.gif"/>'}else{newCell.innerHTML='<img src="/images/neutral-mark.png"/>'}}newCell=c.insertCell(1);newCell.innerHTML='<div style="overflow:hidden; width:500px">'+formatHtml2Text(d.message)+"</div>";c=g.insertRow(g.rows.length);newCell=c.insertCell(0);newCell.colSpan=2;newCell.innerHTML='<div class="hrLine2"></div>'}document.getElementById("divComments").innerHTML="";if(b.length==0){document.getElementById("noComments").style.display="block"}}function checkEditProfile(b){var a=true;if(!checkField(b.givenName)){b.givenName.focus();a=false}if(!checkField(b.familyName)){b.familyName.focus();a=false}if(!checkField(b.fState)){b.fState.focus();a=false}if(!checkField(b.city)){b.city.focus();a=false}if(!checkField(b.facebookUrl)){b.facebookUrl.focus();a=false}if(!checkField(b.orkutUrl)){b.orkutUrl.focus();a=false}if(!checkField(b.psnID)){b.psnID.focus();a=false}if(!checkField(b.xboxLive)){b.xboxLive.focus();a=false}if(!checkField(b.twitter)){b.twitter.focus();a=false}return a}function checkNewProfile(){var b=document.getElementById("formNewProfile");var a=true;if(!checkField(b.email)){b.email.focus();a=false}if(!checkField(b.login)){b.login.focus();a=false}if(!checkField(b.password)){b.password.focus();a=false}if(!checkField(b.confirmPassword)){b.confirmPassword.focus();a=false}if(!checkField(b.givenName)){b.givenName.focus();a=false}if(!checkField(b.familyName)){b.familyName.focus();a=false}if(!checkField(b.fState)){b.fState.focus();a=false}if(!checkField(b.city)){b.city.focus();a=false}if(!checkField(b.facebookUrl)){b.facebookUrl.focus();a=false}if(!checkField(b.orkutUrl)){b.orkutUrl.focus();a=false}if(!checkField(b.psnID)){b.psnID.focus();a=false}if(!checkField(b.xboxLive)){b.xboxLive.focus();a=false}if(!checkField(b.twitter)){b.twitter.focus();a=false}return a}function loginInput(b){if(!b.value){var a=document.getElementById("fEmail").value;b.value=a.split("@",1)}}function checkField(e){var f='<img src="/images/check_OK.png"/>';var d='<img src="/images/check_FAIL.png"/>';var b=true;var a=true;if(e.name=="login"){if(!e.value){b=false}}if(e.name=="email"){if(!validateEmail(e.value)){b=false}}if(e.name=="password"){if(!e.value){b=false}}if(e.name=="givenName"){if(!e.value){b=false}}if(e.name=="familyName"){if(!e.value){b=false}}if(e.name=="confirmPassword"){var c=document.getElementById("password").value;if(!c){a=false}else{if(c!=e.value){b=false}}}if(e.name=="fState"){if(!e.value){b=false}}if(e.name=="city"){if(!e.value){b=false}}if(e.name=="facebookUrl"||e.name=="orkutUrl"||e.name=="twitter"||e.name=="psnID"||e.name=="xboxLive"){if(!e.value){a=false}if(e.value){if(validateUrl(e.value)){b=false}if(validateEmail(e.value)){b=false}}}if(a){if(b==true){if(document.getElementById(e.name+"_Check")){document.getElementById(e.name+"_Check").innerHTML=f}}else{if(document.getElementById(e.name+"_Check")){document.getElementById(e.name+"_Check").innerHTML=d}}}else{if(document.getElementById(e.name+"_Check")){document.getElementById(e.name+"_Check").innerHTML=""}}return b}function loadProfileEvents(a,c){if(!c){c=0}load("profileUpdates_p"+c);var b="/loadProfileEvents.do";var d="idProfile="+a+"&page="+c;sendRequest(b,d,"get",onLoadProfileEvents)}function onLoadProfileEvents(b){var f=b.data;var d=f.page;var c="";var a=f.listEventsWeb;for(i=0;i<a.length;i++){var e=a[i];c+='<div class="texto" style="padding: 3px;">';c+="<div>";c+=e.message;c+="</div>";c+='<div style="color: gray">';c+=e.date;c+="</div>";c+="</div>";c+='<div class="hrLine2" style="margin-right: 5px;margin-left: 5px;"></div>'}document.getElementById("profileUpdates_p"+d).innerHTML=c;if(f.size>0){d+=1;var g='<div id="profileUpdates_p'+d+'">';g+='<div style="text-align: center;"><a href="javascript:void(0);" onClick="loadProfileEvents('+f.idProfile+","+d+');">'+msgMoreUpdate+"</a></div>";g+="</div>";document.getElementById("profileUpdates").innerHTML+=g}}function loadMessages(a,c){load("msgReceiveContent");var b="/loadProfileMessages.do";var d="type="+a+"&page="+c;sendRequest(b,d,"get",onLoadMessages)}function onLoadMessages(f){var h=f.data;var e="";var d=h.listMessages;for(i=0;i<d.length;i++){var a=d[i];e+='<div style="padding: 5px;width: 580px;">';e+='<div class="box-border" style="padding: 5px;float:left">';e+='<img src="'+a.profileMessage.imageSmall+'"/>';e+="</div>";e+='<div style="padding: 5px;float:left">';e+='<a href="/'+a.profileMessage.login+'">'+a.profileMessage.displayName+"</a>";e+="</div>";e+='<div class="texto" style="padding: 5px;float:left">';e+=a.date;e+="</div>";if(h.type==1){e+='<div class="texto" style="padding: 5px;float:left">';e+='<a href="javascript:void();" onClick="showReply(\''+a.profileMessage.login+'\');"><img alt="" src="/images/mail_reply.png" style="vertical-align: middle;" />&nbsp; Reply</a>';e+="</div>"}e+='<div class="texto" style="float: left;width: 490px;padding: 5px;word-wrap: break-word;">';e+=a.message+"</div>";e+='<div style="clear: both;"></div>';e+="</div>";e+='<div style="clear: both;"></div>';e+='<div class="hrLine2"></div>'}var c="";var b="";if(h.previous){var g=h.page-1;b+='<a href="javascript:void(0);" onClick="loadMessages('+h.type+","+g+');"><img src="/images/previus_on.png"></a>'}else{b+='<img src="/images/previus_off.png">'}if(h.next){g=h.page+1;c+='<a href="javascript:void(0);" onClick="loadMessages('+h.type+","+g+');"><img src="/images/next_on.png"></a>'}else{c+='<img src="/images/next_off.png">'}if(h.type==1){document.getElementById("msgReceiveContent").innerHTML=e;document.getElementById("msgReceivePrevius").innerHTML=b;document.getElementById("msgReceiveNext").innerHTML=c}else{document.getElementById("msgSendContent").innerHTML=e;document.getElementById("msgSendPrevius").innerHTML=b;document.getElementById("msgSendNext").innerHTML=c}}function showReply(b){var a=document.getElementById("frmMsgReply");a.loginFriend.value=b;$("#msgReply").modal({position:["30%","35%"],onClose:modalClose});$("#msgReply").modal();$("#simplemodal-container").css({height:"160",width:"300"})}function offerDetail(b,a){document.getElementById("offerDetail-load").style.display="block";document.getElementById("offerDetail-content").style.display="none";$("#offerDetail-modal").modal({position:["10%","30%"]});$("#offerDetail-modal").modal();$("#simplemodal-container").css({height:"210",width:"420"});offerRequest(b,a)}function offerRequest(b,a){load("offerDetail-load");var d=document.getElementById("frmOffer");d.type.value=b;var c="/remote.do?action=offerDetail.do";var e="idOffer="+a+"&lang="+lang;sendRequest(c,e,"get",onOfferDetail)}function onOfferDetail(f){document.getElementById("offerDetail-load").style.display="none";document.getElementById("offerDetail-content").style.display="block";var c=f.data;var h=document.getElementById("frmOffer");h.idProfile.value=c.profile.idProfile;h.idProfileFrom.value=c.profileFrom.idProfile;h.idOffer.value=c.idOffer;var e=h.type.value;var d=c.profileFrom;if(e==2){d=c.profile}var g=d.login;document.getElementById("nameProfileUrl").innerHTML=d.name;document.getElementById("nameProfileUrl").href=g;document.getElementById("profileImg").src=d.imageSmall;document.getElementById("profileUrl").href=g;document.getElementById("offerGame").innerHTML=c.game.name;document.getElementById("offerConsole").innerHTML=c.game.console;document.getElementById("offerDate").innerHTML=c.date;document.getElementById("offerMessage").innerHTML=c.message;var b=c.status;if(b==0&&e==1){document.getElementById("btnOffer").style.display="block"}if(b==1){document.getElementById("status_1").style.display="block";document.getElementById("offerMessageDecline").innerHTML=c.messageDecline;document.getElementById("simplemodal-container").style.height="280px"}if(b==2&&e==2){document.getElementById("status_2").style.display="block";document.getElementById("simplemodal-container").style.height="260px"}if(b==3||b==4){var a=false;if(e==1&&c.idRating==0){a=true}if(e==2&&c.idRatingFrom==0){a=true}if(a){document.getElementById("rating").style.display="block";document.getElementById("simplemodal-container").style.height="410px"}}}function showDecline(a){var b=document.getElementById("frmDecline");b.idOffer.value=a;$("#offerDecline").modal({position:["20%","30%"]});$("#offerDecline").modal();$("#simplemodal-container").css({height:"210",width:"420"})}function offerDecline(){var a=document.getElementById("frmDecline");var d=a.messageDecline.value;if(!d){alert("The field must be filled!");a.messageDecline.focus();return}load("btnOfferDecline");var c="/offerDecline.do";var b={idOffer:a.idOffer.value,messageDecline:a.messageDecline.value,lang:lang};sendRequest(c,b,"post",onOfferClose)}function showAccept(a){var b=document.getElementById("frmAccept");b.idOffer.value=a;$("#offerAccept").modal({position:["20%","30%"]});$("#offerAccept").modal();$("#simplemodal-container").css({height:"210",width:"420"})}function offerAccept(){var g=document.getElementById("frmAccept");var f=g.tel1.value;var e=g.tel2.value;var a=g.email.value;if(!a){alert("The field must be filled!");g.email.focus();return}if(!validateEmail(a)){alert("Email invalid!");g.email.focus();return}var b=g.messageAccept.value;if(!b){alert("The field must be filled!");g.messageAccept.focus();return}load("btnOfferAccept");var d="/offerAccept.do";var c={idOffer:g.idOffer.value,tel1:f,tel2:e,email:a,messageAccept:b,lang:lang};sendRequest(d,c,"post",onOfferClose)}function offerCompleted(a,b){load("btnOfferCompleted_"+a);var d="/offerCompleted.do";var c={idOffer:a,type:b,lang:lang};sendRequest(d,c,"post",onOfferClose)}function showOfferRating(c,e,d,b){var a=document.getElementById("frmRating");a.idOffer.value=c;a.type.value=e;a.idProfileFrom.value=b;a.idProfile.value=d;$("#offerRating").modal({position:["20%","30%"]});$("#offerRating").modal();$("#simplemodal-container").css({height:"230",width:"420"})}function offerRating(){var a=document.getElementById("frmRating");if(!a.ratingMsg.value){alert("The field must be filled!");a.ratingMsg.focus();return}var c;var b;if(a.type.value==1){c=a.idProfileFrom.value;b=a.idProfile.value}else{if(a.type.value==2){c=a.idProfile.value;b=a.idProfileFrom.value}}load("btnRating");var e="/offerRating.do";var d={idProfile:c,idProfileFrom:b,idOffer:a.idOffer.value,type:a.type.value,rating:getRadioValue(a.rating),message:a.ratingMsg.value,lang:lang};sendRequest(e,d,"post",onOfferClose)}function offerCancel(a){load("btnOfferCancel_"+a);var c="/offerCancel.do";var b={idOffer:a,lang:lang};sendRequest(c,b,"post",onOfferClose)}function onOfferClose(a){$.modal.close();location.reload(true)}function loadGames(a,e){load("gameContent");var b=document.getElementById("formGame");b.console.value=a;var d="/remote.do?action=loadGames.do";var f="max=14&console="+a+"&page="+e;sendRequest(d,f,"get",onLoadGames);searchClear();btnClearSelect();var c=document.getElementById("btn"+a);btnChange(2,c)}function searchClear(){var a=document.getElementById("frmSearch");a.keyword.value=""}function btSearch(){var e=document.getElementById("frmSearch");var b=e.keyword.value;if(!b){e.keyword.focus();return false}var c=document.getElementById("formGame");var a=c.console.value;var d=document.getElementById("btnSearch");d.className="btnGreen_active";searchGames(a,b,0)}function searchGames(b,a,d){load("gameContent");if(!a){alert("Keyword")}var c="/remote.do?action=searchGames.do";var e="max=14&console="+b+"&page="+d+"&keyword="+a;sendRequest(c,e,"get",onLoadGames)}function onLoadGames(f){var h=f.data;var a="";var d=h.listGames;for(i=0;i<d.length;i++){var e=d[i];a+='<div id="idGame_'+e.idGame+'">';a+='<div class="gameBox" OnMouseOut="this.className=\'gameBox\'" OnMouseOver="this.className=\'gameBox_Hover\'">';a+='<div align="center" class="gameImgSmall">';a+='<a href="javascript:void(0);" onClick="window.location.href=\'/addGame.do?type=1&game='+e.gameKey+'\'");"> <img src="'+e.imageSmall+'" border=0 align="center"></a>';a+="</div>";a+='<div class="gameName">';a+=e.name;a+="</div>";a+="</div>";a+="</div>"}var c="";var b="";if(h.previous){var g=h.page-1;if(h.search){b+="<a href=\"javascript:searchGames('"+h.console+"','"+h.keyword+"',"+g+');"><img src="/images/previus_on.png"></a>'}else{b+="<a href=\"javascript:loadGames('"+h.console+"',"+g+');"><img src="/images/previus_on.png"></a>'}}else{b+='<img src="/images/previus_off.png">'}if(h.next){g=h.page+1;if(h.search){c+="<a href=\"javascript:searchGames('"+h.console+"','"+h.keyword+"',"+g+');"><img src="/images/next_on.png"></a>'}else{c+="<a href=\"javascript:loadGames('"+h.console+"',"+g+');"><img src="/images/next_on.png"></a>'}}else{c+='<img src="/images/next_off.png">'}if(d.length<=0){document.getElementById("noResults").style.display="block"}else{document.getElementById("noResults").style.display="none"}document.getElementById("resultSize").innerHTML=h.size;document.getElementById("resultConsole").innerHTML=h.console;document.getElementById("gameContent").innerHTML=a;document.getElementById("pag_previus").innerHTML=b;document.getElementById("pag_next").innerHTML=c}function btnClearSelect(){var a=document.getElementById("btnPS3");a.className="btnGreen";a=document.getElementById("btnPSP");a.className="btnGreen";a=document.getElementById("btnXbox");a.className="btnGreen";a=document.getElementById("btnWii");a.className="btnGreen";a=document.getElementById("btnDS");a.className="btnGreen";a=document.getElementById("btnPC");a.className="btnGreen";a=document.getElementById("btnSearch");a.className="btnGreen"};
