﻿// JavaScript Document

// For png24
	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='images/common/blank.gif';
	return '';
    }

//FAQ toggle
function initToggle(tabContainer) {
	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).onclick = function () {
			if (tabContainer.current == this) {
				this.targetEl.style.display = "none";
				if( this.parentNode.tagName.toLowerCase() == "dd"){
					this.className="off trigger";
				}else{
					this.className="off";
				}

				tabContainer.current = null;
			} else {
				if (tabContainer.current) {
					tabContainer.current.targetEl.style.display = "none";

					if(tabContainer.current.parentNode.tagName.toLowerCase() == "dd"){
						tabContainer.current.className="off trigger";
					}else{
						tabContainer.current.className="off";
					}

					
				}
				this.targetEl.style.display = "block";
				this.className="on";
				tabContainer.current = this;
			}
			return false;
		}
	}
}



// Quick link
	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 300; 
			} 
		} 
 
		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) 
	} 
	
	
//인쇄창을 띄운다.
function varitext(text){
text=document 
window.print(text)
} 

/* Tab Content */
function initTabMenu(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.onmouseover = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return;

			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", "");
				}
			}

			this.targetEl.style.display = "block";
			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.onmouseover();
}


/* Tab Content */
function initTabOver(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.onmouseover = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace(".jpg", ".jpg");
				} else {
					currentmenu.className = currentmenu.className.replace("on", "");
				}
			}

			this.targetEl.style.display = "block";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace(".jpg", ".jpg");
			} else {
				this.className += " on";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onmouseover();
}

//레이어
 function layerShow(layerId) {
  document.getElementById(layerId).style.display = "block";
 }
 function layerHide(layerId) {
  document.getElementById(layerId).style.display = "none";
 }

//온오프 이미지
function menuOn(imgEl) {
	imgEl.src = imgEl.src.replace("_off.jpg", "_on.jpg");
}
function menuOut(imgEl) {
	imgEl.src = imgEl.src.replace("_on.jpg", "_off.jpg");
}

// 개발관련 스크립트 추가
//프린트
function pagePrint(Obj) { 
    
    
    var printid = Obj.id;

 window.open("http://www.smotor.com/printPop.jsp?printid="+printid,"printpop","width=785, height=500, scrollbars=yes, menubar=no, toolbar=no");   
    
}
//메일발송
function mailsend()
{
 var urlX=document.location.href;
 var urlTitle = document.title;
 window.open("http://www.smotor.com/mailSend.jsp?title="+urlTitle+"&url="+urlX,"mailsend","width=500, height=410, scrollbars=no, menubar=no, toolbar=no");
 
}

//스크랩하기
function clip() {
var url=document.location.href;
window.clipboardData.setData("Text", url);
alert("URL이 복사되었습니다. CTRL+V하시면 URL이 입력됩니다");
}

//역사관 팝업
function pop() {
		window.open ("/kr/company/center/history/index.html","pop","width=1220,height=800,history=no,resizable=no,status=no,scrollbars=yes,menubar=no")
	}

