﻿// Flash publishing with Cross Browsing
function swfprint(furl,fwidth,fheight,transoption)	{
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+ fwidth +'" height="' + fheight +'" align="middle">');
	document.write('<param name="movie" value="'+ furl +'"/>');
	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" data="'+ furl +'" width="'+ fwidth +'" height="' + fheight +'"');
	if (transoption == "t")	{
		document.write(' wmode="transparent"');
	} else if	(transoption == "o")	{
		document.write(' wmode="opaque"');
	}
	document.write('></object>');
	document.write('<!--> <![endif]-->');
	document.write('</object>');
}


//imageOver
function imageOver(objImg) {	objImg.src = objImg.src.replace("off.gif", "on.gif");}
function imageOut(objImg) {	objImg.src = objImg.src.replace("on.gif", "off.gif");}

// Embeded function image Over
function menuOver() {	this.src = this.src.replace("_off.gif", "_on.gif");}
function menuOut() {	this.src = this.src.replace("_on.gif", "_off.gif");}

// Layer Show-Hide
function showLayer(tgtEl)    {    document.getElementById(tgtEl).style.display = "block";    }
function hideLayer(tgtEl)    {    document.getElementById(tgtEl).style.display = "none";    }

// 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 initTabMenuClick(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return false;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", "_off.gif");
				} else {
					currentmenu.className = currentmenu.className.replace(" on", "off");
				}
			}
			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace("_off.gif", "_on.gif");
			} else {
				this.className += " on";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}

//Popup
function wopen(url,name,w,h,s) {
    if(s==1)    {
        sOp = ",scrollbars=yes";
    } else  if(s==0)   {
        sOp = "";
    }
    winOptions = getCenterOption(w, parseInt(h, 10)) + ',width='+w+',height='+h+sOp;
    window.open(url, name, winOptions);
}
//Popup Close
function wclose()     {
    window.close();
}
//Popup Print
function wprint()     {
    window.print();
}
// 가로,세로 사이즈에 맞는 센터지점의 속성값을 반환한다.
function getCenterOption(winwidth, winheight) {
    var winx = Math.ceil((screen.availWidth - winwidth) / 2);
    var winy = Math.ceil((screen.availHeight - winheight) / 2);
    return "left=" + winx + ",top=" + winy;
}
//png
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 '';
}

// 스크롤바에 따라다니는 레이어 스크립트
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 500;
		}
	}

	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)
}

// 2009-01-05 추가(이상우)
function topMenuDisp(ctrl_id, do_disp) {
    alert("ctrl_id: " + ctrl_id);
    //document.getElementById(ctrl_id).style.visibility = do_disp;
    //document.getElementByName(ctrl_id).style.visibility = do_disp;
}

function faqstyle(objid) {

    this.titletype = 'image';
    this.titleonclass = 'on';
    this.titleonimagename = '_on';
    this.closeothers = true;
    this.autoopen = 0;

    var obj = document.getElementById(objid);
    var objtitle = obj.getElementsByTagName("span")[2];
    var titles = new Array(), contents = new Array();

    this.initialize = function() {
        var nodeno = 0, childs = obj.childNodes;
        for (var i = 0, max = childs.length; i < max; i++) {
            if (childs[i].nodeType == 1) {
                if ((nodeno % 2) == 0) {
                    childs[i].myno = nodeno / 2;
                    mousesetting(childs[i]);
                    childs[i].onclick = function() {
                        eval(objid).action(this.myno);
                        return false;
                    }
                    childs[i].style.cursor = 'pointer';
                    titles.push(childs[i]);
                    this.setclassoff(childs[i]);
                } else {
                    childs[i].style.display = 'none';
                    contents.push(childs[i]);
                }
                nodeno++;
            }
        }
       
        if (this.autoopen) this.action(this.autoopen - 1);
    }

    this.setclasson = function(target) {
        var classes, exist = false;
        if (this.titletype == 'image') {
            var titleimg = target.getElementsByTagName('img')[1];
            var titleimgexp = titleimg.src.substring(titleimg.src.lastIndexOf('.'));
            titleimg.src = (titleimg.src.indexOf(this.titleonimagename + titleimgexp) == -1) ? titleimg.src.replace(titleimgexp, this.titleonimagename + titleimgexp) : titleimg.src;
        }
        classes = target.className.split(' ');
        for (var j = 0; j < classes.length; j++) if (classes[j] == this.titleonclass) exist = true;
        if (!exist) target.className = target.className + ' ' + this.titleonclass;
    }

    this.setclassoff = function(target) {
        if (this.titletype == 'image') {
            var titleimg = target.getElementsByTagName('img')[1];
            var titleimgexp = titleimg.src.substring(titleimg.src.lastIndexOf('.'));
            titleimg.src = titleimg.src.replace(this.titleonimagename + titleimgexp, titleimgexp);
        }
        if (target.className.indexOf(this.titleonclass) != -1) {
            if (target.className.indexOf(' ') == -1) target.className = target.className.replace(this.titleonclass, '');
            else {
                classes = target.className.split(' ');
                for (var j = 0; j < classes.length; j++) if (classes[j] == this.titleonclass) classes[j] = '';
                target.className = classes.join(' ');
            }
        }
    }

    var mousesetting = function(target, remove) {
        if (remove) {
            target.onmouseover = null;
            target.onmouseout = null;
        } else {
            //target.onmouseover=function(){
            //   eval(objid).setclasson(this);
            //}
            target.onmouseout = function() {
                eval(objid).setclassoff(this);
            }
        }
    }

    this.action = function(no) {
        for (var i = 0, max = titles.length; i < max; i++) {
            if (i == no) {
                mousesetting(titles[i], true);
                this.setclasson(titles[i]);
                if (contents[i].style.display == 'none') contents[i].style.display = '';
                else {
                    this.setclassoff(titles[i]);
                    contents[i].style.display = 'none';
                }
            } else {
                if (this.closeothers) {
                    this.setclassoff(titles[i]);
                    contents[i].style.display = 'none';
                }
            }
            if (contents[i].style.display == 'none') mousesetting(titles[i]);
        }
    }

}
