APPEND_DEFAULT_LOGO = false;

/**
 * Применяет свойства к виджету, к примеру выводит выбранную иконку вместо дефолтной
 * @param widget
 * @param properties
 */
function append_properties(widget, properties) {
    var name = widget.attr('name');
    var content = widget.find('.content');

    if ((name=='Common.Logo') && properties.image_url) {
        content.parent().addClass('logo');
        content.html('<img src="' + properties.image_url + '" /> ');
    }
    else if ((name=='Common.Image') && properties.image_url) {
        content.parent().addClass('w-button');
        content.html('<img src="' + properties.image_url + '" /> ');
    }
    else if (properties['default'] && APPEND_DEFAULT_LOGO) {
        content.parent().addClass('logo');
        content.html('<img src="' + properties['default'] + '" />');
    }
    if (name=='Common.Menu' || name=='Common.RSSReader' || name=='Common.Link' || name=='Common.IFrame' || name=='Common.DynamicButton') {
        if (properties.image) {
            content.html('<img src="' + properties.image + '" class="h16 rmargin"/>' + properties.label);
        }
        else {
            content.html(properties.label);
        }
    }
    
    if (name=='Common.Radio') {
        content.html('<img src="/static/i/icon-volume-on.png" class="rmargin h16"/>' + properties.label);
    }

//    Согласно MBR-482 теперь не нужна настройка firstService
//    if (name=='Common.MailChecker') {
//        var icons = {
//            'Yandex': '/static/i/favicons/mail/yandex.ico',
//            'Gmail': '/static/i/favicons/mail/gmail.png',
//            'Rambler': '/static/i/favicons/mail/rambler.png',
//            'MailRu': '/static/i/favicons/mail/mail_ru.ico'
//        };
//        if (icons[properties.firstService]) {
//            content.find('img').attr('src', icons[properties.firstService]);
//        }
//
//    }

    if (name=='Common.SearchBar') {
        if (!properties.branded_search){
            $(widget).addClass('without-tetris');
        }
    }

    if (name=='Common.SearchBar') {
        if (!widget.parents('.pinned-right').length && properties.location=='right') {
            widget.detach().appendTo('.pinned-right');    
        } else if (!widget.parents('.pinned').length && properties.location=='left') {
            widget.detach().appendTo('.pinned');    
        }
    }
}


ODNOKLASSNIKI_FULL_WIDGET = '<div class="w-odnokl">' +
'<div class="withsplit" style="margin-right:10px;">' +
'	<span class="splitbutton_content">' +
'		<img class="icon" src="/static/i/favicons/odnoklassniki.ico">' +
'		<span>Моя страница</span>' +
'		<span title="Настроить" class="split"><i class="icon arr"><i></i></i></span>' +
'	</span>' +
'</div>' +
'<div style="margin-right:10px;">' +
'	<i class="t-odnokl" style="margin-top: 4px;"></i>' +
'	<span>Сообщения</span>' +
'	<strong class="num new">12</strong>' +
'</div>' +
'<div style="margin-right:10px;">' +
'	<i class="t-odnokl t-odnokl_guest" style="margin-top: 6px;"></i>' +
'	<span><span>Гости</span></span>' +
'</div>' +
'<div title="Ваши одноклассники оценили 0 ваших фотографий. Посмотрите?">' +
'	<i class="t-odnokl t-odnokl_fivepl" style="margin-top: 6px;"></i>'+ 
'	<span>Оценки</span>'+ 
'	<strong class="num new" style="display: none;"></strong>' +
'</div>' +
'</div>';
