
// Google_120209
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-29041897-1']);
_gaq.push(['_trackPageview']);

(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


//Element ID 불러쓰기
function dEI(elementID){
	return document.getElementById(elementID);
}

// roundBox Layout
function initLayout(layoutEl,childEl) {
	var layoutId = dEI(layoutEl);
	var contentsId = dEI(childEl);

	//create and build div structure
	var bodyTH = document.createElement('div');
	var bodyLV = document.createElement('div');
	var bodyRV = document.createElement('div');
	var bodyBH = document.createElement('div');
	var bodyTL = document.createElement('div');
	var bodyTR = document.createElement('div');
	var bodyBL = document.createElement('div');
	var bodyBR = document.createElement('div');
	bodyTH.className = "bodyTH";
	bodyLV.className = "bodyLV";
	bodyRV.className = "bodyRV";
	bodyBH.className = "bodyBH";
	bodyTL.className = "bodyTL";
	bodyTR.className = "bodyTR";
	bodyBL.className = "bodyBL";
	bodyBR.className = "bodyBR";
	layoutId.appendChild(bodyTH);
	bodyTH.appendChild(bodyLV);
	bodyLV.appendChild(bodyRV);
	bodyRV.appendChild(bodyBH);
	bodyBH.appendChild(bodyTL);
	bodyTL.appendChild(bodyTR);
	bodyTR.appendChild(bodyBL);
	bodyBL.appendChild(bodyBR);
	bodyBR.appendChild(contentsId);
}

//Images Btn_KSS
function BtnOn(imgEl){
	imgEl.src = imgEl.src.replace(".gif", "_on.gif");
}
function BtnOut(imgEl){
	imgEl.src = imgEl.src.replace("_on.gif", ".gif");
}

// first 예외처리 firstChild(블럭Id, 태그네임, 처리할 아이템 번호) // 아이템번호는 0번부터 반환
function firstChild(Elid, Etn, Num){
	if(Num==""){Num=0;}
	liEl = dEI(Elid).getElementsByTagName(Etn);
	if (liEl.item(Num)) {
		liEl.item(Num).className += " first-child";
	}
}

// first 예외처리 listFirst(블럭Id, 태그네임, 처리할 아이템 갯수) // 아이템번호는 0번부터 반환
function listFirst(Elid, Etn, Num){
	liEl = dEI(Elid).getElementsByTagName(Etn);
	for(i=0; liEl.length>i; i=i+Num){
		liEl.item(i) .className += " first";
	}
}

// first line 예외처리 firstLine(블럭Id, 태그네임, 처리할 아이템 갯수) // 아이템번호는 0번부터 반환
function firstLine(Elid, Etn, Num){
	liEl = dEI(Elid).getElementsByTagName(Etn);
	var checkNum = Num;
	if(liEl.length<Num){
		liEl.length = checkNum;
	}
	for(i=0; i<checkNum; i++){
	liEl.item(i) .className += " firstLine";
	}
}

/* 메뉴스크립트 */
function onTopNavi(viewNum){
	for(var i =1;i<6; i++){
		var onList=dEI("E0"+i);
		var onImg=onList.getElementsByTagName("img").item(0);
		if(i==viewNum){
			onList.className="on";
			var ImgCheck = onImg.src.substring(onImg.src.length-6,onImg.src.length);
			if (ImgCheck!="on.gif") {
				onImg.src = onImg.src.replace(".gif", "on.gif");
			}
		}else{
			onList.className="";
				if (ImgCheck="on.gif") {
				onImg.src = onImg.src.replace("on.gif", ".gif");
			}

		}
	}
}

// layer display
function layerDis(layerID, layerLeft, layerTop, layerW, layerH){
	var tlayer = dEI(layerID);
	if(tlayer.style.display != "block"){
		tlayer.style.display = "block";
		tlayer.style.left = layerLeft + "px";
		tlayer.style.top = layerTop + "px";
		tlayer.style.width = layerW + "px";
		tlayer.style.height = layerH + "px";
	}else if(tlayer.style.display != "none"){
		tlayer.style.display = "none";
	}else{
		tlayer.style.display = "none";
	}
}

// layer openLayer
function openLayer(layerID){
	var tlayer = dEI(layerID);
		tlayer.style.display = "block";
}
// layer closeLayer
function closeLayer(layerID){
	var tlayer = dEI(layerID);
		tlayer.style.display = "none";
}

// class add
function classAdd(boxID){
	var targetBox = dEI(boxID);
	if(targetBox.className != "on"){
		targetBox.className = "on";
	}else{
		targetBox.className = " ";
	}
}

// value change
function valueChange(target,type){
	if ( target.value == target.defaultValue && type==0) target.value = "";
	if ( !target.value && type==1) target.value = target.defaultValue;
}

// Tab Content
function tabCheck(dotabid, num){
		var inum=parseInt(num)-1;
		var linkTab=dEI(dotabid).getElementsByTagName("a");
		for (i=0;i<linkTab.length;i++) {
			var tabimg = linkTab.item(i).getElementsByTagName("img").item(0);
			var  tabContents= dEI(dotabid+(1+i));
			if (i==inum) {
				if(tabContents.style.display!="block"){
					tabimg.src=tabimg.src.replace(".gif", "on.gif");
					tabContents.style.display="block";
				}
		}else{
			tabimg.src=tabimg.src.replace("on.gif", ".gif");
			tabContents.style.display="none";
		}
	}
}

//팝업띄우기
function openPop(url,idn,intWidth,intHeight,scroll,tp,lf) {
	//alert("pop_scroll");
	var default_ext = "width="+intWidth+", height="+intHeight+",resizable=0,scrollbars="+scroll;
	if (tp!="") {
		default_ext += ",top="+tp;
	}
	if (lf!="") {
		default_ext += ",left="+lf;
	}
	window.open(url, idn, default_ext) ;
}

//IE6 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 imgRollover(imgBoxID){
	var MenuCounts = dEI(imgBoxID).getElementsByTagName("img");
	for (i=0;i<MenuCounts.length;i++) {
		var numImg=MenuCounts.item(i);
		var ImgCheck = numImg.src.substring(numImg.src.length-6,numImg.src.length);
		if (ImgCheck!="on.gif") {
				numImg.onmouseover = function () {
					this.src = this.src.replace(".gif", "on.gif");
				}
				numImg.onmouseout = function () {
					this.src = this.src.replace("on.gif", ".gif");
				}
			}
	}
}

