/* $Id: DatRule.js,v eab58338c618 2008/08/06 18:00:41 mro $
 * Copyright (c) 2003, 2007 WorldTicket A/S
 * All rights reserved.
 */

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

DatRule.prototype = new GenericRule();

DatRule.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);
}
DatRule.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);
}
