 function getChildElement(et, tagName) {
	for (var i=0; i<et.childNodes.length; i++) {
		if (et.childNodes[i]) {
			if ((et.childNodes[i].nodeType==1)&&(et.childNodes[i].nodeName==tagName)) {
				return et.childNodes[i];
			}
		}
	}
	return null;
}

function getChildElementById(elementId, tagName) {
	var et = document.getElementById(elementId);
	if (et) et = getChildElement(et, tagName);
	return et;
}

function getStyleValue(sid, sstyle) {
	var e = document.getElementById(sid);
	if (e.currentStyle) {
		return e.currentStyle[sstyle];
	} else if (window.getComputedStyle) {
		return document.defaultView.getComputedStyle(e, null).getPropertyValue(sstyle);
	} else {
	    return null;
	}
}

function getEStyleValue(e, sstyle) {
	if (e.currentStyle) {
		return e.currentStyle[sstyle];
	} else if (window.getComputedStyle) {
		return document.defaultView.getComputedStyle(e, null).getPropertyValue(sstyle);
	} else {
	    return null;
	}
}

function programMenu(eid) {
	var et = document.getElementById(eid);
	if (et) {
		if (getEStyleValue(et, "display")=="none") {
			et.style.display = "block";
		} else {
			et.style.display = "none";
		}
	}
}

function programMenu2(eid, el) {
	var et = document.getElementById(eid);
	if (et) {
		if (getEStyleValue(et, "display")=="none") {
			et.style.display = "block";
		} else {
			et.style.display = "none";
		}
	}
	el = getChildElement(el, "IMG");
	el.src = (el.src.indexOf("off")!=-1) ? el.src.replace("off", "on") : el.src.replace("on", "off");; 
}

function overMainMenu(menuId) {
	var et = getChildElementById(menuId, "IMG");
	if (et==null) {
		et = getChildElementById(menuId, "A");
		if (et==null) return; 
		et = getChildElement(et, "IMG");
		if (et==null) return; 
	}
	et.src = et.src.replace("off", "on");
}
function outMainMenu(menuId) {
	var et = getChildElementById(menuId, "IMG");
	if (et==null) {
		et = getChildElementById(menuId, "A");
		if (et==null) return; 
		et = getChildElement(et, "IMG");
		if (et==null) return; 
	}
	et.src = et.src.replace("on", "off");
}

function showSubMenu(subId) {
    hideSubMenus();
	var et = document.getElementById(subId);
	if (et) et.style.display = "block";
}

function showSubMenu2(subId) {
	var et = document.getElementById(subId);
	if (et) et.style.display = "block";
}

function hideSubMenus() {
                document.getElementById('top_sub_new').style.display = "none";
	document.getElementById('top_sub_cul').style.display = "none";
	document.getElementById('top_sub_spt').style.display = "none";
	document.getElementById('top_sub_spo').style.display = "none";
	document.getElementById('top_sub_com').style.display = "none";
	document.getElementById('top_sub_sch').style.display = "none";
}

function hideSubMenu(subId) {
	var ets = document.getElementById(subId).childNodes;
	for (var i=0; i<ets.length; i++) {
		if (ets[i].className=="top_sub_class") {
			var et = getChildElement(ets[i], "UL");
			if (et) et.style.display = "none";
		}
	}
}

function hideSubMenu(subId, fixId) {
	var ets = document.getElementById(subId).childNodes;
	for (var i=0; i<ets.length; i++) {
		if (ets[i].className=="top_sub_class") {
			var et = getChildElement(ets[i], "UL");
			if (et) et.style.display = "none";
		}
	}
	showSubMenu(fixId);
}

function hideSubMenu2(subId, fixId) {
	var ets = document.getElementById(subId).childNodes;
	for (var i=0; i<ets.length; i++) {
		if (ets[i].className=="top_sub_class") {
			var et = getChildElement(ets[i], "UL");
			if (et) et.style.display = "none";
		}
	}
}

function overLeftSubMenu(currentid, selectid, state) {
	var e = getChildElementById(currentid, "A");
	if (e) {
		var selectColor = getEStyleValue(e, "color"); 
		if (state) {
			e.style.fontWeight = "bold";
			if ((selectColor=="#ffffff")||(selectColor=="rgb(255, 255, 255)")) return;
			e.style.color = "#0c69c6";
		} else {
			e.style.fontWeight = "normal";
			if ((selectColor=="#ffffff")||(selectColor=="rgb(255, 255, 255)")) return;
			e.style.color = "#666666";
		}
	}
}

