function decrypt(str){
var k = viewText;
var ret = "";
var s = new Array();
var i = 0;
var j = 0;
var l = str.length;
//l = 10;
for(var x=0; x<l; x++){
var c = str.charCodeAt(x) + Math.floor(((k.charCodeAt(j)%10)/2));
ret += String.fromCharCode(c);
j++;
if(j==k.length) j=0;
}
ret = replace(ret,"?"," ");
return ret;
}
function replace(str, replaceString, withString){
var myArray = str.split(replaceString);
return (myArray.join(withString));
}
//Active Players OBJECT DEFINITION
function player(){
this.load_data = new Array;
this.cur_date;
this.units;
this.sb_refresh;
this.alt_refresh;
this.qs_refresh;
this.offset;
this.position;
this.id;
this.name;
this.today;
this.thru;
this.thruDispAlt;
this.total;
this.r1;
this.r2;
this.r3;
this.r4;
this.total_score;
this.greens;
this.greens_att;
this.greens_per;
this.fairways;
this.fairways_att;
this.fairways_per;
this.sand_saves;
this.bunker_shots;
this.sand_save_per;
this.no_putts;
this.avg_putts_hole;
this.avg_drv_dist;
this.r1_hbh;
this.r2_hbh;
this.r3_hbh;
this.r4_hbh;
this.player_status;
this.tee_pos;
this.start_type;
this.start_hole;
this.loadData = loadData;
}
function loadData(ds){ //assign data from topic to court object variables
var datastream = new String(ds);
this.load_data = datastream.split("|"); //place data string into array
//this.cur_date = this.load_data[0]; //assign values to court object variables
//this.units = this.load_data[1];
//this.sb_refresh = this.load_data[2];
//this.alt_refresh = this.load_data[3];
//this.qs_refresh = this.load_data[4];
this.offset = this.load_data[0];
this.id = this.load_data[2];
this.name = this.load_data[3];
this.today = this.load_data[4];
this.total = this.load_data[6];
this.r1 = this.load_data[7];
this.r2 = this.load_data[8];
this.r3 = this.load_data[9];
this.r4 = this.load_data[10];
this.total_score = this.load_data[11];
this.greens = this.load_data[12];
this.greens_att = this.load_data[13];
this.greens_per = this.load_data[14];
this.fairways = this.load_data[15];
this.fairways_att = this.load_data[16];
this.fairways_per = this.load_data[17];
this.sand_saves = this.load_data[18];
this.bunker_shots = this.load_data[19];
this.sand_save_per = this.load_data[20];
this.no_putts = this.load_data[21];
this.avg_putts_hole = this.load_data[22];
this.avg_drv_dist = this.load_data[23];
this.r1_hbh = this.load_data[24];
this.r2_hbh = this.load_data[25];
this.r3_hbh = this.load_data[26];
this.r4_hbh = this.load_data[27];
this.player_status = this.load_data[28];
this.tee_pos = this.load_data[29];
this.start_type = this.load_data[30].substr(0,1);
this.start_hole = this.load_data[30];
this.start_hole = this.start_hole.charCodeAt(1) - 64;
if (this.load_data[5] != ''){
if (this.load_data[5] == 'F'){
this.thru = 18;
}
else{
this.thru = parseInt(this.load_data[5]);
}
}
else {
this.thru = '';
}
if (this.today.indexOf(":") > 0){
var AMPM = this.today.substr(this.today.indexOf(" ")+1, 2);
var time = this.today.substring(0, this.today.indexOf(" "));
time = time.split(":");
//traceDebug("loadData: " + this.today + " | " + time[0] + " " + time[1]);
time[1] = time[1].indexOf("0") == 0 ? time[1].substr(1,1) : time[1];
var minutes = parseInt(time[1]);
var hours = parseInt(time[0]);
//traceDebug("loadData: " + this.today + " | " + time[1] + " " + minutes);
if (AMPM=="PM" && hours < 12){
hours += 12;
}
var date = new Date();
date.setHours(hours);
date.setMinutes(minutes);
//traceDebug("loadData: " + this.today + " | " + date);
this.teeTime = date;
}
else{
this.teeTime = -1;
}
var thruDisp;
var ast = "";
//traceDebug("GHTML.object start type: " + this.load_data[5] + " | " + this.start_type + " | " + this.start_hole + " | " +this.thru);
if (this.start_type == "N"){
thruDisp = this.thru;
thruSort = true;
}
else if (this.start_type == "S") {
var hole = parseInt(this.start_hole);
if (hole == 10){
ast = "*";
}
if (this.thru != ''){
thruDisp = this.thru + ast;
}
else {
thruDisp = this.thru;
}
thruSort = false;
}
else if (this.start_type == "G"){
if (this.thru != ''){
if (this.thru >= this.start_hole){
thruDisp = this.thru - this.start_hole + 1;
}
else {
thruDisp = 19 - this.start_hole + this.thru;
}
}
else {
thruDisp = this.thru;
}
thruSort = false;
}
this.thru = thruDisp + "";
//traceDebug("GHTML.object: " + this.thru);
this.thruDispAlt = (this.thru.indexOf("18") == 0) ? "F"+ast : this.thru;
if (this.name == ". " ){
this.name = "Not Available";
}
}
