$(function() {
    /* jdmenu */
	$('ul.jd_menu').jdMenu({
	    // Time in ms before menu shows
		showDelay: 		0,
		// Time in ms before menu hides
		hideDelay: 		200,
        // Should items that contain submenus not 
    	// respond to clicks
	    disableLinks: false
	});
	/* sidebar blurbs */
	var $section_blurb;
	if ($section_blurb = $('#sidebar #section_blurb')) {
	    var original_blurb = $section_blurb.text();
        $('#sidebar a').hover(function(){
            $section_blurb.text($(this).attr('title'));
        }, function(){
            $section_blurb.text(original_blurb);
        });
	}
	/* link_boxes */
	$('.link_box a').corner();
	
	/* contact forms */
	$('.contact_form').validate({
        // debug: true,
	    errorClass: 'error_field',
        rules: {
            'contact[messageData][fromName]': 'required',
            'contact[messageData][fromEmail]': {
                required: true,
                email: true
            },
            'contact[message]': 'required'
        }
    });
    
    /* accordion */
    $('.accordion > div').hide();
    $('.accordion').tabs('.accordion div.pane', {tabs: 'h6', effect: 'slide', initialIndex: null});
	
	/* homepage */
	$('.homepage_promo_block h2')
	    .corner('right')
	    .hover(function(){
	        $(this).addClass('hover');
	    }, function(){
	        $(this).removeClass('hover');
	    });
	$('#homepage_promo_branding h2').mouseover(function(){
        $(this).addClass('active');
        $('#homepage_promo_retail h2').removeClass('active');
        $('#homepage_promo_retail_switchable_content').hide();
        $('#homepage_promo_branding_switchable_content').show();
    });
    $('#homepage_promo_retail h2').mouseover(function(){
        $(this).addClass('active');
        $('#homepage_promo_branding h2').removeClass('active');
        $('#homepage_promo_branding_switchable_content').hide();
        $('#homepage_promo_retail_switchable_content').show();
    });
    
    /* logo_phone_applications_collage */
    $('.logo_phone_applications_collage_area')
        .each(function(){
            var $this = $(this);
            var html = $this.html();
            $this.empty().css({display: 'block'});
            var ieImageShim = $('<img src="/images/blank.gif" alt="" />').css({width: $this.width(), height: $this.height()}).appendTo($this);
            $('<div class="logo_phone_applications_collage_tooltip tooltip"></div>')
                .insertAfter($this)
                .html(html);
        })
        .tooltip({relative: true, offset: [30, 0]});
});

