//	jQuery code handwritten by Zarino Zappia

$(function(){

	$('body.splash').ready(function(){
	/*	$('#splash_logo').prepend('<img id="glow_fade_1" class="glow_fade_logo" src="img/glow_fade_1.jpg" width="350" height="170" style="display:none" />').find('#glow_fade_1').fadeIn(1200, function(){
			$(this).after('<img id="glow_fade_2" class="glow_fade_logo" src="img/glow_fade_2.jpg" width="350" height="170" style="display:none" />').next().fadeIn(1500, function(){
				$(this).after('<img id="glow_fade_3" class="glow_fade_logo" src="img/glow_fade_3.jpg" width="350" height="170" style="display:none" />').next().fadeIn(1300, function(){
					$(this).after('<img id="glow_fade_4" class="glow_fade_logo" src="img/glow_fade_4.jpg" width="350" height="170" style="display:none" />').next().fadeIn(1200, function(){
						$(this).after('<img id="glow_fade_5" class="glow_fade_logo" src="img/glow_fade_5.jpg" width="350" height="170" style="display:none" />').next().fadeIn(1800, function(){
							$('#glow_fade_6').fadeIn(1500, function(){
								$('#glow_fade_1, #glow_fade_2, #glow_fade_3, #glow_fade_4, #glow_fade_5').remove();
								$('#splash_text').fadeIn(3000);
								$('#skip_intro').fadeOut(1000);
								$('#click_to_glow').animate({'opacity':1}, 1000, function(){
									$(this).fadeIn(1500);
								});
							});
							$('#glow_fade_tagline').animate({'opacity':1}, 1000, function(){
								$(this).fadeIn(1500);
							});
						});
					});
				});
			});
		});		*/
		
		$('#glow_fade_1').fadeIn(1200, function(){
			$('#glow_fade_2').fadeIn(1500, function(){
				$('#glow_fade_3').fadeIn(1300, function(){
					$('#glow_fade_4').fadeIn(1200, function(){
						$('#glow_fade_5').fadeIn(1800, function(){
							$('#glow_fade_6').fadeIn(1500, function(){
								$('#glow_fade_1, #glow_fade_2, #glow_fade_3, #glow_fade_4, #glow_fade_5').remove();
								$('#splash_text').fadeIn(3000);
								$('#skip_intro').fadeOut(1000);
								$('#click_to_glow').animate({'opacity':1}, 1000, function(){
									$(this).fadeIn(1500);
								});
							});
							$('#glow_fade_tagline').animate({'opacity':1}, 1000, function(){
								$(this).fadeIn(1500);
							});
						});
					});
				});
			});
		});
		$('#click_to_glow a').bind('click', function(){
			$('#splash_logo, #splash_text, #click_to_glow a').fadeOut(2000, function(){
				$('#splash').fadeOut(2000);
			});
			return false;
		});
		$('#skip_intro').bind('click', function(){
			$('#splash').fadeOut(600, function(){
				$(this).remove();
			});
			return false;
		});
	});
	
	$('a.next-page, a.prev-page, a.last-page, a.first-page').bind('click', function(){
		target = $(this).attr('href');
		pos = $(target).position();
		salon = $(this).html().toLowerCase();
		$('#content').animate({left: pos.left * -1}, 700);
		if($('body').is('.contact')){
			$('#wallpaper .' + salon).css('z-index',1000).fadeIn(500, function(){
				$(this).css('z-index', 10).siblings('div:visible').hide();
			});
		}
		return false;
	});
	
	$('body.salons').ready(function(){
		$('body.salons #salons-chester, body.salons #salons-wrexham, body.salons #salons-mold').slideDown(500);
	});
	
	$('body.treatments').ready(function(){
		$('body.treatments #treatments-chester, body.treatments #treatments-wrexham, body.treatments #treatments-mold').slideDown(500);
	});

	$('body.treatments-salon').ready(function(){
		$('body.treatments-salon #new').animate({left: '+=100'}, 2000, function(){
			$('#fader').fadeIn(3000);
		});
	});
	
	$('body.contact #wallpaper a').hover(function(){
		$(this).children('img').fadeOut(250);
	}, function(){
		$(this).children('img').fadeIn(250);
	});
	
});
