// JavaScript Document
var endEffectRunFunsClick = {'.newsContent':'showContentBox'};

$(document).ready(function(){
	$('.wrap').masonry({
		columnWidth: 1, 
		itemSelector: '.box',
		animate: true, 
		animationOptions: {
    		duration: speed,
    		queue: false
  		},
		resizeable: false
 	}, function() {
		fixPapeHeightForIE6();
	});
	bannerEffect();
	//$('#bg-text').click(showAll);
})

function bannerEffect() {
	if (status != 'off') {
		$('#bg-text').fadeIn(2000, function () { showBg(); });
	}
	else {
		$('.main-container').removeClass('hidden');
		$('.header-fadeInArea').removeClass('hidden');
		$('.footer-fadeInArea').removeClass('hidden');
		showAllDiv2(0, 'run_bind');
	}
}

function showBg() {
	if ($('.main-container').hasClass('hidden')) {
		$('.main-container').hide().removeClass('hidden').fadeIn(1000, function () { showHeaderFooter(); })
	}
}

function showHeaderFooter() {
	if ($('.header-fadeInArea').hasClass('hidden') || $('.footer-fadeInArea').hasClass('hidden')) {
		$('#bg-text').fadeOut(2000, function () { showHeader(0); });
		
	}
}

function showHeader() {
	if ($('.header-fadeInArea').hasClass('hidden')) {
		$('.header-fadeInArea').hide().removeClass('hidden').show('drop', { direction: "left" }, 500, function () { showAllDiv(0); });
	}
}

function showFooter() {
	if ($('.footer-fadeInArea').hasClass('hidden')) {
		$('.footer-fadeInArea').hide().removeClass('hidden').show('drop', { direction: "left" }, 500, function () { showEnd(); });
	}
}

function showAllDiv(num) {
	var obj = $('div.effect:eq('+num+')');
	if (obj.html() != null && obj.hasClass('hidden')) {
		if ($('div.effect:eq('+(num+1)+')').html() != null) {
			obj.hide().removeClass('hidden').fadeIn(500);
			num++;
			setTimeout("showAllDiv("+num+")", 200);
		}
		else {
			obj.hide().removeClass('hidden').fadeIn(500, function () { showFooter(); });
		}
	}
}

function showAll() {
	
}

function cloesDetailBox(_obj) {
	var obj = $(_obj).parent().parent();
	$('.newsContent').unbind('click');
	obj.hide('blind', speed, function () { obj.find('.content').html(''); obj.addClass('hidden').show().css({top:0, left:0}); $('.newsContent').click(showContentBox); });
	gDataID = '';
	$('.wrap').masonry({resizeable: true});
}
