﻿/** BOF START */
//alert("com.js");
var subid = [
	"sub1",
	"sub2",
	"sub3",
	"sub4",
	"sub5",
	"sub6",
	"sub7",
	"sub8",
	"sub9",
	"sub10",
	"sub11",
	"sub12",
	"sub13",
	"sub14",
	"sub15",
	"sub16",
	"sub17",
	"sub18",
	"sub19",
	"sub20",
	"sub21",
	"sub22",
	"sub23",
	"sub24",
	"sub25",
	"sub26",
	"sub27",
	"sub28",
	"sub29",
	"sub30",
	"sub31",
	"sub32",
	"sub33",
	"sub34",
	"sub35",
	"sub36",
	"sub37",
	"sub38",
	"sub39",
	"sub40",
	"sub41",
	"sub42",
	"sub43",
	"sub44",
	"sub45",
	"sub46",
	"sub47",
	"sub48",
	"sub49",
	"sub50",
	"sub51"
	
];

var subURL = [
"/news/new.html",
"/news/overall/new.html",
"/news/contract/new.html",
"/news/relation/new.html",
"/news/house/new.html",
"/news/country/new.html",
"/news/world/new.html",
"/news/finance/new.html",
"/news/plan/new.html",
"/news/photo/photo_list.html",
"/news/opinion/new.html",
"/cw/cw_index_Hot.html",
"/purchase/purchase_index_Hot.html",
"/service/service_index_Hot.html",
"/mypage/mypage_index.html",
"/view/interview/people.html",
"/view/gallery/photo.html",
"/view/culture/new.html",
"/view/event/new.html",
"/free/golf/new.html",
"/data/rule_list.html",
"/data/sum_list.html",
"/data/data_list.html",
"/data/contract_list.html",
"/data/stop.html",
"/data/information.html",
"/data/condition.html",
"/issue/talk.html",
"/issue/poll.html",
"/community/board_list.html",
"/community/club.html",
"/community/cafe.html",
"/customer/com_ceo.html",
"/customer/com_history.html",
"/customer/com_ci.html",
"/customer/com_organize.html",
"/customer/com_map.html",
"/customer/com_builders.html",
"/customer/com_newspaper.html",
"/customer/com_adinfo.html",
"/customer/com_publish.html",
"/customer/com_print.html",
"/customer/com_parther.html",
"/customer/com_recruit.html",
"/customer/subscrip.html",
"/customer/subscrip_de.html",
"/customer/subscrip_vac.html",
"/customer/branch.html",
"/customer/notice_list.html",
"/customer/faq.html",
"/customer/email.html"
];
 
 var menuNum = [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
2,
2,
3,
3,
3,
3,
4,
5,
5,
5,
5,
5,
5,
5,
6,
6,
6,
6,
6,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7,
7
];

 
function subGangjo()
{
	var id = "";
	var mNum = 0;
	for(a=0;a<subURL.length;a++){
		if(document.URL.split("co.kr")[1] == subURL[a]){
			id = subid[a]; 
			mNum = menuNum[a];
		}
	}
	//배열이 정확하게 입력되었는 확인
	//alert(subURL.length+":"+subid.length+":"+menuNum.length);
	//alert(mNum);
	var ele = "";
	if(id != "") {
		ele = document.getElementById(id).innerHTML;
		ele = "<b>" + ele +"</b>";
		document.getElementById(id).innerHTML = ele;
	}

	
}

window.onload = function(){
	   subGangjo();
	   roll2();
	   imgResizeList('ResizeImg', 151, 100);
	   
	   
};

function movePaging(pageNum)
{

	if ( document.URL.search(/([\?|&])PAGE=(\d)+/) != -1 ) 
		location.href = document.URL.replace(/([\?|&])PAGE=(\d)+/, '$1PAGE='+pageNum);
	else {
		if ( document.URL.indexOf('?') == -1 )
			location.href = document.URL + '?PAGE=' + pageNum;
		else
			location.href = document.URL + '&PAGE=' + pageNum;
	}
		
}

function view(idx)
{
	if ( document.URL.search(/([\?|&])IDX=(\d)+/) != -1 ) 
		location.href = document.URL.replace(/([\?|&])IDX=(\d)+/, '$1IDX='+idx);
	else {
		if ( document.URL.indexOf('?') == -1 )
			location.href = document.URL + '?IDX=' + idx;
		else
			location.href = document.URL + '&IDX=' + idx;
	}
}

