/** 
 * SVN FILE: $Id: ajax_basket_tickets.js 15431 2011-10-25 12:33:44Z jlekse $
 * @version $Revision: 15431 $
 * @lastmodified $LastChangedDate: 2011-10-25 14:33:44 +0200 (tor, 25 okt 2011) $
 */
function Ticket(basketItem) {
	if (!basketItem) {
		return;
	}
	this.basketItem = basketItem;
};


Ticket.prototype.updateFlash = function (state) {
	// state = 0 - free, 1 - selected, 5 - unavailable
	if (popupOpened(this.basketItem.basket.venueWindow) && this.basketItem.id == this.basketItem.basket.venueId) 
	{
		movie = getFlashMovieObject(this.basketItem.id); // preberemo embed element (flash element)
		if (movie != undefined || movie != null) {
			if (this.idPrice == undefined) {
				movie.callgetSeatInfo(this.id, state, this.idItemTree, 0); // pokličemo flash animacijo (action script metodo)
			} else {
				movie.callgetSeatInfo(this.id, state, this.idItemTree, this.idPrice); // pokličemo flash animacijo (action script metodo)
			}
		}
	}
};

Ticket.prototype.updateTpackFlash = function (state, id, idItem) {
	// state = 0 - free, 1 - selected, 5 - unavailable
	if (popupOpened(this.basketItem.basket.venueWindow) && this.basketItem.id == this.basketItem.basket.venueId) 
	{
		movie = getFlashMovieObject(this.basketItem.id); // preberemo embed element (flash element)
		if (movie != undefined || movie != null) {
			if (this.idPrice == undefined) {
				movie.callgetSeatInfo(id, state, idItem, 0); // pokličemo flash animacijo (action script metodo)
			} else {
				movie.callgetSeatInfo(id, state, idItem, this.idPrice); // pokličemo flash animacijo (action script metodo)
			}
		}
	}
};


function LockedSeat(basketItem, id) {
	this.base = Ticket;
	this.base(basketItem);
	this.id = id;
	this.basketItem.addLockedSeat(this);
	this.updateFlash(5);
};
LockedSeat.prototype = new Ticket();


LockedSeat.prototype.remove = function () {
	this.updateFlash(0);
	this.basketItem.removeLockedSeat(this);
};

/**
 * Konstruktor za Artikle
 */
function Article(basketItem, id, idbasketitem, iditemarttree) {
	this.base = Ticket;
	this.base(basketItem);
	this.id = id;
	this.iditemarttree = iditemarttree; // id storitve
	this.idbasketitem = idbasketitem;
	this.basketItem.addArtQty(this);
	
	// uiTickets.insertRow
	this.uiRow = this.basketItem.uiTickets.insertRow(this.basketItem.uiTickets.rows.length);
	this.uiRow.insertCell(0);
	this.uiRow.cells[0].className = 'td1';
	
	this.uiRow.insertCell(1);
	this.uiRow.cells[1].className = 'td2';
	
	this.uiRow.insertCell(2);
	this.uiRow.cells[2].className = 'td3';
	this.uiRow.cells[2].innerHTML = '<a href="javascript:void(null);" onclick="ajaxBasket.removeArt(' + this.iditemarttree + ', '+this.idbasketitem+');">X</a>';
};
Article.prototype = new Ticket();


Article.prototype.remove = function ()
{
	this.basketItem.uiTickets.deleteRow(this.uiRow.rowIndex);
	this.basketItem.removeArtQty(this);
};

Article.prototype.setPrice = function (value)
{
	if (this.price != value)
	{
		this.price = value; // cena za eno storitev
		// prikazovanje cene in statusov za izrano kategorijo
		this.priceEUR = formatCurr(this.price);
		this.totalPriceEUR = formatCurr(this.totalPrice);
		this.priceEUR = this.priceEUR.replace('.', ',');
		this.totalPriceEUR = this.totalPriceEUR.replace('.', ',');
		if (CURRENCY_ON_LEFT == 'TRUE') {
			this.middleText = STR_CURRENCY_CODE+'&#160;'+this.totalPriceEUR.replace(',', PRICE_DELIMETER);
		} else {
			this.middleText = this.totalPriceEUR.replace(',', PRICE_DELIMETER)+'&#160;'+STR_CURRENCY_CODE;
		}
		this.uiRow.cells[1].innerHTML =this.middleText;
	}
};

Article.prototype.setTotalPrice = function (value)
{
	if (this.totalPrice != value)
	{
		this.totalPrice = value; // cena skupaj
	}
};

Article.prototype.setName = function (value)
{
	if (this.name != value)
	{
		this.name = value; // ime izbrane kategorije >> status vstopnice
		this.uiRow.cells[0].innerHTML = this.name;
	}
};


Article.prototype.loadFromXml = function (xmlDoc)
{
	tmp = xmlDoc.totalPrice;
	tmp = tmp.replace(',', ".");
	this.setTotalPrice(parseFloat(tmp));
	
	tmp = xmlDoc.price;
	tmp = tmp.replace(',', ".");
	this.setPrice(parseFloat(tmp));
	this.setName(xmlDoc.displayString);
};

/**
 * Konstruktor za Storitve
 */
function SVC(basketItem, id, idbasketitem, iditemsvctree)
{
	this.base = Ticket;
	this.base(basketItem);
	this.id = id;
	this.iditemsvctree = iditemsvctree; // id storitve
	this.idbasketitem = idbasketitem;
	this.basketItem.addSvcQty(this);
	
	// uiTickets.insertRow
	this.uiRow = this.basketItem.uiTickets.insertRow(this.basketItem.uiTickets.rows.length);
	this.uiRow.insertCell(0);
	this.uiRow.cells[0].className = 'td1';
	
	this.uiRow.insertCell(1);
	this.uiRow.cells[1].className = 'td2';
	
	this.uiRow.insertCell(2);
	this.uiRow.cells[2].className = 'td3';
	this.uiRow.cells[2].innerHTML = '<a href="javascript:void(null);" onclick="ajaxBasket.removeSVC(' + this.iditemsvctree + ', '+this.idbasketitem+');">X</a>';

};
SVC.prototype = new Ticket();

/**
 * Odstranjevanje vseh vstopnic iz košarice
 */
SVC.prototype.remove = function ()
{
	this.basketItem.uiTickets.deleteRow(this.uiRow.rowIndex);
	this.basketItem.removeSvcQty(this);
};


