/****************************************************************************************
Program Name ek.js
		 2007. 12.
		 Han Min-A
*****************************************************************************************/

/*-----------------------------------------------------------------------------
	common variable
-----------------------------------------------------------------------------*/
var COLOR_CASE01 = "#DC1433";	 //red
var COLOR_CASE02 = "#0D9D4D";	 //green
var COLOR_CASE03 = "#F99D1C";	 //yellow
var COLOR_CASE04 = "#005BAB";	 //blue
var COLOR_CASE00 = "#666666";

var subName; 
var chFont;

DD_belatedPNG.fix('#content_top');
DD_belatedPNG.fix('#content_center');
DD_belatedPNG.fix('#content_bottom');
DD_belatedPNG.fix('#subContent_top');
DD_belatedPNG.fix('#subContent_bottom')
DD_belatedPNG.fix('#subContent_bg');

tabOver = function() {
var mainLogo = document.getElementById("mainlogo");
mainLogo.onclick = setLinkPath;
var topmenu = document.getElementById('mainTabMenu').getElementsByTagName('li')[0];
	while(topmenu != null){
		topmenu.onmouseover = function() {
   			this.className += ' menuOver'+this.className.substring(4,6)+' over';
 		};
		
  		topmenu.onmouseout = function() {
   			this.className = this.className.replace(new RegExp(' menuOver0\\d over\\b'), '');
  		};
		 topmenu = topmenu.nextSibling;
		 while(topmenu != null && topmenu.nodeType != 1){
		 	topmenu = topmenu.nextSibling;
		 }
	}
	if(document.getElementById("submenu") !=null){
		var submenu = document.getElementById("submenu") .getElementsByTagName("div");

		for(var i= 0;i<(submenu.length-2);i++){
			submenu[i+1].onmouseover = function(){
				this.className += " "+this.className+"Over";
			}
			submenu[i+1].onmouseout = function(){
				if(this.className.indexOf("Over") > 0 ){
					this.className = this.className.split(" ")[0];
				}
			}
		}	
	}
	
};
/*-----------------------------------------------------------------------------
	Rollover
-----------------------------------------------------------------------------*/

function showSubMain(id){
	var obj = document.getElementById(id);
	if(obj.style.display =="none"){
		obj.style.display="block";	
	}else{
		obj.style.display="none";
	}
}

//index main flash
function main_swf()
{
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="376" height="321">');
	document.writeln('<param name="movie" value="'+getContextPath()+'/images/main/visual.swf">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<embed src="'+getContextPath()+'/image/main/visual.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="376" height="321"></embed>');
	document.writeln('</object>');
}

