(function($, window) {

    window.cm = {
        
        /**
         * Dom Readu
         *
         */
        init: function()
        {
            $("form").jqTransform();
            
            $('.form td input, .form td textarea').focus(function() {
                $(this).parents('td').find('.hint').trigger('mouseover');
            });
            $('.form td input, .form td textarea').blur(function() {
                $(this).parents('td').find('.hint').trigger('mouseout');
            });
            
            
            // Tooltips
            $('.hint, .qtip').qtip({
                style: {
                    padding: 5,
                    background: '#14AADD',
                    color: '#fff',
                    textAlign: 'left',
                    border: {
                            width: 7,
                            radius: 5,
                            color: '#14AADD'
                        },
                    tip: 'bottomRight',
                    name: 'dark' // Inherit the rest of the attributes from the preset dark style
                },
                position: {
                    corner: {
                       target: 'topLeft',
                       tooltip: 'bottomRight'
                    }
                }
            });
            
            // Tooltips
            $('.qtipr').qtip({
                style: {
                    padding: 5,
                    background: '#14AADD',
                    color: '#fff',
                    textAlign: 'left',
                    border: {
                            width: 7,
                            radius: 5,
                            color: '#14AADD'
                        },
                    tip: 'bottomLeft',
                    name: 'dark' // Inherit the rest of the attributes from the preset dark style
                },
                position: {
                    corner: {
                       target: 'topRight',
                       tooltip: 'bottomLeft'
                    }
                }
            });
            
            // Specialism
            $('#specialists-browse a').click(function(e) {
                e.preventDefault();
                
                // Remove other lists
                $('#most-pop-spec a').hide();
                $('#synonym-list').slideUp();
                $('#doctor-list').slideUp();
                
                $this = this;
                
                // Hightlight which
                $('#specialists-browse a').removeClass('active');
                $(this).addClass('active');
                
                // Slide current list up
                $('#specialists-list').slideUp(200, function() {
                    
                    // Set Html and slide back down
                    $('#specialists-select h1').html($($this).html());
                    $('#specialists-list').slideDown(200);
                });
            });
            
            // Clicked to show synonyms
            $('#specialists-list a, #most-pop-spec a').click(function(e) {
                e.preventDefault();
                
                $this = this;
                
                // Slide current list up
                $('#most-pop-spec').slideUp(200);
                $('#specialists-list').slideUp(200, function() {
                    
                    // Set Html and slide back down
                    $('#specialists-select h1').html('Synonyms for ' + $($this).html());
                    $('#synonym-list').slideDown(200);
                });
                
            });
            
            /* Clicked to show doctors
            $('#synonym-list a').click(function(e) {
                e.preventDefault();
                
                $this = this;
                
                // Slide current list up
                $('#synonym-list').slideUp(200, function() {
                    
                    // Set Html and slide back down
                    $('#specialists-select h1').html('Practitioners for ' + $($this).html());
                    $('#doctor-list').slideDown(200);
                });
            });
            */
        }
        
        
    };
    
    
    // Init on dom ready
    $(function() {
        cm.init();
    });
    
})(jQuery, window);
