﻿/*
 * 	 customSelect - apply style to a select box by Neil Barrett
 */
 
(function($) {

  $.fn.customSelect = function() {
    
    $(this).find('dt').find('a').click(function() {
//            $(this).parent().parent().find('ul').animate({"width": "toggle", "height": "toggle", "opacity": "toggle"}, { duration: "slow" });
 
//        $(this).parent().parent().find('ul').animate({width: 'show', height: 'show'}, {duration: 'slow', easing: 'easeInQuad'});                       
//        $(this).parent().parent().find('ul').slideToggle({duration: 'slow', easing: 'easeInQuad'});                       
//        $(this).parent().parent().find('ul').css('visibility', 'visible').slideDown('fast');                          
        $(this).parent().parent().find('ul').show();
    });                                    
    
    $(this).find('dd').find('ul').each(function () {
    
    
        $(this).find('a').click(function() {                
            var text = $(this).html(); 
            var selectedVal = $(this).attr('value');
            $(this).parent().parent().parent().parent().find('dt a span').html(text);  
            $(this).parent().parent().parent().parent().find('dt a').attr('value', selectedVal);             
//            $(this).parent().parent().animate({width: 'hide', height: 'hide'}, {duration: 'slow', easing: 'easeInQuad'});
//            $(this).parent().parent().slideToggle({duration: 'slow', easing: 'easeInQuad'}); 
//            $(this).parent().parent().css('visibility', 'hidden').slideUp('slow');                          
            $(this).parent().parent().hide();
        });
        
    });                                                
    
    $(document).bind('click', function(e) {                
        var $clicked = $(e.target);                
        if (! $clicked.parents().hasClass("dropdown"))                    
        $(".dropdown dd ul").hide();            
    }); 

  };
})(jQuery);




    
