
function cargar_url ( categoria, pagina, marca, busqueda, vista ) 
{
		
    if ( !busqueda )
    {
        busqueda = -2;
    }
	
    $("*").css ( "cursor", "wait" );
    $.ajax
    ({
        type:     "POST",
        url:      "/central_dev.php/ajax/articulos/"+categoria+"/"+pagina+"/"+marca+"/"+busqueda+"/"+vista,
        data:     "",
        cache:    false,
        success:  function ( html ) 
        {
            $("#contendido_productos").html(html); 
            $("#filtro_buscador").focus();
        },
        complete: function ( ) {
            $("*").css ( "cursor", "" );
        },
        error:    function ( ) { }
    });
};




function ver_notificacion ( id )
{
    window.location.href = "/almacen_dev.php/comunicacion/notificacion/"+id;
}



function ver_mensaje ( id, tipo, tipo2 )
{
    $("*").css ( "cursor", "wait" );
    $.ajax
    ({
        type:     "POST",
        url:      "/almacen_dev.php/ajax/mensaje/" + tipo + "/" + id + "/" + tipo2,
        data:     "",
        cache:    false,
        success:  function (html)
        {
            $("tr.seleccionable").removeClass("tr_seleccionable_seleccionado");
            $("#linea_mensaje_"+id).removeClass("sin_leer");
            $("#linea_mensaje_"+id).addClass("tr_seleccionable_seleccionado");
			
            $("tr.mensajes").hide();
            $("#display_mensaje_"+id).show("slow");
			
            $("#contenido_mensaje_"+id).html(html);
			
        },
        complete: function ( ) {
            $("*").css ( "cursor", "" );
        },
        error:    function ( ) { }
    });
}



function ver_tablon ( id )
{
    $("*").css ( "cursor", "wait" );
    $.ajax
    ({
        type:     "POST",
        url:      "/almacen_dev.php/ajax/tablon/" + id,
        data:     "",
        cache:    false,
        success:  function (html)
        {
            $("tr.seleccionable").removeClass("tr_seleccionable_seleccionado");
            $("#linea_tablon_"+id).removeClass("sin_leer");
            $("#linea_tablon_"+id).addClass("tr_seleccionable_seleccionado");
			
            $("tr.tablon").hide();
            $("#display_tablon_"+id).show("slow");
			
            $("#contenido_tablon_"+id).html(html);
			
        },
        complete: function ( ) {
            $("*").css ( "cursor", "" );
        },
        error:    function ( ) { }
    });
}




function cambiar_almacen ( almacen )
{
    $("*").css ( "cursor", "wait" );
    $.ajax
    ({
        type:     "POST",
        url:      "/central_dev.php/ajax/almacen/"+almacen,
        data:     "",
        cache:    false,
        success:  function () 
        {
            location.reload();
			
        },
        complete: function ( ) {
            $("*").css ( "cursor", "" );
        },
        error:    function ( ) { }
          
    });
};



function expande_categoria ( categoria )
{
    cargar_url ( categoria, -1, -1, -1, -1 ) ;
	
    $.ajax
    ({
        type:    "POST",
        url:     "/central_dev.php/ajax/categoria/"+categoria,
        data:    "",
        cache:   false,
        success: function ( html ) {
            $("#sfcart_submenu").html(html);
        }
    });   
}




function expande_articulo (articulo )
{
    $("*").css ( "cursor", "wait" );
    $.ajax
    ({
        type:     "POST",
        url:      "/central_dev.php/ajax/articulo/"+articulo,
        data:     "",
        cache:    false,
        success:  function ( html ) 
        {
            $("#product_displayer").show("fast"); 
            $("#product_displayer_content").html(html); 
        //$("#filtro_buscador").focus();
        },
        complete: function ( ) {
            $("*").css ( "cursor", "" );
        },
        error:    function ( ) { }
    });
}



function cerrar_articulo ( )
{ 
    $("#product_displayer").hide("fast"); 
}







elemento = null;


function general_del_menu ( opcion )
{
    $("#memu_cabecera_"+opcion).mouseenter ( function() {
        elemento = this;
        $("#panel_acceso").show(); 
        $("#panel_acceso").html("Cargando..."); 
		
        $("*").css ( "cursor", "wait" );
        $.ajax
        ({
            type:     "POST",
            url:      "/central_dev.php/ajax/"+opcion,
            data:     "",
            cache:    false,
            success:  function ( html ) {
                $("#panel_acceso").html(html);
            },
            complete: function ( ) {
                $("*").css ( "cursor", "" );
            }
        });
    });
}


