function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

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_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_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 goMenu(Val,Sel)
{
	Sel.value = '';
	if (Val) location=Val;

}

function fnResizePopup(nWidth, nHeight)
{
	var strAgent = navigator.userAgent.toLowerCase();
	var bIE = (strAgent.indexOf("msie") != -1);
	var bXP = (strAgent.indexOf("nt 5.1") != -1);
	var bIE7 = (strAgent.indexOf("msie 7.0") != -1);
	var bSafari = (strAgent.indexOf("konqueror") != -1 || strAgent.indexOf("safari") != -1);
	var bFirefox = (strAgent.indexOf("firefox")!= -1);
	window.resizeTo(nWidth, nHeight + (bXP ? (bIE7 ? 40: 20) : 0));
}
//ÆË¾÷ - Áß¾ÓÀ§Ä¡
function PopWindow(url,target,intWidth,intHeight) {
	var posX = (screen.availWidth/2)-(intWidth/2);
	var posY = (screen.availHeight/2)-(intHeight/2);

	var winoption = "width="+intWidth+",height="+intHeight+",left="+posX+",top="+posY +",scrollbars=no,status=no,resizable=0";
	window.open(url, target, winoption);
	return;
}
// ÆäÀÌÁö focus blur
function bluring(){
	if (event.srcElement!=null) {
		if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
	}
}
document.onfocusin=bluring;

/* ÇÃ·¡½Ã */
function ObjFlash(src, width, height, param, addParam) {
	param = param || "";
	addParam = addParam || "";
	document.writeln("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"" + width + "\" height=\"" + height + "\">");
	document.writeln("	<param name=\"movie\" value=\"" + src + "\">");
	document.writeln("	<param name=\"flashVars\" value=\"" + param + "\">");
	document.writeln("  <param name='allowScriptAccess' value='always' />");
	document.writeln("	<param name='quality' value='high' />");
	document.writeln("	<param name='salign' value='lt' />");
	document.writeln("	<param name='bgcolor' value='#000000' />");
	document.writeln("	<param name='menu' value='false' />");
	document.writeln("	<param name='wmode' value='opaque' />");
	document.writeln("	<embed  bgcolor='#000000' wmode='opaque' src=\"" + src + "?" + param + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + width + "\" height=\"" + height + "\"></embed>");
	document.writeln("</object>");
}

function ObjFlash_Tr(src, width, height, param, addParam) {//ÇÃ·¡½Ã Åõ¸í Ã³¸®
	param = param || "";
	addParam = addParam || "";
	document.writeln("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"" + width + "\" height=\"" + height + "\">");
	document.writeln("	<param name=\"movie\" value=\"" + src + "\">");
	document.writeln("	<param name=\"flashVars\" value=\"" + param + "\">");
	document.writeln("  <param name='allowScriptAccess' value='always' />");
	document.writeln("	<param name='quality' value='high' />");
	document.writeln("	<param name='scale' value='noscale' />");
	document.writeln("	<param name='salign' value='lt' />");
	document.writeln("	<param name='bgcolor' value='#000000' />");
	document.writeln("	<param name='menu' value='true' />");
	document.writeln("	<param name='wmode' value='transparent' />");
	document.writeln("	<embed  bgcolor='#000000' wmode='transparent' src=\"" + src + "?" + param + "\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + width + "\" height=\"" + height + "\"></embed>");
	document.writeln("</object>");
}

function ShowhidenLayer(LayName) {
	obj = document.getElementById(LayName);
  obj.style.display = (obj.style.display == 'none') ? 'block':'none';
}

function ShowLayer(LayName) {
	obj = document.getElementById(LayName);
	obj.style.display = "block";
}

function HideLayer(LayName) {
	obj = document.getElementById(LayName);
  // ¼û±â±â
  obj.style.display = "none";
}

//°Ë»ö°ü·Ã scriptµé
var SearchPage = new Array();

SearchPage["total"] = "/search_total.asp";
SearchPage["iq"] = "/Ss_iq/Total_iq.asp";
SearchPage["xbbs"] = "/Ss_Xbbs/Total_Xbbs.asp";
SearchPage["news"] = "/Ss_News/Total_News.asp";
SearchPage["board"] = "/Ss_Board/Total_Board.asp";
SearchPage["image"] = "/Ss_Image/Total_Image.asp";
SearchPage["commty"] = "/Ss_Comty/Total_Comty.asp";
SearchPage["web"] = "/Ss_Web/Total_Web.asp";
SearchPage["envideo"] = "/Ss_EnVideo/Total_EnVideo.asp";


