function URLEncode(unencodedValue) {var SAFECHARS="0123456789"+"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+"abcdefghijklmnopqrstuvwxyz"+"-_.!~*'()";var HEX="0123456789ABCDEF";var plaintext=unencodedValue;if(plaintext===undefined) plaintext='';var encoded="";for(var i=0;i255){alert("Unicode Character '" +ch +"' cannot be encoded using standard URL encoding.\n"+"(URL encoding only supports 8-bit characters.)\n"+"A space (+) will be substituted.");encoded+="+";}else{encoded+="%";encoded+=HEX.charAt((charCode>>4)&0xF);encoded+=HEX.charAt(charCode&0xF);}}} return encoded;} function rand(min,max){return Math.floor(Math.random()*(max-min+1))+min;} function NumberFormat(num){decpoint=".";sep=",";num=num.toString();a=num.split(decpoint);x=a[0];y=a[1];z="";if(typeof(x)!="undefined"){for(i=x.length-1;i>=0;i--) z+=x.charAt(i);z=z.replace(/(\d{3})/g,"$1"+sep);if(z.slice(-sep.length)==sep) z=z.slice(0,-sep.length);x="";for(i=z.length-1;i>=0;i--) x+=z.charAt(i);if(typeof(y)!="undefined"&&y.length>0) x+=decpoint+y;} return x;} function URLDecode(str){var histogram={};var ret=str.toString();var replacer=function(search,replace,str){var tmp_arr=[];tmp_arr=str.split(search);return tmp_arr.join(replace);};histogram["'"]='%27';histogram['(']='%28';histogram[')']='%29';histogram['*']='%2A';histogram['~']='%7E';histogram['!']='%21';histogram['#']='%23';histogram['%23']='#';histogram['%20']='+';histogram['\u20AC']='%80';histogram['\u0081']='%81';histogram['\u201A']='%82';histogram['\u0192']='%83';histogram['\u201E']='%84';histogram['\u2026']='%85';histogram['\u2020']='%86';histogram['\u2021']='%87';histogram['\u02C6']='%88';histogram['\u2030']='%89';histogram['\u0160']='%8A';histogram['\u2039']='%8B';histogram['\u0152']='%8C';histogram['\u008D']='%8D';histogram['\u017D']='%8E';histogram['\u008F']='%8F';histogram['\u0090']='%90';histogram['\u2018']='%91';histogram['\u2019']='%92';histogram['\u201C']='%93';histogram['\u201D']='%94';histogram['\u2022']='%95';histogram['\u2013']='%96';histogram['\u2014']='%97';histogram['\u02DC']='%98';histogram['\u2122']='%99';histogram['\u0161']='%9A';histogram['\u203A']='%9B';histogram['\u0153']='%9C';histogram['\u009D']='%9D';histogram['\u017E']='%9E';histogram['\u0178']='%9F';for(replace in histogram){search=histogram[replace];ret=replacer(search,replace,ret)} ret=decodeURIComponent(ret);return ret;} jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;} var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;} expires='; expires='+date.toUTCString();} var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i-1;},g='gecko',w='webkit',s='safari',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff35':is('firefox/3')?g+' ff3':is('gecko/')?g:/opera(\s|\/)(\d+)/.test(ua)?'opera opera'+RegExp.$2:is('konqueror')?'konqueror':is('chrome')?w+' '+s+' chrome':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js'];c=b.join(' ');h.className+=' '+c;return c;};css_browser_selector(navigator.userAgent); function zeroPad(num){if(num<10){return"0"+num;}else return num;} function add_to_cart(batchdef){window.location='/hands?batch='+batchdef;return 0;$.post('/util/hand_check.php','batch='+batchdef+'&setcookie=1',function(data){if(data.avail){if(window.location.pathname!="/cart") window.location="https://www.pokertableratings.com/cart";else load_cart();}else{alert("We're sorry, this type of hand is not currently available.");}},"json");};var site="";var structure="";var stakes="";var players="";var hands="";var price="10";var game="Hold'em";var tourney="Cash";var batches=0;var emailok=false;var usernameok=false;var captchaok=false;$(document).ready(function(){login_setup();var isposting=false;$('#searchform .searchbox:first').attr("autocomplete","off");$('#searchform .searchbox:first').keyup(function(e){if(e.keyCode!=38&&e.keyCode!=37&&e.keyCode!=39&&e.keyCode!=35&&e.keyCode!=36&&e.keyCode!=40&&e.keyCode!=13&&$(this).val().length>0){if(!isposting){isposting=true;$.post('/util/suggester.php','search='+$(this).val(),function(data){if(data.success){var datalist='';for(var i in data.players){var suggestion_txt='
'+data.players[i].player_disp;suggestion_txt+=' '+data.players[i].sitename+'';suggestion_txt+='
';datalist+=suggestion_txt;} if($('#suggestions').length==0) $('#searchform .searchbox:first').after('');$('#suggestions').html(datalist).fadeIn();isposting=false;}else{if(data.reason=="stop"){isposting=true;$('#searchform .searchbox:first').removeAttr("autocomplete");$('#searchform .searchbox:first').blur();$('#searchform .searchbox:first').focus();}else isposting=false;}},"json");}}});$('#searchform .searchbox:first').keydown(function(e){switch(e.keyCode){case 38:e.preventDefault();if($('.suggestion.selected').length==1) if($('.suggestion.selected').prev().length>0){var selectNew=$('.suggestion.selected').prev();$('.suggestion').removeClass('selected');selectNew.addClass('selected');$('#searchform .searchbox:first').val(selectNew.attr("player"));} break;case 40:e.preventDefault();if($('.suggestion.selected').length==1){if($('.suggestion.selected').next().length>0){var selectNew=$('.suggestion.selected').next();$('.suggestion').removeClass('selected');selectNew.addClass('selected');$('#searchform .searchbox:first').val(selectNew.attr("player"));}}else{$('.suggestion:first').addClass('selected');$('#searchform .searchbox:first').val($('.suggestion:first').attr("player"));} break;case 13:if($('.suggestion.selected').length==1){e.preventDefault();window.location=$('.suggestion.selected').attr("link");} break;}});$('.suggestion').live('click',function(){window.location=$(this).attr("link");});$('#searchform .searchbox:first').blur(function(e){if($(this).val()=='') $('#suggestions').html('');$('#suggestions').fadeOut('fast');});$('#hh_cart').submit(function(e){e.preventDefault();var thisbatch=$('#selSite').val()+","+$('#selStructure').val()+","+$('#selStakes').val()+","+$('#selPlayers').val();add_to_cart(thisbatch);});$('.ov_btab').click(function(){start_load();window.location=($(this).find('a').attr("href"));});$('.addbuddyicon').each(function(){var id=$(this).attr("id");if($('#logggg').html()==42){}else{$('#'+id).click(function(){window.location="/register.php";});} $.post('/buddies.php','action=is_buddy&buddy='+URLEncode(URLEncode($(this).attr("name")))+'&sid='+$(this).attr("sid"),function(data){var xmlDoc=data;var buddies=xmlDoc.getElementsByTagName("buddies")[0];var buddynode=buddies.getElementsByTagName("buddy")[0];var buddy=buddynode.getAttribute("name");var sid=buddynode.getAttribute("sid");var isbuddy=buddynode.getAttribute("isbuddy");if(isbuddy==1){$('#'+id).html("\"Remove");$('#'+id).removeClass("addbuddyicon");$('#'+id).addClass("removebuddyicon");$('#'+id).click(buddy_remove($('#'+id)));}else{$('#'+id).click(buddy_add($('#'+id)));}},"xml");});$('.addbuddytext').each(function(){var id=$(this).attr("id");if($('#logggg').html()==42){}else{$('#'+id).click(function(){window.location="/register.php";});} $.post('/buddies.php','action=is_buddy&buddy='+URLEncode($(this).attr("name"))+'&sid='+$(this).attr("sid"),function(data){var xmlDoc=data;var buddies=xmlDoc.getElementsByTagName("buddies")[0];var buddynode=buddies.getElementsByTagName("buddy")[0];var buddy=buddynode.getAttribute("name");var sid=buddynode.getAttribute("sid");var isbuddy=buddynode.getAttribute("isbuddy");if(isbuddy==1){$('#'+id).html("Remove Buddy");$('#'+id).removeClass("addbuddytext");$('#'+id).addClass("removebuddytext");$('#'+id).click(buddy_remove_t($('#'+id)));}else{$('#'+id).click(buddy_add_t($('#'+id)));}},"xml");});if($('#o_status').length>0){$.get('/buddies.php?action=is_online&buddy='+$('#o_status').attr("name")+'&sid='+$('#o_status').attr("sid"),function(data){try{if(data.childNodes.length>0){if(data.lastChild.attributes[0].nodeValue>0) $('#o_status').html('online icon');else $('#o_status').html("");}}catch(err){}},'xml');} function buddy_add(icon){var id=$(icon).attr("id");$(icon).find('img').click(function(e){e.preventDefault();var params=$(this).attr("addurl");params=params.substring(params.lastIndexOf('?')+1);$.post('/buddies.php',params,function(data){xmlDoc=data;buddynode=xmlDoc.getElementsByTagName("buddy")[0];buddy=buddynode.getAttribute("name");sid=buddynode.getAttribute("sid");alert(buddy+" has been added to your buddy list!");$('#'+id).html("\"Remove");$('#'+id).click(buddy_remove($('#'+id)));},"xml");});} function buddy_add_t(icon){var id=$(icon).attr("id");$(icon).find('a').click(function(e){e.preventDefault();var params=$(this).attr("href");params=params.substring(params.lastIndexOf('?')+1);$.post('/buddies.php',params,function(data){xmlDoc=data;buddynode=xmlDoc.getElementsByTagName("buddy")[0];buddy=buddynode.getAttribute("name");sid=buddynode.getAttribute("sid");alert(buddy+" has been added to your buddy list!");$('#'+id).html("Remove Buddy");$('#'+id).click(buddy_remove_t($('#'+id)));},"xml");});} function buddy_remove(icon){var id=$(icon).attr("id");$(icon).find('img').click(function(e){e.preventDefault();var params=$(this).attr("addurl");params=params.substring(params.lastIndexOf('?')+1);$.post('/buddies.php',params,function(data){xmlDoc=data;buddynode=xmlDoc.getElementsByTagName("buddy")[0];buddy=buddynode.getAttribute("name");sid=buddynode.getAttribute("sid");alert(buddy+" has been removed from your buddy list!");$('#'+id).html("\"Add");$('#'+id).click(buddy_add($('#'+id)));},"xml");});} function buddy_remove_t(icon){var id=$(icon).attr("id");$(icon).find('a').click(function(e){e.preventDefault();var params=$(this).attr("href");params=params.substring(params.lastIndexOf('?')+1);$.post('/buddies.php',params,function(data){xmlDoc=data;buddynode=xmlDoc.getElementsByTagName("buddy")[0];buddy=buddynode.getAttribute("name");sid=buddynode.getAttribute("sid");alert(buddy+" has been removed from your buddy list!");$('#'+id).html("Add Buddy");$('#'+id).click(buddy_add_t($('#'+id)));},"xml");});} $('.buy_hands_ad_right_one, .buy_hands_ad_right_two, .buy_hands_ad_left, .hh_ad160_top, .hh_ad160_bottext, .buy_hands_ad_right_three, .buy_hands_ad_left_b').click(function(){if($('#hhtracklink').length>0) window.location=$('#hhtracklink').attr("href");else window.location=$('#hh_cart').attr("action");});function login_click(event){event.preventDefault();$.post("/login_action.php","username="+$('#login_u').val()+"&password="+$('#login_p').val(),function(data){if(data.success==true){$('#message_box').html("

Login accepted. Welcome back "+data.username+"!

");$('#message_box').fadeIn('fast',function(){$('#login_area').html("
You are logged in as "+data.username+"    (Logout)
");$('#log_out_link').click(function(event){logout_click(event)});$('#message_box').animate({opacity:1.0},2000);$('#message_box').fadeOut('fast');pageTracker._trackPageview('/logged_in');var date=new Date();var options={path:'/',expires:(date.getTime()+(24*60*60))};var path=window.location.pathname;var page=path.substring(path.lastIndexOf('/')+1);if(page!="checkout"&&page!="premium-purchase"){window.location="/my-ptr";}else if(page=="checkout"){window.location="/checkout";}else if(page=="premium-purchase"){window.location="/premium-purchase";}})}else{$('#message_box').html("

Login error. Please check that you typed your username and password correctly.

");$('#message_box').fadeIn('fast',function(){$('#message_box').animate({opacity:1.0},3000);$('#message_box').fadeOut('fast');});}},"json");return false;} function login_setup(){$('#top_login').submit(function(event){login_click(event)});$('#login_u').focus(function(){if($(this).val()=="Email Address") $(this).val("");});$('#login_p').focus(function(){if($(this).val()=="password") $(this).val("");}) $('#log_out_link').click(function(event){logout_click(event);});} $('input[name=player]').focus(function(){if($(this).val()=="Type Your Screen Name Here") $(this).val("");});$('#profilesearch input').click(function(){var pname=$('#o_status').attr("name");if($(this).val()==pname) $(this).val("");});function logout_click(event){event.preventDefault();var date=new Date();var options={path:'/',expires:(date.getTime()+(24*60*60))};$.post("/logout.php","",function(data){if(data.success==true){$('#message_box').html("

You have been logged out. Come back soon!");$('#message_box').fadeIn('slow',function(){$('#login_area').html("

"+"
"+" "+"
"+"
"+" "+"
"+"
"+"
Not Yet a Member? It's FREE! Register Now!
"+"
");$('#top_login').submit(function(event){login_click(event)});$('#message_box').animate({opacity:1.0},3000);$('#message_box').fadeOut('slow');window.location="/";})}},"json");} function register(){var width=document.documentElement.clientWidth;var xpos=Math.round(width/2-193);var ypos=window.pageYOffset;if(ypos==undefined) ypos=document.documentElement.scrollTop;$('#darken').fadeIn();$('#darken').height($(document).height());$('#register_popup').attr({style:"top: 3%; left: 50%; margin: "+ypos+"px 0 0 -193px"});$('#register_popup').fadeIn();$('#register_close').click(function(){$('#register_popup').fadeOut();$('#darken').fadeOut();});} $('#regnow,.regnow').click(function(e){e.preventDefault();$('#rp_l').hide();register();$('#rp_r').show();});$('.login').click(function(e){e.preventDefault();$('#rp_r').hide();register();$('#rp_l').show();});function start_load(){var width=document.documentElement.clientWidth;var xpos=Math.round(width/2-203);var ypos=100+window.pageYOffset;$('#darken').attr({style:"top: "+window.pageYOffset+"px"});$('#darken').fadeIn();$('#loading_box').attr({style:"top: 30%; left: 50%; margin: 0 0 0 -203px"});$('#loading_box').fadeIn();} $('.ov_btab a').click(function(){start_load()});$('#rpli').click(function(e){e.preventDefault();$('#rp_r').hide();$('#rp_l').show();});$('#rpsu').click(function(e){e.preventDefault();$('#rp_l').hide();$('#rp_r').show();});$('#selSite').change(function(){site=this.options[this.options.selectedIndex].innerHTML;$.post('/util/sel_hand.php','key='+$('#selSite').val(),function(data){var options="";for(var k in data.results){options=options+"";} $('#selStructure').html(options);},"json");});$('#selStructure').change(function(){structure=this.options[this.options.selectedIndex].innerHTML;var params='key='+$('#selSite').val()+','+$('#selStructure').val();$.post('/util/sel_hand.php',params,function(data){var options="";for(var k in data.results){options=options+"";} $('#selStakes').html(options);},"json");});$('#selStakes').change(function(){window.stakes=this.options[this.options.selectedIndex].innerHTML;structure=this.options[this.options.selectedIndex].innerHTML;var params='key='+$('#selSite').val()+','+$('#selStructure').val()+','+$('#selStakes').val();$.post('/util/sel_hand.php',params,function(data){var options="";for(var k in data.results){options=options+"";} $('#selPlayers').html(options);},"json");});try{$('#registerform').validate({onkeyup:false,rules:{from:{required:true,remote:"/util/email_check.php"},name:{required:true},username:{required:true,remote:"/util/username_check.php"},recaptcha_response_field:{required:true}},messages:{username:"This username is already taken.",from:"Email address invalid or already used"},errorPlacement:function(error,element){if(element.attr("id")=="recaptcha_response_field"){error.insertAfter('#recaptcha_table');}else{error.insertAfter(element);}}});}catch(err){}}); (function($){$.extend({tablesorter:new function(){var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",decimal:'.',debug:false};function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms");}this.benchmark=benchmark;function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s);}else{alert(s);}}function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug="";}var rows=table.tBodies[0].rows;if(table.tBodies[0].rows[0]){var list=[],cells=rows[0].cells,l=cells.length;for(var i=0;i1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.metadata)&&($(cell).metadata().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;ib)?1:0));};function sortTextDesc(a,b){return((ba)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){$this.trigger("sortStart");var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){var $cell=$(this);var i=this.column;this.order=this.count++%2;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i]+>/gi,'').replace(/\$/,"").replace(/\,/g,"");},type:'numeric'});$.tablesorter.addParser({id:'ranked',is:function(s){return false;},format:function(s){return s.replace(/\./g,"");},type:'numeric'});$.tablesorter.addParser({id:'commad',is:function(s){return false;},format:function(s){return s.replace(/\,/g,"");},type:'numeric'});$.tablesorter.addParser({id:'weirddates',is:function(s){return false;},format:function(s){var dateparts=s.split(' ');var months=new Array();months['Jan']='01';months['Feb']='02';months['Mar']='03';months['Apr']='04';months['May']='05';months['Jun']='06';months['Jul']='07';months['Aug']='08';months['Sep']='09';months['Oct']='10';months['Nov']='11';months['Dec']='12';switch(dateparts.length){case 5:var day=String(dateparts[1]).replace(/[a-z]+/gi,'') if(day<10) day='0'+day;s=months[dateparts[0]]+day;var time=dateparts[3];time=String(time).replace break;case 3:var day=String(dateparts[1]).replace(/[a-z]+,/gi,'') if(day<10) day='0'+day;s=dateparts[2]+''+months[dateparts[0]]+day;break;case 2:var day=String(dateparts[1]).replace(/[a-z]+/gi,'') if(day<10) day='0'+day;s=months[dateparts[0]]+day;break;} return s;},type:'numeric'}) var buddy;var newwindow=null;var hudwindow=null;function pop_replay(url){if(!newwindow) newwindow=window.open(url,"replayer","location=yes,menubar=no,width=1045,height=790,toolbar=no,scrollbars=yes");else if(!newwindow.closed&&!$.browser.opera) newwindow.location.href=url;else newwindow=window.open(url,"replayer","location=yes,menubar=no,width=1045,height=790,toolbar=no,scrollbars=yes");if(window.focus){newwindow.focus();}} function pop_replay2(url){if(!newwindow) newwindow=window.open(url,"replayer","location=yes,menubar=no,width=936,height=570,toolbar=no");else if(!newwindow.closed) newwindow.location.href=url;else newwindow=window.open(url,"replayer","location=yes,menubar=no,width=936,height=570,toolbar=no");if(window.focus){newwindow.focus();}} function pop_hud(site,player){if(!site) url='/web_hud/';else url='/web_hud/'+site+'/'+player;if(!hudwindow) hudwindow=window.open(url,"WebHUD","location=no,menubar=no,width=840,height=480,toolbar=no,scrollbars=no");else if(!hudwindow.closed) hudwindow.location.href=url;else hudwindow=window.open(url,"WebHUD","location=no,menubar=no,width=840,height=480,toolbar=no,scrollbars=no");if(window.focus){hudwindow.focus();}} function pop_share(url){newwindow=window.open(url,"share","location=yes,menubar=no,width=850,height=400,toolbar=no");if(window.focus){newwindow.focus();}} function pop_buddylist(url){if(url!='old'&&$('#logggg').html()==42){newwindow=window.open("http://www.pokertableratings.com/buddy_list","buddylist","location=no,menubar=no,titlebar=no,toolbar=no,width=410,height=610");}else{if($('#logggg').html()==42){newwindow=window.open('https://www.pokertableratings.com/buddylist',"buddylist","location=no,menubar=no,titlebar=no,toolbar=no,width=390,height=620,toolbar=no");}else{window.location="/register.php";return false;}} if(window.focus){newwindow.focus();}} function ajax(url,func,id){var url_arr=new Array();url_arr=url.split('?');xmlhttp=null;if(window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();} else if(window.ActiveXObject){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");} if(xmlhttp!=null){xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4) if(xmlhttp.status==200) func(xmlhttp,id);} xmlhttp.open("GET",url,true);xmlhttp.send(null);} else{alert("Your browser does not support XMLHTTP.");}} function addbuddy(req,id){response=req.responseText;if(response=="-1"){alert("You must login before adding a player to your Buddy List.");} else{xmlDoc=parseXML(response);buddynode=xmlDoc.getElementsByTagName("buddy")[0];buddy=buddynode.getAttribute("name");sid=buddynode.getAttribute("sid");alert(buddy+" has been added to your buddy list!");document.getElementById(id).innerHTML="\"Remove";}} function removebuddy(req,id){response=req.responseText;if(response=="-1"){alert("You must login before removing a player from your Buddy List.");} else{xmlDoc=parseXML(response);buddynode=xmlDoc.getElementsByTagName("buddy")[0];buddy=buddynode.getAttribute("name");sid=buddynode.getAttribute("sid");alert(buddy+" has been removed from your buddy list!");document.getElementById(id).innerHTML="\"Add";}} function isbuddy(req,id){response=req.responseText;if(response!="-1"){xmlDoc=parseXML(response);buddynode=xmlDoc.getElementsByTagName("buddy")[0];buddy=buddynode.getAttribute("name");sid=buddynode.getAttribute("sid");isbuddy=buddynode.getAttribute("isbuddy");if(isbuddy=="1"){document.getElementById(id).innerHTML="\"Remove";} else{document.getElementById(id).innerHTML="\"Add";}}} function getalerts(req,id){content="";response=req.responseText;if(response!="-1"){xmlDoc=parseXML(response);buddies=xmlDoc.getElementsByTagName("buddy");for(var i=0;i";} else{js="ajax('/buddies.php?action=add_alert&sid="+sid+"&buddy="+buddy+"',addalert,'"+id+"')";img="";} content+="
"+img+" "+buddy+" - "+sitename+"
";}} document.getElementById(id).innerHTML=content;} function addalert(req,id){response=req.responseText;if(response=="-1"){alert('Sorry, there is a maximum of 5 alerts allowed! Please remove an alert then try again.');} else{alert('Alert Added!');} ajax('/buddies.php?action=get_buddies_alerts',getalerts,id);} function addbuddyandlist(req,id){response=req.responseText;if(response=="-1"){alert("You must login before adding a player to your Buddy List.");} else{xmlDoc=parseXML(response);buddynode=xmlDoc.getElementsByTagName("buddy")[0];buddy=buddynode.getAttribute("name");sid=buddynode.getAttribute("sid");alert(buddy+" has been added to your buddy list!");document.getElementById('new_buddy_name').value="";} ajax('/buddies.php?action=get_buddies_alerts',getalerts,id);} function addbuddywrapper(){site=document.getElementById('new_buddy_site').value;buddy=document.getElementById('new_buddy_name').value;if(site=='0'){alert('Please select a site.');return;} if(buddy==''){alert('Please enter the buddy name.');return;} url='/buddies.php?action=add_buddy&sid='+site+'&buddy='+buddy;ajax(url,addbuddyandlist,'tr_pro_alerts_leftlist');} function addusernamewrapper(){user=document.getElementById('inputusername').value;if(user==''){alert('Please enter a username!');return;} url='/members/member.php?req=saveusername&username='+user;ajax(url,addusername,'username');} function addusername(req,id){response=req.responseText;if(response=="-1"){alert("Username already exists. Please choose another");} else{document.getElementById(id).innerHTML=response;}} function removealert(req,id){alert('Alert Removed!');ajax('/buddies.php?action=get_buddies_alerts',getalerts,id);} function parseXML(text) {try{xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async="false";xmlDoc.loadXML(text);} catch(e){try {parser=new DOMParser();xmlDoc=parser.parseFromString(text,"text/xml");} catch(e) {alert(e.message);return-1;}} return xmlDoc;} function addslashes(str){str=str.replace(/\\/g,'\\\\');str=str.replace(/\%27/g,'\\%27');str=str.replace(/\'/g,'\\\'');str=str.replace(/\"/g,'"');str=str.replace(/\0/g,'\\0');str=str.replace(/\&/g,'&');return str;}