SVC.prototype.setPrice = function (value, status, priceL)
{
	if (this.isGratis != "") {
		this.uiRow.cells[1].innerHTML = STR_SVC_GRATIS;
	} else if (this.basketItem.allowedSeatSelect == 10 && priceL.length > 1) {
		pL = priceL.length;
		i = 0;
		while (i < pL) {
			var b = formatCurrency(priceL[i].price);
			price = b.replace('.', ',');
			name = priceL[i].name.replace(' ', '&#160;');
			this.addOption += '<div class="priceList">';
			if (status == priceL[i].idStatus) {
				this.addOption += '<input type="radio" name="selectBox_'+this.iditemsvctree+'_'+this.idbasketitem+'" id="selectBox_'+this.iditemsvctree+'_'+this.idbasketitem+'_'+i+'" value="'+i+'" checked=\"checked\" onclick="ajaxBasket.changeStatusSVC('+priceL[i].idprice+', '+this.idbasketitem+', '+this.iditemsvctree+');" />';
			} else {
				this.addOption += '<input type="radio" name="selectBox_'+this.iditemsvctree+'_'+this.idbasketitem+'" id="selectBox_'+this.iditemsvctree+'_'+this.idbasketitem+'_'+i+'" value="'+i+'" onclick="ajaxBasket.changeStatusSVC('+priceL[i].idprice+', '+this.idbasketitem+', '+this.iditemsvctree+');" />';
			}
			if (CURRENCY_ON_LEFT == 'TRUE') {
				this.addOption += '<label for="selectBox_'+this.iditemsvctree+'_'+this.idbasketitem+'_'+i+'">'+name+'&#160;('+STR_CURRENCY_CODE+'&#160;'+price.replace(',', PRICE_DELIMETER)+')</label><br />';
			} else {
				this.addOption += '<label for="selectBox_'+this.iditemsvctree+'_'+this.idbasketitem+'_'+i+'">'+name+'&#160;('+price.replace(',', PRICE_DELIMETER)+'&#160;'+STR_CURRENCY_CODE+')</label><br />';
			}
			this.addOption += '</div>';
			++i;
		}
		/*
		this.middleText = '<select id="selectBox_'+this.id+'_'+this.predstava+'" onchange="ajaxBasket.changeStatusSVC(this.value, '+this.iditemsvctree+', '+this.idbasketitem+');">'; // changePrice(this.value)
		this.middleText += this.basketItem.addOption;
		this.middleText += '</select>'; // end form
		*/
		this.uiRow.cells[1].innerHTML = this.addOption;
	} else {
		this.price = value; // cena za eno storitev
		// prikazovanje cene in statusov za izrano kategorijo
		this.priceEUR = formatCurr(this.price);
		this.priceEUR = this.priceEUR.replace('.', ',');
		if (CURRENCY_ON_LEFT == 'TRUE') {
			this.middleText = STR_CURRENCY_CODE+'&#160;'+this.priceEUR.replace(',', PRICE_DELIMETER);
		} else {
			this.middleText = this.priceEUR.replace(',', PRICE_DELIMETER)+'&#160;'+STR_CURRENCY_CODE;
		}
		this.uiRow.cells[1].innerHTML = this.middleText;
	}
};

SVC.prototype.setTotalPrice = function (value)
{
	if (this.totalPrice != value)
	{
		this.totalPrice = value; // cena skupaj
	}
};

SVC.prototype.setName = function (value)
{
	if (this.name != value)
	{
		this.name = value; // ime izbrane kategorije >> status vstopnice
		this.uiRow.cells[0].innerHTML = this.name;
	}
};

/* gratis tickets */
SVC.prototype.setGratis = function (value) {
	if (this.isGratis != value) {
		this.isGratis = value;
	}
};


SVC.prototype.loadFromXml = function (xmlDoc, priceL)
{
	this.addOption = ''; // za dodajanje opcij v formo
	this.setGratis(xmlDoc.gratis);
	tmp = xmlDoc.TotalPrice;
	tmp = tmp.replace(',', ".");
	this.setTotalPrice(parseFloat(tmp));
	tmp = xmlDoc.price;
	tmp = tmp.replace(',', ".");
	this.setPrice(parseFloat(tmp), xmlDoc.status, priceL);
	this.setName(xmlDoc.name);
};




function Seat(basketItem, id, idbasketitem, idItemTree) {
	this.base = Ticket;
	this.base(basketItem);
	this.idbasketitem = idbasketitem;
	this.id = id; /* id sedeza */
	this.xmlHttp = null; // za xmlHttp povezavo
	this.idItemTree = idItemTree;
	
	this.uiRow = this.basketItem.uiTickets.insertRow(this.basketItem.uiTickets.rows.length);
	/*
	$("#tb"+this.id+' > tbody').append(
		'<tr id="ibi'+this.id+'_'+idbasketitem+'"><td width="100%"></td><td align="right"></td><td align="right"></td><td align="right"></td></tr>'
	);
	*/
	
	// uiTickets.insertRow
	this.uiRow.insertCell(0);
	this.uiRow.cells[0].className = 'td1';
	
	this.uiRow.insertCell(1);
	this.uiRow.cells[1].className = 'td2';
	
	this.uiRow.insertCell(2);
	this.uiRow.cells[2].className = 'td3';
	
	/* mode == 0 -> TPACK sedezi */
	
	if (mode == 0)
	{
		
		this.uiRow.cells[2].innerHTML = '<a href="javascript:void(null);" onclick="ajaxBasket.unlockTpackSeat(' + this.basketItem.id + ', ' + this.idbasketitem + ');">X</a>';
	}
	else /* mode != 0 -> navadni sedezi */
	{
		//$("#ibi"+this.id+'_').append(
		this.uiRow.cells[2].innerHTML = '<a href="javascript:void(null);" onclick="ajaxBasket.unlockSeat(' + this.basketItem.id + ', ' + this.idbasketitem + ');">X</a>';
	}
	
	this.basketItem.addSeat(this);
	this.updateFlash(1);
	if (ajaxBasket.mode == 0)
	{
		if (!ajaxBasket.fastLockTpack) {
			var idframe = 'flashDvorana_'+ajaxBasket.idtpack;
			url = SITE_PATH+'tickets/tpack_seats.php5?index=' + ajaxBasket.index+'&idtpack='+ajaxBasket.idtpack;
			var tmp = frames[idframe].location.href = url;
			this.venueWindow = tmp;
		}
	}
};
Seat.prototype = new Ticket();


Seat.prototype.remove = function () {
	this.basketItem.uiTickets.deleteRow(this.uiRow.rowIndex);
	this.updateFlash(0);
	this.basketItem.removeSeat(this);
};

Seat.prototype.updateCaption = function (value)
{	
	/* mode == 0 -> TPACK sedezi */
	if (mode == 0)
	{
		this.uiRow.cells[0].innerHTML = this.itemString + ' - ' +this.displayString +' (' + this.rowCaption + ' ' + this.rowNo + ', ' + this.seatCaption + ' ' + this.seatNo + ')'+this.seatProp;
	}
	else /* mode != 0 -> navadni sedezi */
	{
		this.uiRow.cells[0].innerHTML = this.displayString +' (' + this.rowCaption + ' ' + this.rowNo + ', ' + this.seatCaption + ' ' + this.seatNo + ')'+this.seatProp;
	}
};


/**
 * Funkcija se klice iz loadFromXML, kjer se zgenerira obstojeca cena za stol
 *
 * @param value - vrednost v EUR
 */ 
