
$(document).ready(function() {

	var IE6 = (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) == 6);
	if(IE6) {
		/// 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 + "');");
		});
	}


	$("#navigation").dynamItDrop();
	
	
	// CAROUSEL -- homepage
	if( $('#carousel li').length > 1 ) {
		$('#carousel li').hide().eq(0).show();
		slideTO = setTimeout(nextSlide, 3000);
	}

	$('#search').focus(function() {
		if(this.value=='looking for something?') {
			this.value = '';
		}
	}).blur(function() {
		if(this.value=='') {
			this.value = 'looking for something?';
		}
	});


	$("#featured-info").accordion({
		header: '> li > a',
		autoHeight: false,
		navigation: false
	});


     // hover functionality for home page highlights section
	$('#i-am-desales').hover(function() {
		$(this).css('background-position', '0px -129px');
		$(this).children('div').css('display', 'block');
	}, function() {
		$(this).css('background-position', '0px 0px');
		$(this).children('div').css('display', 'none');
	});

	$('#sports').hover(function() {
		$(this).css('background-position', '-206px -129px');
		$(this).children('div').css('display', 'block');
	}, function() {
		$(this).css('background-position', '-206px 0px');
		$(this).children('div').css('display', 'none');
	});

	$('#blue-ribbon').hover(function() {
		$(this).css('background-position', '-412px -129px');
		$(this).children('div').css('display', 'block');
	}, function() {
		$(this).css('background-position', '-412px 0px');
		$(this).children('div').css('display', 'none');
	});


    	$('.date').datepicker({ yearRange: '1980:2010' });
    	$('.today').datepicker({ gotoCurrent: true });
    	

});

var slideTO = null;
function nextSlide() {
	var $cur = $('#carousel li:visible').eq(0).fadeOut('slow');
	if( $cur.next().length )
		$cur.next().fadeIn('slow');
	else
		$('#carousel li').eq(0).fadeIn('slow');
	if( slideTO )
		clearTimeout(slideTO);
	slideTO = setTimeout(nextSlide, 10000);
}
function prevSlide() {
	var $cur = $('#carousel li:visible').eq(0).fadeOut('slow');
	if( $cur.prev().length )
		$cur.prev().fadeIn('slow');
	else
		$('#carousel li').eq(0).fadeIn('slow');
	if( slideTO )
		clearTimeout(slideTO);
	slideTO = setTimeout(nextSlide, 10000);
}

function fieldDefaultBlur (strDefault, strID) {
    if ($('#'+strID).val() == strDefault) $('#'+strID).val('');
    return true;
}

function fieldDefault (strDefault, strID) {
    if ($('#'+strID).val() == '') $('#'+strID).val(strDefault);
    return true;
}

function disableButton() {
	if(dynamItElem('submit-button').disabled==true) {
		dynamItElem('submit-button').disabled='';
	} else {
		dynamItElem('submit-button').disabled=true;
     }
}
