function YsSwitches(initialState, onSwitch)
{
this.m_switches = new Array();
this.m_state = initialState;
this.m_onSwitch = onSwitch;
}
YsSwitches.prototype.addDisplaySwitch = function(elem, visibleDisplayValue)
{
this.addSwitch(new YsDisplaySwitch(elem, visibleDisplayValue));
}
YsSwitches.prototype.addImageSwitch = function(imgElem, secondSource)
{
this.addSwitch(new YsImageSwitch(imgElem, secondSource));
}
YsSwitches.prototype.doSwitch = function()
{
for (var i=0; i<this.m_switches.length; ++i)
this.m_switches[i].doSwitch();
this.m_state = !this.m_state;
if (this.m_onSwitch)
this.m_onSwitch(this.m_state);
return this.m_state;
}
YsSwitches.prototype.addSwitch = function(concreteSwitch)
{
this.m_switches[this.m_switches.length] = concreteSwitch;
}
function YsStylePropertySwitch(elem, propName, propSecondValue)
{
this.m_element = YAHOO.util.Dom.get(elem);
this.m_propName = propName;
this.m_propFirstValue = YAHOO.util.Dom.getStyle(this.m_element, this.m_propName);
this.m_propSecondValue = propSecondValue;
}

YsStylePropertySwitch.prototype.doSwitch = function()
{
var propValue = YAHOO.util.Dom.getStyle(this.m_element, this.m_propName);
if (propValue == this.m_propFirstValue) 
YAHOO.util.Dom.setStyle(this.m_element, this.m_propName, this.m_propSecondValue);
else 
YAHOO.util.Dom.setStyle(this.m_element, this.m_propName, this.m_propFirstValue);
}
function YsDisplaySwitch(elem, visibleDisplayValue)
{
element = YAHOO.util.Dom.get(elem);
if (!visibleDisplayValue) visibleDisplayValue = "block";
var secondDisplayValue = (YAHOO.util.Dom.getStyle(element, "display") == "none") ? 
visibleDisplayValue : "none";
YsDisplaySwitch.baseConstructor.call(this, element, "display", secondDisplayValue);
}
ys.extend(YsDisplaySwitch, YsStylePropertySwitch);
function YsImageSwitch(imgElem, secondSource)
{
this.m_preloadedImage = new Image();
this.m_preloadedImage.src = secondSource;
this.m_imgElement = YAHOO.util.Dom.get(imgElem);
this.m_firstSource = this.m_imgElement.src;
this.m_secondSource = secondSource;
}

YsImageSwitch.prototype.doSwitch = function()
{
if (this.m_imgElement.src == this.m_firstSource) 
this.m_imgElement.src = this.m_secondSource;
else
this.m_imgElement.src = this.m_firstSource;
}
function YsClassSwitch(elem, className)
{
this.m_element = YAHOO.util.Dom.get(elem);
this.m_className = className;
}
YsClassSwitch.prototype.doSwitch = function()
{
if (this.m_element.className.lastIndexOf(this.m_className) >= 0)
this.m_element.className = this.m_element.className.replace(this.m_className, '');
else
this.m_element.className += " " + this.m_className;
}
