/*
Plataforma En Línea TecnoCommerce para Distribuidores v1.0: Comercio Electrónico para Empresas con esquema de Distribuidor
Todos los Derechos Reservados por Tecno-Soluciones de Venezuela C.A.

TecnoCommerce para Distribuidores es una Marca Registrada de Tecno-Soluciones de Venezuela C.A.
Más Información en: http://www.tecnosoluciones.com
Email: webmaster@tecnosoluciones.com

Atención: Usted utiliza este programa  bajo el Acuerdo de Servicios de Tecno-Soluciones de
Venezuela C.A. Por favor lea el documento AcuerdoDeServicios.pdf  anexo para
conocer los detalles, responsabilidades y limitaciones del uso de este software.

                     Código Fuente desarrollado y/o mejorado por Tecno-Soluciones de Venezuela C.A.

Control de Versiones:

*/

function resize(obj) {
    $(obj).css({
        //height:$(obj).height()+"px",
        top:($(window).scrollTop()+$(window).height()-$(obj).height())+"px"
    });
}

(function($){
    $.fn.notificaciones = function (option){
        
        var opciones = $.extend($.fn.notificaciones.opciones_default , option);
            
            
        
        function add(obj,txt,tipo,tiempo_fin){
            var aux = $(obj);
            //var aux = $(obj).find("td");
            if(aux.find("div").length == 0){
                var aux2 = $("<div class='ui-widget ui-state-"+tipo+" ui-corner-all mensaje'><div class='ui-icon ui-icon-closethick' onclick='$(this).parent().fadeOut(\"slow\",function(){$(this).remove(); resize($(this).parent().parent());})' index='0'></div>"+txt+"</div>").appendTo(aux);                  
            }else{
                var aux2 = $("<div class='ui-widget ui-state-"+tipo+" ui-corner-all mensaje'><div class='ui-icon ui-icon-closethick' onclick='$(this).parent().fadeOut(\"slow\",function(){$(this).remove(); resize($(this).parent().parent());})' ></div>"+txt+"</div>").prependTo(aux); 
            }
            //var alth= $(aux2).height()+"px";
            resize(aux)
            if($.fn.notificaciones.after.indexActual == $.fn.notificaciones.after.indexUntil){
                $.indexActual = 0;
            }
            $.fn.notificaciones.after.indexActual++;
            $.fn.notificaciones.after.clasexA["a"+$.fn.notificaciones.after.indexActual] = aux2;
            setTimeout('$.fn.notificaciones.after.clasexE("a'+$.fn.notificaciones.after.indexActual+'")',tiempo_fin);
        }
        
        /*function resize(obj) {
            $(obj).css({
                height:$(window).height()+"px",
                top:$(window).scrollTop()+"px"
            });
        }*/
        
        
        
        this.each(function(){  
            switch(opciones.accion){
                case "add":
                    add(this,opciones.txt,opciones.tipo,opciones.tiempo_fin);
                break;
                default:
                    var obj=this;
                    resize(obj);
                    $(window).bind("resize",function(){
                        resize(obj);
                    });
                    $(window).bind("scroll",function(){
                        resize(obj,"0px");
                    })
                    
                break;
            }
        });        
    }
    
    $.fn.notificaciones.opciones_default = {
        accion: ""
    }
    
    $.fn.notificaciones.after = {
        clasexE: function(a) {
            $($.fn.notificaciones.after.clasexA[a]).slideToggle("slow",function(){
                $(this).remove();
                resize($("#notif"));
                /*$("#notif").css({
                    //height:$(obj).height()+"px",
                    top:($(window).scrollTop()+$(window).height()-$("#notif").height())+"px"
                });*/
            });
        },
        clasexA: {},
        indexUntil:1000,
        indexActual:0
    };
})(jQuery);


