/* Common js 함수 ################################################################################*/
/* 팝업 */
/* 
	mypage : 팝업URL myname: 팝업이름
	w:가로길이, h:세로길이 scroll: 스크롤여부
*/
function WinPopup(mypage,myname, w, h,scroll) { //v2.0

	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;

	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',resizable=0,status=0,scrollbars='+scroll+'';
	popWin = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) {
		//popWin.window.focus();
	}
}
/* 팝업 사이즈 조절 */
/* 
	width:가로길이, height:세로길이 
*/
function popupsize(width,height)
{
	var divEl = document.createElement("div");
	divEl.style.position = "absolute";
	divEl.style.left = "0px";
	divEl.style.top = "0px";
	divEl.style.width = "100%";
	divEl.style.height = "100%";
	document.body.appendChild(divEl);
	window.resizeBy(width-divEl.offsetWidth, height-divEl.offsetHeight);
	document.body.removeChild(divEl);
}
/* Common js 함수 ################################################################################*/
// 레이어 open 
/*
item : item id 
*/
function divopen(item) {
	obj=document.getElementById(item);
	obj.style.display="";
}
// 레이어 close
/*
item : item id 
*/
function divclose(item) {
	obj=document.getElementById(item);
	obj.style.display="none";
}
function divopenclose(item,item1) {
	obj=document.getElementById(item);
	obj.style.display="";
	obj1=document.getElementById(item1);
	obj1.style.display="none";
}
function divopenclose1(num,tot) {
	
	for (i=1;i<tot+1;i++){
		var item ="item"+i		
		obj = document.getElementById(item);
		if (num==i)
		{
			obj.style.display="";
		}else{
			obj.style.display="none";
		}
	} 
}

//레이어 관련 스크립트 시작---------------------------------------------------------
			function layerShow(layerId) {
				document.getElementById(eval(layerId)).style.display = "block";
			 
			}

			function layerHide(layerId) {
				document.getElementById(eval(layerId)).style.display = "none";
			}

			function flash_quick_resize(w,h,x) {
				var gndDown_flashEl = document.getElementById("apDiv");	
				gndDown_flashoj = gndDown_flashEl.getElementsByTagName("object");
				gndDown_flashEl.style.left = x +"px";
				gndDown_flashEl.style.width = w +"px";
				gndDown_flashEl.style.height = h +"px";
				gndDown_flashoj[0].style.width = w +"px";
				gndDown_flashoj[0].style.height = h +"px";
			}

/*좌측 탑버튼*/
/*flashLeftDiv start*/
var stmnLEFT = 0; // 왼쪽 여백
var stmnGAP1 = 270; // left메뉴 위쪽 여백
var stmnGAP3 = 157; // top버튼 위쪽 여백
var stmnGAP2 = 0; // 스크롤시 브라우저 위쪽과 떨어지는 거리
var stmnBASE = 50// 스크롤 시작위치
var stmnActivateSpeed = 10;
var stmnScrollSpeed = 10;
function RefreshStaticMenu1() {
	try {
		var stmnStartPoint1, stmnStartPoint2, stmnEndPoint1, stmnEndPoint2, stmnEndPoint3, stmnRefreshTimer;
		stmnStartPoint2 = parseInt(document.getElementById('apDiv').style.top, 10);
		stmnEndPoint2 = document.body.scrollTop + stmnGAP2;
		//화면 넘어 가는 부분 endpoint
		if (stmnEndPoint2 < stmnGAP3) stmnEndPoint2 = stmnGAP3;
		stmnRefreshTimer = stmnActivateSpeed;
		 
		if ( stmnStartPoint2 != stmnEndPoint2 ) {
			stmnScrollAmount = Math.ceil( Math.abs( stmnEndPoint2 - stmnStartPoint2 ) / 15 );
			document.getElementById('apDiv').style.top = parseInt(document.getElementById('apDiv').style.top, 10) + ( ( stmnEndPoint2<stmnStartPoint2 ) ? -stmnScrollAmount : stmnScrollAmount );
			stmnRefreshTimer = stmnScrollSpeed;
		}
		 
	} catch (e) {
	}
	setTimeout ("RefreshStaticMenu1();", stmnRefreshTimer);
}
function InitializeStaticMenu(){
	document.getElementById('apDiv').style.top = document.body.scrollTop + stmnBASE;
	RefreshStaticMenu1();
}
/*좌측 메뉴 높이 계산*/
function windowResizeHandler() {
	/*alert("스크립트 체크")
	var leftHeight = document.getElementById('flashLeftDiv').clientHeight + stmnGAP1;
	var contHeight = document.getElementById('maeilContents').clientHeight + 141;
	if(leftHeight>contHeight) document.getElementById('maeilContents').style.height = leftHeight - 141;
	var conHeight = document.getElementById('maeilSite').clientHeight;
	var scrollHeight = document.body.scrollTop;
	var screenHeight = document.body.clientHeight;
	var banconHeight = conHeight / 2;
	if(document.getElementById('maeilContents').clientHeight < 680)
	{
		document.getElementById('maeilContents').style.height = 680;
		document.getElementById('flashLeftDiv').style.height = 680;
		document.getElementById('flashImgDiv').style.height = 680;
	}
	document.getElementById('flashLine').style.height = banconHeight;
	document.getElementById('flashLine').style.marginTop = banconHeight - 300;
	if(screenHeight + scrollHeight > conHeight)
	{
		return false;
	}
	else
	{
		document.getElementById('flashLeftDiv').style.height = document.body.clientHeight - 55;
		document.getElementById('flashImgDiv').style.height = document.getElementById('maeilContents').clientHeight + 350;
		document.getElementById('flashLine').style.height = document.getElementById('maeilSite').clientHeight / 2;
		document.getElementById('flashLine').style.marginTop = document.getElementById('maeilSite').clientHeight / 2 - 300;
	}*/
}

