function price(d){
	if (d == 0){
		return '';
	}
	else if (d <= 2){
		return '$ ' + (d * 220);
	}
	else {
		return '$ ' + ((2 * 220) + (d-2)*40);
	}
}
function ovht(){
	winht = $(window).height();
	$('#overlay').height(winht);
}
$(function(){
	$('#header').before('<div id="overlay"></div>');
	$('.lbox').hide().css('marginTop', 0);
	$('.lboxlink').click(function(){
		ovht();
		$lbox = $('#' + $(this).attr('rel'));
		marginTop = -$lbox.height()/2;
		$lbox.css('marginTop', marginTop).fadeIn(800);
		$('#overlay').show();
		return false;
	});
	$('#overlay').click(function(){
		$(this).hide();
		$('.lbox').fadeOut(800);
	});
	$('#prslider').slider({
		min: 0,
		max: 10,
		step: 1,
		animate: true,
		start: function(e, ui){
			$('#prslider .callout').fadeIn(400).text(ui.value);
		},
		slide: function(e, ui){
			$('#prslider .callout')
				.text(ui.value).css('left', (ui.value * 10) + '%')
				.parent().siblings('input').attr('value', ui.value)
				.parents('form').find('input[name="price"]').attr('value', price(ui.value))
				.siblings('p').text(price(ui.value));
		},
		stop: function(e, ui){
			$('#prslider .callout').fadeOut(400);
		}
	});
	$('.file p').hover(
		function(){
			$(this).children('input').attr('class', 'on');
		},
		function(){
			$(this).children('input').removeAttr('class');
		}
	);
	$('.file input').click(function(){
		$(this).attr('value', '').siblings('.fileval').text('');
	});
	$('.file input').change(function(){
		val = $(this).attr('value').replace(/^.*[\/\\]/g, '');
		$(this).siblings('.fileval').text(val);
	});
	$('.info input[name="email"]').blur(function(){
		$(this).parents('form').find('#prslider').siblings('p').fadeIn(400);
		setTimeout(function(){
			$('.note').fadeOut(400);
		}, 5000);
	});
});

