/* initMoving */

function initMoving(target, position, topLimit, btmLimit) {

	if (!target)

		return false;

	var obj = target;

	obj.initTop = position;

	obj.topLimit = topLimit;

	obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;

	obj.style.position = "absolute";

	obj.top = obj.initTop;

	obj.left = obj.initLeft;

	if (typeof (window.pageYOffset) == "number") {

		obj.getTop = function() {

			return window.pageYOffset;

		}

	} else if (typeof (document.documentElement.scrollTop) == "number") {

		obj.getTop = function() {

			return document.documentElement.scrollTop;

		}

	} else {

		obj.getTop = function() {

			return 0;

		}

	}

	if (self.innerHeight) {

		obj.getHeight = function() {

			return self.innerHeight;

		}

	} else if (document.documentElement.clientHeight) {

		obj.getHeight = function() {

			return document.documentElement.clientHeight;

		}

	} else {

		obj.getHeight = function() {

			return 300;

		}

	}

	obj.move = setInterval( function() {

		if (obj.initTop > 0) {

			pos = obj.getTop() + obj.initTop;

		} else {

			pos = obj.getTop() + obj.getHeight() + obj.initTop;

			// pos = obj.getTop() + obj.getHeight() / 2 - 15;

		}

		if (pos > obj.bottomLimit)

			pos = obj.bottomLimit;

		if (pos < obj.topLimit)

			pos = obj.topLimit;

		interval = obj.top - pos;

		obj.top = obj.top - interval / 3;

		obj.style.top = obj.top + "px";

	}, 30)

}

// Embeded function image Over

function imageOver(imgEl) {

	imgEl.src = imgEl.src.replace("_off.gif", "_on.gif");

}

function imageOut(imgEl) {

	imgEl.src = imgEl.src.replace("_on.gif", "_off.gif");

}

function menuOver() {
	this.src = this.src.replace("off.gif", "on.gif");
}

function menuOut() {
	this.src = this.src.replace("on.gif", "off.gif");
}

// Tabbed menu

function initTabMenu(menuElId) {

	var tabMenu = document.getElementById(menuElId).getElementsByTagName("a");

	if (tabMenu.length > 0) {

		for (i = 0; i < tabMenu.length; i++) {

			thismenu = tabMenu.item(i);

			thismenu.menuContainer = document.getElementById(menuElId);

			thismenu.targetEl = document.getElementById(tabMenu.item(i).href
					.split("#")[1]);

			thismenu.targetEl.style.display = "none";

			if (thismenu.getElementsByTagName("img").length > 0) {

				thismenu.getElementsByTagName("img").item(0).onmouseover = menuOver;

				thismenu.getElementsByTagName("img").item(0).onmouseout = menuOut;

			}

			thismenu.onclick = tabMenuClick;

		}

		initmenu = tabMenu.item(0);

		initmenu.menuContainer = document.getElementById(menuElId);

		initmenu.targetEl = document
				.getElementById(initmenu.href.split("#")[1]);

		initmenu.targetEl.style.display = "block";

		initmenu.className = "activate";

		if (initmenu.getElementsByTagName("img").length > 0) {

			initmenu.getElementsByTagName("img").item(0).onmouseover();

			initmenu.getElementsByTagName("img").item(0).onmouseover = null;

			initmenu.getElementsByTagName("img").item(0).onmouseout = null;

		}

		initmenu.menuContainer.current = initmenu;

	}

}

function tabMenuClick() {

	currentmenu = this.menuContainer.current;

	if (currentmenu != this) {

		currentmenu.targetEl.style.display = "none";

		currentmenu.className = null;

		if (currentmenu.getElementsByTagName("img").length > 0) {

			currentmenu.getElementsByTagName("img").item(0).onmouseover = menuOver;

			currentmenu.getElementsByTagName("img").item(0).onmouseout = menuOut;

			currentmenu.getElementsByTagName("img").item(0).onmouseout();

		}

		this.targetEl.style.display = "block";

		this.className = "activate";

		if (this.getElementsByTagName("img").length > 0) {

			this.getElementsByTagName("img").item(0).onmouseover = null;

			this.getElementsByTagName("img").item(0).onmouseout = null;

		}

		this.menuContainer.current = this;

	}

	return false;

}

