registerSwitch(this.id, this);
alert('test');
if (this.state >= this.maxState)
this.state = 0;
else
this.state += 1;
var n = parseInt(this.getAttribute('id'), 10);
if (!n) n = 0;
return n;
this.setAttribute('id', value);
var n = parseInt(this.getAttribute('state'), 10);
if (!n) n = 0;
return n;
this.setAttribute('state', value);
switchToState(value);
var n = parseInt(this.getAttribute('pending'), 10);
if (!n) n = 0;
return n;
if (value < 0) value = 0;
this.setAttribute('pending', value);
alert(this); this.toggleState();
transmitSwitch(this.id, state);
if (id == this.id) {
this.pending -= 1;
this.setAttribute('state', value);
}
1
transmitSwitch(this.id, state == 1 ? 1 : 0);
transmitSwitch(this.id + 1, state == 2 ? 1 : 0);
if (id == this.id) {
this.pending -= 1;
if (state) {
switch (this.state) {
case 0: this.setAttribute('state', 1); break;
case 1: this.setAttribute('state', 1); break;
case 2: this.setAttribute('state', 3); break;
}
} else {
switch (this.state) {
case 0: this.setAttribute('state', 0); break;
case 1: this.setAttribute('state', 0); break;
case 2: this.setAttribute('state', 2); break;
}
}
} else if (id == this.id + 1) {
this.pending -= 1;
if (state) {
switch (this.state) {
case 0: this.setAttribute('state', 2); break;
case 1: this.setAttribute('state', 3); break;
case 2: this.setAttribute('state', 2); break;
}
} else {
switch (this.state) {
case 0: this.setAttribute('state', 0); break;
case 1: this.setAttribute('state', 1); break;
case 2: this.setAttribute('state', 0); break;
}
}
}
2