$(document).ready(function() {
	if($.browser.msie && $.browser.version != '9.0') {
		$('body > section').show();
	} else {
		$('body > section').hide().fadeIn();
	}
	
	$(window).resize(function() {
		if($(window).height() <= 660) {
			$('body > section').css({
				margin: '0 auto',
				padding: '20px 0',
				position: 'static'
			});
		} else if($('body > section').css('position') == 'static') {
			$('body > section').css({
				margin: '-310px 0 0 -440px',
				padding: 0,
				position: 'absolute'
			});
		}
	});
	
	$(window).resize();
	
	$('body > section header nav ul li a').click(function() {
		var navName = $(this).children('span').text();
		
		$('body > section section.article').fadeOut('fast').parent().children('section.intro').fadeOut('fast', function() {
			$(this).parent().children('section.article').children().hide().parent().fadeIn('fast', function() {
				$('body > section > section.article > article > *').hide();
				$('body > section > section.article > article section article a').css({
					left: -740
				});
				
				if(navName == 'introduce' || navName == 'members' || navName == 'portfolio') {
					$('body > section section.article h2 span').height(19).css({
						paddingTop: 8,
						backgroundPositionY: 8
					}).html(navName).parent().css({
						backgroundPositionY: 8
					});
					
					if(navName == 'introduce') {
						$('body > section section.article h2 span').width(94).css({
							backgroundPositionX: 0
						});
					} else if(navName == 'members') {
						$('body > section section.article h2 span').width(95).css({
							backgroundPositionX: -102
						});
					} else if(navName == 'portfolio') {
						$('body > section section.article h2 span').width(84).css({
							backgroundPositionX: -205
						});
					}
				} else if(navName == 'helpdesk') {
					$('body > section section.article h2 span').width(93).height(24).css({
						paddingTop: 6,
						backgroundPositionX: -297,
						backgroundPositionY: 6
					}).html(navName).parent().css({
						backgroundPositionY: 6
					});
				}
				
				if($.browser.mozilla) {
					if(navName == 'introduce' || navName == 'members' || navName == 'portfolio') {
						$('body > section section.article h2 span').height(19).css({
							paddingTop: 8
						}).html(navName).parent().css({
							backgroundPosition: '-392px 8px'
						});
						
						if(navName == 'introduce') {
							$('body > section section.article h2 span').width(94).css({
								backgroundPosition: '0 8px'
							});
						} else if(navName == 'members') {
							$('body > section section.article h2 span').width(95).css({
								backgroundPosition: '-102px 8px'
							});
						} else if(navName == 'portfolio') {
							$('body > section section.article h2 span').width(84).css({
								backgroundPosition: '-205px 8px'
							});
							
							
						}
					} else if(navName == 'helpdesk') {
						$('body > section section.article h2 span').width(93).height(24).css({
							paddingTop: 6,
							backgroundPosition: '-297px 6px'
						}).html(navName).parent().css({
							backgroundPosition: '-392px 6px'
						});
					}
				}
				
				$('body > section > section.article > article > *.' + navName).show();
				$(this).children().fadeIn('medium', function() {
					$('body > section > section.article > article section article a').eq(0).animate({
						left: 0
					});
				});
			});
		});
	});
	
	$('body > section header > a').click(function() {
		$('body > section section.intro').fadeOut('fast').parent().children('section.article').fadeOut('fast', function() {
			$(this).parent().children('section.intro').fadeIn();
		});
	});
	
	$('body > section > section.article > article section nav a').bind({
		mouseover: function() {
			$(this).children('span').css({
				'backgroundPosition': '-80px 0'
			});
		},
		mouseout: function() {
			$(this).children('span').css({
				'backgroundPosition': '-120px 0'
			});
		}
	});
	
	$('body > section > section.article > article section nav a').eq(1).click(function() {
		var seeingObject, seeingLength = $('body > section > section.article > article section article a').length;
		
		for(var Loop = 0; Loop < seeingLength; Loop++) {
			if($('body > section > section.article > article section article a').eq(Loop).css('left') == "0px") {
				seeingObject = Loop;
				
				$('body > section > section.article > article section article a').css({
					left: -740
				});
				
				$('body > section > section.article > article section article a').eq(Loop).css({
					left: 0
				});
			}
		}
		
		$('body > section > section.article > article section article a').eq(seeingObject).animate({
			left: 740
		}, {
			complete: function() {
				$(this).css({
					left: -740
				});
			}
		});
		
		$('body > section > section.article > article section article a').eq(seeingObject + 1 == seeingLength ? 0 : seeingObject + 1).animate({
			left: 0
		});
	});
	
	$('body > section > section.article > article section nav a').eq(0).click(function() {
		var seeingObject, seeingLength = $('body > section > section.article > article section article a').length;
		
		for(var Loop = 0; Loop < seeingLength; Loop++) {
			if($('body > section > section.article > article section article a').eq(Loop).css('left') == "0px") {
				seeingObject = Loop;
				
				$('body > section > section.article > article section article a').css({
					left: 740
				});
				
				$('body > section > section.article > article section article a').eq(Loop).css({
					left: 0
				});
			}
		}
		
		$('body > section > section.article > article section article a').eq(seeingObject).animate({
			left: -740
		}, {
			complete: function() {
				$(this).css({
					left: 740
				});
			}
		});
		
		$('body > section > section.article > article section article a').eq(seeingObject - 1 == -1 ? seeingLength - 1 : seeingObject - 1).animate({
			left: 0
		});
	});
});