function viewDisplay(obj) {

	Obj = document.getElementById(obj);

	if (Obj.className == '' || Obj.className == 'visible') {

		Obj.className = 'hidden';

	} else {

		Obj.className = 'visible';

	}

}

/* top show/hide */

function ReverseDisplay(obj) {

	if (document.getElementById(obj).style.display == "block") {

		document.getElementById(obj).style.display = "none";

	}

	else {
		document.getElementById(obj).style.display = "block";
	}

}

var old_index = "0";

function ReverseDisplay2(index) {

	var obj = "question";

	document.getElementById(obj + index + "_1").style.visibility = "visible";

	document.getElementById(obj + index + "_2").style.visibility = "visible";

	document.getElementById(obj + index + "_1").style.display = "";

	document.getElementById(obj + index + "_2").style.display = "";

	if (old_index != "0")

	{

		document.getElementById(obj + old_index + "_1").style.display = "none";

		document.getElementById(obj + old_index + "_2").style.display = "none";

		document.getElementById(obj + old_index + "_2").style.visibility = "hidden";

		document.getElementById(obj + old_index + "_1").style.visibility = "hidden";

	}

	old_index = index;

}

function HideContent(obj) {
	document.getElementById(obj).style.display = "none";
	divOBJ = null;
}
function ShowContent(obj) {
	if (divOBJ != null) {
		HideContent(divOBJ);
	}
	document.getElementById(obj).style.display = "block";
	if (obj == "bgsearch" || obj == "reserwrap") {
		divOBJ = obj;
	}
}

// fmeduView

function fmeduView(obj) {

	var target = document.getElementById(obj);

	target.style.display = (target.style.display == 'none' ? 'block' : 'none');

}

/* png24 */

function setPNG24(obj) {

	obj.width = obj.height = 1;

	obj.className = obj.className.replace(/\bPNG24\b/i, '');

	obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
			+ obj.src + "',sizingMethod='image');"

	obj.src = '';

	return '';

}

/* font_zomm */

var arrTag = new Array('div', 'td', 'tr', 'a');

var arrSize = new Array('8', '9', '10', '11', '12', '13', '14', '15', '16',
		'17', '18');

var stSize = 4;

function AutoTextSize(tget, cnt) {

	var cText = null, sSize = stSize, cTag;

	sSize += cnt;

	if (sSize < 0)
		sSize = 0;

	if (sSize > 10)
		sSize = 10;

	stSize = sSize;

	if (!(cText = document.getElementById(tget)))

		cText = document.getElementsByTagName(tget)[0];

	cText.style.fontSize = arrSize[sSize] + 'px';

	for (i = 0; i < arrTag.length; i++) {

		cTag = cText.getElementsByTagName(arrTag[i]);

		for (j = 0; j < cTag.length; j++) {

			cTag[j].style.fontSize = arrSize[sSize] + 'px';

		}

	}

}

// flash

function swfprint(furl, fwidth, fheight, transoption, Id) {

	if (Id) {

		document
				.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'
						+ fwidth
						+ '" height="'
						+ fheight
						+ '" align="middle" id="' + Id + '">');

	} else {

		document
				.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="'
						+ fwidth + '" height="' + fheight + '" align="middle">');

	}

	document.write('<param name="movie" value="' + furl + '"/>');

	document.write('<param name="allowScriptAccess" value="always"/>');

	if (transoption == "t") {

		document.write('<param name="wmode" value="transparent"/>');

	} else if (transoption == "o") {

		document.write('<param name="wmode" value="opaque"/>');

	}

	document.write('<!-- Hixie method -->');

	document.write('<!--[if !IE]> <-->');

	document
			.write('<object type="application/x-shockwave-flash" allowScriptAccess="always" data="'
					+ furl
					+ '" width="'
					+ fwidth
					+ '" height="'
					+ fheight
					+ '"');

	if (transoption == "t") {

		document.write(' wmode="transparent"');

	} else if (transoption == "o") {

		document.write(' wmode="opaque"');

	}

	if (Id) {

		document.write(' id="' + Id + '"');

	}

	document.write('></object>');

	document.write('<!--> <![endif]-->');

	document.write('</object>');

}

// png

var clear = "/images/common/quick/clear.gif" // path to clear.gif

