// flickerÇö»ó ¾ø¾Ö±â
function flicker() {
	try {
		document.execCommand('BackgroundImageCache', false, true);
	} catch(e) {}
}
addLoadEvent(flicker)


// ie6¿¡¼­ png ¹ÝÅõ¸í Ã³¸® ½ºÅ©¸³Æ®
// ½ºÅ¸ÀÏ ½ÃÆ® .png24 {tmp:expression(setPng24(this));} ¿Í °°ÀÌ »ç¿ë
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='/resource/img/public/common/blank.gif'; // 1*1ÇÈ¼¿ÀÇ Åõ¸íÇÑ blank.gif ÀÌ¹ÌÁö°¡ ¹Ýµå½Ã Á¸ÀçÇØ¾ß ÇÑ´Ù.
	return ''; 
}


// addLoadEvent
function addLoadEvent(func) {
	var oldonload=window.onload;
	if(typeof window.onload!='function') {
		window.onload=func;
		} else {
		window.onload=function() {
			oldonload();
			func();
		}
	}
}


// getElementsByClassName
function getElementsByClassName(clsName,parentNode) {
	var arr = new Array();
	if (parentNode == null) {
		var elems = document.getElementsByTagName("*");
	} else {
		var elems = parentNode.getElementsByTagName("*");
	}
	for ( var cls, i = 0; ( elem = elems[i] ); i++ ) {
		if ( elem.className == clsName ) {
			arr[arr.length] = elem;
		}
	}
	return arr;
}


// ¿ä¼ÒÀÇ µÚ¿¡ »õ·Î¿î ¿ä¼Ò¸¦ Ãß°¡
function insertAfter(newElement,targetElement) {
	var parent = targetElement.parentNode;
	if(parent.lastChild==targetElement) {
		parent.appendChild(newElement);
	} else {
		parent.insertBefore(newElement,targetElement.nextSibling);
	}
}


// Å¬·¡½º ÀüÃ¼¸¦ ¹Ù²ÙÁö¾Ê°í Ãß°¡¸¸ ÇÏ±â
function addClass(element,value) {
	if (!element.className) {
		element.className = value;
	} else {
		newClassName = element.className;
		newClassName+= " ";
		newClassName+= value;
		element.className = newClassName;
	}
}




// ÁÂÃø ¸Þ´º
function fn_setNaviHeight(height){
	document.getElementById("sidebar").style.height = height + "px";
}


// FAQ ¸Þ´º
function tabDisplay(tab,content,num) {
	for (var i=0; i<content.length; i++) {
		content[i].style.display = 'none';
		content[num].style.display = 'block';
	}
}
function tabAct(tab,content,num) {
	tab[num].onclick = function() {
		tabDisplay(tab,content,num);
	}
}

// ¼¿·ºÆ®¹Ú½º ¸µÅ©
function selectLink(arg,target) {
	if (target == "blank") {
		window.open(arg); // »õÃ¢ÀÏ¶§
	} else {
		window.location.href = arg; // ÇöÀçÃ¢¿¡
	}
}

// ÆäÀÌÁö ÃÖ¼Ò °¡·Î»çÀÌÁî
function pageResize() {
	if (navigator.userAgent.indexOf("MSIE 6")!=-1) {
		var target = document.getElementById('wrap');
		var swidth = document.body.scrollWidth;
		if (swidth > 966) {
			target.style.width = swidth + "px";
		} else {
			target.style.width = "966px";
		}
	}
}
addLoadEvent(pageResize)



// ÀÌ¹ÌÁö ¹Ì¸®º¸±â
function fileview(arg) {
	var target = document.getElementById('preimg');
	target.setAttribute('src',arg);
}


//Å¬¸¯½Ã °¨ÁàÁ³´ø ³»¿ë ÆîÃÄÁö±â}
function contentView() {
	var sponsorship_table = document.getElementById('sponsorship_table');
	var div_view = sponsorship_table.getElementsByTagName('div');
	for (i = 0; i < div_view.length; i++) {
		div_view[i].onclick = function() {
			for (var j = 0 ; j < div_view.length; j++) {
					div_view[j].className = '';
				}
			this.className = 'open';
		}
	}
}


// ÆË¾÷Ã¢ ¶ç¿ì±â
function popOpen(uri,name,width,height,top,left,option) {
	window.open(uri,name,'width='+width+',height='+height+',top='+top+',left='+left+","+option);
}

// ÆË¾÷Ã¢ ´Ý±â
function popClose() {
	window.close();
}

// ·¹ÀÌ¾î ¿­±â
function layerOpen(arg) {
	var target= document.getElementById(arg);
	target.style.display = 'block';
}


// ·¹ÀÌ¾î ´Ý±â
function layerClose(arg) {
	var target= document.getElementById(arg);
	target.style.display = 'none';
}