function view4Search(idx)
{
	if ( document.URL.search(/([\?|&])IDX4SEARCH=(\d)+/) != -1 ) 
		location.href = document.URL.replace(/([\?|&])IDX4SEARCH=(\d)+/, '$1IDX4SEARCH='+idx);
	else {
		if ( document.URL.indexOf('?') == -1 )
			location.href = document.URL + '?IDX4SEARCH=' + idx;
		else
			location.href = document.URL + '&IDX4SEARCH=' + idx;
	}
}

function checkMovePage()
{
	var target = arguments[0];
	

	var cookes = document.cookie.split("U_ID");

	if(cookes[1]!=undefined) //로그인 하였을때
	{
		if(cookes[1] == '=&U_PWD=&') //로그인 안햇을때
		{
			target = "/member/login.html";
		}
		
	}
	else 
	{
	    target = "/member/login.html";
	}

	location.replace(target);
}

function fontPlus()
{
	var font = parseInt(document.getElementById('bodyFont').cFont);
	
	if ( !font)  
		font = 3;
	
	font = font + 1;
	
	if ( font > 6 )
		font = 6;
			
	setFont(font);

}

function fontMinus()
{
	var font = parseInt(document.getElementById('bodyFont').cFont);
	
	
	if ( !font)  
		font = 3;
	
	font = font - 1;	
	
	if ( font < 1 )
		font = 1;
	
		
	setFont(font);

}

function setFont(n)
{
	document.getElementById('bodyFont').cFont = n;
	document.getElementById('bodyFont').className = 'article0' + n;
}

function imgResize()
{
	
	var obj = arguments[0];
	var nWidth = arguments[1];
	var nHeight = arguments[2];

	if ( obj.width > nWidth ) {
		obj.height = (obj.height * nWidth) / obj.width;
		obj.width = nWidth;
	}
	else if ( obj.height > nHeight ) {
		obj.width = (obj.width * nHeight) / obj.height;
		obj.height = nHeight;
	}
}

function imgResizeList()
{
	var objID = arguments[0];
	var nWidth = arguments[1];
	var nHeight = arguments[2];
	
	var lists = document.getElementsByName(objID);
	for ( var i=0; i < lists.length; i++ ) {
		imgResize(lists[i], nWidth, nHeight);	
	}
}
/** BOF END */

/** DreamW START */
<!--
function MM_swapImgRestore() {
	//v3.0
	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_preloadImages() {
	//v3.0
	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) {
	//v4.01
	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 && d.getElementById) x=d.getElementById(n);
		return x;
}

function MM_swapImage() {
	//v3.0
	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];
	}
}
//-->
/** DreamW END */

var roll = {
        eTable : null,
        eTbody : null,
        eTR : null,
        speed : 2000,
		temp : new Array(),
		e : function(){
			var ele = document.getElementById(arguments[0]);    
			return ele;
		},          

		move : function(){
			if ( !arguments.callee.tbody && arguments[0]) 
				arguments.callee.tbody = arguments[0];
				
			var eTbody = arguments.callee.tbody;
			var cloneTR = eTbody.firstChild.cloneNode(true);
			
			eTbody.removeChild(eTbody.firstChild);
			eTbody.appendChild(cloneTR);

			tid = setTimeout(roll.move,roll.speed);
		},

		start : function(){
			roll.eTable = roll.e("rollingArticle").childNodes(0);
			roll.eTbody = roll.eTable.childNodes(0);
			roll.eTR = roll.eTbody.childNodes;
			roll.move(roll.eTbody);
		}
};

function roll2()
{	
	if ( !arguments.callee.runner ) 
		arguments.callee.runner = document.getElementsByName('rollPhoto');
	
	if ( arguments.callee.timer )
		clearTimeout(arguments.callee.timer);
		
	var direction = arguments[0];
	
	var pos = 1;
	
	if ( !(!direction) )
		pos = direction;
	
	var displayPos = 0;
		
	var obj = arguments.callee.runner;
	
	if ( !(!obj) && obj.length > 0 ) {
		var isCheck = false;
		for ( var i=0; i < obj.length; i++ ) {
			
			if ( obj[i].style.display == 'block' ) { 
				obj[i].style.display = 'none';
				displayPos = i + pos;
				
				if ( displayPos < 0 )
					displayPos = obj.length-1;
				obj[(displayPos%obj.length)].style.display = 'block';
				imgResize(document.getElementsByName('rollPhotoImg')[(displayPos%obj.length)], 190, 130);
				isCheck = true;
				break;
			}
		}
		
		if ( !isCheck ) {
			obj[0].style.display = 'block';
			imgResize(document.getElementsByName('rollPhotoImg')[0], 190, 130);
		}
		
		if ( !direction )
			arguments.callee.timer = setTimeout(roll2, 5000);
	}
}


