// tablemarket module javascript file

if (Drupal.jsEnabled) {
  $(document).ready(function() {
		
		// Background color fix for TinyMCE
		$('iframe body').css("background-color","#fff");
		
		// Add a class to .form-file parent elements
		$('.form-file').parents('fieldset').addClass('form-file-outer');
		
		// Make the textfield for file uploads shorter so they fit without scrolling
		$('input.form-file').attr('size', 50);
		
		// Reformat the forum topic link
		$('#forum ul li a:contains("Post new forum topic")').empty().append('Post new forum topic >').parent().parent().addClass('post-topic');
		
		// Adjust textfield sizes on location form
		$('#edit-locations-0-street').attr('size', 46);
		$('#edit-locations-0-additional').attr('size', 46);
		$('#edit-locations-0-city').attr('size', 46);
		$('#edit-locations-0-latitude').attr('size', 46);
		$('#edit-locations-0-longitude').attr('size', 46);
		
		// Get rid of the extra fieldset legend
		$('fieldset.location legend').remove();
		
		// Add a colon
		$('fieldset.locations legend').append(':');
		
		// Expandable Supporters lists
		$('.expand-link h2.title').prepend('<span class="show-hide">Show </span>');
		$('.supporter-category').addClass('hide');
		$('.expand-link').addClass('collapsed').toggle(function(){
			$(this).removeClass('collapsed').addClass('expanded').find('span').empty().append('Hide&nbsp;');
			$(this).next().slideDown();
		},function(){
			$(this).removeClass('expanded').addClass('collapsed').find('span').empty().append('Show&nbsp;');
			$(this).next().slideUp();
		});
		
		$('#nice-menu-1').each(function() {
			var menuPadLeft = $(this).css('padding-left');
			var menuPadLeftVal = parseInt(menuPadLeft);
			var menuWidth = $(this).width();
			var headerWidth = $('#header-region').width();
			//alert (headerWidth);
			var newMenuPadLeft = ((headerWidth - menuPadLeftVal - menuWidth) / 2) + menuPadLeftVal;
			$(this).css('padding-left', newMenuPadLeft + 'px');
			
		});
		
		// Show second level menu items
//		$('#left-sidebar ul.menu ul').hide();
//		$('#left-sidebar ul.menu li.active ul').show();
//		$('#left-sidebar ul.menu li.active-parent ul').show();
//		$('#left-sidebar ul.menu li').mouseover(function () {
//				$(this).find('ul:hidden').slideDown('normal');
//      }
//    );
		
//		$('#left-sidebar .block-menu').mouseout(function () {
//				$(this).find('ul.menu li ul').slideUp('normal');
//      }
//    );
    
  });
}




