var google_analytics = {
	setStep : function(step) {
		_gaq.push(step != '' ? ['_trackPageview', step] : ['_trackPageview']);
	},
	setTransaction : function() {
		if(document.getElementById('seoResId')){ this.resId = document.getElementById('seoResId').value; } else this.resId = '';

		if(document.getElementById('seoFinalPrice')){	// cena na potwierdzeniu zapytania jest sciagana z dodatkowego hiddena w oferta.tpl lub z zaznaczonego radiobuttona
			this.finalPrice = document.getElementById('seoFinalPrice').value; }
		else if(document.getElementById('offerChoosenPrice') && document.getElementById('offerChoosenPrice').value != '') {
			this.finalPrice = parseInt(document.getElementById('offerChoosenPrice').value, 10).toFixed(2);
			finalPriceSet = true;
		}
		else if(document.getElementById('offerVariants')) {
			var inputs = document.getElementById('offerVariants').getElementsByTagName('input');
			var finalPriceSet = false;
			for(var n = 0, inputsLength = inputs.length; n < inputsLength; n+=1) {
				if (inputs[n].checked === true) {
					this.finalPrice = parseInt(inputs[n].nextSibling.nextSibling.innerHTML, 10).toFixed(2);
					finalPriceSet = true;
				}
				if(!finalPriceSet) {
					this.finalPrice = 0;
				}
			}
		} else {
			this.finalPrice = 0;
		}

		if(document.getElementById('seoOfferCode')){ this.offerCode = document.getElementById('seoOfferCode').value; } else this.offerCode = '';
		if(document.getElementById('seoHotelName')){ this.hotelName = document.getElementById('seoHotelName').value; } else this.hotelName = '';
		if(document.getElementById('officeName')){ this.officeName = document.getElementById('officeName').value; } else this.officeName = '';


		_gaq.push(['_addTrans',
			this.resId, // ID Rezerwacji
			'',
			this.finalPrice, // wartosc rezerwacji
			'10.00',
			'0',
			'',
			'',
			''
		]);

		_gaq.push(['_addItem',
			this.resId, // ID Rezerwacji
			this.offerCode, // Kod oferty
			this.hotelName, // Nazwa Hotelu
			this.officeName, // nazwa biuro podrozy
			this.finalPrice, // wartośc rezerwacji
			'1'
		]);
		_gaq.push(['_trackTrans']);
	}
}

