function getCookie(varname)
{
	varname += "=";
	startpos	= document.cookie.indexOf(varname);

	if( startpos >= 0 )
	{
		startpos += varname.length;
		endpos    = document.cookie.indexOf(";", startpos);

		if( endpos == -1 )
			endpos = document.cookie.length;

		return unescape(document.cookie.substring(startpos, endpos));
	}
}

function setCookie( name, value, expiredays )
{
	var todayDate = new Date();
		todayDate.setDate( todayDate.getDate() + expiredays );

	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + "; domain=.hankyung.com;"
}

function deleteCookie( name, domain )
{
	var todayDate = new Date();

	document.cookie = name + "=1; path=/; expires=" + todayDate.toGMTString() + "; domain=" + domain + ";"
}


/* ·¹ÀÌ¾î ÄÜÆ®·Ñ */
function LayerControl(name, id)
{
	var allLayer = getElementsByName_iefix('div', name);

	var len = allLayer.length;

	for(i=0; i<len; i++)
	{
		if (allLayer[i].id == id)
			document.getElementById(allLayer[i].id).style.display = '';
		else
			document.getElementById(allLayer[i].id).style.display = 'none';
	}
}
function getElementsByName_iefix(tag, name) {

	var elem = document.getElementsByTagName(tag);
	var arr = new Array();

	for(i = 0,iarr = 0; i < elem.length; i++)
	{
		att = elem[i].getAttribute("name");
		if(att == name)
		{
			arr[iarr] = elem[i];
			iarr++;
		}
	}
	return arr;
}
/* ·¹ÀÌ¾î ÄÜÆ®·Ñ */
function sbar (st,col) { st.style.backgroundColor = '#' + col; }
function cbar (st) { st.style.backgroundColor = ''; }


function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function MM_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_nbGroup(event, grpName) {
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    if ((nbArr = document[grpName]) != null)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = args[i+1];
      nbArr[nbArr.length] = img;
  } }
}
function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}


function MM_reloadPage(init) {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);


function switchlayer(layer_id, total_no, show_no) {
  for(i=1; i<=total_no; i++) {
    var lid = layer_id + i;
    var f = document.getElementById(lid);
	if (i == show_no) {document.getElementById(lid).style.visibility = 'visible';}
	else {document.getElementById(lid).style.visibility = 'hidden';}
  }
}


function popWin(url,winname,wwidth,wheight, scrollbar, resizable) {
	var conWidth = wwidth; conHeight = wheight;

	if(wwidth == null && wheight == null) {
		conWidth = 100;
		wHeight = 150;
	}
	conWidth = (screen.Width) / 2 - conWidth;
	conHeight = (screen.Height) / 2 - conHeight;
	focusWin= window.open(url,winname,'left=20' + ',top=20' + ',width=' + wwidth + ',height=' + wheight + ',scrollbars=' + scrollbar + ',resizable=' + resizable);
	focusWin.focus();
}

function tfOpen(){
	popWin('http://efwts4.truefriend.com/jsp/WTSLoad.jsp','efriend','430','200');
}

var win = "";
function jwopen(htm, ht, wd,sc,rs)
{
    if ((win == 0) || win.closed) {
    	win=window.open(htm,'searchWin','height='+ht+',width='+wd+',scrollbars='+sc+',resizable='+rs+',left=0,top=0,screenX=500,screenY=500');
    }
    var w = win;
    win.focus();
}
function HKCommonPay(prodid, itemorpackage, cpitemid, returnurl, paytool) {
	if( prodid == '' ) {
		var tmp ='http://clubmall.hankyung.com/members/mem_login.php?url=';
		tmp+= top.location;
		location.href=tmp;
		return;
	}
	if( paytool == "" ) {
		paytool = "card";
	}

    var paywin = window.open("","directpay","width=500,height=550,status=NO,resizable=no,top=200,left=200,alwaysRaised=yes,scrollbars=NO,titlebar=no");
    var payurl = "http://cash.hankyung.com/buy/buy_main.php?cpid=1&itemcnt=1";
	payurl += "&cpitemid=" + cpitemid;
    payurl += "&prodid=" + prodid;
    payurl += "&itemorpackage=" + itemorpackage;
    payurl += "&returnurl=" + returnurl;
    payurl += "&paytool=" + paytool;
    paywin.location.href = payurl;
}

