$(document).ready(function() {
    CargarTabs() 
    $("#playlist").playlist("../FlowPlayerDark.swf", {initialScale:'scale'}, {loop:true});   
    //Videos
    var items = $("#playlist a");
    var player = null;            
    if (items.attr("class")== "flv"){
        player = flashembed("reproductor-video", 
            {
                src:'Swf/FlowPlayerDark.swf',
                width: 320, 
                height: 240,
                controls:null
            },                                    
            {
                config: {   
                    autoPlay: false,
                    autoBuffering: true, 
                    loop:false, 
                    clip: { autoPlay: false,
                    autoBuffering: true},
                    initialScale:'scale',
                    videoFile: items.attr("href")
                    //hideControls: true
                }
                
            }
        );   
    }
    else if(items.attr("class")== "swf" || items.attr("class")== "youtube"){
        player = flashembed("reproductor-video", 
        {
            src: items.attr("href"),
            width: 320, 
            height: 240,
            controls:null
        } 
        );   
    }
    else{
         player = flashembed("reproductor-video", 
            {
                src:'Swf/FlowPlayerDark.swf',
                width: 320, 
                height: 240,
                controls:null
            },                                    
            {
                config: {   
                    autoPlay: false,
                    autoBuffering: true, 
                    loop:false, 
                    clip: { autoPlay: false,
                    autoBuffering: true},
                    initialScale:'scale',
                    videoFile: items.attr("href")
                    //hideControls: true
                }
                
            }
        );      
    }       
    
    //Carrousel de productos
    $("#productos").carousel({ loop: true, dispItems: 2 });       
       
                
});

    

(function($) {        
    
    // plugin initialization
    $.fn.extend({
        playlist: function(params, config, opts) {             
            return this.each(function() {
                new playlist($(this), params, config, opts);
            });
        }        
    });
                    
            
    function playlist(root, params, config, playlistOpts) {

        var player = null;  

        var opts = {
            playingClass: 'playing',
            pausedClass: 'paused',
            player: '#reproductor-video',
            loop:false
        }
        
        opts = $.extend(opts, playlistOpts);         
        
        config = config || {};
        if (typeof params == 'string') params = {src:params};
         
        if (!$(opts.player).length) {
            alert("flow.playlist not configured properly\nnonexisting element " + opts.player);
            return;
        }
        
        var items = root.children();
        if (items.is(".__scrollable")) items = root.children().children();
        
        items.click(function(event) {    
            
            var el = $(this);  
            if (el.attr("class")== "flv"){
                player = flashembed("reproductor-video", 
                    {
                        src:'Swf/FlowPlayerDark.swf',
                        width: 320, 
                        height: 240,
                        controls:null
                    },                                    
                    {
                        config: {   
                            autoPlay: false,
                            autoBuffering: true, 
                            loop:false, 
                            clip: { autoPlay: false,
                            autoBuffering: true},
                            initialScale:'scale',
                            videoFile: el.attr("href")
                            //hideControls: true
                        }
                        
                    }
                );   
            }
            else if(el.attr("class")== "swf" || el.attr("class")== "youtube"){
                player = flashembed("reproductor-video", 
                {
                    src: el.attr("href"),
                    width: 320, 
                    height: 240,
                    controls:null
                } 
                );   
            }
            else{
                player = flashembed("reproductor-video", 
                    {
                        src:'Swf/FlowPlayerDark.swf',
                        width: 320, 
                        height: 240,
                        controls:null
                    },                                    
                    {
                        config: {   
                            autoPlay: false,
                            autoBuffering: true, 
                            loop:false, 
                            clip: { autoPlay: false,
                            autoBuffering: true},
                            initialScale:'scale',
                            videoFile: items.attr("href")
                            //hideControls: true
                        }
                        
                    }
                );
            }
            // toggle play pause action
            if (player && el.hasClass(opts.playingClass)) {
                if (player.getIsPaused()) player.DoPlay();
                else player.Pause();
                return false;
            }            
            
            // toggle playing state
            el.parent().find("." + opts.playingClass)
                .removeClass(opts.playingClass)
                .removeClass(opts.pausedClass)
            ;
                
            el.addClass(opts.playingClass);
            
            // setup callback methods
            window.onClipDone = function() {
                player.DoStop();
                /*
                el.removeClass(opts.playingClass).removeClass(opts.pausedClass);
                
                // move to next entry if it exists
                if (el.next().length) el.next().click();
                
                // else reset player                
                else {
                    if (opts.loop) {
                        items.eq(0).click();
                        
                    } else {
                        player.DoStop();
                        player.Seek(0);
                    }
                }
                           */
                
                // omit player's default behaviour (since version 2.2)
                return false;
            }                  
    
            window.onPause = function() {
                if (el.hasClass(opts.playingClass)) el.addClass(opts.pausedClass);                  
            }
    
            window.onResume = function() {
                el.removeClass(opts.pausedClass);    
            }    
            
            // disable default behaviour
            return false;            
            
        });    
        
        // clicking on the player clicks on the first playlist entry
        $(opts.player).click(function(event) {
            //event.preventDefault();
            //items.eq(0).click();        
        });            
            
    }
    

})(jQuery); 




//Tabs de articulos

function CargarTabs()
{  
    $("#tabs-articulos").tabs({ 
            ajaxOptions: { 
                async: false,  
                cache: false,
                dataType: "text",
                success: function(datos){
                   //alert( "Se guardaron los datos: " + datos);
                 }

            } 
    });     
     
}    


function RecuperarContrasena()
{
    var correo = $("#emailrecuperar").val()
    
    $.ajax({
        type: "POST",
        url: "Registro.php",
        data: "op=EnviarRecordatorioPass&noheaders=all&correo="+correo,
        success: function(datos){
           alert( "Se enviaron los datos a "+correo);                   
           jQuery('#reccont').hide()
        }
    });
}
