function deleteSynonym(obj, synonymid) {
    var obj = $(obj);
    if (!confirm('Вы уверены, что хотите удалить синоним?')) return false;
    $.getJSON(base + 'kbtag.ivp/deletesynonym'
		, { json: true, synonymid: synonymid, timestamp: new Date().toString() }
		, function(result) {if (result.hasOwnProperty('IsOK') && !result.IsOK) alert(result.Description); else obj.parents('ul:first').children('li[rel="'+synonymid+'"]').remove(); });
    return false;
}

function toggle() {
	$('#newsynonymholder, #newsynonymlink').toggle();
	return false;
}

function addSynonym(link, tagid) {
	var input = $(link).prev();
	var synonym = input.val();
	if (synonym.length > 0)
		$.getJSON(base + 'kbtag.ivp/addsynonym'
			, { json: true, tagid: tagid, synonym: synonym, timestamp: new Date().toString() }
			, function(result) {
				if (result.hasOwnProperty('IsOK') && !result.IsOK) 
					alert(result.Description); 
				else {
					$('#synonymlistholder').load(base + 'kbtag.ivp/getsynonymlist/'+tagid, {nolayout: true, timestamp: new Date().toString() }
						, function() {
							toggle();
							input.val('');
						}
					);
				}
			});
    return false;
}

function selectTagFieldValueLanguage() {
    var url = 'fieldlanguage.ivp/load?required=true&table=KBTags&field=ValueXml&id=' + $('#id').val();
    openDialog(url, 'selectlanguage', { width: 900, height: 650 });
    return false;
}