
/*ActiveX ÇÃ·¡½¬*/
// id: flash id
// url: source url
// w: source width
// h: source height
// t: wmode (none/transparent/opaque)

function Flash(id,url,w,h,bg,t){
document.write("\
<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width="+w+" height="+h+" id="+id+">\
<param name='movie' value="+url+" />\
<param name='wmode' value="+t+" />\
<param name='bgcolor' value="+bg+" />\
<param name='allowScriptAccess' value='always' />\
<param name='quality' value='high' />\
<param name='menu' value='false' />\
<embed src="+url+" width="+w+" height="+h+" name="+id+" bgcolor="+bg+" wmode="+t+" allowScriptAccess='always' quality='high' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />\
</object>\
");
}

/*ActiveX µ¿¿µ»ó	<script>Movie('url','178','133','0');</script*/
function Movie(url,width,height,controls){
document.write("\
<object width='"+width+"' height='"+height+"' id='Player' classid='clsid:22D6f312-B0F6-11D0-94AB-0080C74C7E95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject' VIEWASTEXT>\
<param name='AutoRestart' value='true'>\
<param name='AutoRewind' value='false'>\
<param name='ShowAudioControls' value='true'>\
<param name='ShowControls' value='"+controls+"'>\
<param name='PlayCount' value='1'>\
<param name='EnableContextMenu' value='0'>\
<param name='BufferTime' value='3'>\
<param name='ClickToPlay' value='false'>\
<param name='AnimationAtStart' value='false'>\
<param name='FileName' value='"+url+"'>\
<param name='Volume' value='0'>\
</object>\
");
}
/* IE¿Í FF ÃÖ¼Ò ³ôÀÌ µ¿±âÈ­ ½ÃÅ°±â À§ÇØ »ç¿ë *//*
function IEHeight() {
	document.write("\
		<!--[if IE]>\
		<style type='text/css'>\
		#Container {\
		  height: 85%;\
		 }\
		#Contents {\
		  height: 100%;\
		 }\
		</style>\
		<![endif]-->\
	");
}*/

/**
 * LG Chemistry Family
 * Author : http://www.cidow.com
 */

/**
 * share
 */

function flashPrint(strFile, width, height) {
	document.write("<!-- Hixie method --><!--[if IE]><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='" + width + "' height='" + height + "' id='flash_movie' align='middle'><param name='movie' value='" + strFile + "'><param name='wmode' value='opaque'><param name='menu' value='false'></object><![endif]--><!-- Hixie method --><!--[if !IE]> <--><object type='application/x-shockwave-flash' data='" + strFile + "' width='" + width + "' height='" + height + "'><param name='wmode' value='opaque'><param name='menu' value='false'></object><!--> <![endif]-->");
}

function initToggleDefList(listEl) {
	listEl.currentItem = false;
	listEl.dtList = listEl.getElementsByTagName("dt");
	listEl.ddList = listEl.getElementsByTagName("dd");

	for (i=0; i<listEl.getElementsByTagName("dt").length; i++) {
		listEl.dtList.item(i).dlEl = listEl;
		listEl.dtList.item(i).listNum = i;
		listEl.dtList.item(i).onclick = toggleDefinitionList;
	}
}
function toggleDefinitionList() {
	if (this.dlEl.dtList.item(this.dlEl.currentItem) && this.dlEl.ddList.item(this.dlEl.currentItem) && this.dlEl.currentItem != this.listNum) {
		this.dlEl.dtList.item(this.dlEl.currentItem).className = null;
		this.dlEl.ddList.item(this.dlEl.currentItem).className = null;
	}
	if (this.dlEl.ddList.item(this.listNum).className == "on") {
		this.dlEl.dtList.item(this.listNum).className = null;
		this.dlEl.ddList.item(this.listNum).className = null;
	} else {
		this.dlEl.dtList.item(this.listNum).className = "on";
		this.dlEl.ddList.item(this.listNum).className = "on";
	}

	this.dlEl.currentItem = this.listNum;
}

function tableDesign () {
	tBody = document.getElementsBySelector("div.board div.board-middle table.list tbody");
	tBody_len = tBody.length;
	for ( i=0 ; i<tBody_len; i++ ) {
		tArry = tBody[i].getElementsByTagName("tr");
		lastTr = tArry.item(tArry.length - 1);
		lastTr.className = lastTr.className + " last-child";
	}
}
// image roll
function menuOver() {
	this.src = this.src.replace("_off.gif", "_on.gif");
}
function menuOut() {
	this.src = this.src.replace("_on.gif", "_off.gif");
}

function imageOver(imgEl) {
	imgEl.src = imgEl.src.replace(".gif", "_on.gif");
}
function imageOut(imgEl) {
	imgEl.src = imgEl.src.replace("_on.gif", ".gif");
}

//
function tdover(obj) {
		obj.parentNode.parentNode.className = obj.parentNode.parentNode.className + " on";
}

function tdout(obj) {
		obj.parentNode.parentNode.className = obj.parentNode.parentNode.className.replace(" on", "");
}

// layout adjust
function layoutAdjust() {
	subHeight = document.getElementById("sub").offsetHeight;
	bodyHeight = document.getElementById("body").offsetHeight;
//	alert(subHeight + ", " + bodyHeight);
	if (subHeight > bodyHeight) {
		document.getElementById("body").style.height = subHeight + "px";
	}
	if (document.getElementById("club-sub")) {
		clubSubHeight = document.getElementById("club-sub").offsetHeight;
		if (clubSubHeight - 115 > bodyHeight) {
			document.getElementById("body").style.height = clubSubHeight - 45 + "px";
		}
	}
}

// content tab menu
function initContentTabmenu(elementList, menuSequence) {
	menuitem = elementList;
	for (i = 0; i < menuitem.length; i++) {
		if (menuSequence - 1 != i) {
			menuitem[i].onmouseover = menuOver;
			menuitem[i].onmouseout = menuOut;
		} else {
			menuitem[i].src = menuitem[i].src.replace(".gif", "_on.gif")
		}
	}
}


/*
 * AA¢¯i ¨ö¨¬A¨Ï¡¤N ¨¡¨ùA¢¯
 * <div>
 * 	<p>
 * 		<span>scroll text</span>
 * 	<p>
 * <div>
 * 
 * initTicker(divElement);
 */
function initTicker(container) {
	mover = container.getElementsByTagName("p").item(0);
	text = mover.getElementsByTagName("span").item(0);
	
	// set
	mover.style.position = "absolute";
	mover.style.margin = "0 0 0 0";
	mover.style.left = "0px";
	mover.leftPosition = 0;
	mover.style.width = text.childNodes.item(0).length + "em";	// stretch width
	textWidth = text.offsetWidth;

	if (textWidth > container.offsetWidth) {	// enough space for move
		// duplicate text
		mover.style.width = textWidth * 2 + "px";
		mover.innerHTML += mover.innerHTML;
		
		// set action
		mover.tickerAction = window.setInterval(
			function()
			{
				if (mover.leftPosition * -1 > textWidth) {
					mover.leftPosition = -1;
				} else {
					mover.leftPosition -= 1;
				}
				mover.style.left = mover.leftPosition + "px";
			}
		, 40);
	}
}

