﻿var closedivBulbEq;
var closedledtypes;

$(function () {
    $('#title').remove();
    $('#led-title').remove();

    $('#bulbEqContent').dialog({
        autoOpen: false,
        async: false,
        modal: true,
        width: 750,
        height: 425,
        open: function () {
            closedivBulbEq = 1;
            $(document).bind('click', function () {
                if (closedivBulbEq) {
                    $('#bulbEqContent').dialog('close')
                }
                closedivBulbEq = 1;
            });
        },
        focus: function () {
            closedivBulbEq = 0;
        },
        close: function () { $(document).unbind('click'); },
        show: "fade",
        hide: "fade",
        resizable: false,
        title: 'Bulb Equivalents',
        position: ["center", 110],
        zIndex: 9999
        //        buttons: { x: function() { $(this).dialog('close'); } }
    });

    $('#BulbConverter').click(function (event) {
        $('#bulbEqContent').dialog('open');
        closedivBulbEq = 0;
        event.preventDefault();
    });

    $('#ledContent').dialog({
        autoOpen: false,
        async: false,
        modal: true,
        width: 775,
        height: 490,
        open: function () {
            closedledtypes = 1;
            $(document).bind('click', function () {
                if (closedledtypes) {
                    $('#ledContent').dialog('close')
                }
                closedledtypes = 1;
            });
        },
        focus: function () {
            closedledtypes = 0;
        },
        close: function () { $(document).unbind('click'); },
        show: "fade",
        hide: "fade",
        resizable: false,
        title: 'LED Types & Applications',
        position: ["center", 82],
        zIndex: 9999
        //        buttons: { x: function() { $(this).dialog('close'); } }
    });


    $('#BulbTypes').click(function (event) {
        $('#ledContent').dialog('open');
        closedledtypes = 0;
        event.preventDefault();
    });


    var $faq = $('#faq .scrollable');

    $faq.append('<div style="text-align:center;"><a id="lighting-sample" href="#"><img src="images/Lighting_facts_label_small.jpg" /></a><div class="small">(Example Lighting Facts Label)</div></div>');

    $faq.append('<div id="lighting-sample-dialog"><img src="images/Lighting_facts_label.jpg" /></div>');

    $('#lighting-sample-dialog').dialog({
        autoOpen: false,
        async: false,
        modal: true,
        width: 650,
        height: 450,
        show: "fade",
        hide: "fade",
        resizable: false,
        title: 'Lighting Facts Example',
        position: ["center", 110],
        zIndex: 9999
    });
    $('#lighting-sample').click(function (event) {
        $('#lighting-sample-dialog').dialog('open');
        event.preventDefault();
    });

    $(window).resize(function () {
        $("#ledContent").dialog("option", "position", ["center", 82]);
        $("#bulbEqContent").dialog("option", "position", ["center", 110]);
        $("#lighting-sample-dialog").dialog("option", "position", ["center", 110]);
    });
});
