﻿/**
 * Переопределение формирования анонса горящих туров
 */

var __renderCount = 0;

if (typeof _scr != 'undefined')
	$.extend(_scr,
	{
		fillTours: function(data){
			var html = '';
			if (data.length > 0) for (var i = 0; i < mSettings.sc.resultLength; i++) html += _scr.renderItem(data[i]);
			else html = '<div class="ht_scr_no_data">Нет данных.</div>';
			$('#ht_showcase_wrapper').html(html);
		},
		
		renderItem: function(item){
			var html = '';
			__renderCount++;
			
			if (typeof (item)=='undefined') return '';
			
			html += '<div class="ht_scr_item'+((__renderCount==mSettings.sc.resultLength)?" last":"")+'">';
			html += 	'<a class="picturelink" href="' + _scr.getQueryString(item.CountryId) + '" rel="nofollow">'+item.CountryName+', '+item.Nights+' ночей, '+item.ResortName+'</a>';
			html +=		'<p class="item_price"> от '+item.MinPrice+'</p>';
			html +='</div>';
			
//			html += '<div class="ht_scr_item"><center>';
//			html += '<div class="burningPreview">';
//			html +='<a href="' + _scr.getQueryString(item.CountryId) + '" rel="nofollow">';
//			html +='<img src="' + item.CountryImageUrl + '" alt="' + item.CountryName + '" width="114" height="89"/>';
//			html +='<img src="/extend/platforms/website/templates/default/img/whiteimg.png" alt="" width="114" height="89"/>';
//			html +='</a>';
//			html +='</div></center>';
//			html += '<a href="' + _scr.getQueryString(item.CountryId) + '" rel="nofollow">';
//			html += item.CountryName+' <br/>';
//			if (item.MinPrice)
//				html += ' от ' + item.MinPrice;
//			html += '</a><br />';
//			html +='</div>';
			return html;
		}
	});


/**
 * Переопределение открытия нового окна из формы быстрого поиска (мини-форма)
 */
if (typeof _sf != 'undefined')
	$.extend(_sf,
	{
		loadToursOnNewPage: function(){
			document.location.href = (mSettings.sm.resultPage || mSettings.modulePath + 'html/SearchResultNoTO.htm') + _sf.getQueryString();
			return false;
		},
		
		setListMsg: function (list, msg, css)
		{
			if (list != null)
			{
				if (css == undefined || css == null) { css = 'sm_listComment'; }
				$('#' + list.id).html('<li class="' + css + '">' + msg + '</li>');
			}
		},
		
		fillList: function (list, data, clickEventName)
		{
			if (list != null)
			{
				if (data != null && data.length > 0)
				{
					if (list == _sf.tOperators ) _sf.computeOpHint(1,data);
					$('#' + list.id).html('');
					var html = '';
					for (var i = 0; i < data.length; i++)
					{
						if (list == _sf.tOperators && data[i].Enabled)
						{
							html += '<li><input ' + (clickEventName ? 'onclick="' + clickEventName + '();" ' : '') + 'type="checkbox" id="' + list.id + data[i].Id + '" value="' + data[i].Id + '" /><label for="' + list.id + data[i].Id + '">' + data[i].Name + '</label></li>';
						}
					}
					if (list == _sf.tOperators) html += '<li><label>——————— вылетов нет ———————</label></li>';
					for (var i = 0; i < data.length; i++)
					{
						if (list == _sf.tOperators && !data[i].Enabled)
						{
							html += '<li><input disabled="disabled" type="checkbox" id="' + list.id + data[i].Id + '" value="' + data[i].Id + '" /><label class="sm_disabled" for="' + list.id + data[i].Id + '">' + data[i].Name + '</label></li>';
						}
						else if(list != _sf.tOperators)
						{
							html += '<li><input ' + (clickEventName ? 'onclick="' + clickEventName + '();" ' : '') + 'type="checkbox" id="' + list.id + data[i].Id + '" value="' + data[i].Id + '" /><label for="' + list.id + data[i].Id + '">' + data[i].Name + '</label></li>';
						}
					}
					$('#' + list.id).html(html);
				}
				else _sf.setListMsg(list, 'Список пуст');
			}
		}
	});

