
// dziedziczenie bede osiagal za pomoca metody parent
Object.prototype.parent = function (supClass) 
{
    tempObj = new supClass();
    for (property in tempObj) 
        this[property] = tempObj[property];       
};

function kalkulator(id_div_element, przed, sklad)
{
    this.init = function (id_div_element, przed, sklad)
    {
        this.container = document.getElementById(id_div_element);
        this.ranges = przed;
        this.components = sklad;
        this.sourceFormElements = this.createSourceForm(this.container);
        this.targetFormElements = this.createTargetForm(this.container);
    }
    
    this.createSubmitField = function (parent) 
    {
        var div = document.createElement('div');
        var submit = document.createElement('input');
		div.className = 'calcRow';
		submit.className = 'calcBtn';
        submit.setAttribute('type', 'submit');
        submit.value = 'Oblicz';
        parent.appendChild(div);
        div.appendChild(submit);
        return submit;
    }
    
    this.createCalcField = function (parent, text) 
    {
        var div = document.createElement('div');
        var label = document.createElement('label');
        var input = document.createElement('input');
        
		div.className = 'calcRow';
		label.className = 'calcLabel';
        label.appendChild(document.createTextNode(text));
        input.className = 'calcText';
        input.setAttribute('type', 'text');
        
        parent.appendChild(div);
        div.appendChild(label);
        div.appendChild(input);
        return input;
    }
    
    this.createTargetField = function (parent, text)
    {
        var element = this.createCalcField(parent, text);
        element.setAttribute('readonly', 'true');
        element.className = 'text target';
        return element;
    }
    
    this.roundMoney = function(money)
    {
        return Math.floor(money * 100) / 100;
    }
    
    // metody do pokrycia
    
    // utworzenie formy z danymi wejsciowymi
    this.createSourceForm = function (kontener) { alert('error'); };
    
    // utworzenie formy z wynikami
    this.createTargetForm = function (kontener) { alert('error'); };
    
    // obliczanie
    this.calculate = function () { alert('error'); };
}
