// ---------------------------------------------------------------------------------
//
// TopMenu Script v1.0
// by webdi21@gmail.com - http://cleanup.tistory.com
// 2007.07.03
// 
// Licensed under the Creative Commons Attribution-ShareAlike 2.0 Korea - http://creativecommons.org/licenses/by-sa/2.0/kr/
//
// ---------------------------------------------------------------------------------

function TopMenuScroll() {
	this.GoodsSetTime = null;
}

TopMenuScroll.prototype.GoodsSetting = function(val) {
	this.TopMenuLocation = new Array();
	this.TopMenuDepth2Location = new Array();
	this.TopMenuWrap = document.getElementById(this.DivName);
	this.TopMenuList = this.TopMenuWrap.getElementsByTagName("dl")[0].getElementsByTagName("dt");
	this.TopMenuList1 = this.TopMenuWrap.getElementsByTagName("dl")[0].getElementsByTagName("dd");
	this.TopMenuTotal = this.TopMenuList.length;
	
	this.IEOpacityArray = new Array();
	this.FFOpacityArray = new Array();
	
	for ( var i=0; i<this.TopMenuTotal; i++ ) {
		this.TopMenuLocation[i] = -this.MovieHeight;
		this.TopMenuDepth2Location[i] = this.topMenuDepthStart;

		this.TopMenuListLink = this.TopMenuList.item(i).getElementsByTagName("a")[0];
		this.TopMenuListLink.style.backgroundPosition = "left " + this.TopMenuLocation[i] + "px";
		this.TopMenuListLink.Num = i;
		this.TopMenuListLink.onmouseover = function() {
			eval( "clearTimeout(" + TScroll.GoodsSetTime + ")");
			eval( TScroll.ScrollName + ".TopMenuMove(" + this.Num + ")");
		}
		
		this.TopMenuListLink.onfocus = function() {
			eval( "clearTimeout(" + TScroll.GoodsSetTime + ")");
			eval( TScroll.ScrollName + ".TopMenuMove(" + this.Num + ")");
		}
		
		if ( this.TopMenuList1.item(i) != undefined ) {
			if ( navigator.appName.indexOf("Explorer") != -1 ) {
				this.TopMenuList1.item(i).style.filter="Alpha(opacity=0)";
				this.IEOpacityArray[i] = - this.IEOpacity;
			} else {
				this.TopMenuList1.item(i).style.opacity=0;
				this.FFOpacityArray[i] = - this.FFOpacity;
			}
		}
	}
	if ( val != undefined && val >= 0 && val < this.TopMenuTotal) {
		this.TopMenuMove(val);
	}
}

TopMenuScroll.prototype.TopMenuMove = function(val) {
	this.TopMenuDepth1(val);
	this.TopMenuDepth2(val);
}

TopMenuScroll.prototype.TopMenuDepth1 = function(val,val2) {
	for ( var i=0; i<this.TopMenuTotal; i++ ) {
		this.TopMenuListLink = this.TopMenuList.item(i).getElementsByTagName("a")[0];
		if ( i == val ) {
			if ( this.TopMenuLocation[i] != 0 ) {
				this.TopMenuStop = 1;
				this.TopMenuLocation[i] = this.TopMenuLocation[i] + this.Speed;
				this.TopMenuListLink.style.backgroundPosition = "left " + this.TopMenuLocation[i] + "px";
			} else {
				this.TopMenuStop = 0;
			}
		} else {
			if ( this.TopMenuLocation[i] != -this.MovieHeight ) {
				this.TopMenuLocation[i] = this.TopMenuLocation[i] - this.Speed;
				this.TopMenuListLink.style.backgroundPosition = "left " + this.TopMenuLocation[i] + "px";
			}
		}
	}
	
	
	if ( this.TopMenuStop == 1 ) {
		this.GoodsSetTime = setTimeout( TScroll.ScrollName + ".TopMenuMove(" + val + ")",1);
		val2 += 1;
	}
}

