/**
 * This document should only contain scripts that are unique for just this site
 */

var $j = jQuery.noConflict();

$j(document).ready(function() {

	/**
	* Function to get rid of target="_blank"
	* Write like this instead.. <a href="somewhere.asp" rel="external">Somewhere</a>
	*/
	$j('a[@rel="external"]').click(function() {
		return !window.open($j(this).attr('href'));
	});
		
	/**
	 * Show/hide #category links
	 */
	$j('#navigation p.menu-head').click(function()
	{
		var bgImg = 'url(/images/button/menu_arrow_expanded.png)';
		var wasOpened = false;
		
		try {
			if ($j(this).next('div.menu-body')[0].style.display != 'block') {
				wasOpened = true;
			} else {
				bgImg = 'url(/images/button/menu_arrow_collapsed.png)';
			}
		} catch(ex) {
		}
		
		var skip = false;
		
		// ie fix -- freaks out on slideToggle and slideUp
		/*@cc_on
			skip = true;

			$j(this)
				.css({backgroundImage:bgImg})
				.next('div.menu-body')
				.toggle()
				.siblings('div.menu-body')
				.hide();
		@*/

		if (!skip)
			$j(this)
				.css({'background-image':bgImg})
				.next('div.menu-body')
				.slideToggle(300)
				.siblings('div.menu-body')
				.slideUp('slow');

		$j(this)
			.siblings('p')
			.css({'background-image':'url(/images/button/menu_arrow_collapsed.png)', 'background-repeat': 'no-repeat'});
	});
	
	if (location.href.indexOf('search/product.asp') > -1) {
		$j('#misc-info dt[class!=disabled]').click(function () {
			$j(this)
				.toggleClass('selected')
				.next()
					.toggle();
					
			$j(this).siblings('dt')
				.removeClass('selected')
				.next()
					.hide();
		});
	}
	
	//if ($j('#left-text-search:visible').is(':visible')) {
		$j('#left-text-search:visible')
			.click(function (e) {
				var loc = e.clientX - $j(this).offset().left;
				if (loc >= 125 && this.value.length) {
					this.form.submit();
				}
			})
			.mousemove(function (e) {
				var loc = e.clientX - $j(this).offset().left;
				if (loc >= 125 && this.value.length) {
					this.style.cursor = 'pointer';
				} else {
					this.style.cursor = 'text';
				}
			});
	//}
});
