// JavaScript Document

$(document).ready(function(){
//	$('.left h1').hover(function(){hidePage()},function(){showPage()});
//	$('.intro').hover('',function(){showPage()});
	$('.innercontents').hover(function(){hidePage()},function(){showPage()});
	
	$('.innercontents li').each(function(){
		$(this).hover(
			function(){showMsg($(this));},
			function(){hideMsg($(this));}
		)
		$(this).click(function(){
			showMsg($(this));
		});
	});
	
	$('.left').click(function(){hidePage()});
	$('.right').click(function(){showComing($(this))});
	$('#header .logo').click(function(){
		showPage();
	});
	
	var fadeSpeed = 1300;
	var showPos = -34;
	var vdohtml = $('.vdo').html();
	
	$('.playvdo').animate({top:showPos},fadeSpeed);
	$('.playvdo').click(function(){
		$('.vdo').html(vdohtml);
		$('.vdo').fadeIn();
		$('.playvdo').stop(true,true).animate({top:0},fadeSpeed);
		$('.closevdo').stop(true,true).animate({top:showPos},fadeSpeed);
	});
	$('.closevdo').click(function(){
		$('.vdo').html('');
		$('.vdo').fadeOut();
		$('.closevdo').stop(true,true).animate({top:0},fadeSpeed);
		$('.playvdo').stop(true,true).animate({top:showPos},fadeSpeed);
	});
});

var hidePage = function() {
	$('.left, .right').stop(true,false).animate({'width':0},'fast','',function(){ $('.innercontents').css('z-index',2); $('.intro').css('z-index',1); })
};

var showPage = function() {
	$('.innercontents').css('z-index',1); $('.intro').css('z-index',2);
	$('.left, .right').stop(true,false).animate({'width':400},'fast')
};

var hideMsg = function(target) {
	target.find('div').stop(true,false).animate({'top':-75},'fast')
};

var showMsg = function(target) {
	target.find('div').stop(true,false).animate({'top':0},'fast')
};

var showComing = function(target) {
	if ($('body').hasClass('zhhk')) {
		window.open(target.children('h1').attr('href'));
	} else {
		$('.right').children('p').stop(true,false).animate({'top':0},'fast','',function(){
			setTimeout( function(){ $('.right').children('p').stop(true,false).animate({'top':-375},'fast')},1000)
		})
	};
};
