/** 
 * SVN FILE: $Id: ajax_basket_items.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) $
 */
/**
* objekt skrbi za risanje predstav v košarici
*/
function BasketItem(basket, id, mode) {
	this.basket = basket;
	this.id = id;
	this.mode = mode;
	this.basket.addItem(this);
	this.seatsCount = 0;
	this.seatsById = {};
	this.segqtysCount = 0;
	this.segqtysById = {};
	this.svcCount = 0;
	this.segsvcsById = {};
	this.artCount = 0;
	this.segartsById = {};
	this.lockCache = {};
	this.bcCount = 0;
	this.segBCById = {};
	this.dcCount = 0;
	this.segDCById = {};
	this.packCount = 0;
	this.segPackById = {};
	this.tpackCount = 0;
	this.segTPackById = {};
	
	// izriši ogrodje (podatki se rišejo ob nastavljanju propertijev)
	
	/**
	 * List of ID's
	 * i - Item
	 * t - Item name
	 * pe - personalization info
	 * segmentsList_ - div with list of segments (drop down)
	 * uiSeatSelect_ - div with list of segments, prices (best seat and services)
	 * divDvorana_ - contains venue
	 * flashDvorana_ - venue
	 * si - list of selected items (tickets), title
	 * tb - tickets box, list of selected items (price, name, remove....)
	 * ibi - id basket item (each item with ID)
	 * promotT - title box
	 * promoE - promotion code entry box
	 * tdT - ticket delivery title
	 * tdS - ticket delivery select box
	 * dP - delivery by mail
	 * dPH - delivery print@home
	 * dV - delivery voucher
	 */
	

	var tempEl;
	
	// create header for each item
	$("#container").append('<div id="i'+this.id+'" class="Blagajna basketitem"></div>');
	$("#i"+this.id).append('<div id="t'+this.id+'" class="wrapper headWrap"></div>');
	$("#t"+this.id).append('<img id="pe'+this.id+'" /><h3 id="c1'+this.id+'"></h3><h4 id="c2'+this.id+'"></h4>');
	
	// image for personalization
	$('#pe'+this.id).attr({ 
		src: SITE_PATH+'design/img/getInfo.png',
		title: STR_PERSONALIZATION,
		alt: STR_PERSONALIZATION_ALT,
		width: 29,
		height: 29
	});
	
	// drop down with segment selection
	$("#i"+this.id).append('<h5 id="segmentsList_'+this.id+'" class="wrapper"></h5>');
	$("#segmentsList_"+this.id).css('display', 'none');
	
	// div for services
	$("#i"+this.id).append('<div id="uiSeatSelect_'+this.id+'" class="wrapper"></div>');
	$("#uiSeatSelect_"+this.id).css('display', 'none');
	
	//  venue
	var vWidth = ($("#i"+this.id).width() > 1000 ? 1000 : $("#i"+this.id).width())
	var vHeight = vWidth * (500/750);
	$("#i"+this.id).append('<div id="divDvorana_'+this.id+'"></div>');
	if (1 == this.mode) {
		$("#divDvorana_"+this.id).css('display', 'none').css('text-align', 'center')
			.append('<iframe id="flashDvorana_'+this.id+'" name="flashDvorana_'+this.id+'" src="about:blank" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" width="'+vWidth+'" height="'+vHeight+'" style="overflow:visible;"></iframe>');
	} else {
		$("#divDvorana_"+this.id).css('display', 'none').css('text-align', 'center')
			.append('<iframe id="flashDvorana_'+this.id+'" name="flashDvorana_'+this.id+'" src="about:blank" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" width="'+vWidth+'" height="0" style="overflow:visible;"></iframe>');
	}
	
	// si - selected items text
	$("#i"+this.id).append('<h5 id="si'+this.id+'" class="wrapper"></h5>');
	
	// tb - tickets box
	$("#i"+this.id).append('<div class="wrapper" id="tb'+this.id+'"></div>');
	this.uiTickets = document.createElement('table');
	this.uiTickets.className = 'basketitemTB';
	this.uiTickets.insertRow(0);
	this.uiTickets.rows[0].insertCell(0);
	this.uiTickets.rows[0].cells[0].colSpan = '3';
	this.uiTickets.rows[0].cells[0].innerHTML = '';
	$(this.uiTickets).appendTo("#tb"+this.id);
	
	// promotions
	$("#i"+this.id).append('<h5 id="promoT'+this.id+'" class="wrapper">'+STR_PROMOC_CODE+':'+'</h5>')
		.append('<div id="promoE'+this.id+'" class="wrapper"></div>')

	// ticket delivery
		.append('<h5 id="tdT'+this.id+'" class="wrapper">'+STR_CHOOSE_DELIVERY+'</h5>')
		.append('<div id="tdS'+this.id+'" class="wrapper" style="line-height:18px"></div>');
	
	$("#tdS"+this.id).append('<div id="dV'+this.id+'"></div>')
		.append('<div id="dP'+this.id+'"></div>')
		.append('<div id="dPT'+this.id+'"></div>')
		.append('<div id="dND'+this.id+'"></div>')
		.append('<div id="dPH'+this.id+'"></div>')
		.append('<br style="clear:both" />');
	
	$("#dV"+this.id).append('<input name="delivery' + this.id + '" id="delivery' + this.id + '_4" type="radio" value="4" onclick="ajaxBasket.basket.itemsById[\'i' + this.id + '\'].setDeliveryType(this.value, true);"><label for="delivery' + this.id + '_4" title="'+STR_TIP_VOUCHER+'">' + STR_VOUCHER + '</label>').addClass('deliveryType');
	$("#dP"+this.id).append('<input name="delivery' + this.id + '" id="delivery' + this.id + '_1" type="radio" value="1" onclick="ajaxBasket.basket.itemsById[\'i' + this.id + '\'].setDeliveryType(this.value, true);"><label for="delivery' + this.id + '_1" title="'+STR_TIP_MAIL+'">' + STR_MAIL + '</label><br>').addClass('deliveryType');
	$("#dPT"+this.id).append('<input name="delivery' + this.id + '" id="delivery' + this.id + '_16" type="radio" value="16" onclick="ajaxBasket.basket.setCashOnDelivery(this.value, true);"><label for="delivery' + this.id + '_16" title="'+STR_TIP_CASH_ON_DELIVER+'">' + STR_CASH_ON_DELIVERY + '</label>').addClass('deliveryType');
	$("#dPH"+this.id).append('<input name="delivery' + this.id + '" id="delivery' + this.id + '_2" type="radio" value="2" onclick="ajaxBasket.basket.itemsById[\'i' + this.id + '\'].setDeliveryType(this.value, true);"><label for="delivery' + this.id + '_2" title="'+STR_TIP_HOME+'">' + STR_PRINT + '</label><br>').addClass('deliveryType');
	$("#dND"+this.id).append(STR_NO_DELIVERY).hide();
	
	// tole ni čisto nujno - malo počasneje in malo bolj 'varno'
	this.setCaption1('');
	this.setCaption2('');
	this.setPersonalize(false);
	this.setAllowedSeatSelect(0);
	this.setDeliveryType(0, false);
	this.setAllowedDeliveryTypes(0);
};


