$(function()
{
    // Configure Propuesta
    var xmlMap = {
        image : {
            fecha : $('div.fecha'),
            media : $('div.imgPropuesta img'),
            title : $('h4.tit_propuesta span.titulopropuesta'),
            desc  : $('div.desc_propuesta p'),
            autor : $('h3.autor_propuesta'),
            inspi : $('.inspirador a:first')
        },
        video : {
            fecha : $('div.fecha'),
            media : $('div.swfPropuesta'),
			title : $('div.tit_propuesta_video span.titulopropuesta'),
			titleDetail : $('div.tit_propuesta_videoDetail span.titulopropuestaDetail'),
            desc  : $('div.desc_propuesta_video p'),
            autor : $('h3.autor_propuesta'),
            inspi : $('.inspirador a:first')
        }
    };

    var sIFRConfig = {
        swfResourcePath    : '/media/swf/sifr/',
        swfTypographie    : {
            demi        : 'avantagardeDemi',
            tic            : 'ticAvantgarde',
            thin        : 'thin'
        }
    };

    var titleAnchor    = {
        image    : $('div.vermas a'),
        video    : $('div.vermas_video a')
    };


    var type    = $('#clipping_content').attr('title');
    var esquema = $('#clipping_content')[0].className;

    var _images    = {
        titlePlus    : '/media/img/common/ico_plus.gif',
        titleMinus    : '/media/img/common/ico_minus.gif'
    };

    $.sifr( { path: sIFRConfig.swfResourcePath, save: true });
    
    xmlMap[type].fecha
       .sifr({path: sIFRConfig.swfResourcePath, font: sIFRConfig.swfTypographie.demi, color:esquemas[esquema].tFgColor, height: 191, width:370, content:xmlMap[type].fecha.html()});
    
    xmlMap[type].fecha.find('.sIFR-flash').css('left', 'auto');
    
    
	if (type == 'image')
		$('div.'+esquema+' .tit_propuesta').css('background', esquemas[esquema].dBgColor)
	else
		$('div.'+esquema+' .tit_propuesta_video').css('background', esquemas[esquema].dBgColor)
		$('div.'+esquema+' .tit_propuesta_videoDetail').css('background', esquemas[esquema].dBgColor)

    xmlMap[type].desc.parent().hide();
	
	
	
    xmlMap[type].autor
        .sifr({path: sIFRConfig.swfResourcePath, font: sIFRConfig.swfTypographie.tic, color:'#ffffff', content:xmlMap[type].autor.html(), width:121, height:16});

    $('div.'+esquema+' .autor_propuesta').css('background', esquemas[esquema].aBgColor)




    titleAnchor[type]
        .unbind('click')
        .click(function()
        {
			xmlMap[type].desc.parent().toggle();

            if ( xmlMap[type].desc.parent()[0].style.display == 'none' )
            {
                titleAnchor[type].find('img').attr('src',_images.titlePlus);
				if (type == 'video') {
					$(this).parents('div.tit_propuesta_video').css({
						top: '',
						bottom: '58px'
					});
					$(this).parents('div.tit_propuesta_videoDetail').css({
						top: '',
						bottom: '120px'
					});
				}
            }
            else
            {
                titleAnchor[type].find('img').attr('src',_images.titleMinus);
                if (type == 'video') {
						$(this).parents('div.tit_propuesta_video').css('top', '117px');
						$(this).parents('div.tit_propuesta_videoDetail').css('top', '117px');
				}

			}
            return false;
        });
});
