function positionBackground() {
	var viewportwidth;
	var posString = "";
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerWidth;
		posString = (viewportwidth/2 - 1020) + 'px 80px';
	} else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
		viewportwidth = document.documentElement.clientWidth;
		posString = (viewportwidth/2 - 1020) + 'px 0';
	} else {
		viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
		posString = (viewportwidth/2 - 1020) + 'px 0';
	}
	$('#bkgd_fibers').css({backgroundPosition: posString});
}

$(document).ready(function() {

	positionBackground();

	_current_process = "";
	// Using multiple unit types within one animation.
	$(".process").click(function() {
		$("#index").animate({ 
			left: "-310px",
			opacity:0
		}, 500 );
		_current_process = "#" + $(this).children(".title").html();
		$(_current_process).animate({ 
			left: "0",
			opacity:1
		}, 500 );
		$(".back_btn").fadeIn("slow");
	});

	$(".process").hover(function() {$(this).addClass('process_hover');}, function() {$(this).removeClass('process_hover');});

	$(".product").hover(function() {$(this).addClass('product_hover');}, function() {$(this).removeClass('product_hover');});

	$("td.product").click(function() {
		window.location.href = "/market/" + ($(this).children('.title').html()).replace(/ /g,'_').toLowerCase();
	});

	$(".press").hover(function() {$(this).addClass('press_hover');}, function() {$(this).removeClass('press_hover');});

	$(".video").hover(function() {$(this).addClass('video_hover');}, function() {$(this).removeClass('video_hover');});

	$(".back_btn").hover(function() {$(this).addClass('back_btn_hover');}, function() {$(this).removeClass('back_btn_hover');});

	$(".back_btn").click(function() {
		$(_current_process).animate({ 
			left: "320px",
			opacity:0
		}, 500 );
		$("#index").animate({ 
			left: "0",
			opacity:1
		}, 500 );
		$(".back_btn").fadeOut("slow");
	});
	$(window).resize(function() {positionBackground();});
});