TopMenuScroll.prototype.TopMenuDepth2 = function(val,val2) {
	for ( var i=0; i<this.TopMenuTotal; i++ ) {
		this.TopMenuListDepth2 = this.TopMenuWrap.getElementsByTagName("dl")[0].getElementsByTagName("dd")[i];
		if ( i == val ) {
			if ( this.TopMenuListDepth2 != undefined && this.TopMenuDepth2Location[i] >= this.topMenuDepthStart - ( this.topMenuDepthSpeed * this.topMenuDepthStep ) ) {
				this.TopMenuDepth2Location[i] = this.TopMenuDepth2Location[i] - this.topMenuDepthSpeed;
				this.TopMenuListDepth2.style.top = this.TopMenuDepth2Location[i] + "px";
				if ( navigator.appName.indexOf("Explorer") != -1 ) {
					this.IEOpacityArray[i] = this.IEOpacityArray[i] + this.IEOpacity;
					this.TopMenuListDepth2.style.filter = "Alpha(opacity=" + this.IEOpacityArray[i] + ")";
				} else {
					this.FFOpacityArray[i] = this.FFOpacityArray[i] + this.FFOpacity;
					this.TopMenuListDepth2.style.opacity = this.FFOpacityArray[i];
				}
			}
		} else {
			if ( this.TopMenuListDepth2 != undefined ) {
				if ( this.TopMenuDepth2Location[i] != this.topMenuDepthStart ) {
					this.TopMenuDepth2Location[i] = this.TopMenuDepth2Location[i] + this.topMenuDepthSpeed;
					this.TopMenuListDepth2.style.top = this.TopMenuDepth2Location[i] + "px";
					if ( navigator.appName.indexOf("Explorer") != -1 ) {
						this.IEOpacityArray[i] = this.IEOpacityArray[i] - this.IEOpacity;
						this.TopMenuListDepth2.style.filter = "Alpha(opacity=" + this.IEOpacityArray[i] + ")";
					} else {
						this.FFOpacityArray[i] = this.FFOpacityArray[i] - this.FFOpacity;
						this.TopMenuListDepth2.style.opacity = this.FFOpacityArray[i];
					}
				}
			}
		}
	}
}







// ---------------------------------------------------------------------------------
// recruit faq tab
var faq_slideSpeed = 7;    // Higher value = faster
var faq_timer = 10;    // Lower value = faster

var objectIdToSlideDown = false;
var faq_activeId = false;
var faq_slideInProgress = false;
function showHideContent(e,inputId)
{
    if(faq_slideInProgress)return;
    faq_slideInProgress = true;
    if(!inputId)inputId = this.id;
    inputId = inputId + '';
    var numericId = inputId.replace(/[^0-9]/g,'');
    var answerDiv = document.getElementById('faq_a' + numericId);

    objectIdToSlideDown = false;

    if(!answerDiv.style.display || answerDiv.style.display=='none'){
        if(faq_activeId &&  faq_activeId!=numericId){
            objectIdToSlideDown = numericId;
            slideContent(faq_activeId,(faq_slideSpeed*-1));
        }else{

            answerDiv.style.display='block';
            answerDiv.style.visibility = 'visible';

            slideContent(numericId,faq_slideSpeed);
        }
    }else{
        slideContent(numericId,(faq_slideSpeed*-1));
        faq_activeId = false;
    }
}

function slideContent(inputId,direction)
{

    var obj =document.getElementById('faq_a' + inputId);
    var contentObj = document.getElementById('faq_ac' + inputId);
    height = obj.clientHeight;
    if(height==0)height = obj.offsetHeight;
    height = height + direction;
    rerunFunction = true;
    if(height>contentObj.offsetHeight){
        height = contentObj.offsetHeight;
        rerunFunction = false;
    }
    if(height<=1){
        height = 1;
        rerunFunction = false;
    }

    obj.style.height = height + 'px';
    var topPos = height - contentObj.offsetHeight;
    if(topPos>0)topPos=0;
    contentObj.style.top = topPos + 'px';
    if(rerunFunction){
        setTimeout('slideContent(' + inputId + ',' + direction + ')',faq_timer);
    }else{
        if(height<=1){
            obj.style.display='none';
            if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
                document.getElementById('faq_a' + objectIdToSlideDown).style.display='block';
                document.getElementById('faq_a' + objectIdToSlideDown).style.visibility='visible';
                slideContent(objectIdToSlideDown,faq_slideSpeed);
            }else{
                faq_slideInProgress = false;
            }
        }else{
            faq_activeId = inputId;
            faq_slideInProgress = false;
        }
    }
}



function initShowHideDivs()
{
    var divs = document.getElementsByTagName('DIV');
    var divCounter = 1;
    for(var no=0;no<divs.length;no++){
        if(divs[no].className=='faq_question'){
            divs[no].onclick = showHideContent;
            divs[no].id = 'faq_q'+divCounter;
            var answer = divs[no].nextSibling;
            while(answer && answer.tagName!='DIV'){
                answer = answer.nextSibling;
            }
            answer.id = 'faq_a'+divCounter;
            contentDiv = answer.getElementsByTagName('DIV')[0];
            contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px';
            contentDiv.className='faq_answer_content';
            contentDiv.id = 'faq_ac' + divCounter;
            answer.style.display='none';
            answer.style.height='1px';
            divCounter++;
        }
    }
}



///  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 '';
    }