/*-----------------------------------------------------------------------------
	̹  ִ ҽ
-----------------------------------------------------------------------------*/
function bluring(){		//ũ ׵θ ֱ
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
document.onfocusin=bluring;


/*-----------------------------------------------------------------------------
	POPUP
-----------------------------------------------------------------------------*/
function openLayerPop(str,imgUrl,width,height){
	/**Layer create**/
	var pNode = parent.document;
	var posX = (pNode.body.clientWidth- width)/2;
	var posY = 120+pNode.body.scrollTop;
	var layer = pNode.createElement("div");
	layer.style.width= pNode.body.scrollWidth;
	layer.style.height=pNode.body.scrollHeight+height;
	layer.style.overflow="hidden";
	layer.id = "layerPop";
	//layer.onclick = closePop;
	pNode.body.appendChild(layer);
	
	/**layerTitle create**/
	var title = pNode.createElement("div");
	var closeBox = pNode.createElement("div");
	title.style.width=width+100;
	//title.style.top =pNode.body.scrollHeight-pNode.body.clientHeight;
	title.style.top =pNode.body.scrollTop+80;
	title.style.left = 80;
	title.id = "layerTitle";
	closeBox.id = "closeBox";
	closeBox.onclick = closePop;
	title.appendChild(pNode.createTextNode(str));
	title.appendChild(closeBox);
	pNode.body.appendChild(title);
	
	/**layer Content create**/
	var content = pNode.createElement("div");
	var img = pNode.createElement("img");
	content.style.top = posY;
	content.style.left = 80;
	content.style.width =width+100 ;
	content.style.height = height+100;
	content.id = "layerContent";
	img.src =imgUrl;
	img.width = width;
	img.height = height;
	img.border = 0;
	
	content.appendChild(img);
	pNode.body.appendChild(content);
	
}
function closePop(){
	var pNode = parent.document;
	var layer = pNode.getElementById("layerPop");
	var title = pNode.getElementById("layerTitle");
	var content = pNode.getElementById("layerContent");
	pNode.body.removeChild(layer);
	pNode.body.removeChild(title);
	pNode.body.removeChild(content);
}


function OpenWindow(url,winName,intWidth,intHeight,intScrollbars) {
	window.open(url,winName,"width="+intWidth+",height="+intHeight+",scrollbars="+intScrollbars+",status=no,toolbar=no,directories=no,menubar=no,resizable=no");
}

 /******print***********/
 function printStart(){
 	var printVal = opener.document.getElementById("subContent_panel").innerHTML;
	var printArea = document.getElementById("printContent");
	printArea.innerHTML = printVal;
	window.print();
 }
/*-----------------------------------------------------------------------------
	Topics View function
-----------------------------------------------------------------------------*/
function view_ans(a){
	if(document.getElementById(a).style.display=="block"){
		document.getElementById(a).style.display="none";
	}else if(document.getElementById(a).style.display=="none"){
		document.getElementById(a).style.display="block";
	}
	reSizeFrame();
}


/*-----------------------------------------------------------------------------
	Imase New Window Open
-----------------------------------------------------------------------------*/
var img_view = null;

function win_view(img){
  img_conf1= new Image();
  img_conf1.src=(img);
  view_conf(img);
}

function view_conf(img){
  if((img_conf1.width!=0)&&(img_conf1.height!=0)){
    view_img(img);
  } else {
    funzione="view_conf('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}

function view_img(img){
    if(img_view != null) {
      if(!img_view.closed) { img_view.close(); }
    }
  width=img_conf1.width+20;
  height=img_conf1.height+20;
  str_img="width="+width+",height="+height;
  img_view=window.open(img,"img_open",str_img);
  img_view.focus();
  return;
}

//WindowOpen for׫髤
function openWindow() {
    var win1 = window.open('compliance.htm','newwin1','width=530,height=430,resizable=yes,scrollbars=auto');
}

function getContextPath(){
	var stp = window.location.href.indexOf(window.location.host)+location.host.length;
	var cxPath = window.location.href.substring(0,stp);
	return cxPath;
}

function setLinkPath(url,content){
	var op = parent.document;
	var contentPath = "";
	if(url ==null) url = "";
	if(content == null){
		contentPath = getContextPath()+url;
	}else{
		contentPath = getContextPath()+url+"?"+content;
	}
	if(op != null){
		op.location.href =contentPath;
	}else{
		window.location.href = contentPath;
	}
}
function setSubPath(){
	var frame = document.getElementById("hiddenFrame");
	var srcPath = location.href.split("?");
	if(srcPath[srcPath.length-1].indexOf("=")>0){
		var param = srcPath[srcPath.length-1].split("=");
		frame.src = param[0]+".html#"+param[1];
	}else{
		frame.src = srcPath[srcPath.length-1]+".html";
	}
}

function opnTitle(){
	var srcPath = location.href.split("?");
	if(srcPath[srcPath.length-1].indexOf("#")>0){
		var param = srcPath[srcPath.length-1].split("#");
		var id = "content"+param[1].substring(4,param[1].length);
		if(document.getElementById(id) !=null){
			view_ans(id);
		}
	}	
}

function setDispatchPath(url,content,name){
	var op = parent.document;
	var contentPath = "";
	if(url ==null) url = "";
	if(content == null){
		contentPath = getContextPath()+url;
	}else{
		contentPath = getContextPath()+url+"?"+content;
	}
	if(name != null){
		contentPath +="="+name;
	}
	if(op != null){
		op.location.href =contentPath;
	}else{
		window.location.href = contentPath;
	}
	
}

function reSizeFrame(){
	var frame = parent.document.getElementById("hiddenFrame");
	var frameBody = document.body;
	var min_height = 400;
	if(frameBody.scrollHeight >min_height){
		frame.style.height = frameBody.scrollHeight+(frameBody.offsetHeight-frameBody.clientHeight)+30;
	}else{
		frame.style.height = min_height+30;
	}
	initTabMenu();
}
function initTabMenu(){
	var tabBar = document.getElementById("tabmenuBar");
	if(tabBar == null)return;
	var tabmenu = tabBar.getElementsByTagName("div");
	for(var i = 0;i<tabmenu.length;i++){
		tabmenu[i].onclick = tabClk;
	}
}
function tabClk(){
	var tabmenu = document.getElementById("tabmenuBar").getElementsByTagName("div");
	var panel = document.getElementById("contArea").getElementsByTagName("div")[0];
		for(var i = 0;i<tabmenu.length;i++){
			if(tabmenu[i].className	.indexOf("Over") >0){
				tabmenu[i].className = tabmenu[i].className.replace(new RegExp("Over"),'');	
			}
		}
		while(panel != null){
			if(panel.className.indexOf("Opn")>0 ){
				panel.className = panel.className.replace(new RegExp("Opn"),'');
			}
			 panel = panel.nextSibling;
			 while(panel != null && panel.nodeType != 1){
		 		panel = panel.nextSibling;
			 }	
		}
	this.className = this.className+"Over";
	document.getElementById(this.pane).className = document.getElementById(this.pane).className+"Opn";
	
	var frame = parent.document.getElementById("hiddenFrame");
	var frameBody = document.body;
	var min_height = 400;
	if(frameBody.scrollHeight >min_height){
		frame.style.height = frameBody.scrollHeight+(frameBody.offsetHeight-frameBody.clientHeight)+30;
	}else{
		frame.style.height = min_height+30;
	}
	
}

function downloadFile(fileName){
	if(fileName =="" || fileName == null)return false;
	window.location.href = getContextPath()+"/Download/"+fileName;
}

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 substrTitle(str){
	var returnVal = str;
	var byte = 0;
	for(var i = 0;i<str.length;i++){
		var temp = escape(str.charAt(i)).length;
		if(temp >3){
			byte +=2;
		}else{
			byte+=1;
		}
		if(byte >= 35){
			returnVal = str.substr(0,i)+"...";
			break;
		}		
	}
	return returnVal;
}
/* FAQ function (Q&A) ------------------------------------------------------------------------------*/
var before1 = "";
var before2 = "";
function test(uid,gid){
	view1 = eval("view"+uid);
	view2 = eval("view"+uid+"2");
	if(view1.style.display == "none"){
		if(before1){
			before1.style.display = "none";
			before2.style.display = "none";
		}
		view1.style.display = "";
		view2.style.display = "";
		before1 = view1;
		before2 = view2;
	}else{
		view1.style.display = "none";
		view2.style.display = "none";
		before1 = "";
	    before2 = "";
	}
}
/*--------------------------------------------------------------------------------------------------*/

/* Imase New Window Open (Popup)--------------------------------------------------------------------*/

function imageView_Popup(image, width, height, center){
  var newWidth = 0;
  var newHeight = 0;
  var scroollbars = "NO";

  //Screen Size ߂Ēw
  var scWidth = screen.width - 30;
  var scHeight = screen.height - 80;
  var scLeft = parseInt(screen.width / 2) - parseInt(width / 2);
  var scTop = parseInt(screen.height / 2) - parseInt(height / 2);


  //New Winbow̑傫 Screen Size 0ŏ
  if(scTop <= 0) scTop = "0";
  if(scLeft <= 0) scLeft = "0";

  //Image Size Screen L Scroll Bar o
  if(width >= scWidth){
    newWidth = scWidth;
    scLeft = 10;
    scroollbars = "YES";
  }
  else{
    newWidth = width;
    scroollbars = "NO";
  }

  //Image Size Screen 荂 Scroll Bar o
  if(height >= scHeight){
    newHeight = scHeight;
    scTop = 10;
	
	//L̂ Scroll BarȂ, Lӂ₵Ă    
    if(scroollbars == "NO") {
      newWidth += 16;
      scLeft -= 8;
    }
    scroollbars = "YES";
  }
  else{
    newHeight = height;
    
	//L̂ Scroll Bar, ӂ₵Ă.    
    if(scroollbars == "YES") {
      newHeight += 16;
      scTop -= 8;
    }
    scroollbars = "NO";
  }

  //Ȃli?ĂƂ󔒏  
  if(center == 1){
    scTop = ",top=" + scTop;
    scLeft = ",left=" + scLeft;
  }
  else{
    scTop = "";
    scLeft = "";
  }

  var popUp = window.open("", "", "width="+newWidth+",height="+newHeight+ scTop + scLeft + "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+scroollbars+",resizable=no");
  popUp.document.open();  
  popUp.document.writeln("<html>")
  popUp.document.writeln("<head><title>Image View</title></head>")
  popUp.document.writeln("<body topmargin='0' leftmargin='0'>");
  popUp.document.writeln("<a onclick=\"window.close();\" style=\"cursor:Hand;\" title=\"\">");
  popUp.document.writeln("<img src='" + image + "' height='" + height + "' width='" + width + "' border='0'></a>");
  popUp.document.writeln("</body></html>");
  popUp.document.close();
}
/*--------------------------------------------------------------------------------------------------*/



/* New Window Open ---------------------------------------------------------------------------------*/
//WindowOpen for Map
function openAnswer() {
    window.open("../main/map.htm","map_pop","width=695,height=590,scrollbars=yes,status=no,toolbar=no,directories=no,menubar=no,resizable=no,top=100,left=100");
}

//WindowOpen forRvCAX
function openWin() {
    var win1 = window.open('../compliance.htm','newwin1','width=530,height=430,scrollbars=auto,resizable=yes');
}

//WindowOpen for ̗v
function openWin2() {
	window.open("../recruit/employ2.htm","mail_pop","width=540,height=500,scrollbars=yes,status=no,toolbar=no,directories=no,menubar=no,resizable=no");
}

//WindowOpen for ptbg
function openPamphlet() {
    window.open("../ebs/pamphlet.htm","pam_pop",'top=0,left=0,width='+(screen.availWidth-10)+',height='+(screen.availHeight-58)+',fullscreen=yes,toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrolling=0');
}

function openerWin(href,wi,he){
	window.open(href,'','width='+ wi +',height='+ he +',menubar=no,scrollbars=yes, resizable=no');
}
/*--------------------------------------------------------------------------------------------------*/