// 이미지 새창
function cnj_win_view(img){
img_conf1= new Image();
img_conf1.src=(img);
cnj_view_conf(img);
}

function cnj_view_conf(img){
if((img_conf1.width!=0)&&(img_conf1.height!=0)){
cnj_view_img(img);
} else{
funzione="cnj_view_conf('"+img+"')";
intervallo=setTimeout(funzione,20);
}
}

var cnj_img_view = null;
function cnj_view_img(img){
if(cnj_img_view != null) {
if(!cnj_img_view.closed) { 
cnj_img_view.close(); 
}
}
cnj_width=img_conf1.width+140;
cnj_height=img_conf1.height+116;
str_img="width="+cnj_width+",height="+cnj_height;

cnj_img_view=window.open("about:blank","",str_img);
cnj_img_view.document.open(); // document.open() 
cnj_img_view.document.writeln("<html>");
cnj_img_view.document.writeln("<head>");
cnj_img_view.document.writeln("<title>SsangYong E&amp;C</title>");
cnj_img_view.document.writeln("<meta http-equiv='content-type' content='text/html; charset=euc-kr'>");
cnj_img_view.document.writeln("<meta http-equiv='imagetoolbar' content='no'>");
cnj_img_view.document.writeln("</head>");
cnj_img_view.document.writeln("<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0' style='overflow:auto;' scroll='auto'>");
cnj_img_view.document.writeln("<table width='100%' border='0' cellpadding='0' cellspacing='0' background='/media/images/kor/common/popup_bg.gif'><tr>");
cnj_img_view.document.writeln("<td><img src='/media/images/kor/press_room/popup_tit_pr3.gif'></td>");
cnj_img_view.document.writeln("<td align='right'><img src='/media/images/kor/common/popup_logo.gif'></td>");
cnj_img_view.document.writeln("</tr></table>");
cnj_img_view.document.writeln("<table width='100%' border='0' cellpadding='20' cellspacing='0'><tr><td>");
cnj_img_view.document.writeln("<center><img src="+ img +" border=0></center>") // 소스 테스트 부분
cnj_img_view.document.writeln("</td></tr></table>");
cnj_img_view.document.writeln("<table width='100%' border='0' cellpadding='0' cellspacing='0'><tr>");
cnj_img_view.document.writeln("<td align='right' height='22' bgcolor='#e82c4a' style='padding:0 5;'><img src='/media/images/kor/common/btn_close.gif' onclick='self.close();' border=0 style='cursor:hand'></td>");
cnj_img_view.document.writeln("</tr></table>");
cnj_img_view.document.writeln("</body></html>");
cnj_img_view.document.close(); // 반드시 document.close() 닫아주어야 함
cnj_img_view.focus();
return;
}

function goEBookUrl(str) {
	var wWidth = screen.width - 10 ;
	var wHeight = screen.height - 10;
	var noticeWindow  =  window.open(str,'ebook','resizable=yes, menubar=no,status=no,toolbar=no,location=no,scrollbar=no, top=0, left=0, width=' + wWidth + ',height=' + wHeight );

       if(noticeWindow != null)
       {
          noticeWindow.focus();
          noticeWindow.opener = self;
       }

}


function ebookPop(url) {
	window.open(url,'ebook','resizable=yes, menubar=no,status=no,toolbar=no,location=no,scrollbar=no, top=0, left=0, width=1030,height=745');
}