Seat.prototype.setPrice = function (value)
{
	if (this.price != value) // preverjamo vrednosti
	{
		this.price = value;

		if (mode == 0) //tpack izpis
		{
			this.priceEUR = formatCurr(value);
			// preverjamo, če ima določeno ceno,ter če je to nosilna predstava (prva predstava) v abonmaju
			if (this.priceEUR != 'NaN' && this.priceEUR != null && this.priceEUR != '' && this.priceEUR != NaN && this.showCount == '0')
			{
				this.priceEUR = formatCurr(value*this.tpackshowCount); // množimo vrednost, ki jo ima karta * število predstav na abonmaju
				this.priceEUR = this.priceEUR.replace('.', ',');
				if (CURRENCY_ON_LEFT == 'TRUE') {
					this.middleText = STR_CURRENCY_CODE+'&#160;'+this.priceEUR.replace(',', PRICE_DELIMETER);
				} else {
					this.middleText = this.priceEUR.replace(',', PRICE_DELIMETER)+'&#160;'+STR_CURRENCY_CODE;
				}
				this.uiRow.cells[1].innerHTML = this.middleText;
			}
			else
			{
				this.uiRow.cells[1].innerHTML = '';
			}
		}
		else
		{
			// urejanje vrednosti v EURO
			this.priceEUR = formatCurrency(value);
			this.priceEUR = this.priceEUR.replace('.', ',');
			// izpis
			if (CURRENCY_ON_LEFT == 'TRUE') {
				this.middleText = STR_CURRENCY_CODE+'&#160;'+this.priceEUR.replace(',', PRICE_DELIMETER);
			} else {
				this.middleText = this.priceEUR.replace(',', PRICE_DELIMETER)+'&#160;'+STR_CURRENCY_CODE;
			}
			this.uiRow.cells[1].innerHTML = this.middleText;
		}
	}
};

/*
 * Funckija se klice, ko se izbere druga vrednost za stol
 * 
 * @param str - vrednost v EUR (value v optionu) in ime statusa (npr: 9_Otroska)
 * @param value2 - id sedeza, ki mora biti podan, da se ve, kater DIV se mora zamenjati (pri setPrice)
 * @param id_predstave - id predstave
 * @param steviloPredstav - to pride v postev pri abonmajih >> koliko je predstav na enem abonmaju
 * @param idbasketitem - id_basket_item zapisa
 */
Seat.prototype.updatePrice = function(index, idprice, idbasketitem, item_tree, steviloPredstav)
{ 
	ajaxBasket.changeStatus(idprice, index, item_tree, idbasketitem);
};


/**
 * Izpise formo, za ceno na sedez. Forma se generira glede na this.addOption
 * Ce je addOption vecji od 1, torej pomeni da bila dodana neka vrednost, se generira,
 * v nasprotnem primeru se prikaze samo prazen string ('')
 */
Seat.prototype.setPricePerSeat = function()
{
	// "resetiranje" spremenljivk
	this.generateForm = '';
	
	// preverjanje dolzine kreirane forme
	if (this.priceListIndex > 1){
		// kreiranje SELECT forme
		this.generateForm += this.addOption;
		
		// zapis forme na spletno stran
		this.uiRow.cells[1].innerHTML = this.generateForm;
	}
};

/**
 * Metoda addPriceForThisSeat, dodaja optione v listo in jih nato metoda setPricePerSeat tudi prikaze
 * addOption se postavi vsakic na novo ob branju XML datoteke (loadFromXML)
 * 
 * @param name - ime oz. tip cene (npr.: otroska)
 * @param price - cena za tip karte (npr.: 8.5)
 */
Seat.prototype.addPriceForThisSeat = function (priceL)
{
	
	pL = priceL.length;
	if (pL > 1) // preverjamo, ce sta argumenta sploh podana. Name in price morata biti definirana
	{
		i = 0;
		while (i < pL) {
			var b = formatCurrency(priceL[i].pricePerSeat);
			price = b.replace('.', ',');
			name = priceL[i].name.replace(' ', '&#160;');
			this.addOption += '<div class="priceList">';
			if (this.statusIndex == priceL[i].idStatus) {
				this.addOption += '<input type="radio" name="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'" id="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'_'+i+'" value="'+i+'" checked=\"checked\" onclick="Seat.prototype.updatePrice(this.value, '+this.idPrice+', '+this.idbasketitem+', '+this.predstava+', '+this.tpackshowCount+');" />';
			} else {
				this.addOption += '<input type="radio" name="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'" id="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'_'+i+'" value="'+i+'" onclick="Seat.prototype.updatePrice(this.value, '+this.idPrice+', '+this.idbasketitem+', '+this.predstava+', '+this.tpackshowCount+');" />';
			}
			if (CURRENCY_ON_LEFT == 'TRUE') {
				this.addOption += '<label for="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'_'+i+'">'+name+'&#160;('+STR_CURRENCY_CODE+'&#160;'+price.replace(',', PRICE_DELIMETER)+')</label><br />';
			} else {
				this.addOption += '<label for="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'_'+i+'">'+name+'&#160;('+price.replace(',', PRICE_DELIMETER)+'&#160;'+STR_CURRENCY_CODE+')</label><br />';
			}
			this.addOption += '</div>';
			++i;
		}
		this.priceListIndex = i;
		
	}
};

/**
 * Določimo id predstave
 */ 
Seat.prototype.idPredstave = function (value)
{
	this.predstava = value;
};

//only for tpack
Seat.prototype.setItemString = function (value) {
	if (this.itemString != value) {
		this.itemString = value;
		this.updateCaption();
	}
};

/**
 * Id holder, s katerim vemo, kdaj moramo narediti črto med abonmaji
 */ 
Seat.prototype.setHolder = function (value)
{
	this.idholder = value;
};

Seat.prototype.getHolder = function()
{
	return this.idholder;
};

/**
 * Ostevilcene predstave (oz.. nekaksen mali id) (0,1,2...) odvisno koliko jih je
 */
Seat.prototype.setshowCount = function (value)
{
	this.showCount = value;
};

/**
 * stevilo predstav, ki pripadajo enemu abonmaju
 */
Seat.prototype.setTpackShowCount = function (value)
{
	this.tpackshowCount = value;
};

Seat.prototype.setDisplayString = function (value) {
	if (this.displayString != value) {
		this.displayString = value;
		this.updateCaption();
	}
};


Seat.prototype.setRowCaption = function (value) {
	if (this.rowCaption != value) {
		this.rowCaption = value;
		this.updateCaption();
	}
};


Seat.prototype.setRowNo = function (value) {
	if (this.rowNo != value) {
		this.rowNo = value;
		this.updateCaption();
	}
};


Seat.prototype.setSeatCaption = function (value) {
	if (this.seatCaption != value) {
		this.seatCaption = value;
		this.updateCaption();
	}
};