BasketItem.prototype.remove = function () {
	$("#i"+this.id).remove();
	this.basket.removeItem(this);
};


BasketItem.prototype.addLockedSeat = function (ticket) {
	this.lockCache['i' + ticket.id] = ticket;
};


BasketItem.prototype.removeLockedSeat = function (ticket) {
	// klicano iz LockedSeat, ko ga vzamemo iz košarice
	delete this.seatsById['i' + ticket.id];
	delete ticket;
	/*this.seatsCount--;
	if (this.seatsCount + this.segqtysCount == 0) {
		this.uiTickets.rows[0].className = '';
	}*/
};


BasketItem.prototype.addSeat = function (ticket) {
	// klicano iz Seat, ko dodamo v košarico
	this.seatsById['i' + ticket.id + ticket.idItemTree] = ticket;
	++this.seatsCount;
	if (this.seatsCount + this.segqtysCount == 1)
	{
		this.uiTickets.rows[0].className = 'hidden';
	}
};


BasketItem.prototype.removeSeat = function (ticket) {
	// klicano iz Seat, ko ga vzamemo iz košarice
	delete this.seatsById['i' + ticket.id + ticket.idItemTree];
	delete ticket;
	this.seatsCount--;
	
	if (this.seatsCount + this.segqtysCount == 0)
	{
		this.uiTickets.rows[0].className = '';
	}
};


BasketItem.prototype.addSegQty = function (ticket) {
	// klicano iz SegQty, ko dodamo novo kvoto
	this.segqtysById['i' + ticket.idbasketitem + ticket.idItemTree + ticket.idholder] = ticket;
	++this.segqtysCount;
	if (this.seatsCount + this.segqtysCount == 1) {
		this.uiTickets.rows[0].className = 'hidden';
	}
};


BasketItem.prototype.removeSegQty = function (ticket) {
	// klicano iz SegQty, ko nastavimo qty na 0
	delete this.segqtysById['i' + ticket.idbasketitem + ticket.idItemTree + ticket.idholder];
	delete ticket;
	this.segqtysCount--;
	if (this.seatsCount + this.segqtysCount == 0) {
		this.uiTickets.rows[0].className = '';
	}
};

BasketItem.prototype.addSvcQty = function (ticket) {
	// klicano iz SegQty, ko dodamo novo kvoto
	this.segsvcsById['i' + ticket.idbasketitem] = ticket;
	++this.svcCount;
	if (this.svcCount == 1) {
		this.uiTickets.rows[0].className = 'hidden';
	}
};


BasketItem.prototype.removeSvcQty = function (ticket) {
	// klicano iz SegQty, ko nastavimo qty na 0
	delete this.segsvcsById['i' + ticket.idbasketitem];
	delete ticket;
	this.svcCount--;
	if (this.svcCount == 0) {
		this.uiTickets.rows[0].className = '';
	}
};


BasketItem.prototype.addArtQty = function (ticket) {
	// klicano iz SegQty, ko dodamo novo kvoto
	this.segartsById['i' + ticket.idbasketitem] = ticket;
	++this.artCount;
	if (this.artCount == 1) {
		this.uiTickets.rows[0].className = 'hidden';
	}
};
BasketItem.prototype.removeArtQty = function (ticket) {
	// klicano iz SegQty, ko nastavimo qty na 0
	delete this.segartsById['i' + ticket.idbasketitem];
	delete ticket;
	this.artCount--;
	if (this.artCount == 0) {
		this.uiTickets.rows[0].className = '';
	}
};

BasketItem.prototype.addBCQty = function (ticket) {
	// klicano iz SegQty, ko dodamo novo kvoto
	this.segBCById['i' + this.id] = ticket;
	++this.bcCount;
	if (this.bcCount == 1) {
		this.uiTickets.rows[0].className = 'hidden';
	}
};


BasketItem.prototype.removeBCQty = function (ticket) {
	// klicano iz SegQty, ko nastavimo qty na 0
	delete this.segBCById['i' + this.id];
	delete ticket;
	this.bcCount--;
	if (this.bcCount == 0) {
		this.uiTickets.rows[0].className = '';
	}
};

BasketItem.prototype.addDCQty = function (ticket) {
	// klicano iz SegQty, ko dodamo novo kvoto
	this.segDCById['i' + ticket.idbasketitem] = ticket;
	++this.dcCount;
	if (this.dcCount == 1) {
		this.uiTickets.rows[0].className = 'hidden';
	}
};


BasketItem.prototype.removeDCQty = function (ticket) {
	// klicano iz SegQty, ko nastavimo qty na 0
	delete this.segDCById['i' + ticket.idbasketitem];
	delete ticket;
	this.dcCount--;
	if (this.dcCount == 0) {
		this.uiTickets.rows[0].className = '';
	}
};

BasketItem.prototype.addPackQty = function (ticket) {
	// klicano iz SegQty, ko dodamo novo kvoto
	this.segPackById['i' + ticket.idbasketitem] = ticket;
	++this.packCount;
	if (this.packCount == 1) {
		this.uiTickets.rows[0].className = 'hidden';
	}
};


BasketItem.prototype.removePackQty = function (ticket) {
	// klicano iz SegQty, ko nastavimo qty na 0
	delete this.segPackById['i' + ticket.idbasketitem];
	delete ticket;
	this.packCount--;
	if (this.packCount == 0) {
		this.uiTickets.rows[0].className = '';
	}
};

BasketItem.prototype.addTPackQty = function (ticket) {
	// klicano iz Tpack, ko dodamo novo kvoto
	this.segTPackById['i' + ticket.idbasketitem] = ticket;
	++this.tpackCount;
	if (this.tpackCount == 1) {
		this.uiTickets.rows[0].className = 'hidden';
	}
};


BasketItem.prototype.removeTPackQty = function (ticket) {
	// klicano iz Tpack, ko nastavimo qty na 0
	delete this.segTPackById['i' + ticket.idbasketitem];
	delete ticket;
	this.tpackCount--;
	if (this.tpackCount == 0) {
		this.uiTickets.rows[0].className = '';
	}
};