pngfix = function() {
	var els = document.getElementsByTagName('*');
	var ip = /\.png/i;
	var i = els.length;
	while (i-- > 0) {
		var el = els[i];
		var es = el.style;
		if (el.src && el.src.match(ip) && !es.filter) {
			es.height = el.height;
			es.width = el.width;
			es.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
					+ el.src + "',sizingMethod='crop')";
			el.src = clear;
		} else {
			var elb = el.currentStyle.backgroundImage;
			if (elb.match(ip)) {
				var path = elb.split('"');
				var rep = (el.currentStyle.backgroundRepeat == 'no-repeat') ? 'crop'
						: 'scale';
				es.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
						+ path[1] + "',sizingMethod='" + rep + "')";
				es.height = el.clientHeight + 'px';
				es.backgroundImage = 'none';
				var elkids = el.getElementsByTagName('*');
				if (elkids) {
					var j = elkids.length;
					if (el.currentStyle.position != "absolute")
						es.position = 'static';
					while (j-- > 0)
						if (!elkids[j].style.position)
							elkids[j].style.position = "relative";
				}
			}
		}
	}
}
if (window.addEventListener) {
	window.addEventListener('onload', pngfix, false);
} else {
	window.attachEvent('onload', pngfix);
}

function changeDivDisplay(contents) {
	var divObj = document.getElementById(contents);
	if (divObj.style.display == "block") {
		divObj.style.display = "none";
	} else {
		divObj.style.display = "block";
	}

}

 /* top show/hide */
 function ShowFamily(obj) {
	if(document.getElementById(obj).style.display == "" || document.getElementById(obj).style.display == "none")	{ 
		document.getElementById(obj).style.display = "block";
		document.getElementById("net").src="/cancer/images/common/layout/btn_cmcfm_close.gif";
	}
	else { 
			document.getElementById(obj).style.display = "none"; 
			document.getElementById("net").src="/cancer/images/common/layout/btn_cmcfm_open.gif";
		}
}





// rollingtext

/**************************************************************************
Function Name   : fn_divPrint
Description     : div내용 인쇄하기
parameters      : 컨텐츠 아이디
return          : 
**************************************************************************/
function fn_divPrint(objName){
	var obj = document.getElementById(objName).innerHTML;
	win = window.open();
	self.focus();
	win.document.open();
	win.document.write('<'+'html'+'><'+'head'+'><'+'style'+'>');
	win.document.write('body, td { font-family: Verdana; font-size: 10pt;}');
	win.document.write('<'+'/'+'style'+'><link rel=\"stylesheet\" type=\"text/css\" href=\"/cancer/css/global.css\" /><'+'/'+'head'+'><'+'body'+'>');
	win.document.write(obj);
	win.document.write('<'+'/'+'body'+'><'+'/'+'html'+'>');
	win.document.close();
	win.print();
	win.close();
}
/**************************************************************************
Function Name   : fn_copyRss
Description     : rss서비스
parameters      : 
return          : 
**************************************************************************/
function fn_copyRss(rssUrl,typeUrl){
	var IE=(document.all)?true:false;
	var rssURL = rssUrl+"?path="+typeUrl;
	if (IE) {
		if(confirm("RSS 주소를 클립보드에 복사하시겠습니까?")) {
			window.clipboardData.setData("Text", rssURL);
			alert("RSS 주소가 클립보드에 복사되었습니다.");
		}
	} else {
		var temp = window.prompt("아래의 RSS 주소를 Ctrl+C를 눌러 클립보드로 복사하세요", rssURL);
	}
}


//원내배치도
	function plot(value){
		document.getElementById("plotLeft").src = "/images/cs/icon_tit" + value +".gif"
		document.getElementById("plotCenter").src = "/images/cs/img_tit" + value +".gif"

		var varTargetLength = document.getElementsByName("target");

		for(var i = 0; i < varTargetLength.length; i++){
			varTargetLength[i].src = "/images/cs/btn_tit" + ("0" + i) +"_off.gif";
		}
			
		document.getElementById("target" + value).src = "/images/cs/btn_tit" + value +"_on.gif"

	}


function chk_text(obj, msg) {
    if(!obj.value){
        window.alert(msg);
        obj.focus();
        return false;
    }else{
        return true;
    }
}