function showLeftMenu(menuId, imgId) {
	var et = getChildElementById("left_menu_"+menuId, "IMG");
	if (et==null) {
		et = getChildElementById("left_menu_"+menuId, "A");
		if (et==null) return; 
		et = getChildElement(et, "IMG");
		if (et==null) return; 
	}
	et.src = "http://www.qbsi.co.kr/images/leftmenu/"+menuId+"_"+imgId+".gif";
}

function toggleLeftMenu(menuId) {
	var ets = document.getElementById("left_menu").childNodes;
	for (var i=0; i<ets.length; i++) {
		if (ets[i].className=="left_menu_class") {
			var et = getChildElement(ets[i], "A");
			if (et) { 
				et = getChildElement(et, "IMG");
			} else {
				et = getChildElement(ets[i], "IMG");
			}
			if (et) et.src = et.src.replace("on", "off");
		}
		if (ets[i].className=="left_sub_class") {
			if (ets[i].id != ("left_sub_"+menuId)) ets[i].style.display = "none";
		}
	}

	var et1 = document.getElementById("left_sub_"+menuId);
	if (et1) {
		if (getEStyleValue(et1, "display")=="none") {
			et1.style.display = "block";
			showLeftMenu(menuId, "on");
		} else {
			et1.style.display = "none";
			showLeftMenu(menuId, "off");
		}
	} else {
		showLeftMenu(menuId, "on");
	}
}

function checkSelfMenu(sid) {
	var et = document.getElementById(sid);
	if (et) {
		var et1 = getChildElement(et, "A");
		var et2 = getChildElement(et, "IMG");
		if (et2) {
			et = et2;
		} else {
			et = getChildElement(et1, "IMG");
		}
		if (et) et.src = et.src.replace("off", "on");
	}
}

function checkLeftMenu(sid) {
	var et = document.getElementById(sid);
	if(et) {
		et.src = et.src.replace("off", "on");
	}
}

function showDisplay(showId, hideClass, pId) {
	var ets = document.getElementById(pId).childNodes;
	for (var i=0; i<ets.length; i++) {
		if (ets[i].className==hideClass) ets[i].style.display ="none";
	}
	var et = document.getElementById(showId);
	if (et) et.style.display = "block";
}

function openflash(width,height,src,wmode,sendVars){ 
 return "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width="+width+" height="+height+"><param name=movie value="+src+"><param name=quality value=high ><param name=wmode value="+wmode+"><param name=FlashVars VALUE='sendVars="+sendVars+"'><embed src="+src+" quality=high  pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width="+width+" height="+height+"></embed></object>"; 
}

function open_nv_flash(width,height,src,wmode,sendVars){ 
 return "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" onmouseout=\"this.SetVariable('is_autodrop','1');\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width="+width+" height="+height+"><param name=movie value="+src+"><param name=quality value=high ><param name=wmode value="+wmode+"><param name=FlashVars VALUE='sendVars="+sendVars+"'><embed src="+src+" quality=high  pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width="+width+" height="+height+"></embed></object>"; 
}

function lala_sub_menuflash(width,height,src,sendVars){ 
 return "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\""+width+"\" height=\""+height+"\" id=\"lalakids_container\" align=\"middle\"><param name=\"allowScriptAccess\" value=\"sameDomain\" /><param name=\"movie\" value=\""+src+"\" /><param name=\"quality\" value=\"middle\" /><param name=\"bgcolor\" value=\"#ffffff\" /><param name=\"FlashVars\" value=\""+sendVars+"\" /><embed src=\"lalakids_container.swf\" quality=\"middle\" bgcolor=\"#ffffff\" width=\""+width+"\" height=\""+height+"\" name=\"lalakids_container\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object>"; 
}


function writeflash(src){ 
 document.write(src); 
} 

function open_m_layer(){
	document.all.banner_div.style.display = "none";
	document.all.movie_div.style.display = "block";
}

function close_m_layer(){
	document.all.banner_div.style.display = "block";
	document.all.movie_div.style.display = "none";
}