BasketItem.prototype.setCaption1 = function (value) {
	if (this.caption1 != value) {
		this.caption1 = value;
		$("#c1"+this.id).html('<a name="'+this.id+'" id="'+this.id+'" title="'+this.caption1+'">'+this.caption1.replace(/&amp;/i, "&")+'</a>');
	}
};


/**
 * Metoda za izpis (dolocanje) kdaj se predstava nahaja
 * npr: 25.10.2007 ob 12:05, Ice Venue
 */
BasketItem.prototype.setCaption2 = function (value)
{
	if (this.caption2 != value)
	{
		this.caption2 = value;
		$("#c2"+this.id).html(this.caption2);
	}
};


BasketItem.prototype.setPersonalize = function (value) {
	if (this.personalize != value) {
		this.personalize = value;
		$('#pe'+this.id).addClass((value ? 'personalize' : 'hidden'));
	}
};

BasketItem.prototype.setMode = function (value) {
	if (this.mode != value) {
		this.mode = value;
		this.uiMode.className = (value ? 'mode' : 'hidden');
	}
};

BasketItem.prototype.allowPromotionCode = function(value) {
	if (parseInt(value, 10) == 1) {
		$('#promoE'+this.id).html('&#160;<input type="text" size="10" maxlength="32" name="promoCode'+this.id+'" id="promoCode'+this.id+'">&#160;<input type="button" name="bu" value="'+STR_ENTER_PROMO_CODE+'" onclick="ajaxBasket.checkPromotionCode(\''+this.id+'\', document.getElementById(\'promoCode'+this.id+'\').value)"><span id="promoI'+this.id+'"></span>');
	} else {
		$('#promoT'+this.id).remove();
		$('#promoE'+this.id).remove();
	}
};

BasketItem.prototype.getPromotionCode = function (value) {
	switch (parseInt(value, 10)) {
		case 0: // ni vnosa
			;
			break;
		case 1: // je napaka
			$('#promoI'+this.id).html('&#160;&#160;<span color="#FF0000">'+STR_PROMOC_CODE_ERROR+'</span>');
			break;
		case 2: // ni napake
			$('#promoE'+this.id).html(STR_PROMOC_CODE_ACCEPTED);
			break;
	}
};

