/* $Id: DotRule.js,v 1.2 2009/02/02 11:44:44 kly Exp $
 * Copyright (c) 2003, 2007 WorldTicket A/S
 * All rights reserved.
 */

function DotRule() {
        this.ADULT = arguments[0] -1 ;
        this.CHILD = arguments[1] - 1;
        this.INFANT = arguments[2] - 1;
        this.SENIOR = arguments[5] - 1 ;
}

DotRule.prototype = new GenericRule();

DotRule.prototype.applyChild = function() {
    var adult = this.handlers[this.ADULT];
    var child = this.handlers[this.CHILD];
    var senior = this.handlers[this.SENIOR];
    var iAdults = adult.getValue() + senior.getValue();
    child.setMax(iAdults >= 1 ? this.maxPerType(child) : 0);
}
DotRule.prototype.applyInfant = function() {
    var adult = this.handlers[this.ADULT];
    var infant = this.handlers[this.INFANT];
    var senior = this.handlers[this.SENIOR];
    var iAdults = adult.getValue() + senior.getValue();
    var iMaxInfants = this.maxPerType(infant);
    infant.setMax(iAdults >=  iMaxInfants ? iMaxInfants : iAdults);
}
