
$(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 + "');");
		});

		document.execCommand("BackgroundImageCache",false,true);
	}


	// contact us slider
	$('#contact-us').hover(
		function() {
			if(!IE6)
				$(this).animate({ top: '-161px' }, 800);
		},
		function() {
			if(!IE6)
				$(this).animate({ top: '0px' }, 800);
		}
	);

	// project portfolio mouseovers
	$('a.project').mouseover(
		function() {
			$(this).next().next().next().children("img").fadeIn(200);
		}
	);
	$('.project-hover').mouseout(
		function() {
			$('.project-hover').fadeOut(200);
		}
	);


	// textarea blurs for contact form
	$('#comments').focus(function() {
		if(this.value=='don\'t be shy, you can tell us...') {
			this.value = '';
		}
	}).blur(function() {
		if(this.value=='') {
			this.value = 'don\'t be shy, you can tell us...';
		}
	});


	// hover effect on gallery tiles in overlay
	$('.tiles').live("mouseover", function() {
		$(this).parent().children('a').children('.tile-hover:hidden').fadeIn(200);
	});
	$('.tile-hover').live("mouseout", function() {
		$('.tile-hover').fadeOut(200);
	});

});


// featured case study overlay
function caseStudy(project) {
	dynamItLoad(project, null, 880, 620, function() { 
		$('.lg-img-contain').hide(); 
		$('.lg-img-contain:first').show(); 
		$('.dcms.slides:first').show();
	});
}

// change the image being viewed
function showLargeImage(index) {
	index = index - 1;
	$('.lg-img-contain').fadeOut(200);
	$('.lg-img-contain').eq(index).fadeIn(200);
	$('.dcms.slides').hide();
	$('.dcms.slides').eq(index).show();

}

// show previous slide
function showPrevSlide() {
	// find the visible slide
	var sel = $('.lg-img-contain:visible');
	var selText = $('.dcms.slides:visible');

	// if this is the first slide (there are no previous, show the last one
	if($('.lg-img-contain:visible').prev('.lg-img-contain').length == 0) { 
		$('.lg-img-contain').hide();
		$('.lg-img-contain:last').fadeIn(200);
		$('.dcms.slides').hide();
		$('.dcms.slides:last').fadeIn(200);
	} else { 
		// if there is a slide previous to this one, show it	
		$('.lg-img-contain').hide();
		$('.dcms.slides').hide();
		sel.prev('.lg-img-contain:first').show();
		selText.prev('.dcms.slides').show();
	}
}

// show next slide
function showNextSlide() {
	var sel = $('.lg-img-contain:visible');
	var selText = $('.dcms.slides:visible');

	if($('.lg-img-contain:visible').next('.lg-img-contain').length == 0) { 
		$('.lg-img-contain').hide();
		$('.lg-img-contain:first').fadeIn(200);
		$('.dcms.slides').hide();
		$('.dcms.slides:first').fadeIn(200);
	} else { 
		$('.lg-img-contain').hide(); 
		$('.dcms.slides').hide();
		sel.next('.lg-img-contain:first').show();
		selText.next('.dcms.slides').show();
	}
}