Seat.prototype.setSeatNo = function (value) {
	if (this.seatNo != value) {
		this.seatNo = value;
		this.updateCaption();
	}
};

Seat.prototype.setSeatProp = function (value) {
	if (this.seatProp != value) {
		this.seatProp = value;
		if ("" != value) {
			this.seatProp = " - <b>"+value+"</b>";
			this.updateCaption();
		}
	}
};

Seat.prototype.setIdPrice = function (value) {
	if (this.idPrice != value) {
		this.idPrice = value;
	}
};

/**
 * DOKUMENTACIJA MORDA NI TOCNA. TO SO SAMO MOJA PREDVIDEVANJA
 * Branje XML datoteke
 * Preberemo celotno datoteko in postavimo atribute.
 */
Seat.prototype.loadFromXml = function (xmlDoc)
{
	this.addOption = ''; // za dodajanje opcij v formo
	var rememberName = ''; // zapomnimo vsa imena, ki jih locimo z vejicami
	var rememberPrice = ''; // zapomnimo vse cene, ki jih locimo z vejicami (samo EUR).
	var counter = 0;
	this.tpackshowCount = '1';
	this.priceListIndex = 0;
	this.statusIndex = 0;
	this.seatProp = "";

	this.setshowCount(xmlDoc.showCount);
	this.setTpackShowCount(xmlDoc.tpackShowCount);
	tmp = xmlDoc.price;
	tmp = tmp.replace(',', ".");
	this.setPrice(parseFloat(tmp));
	this.setItemString(xmlDoc.itemString);
	this.setDisplayString(xmlDoc.displayString);
	this.setRowCaption(xmlDoc.rowCaption);
	this.setRowNo(xmlDoc.rowNo);
	this.setSeatCaption(xmlDoc.seatCaption);
	this.setSeatNo(xmlDoc.seatNo);
	this.setSeatProp(xmlDoc.seatProp);
	this.idPredstave(xmlDoc.idpredstave);
	this.statusIndex = (xmlDoc.status);
	this.setHolder(xmlDoc.idholder);
	this.setIdPrice(xmlDoc.idPrice);
	this.addPriceForThisSeat(xmlDoc.pricesPerSeat);

	this.setPricePerSeat(); // prikaz polja za cene
};




function SegQty(basketItem, id, idbasketitem, idItemTree, idholder) {
	this.base = Ticket;
	this.base(basketItem);
	this.id = id;
	this.idbasketitem = idbasketitem;
	this.idItemTree = idItemTree;
	this.idholder = idholder;
	this.basketItem.addSegQty(this);
	this.rows = [];
	if (ajaxBasket.mode == 0)
	{
		var idframe = 'flashDvorana_'+ajaxBasket.idtpack;
		if (!ajaxBasket.fastLockTpack) {
			url = SITE_PATH+'tickets/tpack_seats.php5?index=' + ajaxBasket.index+'&idtpack='+ajaxBasket.idtpack;
			var tmp = frames[idframe].location.href = url;
			this.venueWindow = tmp;
		}
	}
};
SegQty.prototype = new Ticket();


SegQty.prototype.remove = function () {
	var i=0;
	var rL = this.rows.length;
	while (i < rL) {
		this.basketItem.uiTickets.deleteRow(this.rows[i].rowIndex);
		++i;
	}
	this.basketItem.removeSegQty(this);
};


SegQty.prototype.updateRows = function () {
	var i=0;
	var rL = this.rows.length;
	while (i < rL) {
		this.rows[i].cells[0].innerHTML = this.displayString + this.seatProp;
		//this.rows[i].cells[1].innerHTML = 'status';

		this.generateForm = '';
		// prikaz polja s cenami
		if (this.addOptionSegQty.length > 1) 
		{
			// zapis forme na spletno stran
			this.rows[i].cells[1].innerHTML = this.addOptionSegQty;
		}
		else
		{
			if (mode == 0) //tpack izpis
			{
				this.priceEUR = formatCurrency(this.price);
				if (this.priceEUR != 'NaN' && this.priceEUR != null && this.priceEUR != '' && this.priceEUR != NaN && this.showCount == '0')
				{
					this.priceEUR = formatCurr(this.price*this.tpackshowCount);
					this.priceEUR = this.priceEUR.replace('.', ',');
					if (CURRENCY_ON_LEFT == 'TRUE') {
						this.middleText = STR_CURRENCY_CODE+'&#160;'+this.priceEUR.replace(',', PRICE_DELIMETER)+'&#160;';
					} else {
						this.middleText = this.priceEUR.replace(',', PRICE_DELIMETER)+'&#160;'+STR_CURRENCY_CODE+'&#160;';
					}
					this.rows[i].cells[1].innerHTML = this.middleText;
				}
				else
				{
					this.rows[i].cells[1].innerHTML = '';
				}
			}
			else
			{
				this.priceEUR = formatCurrency(this.price);	
				this.priceEUR = this.priceEUR.replace('.', ',');
				if (CURRENCY_ON_LEFT == 'TRUE') {
					this.middleText = STR_CURRENCY_CODE+'&#160;'+this.priceEUR.replace(',', PRICE_DELIMETER)+'&#160;';
				} else {
					this.middleText = this.priceEUR.replace(',', PRICE_DELIMETER)+'&#160;'+STR_CURRENCY_CODE+'&#160;';
				}	
				this.rows[i].cells[1].innerHTML = this.middleText;
			}
		}
		
		
		//this.rows[i].cells[2].innerHTML = this.price;
		if (mode == 0)
		{
		//this.rows[i].cells[3].innerHTML = '1231231';
			this.rows[i].cells[2].innerHTML = '<a href="javascript:void(null);" onclick="ajaxBasket.unlockTpackSeat(' + this.basketItem.id + ', ' + this.idbasketitem + ');">X</a>';
		}
		else
		{
			this.rows[i].cells[2].innerHTML = '<a href="javascript:void(null);" onclick="ajaxBasket.removeQty(' + this.basketItem.id + ', ' + this.id + ', -1, '+this.idbasketitem+');">X</a>';
		}
		++i;
	}
};

/**
 * Metoda addPriceForThisSeat, dodaja optione v listo in jih nato metoda setPricePerSeat tudi prikaze
 * addOption se postavi vsakic na novo ob branju XML datoteke (loadFromXML)
 * 
 * @param name - ime oz. tip cene (npr.: otroska)
 * @param price - cena za tip karte (npr.: 8.5)
 */