function HKCommonPayUrl(prodid, itemorpackage, cpitemid, returnurl, paytool) {
	if( prodid == '' ) {
		var tmp ='http://clubmall.hankyung.com/members/mem_login.php?url=';
		tmp+= top.location;
		location.href=tmp;
		return;
	}
	if( paytool == "" ) {
		paytool = "card";
	}

    var payurl = "http://cash.hankyung.com/main/mem_pay_check_member.php?cpid=1&itemcnt=1";
    payurl += "&prodid=" + prodid;
    payurl += "&itemorpackage=" + itemorpackage;
    payurl += "&returnurl=" + returnurl;
    payurl += "&paytool=" + paytool;
    location.href = payurl;
}




try {

	var NU_rl = 'http://'+'gather.hankyung.com:8003';
	var NCHKIMG = new Image();
	var NL_bn=navigator.appName;
	if( NL_bn.indexOf("Netscape") > -1 || NL_bn=="Mozilla"){
	setTimeout("NCHKIMG.src = NU_rl+'/?cookie';",1); } else{ NCHKIMG.src = NU_rl+'/?cookie'; };

	document.writeln("<scr"+"ipt language='javascript' src='http://www.hankyung.com/js/acecounter/ebizcode_1.js'></scr"+"ipt>");
	document.writeln("<scr"+"ipt language='javascript1.1' id='_NL_hdc'> NL_sv=11 ; </scr"+"ipt>");
	document.writeln("<scr"+"ipt language='javascript1.1' src='http://www.hankyung.com/js/acecounter/ebizcode_2.js'></scr"+"ipt>");
	document.writeln("<scr"+"ipt language='javascript' src='http://www.hankyung.com/js/acecounter/ebizcode_3.js'></scr"+"ipt>");

} catch(e) {
}



function contents_cp()
{
	if (window.event)
	{
		window.event.returnValue = true;
		window.setTimeout('attach_kinref()', 25);
	}
}
function attach_kinref()
{
	if (window.clipboardData)
	{
		var txt = window.clipboardData.getData('Text');

		txt = txt + '\r\n\r\n¨Ï ÇÑ°æ´åÄÄ, ¹«´Ü ÀüÀç ¹× Àç¹èÆ÷ ±ÝÁö\r\n<ÇÑ±¹¿Â¶óÀÎ½Å¹®ÇùÈ¸ÀÇ µðÁöÅÐ´º½ºÀÌ¿ë±ÔÄ¢¿¡ µû¸¥ ÀúÀÛ±ÇÀ» Çà»çÇÕ´Ï´Ù>\r\n\r\n';

		var result = window.clipboardData.setData('Text', txt);
	}
}


/**
 * ÀÛ¼ºÀÚ : ÃÖ¿µ¹Î
 * ÀÛ¼ºÀÏ : 2008.04.28
 * ¼³  ¸í : °Ô½ÃÆÇ ºäÆäÀÌÁö ÀÌ¹ÌÁö ¸®»çÀÌÁî
*/
function HKbbsImgResize(limitWidth)
{
	var imgWidth = 0;
	var imgTable = document.getElementById('bbsImage');

	var userid   = getCookie('UserId');
	if( typeof(imgTable) == "object" && limitWidth )
	{
		var obj = imgTable.getElementsByTagName('img');
		var cnt = obj.length;

		if(!cnt)
			return;

		for(i=0;i<cnt;i++)
		{
			if( obj[i].width > limitWidth ){
				obj[i].style.width = limitWidth;
				continue;
			}

			var newImg   = new Image();
			newImg.src = String(obj[i].getAttribute('src'));
			imgWidth = newImg.width;

			if ( imgWidth > limitWidth ){
				obj[i].style.width = limitWidth;
				newImg = null;
				continue;
			}
			newImg = null;
		}
	}
}

