$(document).ready(function(){
	$('.item').each(function(){
		var itempic = $(this).find('.itempic');
		var h4a = $(this).find('h4 a');
		var color = $(this).find('.itempic a').css('color');
		$(this).find('a').each(function(){
			$(this).hover(
				function(){
					$(itempic).css('border','10px solid '+color);
					$(h4a).css('color','#4e6d95');
				},
				function(){
					$(itempic).css('border','10px solid #ccc');
					$(h4a).css('color','#030416');
				}
			);
		});
	});
	
	$('.alsoitem').each(function(){
		var thea = $(this).find('a');
		var color = $(thea).css('backgroundColor');
		$(thea).hover(
			function(){
				$(thea).css('border','10px solid '+color);
			},
			function(){
				$(thea).css('border','10px solid #ccc');
			}
		);
	});
	
	$(window).resize(function(){
		posTommi();
	});
	
	function posTommi() {
		var w = $(window).width();
		var newx = 0;
		if (w<975) {
			newx = 507;
		} else {
			newx = Math.floor(w/2)+39;
		}
		$('#header').css('backgroundPosition',newx+'px 0');
	}
	
	posTommi();
	
	if ($('#propics').length) {
		var imgamt = $('#propics img').length;
		var swid = imgamt*605;
		$('#sleigh').css('width',swid+'px');
		$('#propics img').click(function(){
			var cml = parseInt($('#sleigh').css('marginLeft'));
			cml -= 605;
			if (cml+swid<=0) cml = 0;
			if (cml%605==0) {
				switchPic(cml);
			}
		});
		$('#propicnav span').click(function(){
			var id = $(this).attr('id');
			id = parseInt(id.substr(2,id.length-2))-1;
			switchPic((id*-605));
		});
		
		function switchPic(cml) {
			$('#sleigh').animate({marginLeft: cml+'px'},300);
			var id = cml/605*-1+1;
			$('#propicnav .sel').removeClass('sel');
			$('#pp'+id).addClass('sel');
		}
	}
	
	if ($('#contact').length) {
		$('#website').focus(function(){
			if ($(this).val()=='') {
				$(this).val('http://');
			}
		});
		$('#website').focusout(function(){
			if ($(this).val()=='http://') {
				$(this).val('');
			}
		});
	}
});