SegQty.prototype.addPriceForThisSeat = function (priceL) {
	pL = priceL.length;
	
    if (pL > 1) {
		i = 0;
		
		while (i < pL) {
			var b = formatCurrency(priceL[i].pricePerSeat);
			price = b.replace('.', ',');
			name = priceL[i].name.replace(' ', '&#160;');
			this.addOptionSegQty += '<div class="priceList">';
			if (this.statusIndex == priceL[i].idStatus) {
				this.addOptionSegQty += '<input type="radio" name="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'" id="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'_'+i+'" value="'+i+'" checked=\"checked\" onclick="SegQty.prototype.updatePrice(this.value, '+this.idPrice+', '+this.idbasketitem+', '+this.predstava+', '+this.tpackshowCount+');" />';
			} else {
				this.addOptionSegQty += '<input type="radio" name="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'" id="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'_'+i+'" value="'+i+'" onclick="SegQty.prototype.updatePrice(this.value, '+this.idPrice+', '+this.idbasketitem+', '+this.predstava+', '+this.tpackshowCount+');" />';
			}
			if (CURRENCY_ON_LEFT == 'TRUE') {
				this.addOptionSegQty += '<label for="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'_'+i+'">'+name+'&#160;('+STR_CURRENCY_CODE+'&#160;'+price.replace(',', PRICE_DELIMETER)+')</label><br />';
			} else {
				this.addOptionSegQty += '<label for="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'_'+i+'">'+name+'&#160;('+price.replace(',', PRICE_DELIMETER)+'&#160;'+STR_CURRENCY_CODE+')</label><br />';
			}
			this.addOptionSegQty += '</div>';
			++i;
		}
		this.priceListIndex = i;
		this.updateRows();
    }
};

SegQty.prototype.idPredstave = function (value)
{
	this.predstava = value;
};

/*
 * Funckija se klice, ko se izbere druga vrednost za stol
 * 
 * @param str - vrednost v EUR (value v optionu)
 * @param idbasketitem - id_basket_item
 */
SegQty.prototype.updatePrice = function(index, idprice, idbasketitem, item_tree, steviloPredstav) { 
	ajaxBasket.changeStatus(idprice, index, item_tree, idbasketitem);
};

//only for tpack
SegQty.prototype.setItemString = function (value) {
	if (this.itemString != value) {
		this.itemString = value;
		this.updateCaption();
	}
};

/**
 * Id holder, s katerim vemo, kdaj moramo narediti črto med abonmaji
 */ 
SegQty.prototype.setHolder = function (value) {
	this.idholder = value;
};

SegQty.prototype.getHolder = function() {
	return this.idholder;
};

/**
 * Ostevilcene predstave (oz.. nekaksen mali id) (0,1,2...) odvisno koliko jih je
 */
SegQty.prototype.setshowCount = function (value) {
	this.showCount = value;
};

/**
 * stevilo predstav, ki pripadajo enemu abonmaju
 */
SegQty.prototype.setTpackShowCount = function (value) {
	this.tpackshowCount = value;
};

/**
 * Določimo ID predstave
 */
Seat.prototype.idPredstave = function (value)
{
	this.predstava = value;
};


SegQty.prototype.setQty = function (value) {
	if (value < 0) {
		value = 0;
	}
	if (this.qty != value) {
		var r;
		if (typeof(this.qty) == 'undefined') {
			this.qty = 0;
		}
		if (this.qty < value) {
			var idx = (this.rows.length == 0) ? this.basketItem.uiTickets.rows.length : this.rows[this.rows.length - 1].rowIndex + 1;
			var i = this.qty;
			while (i < value) {
				r = this.basketItem.uiTickets.insertRow(idx);
				r.insertCell(0);
				r.cells[0].className = 'td1';
				r.insertCell(1);
				r.cells[1].className = 'td2';
				r.insertCell(2);
				r.cells[2].className = 'td3';
				this.rows.push(r);
				++idx;
				++i;
			}
		} else {
			if (value == 0) {
				// TODO FIX ce dobimo nov element z 0 vstopnicami, se bo najprej kreiral in ob klicu te metode takoj sprostil
				this.remove();
				return;
			}
			i = 0;
			var qL = this.qty - value;
			while (i < qL) {
				this.basketItem.uiTickets.deleteRow(this.rows.pop().rowIndex);
				++i;
			}
		}
		this.qty = value;
		this.updateRows();
	}
};


SegQty.prototype.setPrice = function (value) {
	if (this.price != value) {
		this.price = value;
		this.priceEUR = value;
		this.updateRows();
	}
};


//only for tpack
SegQty.prototype.setItemString = function (value) {
	if (this.itemString != value) {
		this.itemString = value;
		this.updateRows();
	}
};

SegQty.prototype.setIdPrice = function (value) {
	if (this.idPrice != value) {
		this.idPrice = value;
	}
};

SegQty.prototype.setSeatProp = function (value) {
	if (this.seatProp != value) {
		this.seatProp = value;
		if ("" != value) {
			this.seatProp = " - <b>"+value+"</b>";
			this.updateRows();
		}
	}
};

SegQty.prototype.setDisplayString = function (value) {
	if (this.displayString != value) {
		if (mode == 0) {//tpack izpis
			this.displayString = this.itemString + ', ' + value;
		} else {
			this.displayString = value;
		}
		this.updateRows();
	}
};


SegQty.prototype.loadFromXml = function (xmlDoc) {
	this.addOptionSegQty = ''; // za dodajanje opcij v formo
	var rememberName = ''; // zapomnimo vsa imena, ki jih locimo z vejicami
	var rememberPrice = ''; // zapomnimo vse cene, ki jih locimo z vejicami (samo EUR).
	var counter = 0;
	this.priceListIndex = 0;
	this.statusIndex = 0;
	this.tpackshowCount = '1';
	this.seatProp = "";

	this.setshowCount(xmlDoc.showCount);
	this.setTpackShowCount(xmlDoc.tpackShowCount);
	this.setItemString(xmlDoc.itemString);
	tmp = xmlDoc.price;
	tmp = tmp.replace(',', ".");
	this.setPrice(parseFloat(tmp));
	this.setSeatProp(xmlDoc.seatProp);
	this.setDisplayString(xmlDoc.displayString);
	this.setQty(xmlDoc.qty);
	this.idPredstave(xmlDoc.idpredstave);
	this.statusIndex = xmlDoc.status;
	this.setIdPrice(xmlDoc.idPrice);
	this.addPriceForThisSeat(xmlDoc.pricePerSeat);
};





/**
 * Bonus cards
 */
function BC(basketItem, id, idbasketitem, iditembctree)
{
	this.base = Ticket;
	this.base(basketItem);
	this.id = id;
	this.iditembctree = iditembctree; // id storitve
	this.idbasketitem = idbasketitem;
	this.basketItem.addBCQty(this);
	this.rows = [];
	this.isRenewal = false;
};
BC.prototype = new Ticket();

/**
 * Remove bonus card from basket
 */
BC.prototype.remove = function ()
{
	var i = 0;
	var rc = this.rows.length;
	while (i < rc) {
		this.basketItem.uiTickets.deleteRow(this.rows[i].rowIndex);
		++i;
	}
	this.basketItem.removeBCQty(this);
};

/**
 * Display all info about selected bonus card
 */
