$j=jQuery.noConflict();

$j(document).ready(function() 
{
	$j('#wrapper').removeClass('no-js'); // the no-js class is targetted by the CSS if a user has Javascript disabled, as it's otherwise removed by jQuery
	$j('.dropdown-list').addClass('hidden');
	$j('.dropdown-list a.active').parents('.dropdown-list').addClass('visible');
	$j('.teaser-block li:first-child').addClass('no-left-margin');
	$j('#topbanner fieldset').remove();
	
	// This uses the truncate jquery plugin to shorten longer titles for the sidebar and breadcrumbs
	$j('.news-block-title a').truncate(40);
	$j('.breadcrumb-current').truncate(40);
	
	// Some minor styling classes, no major issues if Javascript is disabled
	$j('#leftcontent .block').addClass('leftcontentblock');
	$j('.frontpage-highlight:first-child').addClass('no-left-margin');
	
	// Left sidebar lists. This adds the 'active' class to the parent 'product category' of an opened 'product range'
	$j('.dropdown-list-internal').parent('li').addClass('dropped-down');
	$j('.dropped-down span a').addClass('active');
	
	// Hides stuff in admin mode
/* This should be done in block visibility
	var url = location.pathname;
	if ('url:contains("edit")')
	{
		$j('.circleimg').hide();
		$j('.product-image').hide();
		$j('.enquiry_but').hide();
	}
// */
	// Changes image alignment
	

	// Disables product selector filters until an industry type has been selected
	var $optionvalue = $j('#industryselect option:selected').val();
	if ($optionvalue == 0) 
	{
		$j('#appfilter').attr('disabled','disabled'),
		$j('#appfilter').addClass('grayed-out'),
		$j('#prodfilter').attr('disabled','disabled');
		$j('#prodfilter').addClass('grayed-out');
	};

	// For tabbed items. Updates the class of the parent li item of links the tab plugin has marked as current
	$j('.tabcorner li:first-child').addClass('active');
	$j('.tabcorner li').hover(function()
	{
		$j(this).addClass('tab-hover');
	},
	function ()
	{
		$j(this).removeClass('tab-hover');
	});
	$j('.tabcorner a').click(function()
	{
		$j('.tabcorner a').parent().removeClass('active');
		$j('a.tab-current').parent().addClass('active');
	});
	
	// Hides the enquiry button when it mistakenly turns up on a product category (not type) page
        // UPDATE: This is not a mistake, some prod categories can be enquired about
	if ($j('.three-circle-img').length) {
          if ($j('.enquiry-form').length) {
            $j('body').addClass('enquiry-and-three-circles');
          }
          else {
	    $j('.tabdesign').addClass('wider-tabdesign');
	    // $j('.enquiry-form').remove();
          }
	};
	
	// Adds a clear to deal with the float in the product selector in IE7 stylesheet
	$j('<div class="clear"></div>').insertAfter('.view-content-Product-Selector ul');
	
	// Removes elements from DOM if necessary. Also set to display:none in CSS as fallback
	$j('#navigation-area h2').remove();
	$j('.quicktab-block h2').remove();
	
	// Aesthetic updates to sales network page
	$j('.view-SalesNetworkNew table').addClass('the-sales-network');
});
