$(document).ready(function(){      
    
    if ($('#tooltip').html() == ''){
        $('#tooltip').load('/cydec/help/ajax-help.php?url='+window.location.href, function (){
            $('.form select, .form input, .form textarea').each(function(){
                var content = '';
                var el = $(this).attr('name').replace(']','').replace('[','');
                if ($('#tooltip DIV#hint_' + el ).size() > 0){
                    content = $('#tooltip DIV#hint_'+el).html();
                } 
                if(content!="") {
                $(this).qtip({
                    content: content,
                    position: {
                        corner: {
                           tooltip: 'leftMiddle',
                           target: 'rightMiddle'
                        }
                    },
                    show: { when: { event: 'focus' } },
                    hide: { when: { event: 'blur' }},
                    style: {
                        border: {
                            width: 5,
                            radius: 10,
                            color: '#114785'
                        },
                        classes: {
                            content: 'help-tip'
                        },
                        padding: 3, 
                        textAlign: 'center',
                        tip: true, // Give it a speech bubble tip with automatic corner detection
                        name: 'cream' // Style it according to the preset 'cream' style
                    }
                });
                }
            });
        });
    }

});