BC.prototype.updateRows = function ()
{
	if (this.rows.length != 0) // prikazovanje vrstic, če je število vrstic večje od 0 -> to pomeni, da je vsaj en vnos
	{
		this.rows[0].cells[0].innerHTML = this.name; // ime -> kategorija storiteve
		this.rows[0].cells[1].innerHTML = this.priceForm; // prazen prostor

		// prikazovanje cene in statusov za izrano kategorijo
		this.priceEUR = formatCurr(this.price);
		this.priceEUR = this.priceEUR.replace('.', ',');
		if (CURRENCY_ON_LEFT == 'TRUE') {
			this.middleText = STR_CURRENCY_CODE+'&#160;'+this.priceEUR.replace(',', PRICE_DELIMETER);
		} else {
			this.middleText = this.priceEUR.replace(',', PRICE_DELIMETER)+'&#160;'+STR_CURRENCY_CODE;
		}
		this.rows[0].cells[2].innerHTML = this.middleText;
		
		// X za odstranjevanje izbrane storitve -> kategorije iz košarice
		if (this.isRenewal) {
			this.rows[0].cells[3].innerHTML = '<a href="javascript:void(null);" onclick="ajaxBasket.removeBCR('+this.iditembctree+');">X</a>';
		} else {
			this.rows[0].cells[3].innerHTML = '<a href="javascript:void(null);" onclick="ajaxBasket.removeBC('+this.iditembctree+');">X</a>';
		}
	}
};

/**
 * set Qty for bonus cards and set number of rows
 */
BC.prototype.setQty = function (value)
{
	if (value < 0) // če je količina manjša od 0
	{
		value = 0; // jo nastavimo na nič
	}
	if (this.qty != value)
	{	
		var r;
		if (typeof(this.qty) == 'undefined') // če je slučajno količina nedefinirana
		{
			this.qty = 0; // količino nastavimo na 0
		}
		
		if (this.rows.length == 0) // če je število vrstic enako 0
		{
			var idx = (this.rows.length == 0) ? this.basketItem.uiTickets.rows.length : this.rows[this.rows.length - 1].rowIndex + 1; // prešetejemo vrstice >> generiramo stolpce z vrsticamo
			
			r = this.basketItem.uiTickets.insertRow(idx);
			r.insertCell(0);
			r.cells[0].className = 'td1';
			r.insertCell(1);
			r.cells[1].className = 'td4';
			r.insertCell(2);
			r.cells[2].className = 'td2';
			r.insertCell(3);
			r.cells[3].className = 'td3';
			this.rows.push(r);
			++idx;
		}
		this.qty = value; // število -> količina
		this.updateRows(); // posodobimo vrsto z vnosom
	}
};

/**
 * Add status prices for bonus card
 * d - data (json) with prices and names
 * pID - default id_price
 */
BC.prototype.addPrice = function (d, pId)
{
	var i = 0;
	dL = d.length
	var addOption = '';
	while (i < dL) { // preverjamo, ce sta argumenta sploh podana. Name in price morata biti definirana
		
		if (pId ==  d[i].idStatus) {
			addOption += '<option value="'+d[i].price+'" SELECTED>'+d[i].name+'</option>'; // zato ima ta option selected
		} else {
			addOption += '<option value="'+d[i].price+'">'+d[i].name+'</option>'; // vsi, ki niso privzeti, nimajo statusa SELECTED
		}
		++i;
	}
	
	var generateForm = '';
	if (dL > 1) {
		// kreiranje SELECT forme
		
		generateForm += '<select id="selectBox_'+this.id+'" onchange="ajaxBasket.changeBCStatus(this.value, '+this.iditembctree+','+this.idbasketitem+');">';
		generateForm += addOption;
		generateForm += '</select>'; // end form
	}
	this.priceForm = generateForm;
	this.updateRows(); // posodobimo vrsto z vnosom
};

/**
 * Set default price
 */
BC.prototype.setPrice = function (value)
{
	if (this.price != value)
	{
		this.price = value; // cena za eno storitev
		this.updateRows(); // posodobimo vrsto z vnosom
	}
};

/**
 * Set name
 */
BC.prototype.setName = function (value)
{
	if (this.name != value)
	{
		this.name = value; // ime izbrane kategorije >> status vstopnice
		this.updateRows(); // posodobimo vrsto z vnosom
	}
};

/**
 * Load from JSON
 */
BC.prototype.loadData = function (data)
{
	if (data.type2 !== undefined) {
		this.isRenewal = true;
	}
	tmp = data.price;
	tmp = tmp.replace(',', ".");
	this.setPrice(parseFloat(tmp));
	this.setQty(data.qty);
	this.setName(data.name);
	this.addPrice(data.pricesPerSeat, data.status);
};



/**
 * Debit cards
 */
function DC(basketItem, id, idbasketitem, iditembctree)
{
	this.base = Ticket;
	this.base(basketItem);
	this.id = id;
	this.iditembctree = iditembctree; // id storitve
	this.idbasketitem = idbasketitem;
	this.basketItem.addDCQty(this);
	this.rows = [];
	this.isRenewal = false;
	
	this.uiRow = this.basketItem.uiTickets.insertRow(this.basketItem.uiTickets.rows.length);

	// uiTickets.insertRow
	this.uiRow.insertCell(0);
	this.uiRow.cells[0].className = 'td1';
	
	this.uiRow.insertCell(1);
	this.uiRow.cells[1].className = 'td4';
	
	this.uiRow.insertCell(2);
	this.uiRow.cells[2].className = 'td2';
	
	this.uiRow.insertCell(3);
	this.uiRow.cells[3].className = 'td3';
};
DC.prototype = new Ticket();

/**
 * Remove debit card from basket
 */
DC.prototype.remove = function ()
{
	this.basketItem.uiTickets.deleteRow(this.uiRow.rowIndex);
	this.basketItem.removeDCQty(this);
};


/**
 * Display all info about selected bonus card
 */
DC.prototype.updateRows = function ()
{
	if (this.uiRow.length != 0) // prikazovanje vrstic, če je število vrstic večje od 0 -> to pomeni, da je vsaj en vnos
	{
		this.uiRow.cells[0].innerHTML = this.name; // ime -> kategorija storiteve
		
		if (this.dctype == 'T') {
			this.uiRow.cells[1].innerHTML = STR_DC_TYPE+' '+STR_DC_TYPE_TICKETS; // tickets
		} else {
			this.uiRow.cells[1].innerHTML = STR_DC_TYPE+' '+STR_DC_TYPE_MONEY; // money
		}

		// prikazovanje cene in statusov za izrano kategorijo
		this.priceEUR = formatCurr(this.price);
		this.priceEUR = this.priceEUR.replace('.', ',');
		if (CURRENCY_ON_LEFT == 'TRUE') {
			this.middleText = STR_CURRENCY_CODE+'&#160;'+this.priceEUR.replace(',', PRICE_DELIMETER);
		} else {
			this.middleText = this.priceEUR.replace(',', PRICE_DELIMETER)+'&#160;'+STR_CURRENCY_CODE;
		}
		this.uiRow.cells[2].innerHTML = this.middleText;
		
		// X za odstranjevanje izbrane storitve -> kategorije iz košarice
		if (this.isRenewal) {
			this.uiRow.cells[3].innerHTML = '<a href="javascript:void(null);" onclick="ajaxBasket.removeDCR('+this.iditembctree+', '+this.idbasketitem+');">X</a>';
		} else {
			this.uiRow.cells[3].innerHTML = '<a href="javascript:void(null);" onclick="ajaxBasket.removeDC('+this.iditembctree+', '+this.idbasketitem+');">X</a>';
		}
	}
};

