﻿/*********************************************
	<id>M-DVD:AutoCompleteSearch</id>
	<name>Auto Complete Search</name>
	<version>1.0</version>
	<type>modification</type>
*********************************************/


function smf_MemberSend(oOptions)
{
	this.opt = oOptions;
	this.oMemberAutoSuggest = null;
	this.oMemberListContainer = null;
	this.init();
}

smf_MemberSend.prototype.init = function()
{
	var oUserSpec = document.getElementById(this.opt.sUserSpecControlId);
	this.oUserSpecAutoSuggest = new smc_AutoSuggest({
		sSelf: this.opt.sSelf + '.oUserSpecAutoSuggest',
		sSessionId: this.opt.sSessionId,
		sSuggestId: 'userspec',
		sControlId: this.opt.sUserSpecControlId,
		sSearchType: 'member',
		sPostName: 'recipient_userspec',
		sURLMask: 'action=profile;u=%item_id%',
		sTextDeleteItem: this.opt.sTextDeleteItem,
		bItemList: true,
		sItemListContainerId: 'userspec_item_list_container',
		aListItems: this.opt.aUserSpecRecipients
	});
	this.oUserSpecAutoSuggest.registerCallback('onBeforeAddItem', this.opt.sSelf + '.callbackAddItem');
}

smf_MemberSend.prototype.callbackAddItem = function(oAutoSuggestInstance, sSuggestId)
{
	this.oUserSpecAutoSuggest.deleteAddedItem(sSuggestId);
	return true;
}

function smf_WordsSearchSend(oOptions)
{
	this.opt = oOptions;
	this.oWordsAutoSuggest = null;
	this.oWordsListContainer = null;
	this.init();
}

smf_WordsSearchSend.prototype.init = function()
{
	var oSearch = document.getElementById(this.opt.sSearchControlId);
	this.oSearchAutoSuggest = new smc_AutoSuggest({
		sSelf: this.opt.sSelf + '.oSearchAutoSuggest',
		sSessionId: this.opt.sSessionId,
		sSuggestId: 'search',
		sControlId: this.opt.sSearchControlId,
		sSearchType: 'words',
		sPostName: 'recipient_search',
		sURLMask: 'action=search2;search=%item_name%',
		sTextDeleteItem: this.opt.sTextDeleteItem,
		bItemList: true,
		sItemListContainerId: 'search_item_list_container',
		aListItems: this.opt.aSearchRecipients
	});
	this.oSearchAutoSuggest.registerCallback('onBeforeAddItem', this.opt.sSelf + '.callbackAddItem');
}

smf_WordsSearchSend.prototype.callbackAddItem = function(oAutoSuggestInstance, sSuggestId)
{
	this.oSearchAutoSuggest.deleteAddedItem(sSuggestId);
	return true;
}