﻿/*Wrap jQuery UI Widgets here*/
function dialog(obj) {
    //e.g. obj{id:id,modal:true,height:300px,width:300px,autoOpen:true,draggable:true,resizable:true,showButtons:true,hideTitleBar:true,appendEl:'<div id=\"dialogue-message\"></div>',loadHtml:'/UserControls/Avant/text/life-insurance-popup.htm'} || html:
    if (obj.appendEl)
        $('body').append(obj.appendEl)

    if (obj.loadHtml)
        $(obj.id).load(obj.loadHtml);
    else if (obj.html)
        $(obj.id).html(obj.html);

    $(function () {
        $(obj.id).dialog("destroy");
        $(obj.id).dialog({
            modal: obj.modal,
            height: obj.height,
            width: obj.width,
            autoOpen: obj.autoOpen,
            draggable: obj.draggable,
            resizable: obj.resizable,
            title: obj.title
        });

        if (obj.showButtons)
            $(obj.id).dialog("option", "buttons", { "Ok": function () { $(this).dialog("close"); } });

        if (obj.hideTitleBar)
            $("div.ui-dialog-titlebar").hide();

        if (obj.closeBlur)
            $('.ui-widget-overlay').bind("click", function () { $(obj.id).dialog("close"); });

        //whole number e.g. 80
        if (obj.opacity && !isNaN(obj.opacity))
            $('.ui-widget-overlay').css("opacity", (obj.opacity / 100), "filter", "alpha(opacity=" + obj.opacity + ")", "-moz-opacity", (obj.opacity / 100));

        if (obj.titleCloseBtnOnly)
            $('div').removeClass('ui-widget-header');

        if (!obj.overFlow) {
            $('.ui-dialog').css('overflow', 'hidden');
            $('.ui-dialog-content').css('overflow', 'hidden');
        }
    });
}

var d = new Date();
var year = d.getFullYear();

$(function () {
    $(":text.date-picker").datepicker({
        changeMonth: true,
        changeYear: true,
        dateFormat: 'dd/mm/yy',
        yearRange: '1900:' + year,
        showAnim: 'fold',
        showButtonPanel: false,
        showOn: "button",
        buttonImage: "/images/calendar.gif",
        buttonImageOnly: true
    });
});

$(document).ready(function () {
        $(".tooltip").each(function() {
            $(this).qtip({
              content: {
                attr: 'title' // get the tooltip content from title attribute
              },
              show: 'focus', // focus event to show the tooltip
              hide: 'focusout', // focusout event to hide the tooltip
              position: { // positioning of tooltip 
                my: 'left center',
                at: 'right center'
              },
              style: {
                classes: 'ui-tooltip-dark ui-tooltip-shadow'
              }
            });
        });    
        
        $(".tooltip-date").each(function() {
            $(this).qtip({
              content: {
                attr: 'title'
              },
              show: 'focus',
              hide: 'focusout',
              position: {
                adjust: {
                  x:110
                },
                my: 'left center',
                at: 'right center'
              },
              style: {
                classes: 'ui-tooltip-dark ui-tooltip-shadow'
              }              
            });
        });           
});