BasketItem.prototype.setAllowedSeatSelect = function (value)
{
	if (this.allowedSeatSelect != value)
	{
		this.allowedSeatSelect = value;
		switch (this.allowedSeatSelect)
		{
			case 1:
				$("#uiSeatSelect_"+this.id).remove();
				this.uiTickets.rows[0].cells[0].innerHTML = STR_NO_SEATS;
				$("#si"+this.id).html(STR_SEATS_CHOSEN);
				
				ajaxBasket.basket.dvorane.push(this.id);
				url = '';
				// venue
				if(this.mode == 0) {
					 link_text = STR_ABONMA_CONFIG;
					 url = SITE_PATH+'tickets/tpack_config.php5?idtpack='+this.id+'&idseg=1'; // TODO ime datoteke iz konstant

					this.listOfSegments += '<option value="'+url+'">'+link_text+'</option>';
					$("#segmentsList_"+this.id).append('<table width="100%" border="0"><tr><td align="left" style="margin-top:5px;margin-bottom:3px;">'+STR_ABONMA_ADD_ABONMA +'&#160;<select id="select_box_'+this.id+'" ONCHANGE="switchFlash(\''+this.id+'\', \'\'); ajaxBasket.basket.openVenue(\''+this.id+'\', \''+this.mode+'\', this.value);">'+this.listOfSegments+'</select></td><td style="text-align:right"><a onclick="javascript:closeAllDivs()" style="cursor:pointer">'+STR_CLOSE_ALL_DIVS+'</a></td></tr></table>')
									.css('display', 'block');
				} else {
					$("#segmentsList_"+this.id).append('<table width="100%" border="0"><tr><td align="left" style="margin-top:5px;margin-bottom:3px;">'+STR_CHOOSE_SEGMENT_LIST+'&#160;<select id="select_box_'+this.id+'" ONCHANGE="switchFlash(\''+this.id+'\', \'\'); ajaxBasket.basket.openVenue(\''+this.id+'\', \''+this.mode+'\', this.value);">'+this.listOfSegments+'</select></td><td style="text-align:right"><a onclick="javascript:closeAllDivs()" style="cursor:pointer">'+STR_CLOSE_ALL_DIVS+'</a></td></tr></table>')
									.css('display', 'block');
				}
				
				if (this.id == ajaxBasket.idFastBuy) {
					switchFlash(this.id, '');
					$("#select_box_"+this.id).attr('selectedIndex', 1);
					ajaxBasket.basket.openVenue(this.id, this.mode, $("#select_box_"+this.id+" :selected").val());
				}
				
				break;
			case 2:
				this.uiTickets.rows[0].cells[0].innerHTML = STR_NO_SEATS;
				$("#si"+this.id).html(STR_SEATS_CHOSEN);
				
				// fastLock -> kjer samo vpišemo številko koliko sedežev bi radi (nekakšen best seat)
				$("#uiSeatSelect_"+this.id).html(STR_ENTER_SEAT_COUNT + ' <input type="text" size="2" maxlength="2" id="fl' + this.id + '"> <input type="button" value="'+STR_BUTTON_SELECT+'" id="pageDemo1" onclick="ajaxBasket.fastLock(' + this.id + ', document.getElementById(\'fl' + this.id + '\').value)">');
				$("#uiSeatSelect_"+this.id).css('display', 'block');
				goToFastbuy(this.id);
				break;
			case 3:
				this.uiTickets.rows[0].cells[0].innerHTML = STR_NO_SEATS;
				$("#si"+this.id).html(STR_SEATS_CHOSEN);
				
				var htmlKoda = '';
				htmlKoda += BEST_SEAT_SEGMENT;
				htmlKoda += '&#160;&#160;<select id="SEL_'+this.id+'">';
				
				htmlKoda += this.addOption;
				htmlKoda += '</select><br>';
				
				htmlKoda += BEST_SEAT_CATEGORY;
				htmlKoda += '<select id="SEL2_'+this.id+'">';
				htmlKoda += this.getCategory(this.segments[0].idseg);
				htmlKoda += '</select><br />';
				
				htmlKoda+= STR_ENTER_FAST_BUY_COUNT + ' <input type="text" size="2" maxlength="2" id="fl' + this.id + '">';
				htmlKoda+= '<input type="button" value="'+STR_BUTTON_SELECT+'" id="pageDemo1" onclick="ajaxBasket.bestSeat(' + this.id + ', document.getElementById(\'SEL_' + this.id + '\').value, document.getElementById(\'fl' + this.id + '\').value, document.getElementById(\'SEL2_' + this.id + '\').value);"><br />';
				//htmlKoda+= '</form>';
				//this.uiSeatSelect.appendChild(myform);
				$("#uiSeatSelect_"+this.id).html(htmlKoda).show();
				$("#segmentsList_"+this.id).remove();
				
				
				$('#SEL_'+this.id).change(function() {
					var c = ajaxBasket.basket.itemsById['i'+id];
					var a = $(this).val();
					var b = c.getCategory(a);
					$('#SEL2_'+id).html(b);
				});
				
				goToFastbuy(this.id);
				if (this.id == ajaxBasket.idFastBuy) {
					$("#fl"+this.id).focus();
				}
				break;
			case 4: /* STORITVE */
				this.uiTickets.rows[0].cells[0].innerHTML = STR_SVC_EMPTY;
				$("#si"+this.id).html(STR_SVC_SELECTED);
				
				// vpišemo število 
				var htmlKoda = '';
				
				htmlKoda += STR_SVC_CATEGORY+'&#160;';
				htmlKoda += '<select id="SEL_'+this.id+'">';
				htmlKoda += this.addOption;
				htmlKoda += '</select><br />';
				htmlKoda += STR_SVC_CHOSE + '&#160;<input type="text" size="2" maxlength="2" id="in' + this.id + '">';
				htmlKoda += ' <input type="button" value="'+STR_BUTTON_SELECT+'" id="pageDemo1" onclick="ajaxBasket.addSVC(' + this.id + ', document.getElementById(\'in' + this.id + '\').value, document.getElementById(\'SEL_' + this.id + '\').value)">';
				
				$("#uiSeatSelect_"+this.id).html(htmlKoda);
				$("#uiSeatSelect_"+this.id).show();
				
				goToFastbuy(this.id);
				if (this.id == ajaxBasket.idFastBuy) {
					$("#in"+this.id).focus();
				}
				break;
			case 5:
				$("#si"+this.id).html(STR_ART_ABOUT);
				$("#segmentsList_"+this.id).remove();
				$("#uiSeatSelect_"+this.id).remove();
				break;
			case 6:
				$("#si"+this.id).html(STR_SEATS_CHOSEN);
				$("#segmentsList_"+this.id).remove();
				$("#uiSeatSelect_"+this.id).remove();
				break;
			case 7: /* Bonus cards */
				this.uiTickets.rows[0].cells[0].colSpan = '4';
				this.uiTickets.rows[0].cells[0].innerHTML = STR_BC_EMPTY;
				$("#si"+this.id).html(STR_BC_SELECTED);
				
				goToFastbuy(this.id);
				break;
			case 8: /* Debit cards */
				this.uiTickets.rows[0].cells[0].colSpan = '4';
				this.uiTickets.rows[0].cells[0].innerHTML = STR_DC_EMPTY;
				$("#segmentsList_"+this.id).remove();
				$("#si"+this.id).html(STR_DC_SELECTED);
				
				// text with entry
				if (this.debitCardType == 'M') {
					var htmlKoda = '';
					htmlKoda += STR_DC_ADD_MONEY+'&#160;';
					if (DCR_SHOW_CUSTOM_INPUT && DCR_OPTIONS.length > 0 && this.debitCardType == 'M') {
						htmlKoda += '<select id="in' + this.id + '">';
						for (dcrI = 0; dcrI < DCR_OPTIONS.length; ++dcrI) {
							htmlKoda += '<option value="'+DCR_OPTIONS[dcrI]+'">'+DCR_OPTIONS[dcrI]+'</option>'; 
						}
						htmlKoda += '</select>';
					} else {
						htmlKoda += '<input type="text" size="2" id="in' + this.id + '">';
					}
					htmlKoda += ' <input type="button" value="'+STR_BUTTON_REFILL+'" onclick="ajaxBasket.addDC(' + this.id + ', $(\'#in' + this.id + '\').val())">';
					
					// add to DIV and show it
					$("#uiSeatSelect_"+this.id).html(htmlKoda).show();
				} else if (this.debitCardType == 'T') {
					$("#uiSeatSelect_"+this.id).remove();
				}
				$("label[for='delivery"+this.id+"_2']").html(STR_DC_BUY).attr('title', STR_DC_BUY);
				
				goToFastbuy(this.id);
				break;
			case 9: /* Debit cards -  renew */
				this.uiTickets.rows[0].cells[0].colSpan = '4';
				this.uiTickets.rows[0].cells[0].innerHTML = STR_DC_EMPTY;
				$("#segmentsList_"+this.id).remove();
				$("#si"+this.id).html(STR_DC_SELECTED);
				
				// text with entry
				var htmlKoda = '';
				if (this.debitCardType == 'M') {
					htmlKoda += STR_DC_ADD_MONEY+'&#160;';
				} else if (this.debitCardType == 'T') {
					htmlKoda += STR_DC_ADD_TICKETS+'&#160;';
				}
				
				if (DCR_SHOW_CUSTOM_INPUT && DCR_OPTIONS.length > 0 && this.debitCardType == 'M') {
					htmlKoda += '<select id="in' + this.id + '">';
					for (dcrI = 0; dcrI < DCR_OPTIONS.length; ++dcrI) {
						htmlKoda += '<option value="'+DCR_OPTIONS[dcrI]+'">'+DCR_OPTIONS[dcrI]+'</option>'; 
					}
					htmlKoda += '</select>';
				} else {
					htmlKoda += '<input type="text" size="2" id="in' + this.id + '">';
				}
				htmlKoda += ' <input type="button" value="'+STR_BUTTON_REFILL+'" onclick="ajaxBasket.addDCR(' + this.id + ', $(\'#in' + this.id + '\').val())">';
				
				// add to DIV and show it
				$("#uiSeatSelect_"+this.id).html(htmlKoda).show();
				$("label[for='delivery"+this.id+"_2']").html(STR_REFILL).attr('title', STR_REFILL);
				
				goToFastbuy(this.id);
				break;
			case 10: /* SERVICES - TIME TABLE */
				this.uiTickets.rows[0].cells[0].innerHTML = STR_SVC_EMPTY;
				$("#si"+this.id).html(STR_SVC_SELECTED);
				
				// vpišemo število 
				var htmlKoda = '<div style="float: left; line-height: 18px;">'+
					STR_SVC_DATE_SELECT+'&#160;'+
					'</div><div style="float:left" id="d'+this.id+'">'+
					'</div><div style="float:left">'+
					'<input type="hidden" size="10" maxlength="10" id="in' + this.id + '">'+
					'<input type="button" value="'+STR_BUTTON_CHECK_DATE+'" id="sb'+this.id+'" style="margin-left:10px" onclick="ajaxBasket.checkSvcDate(' + this.id + ')">'+
					'</div>'+
					'<div id="dSelNone_'+this.id+'" style="display:none;clear:both">'+STR_SVC_NO_SERVICE+'</div>'+
					'<div id="dSel_'+this.id+'" style="display:none;clear:both">'+
					STR_SVC_TIME_SELECT+'<span id="dDate'+this.id+'" class="dDate"></span>:<br />'+
					'<div id="SELT_'+this.id+'"></div><br />'+
					STR_SVC_CHOSE + '&#160;<input type="text" size="2" maxlength="2" id="inq' + this.id + '">'+
					' <input type="button" value="'+STR_BUTTON_SELECT+'" onclick="ajaxBasket.addSVCEvent(' + this.id + ')">'+
					'</div>'+
					'<br style="clear:both" />';
				
				$("#uiSeatSelect_"+this.id).html(htmlKoda);
				$("#uiSeatSelect_"+this.id).show();
				
				$("#segmentsList_"+this.id).remove();
				
				Date.format = 'dd.mm.yyyy';
				var $hiddenInput = $('#in'+this.id); // Save a reference to the hidden input form field...
				var $hiddenInputSC = $('#sb'+this.id); // Submit click
				var $dateSel = $('#dDate'+this.id);
				$('#d'+this.id).datePicker({inline:true}
							).dpSetSelected(
								(new Date().addDays(1).asString())
							).bind( // when a new date is selected...
								'dateSelected',
								function(event, date, $td, status) {
									$hiddenInput.val(date.asString()); // update the hidden field with the selected date...
									$hiddenInputSC.trigger('click');
									$dateSel.html(date.asString());
								}
							); /* .date-pick */
				goToFastbuy(this.id);
				
				if (this.id == ajaxBasket.idFastBuy) {
					$("input#inq"+this.id).focus();
				}
				break;
			case 11: /* package */
				// vpišemo število 
				var htmlKoda = '';
				// qty input
				htmlKoda += '<div id="step1_'+this.id+'" style="display:hidden">';
				htmlKoda += STR_PCK_CHOSE + '&#160;<input type="text" size="3" maxlength="3" id="inq' + this.id + '">';
				htmlKoda += ' <input type="button" value="'+STR_BUTTON_NEXT+'" onclick="ajaxBasket.packStart(' + this.id + ', document.getElementById(\'inq' + this.id + '\').value)">';
				htmlKoda += '</div>';
				
				// items select
				if (this.packI != null) {
					htmlKoda += '<div id="step3_'+this.id+'">'+STR_PCK_SVCEVENT+'<br /><ul style="margin-top:0">';
					piL = this.packI.length;
					for (iP=0;iP<piL;++iP){
						htmlKoda += '<li id="step3_'+this.id+'_'+this.packI[iP].ID+'">'+this.packI[iP].NAME+' <span style="display:none"></span></li>';
					}
					htmlKoda += '</ul></div>';
				}
				// items non-select
				if (this.packIN != null) {
					htmlKoda += '<div>'+STR_PCK_EVENT+'<br /><ul style="margin-top:0">';
					piL = this.packIN.length;
					for (iP=0;iP<piL;++iP){
						htmlKoda += '<li>'+this.packIN[iP].NAME+'</li>';
					}
					htmlKoda += '</ul></div>';
				}
				
				// date input
				htmlKoda += '<div id="step2_'+this.id+'" style="display:hidden">';
				htmlKoda += '<div style="float: left; line-height: 18px;">'+
				STR_SVC_DATE_SELECT+'&#160;'+
				'</div><div style="float:left" id="d'+this.id+'">'+
				'</div><div style="float:left">'+
				'<input type="hidden" size="10" maxlength="10" id="in' + this.id + '">'+
				'<input type="hidden" id="step2_pid' + this.id + '">'+
				'<input type="hidden" id="step2_pne' + this.id + '">'+
				'<input type="button" value="'+STR_BUTTON_CHECK_DATE+'" id="sb'+this.id+'" style="margin-left:10px;display:none" onclick="ajaxBasket.checkPackDate(' + this.id + ', $(\'#step2_pid'+this.id+'\').val())">'+
				'</div>'+
				'<div id="dSelNone_'+this.id+'" style="display:none;clear:both">'+STR_SVC_NO_SERVICE+'</div>'+
				'<div id="dSel_'+this.id+'" style="display:none;clear:both">'+
				STR_SVC_TIME_SELECT+'<span id="dDate'+this.id+'" class="dDate"></span>:<br />'+
				'<div id="SELT_'+this.id+'"></div>'+
				'<input type="button" value="'+STR_BUTTON_NEXT+'" onclick="ajaxBasket.packNext(' + this.id + ', $(\'#step2_pne'+this.id+'\').val())">'+
				'</div>'+
				'<br style="clear:both" />'+
				'</div>';
			
				$("#uiSeatSelect_"+this.id).html(htmlKoda);
				$("#uiSeatSelect_"+this.id).show();
				
				Date.format = 'dd.mm.yyyy';
				var $hiddenInput = $('#in'+this.id); // Save a reference to the hidden input form field...
				var $hiddenInputSC = $('#sb'+this.id); // Submit click
				var $dateSel = $('#dDate'+this.id);
				
				$('#d'+this.id).datePicker({inline:true}
							).dpSetSelected(
								(new Date().addDays(1).asString())
							).bind( // when a new date is selected...
								'dateSelected',
								function(event, date, $td, status) {
									$hiddenInput.val(date.asString()); // update the hidden field with the selected date...
									$hiddenInputSC.trigger('click');
									$dateSel.html(date.asString());
								}
							); /* .date-pick */
				this.uiTickets.rows[0].cells[0].innerHTML = STR_PCK_EMPTY;
				$("#si"+this.id).html(STR_PCK_SELECTED);
				
				goToFastbuy(this.id);
				break;
		}
	}
};

