var PlusConstants = {
    STATUS_PLUS   : "plus",
    STATUS_MINUS  : "minus"
}

function Plus( plusId, plusForId, userOnClickEvent){
    this.plusId = plusId;
    this.plusForId = plusForId;
    this.userOnClickEvent = userOnClickEvent;

    this.obj = $( this.plusId);
    if( this.obj == null) return;
 
    this.obj.onclick = this.onClick.bindAsEventListener(this);

    this.init();
}

Plus.prototype = {
    init : function(){
        this.setPlus();
    },

    setMinus : function (){
        this.obj.className = PlusConstants.STATUS_MINUS;
        if( this.plusForId) Element.show( this.plusForId);
    },

    setPlus : function (){
        this.obj.className = PlusConstants.STATUS_PLUS;
        if( this.plusForId) Element.hide( this.plusForId);
    },

    togglePlus : function (){
        if( this.getStatus() == PlusConstants.STATUS_PLUS){
            this.setMinus();
        }else{
            this.setPlus();
        }
    },

    getStatus : function (){
        if( Element.hasClassName( this.obj, PlusConstants.STATUS_PLUS)){
            return PlusConstants.STATUS_PLUS;
        }else if( Element.hasClassName(this.obj, PlusConstants.STATUS_MINUS)){
            return PlusConstants.STATUS_MINUS;
        }else{
            return "N/A";
        }
//        return this.obj.className;
    },

    onClick : function( onClickEvent){
        this.togglePlus();
        this.callUserOnClickEvent();
    },

    callUserOnClickEvent : function(){
        if( this.userOnClickEvent) this.userOnClickEvent();
    }
}