var pos = 0;
var temp_pos = 100;
var div_bio = null;
var id_time = 0;
var movecnt = 0;


function showBio( btn , dr_index ){
	
	var btn_img = btn.getElementsByTagName("img")[0];
	var flag = "";
	
	div_bio = document.getElementById("bio");
	clearInterval( id_time );

	if( btn_img.src.indexOf( "plus" ) > -1 ){
		btn_img.src = "/images/bio_minus.gif";
		flag = "plus";

		if( dr_index == "1" ){
			pos = 400;
		}else if( dr_index == "2" ){
			pos = 315;
		}else if( dr_index == "3" ){
			pos = 190;
		}

		document.getElementById( "bio_dr" ).style.display = "block";

	}else{
		btn_img.src = "/images/bio_plus.gif";
		flag = "minus";
		pos = 100;

		document.getElementById( "bio_dr" ).style.display = "none";
	}	
	
	movecnt = 0;
	id_time = setInterval( resizeBio , 10 );

}

function resizeBio(){

	var t = temp_pos + ( ( pos - temp_pos ) / 5 );	
	temp_pos = t;
	div_bio.style.height = t + "px";
	movecnt++;

	if( movecnt >= 30 ){
		clearInterval( id_time );
	}
	
}


function goWrite(){
	
	location.href = "/admin/write.php?gb=" + document.forms[0].gb.value;

}

function goWrite2(){
	
	location.href = "/admin/write_loc.php?gb=" + document.forms[0].gb.value+"&page=" + document.forms[0].page.value;

}

function goList(){
	
	location.href = "/admin/list.php?gb=" + document.forms[0].gb.value;

}

function goList2(){
	
	location.href = "/admin/list_loc.php?gb=" + document.forms[0].gb.value + "&page=" + document.forms[0].page.value;

}


function goUpdate(){
	
	var f = document.forms[0];

	if( f.title_mv.value == "" ){
		alert( "제목을 입력해 주십시오." );
		f.title_mv.focus();
		return;
	}

	if( f.cate_mv.value == "" ){
		alert( "카테고리를 입력해 주십시오." );
		f.cate_mv.focus();
		return;
	}

	if( f.desc_mv.value == "" ){
		alert( "설명을 입력해 주십시오." );
		f.desc_mv.focus();
		return;
	}

	if( f.img_mv.value == "" && f.idx.value == "" ){
		alert( "썸네일 이미지를 입력해 주십시오." );
		return;
	}

	if( f.path_mv.value == "" ){
		alert( "동영상 주소를 입력해 주십시오." );
		f.path_mv.focus();
		return;
	}
	
	if( f.idx.value == "" ){
		f.work.value = "insert";
	}else{
		f.work.value = "update";
	}
	
	f.action = "/admin/proc.php";
	f.submit();

}


function goUpdate2(){
	
	var f = document.forms[0];

	if( f.txt_pic.value == "" ){
		alert( "설명을 입력해 주십시오." );
		f.txt_pic.focus();
		return;
	}	

	if( f.path_pic.value == "" && ! document.getElementById("p_img").getElementsByTagName("img") ){
		alert( "이미지를 선택하여 주십시오." );
		f.path_pic.focus();
		return;
	}	
	
	if( f.idx.value == "" ){
		f.work.value = "insert";
	}else{
		f.work.value = "update";
	}
	
	f.action = "/admin/proc_loc.php";
	f.submit();

}

function goDelete(){
	
	var re = confirm( "삭제하시겠습니까?" );
	if( re ){
		var f = document.forms[0];
		f.work.value = "delete";
		f.work.action = "/admin/proc.php";
		f.submit();
	}

}

function goDelete2(){
	
	var re = confirm( "삭제하시겠습니까?" );
	if( re ){
		var f = document.forms[0];
		f.work.value = "delete";
		f.work.action = "/admin/proc_loc.php";
		f.submit();
	}

}