BasketItem.prototype.setDeliveryType = function (value, goAjax) {
	if (this.deliveryType != value) {
		if (this.deliveryType == 16 && value != 0) {
			this.basket.setPayment($(".payment > input[type=radio]").get(0).value);
		}
		
		if (value == 0) {
			if (this.allowedDeliveryTypes & 4) {
				value = 4;
			} else if (this.allowedDeliveryTypes & 1) {
				value = 1;
			} else if (this.allowedDeliveryTypes & 2) {
				value = 2;
			} else if (this.allowedDeliveryTypes & 16) {
				value = 16;
			}
		}
		el = document.getElementById('delivery' + this.id + '_' + value);
		if (el && !el.disabled) {
			this.deliveryType = value;
			el.checked = true;
			if (goAjax) {
				ajaxBasket.setDelivery(this.id, value);
			}
		}
	}
};


BasketItem.prototype.setAllowedDeliveryTypes = function (value) {
	if (this.allowedDeliveryTypes != value) {
		var radio;
		this.allowedDeliveryTypes = value;
		var hideDelivery = false;

		if (value & 1) {
			$("#dP"+this.id).show();
			$("#delivery"+this.id+"_1").attr('disabled', false);
			hideDelivery = true;
		} else {
			$("#dP"+this.id).hide();
			$("#delivery"+this.id+"_1").attr({'disabled': true, 'checked': false});
		}

		if (value & 2) {
			$("#dPH"+this.id).show();
			$("#delivery"+this.id+"_2").attr('disabled', false);
			hideDelivery = true;
		} else {
			$("#dPH"+this.id).hide();
			$("#delivery"+this.id+"_2").attr({'disabled': true, 'checked': false});
		}
		
		if (value & 4) {
			$("#dV"+this.id).show();
			$("#delivery"+this.id+"_4").attr('disabled', false);
			hideDelivery = true;
		} else {
			$("#dV"+this.id).hide();
			$("#delivery"+this.id+"_4").attr({'disabled': true, 'checked': false});
		}
		
		if (value & 16) {
			$("#dPT"+this.id).show();
			$("#delivery"+this.id+"_16").attr('disabled', false);
			hideDelivery = true;
		} else {
			$("#dPT"+this.id).hide();
			$("#delivery"+this.id+"_16").attr({'disabled': true, 'checked': false});
		}
		
		if (!hideDelivery) {
			$("#dND"+this.id).show();
		} else {
			$("#dND"+this.id).hide();
		}
	}
};