function press_event()
{
	var code = event.keyCode;
	if (code == 13) {
		Tail_Search();
	}
}

function tpress_event()
{
	var code = event.keyCode;
	if (code == 13) {
		Head_Search();
	}
}

function View_Search(collname)
{
	if(collname == 'xbbs')
		document.HSearchForm.xview.value = (xobj.view == 'I')?'L':'I';
	else if(collname == 'news')
		document.HSearchForm.nview.value = (nobj.view == 'I')?'L':'I';
	Tab_Search(collname);
	document.HSearchForm.pg.value = '';
	document.HSearchForm.pc.value = '';

	
}
function View_EnSearch(collname,enscope)
{
	document.HSearchForm.pg.value = '1';
	document.HSearchForm.pc.value = '10';
	document.HSearchForm.srchtype.value = collname;
	document.HSearchForm.enscope.value = enscope;
	document.HSearchForm.cname.value = '';
	document.HSearchForm.orderfield.value = '';
	Go_Search();
	document.HSearchForm.pg.value = '';
	document.HSearchForm.pc.value = '';
	
}

//»ó´ÜÀÇ ÅÇ¿¡ ÀÇÇØ¼­ °Ë»ö ÅÇ°Ë»öÀÇ ÇÏºÎ ÄÃ·¢¼Ç¸íÀº Áö¿ì°í °Ë»ö
function Tab_Search(srchtype)
{
	document.HSearchForm.pg.value = '1';
	document.HSearchForm.pc.value = '10';
	document.HSearchForm.srchtype.value = srchtype;
	document.HSearchForm.enscope.value = '';
	document.HSearchForm.cname.value = '';
	document.HSearchForm.orderfield.value = '';
	Go_Search();
}
//Á¤·ÄÁ¤º¸¸¦ º¯°æÇÑÈÄ °Ë»ö
function Sort_Search(ofld)
{
	document.HSearchForm.orderfield.value = ofld;
	Go_Search();
}
//º¸ÀÌ±â ¹æ½ÄÀ» º¯°æÇÏ¿© °Ë»ö
function Swap_Search(obj, curr_view)
{
	obj.value = (curr_view == 'I')?'L':'I';
	if (obj.value == 'I')
	{
		document.HSearchForm.pc.value = '20';
	}
	else {
		document.HSearchForm.pc.value = '10';	
	}
	document.HSearchForm.pg.value = '1';
	Go_Search();
}

//»ó´ÜÀÇ °Ë»öÃ¢¿¡¼­ °Ë»ö ½ÇÇà
function Head_Search()
{
	document.HSearchForm.pg.value = '';
	document.HSearchForm.pc.value = '';	
	document.HSearchForm.orderfield.value = '';
	document.HSearchForm.overprv.value = '';
	document.HSearchForm.overnext.value = '';
	Go_Search();
}

//°¢ ÅÇÀÇ ÀÌµ¿ÇÏ±â ¹öÆ°Å¬¸¯½Ã ÄÃ·¢¼Ç¿¡ ´ëÇÑ °Ë»ö
function Sub_Search(collname)
{
	document.HSearchForm.cname.value = collname;
	Head_Search();
}

