﻿if (typeof Ferengi == "undefined") {
    var Ferengi = {
        Version: "1.0"
    };
    Ferengi.namespace = function() {
        var a = arguments,
			o = null,
			i, j, d;
        for (i = 0; i < a.length; ++i) {
            d = a[i].split(".");
            o = Ferengi;
            for (j = (d[0] == "Ferengi") ? 1 : 0; j < d.length; ++j) {
                o[d[j]] = o[d[j]] || {};
                o = o[d[j]];
            }
        }
        return o;
    };
};
Ferengi.namespace("Pxp");
// Creating a class
Ferengi.Pxp.BotonTextoDinamico = new Class({
    Implements: Options,
    options: {
        Texto: ""
		,Autenticacion: "Si"	
		,Url:""
		,Grisado:""					
    },
    initialize: function(options) {
        this.setOptions(options);
        // initialize commands goes here
    }

});
Ferengi.Pxp.BotonTextoDinamico.implement({
    load: function(o) {

        var url = "";
        var html = "";

        if (this.options.Autenticacion == "Si") {
            url = this.options.Url;
            html = "<div class='botonTextoDinamico'><A class='smoothbox' title='' href='" + url + "' NeedsAuthentication='true'><span>" + this.options.Texto + "</span></A></div>"            
        }
        else {
            url = this.options.Url;
            if (this.options.Grisado == "Si") {
                html = "<div class='botonTextoDinamico'><a class='smoothbox'  title='' href='" + url + "' NeedsAuthentication='false'> <span>" + this.options.Texto + "</span></a></div>";
            }
            else {
                html = "<div class='botonTextoDinamico'><a title='' href='" + url + "' target='_blank'> <span>" + this.options.Texto + "</span></a></div>";
            }
        }
        $(o).set("html", html);
    }
});

window.addEvent("domready", function() {
    //Busca todos los divs que tengan como clase Ferengi_Pxp_BotonTextoDinamico por si hay varios botones en la pagina
    //<div class="Ferengi_Pxp_BotonTextoDinamico" Texto="Texto" Autenticacion="Si" Url="/seccion-32-clasico.html"></div>
    var oo = $$('.Ferengi_Pxp_BotonTextoDinamico');
    for (var i = 0; i < oo.length; i++) {
        var o = oo[i];

        var oparams = {};
        var attrs = o.getAttribute('Ferengi_Pxp_BotonTextoDinamico')

        if (o.getAttribute('Texto')) { oparams.Texto = o.getAttribute('Texto'); }
        if (o.getAttribute('Autenticacion')) { oparams.Autenticacion = o.getAttribute('Autenticacion'); }
        if (o.getAttribute('Url')) { oparams.Url = o.getAttribute('Url'); }
        if (o.getAttribute('Grisado')) { oparams.Grisado = o.getAttribute('Grisado'); }
        var gp = new Ferengi.Pxp.BotonTextoDinamico(oparams);
        gp.load(o);
    }
});

Asset.javascript("/scripts/flash-flotado.js"); 


