
//class
function callHistory() {
	this.next = 0;
	this.calls = new Array();

	this.calls[this.next] = new call('<incoming>', -1, 'outgoing');
	this.next++;
};

callHistory.prototype.add = ADD;
callHistory.prototype.getCalls = GETCALLS;
callHistory.prototype.getCall = GETCALL;
callHistory.prototype.dispCalls = DISPCALLS;
function ADD(callID, num, type)
{
	this.calls[this.next] = new call(callID, num, type);

	this.next++;
}

function GETCALLS()
{
	var retstring = '';
	for (var i = 0; i < this.next; i++)
	{
		retstring += i+"...[seperator2]...";
		retstring += this.calls[i].getCID()+"...[seperator2]...";
		retstring += this.calls[i].getNum()+"...[seperator2]...";
		retstring += this.calls[i].getType();
		if (i < this.next - 1)
		{
			retstring += "...[seperator1]...";
		}
			
	}
	return retstring;
}

function GETCALL(index)
{
	var retstring = '';

	retstring += this.calls[index].getCID()+","+this.calls[index].getNum();
	return retstring;
}

function DISPCALLS()
{
	var dispHTML = '';

	dispHTML = '<select ondblclick="alert(this.value)"id="callHistory_display" multiple size=7>';
	var i = this.next - 1;	
	while ( i >= 0)
	{
		dispHTML += '<option value="'+this.calls[i].getNum()+'">'+this.calls[i].getCID()+'</option>';
		i--;
	}
	dispHTML += '</select>';
	
	return dispHTML;
}


//class
function call(cid, num, type) {
	this.number = num ? num : 0;
	this.callerid = cid ? cid : 'none';
	this.type = type ? type : 'none';
}

call.prototype.getNum = GETNUM;
call.prototype.getCID = GETCID;
call.prototype.getType = GETTYPE;

function GETTYPE()
{
	return this.type;
}

function GETNUM()
{
	return this.number;
}

function GETCID()
{
	return this.callerid;
}
