/*
 * Phone constructor
 */
function Phone(id,model,img,cool) {
   this.id=id;
   this.model=model;
   this.img=img;
   this.cool=cool;
}
/*
 * Returns phone image URL
 * Pre: type = model | small | medium | large | extralarge | 3d
 */
Phone.prototype.getImage = function(type) {
	if (type == 'model')
		return "images/phones/"+this.img+".gif";
	if (type == 'small')
		return "images/phones/"+this.img+"_s.gif";
	if (type == 'small2')
		return "images/phones/"+this.img+"_m.gif";
	if (type == 'medium')
		return "images/phones/"+this.img+"_m.gif";
	if (type == 'large')
		return "images/phones/"+this.img+"_l.gif";
	if (type == 'extralarge')
		return "images/phones/"+this.img+"_xl.gif";
	if (type == '3d')
		return "images/phones/"+this.img+"_3d.gif";
}


function Slot() {
	this.slot = new Array(3);
	this.slot[0] = -1;
	this.slot[1] = -1;
	this.slot[2] = -1;
	this.full = 0;
}
Slot.prototype.addPhone = function(index) {
	for (i=0; i<3; i++) {
		if (this.slot[i] == -1) {
			this.slot[i] = index;
			this.full += 1;
			return i;
		}
	}
}
Slot.prototype.removePhone = function(index) {
	this.slot[index] = -1;
	this.full -= 1;
}
Slot.prototype.isFull = function() {
	if (this.full == 3)
		return true;
	else
		return false;
}
Slot.prototype.isSelected = function(phoneId) {
	for (i=0; i<3; i++) {
		if (this.slot[i] == phoneId)
			return true;
	}
	return false;
}

