function fileList_(){
 var f = $(".v-file p.file"),
	p = $(".v-file"),
	l = $(".file-list"),
	c = $(".file-list p").length;
	//console.log(c);
	f_sta = true;

	if(c > 0){
		f.find("b").html(c);
		f.on("click", function(){
			if(f_sta){
				f_sta = false;
				$(this).parent(p).addClass("on");
				l.slideDown();
			} else {
				f_sta = true;
				$(this).parent(p).removeClass("on");
				l.stop().slideUp();
			};
		});
		/*
		p.on("mouseleave", function(){
			f_sta = true;
			$(this).removeClass("on");
			l.stop().slideUp();
		});
		*/
	} else {
		$(".file b").css({"color":"#666", "font-weight":"normal"});
	};
};


function tabBoxTop(){
	var $tabArea = $(".loginTab-Type"),
	$tab = $(".tab"),
	$tabH = $tab.height() + 1,
	$box = $(".tab-Area"),
	$boxH = $(".tab-Area").height(),
	$h = $tabH + $boxH;
	
	//$tabArea.css({"height":$h});
	$box.css({"top":$tabH});
};

function loginTab(){
	var $tab = $(".tab"),
	$tabH = $tab.height() + 1,
	$box = $(".tab-Area"),
	$boxH = $(".tab-Area").height(),
	$h = $tabH + $boxH;
	
	//console.log($h);
	$tab.each(function(index){
		$(this).attr("rel","#tab_" + index);
	});
	
	$box.each(function(index){
		$(this).attr("id","tab_" + index);
	});

	$(".tab-Area:not(" + $(".tab.on").attr("rel") + ")").hide();
	$tab.on("click", function(){
		$(".tab").removeClass("on");
		$(this).addClass("on");
		$box.hide();
		$($(this).attr("rel")).show();
	});
};

function inputPlaceHoder(){
	$(".input-p").find("input[type=text], input[type=password], textarea").each(function(){
		if($(this).val() == ""){
			$(this).siblings("label").show();
		} else {
			$(this).siblings("label").hide();
		};

		$(this).on("click focus", function(){
			if($(this).val() == ""){
				$(this).siblings("label").hide();
			};
		});

		$(this).on("focusout", function(){
			if($(this).val() == ""){
				$(this).siblings("label").show();
			};
		});
	});

	$(".input-p2").find("input[type=text], input[type=password], textarea").each(function(){
		if($(this).val() == ""){
			$(this).siblings("label").show();
		} else {
			$(this).siblings("label").hide();
		};

		$(this).on("click focus", function(){
			if($(this).val() == ""){
				$(this).siblings("label").hide();
			};
		});

		$(this).on("focusout", function(){
			if($(this).val() == ""){
				$(this).siblings("label").show();
			};
		});
	});
};

function faq_fn(){
	var $f = $(".hy_faqType>dt"),
	$q = $(".hy_faqType>dd");

	$f.click(function(){
		var answer = $(this).next("dd");
		if(answer.is(":visible")){
			$f.removeClass("on");
			answer.slideUp();
		} else {
			//$q.hide();
			$f.removeClass("on");
			$(this).addClass("on");
			answer.slideDown();

			fun_resize(); // pds.list.php 선언
		};
	});
};



$(document).ready(function(){
	fileList_();
	tabBoxTop();
	loginTab();
	inputPlaceHoder();
	faq_fn();
});