//ÇÏ´ÜÀÇ °Ë»öÃ¢¿¡¼­ °Ë»ö »ó´ÜÀÇ °Ë»öÆû¿¡ °ªÀ» ¼³Á¤ ÈÄ °Ë»ö
function Tail_Search()
{
	document.HSearchForm.keyword.value = document.TSearchForm.Foot_keyword.value;
	document.HSearchForm.srchtype.value = document.TSearchForm.Foot_srchtype.value;
	document.HSearchForm.research.checked = document.TSearchForm.Foot_research.checked;
	//Go_Search();
	Head_Search();
}
//ÇÏ´ÜÀÇ ÆäÀÌÁö ³×ºñ°ÔÀÌ¼Ç¿¡¼­ °Ë»ö½ÇÇà
function Page_Search(page, pagepercnt)
{
	document.HSearchForm.pg.value = page;
	document.HSearchForm.pc.value = pagepercnt;
	Go_Search();
}
function make_querydata(obj)
{
	obj = obj.replace(/\\/gi, "");
	obj = obj.replace(/\'/gi, "");
	obj = obj.replace(/\"/gi, "");
	return obj;
}

//½ÇÁ¦ °Ë»öÀ» ½ÇÇà
function Go_Search()
{
	document.HSearchForm.keyword.value = make_querydata(document.HSearchForm.keyword.value);
	
//	if(document.HSearchForm.keyword.value == '') {
//		alert('°Ë»ö¾î¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.');
//		document.HSearchForm.keyword.focus();
//		return false;
//	}
	
	if(!document.HSearchForm.research.checked) document.HSearchForm.oldKeyWord.value = '';
	document.HSearchForm.action = SearchPage[document.HSearchForm.srchtype.value];
	
	log_write('0', document.HSearchForm.keyword.value, 'cleanlog_srch_action');
	
	document.HSearchForm.submit();
	
}
function Same_Search(same_id)
{
	document.HSearchForm.sameid.value = same_id;
	Go_Search();
}
function Key_Search(keyword)
{
	document.HSearchForm.keyword.value = keyword;
	Go_Search();
}
//ÀÌ¹ÌÁöÀÇ Å©±â¸¦ ¸Â°Ô ¹Ù²Û´Ù.
function resizeimage(obj, maxWidth, maxHeight)
{
 var w, h, nw, nh, maxWidth, maxHeight;
	w = obj.width;
	h = obj.height;

	if(w > maxWidth || h > maxHeight){
		if(w > h){
			nw = maxWidth;
			nh = Math.round((h*nw)/w);
		}
		else{
			nh = maxHeight;
			nw = Math.round((nh*w)/h);
		}
	}
	else {
		nw = w;
		nh = h;
	}

	obj.width = nw;
	obj.height = nh;
}

//³»°¡ °Ë»öÇÑ ´Ü¾î ÀÇ ÄíÅ° °ªÀ» ¾ò¾î¿À´Â ÇÔ¼ö
//ÄíÅ°ÀÇ DATA=¿¡ |·Î ¿¬°áµÇ¾î ÀúÀåµÇ¾îÀÖ´Ù.
function get_sl_cookie(cName)
{
 var tmp_str = document.cookie.split("; ");
	for(var i = 0 ; i < tmp_str.length ; i++) {
		split_str = tmp_str[i].split("=");
		if(split_str[0] == cName) {
			return split_str[1];
		}
	}
	return "";
}
//³»°¡ °Ë»öÇÑ ´Ü¾îÀÇ ÄíÅ°¸¦ ÀúÀåÇÏ´Â ÇÔ¼ö
function gs_sl_Cookie(str, cName, NoResultFlag, mx)
{
 var nextyear = new Date();
 var cookie_path = '/';
 var start_i;
 var find_flag = 0;
 var new_cookie_str = '';

 nextyear.setFullYear(nextyear.getFullYear()+1);
 var cookie_expire = nextyear.toGMTString();
	var prv_cookie_str = get_sl_cookie(cName);

	if(NoResultFlag == 0 && str != '') {
		split_str = prv_cookie_str.split("|");
		if(split_str.length > mx) start_i = 1;
		else start_i = 0;
		for(var i = start_i ; i < split_str.length -1 ; i++) {
			if(split_str[i] != '') {
				if(split_str[i] == str) find_flag = 1;
				else new_cookie_str += split_str[i] + '|';
			}
		}
		new_cookie_str += str + '|';
		if(find_flag == 1)  new_cookie_str = split_str[0] + '|' + new_cookie_str;

		var tmp_str = '';
		tmp_str += cName + '=' + new_cookie_str;
		tmp_str += '; path=' + cookie_path;
		tmp_str += '; expires=' + cookie_expire;
		document.cookie = tmp_str;
		return new_cookie_str;
	}
	else {
		return prv_cookie_str;
	}
	
}
function Make_MyList(istr)
{
 var ostr = '';
 var split_str = istr.split("|");
	for(var i = 0 ; i < split_str.length - 1 ;i++) {
		ostr += '<a href="javascript:Key_Search(\''+split_str[i]+'\');" class="txt">\n' + split_str[i] + '</a>';
	}
	return ostr;
}
