/*
 * jQuery UI openads @VERSION
 *
 * Copyright (c) 2008 Alexandre Djioev
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/openads
 *
 * Depends:
 *    ui.core.js
 */
(function($) {
    $.widget("ui.openads", {
        plugins: {},

        _init: function() {
            var o = this.options;
            var openadsDiv = $("<div/>").addClass("openads");
            var date = new Date();
            var seed = date.getTime();


            var iFrameParams = {
                ck_seed: Math.random(seed),
                afr_seed: Math.random(seed),
                avw_seed: Math.random(seed),
                adServerURL: o.adServerURL,
                zoneId: o.zoneId,
                width: o.width,
                height: o.height
            };

            var iFrameTemplate =
            "<iframe src='{adServerURL}&target=_blank&what=zone:{zoneId}' " +
            "width='{width}' HEIGHT='{height}' frameborder='0' marginwidth='0' marginheight='0' scrolling='no' allowtransparency='true'></iframe>";

            openadsDiv.simpleTemplate(iFrameTemplate, iFrameParams);
            this.element.html(openadsDiv[0]);
        },

        //TODO
        destroy: function() {
            this.element.unbind();
            this.element.removeClass('ui-openads').empty();
        },
        // TODO
        enable: function() {
            this.element.removeClass('ui-openads-disabled');
            this.disabled = false;
        },
        // TODO
        disable: function() {
            this.element.addClass('ui-openads-disabled');
            this.disabled = true;
        }
    });

    $.ui.openads.getter = "";
    $.ui.openads.defaults = {
        adServerURL:"www.lisasoft.com",
        type: "bottom", //side, bottom
        zoneId: "1", //zone id
        width:"200",
        height:"200"
    };

})(jQuery);