function showMV( mtitle , mdesc , mpath , mfile ){

	document.getElementById("mvframe").src = mpath;
	document.getElementById("desc_mv").getElementsByTagName("span")[0].innerHTML = mtitle;
	document.getElementById("desc_mv").getElementsByTagName("span")[1].innerHTML = mdesc;
	document.getElementById("desc_mv").getElementsByTagName("a")[0].href = mfile;

}

function openArchive( _a ){

	var _img = _a.getElementsByTagName( "img" )[0];
	if( _img.src.indexOf( "open" ) > -1 ){
		_img.src = "/images/close.gif";
		document.getElementById( "mv_list_archive" ).style.display = "";
		document.getElementById( "mv_list" ).style.display = "none";
	}else{
		_img.src = "/images/open.gif";
		document.getElementById( "mv_list" ).style.display = "";
		document.getElementById( "mv_list_archive" ).style.display = "none";
	}

}
var work = null;
var navi_2depth = null;
function showContent(){
	
	var flag = "";	
	work = document.getElementById("work");
	navi_2depth = document.getElementById("navi_2depth");

	clearInterval( id_time );

	if( work.style.display == "none" ){
		pos = 200;
		work.style.display = "block";
	}else{
		pos = 100;
		work.style.display = "none";
	}	
	
	movecnt = 0;
	id_time = setInterval( resizeContent , 10 );

}

function showContent2(){
	
	var flag = "";	
	work = document.getElementById("work2");
	navi_2depth = document.getElementById("navi_2depth");

	clearInterval( id_time );

	if( work.style.display == "none" ){
		pos = 250;
		work.style.display = "block";
	}else{
		pos = 160;
		work.style.display = "none";
	}	
	
	movecnt = 0;
	id_time = setInterval( resizeContent , 10 );

}

function resizeContent(){

	var t = temp_pos + ( ( pos - temp_pos ) / 5 );	
	temp_pos = t;

	navi_2depth.style.height = t + "px";
	movecnt++;

	if( movecnt >= 30 ){
		clearInterval( id_time );
	}
	
}

function showEnKor( n ){

	if( n == 1 ){

		document.getElementById("en").style.display = "block";
		document.getElementById("kor").style.display = "none";

	}else if( n == 0 ){

		document.getElementById("kor").style.display = "block";
		document.getElementById("en").style.display = "none";

	}

}


function showMenu(){
	
	document.getElementById("navi_2depth").style.display = "block";

}

function setWidth(){

}

function show_subtext( n ){
	
	var h_cont = [ 700 , 900 , 800 , 800 , 900 , 800 , 1000 , 900 ];
	document.getElementById( "content_in_type_02" ).style.height = h_cont[ n - 1 ] + "px";
	
	for( var i = 1 ; i <= 8 ; i++ ){

		if( i == n ){
			document.getElementById( "prod_sub_0" + i ).style.display = "block";
			document.getElementById( "menu_prod_01" ).getElementsByTagName("a")[ i - 1 ].className = "now";
		}else{
			document.getElementById( "prod_sub_0" + i ).style.display = "none";
			document.getElementById( "menu_prod_01" ).getElementsByTagName("a")[ i - 1 ].className = "";
		}
	}
}

function show_subtext_t( n ){
	
	var h_cont = [ 700 , 900 ];
	document.getElementById( "content_in_type_02" ).style.height = h_cont[ n - 1 ] + "px";
	
	for( var i = 1 ; i <= 2 ; i++ ){

		if( i == n ){
			document.getElementById( "prod_sub_0" + i ).style.display = "block";
			document.getElementById( "menu_prod_01" ).getElementsByTagName("a")[ i - 1 ].className = "now";
		}else{
			document.getElementById( "prod_sub_0" + i ).style.display = "none";
			document.getElementById( "menu_prod_01" ).getElementsByTagName("a")[ i - 1 ].className = "";
		}
	}
}

function sendMail(){

	var f = document.forms[0];

	if( f.email.value == "" || f.email.value.indexOf("@") == -1 ){
		alert( "Invalid E-mail address." );
		f.email.focus();
		return;
	}

	if( f.message.value == "" ){
		alert( "Insert Message." );
		f.message.focus();
		return;
	}

	f.submit();

}