$(document).ready ( function () {

    $("#memu_cabecera_inicio").mouseenter ( general_del_menu("inicio") );
    //$("#memu_cabecera_tienda").mouseenter ( general_del_menu("tienda") );

    $("#menu_cabecera a.duepuntozero").mouseleave ( function() {
        $("#panel_acceso").hide()
    });

    $("#panel_acceso").mouseleave ( function () {
        $(this).hide();
        $(elemento).removeClass("duepuntozero_hover");		
    });

    $("#panel_acceso").mouseenter ( function () {
        $(this).show();
        $(elemento).addClass("duepuntozero_hover");		
    });
	

    $(".destinatarios").mouseleave ( function () {
        $("div.destinatarios").hide();
        $("div.destinatarios").html ( '' );
    });
		
    // oculta el noticer al cabo de x segundos
    setTimeout( function() {
        $('#noticer').hide(4000);
    }, 5000 );
});




function FiltrarMensajeAlmacen ( carpeta, de_para, id ) 
{ 
    window.location.href="/almacen_dev.php/comunicacion/mensajeria/" + carpeta + "/" + de_para + "/" + id;
}
//
//function FiltrarAlmacen_Para ( id ) 
//{ 
//    window.location.href="/almacen_dev.php/comunicacion/mensajeria/enviados/para/"+id;
//}



function ampliar_demanda ( id )
{
    $.ajax
    ({
        type:    "POST",
        url:     "/almacen_dev.php/ajax/ampliar-demanda/"+id,
        data:    "",
        cache:   false,
        success: function ( html ) {
            $( "#demanda_contenido_" + id ).html ( html );
            $( "#demanda_contenido_" + id ).show("slow");
			
        }
    }); 
}



function ampliar_noticia ( id )
{
    $( "#parcial_"+id ).toggle();
    $( "#noticia_"+id ).slideToggle();
	
    $("#ampliar_"+id).text($("#ampliar_"+id).text() == 'ocultar' ? 'ampliar' : 'ocultar' );
    $("#ampliar_"+id).toggleClass("contraer");

}



function FiltrarNoticia ( ruta, value )
{
    window.location.href = ruta + value ;
}




function boton_eliminar ( objeto ) 
{
		
    $( objeto ).toggle ( );
   
};






function ajax_cargar_sede ( sede )
{
    ajax_cargar_sede_informacion ( sede )
    ajax_cargar_sede_contactar ( sede )
//ajax_cargar_sede_noticias ( sede )
}



function ajax_cargar_sede_informacion ( sede )
{
    $.ajax
    ({
        type:    "POST",
        url:     "/central_dev.php/ajax/sede/informacion/"+sede,
        data:    "",
        cache:   false,
        success: function ( html ) {
            $( "#informacion" ).html ( html );
        }
    });	
}

function ajax_cargar_sede_noticias ( sede )
{
    $.ajax
    ({
        type:    "POST",
        url:     "/central_dev.php/ajax/sede/noticias/"+sede,
        data:    "",
        cache:   false,
        success: function ( html ) {
            $( "#noticias" ).html ( html );
        }
    });	
}

function ajax_cargar_sede_contactar ( sede )
{
    $.ajax
    ({
        type:    "POST",
        url:     "/central_dev.php/ajax/sede/contactar/"+sede,
        data:    "",
        cache:   false,
        success: function ( html ) {
            $( "#contacto" ).html ( html );
        }
    });	
}





function ajax_cambiar_punto_de_venta ( )
{
    $.ajax
    ({
        type:    "POST",
        url:     "/central_dev.php/ajax/get_punto_de_venta",
        data:    "",
        cache:   false,
        success: function ( html ) {
            $( "#puntos_de_venta" ).html ( html );
        }
    });	
    setTimeout ( "ajax_cambiar_punto_de_venta()", 4000 );   
}







function ajax_mostrar_enviados ( id )
{
    dest = "#destinatarios_"+id;
    
    
    $.ajax
    ({
        type:    "POST",          
        url:     "/almacen_dev.php/ajax/mostrar_info_enviados/"+id,
        data:    "",
        cache:   false,
        success: function ( html ) {
            $( dest ).html ( html );
        }
    });	
   
    $(dest).show();
}





function ajax_borrar_mensaje_recibido ( id )
{
    if ( confirm("Desea borrar este mensaje?") ) 
    {
        $.ajax
        ({
            type:    "POST",          
            url:     "/almacen_dev.php/ajax/eliminar_mensaje_recibido/"+id,
            data:    "",
            cache:   false,
            success: function ( html ) 
            {
                alert ( "Mensaje borrado correctamente" );
                document.location.reload(true);
            }
        });	
    }
    
}


function ajax_borrar_mensaje_enviado ( id )
{
    if ( confirm("Desea borrar este mensaje?") ) 
    {
        $.ajax
        ({
            type:    "POST",          
            url:     "/almacen_dev.php/ajax/eliminar_mensaje_enviado/"+id,
            data:    "",
            cache:   false,
            success: function ( html ) 
            {
                alert ( "Mensaje borrado correctamente" );
                document.location.reload(true);
            }
        });	
     
    }
    
}

