var $open = false;
var $slide = false;
PZERO = function(){};


PZERO.prototype.lookbook = function(){
	
	$('.lookbook_filter a').live('click', function(e){
		$pzero.scrollTo($(this).attr('href'));
		return false;
	});
	
}


PZERO.prototype.scrollTo = function(e)
{
	$('html, body').stop(true, true).animate({
		scrollTop: $(e).offset().top
	}, 500);
	
	window.location.hash = e;
	return false;
}



PZERO.prototype.homeShow = function(){
	
	$('#splash_one img.preview').delay(600).animate({
		'bottom' : 40
	}, 600, 'easeOutExpo');
	
	$('#splash_one div').delay(600).animate({
		'bottom' : 0
	}, 500, 'easeOutExpo');


	$('#splash_two img.preview').delay(700).animate({
		'bottom' : 0
	}, 900, 'easeOutExpo');
	
	$('#splash_two div').delay(700).animate({
		'bottom' : 90
	}, 1000, 'easeOutExpo');

	
	$('#splash_three img.preview').delay(800).animate({
		'top' : 0
	}, 900, 'easeOutExpo');
	
	$('#splash_three div').delay(800).animate({
		'top' : 160
	}, 600, 'easeOutExpo');
	
	
	$('#splash_four img.preview').delay(900).animate({
		'top' : 0
	}, 1000, 'easeOutExpo');
	
	$('#splash_four div').delay(900).animate({
		'top' : 140
	}, 700, 'easeOutExpo');
	
	
	$('#splash_five img.preview').delay(1000).animate({
		'top' : 0
	}, 1100, 'easeOutExpo');
	
	$('#splash_five div').delay(1000).animate({
		'top' : 160
	}, 800, 'easeOutExpo');


	$('#splash_six img.preview').delay(1100).animate({
		'bottom' : 60
	}, 600, 'easeOutExpo');
	
	$('#splash_six div').delay(1100).animate({
		'bottom' : 10
	}, 500, 'easeOutExpo');


	$('#splash_seven img.preview').delay(800).animate({
		'top' : 0
	}, 1100, 'easeOutExpo');
	
	$('#splash_seven div').delay(800).animate({
		'top' : 120
	}, 800, 'easeOutExpo', function(){
		$('.line').fadeIn();
	});



	$('#hp_box_01').delay(600).animate({
		'top' : 135,
		'opacity' : 1
	}, 500);
	
	$('#hp_box_02').delay(200).animate({
		'top' : 45,
		'opacity' : 1
	}, 700);
	
	$('#hp_box_03').delay(200).animate({
		'top' : 270,
		'opacity' : 1
	}, 700);
	

	$('#home #btn_tumblr').delay(200).animate({
		'top' : 220,
		'opacity' : 1
	}, 500);
}

PZERO.prototype.gallery = function(){
	var $rel;
	var $abs_title = '';
	var $abs_text = '';
	$('a[class*="gallery"]').colorbox({
		'onComplete': function(){
			$pzero.scrollTo('#btn_menu');	
			$pos = $('a[class*="gallery"]').index(this)+1;
			$rel = $(this).attr('class');
			$abs_title = $(this).parent('li').find('.abs_title').text();
			$abs_desc = $(this).parent('li').find('.abs_desc').text();
			//$('#cboxTitle').html('<h2>'+$abs_title+'</h2><h5>'+$abs_text+'</h5>');
			window.location.hash = 'photo'+$pos;
			$('#cboxTitle').hide();
		},
		'onCleanup': function(){
			window.location.hash = '';
		},
		'photo' : true,
		'rel'	: ''+$rel+'',
		'fixed' : true,
		//'title'	: '&nbsp;',
		'width'	: 980,
		'height': 650
	});
	
	$('#cboxLoadedContent').live('click', function(){
		$.colorbox.close();
		return false;
	});
	
	
	$hash = window.location.hash;
	if($hash != '')
	{
		$open = $hash.split('#photo').join('');
		$('a[class*="gallery"]').eq($open-1).trigger('click');	
	}
}



PZERO.prototype.footerNav = function(){
	$('.f_slide').append('<a href="#" class="btn_f_close"></a>');
	
	$('.btn_f_close').live('click', function(){
		$('.f_slide').slideUp();	
		return false;
	});
	
	$('#contacts').find('li').eq(2).addClass('large');
	
	
	$('#btn_disclaimer').live('click', function(){
		$('#company_info, #contacts,').slideUp(200, function(){
			if($open)
			$slide = true;
			
			$open = true;
			if($slide)
			{
			$('#disclaimer').slideDown(200, function(){
				$pzero.scrollTo('#footer');	
				$open = false;
				$slide = false;
			});
			}
		});
		
		return false;	
	});

	$('#btn_company').live('click', function(){
		$('#disclaimer, #contacts').slideUp(200, function(){
			if($open)
			$slide = true;
			
			$open = true;
			if($slide)
			{
				$('#company_info').slideDown(200, function(){
					$pzero.scrollTo('#footer');	
					$open = false;
					$slide = false;
				});	
			}
		});
		
		return false;	
	});

	$('#btn_contacts').live('click', function(){
		$('#company_info, #disclaimer').slideUp(200, function(){
			if($open)
			$slide = true;
			
			$open = true;
			if($slide)
			{
				$('#contacts').slideDown(200, function(){
					$pzero.scrollTo('#footer');	
					$open = false;
					$slide = false;
				});	
			}
		});
		
		return false;	
	});
}


PZERO.prototype.openMenu = function(){
	$('#btn_menu').live('click', function(){
		$('#menu').fadeIn(200, function(){
			

			$('#menu_five').delay(200).animate({
				'top' : 370
			}, 600, 'easeOutExpo');
			
			$('#menu_four').delay(300).animate({
				'top' : 371
			}, 600, 'easeOutExpo');
			
			$('#menu_three').delay(400).animate({
				'top' : 370
			}, 600, 'easeOutExpo');
			

			$('#menu_six').delay(350).animate({
				'top' : 220
			}, 600, 'easeOutExpo');
			

			$('#menu_seven').delay(350).animate({
				'top' : 370
			}, 600, 'easeOutExpo');
			

			$('#menu_two').delay(400).animate({
				'top' : 140
			}, 600, 'easeOutExpo');
			
			$('#menu_one').delay(400).animate({
				'top' : 157
			}, 600, 'easeOutExpo', function(){
				$('.line').fadeIn();
			});
			
		});
		
		
		return false;	
	});
	
	$('#btn_close_menu').live('click', function(){
		$('#menu').fadeOut();
		return false;	
	});
	
	
	resetMenu = function(){
		$('#menu_one, #menu_two, #menu_three, #menu_four, #menu_five').css({
			'top' : -1000
		});	
	}
	
	resetMenu();
}


$pzero = new PZERO();

$(function(){
	$pzero.lookbook();
	$pzero.homeShow();
	$pzero.gallery();
	$pzero.openMenu();
	$pzero.footerNav();
});


$(window).load(function(){
//	$('#btn_menu').click()
});