/** Other START */
function PopUp()
{
	var a = window.open('','','top=0, left=0, width=600, height=550, toolbar=0, directories=0, status=0, menubar=0, scrollbars=1, resizable=1');
	
	a.document.write("<BODY onselectstart = 'return false' oncontextmenu = 'return false'><table width='640' border='0' cellspacing='0' cellpadding='0'><tr><td><img src='http://www.cnews.co.kr/images/top_logo_s.gif' width='140' height='40'></td><td valign='bottom'><div align='right'></div></td></tr></table>"+document.getElementById("articleSpecView").innerHTML + "</BODY><script>window.print();</script>");
	var tbl = a.document.getElementsByTagName('TABLE');
	for ( var i=0; i < tbl.length; i++ ) {
		if ( tbl[i].getAttribute('idx') == '112' ) {
			tbl[i].parentNode.removeChild(tbl[i]);
			break;	
		}	
	}
	a.document.close();
	a.document.write(a.document.body.outerHTML);
}

function random_imglink(){

//var myimages="/images/banner/ma/top_banner.gif";
var myimages="/banner/panMA20081203.gif";
var ry=Math.floor(Math.random()*3);

	if (ry==0)
	{

		document.write("<a href='http://www.pk-metal.co.kr' target='_blank'><img src='"+myimages+"' border=0></a>");
	}
	else if(ry==1)
	{

	 document.write("<embed src='/images/banner/ma/autodesk1106_250x60_MA.swf' width='250' height='60'></embed>");
	}
	else if(ry==2)
	{

	 document.write("<embed src='/images/banner/ma/Mcore_ERP_banner_small.swf' width='250' height='60'></embed>");
	}
}


function random_imglink_full(){

//var myimages="/images/banner/mb/banner_001.gif";
var myimages="/banner/panMB20081203.gif";
var ry=Math.floor(Math.random()*3);

	if (ry==0)
	{

		document.write("<a href='http://www.pk-metal.co.kr' target='_blank'><img src='"+myimages+"' border=0></a>");
	}
	else if(ry==1)
	{

	 document.write("<embed src='/images/banner/mb/autodesk1113_440x65.swf' width='440' height='65'></embed>");
	}
	else if(ry==2)
	{

	 document.write("<embed src='/images/banner/mb/Duzon_banner_081117.swf' width='440' height='65'></embed>");
	}
}

function cc()
{
    
    location.href='/CNEWS/Login/LoginOut.aspx';

}




function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}




function mtr(n) {
    for(var i = 1; i < 3; i++) {
        obj = document.getElementById('mtr'+i);
        img = document.getElementById('mtr_button'+i);
        if ( n == i ) {
            obj.style.display = "block";
                        img.height = 22;
            img.src = "/images/tab"+i+"_on.gif";    
        } else {
            obj.style.display = "none";
                        img.height = 22;
            img.src = "/images/tab"+i+".gif";
        }
    }
}

function m1(n) {
    for(var i = 1; i < 7; i++) {
        obj = document.getElementById('m1'+i);
        img = document.getElementById('m1_button'+i);
        if ( n == i ) {
            obj.style.display = "block";
                        img.height = 28;
            img.src = "/images/m1_on"+i+".gif";    
        } else {
            obj.style.display = "none";
                        img.height = 28;
            img.src = "/images/m1_off"+i+".gif";
        }
    }
}

function m2(n) {
    for(var i = 1; i < 7; i++) {
        obj = document.getElementById('m2'+i);
        img = document.getElementById('m2_button'+i);
        if ( n == i ) {
            obj.style.display = "block";
                        img.height = 28;
            img.src = "/images/m2_on"+i+".gif";    
        } else {
            obj.style.display = "none";
                        img.height = 28;
            img.src = "/images/m2_off"+i+".gif";
        }
    }
}