//	offsetHeight : padding, border를 포함하고 margin은 포함하지 않는 높이와 폭, scrollHeight : 전체 높이와 폭, iframe.height
/*
function resizeLeftMenu() {
	//return;
	var container_et = document.getElementById("container");
	var left_et = document.getElementById("content_left");
	var right_et = document.getElementById("content_right");
	if ((container_et)&&(left_et)&&(right_et)) {
		//alert(left_et.scrollHeight+" resize "+right_et.scrollHeight);
		if (right_et.scrollHeight > left_et.scrollHeight) {
			container_et.style.height = right_et.scrollHeight + "px";
		} else if (right_et.scrollHeight < left_et.scrollHeight) {
			container_et.style.height = left_et.scrollHeight + "px";
		}
	}
}
*/
function resizeLeftMenu() {
	return;
	var left_et = document.getElementById("content_left");
	var right_et = document.getElementById("content_right");
	if ((left_et)&&(right_et)) {
		//alert(left_et.scrollHeight+" resize "+right_et.scrollHeight);
		if (right_et.scrollHeight < 640) {
			left_et.style.height = 640 + "px";
		} else {
			if (right_et.scrollHeight > left_et.scrollHeight) {
				left_et.style.height = right_et.scrollHeight + "px";
			}
		}
	}
	//alert(left_et.scrollHeight+" resize "+right_et.scrollHeight);
}

function resizeFrame(ifr_id,re) {
    //가로길이는 유동적인 경우가 드물기 때문에 주석처리!
    var ifr = document.getElementById(ifr_id);
    var innerBody = ifr.contentWindow.document.body;

    if (innerBody.scrollHeight!=innerBody.offsetHeight) {
	    var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight);
	    //var innerWidth = document.body.scrollWidth + (document.body.offsetWidth - document.body.clientWidth);
    } else {
    	var innerHeight = innerBody.scrollHeight;
    }
	
    if (ifr.style.height != innerHeight) {//주석제거시 다음 구문으로 교체 -> if (ifr.style.height != innerHeight || ifr.style.width != innerWidth)
        ifr.style.height = innerHeight + "px";
        //ifr.style.width = innerWidth;
    }

    if(!re) {
        try {
            innerBody.attachEvent('onclick', parent.do_resize);
            innerBody.attachEvent('onkeyup', parent.do_resize);
            //글작성 상황에서 클릭없이 타이핑하면서 창이 늘어나는 상황이면 윗줄 주석제거
        } catch(e) {
            innerBody.addEventListener("click", parent.do_resize, false);
            innerBody.addEventListener("keyup", parent.do_resize, false);
            //글작성 상황에서 클릭없이 타이핑하면서 창이 늘어나는 상황이면 윗줄 주석제거
        }
    }
}

function getDocHeight(doc)
{
  var docHt = 0, sh, oh;
  if (doc.height)
  {
    docHt = doc.height;
  }
  else if (doc.body)
  {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}

function getReSize(id)
{
  var iframeWin = window.frames[id];

  var iframeEl = window.document.getElementById? window.document.getElementById(id): document.all? document.all[id]: null;

  if ( iframeEl && iframeWin )
  {
    var docHt = getDocHeight(iframeWin.document);

    if (docHt != iframeEl.style.height) iframeEl.style.height = docHt + 'px';
  }
  else
  { // firefox
    var docHt = window.document.getElementById(id).contentDocument.height;
    window.document.getElementById(id).style.height = docHt + 'px';
  }
}

function getRetry(id)
{
    getReSize(id);
    setTimeout('getRetry('+id+')',500);
}

function openPopup(){
window.open('http://www.qbsi.co.kr/app2/event/2009/11/apply.php', 'qbs_pop', 'scrollbars=no,toolbar=no,resizable=no,width=500,height=651,left=0,top=0');
}

function OpenNewsWindow(url) {
    var winObj;
    winObj = window.open(url, "NewsWindow", "width=1024, height=800, scrollbars=yes");
}

function SendNews(media) {
    var url;
    var title = utf8Title;
    var shortUrl = location.href;

    switch (media) {
        case "twitter":
            url = "http://twitter.com/intent/tweet?text=" + title + "&url=" + shortUrl;
            break;
        case "facebook":
            url = "http://www.facebook.com/sharer.php?u=" + shortUrl + "&t=" + title + "&src=sp";
            break;
        case "metoday":
            url = "http://me2day.net/posts/new?new_post[body]=\"" + title + "\":" + shortUrl + "&new_post[tags]=QBS+%ED%95%9C%EA%B5%ADDMB";
            break;
        case "yozm":
            url="http://yozm.daum.net/api/popup/prePost?prefix="+title+"&link="+shortUrl;
            break;  
        case "clog":
            url="http://csp.cyworld.com/bi/bi_recommend_pop.php?url="+shortUrl+"&title_nobase64="+title+"&writer=hankyung.com";
            break;
    }
    OpenNewsWindow(url);
}
