///// Auto blur
function autoBlur(){ 
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="img") 
document.body.focus(); 
}
document.onfocusin=autoBlur; 
//-->

/* ·Ñ¸µ ÄÁÅÙÃ÷  */
function init_rolling_content(id,tag,classname,random){
	var obj=document.getElementById(id);
	obj.nowno=0;
	if(tag){
		if(classname){
			var temp=obj.getElementsByTagName(tag);
			obj.mycs=new Array();
			for(var i=0,max=temp.length; i<max; i++) if(temp[i].className==classname) obj.mycs.push(temp[i]);
		}else obj.mycs=obj.getElementsByTagName(tag);
	}else obj.mycs=obj.getElementsByTagName('ul');
	obj.mycsnum=obj.mycs.length;
	var showno=0;
	if(random){
		showno=Math.floor(Math.random()*obj.mycsnum);
		obj.nowno=showno;
	}
	for(var i=0; i<obj.mycsnum; i++){
		if(i!=showno) obj.mycs[i].style.display='none';
	}
	if(classname=='rankitems') init_homepage_textroll(id);
}

/* ·Ñ¸µ ÄÁÅÙÃ÷ ¾×¼Ç(id,'prev'¶Ç´Â'next') */
function rolling_wooriwm(id,flag){
	var obj=document.getElementById(id);
	if(obj.mycsnum<2) return;
	else{
		obj.nowno=(flag=='prev')? (obj.nowno==0)? obj.mycsnum-1 : obj.nowno-1 : (obj.nowno==(obj.mycsnum-1))? 0 : obj.nowno+1;
		for(var i=0; i<obj.mycsnum; i++){
			if(i==obj.nowno) obj.mycs[i].style.display='block';
			else obj.mycs[i].style.display='none';
		}
	}
}

// ·¹ÀÌ¾î - ¿©·¯°³ ·¹ÀÌ¾îÁß ÇÑ°³¸¸ º¸¿©ÁÜ
function Show_OneLayer(GroupName, Total, LayerID)   // (ÀÌ¸§, ÃÑ·¹ÀÌ¾î °¹¼ö, º¸¿©ÁÖ·Á´Â ·¹ÀÌ¾î)
{
    var targetId;

    targetId = GroupName + LayerID;
    document.getElementById(targetId).style.display = 'block';

    for (var i=0; i<Total; i++) {
        if (i != LayerID)
        {
            targetId = GroupName + i;
            document.getElementById(targetId).style.display = 'none';
        }
    }
}


// ÅÇ ¸¶¿ì½º ¿À¹ö½º ÀÌ¹ÌÁö º¯È¯
 function imgOver(imgEl) { imgEl.src = imgEl.src.replace(".gif", "_on.gif");}
 function imgOut(imgEl) { imgEl.src = imgEl.src.replace("_on.gif", ".gif");}


// °Ô½ÃÆÇ¿¡ »ç¿ë  ¸¶¿ì½º ¿À¹ö½Ã tr ¹è°æ ±³Ã¼
	function bgChange(row)
	{
		color = row.style.backgroundColor;
		
		row.style.backgroundColor = '#ecf2f9';
	}
 
	function bgRecover(row)
	{
		row.style.backgroundColor = color;
	}


//¸¶¿ì½º¿À¹ö
function menuOver() {
	this.src = this.src.replace(".gif", "_on.gif");
}
function menuOut() {
	this.src = this.src.replace("_on.gif", ".gif");
}


//ÅÇ ·¹ÀÌ¾î

function initTabMu(menuElId, idx) {
	var tabMenu = document.getElementById(menuElId).getElementsByTagName("a");
	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";
		thismenu.getElementsByTagName("img").item(0).onmouseover = menuOver;
		thismenu.getElementsByTagName("img").item(0).onmouseout = menuOut;
		thismenu.onclick = tabMenuClick;
	}

	initmenu = tabMenu.item(idx);
	initmenu.targetEl.style.display = "block";
	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.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.getElementsByTagName("img").item(0).onmouseover = null;
		this.getElementsByTagName("img").item(0).onmouseout = null;
		this.menuContainer.current = this;
		contractcontent(1);
	}
	return false;
}

//ÀÚÁÖÇÏ´ÂÁú¹®
var enablepersist="on" // ÄíÅ°¸¦ Àû¿ëÇÏ¿© À§Ä¡±â¾ï½ÃÅ°±â ¼³Á¤ (on/off)
var collapseprevious="no" // ÀÌÀü ¿­¾ú´ø Ç×¸ñ À¯Áö¿©ºÎ (yes/no)

var contractsymbol='- ' // Ãà¼Ò¹öÆ° ÀÌ¹ÌÁö·Î »ç¿ëÇÒ °æ¿ì <img src="whatever.gif"> Ã³·³ ¼³Á¤ÇØ ÁÝ´Ï´Ù
var expandsymbol='+ ' // È®Àå¹öÆ°


if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}

function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
temparray[inc++]=rootobj[i]
}
return temparray
}

function sweeptoggle(ec){
var thestate=(ec=="expand")? "block" : "none"
var inc=0
while (ccollect[inc]){
ccollect[inc].style.display=thestate
inc++
}
revivestatus()
}


function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(curobj, cid){
var spantags=curobj.getElementsByTagName("SPAN")
var showstateobj=getElementbyClass(spantags, "showstate")
if (ccollect.length>0){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
if (showstateobj.length>0){ 
if (collapseprevious=="no")
showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol
else
revivestatus()
}
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function revivestatus(){
var inc=0
while (statecollect[inc]){
if (ccollect[inc].style.display=="block")
statecollect[inc].innerHTML=contractsymbol
else
statecollect[inc].innerHTML=expandsymbol
inc++
}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
var alltags=document.all? document.all : document.getElementsByTagName("*")
ccollect=getElementbyClass(alltags, "switchcontent")
statecollect=getElementbyClass(alltags, "showstate")
if (enablepersist=="on" && ccollect.length>0){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 
if (!firsttimeload)
revivecontent()
}
if (ccollect.length>0 && statecollect.length>0)
revivestatus()
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate


/*** [  iframe ÀÚµ¿ »çÀÌÁî Á¶Àý } ***/

var iframeids=["prodCompareLayer"] // iframe ¿¡ »ç¿ëÇÒ ID ¸¦ ÁöÁ¤ ÇØ ÁÖ¼¼¿ä

var iframehide="yes"

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeiframe(iframeids[i])
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeiframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight; 
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustiframe, false)
else if (currentfr.attachEvent)
currentfr.attachEvent("onload", readjustiframe)
}
}

function readjustiframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeiframe(iframeroot.id);
}

function loadintoiframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller