
function moveFocus(num,fromform,toform)
{
	var str = fromform.value.length;
	if(str == num)
		toform.focus();
}
function checkSpace( str )
{
     if(str.search(/\s/) != -1){
     	return 1;
     }

     else {
         return "";
     }
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function goList(){
   sform.exclude.value="1";
   sform.submit();
}

var timer_clear_num = 0;
var timer;

var g_BrowserWidth	= window.innerWidth;
var g_hasLayers		= (document.layers);
var g_hasAll		= (document.all);
var g_hasGetElement = (document.getElementById);

var IE40 = (navigator.appVersion.indexOf("MSIE 4.0") >= 0);
var IE45 = (navigator.appVersion.indexOf("MSIE 4.5") >= 0);
var NS7  = ((navigator.userAgent.indexOf("Netscape/7") >= 0) || (navigator.userAgent.indexOf("Safari") >= 0));
var NS6  = (!g_hasAll && g_hasGetElement);	// this test is positive for NS7 also

var g_sepText;
if (g_hasGetElement || g_hasAll) {
	if (IE40)
		g_sepText = "<font color='#999999' size='1'>&nbsp;|&nbsp;</font>";
	else
		g_sepText ="<span class='subNav' style='color:#999999'>&nbsp;|&nbsp;</span>";
} else if (g_hasLayers) {
	g_sepText = "&nbsp;|&nbsp;";
}

function showDDNav(itemId) { 
	var obj = document.getElementById(itemId);
	obj.style.display = 'block'
}

function hideDDNav(itemId) {
	var obj = document.getElementById(itemId);
	obj.style.display = 'none';
}

function reSize() 
{
	try{
			var objBody = Category.document.body;
			var objFrame = document.all["Category"];
			ifrmHeight = objBody.scrollHeight + (objBody.offsetHeight - objBody.clientHeight);

			if (ifrmHeight > 10) 
			{
			   objFrame.style.height = ifrmHeight
			}
			else
			{
			   objFrame.style.height = 10;
			}
			objFrame.style.width = '180';
        }catch(e){}
}

function init_iframe() 
{
	reSize();

	if(timer_clear_num >= 100) {		// 1초 후 타이머 clear
		clearTimeout(timer);
	} else {
		timer_clear_num++;
		timer = setTimeout('init_iframe()',100);
	}
}
init_iframe();

function window_open(width, height, name, url)
{
     window.open(url,name,"width="+width+" height="+height+" left=0 top=0 scrollbars=1"); 
}

var ck_mode = 0;
function all_select()
{
    var form = document.forms.list_form;
	if(ck_mode == 0)
	{
		flage1 = false;
		flage2 = true;
		this.btn_display.src="/common/images/img/btn_lbox_unlock.gif";
		this.btn_display2.src="/common/images/img/btn_lbox_unlock.gif";
		ck_mode = 1;
	}
	else
	{
		flage1 = true;
		flage2 = false;
		this.btn_display.src="/common/images/img/btn_allselec.gif";
		this.btn_display2.src="/common/images/img/btn_allselec.gif";
		ck_mode = 0;	
	}
    for(var i=0; i< form.length; i++)
	{
		if(form[i].checked == flage1)
		{
			form[i].checked=flage2;
		}
	}	
}

function all_select_one()
{
    var form = document.forms.list_form;
	if(ck_mode == 0)
	{
		flage1 = false;
		flage2 = true;
		this.btn_display.src="/images/common/select_all_off.gif";
		ck_mode = 1;
	}
	else
	{
		flage1 = true;
		flage2 = false;
		this.btn_display.src="/images/common/select_all_on.gif";
		ck_mode = 0;	
	}
    for(var i=0; i< form.length; i++)
	{
		if(form[i].checked == flage1)
		{
			form[i].checked=flage2;
		}
	}
}
function del_select(act_url)
{
	var form = document.forms.list_form;
	var cnt = 0;

	for(var i=0; i< form.length; i++)
	{
		if(form[i].checked == true)
		{
			cnt++;
		}
	}
	if(cnt==0)
	{
		alert("이미지를 선택하세요.");
	}
	else
	{
		 var mycon = confirm("선택한 이미지를 삭제하겠습니까?");
		 if(mycon == true)
		 {
			document.list_form.target = "hiddenframe";
			document.list_form.action = act_url;
			document.list_form.submit();
		 }
	}
}

function all_input(cnt)
{
	var form = document.forms.list_form
	var check_cnt = 0;
    for(var i=0; i< form.length; i++)
	{
		//if(eval("form.check"+i+".checked") == true)
		if(form[i].checked==true)
		{
			check_cnt++;
		}
	}
	if(check_cnt == 0)
	{
		alert("이미지를 체크하세요.");
		return;
	}
        list_form.target = "pop_result";
	    list_form.action="./pop_result.php/?cnt="+cnt;
        win=window.open(list_form.action,list_form.target,"width=540 height=350 left=0 top=0 scrollbars=yes");
        list_form.submit();
		win.window.focus();
}


// 컨텐츠 프리뷰 창
function cont_detail(cmd, cont_seq, cont_code, mem_flag, cont_group, cont_type, cont_flag, premium_flag, offset, SearchSort, search, SearchFilter, tot_count, update_seq, mode)
{
	url = '/search/preview.php?cmd='+cmd+'&cont_seq=' + cont_seq + '&cont_code='+cont_code+'&mem_flag=' + mem_flag + '&cont_group=' + cont_group + '&cont_type=' + cont_type + '&cont_flag='+cont_flag+'&premium_flag='+premium_flag+'&offset='+offset+'&SearchSort='+SearchSort+'&SearchFilter='+SearchFilter+'&search='+search + '&tot_count=' + tot_count + '&update_seq=' + update_seq + '&mode=' + mode;
	win=window.open(url, 'it_cont_detail', 'left=20, top=20, width=930, height=747, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=1');
	win.window.focus();
}

// 슬라이드 창
function view_slideshow(cont_group, cont_type, cont_flag, offset, SearchSort, search, SearchFilter, cmd, update_seq, mode)
{
	url = '/search/slideshow_full.php?cont_group=' + cont_group + '&cont_type=' + cont_type + '&cont_flag='+cont_flag+'&offset='+offset+'&SearchSort='+SearchSort+'&SearchFilter='+SearchFilter+'&search='+search+'&cmd='+cmd+'&update_seq='+update_seq+'&mode='+mode;
	win=window.open(url, 'slidershow', 'left=20, top=20, width=1210, height=748, toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=1');
	win.window.focus();
}




//------------------------------------------------------------------------
// 사운드 재생 관련 함수

var nowTime;
var totalTime;
var isInterval = false;
var Player;
var id;
var p_list_cont_idx;
var sound_status;

// 음악 재생
function playMusic()
{

	var sound_bg = document.getElementById("sound_bg_" + p_list_cont_idx);
	var sound_bt = document.getElementById("sound_bt_" + p_list_cont_idx);
	var sound_ico = document.getElementById("sound_ico_" + p_list_cont_idx);
	var sound_time = document.getElementById("sound_time_" + p_list_cont_idx);
	
	sound_bg.style.background = 'url( /common/images/img/sound_bg_play.gif )';
	sound_bt.src = '/common/images/img/btn_s_hear_off.gif';
	sound_ico.src = '/common/images/img/ico_sound_stop.gif';
	sound_time.style.display = '';

	Player.Play();
}


// 음악 정지
function stopMusic()
{
	if (p_list_cont_idx)
	{
		var sound_bg = document.getElementById("sound_bg_" + p_list_cont_idx);
		var sound_bt = document.getElementById("sound_bt_" + p_list_cont_idx);
		var sound_ico = document.getElementById("sound_ico_" + p_list_cont_idx);
		var sound_time = document.getElementById("sound_time_" + p_list_cont_idx);
		
		sound_bg.style.background = 'url( /common/images/img/sound_bg_stop1.gif )';
		sound_bt.src = '/common/images/img/btn_s_hear_on.gif';
		sound_ico.src = '/common/images/img/ico_sound_play.gif';
		sound_time.style.display = 'none';

		clearInterval( id );
		Player.Stop();
	}
	return false;
}

function startPlay(v_list_cont_idx)
{
	Player = document.all.Player;
	stopMusic();

	p_list_cont_idx = v_list_cont_idx;

	addr = document.getElementById("FileName_" + p_list_cont_idx).value;

	Player.Filename = addr;

	// 노래 제목 삽입
	//titleDiv.innerHTML = Player.currentMedia.name;

	// 변경된 프로그레스바 크기 지정
	//progressBarWidth = document.getElementById("progress_td").clientWidth;

	// 프로그레스바 초기화
	//showProgressBar(0);

	// 음악 재생
	playMusic();

	// 볼륨조절 슬라이더 셋팅
	//slider.setValue( getVolume() );

	// 반복 체크 값 true
	isInterval = true;

	startTimeInterval(); // 재생시간 보기
}


// 반복적으로 재생시간을 보여주는 함수를 실행
function startTimeInterval()
{
	id = setInterval( "showPlayTime()", 1000 );
}


// 재생시간 출력
function showPlayTime() {
	try
	{
		nowTime   = Player.currentPosition; // 현재 재생시간 추출
		totalTime = Player.duration; // 총 재생시간 추출

		if (nowTime == 0) {
			stopMusic();
		}

		document.getElementById("nowTimeDiv_" + p_list_cont_idx).innerHTML  = changeTimeType( nowTime );
		document.getElementById("fullTimeDiv_" + p_list_cont_idx).innerHTML = changeTimeType( totalTime );

		// 재생바 출력
		//percentage = Math.floor( ( nowTime / totalTime ) * 100 );
		//showProgressBar( percentage );
	}
	catch( e )
	{
		if( isInterval == true )
		{
			stopMusic(p_list_cont_idx);
			alert("재생 가능한 파일이 아닙니다.");

			clearInterval( id );
			isInterval = false;
		}
	}
}

/*
	초로 되어있는 시간을 분/초 나눠서 보여줌
	@param time 초단위의 재생시간
*/
function changeTimeType( time ) {

	var result;

	// 시간이 1분 초과했을 경우
	if( time >= 0 ) {
		result = Math.floor( time / 60 ) + ":";

		if( time % 60 != 0 ) result += Math.round(time % 60);

	} else {

		result = time;
	}

	return result;
}

function soundProc(v_list_cont_idx) {

	if(sound_status == 'Y'){
		if(v_list_cont_idx == p_list_cont_idx)
			stopMusic(v_list_cont_idx);
		else
			startPlay(v_list_cont_idx);

		sound_status = 'N';
	} else {
		startPlay(v_list_cont_idx);
		sound_status = 'Y';
	}
}
//------------------------------------------------------------------------