/**
 * Set default price
 */
DC.prototype.setPrice = function (value)
{
	if (this.price != value)
	{
		this.price = value; // cena za eno storitev
		this.updateRows(); // posodobimo vrsto z vnosom
	}
};

/**
 * Set name
 */
DC.prototype.setName = function (value)
{
	if (this.name != value)
	{
		this.name = value; // ime izbrane kategorije >> status vstopnice
		this.updateRows(); // posodobimo vrsto z vnosom
	}
};

/**
 * Set Debit card type
 */
DC.prototype.setDCtype = function (value)
{
	if (this.dctype != value)
	{
		this.dctype = value; // ime izbrane kategorije >> status vstopnice
		this.updateRows(); // posodobimo vrsto z vnosom
	}
};

/**
 * Load from JSON
 */
DC.prototype.loadData = function (data)
{
	if (data.renew !== undefined) {
		this.isRenewal = true;
	}
	tmp = data.price;
	tmp = tmp.replace(',', ".");
	this.setPrice(parseFloat(tmp));
	this.setName(data.name);
	this.setDCtype(data.dctype);
};


/**
 * Konstruktor za Pakete
 */
function Pack(basketItem, id, idbasketitem, iditempacktree)
{
	this.base = Ticket;
	this.base(basketItem);
	this.id = id;
	this.iditempacktree = iditempacktree; // id storitve
	this.idbasketitem = idbasketitem;
	this.basketItem.addPackQty(this);
	
	// uiTickets.insertRow
	this.uiRow = this.basketItem.uiTickets.insertRow(this.basketItem.uiTickets.rows.length);
	this.uiRow.insertCell(0);
	this.uiRow.cells[0].className = 'td1';

	this.uiRow.insertCell(1);
	this.uiRow.cells[1].className = 'td2';

	this.uiRow.insertCell(2);
	this.uiRow.cells[2].className = 'td3';
	this.uiRow.cells[2].innerHTML = '<a href="javascript:void(null);" onclick="ajaxBasket.removePack(' + this.iditempacktree + ', '+this.idbasketitem+');">X</a>';

};
Pack.prototype = new Ticket();

Pack.prototype.remove = function () {
	this.basketItem.uiTickets.deleteRow(this.uiRow.rowIndex);
	this.basketItem.removePackQty(this);
};

Pack.prototype.setPrice = function (value, idP, priceL) {
	if (this.isGratis != "") {
		this.uiRow.cells[1].innerHTML = STR_SVC_GRATIS;
	} else if (priceL.length > 1) {
		pL = priceL.length;
		i = 0;
		while (i < pL) {
			var b = formatCurrency(priceL[i].price);
			price = b.replace('.', ',');
			name = priceL[i].name.replace(' ', '&#160;');
			this.addOption += '<div class="priceList">';
			if (idP == priceL[i].idprice) {
				this.addOption += '<input type="radio" name="selectBox_'+this.iditempacktree+'_'+this.idbasketitem+'" id="selectBox_'+this.iditempacktree+'_'+this.idbasketitem+'_'+i+'" value="'+i+'" checked=\"checked\" onclick="ajaxBasket.changeStatusPACK('+priceL[i].idprice+', '+this.idbasketitem+', '+this.iditempacktree+');" />';
			} else {
				this.addOption += '<input type="radio" name="selectBox_'+this.iditempacktree+'_'+this.idbasketitem+'" id="selectBox_'+this.iditempacktree+'_'+this.idbasketitem+'_'+i+'" value="'+i+'" onclick="ajaxBasket.changeStatusPACK('+priceL[i].idprice+', '+this.idbasketitem+', '+this.iditempacktree+');" />';
			}
			if (CURRENCY_ON_LEFT == 'TRUE') {
				this.addOption += '<label for="selectBox_'+this.iditempacktree+'_'+this.idbasketitem+'_'+i+'">'+name+'&#160;('+STR_CURRENCY_CODE+'&#160;'+price.replace(',', PRICE_DELIMETER)+')</label><br />';
			} else {
				this.addOption += '<label for="selectBox_'+this.iditempacktree+'_'+this.idbasketitem+'_'+i+'">'+name+'&#160;('+price.replace(',', PRICE_DELIMETER)+'&#160;'+STR_CURRENCY_CODE+')</label><br />';
			}
			this.addOption += '</div>';
			++i;
		}
		this.uiRow.cells[1].innerHTML = this.addOption;
	} else {
		this.price = value; // cena za eno storitev
		// prikazovanje cene in statusov za izrano kategorijo
		this.priceEUR = formatCurr(this.price);
		this.priceEUR = this.priceEUR.replace('.', ',');
		if (CURRENCY_ON_LEFT == 'TRUE') {
			this.middleText = STR_CURRENCY_CODE+'&#160;'+this.priceEUR.replace(',', PRICE_DELIMETER);
		} else {
			this.middleText = this.priceEUR.replace(',', PRICE_DELIMETER)+'&#160;'+STR_CURRENCY_CODE;
		}
		this.uiRow.cells[1].innerHTML = this.middleText;
	}
};

Pack.prototype.setTotalPrice = function (value) {
	if (this.totalPrice != value) {
		this.totalPrice = value; // cena skupaj
	}
};

Pack.prototype.setName = function (value) {
	if (this.name != value) {
		this.name = value; // ime izbrane kategorije >> status vstopnice
		str = this.name
		pL = this.pItems.length;
		i = 0;
		while (i < pL) {
			str += '<br /><span class="pItems">'+this.pItems[i].QTY+'x '+this.pItems[i].NAME+'</span>';
			++i;
		}
		this.uiRow.cells[0].innerHTML = str;
	}
};

Pack.prototype.setGratis = function (value) {
	if (this.isGratis != value) {
		this.isGratis = value;
	}
};

Pack.prototype.setPItems = function (items) {
	if (this.pItems != items) {
		this.pItems = items;
	}
};

Pack.prototype.loadData = function (xmlDoc, priceL) {
	this.addOption = ''; // za dodajanje opcij v formo
	this.setGratis(xmlDoc.gratis);
	tmp = xmlDoc.TotalPrice;
	tmp = tmp.replace(',', ".");
	this.setTotalPrice(parseFloat(tmp));
	tmp = xmlDoc.price;
	tmp = tmp.replace(',', ".");
	this.setPrice(parseFloat(tmp), xmlDoc.idPrice, priceL);
	this.setPItems(xmlDoc.pItems);
	this.setName(xmlDoc.name);
};


