﻿// JScript File
function _ws_(id) 
{ 
	var _object = id.innerHTML; 
	_object = _object.replace("<!--", ""); 
	_object = _object.replace("-->" , ""); 
	document.write(_object); id.id=""; 
}

function na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
    toolbar_str = toolbar ? 'yes' : 'no';
    menubar_str = menubar ? 'yes' : 'no';
    statusbar_str = statusbar ? 'yes' : 'no';
    scrollbar_str = scrollbar ? 'yes' : 'no';
    resizable_str = resizable ? 'yes' : 'no';
    window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
}

function MM_jumpMenu1(targ,selObj,restore){ //v3.0
  if (selObj.options[selObj.selectedIndex].value){
  window.open(selObj.options[selObj.selectedIndex].value,'_top');
  }
  if (restore) selObj.selectedIndex=0;
}

/*************************************************
// 체크박스의 체크 갯수를 확인합니다.
*************************************************/
function GetCheck()
{
    var ck = 0;
    document.all.cnumlist.value = "";
    
    for(var i = 0 ;i < document.all.length; i++)
    {
        if(document.all[i].type == 'checkbox' && document.all[i].name == 'cbcnum')
        {
            if(document.all[i].checked)
            {                
                if(ck > 0)
                {
                    document.all.cnumlist.value += ":" + document.all[i].value;
                }
                else
                {
                    document.all.cnumlist.value = document.all[i].value;
                }
                
                ck++;
            }
        }
    }
    
    return ck;
}

/*************************************************
// 체크박스를 전부 체크합니다.
*************************************************/
function allCheck()
{       
    for(var i = 0 ;i < document.all.length; i++)
    {
        if(document.all[i].type == 'checkbox' && document.all[i].name == 'cbcnum')
        {
            document.all[i].checked = true;            
        }
    }    
}

/*************************************************
// 체크박스의 체크를 전부 해제합니다.
*************************************************/
function allCheckfalse()
{       
    for(var i = 0 ;i < document.all.length; i++)
    {
        if(document.all[i].type == 'checkbox' && document.all[i].name == 'cbcnum')
        {
            document.all[i].checked = false;            
        }
    }    
}

function ContentEdit()
{
    var cnt = GetCheck();
    if(cnt == 0)
    {
        alert("수정할 게시물을 선택하세요.");
        return;
    }
    
    if(cnt > 1)
    {
        alert("수정할 게시물은 1개만 선택하세요.");
        return;
    }
    
    window.location.href = 'write.aspx?cate=' + document.all.catecode.value + '&cnum=' + document.all.cnumlist.value + '&flag=edit';
}

function ContentDel()
{
    var cnt = GetCheck();
    if(cnt == 0)
    {
        alert("삭제할 게시물을 선택하세요.");
        return;
    }
    
    window.open('/_admin/delcontent.aspx?cate=' + document.all.catecode.value + '&cnum=' + document.all.cnumlist.value, 'write', 'left=0,top=0,width=400,height=200')
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

//링크 한꺼번에 없애기
function bluring(){ 
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus(); 
} 

document.onfocusin=bluring; 
//링크 없애기 끝

String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}        