function bluring()
{
    if( event.srcElement.tagName=="A" || event.srcElement.tagName=="IMG" || event.srcElement.tagName=="a" || event.srcElement.tagName=="img")
    	document.body.focus();
}
document.onfocusin=bluring;

/* ¼Óº¸Ã¢ ·Ñ¸µ ½ÃÀÛ */
function RotateLayer(classname, data)
{
	this.list        = data;
	this.classname   = classname;
	this.speed       = 1;
	this.wait        = 2500;
	this.height      = 22;
	this.amount      = 0;
	this.temp        = 0;
	this.count       = this.list.length;
	this.mouseover   = false;
	this.rotateLayers;
}
RotateLayer.prototype =
{
	Scroll : function()
	{
		if( this.mouseover == false )
		{
			this.rotateLayers[0].style.top = parseInt(this.rotateLayers[0].style.top,10) - this.speed + "px";
			this.rotateLayers[1].style.top = parseInt(this.rotateLayers[1].style.top,10) - this.speed + "px";
			if( this.rotateLayers[0].style.top == ( ( -1 * this.height ) + 1 ) + "px" )
			{
				this.SetNews();
				return;
			}
		}
		window.setTimeout(this.classname + ".Scroll()",1);
	} ,
	SetNews : function()
	{
		var news0, news1;
		var index0, index1;
		index0 = ( this.amount % this.count );
		index1 = ( ( this.amount + 1 ) % this.count );
		news0 = this.list[index0].replace(/&#39;/gi, "'");
		news1 = this.list[index1].replace(/&#39;/gi, "'");
		this.rotateLayers[0].innerHTML = news0;
		this.rotateLayers[1].innerHTML = news1;
		this.rotateLayers[0].style.top = "2px";
		this.rotateLayers[1].style.top = ( 2 + this.height ) + "px";
		this.amount++;
		window.setTimeout(this.classname + ".Scroll()",this.wait);
	} ,
	Start : function()
	{
		var news0, news1;
		var index0, index1;
		document.write('<ul id="rotate" onMouseover="javascript:' + this.classname + '.MouseControl(true);" onMouseout="javascript:' + this.classname + '.MouseControl(false);">');
		index0 = ( this.amount % this.count );
		index1 = ( ( this.amount + 1 ) % this.count );
		news0 = this.list[index0].replace(/&#39;/gi, "'");
		news1 = this.list[index1].replace(/&#39;/gi, "'");
		document.write('<li style="top:2px">' + news0 + '</li>');
		document.write('<li style="top:' + ( 2 + this.height ) + 'px">' + news1 + '</li>');
		document.write('</ul>');
		this.rotateLayers = document.getElementById('rotate').getElementsByTagName('li');
		this.amount++;
		window.setTimeout(this.classname + ".Scroll()",this.wait);
	} ,
	MouseControl : function(b)
	{
		this.mouseover = b;
	}
}
/* ¼Óº¸Ã¢ ·Ñ¸µ ³¡ */

function getGetValue(getName){
	var regx = eval("/[?|&]+"+getName+"=([^&]*|.*$)/");
	var url=location.href;
	if (regx.test(url)){
		var resultArray = regx.exec(url);
		return resultArray[1];
	}
	return "";
}
/* ÆÄºñÄÜ ³Ö±â ½ÃÀÛ */
document.write('<link rel="shortcut icon" href="/img/ico/favicon.ico">');
/* ÆÄºñÄÜ ³Ö±â ³¡ */


/**
 * ÀÛ¼ºÀÚ : ±èÁÖ¿¬ 2010 Åð»ç
 * ÀÛ¼ºÀÏ : 2010.05.11
 * ¼³  ¸í : 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 ShowSlide(url)
{
	location.href = 'http://image.hankyung.com';
	/* Æ÷Åä°³ÆíÀ¸·Î ÆË¾÷ »çÀÌÁî º¯°æ - 2011.06.30 dream25 */
	window.open(url, 'slide', 'width=1041,height=895,status=yes,scrollbars=yes');
//	window.open(url, 'slide', 'width=1024,height=790,status=yes')
;


}
/*
 * ÇÑ°æ¸ÞÀÎ ÁÂÃøÁß°£ Æ÷ÅäºÎºÐ - ÇöÀç ¸ÞÀÎ¿¡¼­¸¸ »ç¿ë
 * ÇÑ°æ¸ÞÀÎ Æ÷ÅäÆË¾÷ classº¯°æ
 */
function photoSwitch(n)
{
	if(!n) n = 1;
	for(var i=1;i<=5;i++){
		//document.getElementById('photobox0' + i ).className="photobox_alpha05";
		//document.getElementById('photobox0' + n ).className = '';
		document.getElementById('photobox_text0' + i).className='noview';
		document.getElementById('photobox_text0' + n).className='';

	}
}
/**
*
*URLÀÇ get°ªÀ» °¡Á®¿À´Â function
* 2010-12-20 ÀÓ¼º¹¬
*/
function getGetValue(getName){
	var regx = eval("/[?|&]+"+getName+"=([^&|#]*|.*$)/");
	var url=location.href;
	if (regx.test(url)){
		var resultArray = regx.exec(url);
		return resultArray[1];
	}
	return "";
}


/**
*
*IFRAMEÀÇ ³ÐÀÌ¿Í ³ôÀÌ¸¦ ÀÚµ¿À¸·Î °¡Á®¿Í¼­ ¼ÂÆÃ
* 2011-09-06 Çö»óÀº
* »ç¿ë¹ý : <IFRAME src="xxx.html" name="iframe1" onLoad="javascript:ResizeFrame('iframe1');" WIDTH="560" height="100%" NORESIZE SCROLLING="no" FRAMEBORDER="0" MARGINHEIGHT="0" MARGINWIDTH="0"></IFRAME>
*/
function ResizeFrame(name)
{  
	// IFRAME ³»ºÎÀÇ body °³Ã¼  
	var fBody  = document.frames(name).document.body;  
	// IFRAME °³Ã¼  
	var fName  = document.getElementById(name);
	
	// IFRAME ³»ºÎÀÇ body°³Ã¼ÀÇ ³ÐÀÌ¸¦ °è»êÇÏ¿© IFRAMEÀÇ ³ÐÀÌ¸¦ ¼³Á¤ÇØ ÁØ´Ù.  
	fName.style.width     = fBody.scrollWidth + (fBody.offsetWidth - fBody.clientWidth);  
	// IFRAME ³»ºÎÀÇ body°³Ã¼ÀÇ ³ôÀÌ¸¦ °è»êÇÏ¿© IFRAMEÀÇ ³ôÀÌ¸¦ ¼³Á¤ÇØ ÁØ´Ù.  
	fName.style.height     = fBody.scrollHeight + (fBody.offsetHeight - fBody.clientHeight);  

	// ¸¸¾à IFRAMEÀÇ Å©±â ¼³Á¤¿¡ ½ÇÆÐ ÇÏ¿´´Ù¸é ±âº»Å©±â·Î ¼³Á¤ÇÑ´Ù.  
	if (fName.style.height == "0px" || fName.style.width == "0px")  
	{    
		fName.style.width = "560px";     
		//±âº» iframe ³Êºñ    
		fName.style.height = "800px";    
		//±âº» iframe ³ôÀÌ  
	}
}


/** 
* ´º½ºÆú °ü·Ã script
* 2011-10-10 ÀÓ¼º¹¬
*/
function polling(pid){
	var val = $(":input:radio[name=poll_"+pid+"]:checked").val();
	if(val==undefined || val==''){
		alert('Ç×¸ñÀ» ¼±ÅÃÇØÁÖ¼¼¿ä');
	}else{
		openWindow("http://www.hankyung.com/poll/polling.php?pid="+pid+"&val="+val,350,185);
	}
}

function resultPoll(pid){
	openWindow("http://www.hankyung.com/poll/resultPoll.php?pid="+pid,350,185);
}

function openWindow(url,w,h){
	x=(screen.width/2 - w/2);
	y=(screen.height/2 - h/2) - 50;

	window.open(url,'110725','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',height='+h+',left='+x+',top='+y);
}