//Footer select Open
function selectOn(boxID){
	var selectBox = document.getElementById(boxID);
	//var selectObj = document.getElementById("relatedSelect")

	if(selectBox.style.display!="block"){
	selectBox.style.display="block";
	//selectObj.src = selectObj.src.replace(".gif","_on.gif");
	selectBox.onmouseover = function(){selectBox.style.display="block";}
	selectBox.onmouseout = function(){
		selectBox.style.display="none";
		//selectObj.src = selectObj.src.replace("_on.gif",".gif");
	}
	}else{
		selectBox.style.display="none";
		//selectObj.src = selectObj.src.replace("_on.gif",".gif");
	}
}

//Text Zoom
var TextZoom = 1;
function zoom(check){
	if(check == "in"){
		TextZoom+=0.2;
		if(TextZoom>=1.8){
			alert("더 이상 크게 볼 수 없습니다.")
			return;
		}
	}else{
		TextZoom-=0.2;
		if(TextZoom<=0.8){
			alert("더 이상 작게 볼 수 없습니다.")
			return;
		}
	}
	var txtEle = dEI("cntWrap");
	txtEle.style.fontSize = TextZoom +"em";
	//alert(text);
}

//FAQ
function toggleList(tabContainer) {
	var tabContainer=document.getElementById(tabContainer)
	var triggers = tabContainer.getElementsByTagName("a");

	for(i = 0; i < triggers.length; i++) {
		if (triggers.item(i).href.split("#")[1])
			triggers.item(i).targetEl = document.getElementById(triggers.item(i).href.split("#")[1]);

		if (!triggers.item(i).targetEl)
			continue;

		triggers.item(i).targetEl.style.display = "none";
		triggers.item(i).className="";
		triggers.item(i).onclick = function () {
			if (tabContainer.current == this) {
				this.targetEl.style.display = "none";
				this.className="";
				tabContainer.current = null;
			} else {
				if (tabContainer.current) {
					tabContainer.current.targetEl.style.display = "none";
					tabContainer.current.className="";
				}
				this.targetEl.style.display = "block";
				this.className="on";
				tabContainer.current = this;
			}
			return false;
		}
	}
	//triggers.item(0).targetEl.style.display = "block";
}

// print
function cntPrint(){
	window.print();
}

// scrolling layer
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)
}
//scrolling layer end

//family site
function ftrfmly(fmlonf) {
	var divs = document.getElementById("FmlySt");

	if(fmlonf == "block") {
		divs.style.left = 800;
		divs.style.posTop = 607;
		divs.style.display = "block";
	//	alert(nowtop);
	} else if(fmlonf == "click") {
		if(divs.style.display == "block") {
			divs.style.display = "none"
		} else {
			divs.style.left = 800;
			divs.style.posTop = 607;
			divs.style.display = "block";
		}
	} else if(fmlonf == "out") {
		divs.style.display = "none";
	} else {
		if(divs.style.display == "block") {
			divs.style.display = "none";
		}
	}
}

function ftrfmly_sub(fmlonf) {
	var divs = document.getElementById("FmlySt");
	var bodyHeight = document.body.scrollHeight;

	if(fmlonf == "block") {
		if(divs.style.display == "none") {
			divs.style.left = 640;
			divs.style.posTop = bodyHeight - 50;
			divs.style.display = "block";
		}
	//	alert(nowtop);
	} else if(fmlonf == "click") {
		if(divs.style.display == "block") {
			divs.style.display = "none"
		} else {
			divs.style.left = 640;
			divs.style.posTop = bodyHeight - 50;
			divs.style.display = "block";
		}
	} else if(fmlonf == "out") {
		divs.style.display = "none";
	} else {
		if(divs.style.display == "block") {
			divs.style.display = "none";
		}
	}
}

function closeLayer() {
	document.getElementById("FmlySt").style.display = "none";
}

//인증서 크게보기
function displayImage(picName, windowName, windowWidth, windowHeight){
	var winHandle = window.open("" ,windowName,"toolbar=no,scrollbars=no,resizable=no,width=" + windowWidth + ",height=" + windowHeight)

	if(winHandle != null){
		var htmlString = "<html><head><title>Fin Tube Tek. Co., Ltd.<\/title><\/head>"
		htmlString += "<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>"
		htmlString += "<a href='#' onclick='window.close();return false;'><img src=" + picName + " border='0' alt='인증서 큰 이미지' \/><\/a>"
		htmlString += "<\/body><\/html>"
		winHandle.document.open()
		winHandle.document.write(htmlString)
		winHandle.document.close()
		}
	if(winHandle != null) winHandle.focus()
	return winHandle
}
//-->

