 $(document).ready(function(){
	bindBenchBehaviour(false);
// ---------------------------------------------------------------------------------------
// DESCRIPTION TABS ----------------------------------------------------------------------
// ---------------------------------------------------------------------------------------	
	$('.equipTabs a').click( function(e) {
		e.preventDefault();
		// change over tabs
		$('.equipTabs .activeTab').removeClass('activeTab').addClass('inactiveTab');
		$('#equipViewTabContents .activeTab').removeClass('activeTab').addClass('inactiveTab');
		// change over contentbox
		$(this).parent('li').removeClass('inactiveTab').addClass('activeTab');
		$('#' + $(this).parent('li').attr('id') + 'Text').removeClass('inactiveTab').addClass('activeTab');
	});

// ---------------------------------------------------------------------------------------
// SERIES --------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
	$('.seriesBlock > table').hide();
	$('.seriesBlock > .itemTitle').append("<a href='#' class='lnkSeriesToggleAttrView'>[+] View Specifications</a>");
	$('.seriesBlock > .itemEditOptions').css({ "margin-bottom":"1.5em"});
	$('.lnkSeriesToggleAttrView').live('click', function() {
		var _thisTable = $(this).parents('.seriesBlock').find('table');
		if (_thisTable.is(':visible')) {
			_thisTable.hide();
			$(this).text("[+] View Specifications");
		}
		else {
			_thisTable.show();
			$(this).text("[-] Hide Specifications");
		}
		return false;
	}); // Close .lnkSeriesToggleAttrView.click
	if ($('#ActiveSeriesNo').val()) {
		// SHOULD ONLY RUN IF THERE IS A SERIESNO PASSED IN ATTRIBUTES
		$('#series_' + $('#ActiveSeriesNo').val()).parents('.seriesBlock:first').find('.lnkSeriesToggleAttrView').click();
	} // Close if SeriesNo Exists 
// ---------------------------------------------------------------------------------------
// GALLERY -------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
	$('#GalleryThumbs li.inactiveImage img').each( function() {
		$('body').append('<img src="' + $('input[name="imgPath"]').val() + '/' + $(this).attr('data-equipNo') + '-' + $(this).attr('data-photoNo') + '.jpg" class="hidden">');
	});
	$('#GalleryThumbs a').click( function(e) {
		e.preventDefault();
		_thisThumb = $(this).children('img');
		_thisLi = $(this).parent('li');

		$('.activeImage').removeClass('activeImage').addClass('inactiveImage');
		_thisLi.removeClass('inactiveImage').addClass('activeImage');

		$('#GalleryDisplayImage').attr('src',$('input[name="imgPath"]').val() + '/' + _thisThumb.attr('data-equipNo') + '-' + _thisThumb.attr('data-photoNo') + '.jpg');
		$('#GalleryDisplayImage').attr('alt',_thisThumb.attr('alt'));
		$('#GalleryDisplayImage').attr('title',_thisThumb.attr('title'));
		$('#GalleryDisplayImage').removeAttr('width');
		if ($('#GalleryDisplayImage').width() > 460) {
			$('#GalleryDisplayImage').attr('width','460');
		}
		else {
			$('#GalleryDisplayImage').attr('width',$('#GalleryDisplayImage').width());
		}
		$('.GalleryCaption').text(_thisThumb.attr('title'));
	});
// ---------------------------------------------------------------------------------------
// SCROLL --------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
	$('a.scrollToLocation').click( function(e) {
		e.preventDefault();
		if ($(this).attr('data-Goto')) {
			objOffset = $($(this).attr('data-Goto')).position();		
		}
		else {
			objOffset = $($(this).attr('href')).position();		
		}
		i = $(window).scrollTop();
		while (i < objOffset.top) {
			$(window).scrollTop(i);
			i = i + 20;
		}
	});
// ---------------------------------------------------------------------------------------
// Inline Post Flyout --------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
	$('p.postNew a.FlyOut').click( function(e) {
		e.preventDefault();
		_thisForm = $(this).parents('.frmReplyLight').find('form:first');

		if (_thisForm.is(':visible')) {
			_thisForm.slideUp(200);
		}
		else {
			_thisForm.slideDown(200);
		}
	}); // Close P.postNew a.click()
	$('input[name="btnCancel"]').click( function(e) {
		e.preventDefault();
		$(this).parents('form').find('input:visible:text').val('');
		$(this).parents('form').find('textarea:visible').val('');
		$(this).parents('form').toggle();
	}); // Close #btnCancel.click
	$('#QandA.threadList').each( function(e) {
		if ($(this).find('.threadBody').size() < 1) {
			$(this).find('p.postNew a.FlyOut').click();
		}
	}); // Close .threadList.Each
// ---------------------------------------------------------------------------------------
// MSIE MAX HEIGHT -----------------------------------------------------------------------
// ---------------------------------------------------------------------------------------
	// We want additional specs to scroll if its too long 
	// but MSIE dosnt like max-height, so detect first if the 
	// browser is MSIE, then if addition specs exceeds our
	// max-hight then remove padding from the cell, and 
	// create a box inside that is that height and will scroll
	if (jQuery.browser.msie) {
		if ($('.additionalSpecs').height() > 300) {
			$('.additionalSpecs').css({ 'padding':'0' });
			$('.additionalSpecs').wrapInner('<div style="height: 300px; overflow: auto; padding: 3px 5px;">')
		}
	}
}); // Close Document.ready