function searchbtnClick()
{
    document.all.txtSearch.value = document.all.txtSearch.value.replace(/-/gi, "");
    document.all.txtSearch.value = document.all.txtSearch.value.replace(/'/gi, "");
    document.all.txtSearch.value = document.all.txtSearch.value.replace(/\"/gi, "");
    document.all.txtSearch.value = document.all.txtSearch.value.replace(/&/gi, "");
    document.all.txtSearch.value = document.all.txtSearch.value.replace(/,/gi, "");       

    if(document.all.txtSearch.value.trim() == "")
    {
        alert("검색어를 입력하세요.");
        document.all.txtSearch.value = "";
        document.all.txtSearch.focus();
    }
    else
    {
        if(document.all.txtSearch.value.length < 2)
        {
            alert("검색어는 2자 이상 입력하셔야 합니다.");
            document.all.txtSearch.focus();
        }
        else
        {
            location.href = "search.aspx?word=" + document.all.txtSearch.value.trim();
        }
    }
}

function searchbtnClick1()
{
    document.all.txtSearch1.value = document.all.txtSearch1.value.replace(/-/gi, "");
    document.all.txtSearch1.value = document.all.txtSearch1.value.replace(/'/gi, "");
    document.all.txtSearch1.value = document.all.txtSearch1.value.replace(/\"/gi, "");
    document.all.txtSearch1.value = document.all.txtSearch1.value.replace(/&/gi, "");
    document.all.txtSearch1.value = document.all.txtSearch1.value.replace(/,/gi, "");
    
    if(document.all.txtSearch1.value.trim() == "")
    {
        alert("검색어를 입력하세요.");
        document.all.txtSearch1.value = "";
        document.all.txtSearch1.focus();
    }
    else
    {
        if(document.all.txtSearch1.value.length < 2)
        {
            alert("검색어는 2자 이상 입력하셔야 합니다.");
            document.all.txtSearch1.focus();
        }
        else
        {
            if(document.all.reSearchCheck != null && document.all.reSearchCheck.checked)
            {
                location.href = "search.aspx?word=" + document.all.word.value.trim() + "&detailword=" + document.all.txtSearch1.value.trim();
            }
            else
            {
                location.href = "search.aspx?word=" + document.all.txtSearch1.value.trim();
            }
        }
    }
}

function playListVOD()
{
    var cnt = GetCheck();
    if(cnt == 0)
    {
        alert("게시물을 선택하세요.");
        return;
    }
    
    if(cnt == 1)
    {
        alert("게시물은 2개 이상 선택하세요.");
        return;
    }
    
    parent.process.location.href='/playasxfile.aspx?flag=VOD&cnumlist=' + document.all.cnumlist.value;
}

function playListAOD()
{
    var cnt = GetCheck();
    if(cnt == 0)
    {
        alert("게시물을 선택하세요.");
        return;
    }
    
    if(cnt == 1)
    {
        alert("게시물은 2개 이상 선택하세요.");
        return;
    }
    
    parent.process.location.href='/playasxfile.aspx?flag=AOD&cnumlist=' + document.all.cnumlist.value;
}

// 양쪽 공백 없애기
function wrestTrim(fld)
{
    var pattern = /(^\s*)|(\s*$)/g; // \s 공백 문자
    fld.value = fld.value.replace(pattern, "");
    return fld.value;
}


// 네이버에서 가져온 스크립트입니당..
// o File    : nvscroll.js
// o Author  : Kukjin Kang
// o Date    : 2004. 7. 6
// o Cont.   : scroll object
//
function NvScroll() {

this.version = "0.2";
this.name = "NvScroll";
this.item = new Array();
this.itemcount = 0;
this.currentspeed = 0;
this.scrollspeed = 50;
this.pausedelay = 1000;
this.pausemouseover = false;
this.stop = false;
this.type = 1;
this.height = 100;
this.width = 100;
this.stopHeight=0;
this.i=0;

this.add = function () {
	var text = arguments[0];

	this.item[this.itemcount] = text;
//	alert(this.item[this.itemcount]);
	this.itemcount ++;
};

this.add2 = function () {
	var url = arguments[0];
	var title = arguments[1];
	this.item[this.itemcount] = "<a href=" + url + ">" + title + "</a>";
	this.itemcount = this.itemcount + 1;
};

this.reset_item = function () {
	this.item = new Array();
	this.itemcount = 0;
};

this.start = function (layer_name) {
	if ( this.itemcount == 1 ) {
		this.add(this.item[0]);
	}
	if (layer_name != null)
	{
		document.getElementById(layer_name).innerHTML = this.str_ret();
	}
	else 
	{
		this.display();
	}
	this.currentspeed = this.scrollspeed;
	if ( this.type == 1 || this.type == 2 ) {
		this.stop = true;
		setTimeout(this.name+'.scroll()',this.currentspeed);
		window.setTimeout(this.name+".stop = false", this.pausedelay);
	} else if ( this.type == 3 ) {
		this.stop = true;
		setTimeout(this.name+'.rolling()',this.currentspeed);
		window.setTimeout(this.name+".stop = false", this.pausedelay);
	}
};

this.display = function () {
	document.write('<div id="'+this.name+'" style="height:'+this.height+'; width:'+this.width+'; position:relative; overflow:hidden; " OnMouseOver="'+this.name+'.onmouseover(); " OnMouseOut="'+this.name+'.onmouseout(); ">');
	for(var i = 0; i < this.itemcount; i++) {
		if ( this.type == 1 ) {
			document.write('<div id="'+this.name+'item'+i+'"style="left:0px; width:'+this.width+'; position:absolute; top:'+(this.height*i)+'px; ">');
			document.write(this.item[i]);
			document.write('</div>');
		} else if ( this.type == 2 || this.type == 3 ) {
			document.write('<div id="'+this.name+'item'+i+'"style="left:'+(this.width*i)+'px; width:'+this.width+'; position:absolute; top:0px; ">');
			document.write(this.item[i]);
			document.write('</div>');
		}
	}
	document.write('</div>');
};
// 바로 디스플레이 않고 스트링 리턴하도록 추가 2006-03-30
this.str_ret = function () {
	var str = '<div id="'+this.name+'" style="height:'+this.height+'; width:'+this.width+'; position:relative; overflow:hidden; " OnMouseOver="'+this.name+'.onmouseover(); " OnMouseOut="'+this.name+'.onmouseout(); ">';
	for(var i = 0; i < this.itemcount; i++) {
		if ( this.type == 1 ) {
			str += '<div id="'+this.name+'item'+i+'"style="left:0px; width:'+this.width+'; position:absolute; top:'+(this.height*i)+'px; ">';
			str += this.item[i];
			str += '</div>';
		} else if ( this.type == 2 || this.type == 3 ) {
			str += '<div id="'+this.name+'item'+i+'"style="left:'+(this.width*i)+'px; width:'+this.width+'; position:absolute; top:0px; ">';
			str += this.item[i];
			str += '</div>';
		}
	}
			str += '</div>';
			return str;
};

this.scroll = function () {

	if ( this.pause == true ) {

		window.setTimeout(this.name+".scroll()",this.pausedelay);
		this.pause = false;

	} else {

		this.currentspeed = this.scrollspeed;
		if ( !this.stop ) {
			for (i = 0; i < this.itemcount; i++) {
				obj = document.getElementById(this.name+'item'+i).style;
				if ( this.type == 1 ) {
					obj.top = parseInt(obj.top) - 1;
					if ( parseInt(obj.top) <= this.height * (-1) ) obj.top = this.height * (this.itemcount-1);
					if ( parseInt(obj.top) == 0 ) this.currentspeed = this.pausedelay;
				} else if ( this.type == 2 ) {
					obj.left = parseInt(obj.left) - 1;
					if ( parseInt(obj.left) <= this.width * (-1) ) obj.left = this.width * (this.itemcount-1);
					if ( parseInt(obj.left) == 0 ) this.currentspeed = this.pausedelay;
				}
			}
		}
		window.setTimeout(this.name+".scroll()",this.currentspeed);
	}
};

this.rolling = function () {
	if ( this.stop == false  ) {
		this.next();
	}
	window.setTimeout(this.name+".rolling()",this.scrollspeed);
}

this.onmouseover = function () {
	if ( this.pausemouseover ) {
		this.stop = true;
	}
};

this.onmouseout = function () {
	if ( this.pausemouseover ) {
		this.stop = false;
	}
};

this.next = function() {

	for (i = 0; i < this.itemcount; i++) {
		obj = document.getElementById(this.name+'item'+i).style;
		if ( parseInt(obj.left) < 1 ) { 
			width = this.width + parseInt(obj.left);
			break;
		}
	}
	for (i = 0; i < this.itemcount; i++) {
		obj = document.getElementById(this.name+'item'+i).style;
		if ( parseInt(obj.left) < 1 ) { 
			obj.left = this.width * (this.itemcount-1);
		} else {
			obj.left = parseInt(obj.left) - width;
		}
	}

}

this.prev = function() {

	for (i = 0; i < this.itemcount; i++) {
		obj = document.getElementById(this.name+'item'+i).style;
		if ( parseInt(obj.left) < 1 ) { 
			width = parseInt(obj.left) * (-1);
			break;
		}
	}
	if ( width == 0 ) {
		total_width = this.width * (this.itemcount-1);
		for (i = 0; i < this.itemcount; i++) {
			obj = document.getElementById(this.name+'item'+i).style;
			if ( parseInt(obj.left) + 1 > total_width ) { 
				obj.left = 0;
			} else {
				obj.left = parseInt(obj.left) + this.width;
			}
		}
	} else {
		for (i = 0; i < this.itemcount; i++) {
			obj = document.getElementById(this.name+'item'+i).style;
			if ( parseInt(obj.left) < 1 ) { 
				obj.left = 0;
			} else {
				obj.left = parseInt(obj.left) + width;
			}
		}
	}
}

this.unext = function () {
	this.onmouseover();
	this.next();
	window.setTimeout(this.name+".onmouseout()",this.pausedelay);
}

this.uprev = function () {
	this.onmouseover();
	this.prev();
	window.setTimeout(this.name+".onmouseout()",this.pausedelay);
}

}