$(document).ready(function() {
    sessionStorage.removeItem('busquedaDispo')
    sessionStorage.removeItem('Paquete')
})

$.ajax({
    url: URL_COMMON+'functionality/companyManager.php',
    type: 'POST',
    contentType: 'application/json', 
    processData: false, 
    beforeSend: function () {
        // notifyLoading('Loading', NO_TIMEOUT);
    },
    data: JSON.stringify(
        {
            'op'        : 'promo_url',
            'company':  ORIGIN_SITE
            
        }
    )
})
.done(function (response) {
    
    if (response && response.length > 0) {
        promotions(response)
        $("#apiopm_container_promociones").show();
    }
    

})

function promotions(resultado){
    template = '';
    $.ajax({
        url: URL_COMMON+'functionality/companyManager.php',
        type: 'POST',
        contentType: 'application/json',
        processData: false,
        data: JSON.stringify(
            {
                'op'        : 'read_file', 
                'company' : ORIGIN_SITE,
                'values'    : {
                    'file'  : 'item-promocion'
                }
            }
        )
    })
    .done(function (response) {
        apiom_container_promocion=$('#apiom_promociones')

       $('#apiom_title_promociones').css('display', 'block')

        template=response;
        apiom_container_promocion.html('');

        jQuery.each(resultado,function(i,val){
            // apiom_container_promocion.append('<br>');
            apiom_container_promocion.append(template);

            // clearTrn();
            element=$('.apiom_photo_promocion').first();
            element.attr('src',URL_RAIZ+"assets/images/imgPromociones/Home/"+ val.imagen);
            element.removeClass('apiom_photo_promocion');

            apiom_text_promocion=$('.apiom_text_promocion').first();
            apiom_text_promocion.text(val.Descripcion);
            apiom_text_promocion.removeClass('apiom_text_promocion');

        })
    })

}