// tabbed menu
function initTabMenu(menuElId,tNum) {
	var tabMenu = document.getElementsByName("tab");
	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").item(0)) {
			thismenu.getElementsByTagName("img").item(0).onmouseover = menuOver;
			thismenu.getElementsByTagName("img").item(0).onmouseout = menuOut;
		}
		*/
		thismenu.onclick = tabMenuClick;
	}

	initmenu = tabMenu.item(tNum);
	initmenu.targetEl.style.display = "block";
	/*
	if (initmenu.getElementsByTagName("img").item(0)) {
		initmenu.getElementsByTagName("img").item(0).onmouseover();
		initmenu.getElementsByTagName("img").item(0).onmouseover = null;
		initmenu.getElementsByTagName("img").item(0).onmouseout = null;
	}
	*/
	initmenu.getElementsByTagName("img").item(0).src = initmenu.getElementsByTagName("img").item(0).src.replace(".gif", "_on.gif");
	initmenu.menuContainer.current = initmenu;
}
function tabMenuClick() {
	currentmenu = this.menuContainer.current;
	if (currentmenu != this) {
		currentmenu.targetEl.style.display = "none";
		/*
		if (currentmenu.getElementsByTagName("img").item(0)) {
			currentmenu.getElementsByTagName("img").item(0).onmouseover = menuOver;
			currentmenu.getElementsByTagName("img").item(0).onmouseout = menuOut;
			currentmenu.getElementsByTagName("img").item(0).onmouseout();
		}
		*/
		currentmenu.getElementsByTagName("img").item(0).src = currentmenu.getElementsByTagName("img").item(0).src.replace("_on.gif", ".gif")
	
		this.targetEl.style.display = "block";
		/*
		if (this.getElementsByTagName("img").item(0)) {
			this.getElementsByTagName("img").item(0).onmouseover = null;
			this.getElementsByTagName("img").item(0).onmouseout = null;
		}
		*/
		this.getElementsByTagName("img").item(0).src = this.getElementsByTagName("img").item(0).src.replace(".gif", "_on.gif");
		this.menuContainer.current = this;
	}
	return false;
}



/**
 * CSS Control
 */

/* document.getElementsBySelector(selector)
	 - returns an array of element objects from the current document
		 matching the CSS selector. Selectors can contain element names, 
		 class names and ids and can be nested. For example:
		 
			 elements = document.getElementsBySelect('div#main p a.external')
		 
		 Will return an array of all 'a' elements with 'external' in their 
		 class attribute that are contained inside 'p' elements that are 
		 contained inside the 'div' element which has id="main"

	 New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
	 See http://www.w3.org/TR/css3-selectors/#attribute-selectors

	 Version 0.4 - Simon Willison, March 25th 2003
	 -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
	 -- Opera 7 fails 
*/

function getAllChildren(e) {
	// Returns all children of element. Workaround required for IE5/Windows. Ugh.
	return e.all ? e.all : e.getElementsByTagName('*');
}