/**
 * Konstruktor za Ticket package
 */
function TPack(basketItem, id, idbasketitem, iditempacktree)
{
	this.base = Ticket;
	this.base(basketItem);
	this.id = id;
	this.iditempacktree = iditempacktree; // id storitve
	this.idbasketitem = idbasketitem;
	this.basketItem.addTPackQty(this);

	// uiTickets.insertRow
	this.uiRow = this.basketItem.uiTickets.insertRow(this.basketItem.uiTickets.rows.length);
	this.uiRow.insertCell(0);
	this.uiRow.cells[0].className = 'td1';

	this.uiRow.insertCell(1);
	this.uiRow.cells[1].className = 'td2';

	this.uiRow.insertCell(2);
	this.uiRow.cells[2].className = 'td3';
	this.uiRow.cells[2].innerHTML = '<a href="javascript:void(null);" onclick="ajaxBasket.unlockTpackSeat(' + this.basketItem.id + ', ' + this.idbasketitem + ');">X</a>';

};
TPack.prototype = new Ticket();

TPack.prototype.remove = function () {
	this.basketItem.uiTickets.deleteRow(this.uiRow.rowIndex);
	pL = this.pItems.length;
	i = 0;
	while (i < pL) {
		if (this.pItems[i].id) {
			this.updateTpackFlash(0, this.pItems[i].id, this.pItems[i].idI);
		}
		++i;
	}
	this.basketItem.removeTPackQty(this);
};

TPack.prototype.addPriceForThisSeat = function (priceL) {
	
	pL = priceL.length;
	if (pL > 1) // preverjamo, ce sta argumenta sploh podana. Name in price morata biti definirana
	{
		i = 0;
		while (i < pL) {
			var b = formatCurrency(priceL[i].pricePerSeat);
			price = b.replace('.', ',');
			name = priceL[i].name.replace(' ', '&#160;');
			this.addOption += '<div class="priceList">';
			if (this.statusIndex == priceL[i].idStatus) {
				this.addOption += '<input type="radio" name="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'" id="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'_'+i+'" value="'+i+'" checked=\"checked\" onclick="TPack.prototype.updatePrice(this.value, '+this.idPrice+', '+this.idbasketitem+', '+this.predstava+', '+this.tpackshowCount+');" />';
			} else {
				this.addOption += '<input type="radio" name="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'" id="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'_'+i+'" value="'+i+'" onclick="TPack.prototype.updatePrice(this.value, '+this.idPrice+', '+this.idbasketitem+', '+this.predstava+', '+this.tpackshowCount+');" />';
			}
			if (CURRENCY_ON_LEFT == 'TRUE') {
				this.addOption += '<label for="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'_'+i+'">'+name+'&#160;('+STR_CURRENCY_CODE+'&#160;'+price.replace(',', PRICE_DELIMETER)+')</label><br />';
			} else {
				this.addOption += '<label for="selectBox_'+this.id+'_'+this.predstava+'_'+this.idbasketitem+'_'+i+'">'+name+'&#160;('+price.replace(',', PRICE_DELIMETER)+'&#160;'+STR_CURRENCY_CODE+')</label><br />';
			}
			this.addOption += '</div>';
			++i;
		}
		this.priceListIndex = i;
		
	}
};

TPack.prototype.updatePrice = function(index, idprice, idbasketitem, item_tree, steviloPredstav) {
	ajaxBasket.changeStatus(idprice, index, item_tree, idbasketitem);
};

TPack.prototype.setPricePerSeat = function() {
	this.generateForm = '';
	if (this.priceListIndex > 1){
		this.generateForm += this.addOption;
		this.uiRow.cells[1].innerHTML = this.generateForm;
	}
};

TPack.prototype.setPrice = function (value, idP, priceL) {
	this.price = value; // cena za eno storitev
	// prikazovanje cene in statusov za izrano kategorijo
	if (CURRENCY_ON_LEFT == 'TRUE') {
		this.middleText = STR_CURRENCY_CODE+'&#160;'+this.price;
	} else {
		this.middleText = this.price+'&#160;'+STR_CURRENCY_CODE;
	}
	this.uiRow.cells[1].innerHTML = this.middleText;
};

TPack.prototype.setTotalPrice = function (value) {
	if (this.totalPrice != value) {
		this.totalPrice = value; // cena skupaj
	}
};

TPack.prototype.setName = function (value) {
	if (this.name != value) {
		this.name = value; // ime izbrane kategorije >> status vstopnice
		str = this.name
		pL = this.pItems.length;
		i = 0;
		while (i < pL) {
			if (this.pItems[i].id) {
				this.updateFlash(1, this.pItems[i].id, this.pItems[i].idI);
			}
			str += '<br /><span class="pItems">'+this.pItems[i].name+'</span>';
			++i;
		}
		this.uiRow.cells[0].innerHTML = str;
	}
};

TPack.prototype.setGratis = function (value) {
	if (this.isGratis != value) {
		this.isGratis = value;
	}
};

TPack.prototype.setTPItems = function (items) {
	if (this.pItems != items) {
		this.pItems = items;
	}
};

TPack.prototype.idPredstave = function (value) {
	this.predstava = value;
};

TPack.prototype.setHolder = function (value) {
	this.idholder = value;
};

TPack.prototype.getHolder = function() {
	return this.idholder;
};

TPack.prototype.setshowCount = function (value) {
	this.showCount = value;
};

TPack.prototype.setTpackShowCount = function (value) {
	this.tpackshowCount = value;
};

TPack.prototype.setIdPrice = function (value) {
	if (this.idPrice != value) {
		this.idPrice = value;
	}
};

TPack.prototype.loadData = function (xmlDoc) {
	this.addOption = ''; // za dodajanje opcij v formo
	var rememberName = ''; // zapomnimo vsa imena, ki jih locimo z vejicami
	var rememberPrice = ''; // zapomnimo vse cene, ki jih locimo z vejicami (samo EUR).
	var counter = 0;
	this.tpackshowCount = '1';
	this.priceListIndex = 0;
	this.statusIndex = 0;
	this.seatProp = "";
	this.setPrice(xmlDoc.price);
	this.setshowCount(xmlDoc.showCount);
	this.setTpackShowCount(xmlDoc.tpackShowCount);
	this.setIdPrice(xmlDoc.idPrice);
	this.statusIndex = (xmlDoc.status);
	this.idPredstave(xmlDoc.idpredstave);
	this.setHolder(xmlDoc.idholder);
	this.setTPItems(xmlDoc.pItems);
	this.addPriceForThisSeat(xmlDoc.pricesPerSeat);
	this.setName(xmlDoc.itemString);
	this.setPricePerSeat(); // prikaz polja za cene
};