BasketItem.prototype.setAllowMailAbroad = function (value) {
	if (this.allowMailAbroad != value) {
		this.allowMailAbroad = value;
		if (value) {
			$("#dP"+this.id).attr('label', STR_MAIL);
		} else {
			$("#dP"+this.id).attr('label', STR_MAIL_LOCAL_ONLY);
		}
	}
};

/**
 * Funkcija dodaja vrednosti (optione) za izbiro (select), generira se polje za izbiro segmenta
 *
 * @param int id_seg - id segmenta
 * @param String name - ime segmenta
 * @param freepercen - odstotek segmenta, ki je še prost
 */
BasketItem.prototype.addSegment = function (id_seg, name, freepercent)
{
	if (freepercent == null) // v primeru da nimamo določenega freepercenta, gre za bestseat ali nepozicijsko predstavo z enim segmentom
	{
		this.addOption += '<option value="'+id_seg+'">'+name+'</option>'; // dodajmo v selectbox
	}
	else
	{ 
		// gre za prikaz segmentov >> ločimo glede na allowedSeatSelect
		switch (this.allowedSeatSelectTmp)
		{
			case 1: //
				url = ''; // Za naslov do tipa dvorane naredimo prazen string			
				link_text = STR_CHOOSE_SEATS_FROM_VENUE; // besedilo za prikaz dvorane
				url = SITE_PATH+'tickets/dvorana.php5'; // pot do flash animacije za dvorane
				if (freepercent == '-2') // prikaz celotne dvorane, ki ima podsegmente
				{	
					this.listOfSegments += '<option value="'+url+'?id='+this.id+'">'+name+'</option>';
				}
				else if (freepercent == '-1') // prikaz celotne dvorane, ki ima samo 1 segment (glej -> linhartova dvorana)
				{
					// prikaz celotne dvorane
					this.listOfSegments += '<option value="'+url+'?id='+this.id+'&idseg='+id_seg+'">'+name+'</option>';
				}
				else // prikaz segmentov
				{
					this.listOfSegments += '<option value="'+url+'?id='+this.id+'&idseg='+id_seg+'">&#160;'+name +'</option>';
				}
				break;
			/*case 2:	//// TRENUTNO ŠE NIMA POMENA, MORDA BO KDAJ \\\\
				break;
			case 3:
				break;*/
		}
	}
};

/**
 * za storitve
 */
BasketItem.prototype.addToPriceList = function (id_price, name, def)
{
	if (def == 1) // v primeru da imamo izbrano neko privzeto ceno, jo je tudi kot privzeto prikazati
	{
		this.addOption += '<option value="'+id_price+'" SELECTED>'+name+'</option>'; // zato ima ta option selected
	}
	else
	{
		this.addOption += '<option value="'+id_price+'">'+name+'</option>'; // vsi, ki niso privzeti, nimajo statusa SELECTED
	}
};

/**
 * for services - event dates
 */
BasketItem.prototype.addToEventDatesList = function (ed) {
	if (ed.info != '') {
		$("#SELT_"+this.id).append('<input type="radio" name="r'+this.id+'" id="r'+this.id+'_'+ed.id+'" value="'+ed.id+'"'+(ed.sel != ''? " checked" : "")+'>'+
			'<label for="r'+this.id+'_'+ed.id+'">'+ed.hour+''+ed.text+' ('+ed.info+')</label><br />');
	} else {
		$("#SELT_"+this.id).append('<input type="radio" name="r'+this.id+'" id="r'+this.id+'_'+ed.id+'" value="'+ed.id+'"'+(ed.sel != ''? " checked" : "")+'>'+
			'<label for="r'+this.id+'_'+ed.id+'">'+ed.hour+''+ed.text+'</label><br />');
	}
	
	if (ed.disable != '') {
		$('#r'+this.id+'_'+ed.id).attr('disabled', true);
	}
};

/**
 * generiramo drugo "dimenzijo" drugo opcijo za izbrio sedežev, glede na izbran segment
 * @param string parent - ime "starša", kar pomeni ime segmenta
 * @param int price - cena vstopnice
 * @param string statusname - ime statusa
 */
BasketItem.prototype.getCategory = function (id_seg)
{
	var seL = this.category.length;
	seLi = 0;
	r = '';
	p = '';
	while (seLi < seL) {
		if (id_seg == this.category[seLi].parent) {
			p = formatCurrency(this.category[seLi].price);
			p = p.replace('.', ',');
			r += '<option value="'+this.category[seLi].id+'">'+this.category[seLi].statusname+' ('+(p.replace(',', PRICE_DELIMETER))+' '+STR_CURRENCY_CODE+')</option>'; 
		}
		++seLi;
	}
	return r;
};