// °æ¿µÁø/»ç¿ÜÀÌ»ç ÂÊ¿¡ ¾²ÀÎ ÇÔ¼ö
function viewImgCon(num,page,top) {
	var target = document.getElementById('img_directors');
	target.setAttribute("src","/resource/img/eng/info/txt_"+ page + num + ".gif");
	target.style.paddingTop = top+"px";


	var btn = getElementsByClassName('btn_director');
	for (var i=1; i<=btn.length; i++) {
		var btn_img = btn[i-1].getElementsByTagName('img');
		var len=btn[i-1].getAttribute("href").length;
		var img_idx=btn[i-1].getAttribute("href").substr(len-2);
		img_idx = img_idx.replace(/s/i,'');
		if (img_idx == num) {
			btn_img[0].setAttribute("src","/resource/img/eng/info/img_"+ page + num + "_on.jpg");
		} else {
			btn_img[0].setAttribute("src","/resource/img/eng/info/img_"+ page + img_idx + "_off.jpg");
		}
	}
}
function viewImg(page) {
	var box = document.getElementById('img_directors');

	var btn = getElementsByClassName('btn_director');
	for (var j=0; j<btn.length; j++) {
		btn[j].onmouseover = function() {
			var conid = this.href.split('#directors',2);
			viewImgCon(conid[1],page,this.getAttribute("txtTop"));
			return false;
		} 
	}
}



/* ÀÌ ¹ØÀ¸·Î´Â ÇÃ·¡½Ã °ü·Ã ½ºÅ©¸³Æ®µé */
function view_inno_history() {
	popOpen("/eng/innovationStory.do",'',960,520,0,0,'');
	
}
function webGree() {
	popOpen("http://www.teletogether.com/irlivecasting/hanafn/2011Q3ENG",'',994,684,0,0,'');
}

function webPre() {
	popOpen("http://218.50.55.91:8886/hana/20100211/eng/03/default.htm",'',994,684,0,0,'');
}

function webCard() {
	popOpen("http://218.50.55.91:8886/hana/20100211/eng/05/default.htm",'',994,684,0,0,'');
}

function webQna() {
	popOpen("http://218.50.55.91:8886/hana/20100211/eng/07/default.htm",'',994,684,0,0,'');
}

/* ÇÃ·¡½Ã ¸ÞÀÎÀ¸·Î °¡´Â ½ºÅ©¸³Æ®¶û ¸ÞÀÎ¿¡¼­ ÇÏ³ª¸Ê, °³ÀÎº¸È£Á¤Ã¥ Ã¢ ¶ç¿ì´Â ÇÔ¼ö*/
function goTopUrl(type){
	if(type == 'logo') {
		// alert(type);
		window.location.href = '/eng/main.do';
	}
	else if(type == 'map') {
		// alert(type);
		popOpen("http://hanafn.chzero.com/relative_list.jsp?bizType=2&gb=2&flag=1",'',880,600,0,0,'');
	}
	else if(type == 'private') {
		// alert(type);
		popOpen("/eng/privacyPolicy.do",'',634,462,0,0,'');
	}
}
/* ÇÃ·¡½Ã ¾ð¾î ¼±ÅÃ ½ºÅ©¸³Æ®.
	³ªÁß¿¡ ÆäÀÌÁö »ý±â¸é °¢ ¾ð¾îº° ÁÖ¼Ò·Î ¿¬°á.
*/
function changeLanguage( type ){
	if (type == 'kr') {
		// alert("changeLanguage : " + type);
		window.location.href = '/main.do';
	} else if (type == 'en') {
		// alert("changeLanguage : " + type);
		window.location.href = '/eng/main.do';
	} else {
		// alert("changeLanguage : " + type);
		window.location.href = '/chn/main.do';
	}
}


var num = 1;


// ÄíÅ° ¸¸µé±â
function setCookie(key,value,expire) {
   var cookieDate = new Date();
   cookieDate.setDate(cookieDate.getDate() + parseInt(expire));
   document.cookie = key + "=" + escape(value) + "; espires" + cookieDate.toGMTString() + "; path=/";
}

// ÄíÅ° °ª ¾ò±â
function getCookie(key) {
   var cookie = document.cookie;
   var first = cookie.indexOf(key+"=");
   if (first>=0) {
       var str = cookie.substring(first,cookie.length);
       var last = str.indexOf(";");
       if (last<0) {
           last = str.length;
       }
       str = str.substring(0,last).split("=");
       return unescape(str[1]);
   } else {
       return null;
   }
}

// ÄíÅ° Áö¿ì±â
function delCookie(key) {
   today = new Date();
   today.setDate(today.getDate() - 1);
   document.cookie = key + "=; path=/; expires=" + today.toGMTString() + ";";
}