document.getElementsBySelector = function(selector) {
	// Attempt to fail gracefully in lesser browsers
	if (!document.getElementsByTagName) {
		return new Array();
	}
	// Split selector in to tokens
	var tokens = selector.split(' ');
	var currentContext = new Array(document);
	for (var i = 0; i < tokens.length; i++) {

		token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');;
		if (token.indexOf('#') > -1) {
			// Token is an ID selector
			var bits = token.split('#');
			var tagName = bits[0];
			var id = bits[1];
			var element = document.getElementById(id);
			if (tagName && element.nodeName.toLowerCase() != tagName) {
				// tag with that ID not found, return false
				return new Array();
			}
			// Set currentContext to contain just this element
			currentContext = new Array(element);
			continue; // Skip to next token
		}
		if (token.indexOf('.') > -1) {
			// Token contains a class selector
			var bits = token.split('.');
			var tagName = bits[0];
			var className = bits[1];
			if (!tagName) {
				tagName = '*';
			}
			// Get elements matching tag, filter them for class selector
			var found = new Array;
			var foundCount = 0;
			for (var h = 0; h < currentContext.length; h++) {
				var elements;
				if (tagName == '*') {
						elements = getAllChildren(currentContext[h]);
				} else {
						elements = currentContext[h].getElementsByTagName(tagName);
				}
				for (var j = 0; j < elements.length; j++) {
					found[foundCount++] = elements[j];
				}
			}
			currentContext = new Array;
			var currentContextIndex = 0;
			for (var k = 0; k < found.length; k++) {
				if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) {
					currentContext[currentContextIndex++] = found[k];
				}
			}
			continue; // Skip to next token
		}
		// Code to deal with attribute selectors
		if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {
			var tagName = RegExp.$1;
			var attrName = RegExp.$2;
			var attrOperator = RegExp.$3;
			var attrValue = RegExp.$4;
			if (!tagName) {
				tagName = '*';
			}
			// Grab all of the tagName elements within current context
			var found = new Array;
			var foundCount = 0;
			for (var h = 0; h < currentContext.length; h++) {
				var elements;
				if (tagName == '*') {
						elements = getAllChildren(currentContext[h]);
				} else {
						elements = currentContext[h].getElementsByTagName(tagName);
				}
				for (var j = 0; j < elements.length; j++) {
					found[foundCount++] = elements[j];
				}
			}
			currentContext = new Array;
			var currentContextIndex = 0;
			var checkFunction; // This function will be used to filter the elements
			switch (attrOperator) {
				case '=': // Equality
					checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
					break;
				case '~': // Match one of space seperated words 
					checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
					break;
				case '|': // Match start with value followed by optional hyphen
					checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); };
					break;
				case '^': // Match starts with value
					checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); };
					break;
				case '$': // Match ends with value - fails with "Warning" in Opera 7
					checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); };
					break;
				case '*': // Match ends with value
					checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); };
					break;
				default :
					// Just test for existence of attribute
					checkFunction = function(e) { return e.getAttribute(attrName); };
			}
			currentContext = new Array;
			var currentContextIndex = 0;
			for (var k = 0; k < found.length; k++) {
				if (checkFunction(found[k])) {
					currentContext[currentContextIndex++] = found[k];
				}
			}
			// alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
			continue; // Skip to next token
		}
		// If we get here, token is JUST an element (not a class or ID selector)
		tagName = token;
		var found = new Array;
		var foundCount = 0;
		for (var h = 0; h < currentContext.length; h++) {
			var elements = currentContext[h].getElementsByTagName(tagName);
			for (var j = 0; j < elements.length; j++) {
				found[foundCount++] = elements[j];
			}
		}
		currentContext = found;
	}
	return currentContext;
}

var Content_Code = "";
var ArticleNum   = "";

/* That revolting regular expression explained 
/^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
	\---/	\---/\-------------/		\-------/
		|			|				 |							 |
		|			|				 |					 The value
		|			|		~,|,^,$,* or =
		|	 Attribute 
	 Tag
*/


// family site
function startFamilySiteScroll() {
	setTimeout("slideFamilySite()", 10);
}
function slideFamilySite() {
	el = document.getElementById("related-site-list");
	el.style.border = "1px solid #BFC6CE";
	el.style.borderBottom = "1px solid #fff";
	if (el.heightPos == null || (el.isDone && el.isOn == false)) {
		el.isDone = false;
		el.heightPos = 0;
		el.heightTo = 110;
		document.getElementById("family-img").style.background = "url(/images/nav/select_h3_close.gif) no-repeat";
	} else if (el.isDone && el.isOn){
		el.isDone = false;
		el.heightTo = 0;
		document.getElementById("family-img").style.background = "url(/images/nav/select_h3.gif) no-repeat";
	}
	if (Math.abs(el.heightTo - el.heightPos) > 1) {
		el.heightPos += (el.heightTo - el.heightPos) / 10;
		el.style.height = el.heightPos + "px";
		startFamilySiteScroll();
	} else {
		if (el.heightTo == 110) {
			el.isOn = true;
		} else {
			el.isOn = false;
			el.style.border = "1px solid #F3F3F3";
		}
		el.heightPos = el.heightTo;
		el.style.height = el.heightPos + "px";
		el.isDone = true;
	}
}


