/**
 * JetCredit
 *
 * @version $Id$
 * @copyright 2005
 **/

function Payment() {
	this.mounts = 12;
	this.instalment;
	this.sum;
	this.errorMsg;
	this.currency = 0; 
	this.us2bg = 1.0;
	this.ucsAddition = 0; //10 bg lewa
	this._errmsg = "За избраният от Вас сроок на плащане сумата трябва да е по-голяма или равна на ";	
}
	Payment.prototype.Pay = function(sum, mounts) {
	this.sum = sum + 10; //10 лева за ucs
	this.mounts = (mounts != null)?mounts:12;
	if (this.currency == 0) {		
		this.sum = parseFloat(this.sum) * parseFloat(this.us2bg);		
	}			
		switch(this.mounts){
			case 7: 
				if (this.sum >= 150) {
		    		this.instalment = this.sum/6 + this.ucsAddition;
				} else {
					this.instalment = -1;
					this.errorMsg = this._errmsg + " 150 " + ((this.currency == 0)?"$":"лв");
				}
				break;
			case 12: 
				if (this.sum >= 400) {
		    		//alert(this.sum);
					this.instalment = this.sum*10.34/100 + this.ucsAddition;
				} else {
					this.instalment = -1;
					this.errorMsg = this._errmsg + " 400 "  + ((this.currency == 0)?"$":"лв");
				}
				break;
			case 18:
				if (this.sum >= 600) {
		    		this.instalment = this.sum*7.34/100 + this.ucsAddition;
				} else {
					this.instalment = -1;
					this.errorMsg = this._errmsg + " 600 " + ((this.currency == 0)?"$":"лв");
				}			
				break;
			default:				
				this.instalment = -1;
				this.errorMsg = "Некоректен период за изплащане";				
		} // switch		
}

