	function SiteReservation()
	{
		this.init();
	}
/*
*/
	SiteReservation.prototype.host = 'https://www.landlordterminal.com/';
/*
	SiteReservation.prototype.host = 'https://llt.necrian.firstvds.ru/';
/*
	SiteReservation.prototype.host = 'https://stage.landlordterminal.com/';
/*
*/
	SiteReservation.prototype.width = 600;
	SiteReservation.prototype.canLoad = false;
	SiteReservation.prototype.finish_price = '';
	SiteReservation.prototype.standalone = false;
	SiteReservation.prototype.finish_total_price = '';
	SiteReservation.prototype.predefined_unit_id = 0;
	SiteReservation.prototype.firstControlFilled = false;
	SiteReservation.prototype.first_day_box_id = 0;
	SiteReservation.prototype.second_day_box_id = 0;
	SiteReservation.prototype.important_date = false;

	SiteReservation.prototype.tax = null;
	SiteReservation.prototype.pkg = null;
	SiteReservation.prototype.rule = null;
	SiteReservation.prototype.custom = null;
	SiteReservation.prototype.myname = null;
	SiteReservation.prototype.nights = null;
	SiteReservation.prototype.pp_data = null;
	SiteReservation.prototype.user_id = null;
	SiteReservation.prototype.site_id = null;
	SiteReservation.prototype.no_guest = null;
	SiteReservation.prototype.dateRange = null;
	SiteReservation.prototype.fullQuery = null;
	SiteReservation.prototype.dictionary = null;
	SiteReservation.prototype.round_rule = null;
	SiteReservation.prototype.guest_types = null;
	SiteReservation.prototype.disabled_next = null;
	SiteReservation.prototype.selectOptions = null;
	SiteReservation.prototype.pp_notification = null;
	SiteReservation.prototype.billing_statement = null;
	SiteReservation.prototype.is_price_advanced = null;
	SiteReservation.prototype.selectedUnitsNumber = null;

	SiteReservation.prototype.step = [];
	SiteReservation.prototype.journal = [];
	SiteReservation.prototype.resQuery = [];
	SiteReservation.prototype.formFields = [];
	SiteReservation.prototype.formValues = [];

	SiteReservation.prototype.get = {};
	SiteReservation.prototype.data = {};
	SiteReservation.prototype.unitsDetails = {};
	SiteReservation.prototype.bookRelation = {};
	SiteReservation.prototype.availableCats = {};
	SiteReservation.prototype.selectedUnits = {};
	SiteReservation.prototype.priceForCurDate = {};
	SiteReservation.prototype.basicSelectsData = {};
	SiteReservation.prototype.selectedCategories = {};

	SiteReservation.prototype.init = function()
	{
		if (document.location.href.match(/www7\.jimdo\.com/)) {
			return;
		}
		var html = '';

		html += '' +
				'<div id="landlordterminal_status" class="landlordterminal_status">Initialize Online Booking Module</div>' +
				'<iframe src="about:_blank" id="landlordterminal_big_picture_substrate" class="landlordterminal_big_picture_substrate" style="display: none;"></iframe>' +
				'<div id="landlordterminal_big_picture" class="landlordterminal_big_picture"></div>' +
				'<div id="landlordterminal_notice_error" class="landlordterminal_notice_error"></div>' +
				'<div id="landlordterminal_contents" class="landlordterminal_contents"></div>';

		document.write(html);

		this.contentEl = this.getEl('landlordterminal_contents');
	}

	SiteReservation.prototype.getData = function()
	{
// Next line crush IE8 :(
//		this.setStatus('Loading page');

		_this = this;
		setLoadEvent(function() {
			_this.canLoad = true;
		});
		if (this.canLoad) {
			if (this.user_id > 0) {
				if (this.standalone) {
					this.doLoad(true, false, 'get_data', { query : location.href , user_id : this.user_id , site_id : this.site_id , get : 'standalone' });
				} else {
					this.myGET();
//					if (this.get['from_d'] && this.get['from_m'] && this.get['from_y'] && this.get['to_d'] && this.get['to_m'] && this.get['to_y']) {
					if (this.get['from'] && this.get['to']) {
						this.check('query', {}, 'query_string');
					} else {
						this.doLoad(true, false, 'get_data', { query : location.href , user_id : this.user_id , site_id : this.site_id , get : this.get });
					}
				}
			} else {
				this.mistake('Unknown user', 'fatal');
			}
		} else {
			setTimeout('_this.getData();', 100);
		}
	}

	SiteReservation.prototype.parseDateRange = function()
	{
		var tmp;

		if (this.dateRange['from']) {
			tmp = this.dateRange['from'].split(/\//);

			this.dateRange['from_d'] = tmp[1];
			this.dateRange['from_m'] = tmp[0];
			this.dateRange['from_y'] = tmp[2];
		}

		if (this.dateRange['to']) {
			tmp = this.dateRange['to'].split(/\//);

			this.dateRange['to_d'] = tmp[1];
			this.dateRange['to_m'] = tmp[0];
			this.dateRange['to_y'] = tmp[2];
		}
	}

	SiteReservation.prototype.check = function(type, data, data_from)
	{
		if (type == 'query') {
			if (data_from == 'form') {
				this.dateRange = {};
				for (var i = 0; i < this.formFields.length; i++) {
					if (this.formFields[i] && this.getEl(this.formFields[i])) {
						this.dateRange[this.formFields[i]] = this.getEl(this.formFields[i]).value;
					}
				}
			} else {
				this.dateRange = this.get;
			}
			this.selectedUnitsNumber = null;
			this.selectedCategories = {};
			this.selectedUnits = {};
			this.priceForCurDate = {};
			this.doLoad(true, false, 'check', { form_data : this.dateRange , referer : location.href , user_id : this.user_id , site_id : this.site_id , predefined_unit_id : this.predefined_unit_id });
		} else {
			var formCode = '';
			this.availableCats = {};
			this.custom = data.result.record;
			this.width = this.custom.Width;
			this.selectOptions = data.result.options;
			this.parseDateRange();

			if (data.result.pkg) {
				this.pkg = data.result.pkg;
			}
			if (!this.dictionary) {
				this.dictionary = data.result.dictionary;
			}
			if (!this.pp_data) {
				this.pp_data = data.result.pp_data;
			}
			if (!this.guest_types) {
				this.guest_types = data.result.guest_types;
			}
			if (!this.round_rule) {
				this.round_rule = data.result.round_rule;
			}
			if (!this.billing_statement) {
				this.billing_statement = data.result.billing_statement;
			}
			if (data.result.tax) {
				this.tax = data.result.tax;
			}
			if (!this.is_price_advanced) {
				this.is_price_advanced = data.result.is_price_advanced;
			}
			if (data.result.rule) {
				this.rule = data.result.rule;
			} else {
				this.rule = false;
			}
			if (data.result.formTPL) {
				this.formFields = [];
				formCode = this.align(this.getFormHTML(data.result.formTPL, this.custom, data.result.FormID), 'left');
				this.putHTML(formCode);
			}
			if (data.error.length == 0) {
				this.mistake('', 0);
				this.setStatus('Bilding stage');
				this.nights = data.result.nights;
				var units = [];
				var unit_details = [];
				if (this.custom.rwcf_UnitDetailsDescription == 'Y') {
					unit_details[this.custom.rwcf_UnitDetailsDescriptionOrder] = 'description';
				}
				if (this.custom.rwcf_UnitDetailsFacilities == 'Y') {
					unit_details[this.custom.rwcf_UnitDetailsFacilitiesOrder] = 'facilities';
				}
				if (this.custom.rwcf_UnitDetailsServices == 'Y') {
					unit_details[this.custom.rwcf_UnitDetailsServicesOrder] = 'services';
				}
				if (this.custom.rwcf_UnitDetailsCancelpolicy == 'Y') {
					unit_details[this.custom.rwcf_UnitDetailsCancelpolicyOrder] = 'cancellation_policy';
				}
				unit_details = ksort(unit_details);
/*
	OBJECT "640"
		309 = 2
*/
				for (var i in data.result.cats) {
					units.push(this.printCategory(data.result.cats[i], unit_details, this.custom.rwcf_ShowPicture));

					if (!data.result.book_relation[i]) {
						for (j in data.result.book_relation) {
							for (k in data.result.book_relation[j]) {
								if (k == i) {
									data.result.book_relation[i] = {};
									data.result.book_relation[i][j] = 1;
								}
							}
						}
					}
					var pkg_ids = [0];

					for (var j in data.result.cats[i].Packages) {
						if (typeof(data.result.cats[i].Packages[j]) == 'function') {
							continue;
						}
						var undef;

						if ( typeof(data.result.cats[i].Packages[j].ID) == typeof(undef) ) {
							continue;
						}
						units.push(this.printCategory(data.result.cats[i], unit_details, this.custom.rwcf_ShowPicture, data.result.cats[i].Packages[j]));

						if (!data.result.book_relation[i]) {
							data.result.book_relation[i] = {};
						}
						if (!data.result.book_relation[i].pkg) {
							data.result.book_relation[i].pkg = [];
						}
						data.result.book_relation[i].pkg.push(data.result.cats[i].Packages[j].ID);
					}
					if (this.predefined_unit_id > 0) {
						var exec_data = [i, this.getTitle(data.result.cats[i].Description), data.result.cats[i].NormalAdult, data.result.cats[i].NormalChildren];
					}
				}
				this.bookRelation = this.completeBookRelation(data.result.book_relation);

				var html = '';
				if (this.predefined_unit_id > 0) {
					html += '' +
							this.categoriesInfoBox('top') + join('', units);
				} else {
					html += '' +
							this.categoriesInfoBox('top') + '<table cellspacing="0" cellpadding="0" width="' + this.width + '" border="0">' + join('', units) + '</table>' + this.categoriesInfoBox('bottom');
				}
				this.step[1] = formCode + html;
				this.putHTML(this.step[1]);
				if (this.predefined_unit_id > 0) {
					this.selectCat(exec_data[0], exec_data[1], exec_data[2], exec_data[3], 0);
				}
				this.getEl('from').value = this.dateRange['from'];
				this.getEl('to').value = this.dateRange['to'];
			} else {
				this.mistake(data.error, 'notice');
			}
			this.setStatus('');
		}
	}

	SiteReservation.prototype.selectUnits = function(type, data)
	{
		if (type == 'query') {
			var res = {};
			var obj = {};
			for (var i = 0; i < this.formFields.length; i++) {
				if (this.getEl(this.formFields[i])) {
					obj[this.formFields[i]] = this.getEl(this.formFields[i]).value;
				} else {
					obj[this.formFields[i]] = '';
				}
			}
			for (var id in this.availableCats) {
				res[id] = this.getEl('unit_num_' + id).value;
			}
			this.doLoad(true, false, 'select_units', {form_data: {res: res, date: obj}, referer: location.href, user_id: this.user_id, site_id: this.site_id, predefined_unit_id: this.predefined_unit_id});
		} else {
			if (data.error.length == 0) {
				this.mistake('', 0);
				this.setStatus('Bilding stage');
				var units;

				var unit_details = [];
				if (this.custom.bf_UnitDescription == 'Y') {
					unit_details[this.custom.bf_UnitDescriptionOrder] = 'description';
				}
				if (this.custom.bf_UnitFacilities == 'Y') {
					unit_details[this.custom.bf_UnitFacilitiesOrder] = 'facilities';
				}
				if (this.custom.bf_UnitServices == 'Y') {
					unit_details[this.custom.bf_UnitServicesOrder] = 'services';
				}
				if (this.custom.bf_UnitCancelpolic == 'Y') {
					unit_details[this.custom.bf_UnitCancelpolicOrder] = 'cancellation_policy';
				}
				unit_details = ksort(unit_details);
				var html = '';
				this.formFields = [];
				var units = this.printUnit(data.result.units, this.custom, unit_details);

				html += '' +
						'<div id="bf_whole_box" style="width: ' + this.width + 'px;">' +
							'<span id="bf_booking_details">' + this.GD('booking_details') + '</span> &nbsp; ' + this.getDateRangeHTML(true) +
							'<br />' +
							this.categoriesInfoBox('full') +
							'<br />';
				if (this.selectedUnitsNumber > 1) {
					html += '' +
							'<span id="bf_top_note">' + this.GD('to_book_we_requiring') + '</span><br />';
				}
				html += '' +
							units +
							'<span id="bf_bottom_note"><span class="bf_asterix">**</span> ' + this.GD('selected_smoking_not_guaranted') + '</span>' +
							'<br />' +
							'<br />' +
							this.getFormHTML(data.result.formTPL, this.custom, data.result.FormID);
				var textual;
				if (this.custom.bf_SubmitTextual == 'Y') {
					textual = true;
				} else {
					textual = false;
				}
				var pref = {type : 'submit' , align : '' , title : '<< ' + this.GD('previous') , click : this.myname + '.backToStep(1); return false;' , textual : textual};
				var next = {type : 'submit' , align : '' , title : this.GD('proceed') + ' >>' , click : this.myname + '.confirmation(\'query\', {}); return false;' , textual : textual};
				html += '' +
							'<table width="' + this.width + '" border="0" cellspacing="0" cellpadding="0">' +
								'<tr>' +
									'<td>' + this.getFormCell('pref', pref, 'bf', 2).field + '</td>' +
									'<td style="text-align: right;">' + this.getFormCell('pref', next, 'bf', 2).field + '</td>' +
								'</tr>' +
							'</table>' +
						'</div>';
				this.step[2] = html;
				this.putHTML(this.step[2]);
			} else {
				this.mistake(data.error, 'notice');
			}
			this.setStatus('');
		}
	}

	SiteReservation.prototype.confirmation = function(type, data)
	{
		var obj, error, required, i, tmp, tmp1, tmp2, j, gt_fill;

		obj = {};
		error = [];

		for (i = 0; i < this.formFields.length; i++) {
			obj[this.formFields[i]] = this.getEl(this.formFields[i]).value;
		}
		if (this.custom.CCVType == 'no_ccv') {
			required = {'first_name' : 'First Name' , 'last_name' : 'Last Name' , 'phone' : 'Phone' , 'llt_email' : 'Email' , 'address' : 'Street Address' , 'city' : 'City/Town' , 'zip' : 'ZIP/Postal Code' , 'country' : 'Country'};
		} else {
			required = {'first_name' : 'First Name' , 'last_name' : 'Last Name' , 'phone' : 'Phone' , 'llt_email' : 'Email' , 'cc_type' : 'Credit Card Type' , 'cc_number' : 'Credit Card Number' , 'cc_holder' : 'Card Holder\'s Name' , 'cc_exp' : 'Expiration Date' , 'cc_csv' : 'CVV' , 'address' : 'Street Address' , 'city' : 'City/Town' , 'zip' : 'ZIP/Postal Code' , 'country' : 'Country'};
			obj['cc_number'] = obj['cc_number'].replace(/[^\d]/g, '').substr(0, 16);
		}
		for (i in this.selectedUnits) {
			tmp = this.selectedUnits[i];

			if (in_array(i + '_' + tmp.pkg_id + '_f', this.formFields) && !(obj[i + '_' + tmp.pkg_id + '_f'])) {
				error.push(tmp.title + ' ' + this.GD('guest_first_name') + ' ' + this.GD('error_is_required'));
			}
			if (in_array(i + '_' + tmp.pkg_id + '_l', this.formFields) && !(obj[i + '_' + tmp.pkg_id + '_l'])) {
				error.push(tmp.title + ' ' + this.GD('guest_last_name') + ' ' + this.GD('error_is_required'));
			}
			if (in_array(i + '_' + tmp.pkg_id + '_p', this.formFields) && !(obj[i + '_' + tmp.pkg_id + '_p'])) {
				error.push(tmp.title + ' ' + this.GD('guest_phone') + ' ' + this.GD('error_is_required'));
			}
		}
		for (i in required) {
			if (!(obj[i])) {
				error.push(required[i] + ' ' + this.GD('error_is_required'));
			} else {
				if (i == 'country' && obj[i] == '1' && obj['state'] == 'Not USA') {
					error.push(this.GD('state') + ' ' + this.GD('error_is_required'));
				}
				if (i == 'llt_email' && obj[i].match(/.+@.+\..+/) == null) {
					error.push(this.GD('email') + ' ' + this.GD('error_is_invalid'));
				}
			}
		}
		if (this.custom.CCVType != 'no_ccv') {
			if (obj['cc_exp'].match(/\d\d\/\d\d/) == null) {
				error.push(this.GD('si_expiration_date') + ' ' + this.GD('error_is_invalid'));
			} else {
				tmp1 = new Date();
				tmp2 = obj['cc_exp'].split('/');
				if (parseInt('20' + tmp2[1]) < tmp1.getYear()) {
					error.push(this.GD('incorrect_expiration_date'));
				} else if (parseInt('20' + tmp2[1]) == tmp1.getYear()) {
					if (tmp2[0] < (tmp1.getMonth() + 1)) {
						error.push(this.GD('incorrect_expiration_date'));
					}
				}
			}
		}
		if (this.no_guest) {
			error.push(this.GD('no_guests'));
		}
// Debug
// error = [];
		if (error.length > 0) {
			this.mistake(error, 'notice');
		} else {
			this.mistake('', 0);
			var html = '';
			this.setStatus('Bilding stage');
			this.fullQuery = obj;
			html += '' +
					'<div id="cp_whole_box" style="width: ' + this.width + 'px;">' +
						'<span id="cp_booking_details">' + this.GD('booking_details') + '</span> &nbsp; ' + this.getDateRangeHTML(true) +
						'<div id="cp_booking_price"></div>' +
						'<div id="cp_booking_separator"><img src="' + this.host + 'pics/1x1.gif" width="300" height="3" border="0" alt="" /></div>' +
						'<div id="cp_booking_total_price"></div>' +
						'<div id="pp_notification">' + this.pp_notification + '</div>' +
						'<br />' +
						'<br />';
			this.fullQuery.price = {};
			var price;
			var price_html = [];
			var price_total = 0;
			for (i in this.selectedUnits) {
				tmp = this.selectedUnits[i];
				tmp2 = this.availableCats[tmp.category + '_' + tmp.pkg_id];

				price = this.getPrice(tmp2.Price, tmp2, tmp.guests, tmp2.Packages[tmp.pkg_id]);

				this.fullQuery.price[i] = price;
				if (!price_html[tmp.category + '_' + tmp.pkg_id]) {
					price_html[tmp.category + '_' + tmp.pkg_id] = 0;
				}
				price_html[tmp.category + '_' + tmp.pkg_id] += parseFloat(price.out);
				price_total += parseFloat(price.out);

				gt_fill = '';
				for (j in this.guest_types) {
					if (obj[i + '_' + tmp.pkg_id + '_gt_' + j] > 0) {
						gt_fill += '<strong>' + obj[i + '_' + tmp.pkg_id + '_gt_' + j] + '</strong> ' + this.guest_types[j].title + '; ';
					}
				}

				this.selectedUnits[i].confirm_html = tmp.confirm_html.replace(/<span salt="guest">.*?<\/span>/, '<span salt="guest">' + obj[i + '_' + tmp.pkg_id +'_f'] + ' ' + obj[i + '_' + tmp.pkg_id +'_l'] + '</span>');
				this.selectedUnits[i].confirm_html = tmp.confirm_html.replace(/<span salt="phone">.*?<\/span>/, '<span salt="phone">' + obj[i + '_' + tmp.pkg_id +'_p'] + '</span>');
				this.selectedUnits[i].confirm_html = tmp.confirm_html.replace(/<span salt="guests">.*?<\/span>/, '<span salt="guests">' + gt_fill + '</span>');
				this.selectedUnits[i].confirm_html = tmp.confirm_html.replace(/<span salt="disabled">.*?<\/span>/, '<span salt="disabled">' + obj[i + '_' + tmp.pkg_id +'_d'] + '</span>');
				this.selectedUnits[i].confirm_html = tmp.confirm_html.replace(/<span salt="smoking">.*?<\/span>/, '<span salt="smoking">' + obj[i + '_' + tmp.pkg_id +'_s'] + '</span>');

				this.selectedUnits[i].thanks_html = tmp.thanks_html.replace(/<span salt="guest">.*?<\/span>/, '<span salt="guest">' + obj[i + '_' + tmp.pkg_id +'_f'] + ' ' + obj[i + '_' + tmp.pkg_id +'_l'] + '</span>');
				this.selectedUnits[i].thanks_html = tmp.thanks_html.replace(/<span salt="phone">.*?<\/span>/, '<span salt="phone">' + obj[i + '_' + tmp.pkg_id +'_p'] + '</span>');
				this.selectedUnits[i].thanks_html = tmp.thanks_html.replace(/<span salt="guests">.*?<\/span>/, '<span salt="guests">' + gt_fill + '</span>');
				this.selectedUnits[i].thanks_html = tmp.thanks_html.replace(/<span salt="disabled">.*?<\/span>/, '<span salt="disabled">' + obj[i + '_' + tmp.pkg_id +'_d'] + '</span>');
				this.selectedUnits[i].thanks_html = tmp.thanks_html.replace(/<span salt="smoking">.*?<\/span>/, '<span salt="smoking">' + obj[i + '_' + tmp.pkg_id +'_s'] + '</span>');

				html += '' +
							this.selectedUnits[i].confirm_html;
			}
			html += '' +
							'<span id="cp_bottom_note"><span class="cp_asterix">**</span> ' + this.GD('selected_smoking_not_guaranted') + '</span>' +
							'<br />' +
							'<br />' +
							'<div id="cp_personal_title">' + this.GD('personal_information') + '</div>' +
							'<div class="cp_personal_text">' +
								this.GD('name') + ': ' + obj['first_name'] + ' ' + obj['last_name'] +
								'<br />' +
								this.GD('phone') + ': ' + obj['phone'] +
								'<br />' +
								this.GD('email') + ': ' + obj['llt_email'];
			if (this.custom.CCVType != 'no_ccv') {
				html += '' +
							'</div>' +
							'<div id="cp_billing_title">' + this.GD('billing_information') + '</div>' +
							'<div class="cp_billing_text">' +
								this.GD('credit_card') + ' - ' + this.selectOptions.card[obj['cc_type']] + ': **** **** **** ' + obj['cc_number'].substr(12, 4) +
								'<br />' +
								this.GD('si_expiration_date') + ': ' + obj['cc_exp'] +
								'<br />' +
								this.GD('card_holder_name') + ': ' + obj['cc_holder'];
			}
			html += '' +
								'<br />' +
								this.GD('company') + ': ' + obj['company'] +
								'<br />' +
								this.GD('billing_address') + ': ' + obj['address'] +
								'<br />' +
								this.GD('city_town') + ': ' + obj['city'] +
								'<br />';
			if (obj['country'] == 1) {
				html += '' +
								this.GD('state') + ': ' + this.selectOptions.state[obj['state']] +
								'<br />';
			}
			html += '' +
								this.GD('zip_postal') + ': ' + obj['zip'] +
								'<br />' +
								this.GD('country') + ': ' + this.selectOptions.country[obj['country']] +
							'</div>' +
							'<br />';
			var textual;
			if (this.custom.cp_PreviousTextual == 'Y') {
				textual = true;
			} else {
				textual = false;
			}
			var pref = {type : 'submit' , align : '' , title : '<< ' + this.GD('return_previous_step') , click : this.myname + '.backToStep(2); return false;' , textual : textual};
			if (this.custom.cp_SubmitTextual == 'Y') {
				textual = true;
			} else {
				textual = false;
			}
			var next = {type : 'submit' , align : '' , title : this.GD('proceed_booking') + ' >>' , click : this.myname + '.finish(\'query\', {}); return false;' , textual : textual};

			if (this.custom.TermCond != '') {
				html += '' +
							'<table cellspacing="0" cellpadding="0" width="' + this.width + '" border="0">' +
								'<tr>' +
									'<td colspan="2" id="cp_term_cond_title">' + this.GD('terms_and_conditions') + '</td>' +
								'</tr>' +
								'<tr>' +
									'<td width="25" style="text-align: right;">' +
										'<input type="checkbox" name="term_cond_agree" id="term_cond_agree" onclick="' + this.myname + '.changeTermCond(this);" />' +
									'</td>' +
									'<td width="' + (this.width - 20) + '" class="cp_term_cond_text">' +
										'&nbsp;' + this.GD('terms_cond') +
										' ' +
										'<a href="#" onclick="' + this.myname + '.clickTermCond(); return false;">' + this.GD('terms_link') + '</a>' +
										' ' +
										'<a href="#" onclick="' + this.myname + '.printTermCond(); return false;">' + this.GD('printer_friendly_version') + '</a>' +
									'</td>' +
								'</tr>' +
								'<tr>' +
									'<td colspan="2">&nbsp;</td>' +
								'</tr>' +
								'<tr>' +
									'<td colspan="2">' +
										'<div class="cp_unit_cancel" id="term_cond_box" style="display: none; overflow: auto; height: 100px; margin: 0px 0px 10px 0px;">' + this.strToOut(this.custom.TermCond) + '</div>' +
									'</td>' +
								'</tr>' +
							'</table>';
				this.disabled_next = true;
			} else {
				this.disabled_next = false;
			}

			html += '' +
							'<table width="' + this.width + '" border="0" cellspacing="0" cellpadding="0">' +
								'<tr>' +
									'<td>' + this.getFormCell('pref', pref, 'cp', 1).field + '</td>' +
									'<td><div id="cp_confirm_button" style="text-align: right;">' + this.getFormCell('next', next, 'cp', 2).field + '</div></td>' +
								'</tr>' +
							'</table>' +
						'</div>';
			this.formValues[2] = obj;
			this.step[3] = html;
			this.putHTML(this.step[3]);
			this.finish_price = '';
			for (i in this.selectedCategories) {
				this.finish_price += this.selectedCategories[i].number + ' ' + this.selectedCategories[i].name + '(s): ' + this.custom.Currency + ' ' + myParseFloat(price_html[i]) + '<br />';
			}
			this.getEl('cp_booking_price').innerHTML = this.finish_price;
			this.finish_total_price = this.GD('total') + ': ' + this.custom.Currency + ' ' + myParseFloat(price_total);
			this.getEl('cp_booking_total_price').innerHTML = this.finish_total_price;
		}
		this.setStatus('');
	}

	SiteReservation.prototype.finish = function(type, data)
	{
		if (this.disabled_next) {
			alert(this.GD('check_terms_cond_first'));
			return;
		}
		if (type == 'query') {
			this.getEl('cp_confirm_button').style.display = 'none';

			var res = { 'cat' : [] , 'unit' : [] };
			var number = 0;
			var number_total = objLen(this.selectedUnits);
			var data = this.normilize(this.fullQuery);

			var transaction_id = getRandom();
			var tmp_info = {};
			var tmp_price = {};
			var o, i;
			for (i in this.selectedUnits) {
				number++;
				for (var j in data.info) {
					if (j == 'price') {
						tmp_price = data.info[j][i];
					} else {
						tmp_info[j] = data.info[j];
					}
				}
				o = {pid: i, cid: this.selectedUnits[i].category, tid: transaction_id, gid: this.custom.GroupID, packet: (number + '/' + number_total), info: tmp_info, price: tmp_price, d: data[i], date: this.dateRange, referer: location.href, user_id: this.user_id, site_id: this.site_id, predefined_unit_id: this.predefined_unit_id};
				this.resQuery[number] = o;
			}
			this.doLoad(true, false, 'reserv', this.resQuery[1]);
		} else {
			if (data.packet) {
				var p = data.packet.split('/');
				if (p[0] < p[1]) {
					if (data.error.length == 0) {
						this.setStatus(p[0] + ' of ' + p[1] + ' unit has been reserved');
						this.doLoad(true, false, 'reserv', this.resQuery[(++p[0])]);
					} else {
						this.getEl('cp_confirm_button').style.display = 'block';
						this.mistake(data.error, 'notice');
					}
					return;
				} else {
					this.setStatus('Reservation complete, Bilding stage');
				}
			} else {
				this.mistake('Unknown reservation packet', 'fatal');
			}
			if (data.error.length == 0) {
				this.mistake('', 0);
				var html = '';
				var total_price = 0;

				html += '' +
						'<div id="typ_whole_box" style="width: ' + this.width + 'px;">' +
							'<span id="typ_booking_details">';
				if (this.custom.AutoConfirm == 'Y') {
					html += '' +
							this.GD('thank_you_confirmed') + ' - ' + data.result.ReservationID + '<br />' + this.GD('copy_confirmation_sent') + ' ' + data.result.Email;
				} else {
					html += '' +
							this.GD('thank_you_processing') + ' ' + data.result.Email;
				}
				html += '' +
							'<br />' +
							'<br />' +
							this.GD('booking_details') + '</span> &nbsp; ' + this.getDateRangeHTML(true) +
							'<div id="typ_booking_price">' + this.finish_price + '</div>' +
							'<div id="typ_booking_separator"><img src="' + this.host + 'pics/1x1.gif" width="300" height="3" border="0" alt="" /></div>' +
							'<div id="typ_booking_total_price">' + this.finish_total_price + '</div>';
				for (i in this.selectedUnits) {
					html += '' +
							this.selectedUnits[i].thanks_html;
				}
				html += '' +
							'<br />' +
							'<span id="typ_bottom_note"><span class="typ_asterix">**</span> ' + this.GD('selected_smoking_not_guaranted') + '</span>' +
							'<br />' +
							'<br />';
				if (this.custom.IsAppartmentGroup == 'N') {
					html += '' +
							'<div id="typ_contact_title">' + this.GD('hotel_address_contact') + '</div>' +
							'<div class="typ_direction_text">' + this.strToOut(this.custom.Direction) + '</div>' +
							'<br />';
				}
				html += '' +
							'<div id="typ_cancel_title">' + this.GD('cancellation_procedure') + '</div>' +
							'<div class="typ_cancel_text">' + this.strToOut(this.custom.Cancellation) + '</div>' +
							'<br />' +
							'<div id="typ_addition_title">' + this.GD('additional_information') + '</div>' +
							'<div class="typ_addition_text">' + this.strToOut(this.custom.AdditionalInformation) + '</div>' +
							'</div>';
/////////////////////////////////////////////////////////////////////
//	html += '<input type="button" onclick="' + this.myname + '.finish(\'query\', {});" value=">>>>>>>>>>>>" /><div id="cp_confirm_button"></div>';
/////////////////////////////////////////////////////////////////////
				this.step[4] = html;
				this.putHTML(this.step[4]);
			} else {
				this.getEl('cp_confirm_button').style.display = 'block';
				this.mistake(data.error, 'notice');
			}
			this.setStatus('');
		}
	}

	SiteReservation.prototype.printUnit = function(units, customs, unit_details)
	{
		var i, j, pkg_id, pkg, id, ret, data, confirm_html, thanks_html, number, total_number, flag, field, pkg_using;

		ret = [];
		number = 0;
		total_number = 0;

		this.selectedUnits = {};

		for (id in units) {
			flag = 0;
			for (i in units[id]) {
				if (flag < units[id][i].Num.total) {
					total_number++;
				}
				flag++;
			}
		}
		this.selectedUnitsNumber = total_number;

		for (id in units) {
			pkg_using = {};
			flag = 0;
			data = units[id];
			for (i in data) {
				for (j in data[i].Num) {
					data[i].Num[j] = parseInt(data[i].Num[j]);
					if (j == 'total' || !data[i].Num[j]) {
						continue;
					}
					pkg_using[j] = data[i].Num[j];
				}
			}
			for (i in data) {
				if (flag < data[i].Num.total) {
					pkg_id = false;
					for (j in pkg_using) {
						if (pkg_using[j] == 0) {
							continue;
						}
						pkg_id = j;
						break;
					}
					pkg_using[pkg_id]--;
					number++;

					data[i].Title = this.selectedCategories[data[i].Property + '_' + pkg_id].name;
					data[i].NormalAdults = this.selectedCategories[data[i].Property + '_' + pkg_id].normal_adults;
					data[i].Description = this.availableCats[data[i].Property + '_' + pkg_id].Description;
					pkg = this.availableCats[data[i].Property + '_' + pkg_id].Packages[pkg_id];

					ret.push(this.printUnitHTML(data[i], number, customs, unit_details, total_number, pkg));
					confirm_html = this.printUnitConfirmHTML(data[i], number, customs, unit_details, total_number, pkg);
					thanks_html = this.printUnitThanksHTML(data[i], number, customs, unit_details, total_number, pkg);

					this.selectedUnits[data[i].ID] = {'title': data[i].Title, 'category': data[i].Property, 'confirm_html': confirm_html, 'thanks_html': thanks_html, 'guests': this.defaultGuests(data[i].NormalAdults), 'pkg_id': pkg_id};
				}
				flag++;
			}
		}
		return join('', ret);
	}

	SiteReservation.prototype.defaultGuests = function(def_pers)
	{
		var i, undef, ret;

		if (typeof(undef) == typeof(def_pers)) {
			def_pers = 1;
		}
		ret = {};

		for (i in this.guest_types) {
			if (this.guest_types[i]['default']) {
				ret[i] = def_pers;
			} else {
				ret[i] = 0;
			}
		}
		return ret;
	}

	SiteReservation.prototype.getPrice = function(price, cat, guests, pkg)
	{
		var sip, ret;

		sip = new RBPrice();

		sip.tax =				this.tax;
		sip.nights =			this.nights;
		sip.guests =			guests;
		sip.rate_id =			this.custom.Rate;
		sip.currency =			this.custom.Currency;
		sip.discounts =			{};
		sip.linked_to =			'SI';
		sip.round_rule =		this.round_rule;
		sip.exemptions =		{};
		sip.use_package =		pkg;
		sip.guest_types =		this.guest_types;
		sip.exemption_id =		0;
		sip.addition_list =		{};
		sip.full_addition =		cat.Addition;
		sip.full_transfer =		cat.Transfer;
		sip.property_price =	price;
		sip.advanced_price =	this.is_price_advanced;

		if (this.rule[cat.ID]) {
			sip.by_rule_discount = this.rule[cat.ID].DiscountID;
			sip.full_rule = this.rule[cat.ID];

			sip.discounts[this.rule[cat.ID].DiscountID] = {type: this.rule[cat.ID].Type, value: this.rule[cat.ID].Discount}
		} else {
			sip.by_rule_discount = 0;
			sip.full_rule = {};
		}
		if (pkg) {
			if (pkg.DiscountData) {
				sip.discounts[pkg.DiscountData.ID] = {type: pkg.DiscountData.Type, value: pkg.DiscountData.Value}
			}
			sip.package_id = pkg.ID;
		} else {
			sip.package_id = 0;
		}
		sip.exec();

		ret = sip.result;

		ret.rule_id = sip.full_rule.ID;

		if (ret.postfix != '') {
			ret.postfix = ' / ' + this.GD(ret.postfix);
		}
		if (this.custom.TaxIncluded == "Y") {
			ret.out = parseFloat(ret.total_value).toFixed(2);
		} else {
			ret.out = (ret.total_value - ret.tax_value).toFixed(2);
		}
		ret.avg = (ret.out / this.nights).toFixed(2);

		if (sip.guests.p > 0) {
			ret.no_guest = false;
		} else {
			ret.no_guest = true;
		}

		return ret;
	}

	SiteReservation.prototype.getOccupiedHTML = function(id, occupied, nocico)
	{
		var tmp, cur_day, i, j, rule_start, border, i_am_busy, wd, no_ci, no_co, ttl, img;
		var html = '';
		var empty = true;
		var s = 0;
		var f = 0;
		var d = new Date();
		var m = '';
		var day_of_week = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];
		var more_days = 65;
		var busy = {};

		for (i in occupied) {
			if (typeof occupied[i] == 'function') {
				continue;
			}
			empty = false;
			for (j = occupied[i].s; j < occupied[i].f; j = parseInt(j) + 86400) {
				busy[(j * 1000)] = true;
			}
			if (occupied[i].s < s || s == 0) {
				s = occupied[i].s;
			}
			if (occupied[i].f > f) {
				f = occupied[i].f;
			}
		}
		if (empty) {
			s = (d.getTime() / 1000) - (5 * 86400);
			f = s + (30 * 86400);
		}

		d.setTime(s * 1000);
		d.setDate(this.dateRange.from_d);
		d.setMonth(this.dateRange.from_m - 1);
		d.setYear(this.dateRange.from_y);
		rule_start = Math.round(d.getTime() / 1000 - 86400 * 5);
/*
		if (s < rule_start) {
			rule_start = s;
		}
*/
		html += '' +
				'<br />' +
				'<div style="position: absolute;">' +
					'<div style="width: ' + (this.width - 110) + 'px; height: 40px; top: 0px; left: -5px; position: absolute;">' +
						'<img width="6" height="31" alt="" id="llt_res_l_ctrl_' + id + '" src="' + this.host + 'pics/arrow_left_3.gif" onclick="' + this.myname + '.moveResBox(' + id + ', \'left\');" style="left: 0px; top: 10px; position: absolute; display: none; margin: 0px;" />' +
						'<img width="6" height="31" alt="" id="llt_res_r_ctrl_' + id + '" src="' + this.host + 'pics/arrow_right_3.gif" onclick="' + this.myname + '.moveResBox(' + id + ', \'right\');" style="left: ' + (this.width - 106) + 'px; top: 10px; position: absolute; margin: 0px;" />' +
						'<div style="width: ' + (this.width - 130) + 'px; height: 40px; left: 9px; top: 0px; position: absolute; overflow: hidden;">' +
							'<div id="llt_res_box_' + id + '" style="width: ' + (parseInt((f - rule_start) / 86400 + more_days) * 20 + 63) + 'px; height: 50px; left: 0px; top: 0px; position: absolute; overflow: hidden;">';
//	for (i = 0; i <= parseInt((f - rule_start) / 86400 + more_days); i++) {
		for (i = 0; i <= more_days; i++) {
			cur_day = Math.round(rule_start + i * 86400);
			d.setTime(cur_day * 1000);

			i_am_busy = false;
			for (j in busy) {
				if (Math.round((j - d.getTime()) / 86400000) == 0) {
					i_am_busy = true;
				}
			}

			month = d.getMonth() + 1;
			day = d.getDay();
			tmp = d.getDate();
			year = d.getFullYear();
			no_ci = no_co = false;

			for (j in nocico) {
				if (day) {
					wd = day;
				} else {
					wd = 7;
				}
				if
				(
					(nocico[j].from_m < month || (nocico[j].from_m == month && nocico[j].from_d <= tmp))
					&&
					(month < nocico[j].to_m || (month == nocico[j].to_m && tmp <= nocico[j].to_d))
				) {
					if (nocico[j].no_ci[wd]) {
						no_ci = true;
					}
					if (nocico[j].no_co[wd]) {
						no_co = true;
					}
				}
			}

			if (m != month) {
				m = month;
				html += '' +
								'<div class="rwcf_oc_month" style="width: 100px; height: 15px; left: ' + (20 * i + 1) + 'px; top: 1px;">' + (tmp == 1 ? '&darr;' : '') + (m > 9 ? m : '0' + m) + '.' + year + '</div>';
			}

			if (this.dateRange.from_d == tmp && this.dateRange.from_m == month && this.dateRange.from_y == year) {
				border = 'from';
				this.first_day_box_id = 'llt_day_box_' + id + '_' + tmp + '_' + month + '_'+ year;
			} else if (this.dateRange.to_d == tmp && this.dateRange.to_m == month && this.dateRange.to_y == year) {
				border = 'to';
				this.second_day_box_id = 'llt_day_box_' + id + '_' + tmp + '_' + month + '_'+ year;
			} else {
				border = 'usual';
			}

			if (no_ci && no_co) {
				img = '<img src="' + this.host + 'pics/red_cross.gif" width="5" height="9" alt="" border="0" align="absmiddle" />';
				ttl = ' title="' + this.GD('error_los_nci') + ' ' + this.GD('error_los_nco') + '"';
			} else if (no_ci) {
				img = '<img src="' + this.host + 'pics/red_arr_up.gif" width="5" height="9" alt="" border="0" align="absmiddle" />';
				ttl = ' title="' + this.GD('error_los_nci') + '"';
			} else if (no_co) {
				img = '<img src="' + this.host + 'pics/green_arr_dwn.gif" width="5" height="9" alt="" border="0" align="absmiddle" />';
				ttl = ' title="' + this.GD('error_los_nco') + '"';
			} else {
				img = '<img src="' + this.host + 'pics/1x1.gif" width="5" height="9" alt="" border="0" align="absmiddle" />';
				ttl = '';
			}

			html += '' +
								'<div class="rwcf_oc_day' + (day == 0 || day == 6 ? '_we' : '') + '" style="font-size: 9px; white-space: nowrap; width: 19px; height: 14px; left: ' + (20 * i + 1) + 'px; top: 15px;"' + ttl + '>' + day_of_week[day] + ' ' + img + '</div>' +
								'<div id="llt_day_box_' + id + '_' + tmp + '_' + month + '_'+ year + '" class="rwcf_oc_date' + (i_am_busy ? '_busy' : '') + '_' + border + '" style="width: 17px; height: 15px; left: ' + (20 * i + 1) + 'px; top: 30px;"><a href="#" onclick="' + this.myname + '.setDateControl(' + id + ', ' + tmp + ', ' + month + ', '+ year + '); return false;">' + tmp + '</a></div>';
		}
		html += '' +
							'</div>' +
						'</div>' +
					'</div>' +
				'</div>' +
				'<img src="' + this.host + 'pics/1x1.gif" border="0" width="1" height="65" alt="" />' +
				'<table cellspacing="0" cellpadding="0" width="" border="0">' +
					'<tr>' +
						'<td style="vertical-align: middle;">' +
							this.GD('legend') + ':&nbsp;' +
						'</td>' +
						'<td>' +
							'<img src="' + this.host + 'pics/1x1.gif" width="13" height="13" alt="" class="rwcf_oc_date_busy_usual" style="display: inline; position: static;" align="absmiddle" /> - ' +
							this.GD('no_room_available') + '; ' +
							'<img src="' + this.host + 'pics/1x1.gif" width="13" height="13" alt="" class="rwcf_oc_date_usual" style="display: inline; position: static;" align="absmiddle" /> - ' +
							this.GD('date_available') + '; ' +
							'<img src="' + this.host + 'pics/1x1.gif" width="13" height="13" alt="" class="rwcf_oc_date_from" style="display: inline; position: static;" align="absmiddle" /> - ' +
							this.GD('arrival') + '; ' +
							'<img src="' + this.host + 'pics/1x1.gif" width="13" height="13" alt="" class="rwcf_oc_date_to" style="display: inline; position: static;" align="absmiddle" /> - ' +
							this.GD('departure') + ';' +
						'</td>' +
					'</tr>' +
					'<tr><td colspan="2"><img src="' + this.host + 'pics/1x1.gif" border="0" width="1" height="3" alt="" /></td></tr>' +
					'<tr>' +
						'<td>&nbsp;</td>' +
						'<td>' +
							'<img src="' + this.host + 'pics/red_cross.gif" width="3" height="3" alt="" style="display: inline; position: static;" align="absmiddle" />, ' +
							'<img src="' + this.host + 'pics/red_arr_up.gif" width="5" height="9" alt="" style="display: inline; position: static;" align="absmiddle" />, ' +
							'<img src="' + this.host + 'pics/green_arr_dwn.gif" width="5" height="9" alt="" style="display: inline; position: static;" align="absmiddle" /> - ' +
							this.GD('limited_ci_co') + ';' +
						'</td>' +
					'</tr>' +
				'</table>';

		return html;
	}

	SiteReservation.prototype.moveResBox = function(id, vector)
	{
		var displacement = 14 * 20;
		var left;

		if (vector == 'right') {
			displacement = 0 - displacement;
		}
		left = parseInt(this.getEl('llt_res_box_' + id).style.left) + displacement;

		if (left >= 0) {
			this.getEl('llt_res_l_ctrl_' + id).style.display = 'none';
		} else {
			this.getEl('llt_res_l_ctrl_' + id).style.display = 'block';
		}
		if (left <= (this.width - 1440)) {
			this.getEl('llt_res_r_ctrl_' + id).style.display = 'none';
		} else {
			this.getEl('llt_res_r_ctrl_' + id).style.display = 'block';
		}

		this.getEl('llt_res_box_' + id).style.left = left + 'px';
	}

	SiteReservation.prototype.setDateControl = function(id, d, m, y)
	{
		if (this.firstControlFilled) {
			this.getEl('to').value = m + '/' + d + '/' +y;

			if (this.second_day_box_id != 0) {
				this.getEl(this.second_day_box_id).style.border = 'solid 1px #dddddd';
			}
			this.second_day_box_id = 'llt_day_box_' + id + '_' + d + '_' + m + '_'+ y;
			this.getEl(this.second_day_box_id).style.border = 'solid 1px #ff0000';

			this.firstControlFilled = false;

			this.check('query', {}, 'form');
		} else {
			this.getEl('from').value = m + '/' + d + '/' +y;

			if (this.first_day_box_id != 0) {
				this.getEl(this.first_day_box_id).style.border = 'solid 1px #dddddd';
			}
			this.first_day_box_id = 'llt_day_box_' + id + '_' + d + '_' + m + '_'+ y;
			this.getEl(this.first_day_box_id).style.border = 'solid 1px #009900';

			this.firstControlFilled = true;
		}
	}

	SiteReservation.prototype.printCategory = function(data, unit_details, show_picture, pkg)
	{
		var i, j, html, hidden_html, details_count, show_opener, free_units, to_user_title, min_block, max_block, block, occupied, price, prop, prop_title, undef, pkg_id;

		html = false;
		for (i in data) {
			if (typeof(data[i]) != 'function') {
				html = true;
			}
		}
		if (html) {
			html = '';
		} else {
			return '';
		}
		occupied = '';
		hidden_html= '';
		show_opener = false;
		to_user_title = this.getTitle(data.Description);

		if (typeof(undef) != typeof(pkg)) {
			if (pkg.Description && pkg.Description.title && pkg.Description.title[this.custom.LanguageID]) {
				to_user_title += ' ' + pkg.Description.title[this.custom.LanguageID];
			}
			pkg_id = pkg.ID;
		} else {
			pkg_id = 0;
			pkg = false;
		}

		if (data.FreeUnits == 0) {
			if (this.custom.ShowOccupied == 'show_short') {
				occupied = this.GD('occupied_for_seleted_date');
			} else {
				occupied = this.getOccupiedHTML(data.ID, data.Occupied, data.No_CI_CO_data);

				if (occupied == '') {
					occupied = this.GD('occupied_for_seleted_date');
				} else {
					occupied = this.GD('occupied_for_seleted_date') + ' ' + this.GD('see_occupied_table') + ':<br />' + occupied;
				}
			}
		}
		this.availableCats[data.ID + '_' + pkg_id] = data;

		html += '' +
				'<tr>' +
					'<td class="rwcf_result_table_header" style="border-left: 0px;" colspan="3">' + this.GD('available_rooms') + '</td>' +
					'<td class="rwcf_result_table_header">' + this.GD('persons') + '</td>' +
					'<td class="rwcf_result_table_header">' + this.GD('avg_rate') + '</td>' +
					'<td class="rwcf_result_table_header">' + this.GD('price_stay') + '</td>' +
					'<td class="rwcf_result_table_header">' + this.GD('num_rooms') + '</td>' +
				'</tr>' +
				'<tr>' +
					'<td class="rwcf_pricing_box" id="rwcf_pricing_box_unit" style="text-align: left; border-left: 0px;" colspan="2">';
		if (data.Description && data.Description.url && data.Description.url[this.custom.LanguageID] != '') {
			html += '' +
						'<a href="' + data.Description.url[this.custom.LanguageID] + '">' + to_user_title + '</a>';
		} else {
			html += '' +
						to_user_title;
		}
		html += '' +
					'</td>' +
					'<td class="rwcf_pricing_box" style="text-align: right; border-left: 0px;">';
		if (show_picture == 'Y') {
			show_opener = true;
		} else {
			for (i in unit_details) {
				if (data.Description[unit_details[i]]) {
					show_opener = true;
				}
			}
		}
		if (occupied != '') {
			show_opener = false;
		}
		if (show_opener) {
			html += '' +
						'<img src="' + this.host + 'pics/si_down.gif" border="0" width="13" height="13" alt="" id="landlordterminal_showhide_' + data.ID + '" onclick="' + this.myname + '.moreUnitInfo(' + data.ID + ', ' + pkg_id + ');" style="cursor: pointer; cursor: hand;" />';
		} else {
			html += '' +
						'<img src="' + this.host + 'pics/1x1.gif" border="0" width="1" height="1" alt="" />';
		}
		this.priceForCurDate[data.ID + '_' + pkg_id] = data.Price;

		price = this.getPrice(data.Price, data, this.defaultGuests(data.NormalAdult), pkg);

		html += '' +
					'</td>' +
					'<td class="rwcf_pricing_box">' + data.NormalAdult + '</td>' +
					'<td class="rwcf_pricing_box" nowrap="nowrap">' + this.custom.Currency + ' ' + price.avg + '</td>' +
					'<td class="rwcf_pricing_box" nowrap="nowrap">' + this.custom.Currency + ' ' + price.out + price.postfix + '</td>' +
					'<td class="rwcf_pricing_box">' +
						'<select name="unit_num_' + data.ID + '_' + pkg_id + '" id="unit_num_' + data.ID + '_' + pkg_id + '" class="rwcf_pricing_box_dd" style="width:100px;" onchange="' + this.myname + '.selectCat(' + data.ID + ', \'' + to_user_title.replace(/\'/g, '\\\'') + '\', \'' + data.NormalAdult + '\', \'' + data.NormalChildren + '\', ' + pkg_id + ');">';
		if (data.FreeUnits > 7) {
			free_units = 7;
		} else {
			free_units = data.FreeUnits;
		}

		hidden_html = '<input type="hidden" name="unit_num_' + data.ID + '_' + pkg_id + '" id="unit_num_' + data.ID + '_' + pkg_id + '" value="0" />';

		if (min_block || max_block || block || occupied != '' || data.LOS != '') {
			html += '' +
							'<option value="0">0</option>';
		} else {
			for (i = 0; i <= free_units; i++) {
				if (i) {
					html += '' +
							'<option value="' + i + '">' + i + ' (' + this.custom.Currency + ' ' + parseFloat(i * price.out).toFixed(2) + ')</option>';
					if ( i == 1 ) {
						hidden_html = '<input type="hidden" name="unit_num_' + data.ID + '_' + pkg_id + '" id="unit_num_' + data.ID + '_' + pkg_id + '" value="' + i + '" />';
					}
				} else {
					html += '' +
							'<option value="' + i + '">' + i + '</option>';
				}
			}
		}
		html += '' +
						'</select>' +
					'</td>' +
				'</tr>' +
				'<tr>' +
					'<td class="rwcf_unit_details" style="vertical-align: top;">';
		if (show_picture == 'Y') {
			html += '' +
						this.imageThumb(data.ID, data.Image, pkg);
		} else {
			html += '' +
						'<img src="' + this.host + 'pics/1x1.gif" border="0" width="1" height="1" alt="" />';
		}
		html += '' +
					'</td>' +
					'<td class="rwcf_unit_details" colspan="6">';
		details_count = 0;
		
		if (occupied != '') {
			html += '' +
						'<div class="rwcf_oc_box">' + occupied + '</div>';
		} else if (data.LOS != '') {
			html += '' +
						'<div class="rwcf_oc_box">' + data.LOS + '</div>';
		} else {
			for (i in unit_details) {
				prop = unit_details[i];
				if (typeof(prop) != 'string') {
					continue;
				}
				prop_title = this.GD(unit_details[i]);

				if (data.Description[prop]) {
					if (prop == 'description') {
						html += '' +
						'<div>';
					} else {
						details_count++;
						html += '' +
						'<div style="display: none;" id="landlordterminal_more_unit_info_' + details_count + '_' + data.ID + '_' + pkg_id + '">' +
							'<strong>' + prop_title + '</strong>: ';
					}
					var output = data.Description[prop][this.custom.LanguageID];

					if (pkg && pkg.Description && pkg.Description[prop] && pkg.Description[prop][this.custom.LanguageID]) {
						if (prop == 'description') {
							output += '<br /><br />' + pkg.Description[prop][this.custom.LanguageID];
						}
						if (prop == 'cancellation_policy') {
							output = pkg.Description[prop][this.custom.LanguageID];
						}
					}
					if (output != '') {
						html += '' +
							this.strToOut(output);
					} else {
						html += '' +
							this.GD('no') + ' ' + prop_title;
					}
					html += '' +
						'</div>';
				}
			}
		}
		this.unitsDetails[data.ID] = details_count;
		html += '' +
					'</td>' +
				'</tr>' +
				'<tr>' +
					'<td style="padding: 0px ! important;"><img src="' + this.host + 'pics/1x1.gif" border="0" width="90" height="10" alt="" /></td>' +
					'<td style="padding: 0px ! important;"><img src="' + this.host + 'pics/1x1.gif" border="0" width="' + (this.width - 490) + '" height="10" alt="" /></td>' +
					'<td style="padding: 0px ! important;"><img src="' + this.host + 'pics/1x1.gif" border="0" width="30" height="10" alt="" /></td>' +
					'<td style="padding: 0px ! important;"><img src="' + this.host + 'pics/1x1.gif" border="0" width="70" height="10" alt="" /></td>' +
					'<td style="padding: 0px ! important;"><img src="' + this.host + 'pics/1x1.gif" border="0" width="80" height="10" alt="" /></td>' +
					'<td style="padding: 0px ! important;"><img src="' + this.host + 'pics/1x1.gif" border="0" width="110" height="10" alt="" /></td>' +
					'<td style="padding: 0px ! important;"><img src="' + this.host + 'pics/1x1.gif" border="0" width="110" height="10" alt="" /></td>' +
				'</tr>';
		if (this.predefined_unit_id > 0) {
			html = hidden_html;
		}
		return html;
	}

	SiteReservation.prototype.setDefResDate = function(from_today, nights, important)
	{
		var undef;

		if ( typeof(important) == typeof(undef) ) {
			important = true;
		}
		if ( this.important_date && !important ) {
			return;
		}
		if ( important ) {
			this.important_date = true;
		}

		if (this.getEl('from') && this.getEl('to')) {
			if (this.getEl('from').value == '' && this.getEl('to').value == '') {
				var date, tmp;

				date = new Date();

				date.setTime(date.getTime() + 86400000 * from_today);
				tmp = parseInt(date.getMonth()) + 1;
				if (tmp < 10) {
					tmp = '0' + tmp;
				}
				this.getEl('from').value = tmp + '/' + date.getDate() + '/' + date.getFullYear();

				date.setTime(date.getTime() + 86400000 * nights);
				tmp = parseInt(date.getMonth()) + 1;
				if (tmp < 10) {
					tmp = '0' + tmp;
				}
				this.getEl('to').value = tmp + '/' + date.getDate() + '/' + date.getFullYear();
			}
		} else {
			setTimeout(this.myname + '.setDefResDate(' + from_today + ', ' + nights + ', ' + important + ')', 100);
		}
	}

	SiteReservation.prototype.selectCat = function(id, name, normal_adults, normal_children, pkg_id)
	{
		var undef, price, i, sel, tmp, opt, text, number, value;

		number = this.getEl('unit_num_' + id + '_' + pkg_id, true).value;

		if (number == -1) {
			this.getEl('unit_num_' + id + '_' + pkg_id).value = 0;
			alert(this.GD('si_block_category'));
			return;
		}
		if (typeof(undef) == typeof(normal_adults)) {
			normal_adults = 1;
		}
		if (typeof(undef) == typeof(normal_children)) {
			normal_children = 0;
		}
		if (typeof(undef) == typeof(pkg_id)) {
			pkg_id = 0;
		}
		price = this.priceForCurDate[id + '_' + pkg_id];

		if (this.bookRelation[id + '_' + pkg_id]) {
			for (i in this.bookRelation[id + '_' + pkg_id]) {

				sel = this.getEl('unit_num_' + i);
				value = sel.value;

				if (!this.basicSelectsData[i]) {
					tmp = {};
					count = 0;
					while (sel.hasChildNodes()) {
						tmp[sel.firstChild.value] = sel.firstChild.text;
						count++;
						sel.removeChild(sel.firstChild);
					}
					this.basicSelectsData[i] = {count: count, opts: tmp};
				}
				while(sel.hasChildNodes()) {
					sel.removeChild(sel.firstChild);
				}
				for (k = 0; k < this.basicSelectsData[i].count; k++) {
					opt = document.createElement('option');
					if (k < (this.basicSelectsData[i].count - (number * this.bookRelation[id + '_' + pkg_id][i]))) {
						text = document.createTextNode(this.basicSelectsData[i].opts[k]);
						opt.setAttribute('value', k);
					} else {
						text = document.createTextNode(k + ' *');
						opt.setAttribute('value', -1);
					}
					opt.appendChild(text);
					sel.appendChild(opt);
				}
				sel.value = value;
			}
		}
		if (typeof(undef) != typeof(id) && typeof(undef) != typeof(name)) {
			if (number > 0) {
				this.selectedCategories[id + '_' + pkg_id] = {name: name, price: price, normal_adults: normal_adults, normal_children: normal_children, number: number};
			} else {
				delete(this.selectedCategories[id + '_' + pkg_id]);
			}
		}
		this.printSelectedCatsHTML();
	}

	SiteReservation.prototype.printSelectedCatsHTML = function()
	{
		this.getEl('landlordterminal_selected_categories_top').innerHTML = this.getSelectedCatsHTML();
		try {
			this.getEl('landlordterminal_selected_categories_bottom').innerHTML = this.getSelectedCatsHTML();
		} catch (e) {}
	}

	SiteReservation.prototype.getSecureDeposit = function(price)
	{
		var ret = 0;

		switch (this.pp_data.CCVType) {
			case 'percent':
				ret += parseFloat(price.out * this.pp_data.CCVValue / 100);
				break;
			case 'night':
				ret += parseFloat(price.detailed[(this.pp_data.CCVValue - 1)]);
				break;
			case 'fixed':
				if (this.pp_data.CCVValue > price.out) {
					ret += parseFloat(price.out);
				} else {
					ret += parseFloat(this.pp_data.CCVValue);
				}
				break;
		}

		return ret;
	}

	SiteReservation.prototype.getSelectedCatsHTML = function()
	{
		var html, not_culced, res_price, tmp, cat, tmp_cat, res, pp_price, u, i, pkg_id, no_guest;

		html = '';
		not_culced = true;
		tmp_cat = '';
		res = {};
		pp_price = 0;
		no_guest = false;

		for (u in this.selectedUnits) {
			if (not_culced) {
				not_culced = false;
			}
			pkg_id = this.selectedUnits[u].pkg_id;

			if (tmp_cat != (this.selectedUnits[u].category + '_' + pkg_id)) {
				res_price = 0;
			}
			tmp_cat = this.selectedUnits[u].category + '_' + pkg_id;
			tmp = this.selectedCategories[tmp_cat];
			cat = this.availableCats[tmp_cat];

			price = this.getPrice(cat.Price, cat, this.selectedUnits[u].guests, cat.Packages[pkg_id]);

			if (!no_guest && price.no_guest) {
				no_guest = price.no_guest;
			}

			pp_price += this.getSecureDeposit(price);
			res_price += parseFloat(price.out);
			res[tmp_cat] = '<strong>' + tmp.number + ' ' + tmp.name + ' - ' + this.custom.Currency + ' ' + myParseFloat(res_price) + price.postfix + '</strong><br />';
		}

		this.no_guest = no_guest;

		if (this.getEl('ppn_price_box')) {
			this.getEl('ppn_price_box').innerHTML = pp_price.toFixed(2);
		}
		if (this.pp_data.CCVType == 'no_ccv') {
			this.pp_notification = '';
		} else if (this.pp_data.CCVType == 'ccv_only') {
			this.pp_notification = this.GD('si_ccv_notification').replace(/\[:MASK:\]/, this.billing_statement);
		} else if (this.pp_data.CCVType == 'ccv_luhn') {
			this.pp_notification = this.GD('si_ccv_luhn_notif');
		} else {
			this.pp_notification = this.GD('si_ccc_notification').replace(/\[:PRICE:\]/, (this.custom.Currency + ' <span id="ppn_price_box">' + pp_price.toFixed(2) + '</span>')).replace(/\[:MASK:\]/, this.billing_statement);
		}

		if (not_culced) {
			for (i in this.selectedCategories) {

				tmp = this.availableCats[i];
				tmp_cat = this.selectedCategories[i];
				i = i.split('_');
				price = this.getPrice(tmp.Price, tmp, this.defaultGuests(tmp.NormalAdult), tmp.Packages[i[1]]);

				html += '' +
						'<strong>' + tmp_cat.number + ' ' + tmp_cat.name + ' - ' + this.custom.Currency + ' ' + myParseFloat(price.out * tmp_cat.number) + price.postfix + '</strong>' +
						'<br />';
			}
		} else {
			for (i in res) {
				html += '' +
						res[i];
			}
		}
		return html;
	}

	SiteReservation.prototype.guestsNumber = function(n, id, gt)
	{
		this.selectedUnits[id].guests[gt] = n;

		this.getEl('landlordterminal_selected_categories_full').innerHTML = this.getSelectedCatsHTML();
	}

	SiteReservation.prototype.categoriesInfoBox = function(s)
	{
		var html = '' +
		'' +
				'<div class="rwcf_requested_box" style="width: ' + (this.width - 20) +'px;">' +
					'<table cellspacing="0" cellpadding="0" border="0" width="100%">' +
						'<tr>' +
							'<td nowrap="nowrap"><strong>' + this.GD('requested') + ':&nbsp;</strong></td>' +
							'<td colspan="2">' + this.getDateRangeHTML(true) + '</td>' +
						'</tr>' +
						'<tr>' +
							'<td width="10%" nowrap="nowrap"><strong>' + this.GD('selected') + ':&nbsp;</strong></td>' +
							'<td width="80%">' +
								'<div id="landlordterminal_selected_categories_' + s + '">';
		if (s == 'full') {
			html += '' +
									this.getSelectedCatsHTML();
		}
		html += '' +
								'</div>' +
							'</td>' +
							'<td width="10%" style="vertical-align: bottom;">';
		if (s == 'top' || s == 'bottom') {
			html += '' +
								'<div class="rwcf_requested_box_submit">';
			if (this.custom.rwcf_InfoSubmitText) {
				html += '' +
									'<a href="#" onclick="' + this.myname + '.selectUnits(\'query\', {}); return false;">' + this.GD('book_selected') + '</a>';
			} else {
				html += '' +
									'<button onclick="' + this.myname + '.selectUnits(\'query\', {}); return false;">' + this.GD('book_selected') + '</button>';
			}
			html += '' +
								'</div>';
		} else {
			html += '' +
								'&nbsp;';
		}
		html += '' + 
							'</td>' +
						'</tr>';
		if (this.pp_notification) {
			html += '' + 
						'<tr>' +
							'<td colspan="3" id="pp_notification" style="padding: 10px 0px 10px 0px;">' +
								this.pp_notification +
							'</td>' +
						'</tr>';
		}
		html += '' + 
					'</table>' +
				'</div>';
		return html;
	}

	SiteReservation.prototype.imageThumb = function(id, in_image, pkg)
	{
		var html, more, onclick, pic, image;

		if (pkg) {
			image = pkg.Image[0];
			pkg_id = pkg.ID;
			more = true;
		} else if (in_image[0]) {
			image = in_image[0];
			pkg_id = 0;
			more = true;
		} else {
			image = false;
		}
		if (image) {
			onclick = ' style="cursor: hand; cursor: pointer;" onclick="' + this.myname + '.clickImageBig([\'' + join("', '", in_image) + '\'], 0, 1, ' + pkg_id + '); return false;"';
			pic = '<img src="' + this.host + join('75x75', image.split('[FOLDER]')) + '"' + onclick + ' width="75" height="75" border="0" alt="" />';
		} else {
			pic = '<img src="' + this.host + 'pics/no_photo.gif" width="75" height="75" border="0" alt="' + this.GD('no_photo') + '" />';
		}
		if (more) {
			more = '<a href="#"' + onclick + '>' + this.GD('more_photos') + '</a>';
		} else {
			more = '';
		}
		return '<div id="rwcf_picture_frame">' + pic + '<div style="display: block;">' + more + '</div></div>';
	}

	SiteReservation.prototype.clickImageBig = function(in_image, id, small, pkg_id)
	{
		var el, sub_el, i, html, width, height, thumb_width, thumb_height, image_count, left, top, scroll, tmp, image;

		el = this.getEl('landlordterminal_big_picture');
		sub_el = this.getEl('landlordterminal_big_picture_substrate');
		if (in_image == '') {
			el.style.display = 'none';
			sub_el.style.display = 'none';
			el.innerHTML = '';
			return;
		}
		image = [];

		if (pkg_id && this.pkg[pkg_id].Image.length) {
			for (i = 0; i < this.pkg[pkg_id].Image.length; i++) {
				image.push(this.pkg[pkg_id].Image[i]);
			}
		}
		for (i = 0; i < in_image.length; i++) {
			image.push(in_image[i]);
		}
		html = '';
		width = 400;
		height = 300;
		thumb_width = 50;
		thumb_height = 50;
		image_count = image.length;

if ( this.site_id == 231 ) {
	left = 75;
	top = 110;
}
else if ( this.site_id == 222 ) {
	left = 180;
	top = 110;
}
else {

		if (document.documentElement) {
			left = parseInt(document.documentElement.scrollLeft + ((getStageSize('x') - width) / 2));
			top = parseInt(document.documentElement.scrollTop + ((getStageSize('y') - (height + 80)) / 2));
		} else {
			left = parseInt(document.body.scrollLeft + ((getStageSize('x') - width) / 2));
			top = parseInt(document.body.scrollTop + ((getStageSize('y') - (height + 80)) / 2));
		}
		if (left < 0) {
			left = 0;
		}
		if (top < 0) {
			top = 0;
		}

}
		html += '' +
				'<table cellspacing="0" cellpadding="0" width="424" height="424" border="0" id="rwcf_placeholder">' +
					'<tr>' +
						'<td><img src="' + this.host + 'pics/1x1.gif" width="1" height="50" border="0" alt="" style="floar: right;" /></td>' +
						'<td style="text-align: right; font-size: 10px; padding: 3px;">' +
							'<a href="#" onclick="' + this.myname + '.clickImageBig(\'\', 0, ' + small + ', ' + pkg_id + '); return false;" id="rwcf_placeholder_close">' + this.GD('close') + '</a>' +
						'</td>' +
					'</tr>' +
					'<tr>' +
						'<td colspan="2" style="text-align: center;">' +
							'<img src="' + this.host + join('400x300', image[id].split('[FOLDER]')) + '" border="0" alt="" style="margin: 0px 5px 0px 5px;" />' +
						'</td>' +
					'</tr>';
		if (image_count > 1) {
			if (image_count > 3) {
				scroll = true;
			} else {
				scroll = false;
			}
			in_image = "['" + join("', '", in_image) + "']";

			html += '' +
					'<tr>' +
						'<td colspan="2" style="text-align: center; vertical-align: middle;">';
			if (scroll && (small > 1)) {
				html += '' +
							'<a href="#" onclick="' + this.myname + '.clickImageBig(' + in_image + ', ' + id + ', ' + (small - 1) + ', ' + pkg_id + '); return false;">' +
								'<img src="' + this.host + 'pics/si_arrow_left.gif" width="' + thumb_width + '" height="' + thumb_height + '" border="0" alt="" style="margin: 5px; display: inline;" />' +
							'</a>';
			} else {
				html += '' +
							'<img src="' + this.host + 'pics/1x1.gif" width="' + thumb_width + '" height="' + thumb_height + '" border="0" alt="" style="margin: 5px; display: inline;" />';
			}
			for (i = 0; i < image_count; i++) {
				if (i == id) {
					css_class = 'rwcf_active_thumb_border';
				} else {
					css_class = 'rwcf_inactive_thumb_border';
				}
				if (i >= (small - 1) && i <= (small + 1)) {
					html += '' +
							'<a href="#" onclick="' + this.myname + '.clickImageBig(' + in_image + ', ' + i + ', ' + small + ', ' + pkg_id + '); return false;">' +
								'<img src="' + this.host + join('75x75', image[i].split('[FOLDER]')) + '" width="' + thumb_width + '" height="' + thumb_height + '" alt="" style="margin: 5px; display: inline;" class="' + css_class + '" />' +
							'</a>';
				}
			}
			if (scroll && (small < (image_count - 2))) {
				html += '' +
							'<a href="#" onclick="' + this.myname + '.clickImageBig(' + in_image + ', ' + id + ', ' + (small + 1) + ', ' + pkg_id + '); return false;">' +
								'<img src="' + this.host + 'pics/si_arrow_right.gif" width="' + thumb_width + '" height="' + thumb_height + '" border="0" alt="" style="margin: 5px; display: inline;" />' +
							'</a>';
			} else {
				html += '' +
							'<img src="' + this.host + 'pics/1x1.gif" width="' + thumb_width + '" height="' + thumb_height + '" border="0" alt="" style="margin: 5px; display: inline;" />';
			}
			html += '' +
						'</td>' +
					'</tr>';
		} else {
			html += '' +
					'<tr>' +
						'<td colspan="2" style="text-align: center; vertical-align: middle;">' +
							'<img src="' + this.host + 'pics/1x1.gif" width="' + thumb_width + '" height="' + thumb_height + '" border="0" alt="" style="margin: 5px; display: inline;" />' +
						'</td>' +
					'</tr>';
		}
		html += '' +
				'</table>';
		sub_el.style.left = left + 'px';
		sub_el.style.top = top + 'px';
		sub_el.style.width = (width + 20) + 'px';
		sub_el.style.height = (height + 124) + 'px';
		sub_el.style.display = 'block';
		el.style.left = left + 'px';
		el.style.top = top + 'px';
		el.style.width = (width + 20) + 'px';
		el.style.display = 'block';
		el.innerHTML = html;
	}

	SiteReservation.prototype.moreUnitInfo = function(id, pkg_id)
	{
		var el, i;
		for (i = 1; i <= this.unitsDetails[id]; i++) {
			el = this.getEl('landlordterminal_more_unit_info_' + i + '_' + id + '_' + pkg_id);
			if (el.style.display == 'block') {
				el.style.display = 'none';
				this.getEl('landlordterminal_showhide_' + id).src = this.host + '/pics/si_down.gif';
			} else {
				el.style.display = 'block';
				this.getEl('landlordterminal_showhide_' + id).src = this.host + '/pics/si_up.gif';
			}
		}
	}

	SiteReservation.prototype.showHideUnitDetails = function(id)
	{
		if (this.getEl('landlordterminal_unit_body_box_info_' + id).style.display == 'block') {
			this.getEl('landlordterminal_unit_body_box_info_' + id).style.display = 'none';
			this.getEl('landlordterminal_unit_body_box_details_' + id).style.display = 'block';
		} else {
			this.getEl('landlordterminal_unit_body_box_info_' + id).style.display = 'block';
			this.getEl('landlordterminal_unit_body_box_details_' + id).style.display = 'none';
		}
	}

	SiteReservation.prototype.printContent = function(data)
	{
		var html = '';
		if (!this.dictionary) {
			this.dictionary = data.result.dictionary;
		}
		if (data.error.length == 0) {
			html += '' +
					this.getFormHTML(data.result.formTPL, data.result.record, data.result.FormID);
			if (data.result.FormID == 'rwcf') {
				html = '' +
					this.align(html, 'left');
			}
			this.step[0] = html;
			this.putHTML(this.step[0]);
		} else {
			this.mistake(data.error, 'fatal');
		}
		if (this.getEl('from').value == '' && this.getEl('to').value == '') {
			this.setDefResDate(14, 1, false);
		}
	}

/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////

	SiteReservation.prototype.printUnitHTML = function(d, number, customs, unit_details, total_number, pkg)
	{
		var i, k, html, name, to_user_title, pkg_id, cat, tmp, tmp2;

		html = '';
		name = '';
		to_user_title = this.getTitle(d.Description);

		if (typeof(undef) != typeof(pkg)) {
			if (pkg.Description && pkg.Description.title && pkg.Description.title[this.custom.LanguageID]) {
				to_user_title += ' ' + pkg.Description.title[this.custom.LanguageID];
			}
			pkg_id = pkg.ID;
		} else {
			pkg_id = 0;
			pkg = false;
		}
		cat = this.availableCats[d.Property + '_' + pkg_id];

		name = d.ID + '_' + pkg_id + '_k';
		this.formFields.push(name);
		html += '' +
				'<div class="bf_unit_box" style="width: ' + (this.width - 20) + 'px;">' +
					'<input type="hidden" name="' + name + '" id="' + name + '" value="' + pkg_id + '" />' +
					'<table cellspacing="0" cellpadding="0" width="100%" border="0" class="bf_unit_table_header">' +
						'<tr>' +
							'<td>' +
								this.GD('room_unit') + ' ' + number + ' - ' + to_user_title +
							'</td>' +
							'<td style="text-align: right; vertical-align: middle;">';
		if (customs.bf_UnitLinkToDetails == 'Y') {
			html += '' +
								'<a href="#" onclick="' + this.myname + '.showHideUnitDetails(' + number + '); return false;">' +
									this.GD('room_unit_details') + ' | ' + this.GD('cancellation_policy') +
								'</a>';
		} else {
			html += '' +
								'&nbsp;';
		}
		html += '' +
							'</td>' +
						'</tr>' +
					'</table>' +
					'<div style="display: block;" id="landlordterminal_unit_body_box_info_' + number + '" class="bf_unit_table">' +
						'<table cellspacing="0" cellpadding="0" width="' + (this.width - 200) + '" border="0" class="bf_unit_table">' +
							'<tr>' +
								'<td width="120" class="bf_unit_options" nowrap="nowrap">' + this.GD('guests') + ':</td>' +
								'<td width="' + (this.width - 320) + '" class="bf_unit_input">' +
									'<table cellspacing="0" cellpadding="0" width="" border="0">' +
										'<tr>';
		k = 1;
		for (i in this.guest_types) {
			tmp2 = 0;
			switch (this.guest_types[i].type) {
				case'adult':
					if (this.guest_types[i]['default']) {
						tmp2 = cat.NormalAdult;
					}
					tmp = cat.MaxAdult;
					break;
				case'child':
					if (this.guest_types[i]['default']) {
						tmp2 = cat.NormalChildren;
					}
					tmp = cat.MaxChildren;
					break;
				case'pet':
					if (this.guest_types[i]['default']) {
						tmp2 = 1;
					}
					tmp = 3;
					break;
			}
			name = d.ID + '_' + pkg_id + '_gt_' + i;
			this.formFields.push(name);

			html += '' +
											'<td style="vertical-align: middle;" nowrap="nowrap">' +
												this.guest_types[i].title + ':&nbsp;' +
											'</td>' +
											'<td style="vertical-align: middle;">' +
												'<select name="' + name + '" id="' + name + '" onchange="' + this.myname + '.guestsNumber(this.value, ' + d.ID + ', ' + this.guest_types[i].id + ');">';
			for (i = 0; i <= tmp; i++) {
				html += '' +
													'<option value="' + i + '"' + (i == tmp2 ? ' selected' : '') + '>' + i + '</option>';
			}
			html += '' +
												'</select>' +
												llt_unique_repeat('&nbsp;', 7) +
											'</td>';
			if (k == 2) {
				html += '' +
										'</tr>' +
										'<tr>';
				k = 1;
			} else {
				k++;
			}
		}
		if (k == 1) {
			html += '' +
											'<td>&nbsp;</td>';
		}
		html += '' +
										'</tr>' +
									'</table>' +
								'</td>' +
							'</tr>' +
							'<tr><td class="bung_fs1"><img src="' + this.host + 'pics/1x1.gif" border="0" width="1" height="1" alt="" /></td><td class="bf_unit_field_separator bung_fs1"><img src="' + this.host + 'pics/1x1.gif" border="0" width="1" height="1" alt="" /></td></tr>' +
							'<tr>' +
								'<td class="bf_unit_options" nowrap="nowrap">' + this.GD('preferences') + ':</td>' +
								'<td class="bf_unit_input">' +
									'<table cellspacing="0" cellpadding="0" width="" border="0">' +
										'<tr>' +
											'<td style="vertical-align: middle;" nowrap="nowrap">' +
												this.GD('available_for_disabled') + ':&nbsp;' +
											'</td>' +
											'<td style="vertical-align: middle;">';
		name = d.ID + '_' + pkg_id + '_d';
		this.formFields.push(name);
		tmp = 'N';
		for (i in cat.Disabled) {
			if (cat.Disabled[i] == 'Y') {
				tmp = 'Y';
			}
		}
		if (tmp == 'Y') {
			html += '' +
												'<select name="' + name + '" id="' + name + '">' +
													'<option value="N">' + this.GD('no') + '</option>' +
													'<option value="Y">' + this.GD('yes') + '</option>' +
												'</select>';
		} else {
			html += '' +
												'<input type="hidden" name="' + name + '" id="' + name + '" value="N" />' + this.GD('no');
		}
		html += '' +
											'</td>' +
											'<td nowrap="nowrap">' +
												llt_unique_repeat('&nbsp;', 7) +
											'</td>' +
											'<td style="vertical-align: middle;" nowrap="nowrap">' +
												this.GD('smoking') + ':&nbsp;' +
											'</td>' +
											'<td style="vertical-align: middle;">';
		name = d.ID + '_' + pkg_id + '_s';
		this.formFields.push(name);
		tmp = 'N';
		for (i in cat.Smoking) {
			if (cat.Smoking[i] == 'Y') {
				tmp = 'Y';
			}
		}
		if (tmp == 'Y') {
			html += '' +
												'<select name="' + name + '" id="' + name + '">' +
													'<option value="N">' + this.GD('no') + '</option>' +
													'<option value="Y">' + this.GD('yes') + '</option>' +
												'</select>';
		} else {
			html += '' +
												'<input type="hidden" name="' + name + '" id="' + name + '" value="N" />' + this.GD('no');
		}
		html += '' +
											'</td>' +
											'<td style="vertical-align: middle;">' +
												' <span class="bf_asterix">**</span>' +
											'</td>' +
											'<td><img src="' + this.host + 'pics/1x1.gif" width="1" height="24" alt="" border="0" /></td>' +
										'</tr>' +
									'</table>' +
								'</td>' +
							'</tr>';
		if (total_number > 1) {
			name = d.ID + '_' + pkg_id + '_f';
			this.formFields.push(name);
			html += '' +
							'<tr><td><img src="' + this.host + 'pics/1x1.gif" border="0" width="1" height="1" alt="" /></td><td class="bf_unit_field_separator"><img src="' + this.host + 'pics/1x1.gif" border="0" width="1" height="1" alt="" /></td></tr>' +
							'<tr>' +
								'<td class="bf_unit_options" nowrap="nowrap">' + this.GD('guest_first_name') + ':</td>' +
								'<td class="bf_unit_input"><input type="text" name="' + name + '" id="' + name + '" /></td>' +
							'</tr>';
			name = d.ID + '_' + pkg_id + '_l';
			this.formFields.push(name);
			html += '' +
							'<tr><td><img src="' + this.host + 'pics/1x1.gif" border="0" width="1" height="1" alt="" /></td><td class="bf_unit_field_separator"><img src="' + this.host + 'pics/1x1.gif" border="0" width="1" height="1" alt="" /></td></tr>' +
							'<tr>' +
								'<td class="bf_unit_options" nowrap="nowrap">' + this.GD('guest_last_name') + ':</td>' +
								'<td class="bf_unit_input"><input type="text" name="' + name + '" id="' + name + '" /></td>' +
							'</tr>';
			name = d.ID + '_' + pkg_id + '_p';
			this.formFields.push(name);
			html += '' +
							'<tr><td><img src="' + this.host + 'pics/1x1.gif" border="0" width="1" height="1" alt="" /></td><td class="bf_unit_field_separator"><img src="' + this.host + 'pics/1x1.gif" border="0" width="1" height="1" alt="" /></td></tr>' +
							'<tr>' +
								'<td class="bf_unit_options" nowrap="nowrap">' + this.GD('phone_number') + ':</td>' +
								'<td class="bf_unit_input"><input type="text" name="' + name + '" id="' + name + '" /></td>' +
							'</tr>';
		}
		html += '' +
						'</table>' +
					'</div>' +
					'<div style="display: none;" class="bf_unit_info_box" id="landlordterminal_unit_body_box_details_' + number + '">';
		for (var i in unit_details) {
			var prop = unit_details[i];
			if (typeof(prop) != 'string') {
				continue;
			}
			var prop_title = this.GD(unit_details[i]);

			if (d.Description[prop]) {
				var output = d.Description[prop][this.custom.LanguageID];

				if (pkg && pkg.Description && pkg.Description[prop] && pkg.Description[prop][this.custom.LanguageID]) {
					if (prop == 'description') {
						output += '<br /><br />' + pkg.Description[prop][this.custom.LanguageID];
					}
					if (prop == 'cancellation_policy') {
						output = pkg.Description[prop][this.custom.LanguageID];
					}
				}
				if (output != '') {
					html += '' +
						'<strong>' + prop_title + '</strong><br />' + this.strToOut(output);
				} else {
					html += '' +
						this.GD('no') + ' ' + prop_title;
				}
				html += '' +
						'<br /><br />';
			}
		}
		html += '' +
					'</div>' +
				'</div>';

		return html;
	}

	SiteReservation.prototype.printUnitConfirmHTML = function(d, number, customs, unit_details, total_number, pkg)
	{
		var html, name, to_user_title, pkg_id;

		html = '';
		name = '';
		to_user_title = this.getTitle(d.Description);

		if (typeof(undef) != typeof(pkg)) {
			if (pkg.Description && pkg.Description.title && pkg.Description.title[this.custom.LanguageID]) {
				to_user_title += ' ' + pkg.Description.title[this.custom.LanguageID];
			}
			pkg_id = pkg.ID;
		} else {
			pkg_id = 0;
			pkg = false;
		}

		html += '' +
				'<table cellspacing="0" cellpadding="0" width="" border="0">' +
					'<tr>' +
						'<td class="cp_unit_title">' +
							this.GD('room_unit') + ' ' + number + ' - ' + to_user_title +
						'</td>' +
						'<td style="vertical-align: middle;" class="cp_unit_link">' +
							'<a href="#" onclick="' + this.myname + '.showHideCancel(' + number + '); return false;">' +
								'<span id="landlordterminal_cancelation_policy_' + number + '">' + this.GD('show') + ' ' + this.GD('cancellation_policy') + '</span>' +
							'</a>' +
						'</td>' +
					'</tr>' +
				'</table>' +
				'<div style="display: none;" class="cp_unit_cancel" id="landlordterminal_unit_body_box_confirm_' + number + '">';

		if (pkg && pkg.Description && pkg.Description.cancellation_policy && pkg.Description.cancellation_policy[this.custom.LanguageID]) {
			html += '' +
					this.strToOut(pkg.Description.cancellation_policy[this.custom.LanguageID]);
		} else if (d.Description.cancellation_policy && d.Description.cancellation_policy[this.custom.LanguageID]) {
			html += '' +
					this.strToOut(d.Description.cancellation_policy[this.custom.LanguageID]);
		} else {
			html += '' +
					this.GD('no_cancellation_policy');
		}
		html += '' +
				'</div>' +
				'<div class="cp_unit_text">';
		if (total_number > 1) {
			html += '' +
					this.GD('si_guest') + ': <span salt="guest"></span> ; ' + this.GD('si_phone') + ': <span salt="phone"></span>' +
					'<br />';
		}
		html += '' +
					this.GD('guests') + ': <span salt="guests"></span>' +
					'<br />' +
					this.GD('si_available_for') + ' ' + this.GD('si_disabled') + ': <span salt="disabled"></span> <span class="cp_asterix">**</span>' +
					'<br />' +
					this.GD('si_smoking') + ': <span salt="smoking"></span> <span class="cp_asterix">**</span>' +
				'</div>';
		return html;
	}

	SiteReservation.prototype.printUnitThanksHTML = function(d, number, customs, unit_details, total_number, pkg)
	{
		var html, name, to_user_title, pkg_id;

		html = '';
		name = '';
		to_user_title = this.getTitle(d.Description);

		if (typeof(undef) != typeof(pkg)) {
			if (pkg.Description && pkg.Description.title && pkg.Description.title[this.custom.LanguageID]) {
				to_user_title += ' ' + pkg.Description.title[this.custom.LanguageID];
			}
			pkg_id = pkg.ID;
		} else {
			pkg_id = 0;
			pkg = false;
		}

		html += '' +
				'<div class="typ_unit_title">' + this.GD('room_unit') + ' ' + number + ' - ' + to_user_title + '</div>' +
				'<div class="typ_unit_facilities">' +
					'<strong>' + this.GD('room_facilities') + ':</strong>' +
					'<br />';
		try {
			if (d.Description.facilities[this.custom.LanguageID]) {
				html += '' +
					this.strToOut(d.Description.facilities[this.custom.LanguageID]);
			} else {
				html += '' +
					this.GD('no_facilities');
			}
		} catch (e) {
			html += '' +
					this.GD('no_facilities');
		}
		html += '' +
				'</div>';
		try {
			if (d.Description.directions[this.custom.LanguageID]) {
				html += '' +
				'<div class="typ_unit_directions">' +
					'<strong>' + this.GD('directions') + ':</strong>' +
					'<br />' +
					this.strToOut(d.Description.directions[this.custom.LanguageID]) +
				'</div>';
			}
		} catch (e) {}
		html += '' +
				'<div class="typ_unit_cancel">';
		if (pkg && pkg.Description && pkg.Description.cancellation_policy && pkg.Description.cancellation_policy[this.custom.LanguageID]) {
			html += '' +
					this.strToOut(pkg.Description.cancellation_policy[this.custom.LanguageID]);
		} else if (d.Description.cancellation_policy && d.Description.cancellation_policy[this.custom.LanguageID]) {
			html += '' +
					this.strToOut(d.Description.cancellation_policy[this.custom.LanguageID]);
		} else {
			html += '' +
					this.GD('no_cancellation_policy');
		}
		html += '' +
				'</div>' +
				'<div class="typ_unit_text">';
		if (total_number > 1) {
			html += '' +
					this.GD('si_guest') + ': <span salt="guest"></span> ; ' + this.GD('si_phone') + ': <span salt="phone"></span>' +
					'<br />';
		}
		html += '' +
					this.GD('guests') + ': <span salt="guests"></span>' +
					'<br />' +
					this.GD('si_available_for') + ' ' + this.GD('si_disabled') + ': <span salt="disabled"></span> <span class="cp_asterix">**</span>' +
					'<br />' +
					this.GD('si_smoking') + ': <span salt="smoking"></span> <span class="cp_asterix">**</span>' +
				'</div>';
		return html;
	}

/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////

	SiteReservation.prototype.getFormHTML = function(tpl, info, prefix)
	{
		var html = '';
		var form_url = '';
		var dir = 'V2';
		var spacer_num = 0;
		var tmp, td_attr, i, pair;
		if (prefix == 'scf') {
			if (info[prefix + '_BoxType'] != '') {
				dir = info[prefix + '_BoxType'];
			}
			form_url = info[prefix + '_ResultURL'];
		}
		if (prefix == 'rwcf') {
			dir = 'H2';
		}
		if (form_url != '') {
			tmp = form_url.split(/\?/);
			if ( tmp[1] ) {
				html += '' +
				'<form method="get" action="' + tmp[0] + '" id="' + prefix + '_form_id">';
				tmp = tmp[1].split(/&/);
				for ( i in tmp ) {
					if ( typeof(tmp[i]) != 'string' ) {
						continue;
					}
					pair = tmp[i].split(/=/);
					html += '' +
				'<input type="hidden" name="' + pair[0] + '" value="' + pair[1] + '" />';
				}
			}
			else {
				html += '' +
				'<form method="get" action="' + form_url + '" id="' + prefix + '_form_id">';
			}
		}
		html += '' +
					'<table cellspacing="0" cellpadding="0" id="' + prefix + '_box">';
		if (dir == 'H1' || dir == 'H2') {
			html += '' +
						'<tr>';
		}
		for (var i in tpl) {
// Culculating submit
			if (tpl[i].type == 'submit') {
				if (info[prefix + '_SubmitText'] == 'Y' || info[prefix + '_FormSubmitText'] == 'Y' || info[prefix + '_SubmitTextual'] == 'Y') {
					tpl[i].textual = true;

					if (form_url != '') {
						tpl[i].click = this.myname + '.getEl(\'' + prefix + '_form_id\').submit(); return false;';
					} else {
						tpl[i].click = this.myname + '.' + tpl[i].click + '; return false;';
					}
				} else {
					tpl[i].textual = false;

					if (form_url != '') {
						tpl[i].click = 'this.form.submit(); return false;';
					} else {
						tpl[i].click = this.myname + '.' + tpl[i].click + '; return false;';
					}
				}
			}
// Culculating title and field
			if (tpl[i].type == 'space') {
				spacer_num++;
			}
			td_attr = '';
			td_attr += ' class="' + prefix + '_title';
			if (spacer_num > 0) {
				td_attr += '_' + spacer_num;
			}
			td_attr += '" id="' + prefix + '_title_' + i + '"';
			tmp = this.getFormCell(i, tpl[i], prefix, spacer_num);
			switch (dir) {
				case('H1'):
					if (tmp.title == '') {
						html += '' +
							'<td>' + tmp.field + '</td>';
					} else if (tmp.field == '') {
						html += '' +
							'<td' + td_attr + '>' + tmp.title + '</td>';
					} else {
						html += '' +
							'<td' + td_attr + '>' + tmp.title + '</td><td>' + tmp.field + '</td>';
					}
					break;
				case('H2'):
					if (tmp.title == '') {
						html += '' +
							'<td><br />' + tmp.field + '</td>';
					} else if (tmp.field == '') {
						html += '' +
							'<td' + td_attr + '>' + tmp.title + '</td>';
					} else {
						html += '' +
							'<td' + td_attr + '>' + tmp.title + '<br />' + tmp.field + '</td>';
					}
					break;
				case('V1'):
					if (tmp.title == '') {
						html += '' +
						'<tr><td>' + tmp.field + '</td></tr>';
					} else if (tmp.field == '') {
						html += '' +
						'<tr><td' + td_attr + '>' + tmp.title + '</td></tr>';
					} else {
						html += '' +
						'<tr><td' + td_attr + '>' + tmp.title + '</td></tr>' +
						'<tr><td>' + tmp.field + '</td></tr>';
					}
					break;
				case('V2'):
					html += '' +
						'<tr>';
					if (tmp.title == '') {
						html += '' +
							'<td colspan="2">' + tmp.field + '</td>';
					} else if (tmp.field == '') {
						html += '' +
							'<td colspan="2"' + td_attr + '>' + tmp.title + '</td>';
					} else {
						html += '' +
							'<td' + td_attr + '>' + tmp.title + '</td>' +
							'<td>' + tmp.field + '</td>';
					}
					html += '' +
						'</tr>';
					break;
				default:
					this.mistake('Unknown form direction', 'fatal');
					break;
			}
		}
		if (dir == 'H1' || dir == 'H2') {
			html += '' +
						'</tr>';
		}
		html += '' +
					'</table>';
		if (form_url != '') {
			html += '' +
					'</form>';
		}
		return html;
	}

	SiteReservation.prototype.setDepartureDate = function()
	{
		var d, tmp;

		tmp = this.getEl('from').value.split(/\//);

		d = new Date();
		d.setYear(parseInt(tmp[2]));
		d.setMonth(parseInt(tmp[0]) - 1);
		d.setDate(parseInt(tmp[1]) + 1);

		this.getEl('to').value = (d.getMonth() + 1) + '/' + d.getDate() + '/' + d.getFullYear();
	}

	SiteReservation.prototype.getFormCell = function(name, field, prefix, spacer_num)
	{
		var tmp = { 'title' : '' , 'field' : '' };
		field.title = this.GD(field.title);
		switch (field.type) {
			case 'text':
				this.formFields.push(name);
				tmp.title = '<strong>' + field.title + ':</strong>';
				tmp.field = '<input type="text" name="' + name + '" id="' + name + '" value="" class="' + prefix + '_input' + (spacer_num > 0 ? '_' + spacer_num : '') + '" style="width: ' + field.width + 'px;" />';
				if (typeof(field.help) != 'undefined') {
					tmp.field += '&nbsp;&nbsp;&nbsp;<span style="font-size: 100%; font-weight: bold;">(' + this.GD(field.help) + ')</span>';
				}
				break;
			case 'space':
				tmp.title = '<strong>' + field.title + ':</strong>';
				tmp.field = '';
				break;
			case 'select':
				this.formFields.push(name);
				tmp.title = '<strong>' + field.title + ':</strong>';

				tmp.field = '';
				tmp.field += '<select name="' + name + '" id="' + name + '"' + (field.width ? ' class="' + prefix + '_select' + (spacer_num > 0 ? '_' + spacer_num : '') + '" style="width: ' + (++field.width + 3) + 'px;"' : '') + '>';
				for (var i in field.option) {
					tmp.field += '<option value="' + i + '">' + field.option[i] + '</option>';
				}
				tmp.field += '</select>';
				break;
/*
			case 'date':
				this.formFields.push(name + '_d');
				this.formFields.push(name + '_m');
				this.formFields.push(name + '_y');
				tmp.title = '<strong>' + field.title + ':</strong>&nbsp;(' + this.GD('mm_dd_yyyy') + ')';

				if (field.value != '') {
					v = field.value.split('-');
				}
				tmp.field = '<div nowrap="nowrap">';
				tmp.field += '<select name="' + name + '_d" id="' + name + '_d" class="' + prefix + '_select' + (spacer_num > 0 ? '_' + spacer_num : '') + '">';
				for (var i = 1; i <= 31; i++) {
					tmp.field += '<option value="' + i + '"' + (v[0] == i ? ' selected' : '') + '>' + i + '</option>';
				}
				tmp.field += '</select> <select name="' + name + '_m" id="' + name + '_m" class="' + prefix + '_select' + (spacer_num > 0 ? '_' + spacer_num : '') + '">';
				for (var i = 1; i <= 12; i++) {
					tmp.field += '<option value="' + i + '"' + (v[1] == i ? ' selected' : '') + '>' + landlordterminal_month[i-1] + '</option>';
				}
				tmp.field += '</select> <select name="' + name + '_y" id="' + name + '_y" class="' + prefix + '_select' + (spacer_num > 0 ? '_' + spacer_num : '') + '">';
				for (var i = field.start; i <= field.end; i++) {
					tmp.field += '<option value="' + i + '"' + (v[2] == i ? ' selected' : '') + '>' + i + '</option>';
				}
				tmp.field += '</select>';
				tmp.field += '</div>';
				break;
/**/
			case 'date':
				this.formFields.push(name);
				tmp.title = '<strong>' + field.title + ':</strong>&nbsp;(' + this.GD('mm_dd_yyyy') + ')';

				if (!field.callback) {
					field.callback = '';
				}

				tmp.field = '<div style="position: absolute;"><div id="calendar_box_' + name + '" style="position: absolute; left: 0px; top: 20px; width: 16px; height: 16px;"></div></div>';
				tmp.field += '<input type="text" name="' + name + '" id="' + name + '" value="' + field.value + '" onclick="lltUniqueCalendarControlShow(\'' + name + '\', \'' + field.callback + '\', false, true);" onblur="setTimeout(\'lltUniqueCalendarControlClose(\\\'' + name + '\\\');\', 300);" style="width: ' + field.width + 'px;" />';
				break;
/**/
			case 'submit':
				tmp.title = '';
				if (field.textual) {
					tmp.field = '<a href="#" onclick="' + field.click + '" id="' + prefix + '_submit' + (spacer_num > 0 ? '_' + spacer_num : '') + '">' + field.title + '</a>';
				} else {
					tmp.field = '<button onclick="' + field.click + '" id="' + prefix + '_submit' + (spacer_num > 0 ? '_' + spacer_num : '') + '">' + field.title + '</button>';
				}
				if (field.align != '') {
					tmp.field = '<div style="text-align: ' + field.align + ';">' + tmp.field + '</div>';
				}
				break;
			default:
				this.mistake('Unknown type of field - ' + field.type, 'fatal');
				break;
		}
		return tmp;
	}

/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////

	SiteReservation.prototype.putHTML = function(html)
	{
		this.contentEl.innerHTML = '<center>' + html + '</center>';
	}

	SiteReservation.prototype.mistake = function(error, type)
	{
		if (error == '') {
			this.setStatus('');
			this.getEl('landlordterminal_notice_error').style.display = 'none';
			this.getEl('landlordterminal_notice_error').innerHTML = '';
			return;
		}
		var html = '';
		if (isArray(error)) {
			html += '' +
					join('<br />', error);
		} else {
			html += '' +
					error;
		}
		this.setStatus('Error');
		if (type == 'fatal') {
			this.putHTML('<div class="landlordterminal_fatal_error">' + html + '</div>');
		} else {
			this.getEl('landlordterminal_notice_error').style.display = 'block';
			this.getEl('landlordterminal_notice_error').innerHTML = html;
		}
	}

	SiteReservation.prototype.setStatus = function(str)
	{
		if (str == '') {
			str = '&nbsp;';
		} else {
			this.journal.push(' - '.str);
		}
		this.getEl('landlordterminal_status').innerHTML = str;
	}

	SiteReservation.prototype.viewJournal = function()
	{
		alert(join("\n\n", this.journal));
	}

	SiteReservation.prototype.showHideCancel = function(number)
	{
		if (this.getEl('landlordterminal_unit_body_box_confirm_' + number).style.display == 'block') {
			this.getEl('landlordterminal_unit_body_box_confirm_' + number).style.display = 'none';
			this.getEl('landlordterminal_cancelation_policy_' + number).innerHTML = this.GD('show') + ' ' + this.GD('cancellation_policy');
		} else {
			this.getEl('landlordterminal_unit_body_box_confirm_' + number).style.display = 'block';
			this.getEl('landlordterminal_cancelation_policy_' + number).innerHTML = this.GD('hide') + ' ' + this.GD('cancellation_policy');
		}
	}

	SiteReservation.prototype.myGET = function()
	{
		var pair = location.search.substr(1).split('&');
		var tmp, tmp2;
		var my_vars = ['from', 'from_d', 'from_m', 'from_y', 'to', 'to_d', 'to_m', 'to_y'];
		tmp2 = {};
		for (var i = 0; i < pair.length; i++) {
			tmp = pair[i].split('=');
			if (in_array(tmp[0], my_vars)) {
				tmp2[tmp[0]] = tmp[1];
			}
		}
		if (tmp2['from']) {
			this.get['from'] = unescape(tmp2['from']);
		} else if (tmp2['from_m'] && tmp2['from_d'] && tmp2['from_y']) {
			this.get['from'] = tmp2['from_m'] + '/' + tmp2['from_d'] + '/' + tmp2['from_y'];
		} else if (this.get['from_m'] && this.get['from_d'] && this.get['from_y']) {
			this.get['from'] = this.get['from_m'] + '/' + this.get['from_d'] + '/' + this.get['from_y'];
		} else {
			this.get['from'] = false;
		}
		if (tmp2['to']) {
			this.get['to'] = unescape(tmp2['to']);
		} else if (tmp2['to_m'] && tmp2['to_d'] && tmp2['to_y']) {
			this.get['to'] = tmp2['to_m'] + '/' + tmp2['to_d'] + '/' + tmp2['to_y'];
		} else if (this.get['to_m'] && this.get['to_d'] && this.get['to_y']) {
			this.get['to'] = this.get['to_m'] + '/' + this.get['to_d'] + '/' + this.get['to_y'];
		} else {
			this.get['to'] = false;
		}
/*
		if (debug()) {
			alert(var_dump(this.get));
		}
*/
	}

	SiteReservation.prototype.backToStep = function(number)
	{
		this.putHTML(this.step[number]);
		if (number == 1) {
			this.pp_notification = '';
			this.formFields = ['from', 'to'];

			for (var i in this.selectedUnits) {
				this.getEl('unit_num_' + this.selectedUnits[i].category + '_' + this.selectedUnits[i].pkg_id).value = parseInt(this.getEl('unit_num_' + this.selectedUnits[i].category + '_' + this.selectedUnits[i].pkg_id).value) + 1;
			}
			this.selectedUnits = {};
			this.printSelectedCatsHTML();
			this.mistake('', 'notice');
		}
		if (number == 2) {
			for (var i in this.formValues[2]) {
				try {
					this.getEl(i).value = this.formValues[2][i];
				} catch (e) {}
			}
/*
			for (var i in this.selectedUnits) {
				this.adultsNumber(this.formValues[2][i + '_' + this.selectedUnits[i].pkg_id + '_a'], i);
			}
*/
			this.getEl('landlordterminal_selected_categories_full').innerHTML = this.getSelectedCatsHTML();
		}
		this.mistake('', 0);
	}
/*

	SiteReservation.prototype.getRuleID = function(cat_id)
	{
		if (this.rule[cat_id]) {
			return this.rule[cat_id].ID;
		} else {
			return 0;
		}
	}
	SiteReservation.prototype.useDiscount = function(price, cat_id, pkg)
	{
		var discount, d, return_discount;

		discount = 0;
		price = parseFloat(price);

		if (!pkg || pkg.Discounts) {
			if (this.rule[cat_id]) {
				d = this.rule[cat_id];
			} else {
				return {'price': price, 'discount': 0};
			}
			if (d.Type == 'percent') {
				discount = parseFloat(price * d.Discount / 100);
			} else {
				discount = parseFloat(d.Discount);
			}
			return_discount = false;

		} else if (pkg.DiscountData) {
			d = pkg.DiscountData;

			if (d.Type == 'percent') {
				discount = parseFloat(price * d.Value / 100);
			} else {
				discount = parseFloat(d.Discount);
			}
			return_discount = true;
		}
		if (discount > price) {
			price = 0;
		} else if (discount > 0) {
			price -= discount;
		}
		if (return_discount) {
			return {'price': price, 'discount': discount};
		} else {
			return {'price': price, 'discount': 0};
		}
	}
*/
	SiteReservation.prototype.getDateRangeHTML = function(show_nights)
	{
		if (this.dateRange == null) {
			this.mistake('Unknown data range', 'fatal');
			return;
		}
		var html = '' +
		this.GD('arrival') + ': ' + this.dateRange.from_d + '/' + this.dateRange.from_m + '/' + this.dateRange.from_y + ', ' + this.GD('departure') + ': ' + this.dateRange.to_d + '/' + this.dateRange.to_m + '/' + this.dateRange.to_y;
		if (show_nights) {
			html += '' +
					', ' + this.GD('nights') + ': ' + this.nights;
		}
		return html;
	}

	SiteReservation.prototype.GD = function(str, data)
	{
		var undef;
		var ret;
		if (typeof(undef) == typeof(data)) {
			data = [];
		}
		if (this.dictionary[str]) {
			ret = this.dictionary[str];
		} else {
			ret = str;
		}
		for (var i in data) {
			i = parseInt(i);
			ret = eval('ret.replace(/\\[:' + (i + 1) + ':\\]/, "' + data[i] + '");');
		}
		return ret;
	}

	SiteReservation.prototype.getTitle = function(d)
	{
		if (!d || !d.title || !d.title[this.custom.LanguageID]) {
			return this.GD('si_untitled');
		} else {
			return d.title[this.custom.LanguageID];
		}
	}

	SiteReservation.prototype.strToOut = function(str)
	{
		if (!str) {
			return '';
		}
		return str.replace(/\n/g, '<br />');
	}

	SiteReservation.prototype.encryptRSA = function(string)
	{
		setMaxDigits(28);
		key = new RSAKeyPair("380ed8c1e67969cd2260700fce17b21cd4b30bddafde39c05", "", "7f2bdcd512683b08481759a51984d6af5d858d639b3f44557");
		return encryptedString(key, string + '\x01');
	}

	SiteReservation.prototype.changeTermCond = function(el)
	{
		if (el.checked) {
			this.disabled_next = false;
		} else {
			this.disabled_next = true;
		}
	}

	SiteReservation.prototype.clickTermCond = function()
	{
		if (this.getEl('term_cond_box').style.display == 'block') {
			this.getEl('term_cond_box').style.display = 'none';
		} else {
			this.getEl('term_cond_box').style.display = 'block';
		}
	}

	SiteReservation.prototype.printTermCond = function()
	{
		window.open(this.host + 'integration/terms_cond.php?id=' + this.site_id, 'print', 'width:500;height:300;statusbar=no;toolbar:no');
	}

	SiteReservation.prototype.align = function(html, align)
	{
		return '<div style="width: ' + this.width + 'px; text-align: ' + align + ';">' + html + '</div>';
	}

	SiteReservation.prototype.normilize = function(obj)
	{
		var ret, i, tmp1, tmp2;
		ret = {};
		ret.info = {};
		for (i in obj) {
			tmp1 = i.match(/(\d+)_(\d+)_([k,f,l,p,d,s])/)
			tmp2 = i.match(/(\d+)_(\d+)_gt_(\d+)/)

			if (tmp1) {
				if (!ret[tmp1[1]]) {
					ret[tmp1[1]] = {};
				}
				ret[tmp1[1]][tmp1[3]] = obj[i];
			} else if (tmp2) {
				if (!ret[tmp2[1]]) {
					ret[tmp2[1]] = {};
				}
				if (!ret[tmp2[1]].g) {
					ret[tmp2[1]].g = '';
				}
				ret[tmp2[1]].g += tmp2[3] + ':' + obj[i] + ';';

			} else if (i == 'cc_number' || i == 'cc_exp' || i == 'cc_csv') {
				ret.info[i] = this.encryptRSA(obj[i]);
			} else {
				ret.info[i] = obj[i];
			}
		}
		return ret;
	}

	SiteReservation.prototype.completeBookRelation = function(data)
	{
/*
	OBJECT "640" 
		309 = 2
		OBJECT "pkg" 
			0 = 16

	OBJECT "309" 
		640 = 1

	OBJECT "312" 
		OBJECT "pkg" 
			0 = 16
*/
		ret = {};

		for (var i in data) {
			if (isNaN(parseInt(i))) {
				continue;
			}
			mod = {};
			for (var j in data[i]) {
				if (j == 'pkg') {
					continue;
				}
				if (data[j] && data[j].pkg) {
					for (k in data[j].pkg) {
						mod[j + '_' + data[j].pkg[k]] = data[i][j];
					}
				}
				mod[j + '_0'] = data[i][j];
			}
			if (data[i].pkg) {
				for (k in data[i].pkg) {
					if (typeof(data[i].pkg[k]) == 'function') {
						continue;
					}
					for (j in mod) {
						if (!ret[i + '_' + data[i].pkg[k]]) {
							ret[i + '_' + data[i].pkg[k]] = {};
						}
						if (i != data[i].pkg[k][j]) {
							ret[i + '_' + data[i].pkg[k]][j] = mod[j];
						}
					}
				}
			}
			ret[i + '_0'] = mod;

			mod = {};
			if (data[i].pkg) {
				data[i].pkg.push(0);

				for (k in data[i].pkg) {
					if (typeof(data[i].pkg[k]) == 'function') {
						continue;
					}
					for (j in data[i].pkg) {
						if (typeof(data[i].pkg[j]) == 'function') {
							continue;
						}
						if (k != j) {
							if (!mod[data[i].pkg[k]]) {
								mod[data[i].pkg[k]] = {};
							}
							mod[data[i].pkg[k]][i + '_' + data[i].pkg[j]] = 1;
						}
					}
				}
				for (k in data[i].pkg) {
					if (typeof(data[i].pkg[k]) == 'function') {
						continue;
					}
					for (j in mod[data[i].pkg[k]]) {
						if (!ret[i + '_' + data[i].pkg[k]]) {
							ret[i + '_' + data[i].pkg[k]] = {};
						}
						ret[i + '_' + data[i].pkg[k]][j] = mod[data[i].pkg[k]][j];
					}
				}
			}
		}

		return ret;
	}

	SiteReservation.prototype.getEl = function(el, alert_on_error)
	{
		if ( document.getElementById(el) ) {
			return document.getElementById(el);
		}
		else {
			var undef
			if ( typeof(undef) != typeof(alert_on_error) && alert_on_error ) {
				alert(el);
			}
		}
	}

	SiteReservation.prototype.doLoad = function(force, cach, type, data)
	{
		if (debug()) {
			data['debug'] = true;
		}
		this.setStatus('Loading data...');
		var _this = this;
		var req = new Subsys_JsHttpRequest_Js();
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				if (req.responseJS) {
					switch (type) {
						case 'get_data':
							_this.setStatus('');
							_this.printContent(req.responseJS);
							break;
						case 'check':
							_this.check('answer', req.responseJS, '');
							break;
						case 'select_units':
							_this.selectUnits('answer', req.responseJS);
							break;
						case 'reserv':
							_this.finish('answer', req.responseJS);
							break;
						default:
							_this.mistake('unknown type', 'fatal');
							break;
					}
				}
//				_this.getEl('debug').innerHTML = req.responseText;
			}
		}
		req.caching = cach;
		req.open('GET', _this.host + 'integration/load.php', true);
		req.send({ data: data, act: type });
	}
/////////////////////////////////////////////////////////////////////
/// Call ////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
	var llt_res_object_unique = new SiteReservation();
	document.llt_res_object_unique = llt_res_object_unique;
	llt_res_object_unique.myname = 'llt_res_object_unique';
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