function m3(n) {
    for(var i = 1; i < 7; i++) {
        obj = document.getElementById('m3'+i);
        img = document.getElementById('m3_button'+i);
        if ( n == i ) {
            obj.style.display = "block";
                        img.height = 28;
            img.src = "/images/m3_on"+i+".gif";    
        } else {
            obj.style.display = "none";
                        img.height = 28;
            img.src = "/images/m3_off"+i+".gif";
        }
    }
}

function m4(n) {
    for(var i = 1; i < 7; i++) {
        obj = document.getElementById('m4'+i);
        img = document.getElementById('m4_button'+i);
        if ( n == i ) {
            obj.style.display = "block";
                        img.height = 28;
            img.src = "/images/m4_on"+i+".gif";    
        } else {
            obj.style.display = "none";
                        img.height = 28;
            img.src = "/images/m4_off"+i+".gif";
        }
    }
}

function m5(n) {
    for(var i = 1; i < 7; i++) {
        obj = document.getElementById('m5'+i);
        img = document.getElementById('m5_button'+i);
        if ( n == i ) {
            obj.style.display = "block";
                        img.height = 28;
            img.src = "/images/m5_on"+i+".gif";    
        } else {
            obj.style.display = "none";
                        img.height = 28;
            img.src = "/images/m5_off"+i+".gif";
        }
    }
}


function m6(n) {
    for(var i = 1; i < 7; i++) {
        obj = document.getElementById('m6'+i);
        img = document.getElementById('m6_button'+i);
        if ( n == i ) {
            obj.style.display = "block";
                        img.height = 28;
            img.src = "/images/m6_on"+i+".gif";    
        } else {
            obj.style.display = "none";
                        img.height = 28;
            img.src = "/images/m6_off"+i+".gif";
        }
    }
}


function tm1(n) {
    for(var i = 1; i < 6; i++) {
        obj = document.getElementById('tm1'+i);
        img = document.getElementById('tm1_button'+i);
        if ( n == i ) {
            obj.style.display = "block";
                        img.height = 29;
            img.src = "/images/tab3_on"+i+".gif";    
        } else {
            obj.style.display = "none";
                        img.height = 29;
            img.src = "/images/tab3_off"+i+".gif";
        }
    }
}


function tm2(n) {    
	for(var i = 1; i < 7; i++) {        
		obj = document.getElementById('tm2'+i);        
		img = document.getElementById('tm2_button'+i);        
		if ( n == i ) {            
			obj.style.display = "block";                        
			img.height = 36;            
			img.src = "/images/customer/m"+i+"_on.gif";            
		} else {            
			obj.style.display = "none";                        
			img.height = 36;            
			img.src = "/images/customer/m"+i+".gif";        
			}    
		}
	} 
	




function keyEvent(){
	if(event.keyCode == 13){
		goSearch();
	}
}

function goSearch() {
    if(searchForm.txtSearch.value != "") {
		var strSearch = encodeURIComponent(searchForm.txtSearch.value);
		var strSection = encodeURIComponent(searchForm.txtSection.value);
		var strUrl = "/search/search_01.html?Search=" + strSearch + "&Section=" + strSection;
		location.href = strUrl;
	}
}

function goDSearch() {
    //if(searchForm.txtSearch.value != "") {
		var strSearch = encodeURIComponent(searchForm.txtSearch.value);
		location.href = "/search/search_02.html?Search=" + strSearch;
	//}
}

  
function GoScrap()
{
// alert(location.href);
// alert(document.cookie);


 var cookes = document.cookie.split("U_ID");

 if(cookes[1]!= undefined) //로그인 하였을때
 {
  if (confirm('스크랩 하시겠습니까?'))
  {
   var url = location.href.split("=");
   var idx = url[1];

	
   location.href = '/CNEWS/Member/MyScrap_Insert.aspx?idx='+idx;
   //parent.location.href = '
  }
  else
  {
   
  }
  
 }

 else if(cookes[1] == '=&U_PWD=&') //로그인 안햇을때
 {
  
  alert('로그인을 해주세요.');
  parent.location.href = '/member/login.html';
 }

 else if(cookes[1] == undefined) //로그인 안햇을때
 {
  alert("로그인 해주세요.");

  parent.location.href = '/member/login.html';
 }
 else
 {
  
  alert('로그인을 해주세요.');
  parent.location.href = '/member/login.html';
 }

}
/** Other END */