BasketItem.prototype.setDateSelected = function (date) {
	if (this.dateSelected != date) {
		this.dateSelected = date; // cena skupaj
	}
}


/*
 * Branje XML dokumenta
 */
BasketItem.prototype.loadFromXml = function (xmlDoc) {
	this.setCaption1(xmlDoc.caption1.xmlEscapeText());
	this.setCaption2(xmlDoc.caption2.xmlEscapeText());
	this.setPersonalize(parseInt(xmlDoc.personalize, 10) == -1);
	this.allowPromotionCode(xmlDoc.promotion.xmlEscapeText());
	this.getPromotionCode(xmlDoc.promotioncode.xmlEscapeText());
	
	this.setAllowedDeliveryTypes(parseInt(xmlDoc.allowedDeliveryTypes, 10));
	this.setDeliveryType(parseInt(xmlDoc.deliveryType, 10), false);
	this.setMode(parseInt(xmlDoc.mode, 10));


	this.setAllowMailAbroad(parseInt(xmlDoc.allowMailAbroad, 10) == -1);

	var type;
	var id;

	var tickets;
	var locked;
	var countSegmetns = 0;
	this.segments = {};
	this.segmentIds = [];
	
	this.addOption = '';
	this.listOfSegments = '';
	this.listOfSegments += '<option value="about:blank" selected="selected">----- '+STR_DROP_DOWN+' -----</option>';
	
	this.allowedSeatSelectTmp = parseInt(xmlDoc.allowedSeatSelect, 10);
	
	// preberemo ostale argumetne
	xmlTickets = xmlDoc.tickets;
	
	var i = 0;
	if (xmlDoc.locked) {
		locked = xmlDoc.locked;
	} else {
		locked = {};
	}
	
	if (xmlDoc.category) {
		this.category = xmlDoc.category;
	} else {
		this.category = {};
	}
	
	if (xmlDoc.segments) {
		this.segments = xmlDoc.segments;
		var seL = this.segments.length;
		if (seL > 0) {
			seI = 0;
			while(seI < seL) {
				this.addSegment(this.segments[seI].idseg, this.segments[seI].value, this.segments[seI].freePercent);
				++seI;
			}
		}
	} else {
		this.segments = {};
	}

	
	if (xmlDoc.priceList) {
		priceL = xmlDoc.priceList;
		var seL = priceL.length;
		i = 0;
		while (i < seL) {
			this.addToPriceList(priceL[i].idprice, priceL[i].value, priceL[i].isDefault);
			++i;
		}
	}
	
	if (xmlDoc.amounttype) {
		this.debitCardType = xmlDoc.amounttype;
	}
	
	this.packI = null;
	this.packIN = null;
	if (xmlDoc.pack && xmlDoc.pack[0].pItems && xmlDoc.pack[0].pItems.length > 0) {
		this.packI = xmlDoc.pack[0].pItems;
		
		if (xmlDoc.pack[0].packD && xmlDoc.pack[0].packD.length > 0) {
			piL = xmlDoc.pack[0].packD.length;
			for (iP=0;iP<piL;++iP){
				// show date values near each item
				$('#step3_'+this.id+'_'+this.packI[iP].ID+' > span').html('('+xmlDoc.pack[0].packD[iP].D+')').show();
			}
		} else {
			piL = this.packI.length;
			for (iP=0;iP<piL;++iP){
				// reset values
				$('#step3_'+this.id+'_'+this.packI[iP].ID+' > span').html('').hide();
			}
		}
		
	}
	
	if (xmlDoc.pack && xmlDoc.pack[0].packA && xmlDoc.pack[0].packA.length > 0) {
		this.packIN = xmlDoc.pack[0].packA;
	}
	
	this.setAllowedSeatSelect(parseInt(xmlDoc.allowedSeatSelect, 10));
	
	$('#step3_'+this.id+' > ul > li').removeClass('pItemsSel');
	if (xmlDoc.pack && xmlDoc.pack[0].packN[0] != null) {
		this.packT = xmlDoc.pack[0].packR;
		this.pack = xmlDoc.pack[0].packN;
		$('#step1_'+this.id).hide();
		$('#step2_pid'+this.id).val(this.pack[0].ID_ITEM_SVC_TREE);
		$('#step2_pne'+this.id).val(this.packT);
		$('#step2_'+this.id).show();
		$('#step3_'+this.id+'_'+this.pack[0].ID_ITEM_SVC_TREE).addClass('pItemsSel');
	} else {
		this.packT = -1;
		this.pack = new Array();
		$('#step1_'+this.id).show();
		$('#step2_'+this.id).hide();
	}
	
	if (xmlDoc.eventDates) {
		if (xmlDoc.eventDate) {
			$("#in"+this.id).val(xmlDoc.eventDate);
			$("#dDate"+this.id).html(xmlDoc.eventDate);
			$("#d"+this.id).dpSetSelected(xmlDoc.eventDate);
		}
		$("#SELT_"+this.id).empty();
		$("#dSel_"+this.id).hide();
		$("#dSelNone_"+this.id).hide();
		eventsL = xmlDoc.eventDates;
		var seL = eventsL.length;
		i = 0;
		while (i < seL) {
			this.addToEventDatesList(eventsL[i]);
			++i;
		}
		if (i > 0) {
			$("#dSel_"+this.id).show();
		} else {
			if ($("#in"+this.id).val() != '') {
				$("#dSelNone_"+this.id).show();
			}
		}
		$("#SELT_"+this.id+" > input").unbind('click');
		var $doFocus = $('#inq'+this.id);
		$("#SELT_"+this.id+" > input").bind('click', function() { $doFocus.focus(); });
		
		if (!xmlDoc.eventDate) {
			if (this.packT > -1) {
				// show calendar for last event
				$('#sb'+this.id).trigger('click');
			}
		}
	}

	var lockedSeat;
	var xcL = locked.length;
	if (xcL > 0) {
		i = 0;
		while (i < xcL) {
			id = locked[i].id;
			if (typeof(this.lockCache['i' + id]) == 'undefined') {
				lockedSeat = new LockedSeat(this, id);
				// no need to load from XML
			}
			++i;
		}
	}
	
	if (AMC_STUDIO_SHOW_VENUE && xmlDoc.venueId) {
		if($('#venueImg_'+this.id).attr('src') == undefined) {
			$('#tb'+this.id).after('<img id="venueImg_'+this.id+'" src="'+SITE_PATH+'picture/'+xmlDoc.venueId+'/5/" width="750" />');
		}
	}
	
	// TODO ali tudi brišemo lockedSeats ??
	// dodaj vstopnice, ki jih še ni v naši košarici oz. osveži že obstoječe
	var tempSeatIds = {};
	var tempSegQtyIds = {};
	var tempSvcQtyIds = {};
	var tempArtQtyIds = {};
	var tempBCQtyIds = {};
	var tempDCQtyIds = {};
	var tempPackQtyIds = {};
	var tempTPackQtyIds = {};
	var xtL = xmlTickets.length;
	if (xtL > 0) {
		var lastHolder = -1; // zapomnimo si holder, ter ce je zdejsni razlicen od prejsnega, naredimo crto med njimi
		var prviAbonma = true;
		
		i = 0;
		while (i < xtL) {
			type = xmlTickets[i].type;
			id = xmlTickets[i].id;
			idbasketitem = xmlTickets[i].idbasketitem;
			
			switch (type)
			{
				case 'seat':
					itemId = xmlTickets[i].itemId;
					if (itemId != '') {
						tempSeatIds['i' + id + itemId] = true;
						ticket = this.seatsById['i' + id + itemId];
					} else {
						itemId = this.id;
						tempSeatIds['i' + id + itemId] = true;
						ticket = this.seatsById['i' + id + itemId] ;
					}
					
					if (typeof(ticket) == 'undefined')
					{
						ticket = new Seat(this, id, idbasketitem, itemId);
					}
					ticket.loadFromXml(xmlTickets[i]);
					tmp = ticket.getHolder();
					if (tmp != null) // samo za tpack
					{
						if (tmp != lastHolder)
						{
							if(prviAbonma == true)
							{
								prviAbonma = false;
							}
							lastHolder = tmp;
						}
					}
					break;
				case 'segqty': // nepozicijski segment
					itemId = xmlTickets[i].itemId;
					idholder = xmlTickets[i].idholder;
					if (itemId == '') {
						itemId = this.id;
					}
					if (idholder == '') {
						idholder = idbasketitem;
					}
					tempSegQtyIds['i' + idbasketitem + itemId + idholder] = true;
					ticket = this.segqtysById['i' + idbasketitem + itemId + idholder];
					if (typeof(ticket) == 'undefined')
					{
						ticket = new SegQty(this, id, idbasketitem, itemId, idholder);
					}
					ticket.loadFromXml(xmlTickets[i]);
					if (tmp != null) // samo za tpack
					{
						if (tmp != lastHolder)
						{
							if(prviAbonma == true)
							{
								prviAbonma = false;
							}
							lastHolder = tmp;
						}
					}
					break;
				case 'tpack':
					tempTPackQtyIds['i' + idbasketitem] = true;
					ticket = this.segTPackById['i' + idbasketitem];
					if (typeof(ticket) == 'undefined')
					{
						ticket = new TPack(this, id, idbasketitem, this.id);
					}
					ticket.loadData(xmlTickets[i]);
					break;
				case 'svc': // storitve
					tempSvcQtyIds['i' + idbasketitem] = true;
					ticket = this.segsvcsById['i' + idbasketitem];
					if (typeof(ticket) == 'undefined')
					{
						ticket = new SVC(this, id, idbasketitem, this.id);
					}
					ticket.loadFromXml(xmlTickets[i], xmlDoc.priceList);
					break;
				case 'article':
					tempArtQtyIds['i' + idbasketitem] = true;
					ticket = this.segartsById['i' + idbasketitem];
					if (typeof(ticket) == 'undefined')
					{
						ticket = new Article(this, id, idbasketitem, this.id);
					}
					ticket.loadFromXml(xmlTickets[i]);
					break;
				case 'bc': // bonus cards
					tempBCQtyIds['i' + id] = true;
					ticket = this.segBCById['i' + id];
					if (typeof(ticket) == 'undefined')
					{
						ticket = new BC(this, id, idbasketitem, this.id);
					}
					ticket.loadData(xmlTickets[i]);
					break;
				case 'dc': // debit cards
					tempDCQtyIds['i' + idbasketitem] = true;
					ticket = this.segDCById['i' + idbasketitem];
					if (typeof(ticket) == 'undefined')
					{
						ticket = new DC(this, id, idbasketitem, this.id);
					}
					ticket.loadData(xmlTickets[i]);
					break;
				case 'pack': // packages
					tempPackQtyIds['i' + idbasketitem] = true;
					ticket = this.segPackById['i' + idbasketitem];
					if (typeof(ticket) == 'undefined')
					{
						ticket = new Pack(this, id, idbasketitem, this.id);
					}
					ticket.loadData(xmlTickets[i], xmlDoc.priceList);
					break;
			}
			++i;
		}
	}

	if (xmlDoc.vTickets && xmlDoc.vTickets == 'T') {
		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;
		ajaxBasket.basket.venueWindow = tmp;
	}

	// briši vstopnice, ki jih ni več v košarici
	for (var k in this.seatsById) {
		if (typeof(tempSeatIds[k]) == 'undefined') {
			this.seatsById[k].remove();
		}
	}
	for (var k1 in this.segqtysById) {
		if (typeof(tempSegQtyIds[k1]) == 'undefined') {
			this.segqtysById[k1].remove();
		}
	}
	for (var k2 in this.segsvcsById) {
		if (typeof(tempSvcQtyIds[k2]) == 'undefined') {
			this.segsvcsById[k2].remove();
		}
	}
	for (var k3 in this.segartsById) {
		if (typeof(tempArtQtyIds[k3]) == 'undefined') {
			this.segartsById[k3].remove();
		}
	}
	for (var k4 in this.segBCById) {
		if (typeof(tempBCQtyIds[k4]) == 'undefined') {
			this.segBCById[k4].remove();
		}
	}
	
	for (var k5 in this.segDCById) {
		if (typeof(tempDCQtyIds[k5]) == 'undefined') {
			this.segDCById[k5].remove();
		}
	}
	
	for (var k6 in this.segPackById) {
		if (typeof(tempPackQtyIds[k6]) == 'undefined') {
			this.segPackById[k6].remove();
		}
	}
	
	for (var k7 in this.segTPackById) {
		if (typeof(tempTPackQtyIds[k7]) == 'undefined') {
			this.segTPackById[k7].remove();
		}
	}
	
};


function getObj(name) {
  if (document.getElementById) {
	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all) {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers) {
	this.obj = document.layers[name];
	this.style = document.layers[name];
  }
};

function goToFastbuy(id) {
	if (id == ajaxBasket.idFastBuy) {
		if (1 == ajaxBasket.basket.itemsCount) {
			window.location = '#buyStep1';
		} else {
			window.location = '#'+id;
		}
	}
};
