
var navOpen = false;
var whichNav = '';

$(document).ready( function() {
/*
	// initiate dynamItScript for dialogs
	dynamItScript({
		xout: {
			image: 'img/admin/xout.gif',
			width: 17,
			height: 18,
			right: 10,
			top: 4
		},
		dialogTop: '<div class="formcontainer"><div class="formouter"><div class="formcap"></div> <div class="formbody">',
		dialogBottom: '</div><div class="formcup"></div></div></div>',
		dialogWidth: 486
	});
*/

	// Fix IE 6
	var IE6 = (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) == 6);
	if( IE6 ) {
	
		// cached background images
		document.execCommand("BackgroundImageCache",false,true);
		
		// PNGs
		$("img[src$='.png']").each(function() {
			var src = '/' + $(this).attr('src');
			$(this).attr("src", "http://www.dynamit.us/img/spacer.gif").attr("style", "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "');");
		});
		
	}
	
	
//	$('#browse-category').dynamItDrop();

	$('ul#browse-category').children('li').children('ul').addClass('opened');
	$('ul#browse-category').children('li').children('a').not('#nav-find').attr('href', 'javascript:;').click(function() {
		if( navOpen ) {
			if(whichNav == $(this).attr('title')) {
				navOpen = false;
				$('ul.opened').hide('slow');
			} else {
				$('ul.opened').hide();
				$(this).siblings('ul').show();
				whichNav = $(this).attr('title');
			}
		} else {
			$(this).siblings('ul').show('slow');
			navOpen = true;
			whichNav = $(this).attr('title');
		}
		return false;
	});



	$("#feature-info").click(function() {
		if($(this).hasClass('on')) {
			$(this).removeClass('on');
		} else {
			$(this).addClass('on');
		}
	});


	$('#carousel ul').dynamItCarousel({
		next: '.arrowright',
		prev: '.arrowleft',
		indexnav: '#index-nav ul',
		width: 495,
		inview: 1,
		wraparound: true,
		slideshow: true,
		slideshowtimeout: 7000
	});
	



	// Forms and Stuff.
	$('input, textarea').focus( function() {
		if( $(this).val() == $(this).attr('title') ) {
			$(this).val('');
		}
	}).blur( function() {
		if( $(this).val() == '' ) {
			$(this).val( $(this).attr('title') );
		}
	});
	

}).click(function(e) {

	if( navOpen ) {
		if( !$(e.target).closest("#browse-category").length ) {
			navOpen = false;
			$('ul.opened').hide('slow');
		}
	}
});



