//------------------------------------------------------------------------
// $Id: person.js,v 1.2 2008/08/31 12:30:33 kimballr Exp kimballr $
// $Author: kimballr $
//
// Copyright 2002-2008 Kimball Software
// All rights reserved
// mailto:rick@vrmlworld.net
//------------------------------------------------------------------------
// requires config.js

//------------------------------------------------------------------------
//-- Person Object

function Person(uniqID, username, avatarURL, interests, homepage) {
  var n = parseInt(Math.random()*10000);
  var x = parseInt(Math.random()*5);
  var z = parseInt(Math.random()*5);

  this.isMe = false;
  this.uniqID = 'notset';
  this.username = ABNetApp.User.defaultName();
  this.avatarURL = ABNetApp.defaults.avatarURL;
  this.interests = '';
  this.homepage = '';
  this.state = 'Online';
  this.typing = false;
  this.ignored=0;
  this.avatarPilot=null;
  this.currP= x + " 1.75 " + z;
  this.currO="0 0 1 0";

  if ( uniqID    ) { this.uniqID = uniqID; }
  if ( username  ) { this.username = username; }
  if ( avatarURL ) { this.avatarURL=avatarURL;   }
  if ( interests ) { this.interests = interests; }
  if ( homepage  ) { this.homepage = homepage;   }
};

Person.prototype.fromString = function(v) {
  var keylist=v.split('&');
  var i,kv;
  for ( i=0; i < keylist.length; i++ ) {
    kv = keylist[i].split('=');
    if ( kv.length == 2 ) {
      switch(kv[0]) {
       case 'avatarURL':
       case 'username':
	 this[kv[0]] = unescape(kv[1]);
         break;
       default:
        this[kv[0]]=kv[1];
      }
    }
  }
};

//------------------------------------------------------------------------
//-- Person Dictionary Object

function Dictionary() {};

Dictionary.prototype.toArray = function () {
  var theArray=new Array();
  
  for (var w in this) {
    if ( typeof w != 'function' ) {
      if ( this.hasOwnProperty(w) ) {
	var person = this[w];
	if ( !person.isMe )
	  theArray.push(person);
      }
    }
  }
  return theArray;
};
