//index.jsp
function showMenu(menuNo)
{
	Element.hide('index1');
	Element.hide('index2');
	Element.hide('index3');
	Element.show('index'+menuNo);
	
	$('menuBtn1').className = '';
	$('menuBtn2').className = '';
	$('menuBtn3').className = '';
	
	$('menuBtn'+menuNo).className = 'menu_b';
}

function changeVisible(n)
{
	Element.hide('div01');
	Element.hide('div02');
	Element.hide('div03');
	Element.show('div0'+n);
}

function changeDisplay(n)
{
	Element.hide('tp1');
	Element.hide('tp2');
	Element.hide('tp3');
	Element.show('tp'+n);
}

function printPage(popUrl)
{
	window.open(popUrl, 'printPop','width=620,height=700,resizable=yes,scrollbars=yes');
}

function login_confirm()
{
	if(confirm('·Î±×ÀÎÀ» ÇÏ¼Å¾ß ÇØ´ç ±ÛÀ» »èÁ¦ÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù. ·Î±×ÀÎÇÏ½Ã°Ú½À´Ï±î?'))
	{
		Login();
	}
}

function adminDelComment(seq)
{
	if(confirm('´ñ±ÛÀ» »èÁ¦ ÇÏ½Ã°Ú½À´Ï±î?'))
	{
		document.delForm.seq.value = seq;
		document.delForm.passwd.value = 'think_passwd';
		document.delForm.submit();
	}
}

function setNews(_title, _url)
{
	var mynews = '';
	if(getCookie('mynews') == '')
	{
		mynews = _title+'@@'+_url
	}
	else
	{
		mynews = getCookie('mynews');

		if(mynews.indexOf(_title) == -1)
		{
			var newsArr = mynews.split('||');
			if(newsArr.length >= 10)
			{
				mynews = '';
				for(var i = 0; i < 9; i ++)
				{
					if(i > 0) mynews += '||';
					mynews += newsArr[i];
				}
			}
			
			mynews = _title+'@@'+_url+'||'+mynews;
		}
	}

	setCookie('mynews',  mynews, 1);
	//setCookie('mynews', '', 1);
}

var newsArray = null;
function getNewsArray()
{
	var v = getCookie('mynews');
	if(v != ''){ newsArray = v.split('||'); }

	return newsArray
}


function getTitle(idx)
{
	return newsArray[idx].split('@@')[0];
}

function getUrl(idx)
{
	return newsArray[idx].split('@@')[1];
}


function openReadNews()
{
	Element.show('readNews');
	Element.hide('open_btn');
	Element.show('close_btn');
}

function closeReadNews()
{
	Element.hide('readNews');
	Element.hide('close_btn');
	Element.show('open_btn');
}

var selectedNews = '';
function now_news(flag)
{
	setCookie("tab_index", flag, 1);

	Element.hide('total_news');
	Element.hide('stock_news');
	Element.hide('item_news');

	if(flag == 1)
	{
		Element.show('total_news');
	}
	else if(flag == 2)
	{
		Element.show('stock_news');
	}
	else if(flag == 3)
	{
		Element.show('item_news');
	}

	var html = '';
	html = '<table width="220" border="0" cellspacing="0" cellpadding="0">';
	html += '<tr>';
		html += '<td width="1"><img src="http://img.thinkpool.com/nnews/right_tap_line.gif" width="1" height="25"></td>';
		html += '<td width="72" align="center" background="http://img.thinkpool.com/nnews/right_tap_'+(flag == 1 ? 'on' : 'un')+'.gif" style="padding-top:4">'+(flag == 1 ? '<strong>Á¾ ÇÕ</strong>' : '<span onMouseOver=now_news(1) style=cursor:Pointer;>Á¾ ÇÕ</span>')+'</td>';
		html += '<td width="1"><img src="http://img.thinkpool.com/nnews/right_tap_line.gif" width="1" height="25"></td>';
		html += '<td width="72" align="center" background="http://img.thinkpool.com/nnews/right_tap_'+(flag == 2 ? 'on' : 'un')+'.gif" style="padding-top:4">'+(flag == 2 ? '<strong>½Ã Àå</strong>' : '<span onMouseOver=now_news(2) style=cursor:Pointer;>½Ã Àå</span>')+'</td>';
		html += '<td width="1"><img src="http://img.thinkpool.com/nnews/right_tap_line.gif" width="1" height="25"></td>';
		html += '<td width="72" align="center" background="http://img.thinkpool.com/nnews/right_tap_'+(flag == 3 ? 'on' : 'un')+'.gif" style="padding-top:4">'+(flag == 3 ? '<strong>Á¾ ¸ñ</strong>' : '<span onMouseOver=now_news(3) style=cursor:Pointer;>Á¾ ¸ñ</span>')+'</td>';
		html += '<td width="1"><img src="http://img.thinkpool.com/nnews/right_tap_line.gif" width="1" height="25"></td>';
	html += '</tr>';
	html += '</table>';

	$('now_news_view').innerHTML = html;
}

var nowFontSz = 10; // À§ CSSÀÇ article°ú °°Àº Font Å©±â
var fontObj ;

function fontSz() {

	if (document.getElementById) fontObj = document.getElementById("fontSzArea").style ;
	else if (document.all) fontObj = document.all("fontSzArea").style ;

	// Font Resize
	if (arguments[0] == "-") {
		if (nowFontSz <= 9) return ;
		fontObj.fontSize = nowFontSz-1 + "pt" ;
		nowFontSz = eval(nowFontSz-1) ;
	} else if (arguments[0] == "+") {
		if (nowFontSz >= 16) return ;
		fontObj.fontSize = nowFontSz+1 + "pt" ;
		nowFontSz = eval(nowFontSz+1) ;
	}
}

function visibleCommentList()
{
	if(Element.visible('commentList'))
	{
		Element.show('show_btn');
		Element.hide('hide_btn');
		Element.hide('commentList');
		setCookie('comment_view',  'N', 1);
	}
	else
	{
		Element.hide('show_btn');
		Element.show('hide_btn');
		Element.show('commentList');

		setCookie('comment_view',  'Y', 1);
	}
}

function oepnComment()
{
	Element.show('commentList');
}

function closeComment()
{
	Element.hide('commentList');
}


function inputPassWD(seq)
{
	$('passwdWindow').style.left = (event.clientX - 400);
	$('passwdWindow').style.top = (document.body.scrollTop + event.clientY);
	document.delForm.seq.value = seq;
	Element.show('passwdWindow');
	$('ipasswd').focus();
}

function addComment()
{
	if(!$('writer').present())
	{
		alert("ÇÊ¸íÀ» ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
		$('writer').focus();
	}
	else if(document.f.passwd.value == '')
	{
		alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.');
		document.f.passwd.focus();
	}
	else if(!$('memo').present())
	{
		alert('³»¿ëÀ» ÀÔ·ÂÇØ ÁÖ¼¼¿ä.');
		$('memo').focus();
	}
	else
	{
		document.f.submit();
	}
}

function delComment()
{
	if(!$('ipasswd').present())
	{
		alert('ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.');
		$('ipasswd').focus();
	}
	else
	{
		document.delForm.passwd.value = $('ipasswd').getValue();
		document.delForm.submit();
	}
}

var sokboIndex = 0;
function sokboDisplay()
{
	if(sokboIndex < 5)
	{
		sokboIndex ++;
	}
	else
	{
		sokboIndex = 1;
	}

	Element.hide('sokbo1');
	Element.hide('sokbo2');
	Element.hide('sokbo3');
	Element.hide('sokbo4');
	Element.hide('sokbo5');
	Element.show('sokbo'+sokboIndex);
}

function interval_sokbo()
{
	sokboDisplay();
	setTimeout("interval_sokbo()", 7000);
}

	function makeHome(hid)
	{
		if(confirm('¹Ì´ÏÈ¨ÀÌ ¾ø½À´Ï´Ù. ¹Ì´ÏÈ¨À» °³¼³ÇÏ½Ã°Ú½À´Ï±î?'))
		{
			var pars = $H({loc:'makeHome',hid:hid,ran:Math.random()*1000}).toQueryString();
			new Ajax.Request('/MiniHome.do', {method:'get', parameters:pars, onComplete:makeHomeResult});
		}
	}
	
	function makeHomeResult(req)
	{
		var xml = req.responseXML;
		var result = xml.getElementsByTagName("result")[0].firstChild.nodeValue;
		if(result == 'success')
		{
			alert('¹Ì´ÏÈ¨ÀÌ °³¼³µÇ¾ú½À´Ï´Ù.\n¹Ì´ÏÈ¨À¸·Î ÀÌµ¿ÇÕ´Ï´Ù.');
			goMiniHome($('userid').getValue());
		}
		else if(result == 'fail')
		{
			alert('¹Ì´ÏÈ¨ °³¼³¿¡ ½ÇÆÐ ÇÏ¿´½À´Ï´Ù.');
		}
		else if(result == 'error')
		{
			alert('¹Ì´ÏÈ¨ °³¼³Áß ¿¡·¯°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù.');
		}
	}

	function goMiniHome(hid)
	{
		if(hid != '')
		{
			location.href="/MiniBbs.do?action=list&hid="+hid;
		}
	}

function news_scrap(sn, mcd)
{
	if($('userid').getValue() == '')
	{
		Login();
	}
	else
	{
		if($('isMiniHome').getValue() == 'false')
		{
			makeHome($('userid').getValue());
		}
		else
		{
			window.open('/minihome/popup/news_scrapPopup.jsp?sn='+sn+'&mcd='+mcd, 'news_scrap','width=400,height=335,resizable=no,scrollbars=no');
		}
	}
}

function issueMentVisible(n)
{
	if(Element.visible('view_ment'+n))
	{
		Element.hide('view_ment'+n);
		Element.show('modify_ment'+n);
	}
	else
	{
		Element.show('view_ment'+n);
		Element.hide('modify_ment'+n);
	}
}

var updateIssueMentFlag = false;
function updateIssueMent(n)
{
	if(updateIssueMentFlag)
	{
		alert('¿äÃ»Ã³¸® ÁøÇàÁßÀÔ´Ï´Ù...');
		return;
	}
	else if(confirm('ÇØ´ç ÀÌ½´ÀÇ Á¦¸ñÀ» ¼öÁ¤ÇÏ½Ã°Ú½À´Ï±î?'))
	{
		var pars = $H({issuement:$('issuement'+n).getValue(),issuenum_grp:$('issuenum_grp').getValue(),ran:Math.random()*1000}).toQueryString();
		updateIssueMentFlag = true;
		new Ajax.Request('/nnews/topissue/setIssueMent.jsp', {method:'post', parameters:pars, onComplete:updateIssueMentResult});
	}
}

function updateIssueMentResult(obj)
{
	updateIssueMentFlag = false;
	var xml = obj.responseXML;
	var result = xml.getElementsByTagName("result")[0].firstChild.nodeValue;

	if(result == 'success')
	{
		alert('¼öÁ¤µÇ¾ú½À´Ï´Ù.');
		document.location.reload();
	}
	else
	{
		alert('Ã³¸®Áß ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù.');
	}
}

var issueDeleteFlag = false;
function issueDelete(issuenum_grp)
{
	if(issueDeleteFlag)
	{
		alert('¿äÃ»Ã³¸® ÁøÇàÁßÀÔ´Ï´Ù...');
		return;
	}
	else if(confirm('ÀÌ½´¸¦ »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?'))
	{
		var pars = $H({issuenum_grp:issuenum_grp,ran:Math.random()*1000}).toQueryString();
		issueDeleteFlag = true;
		new Ajax.Request('/nnews/topissue/deleteIssue.jsp', {method:'post', parameters:pars, onComplete:deleteIssueResult});
	}
}

function deleteIssueResult(obj)
{
	issueDeleteFlag = false;
	var xml = obj.responseXML;
	var result = xml.getElementsByTagName("result")[0].firstChild.nodeValue;

	if(result == 'success')
	{
		document.location.href = "/nnews/?mcd=I1BA";
	}
	else
	{
		alert('Ã³¸®Áß ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù.');
	}
}

var updateIssueType = false;
function setIssueType(issuenum_grp, issue_type)
{
	if(updateIssueType)
	{
		alert('¿äÃ»Ã³¸® ÁøÇàÁßÀÔ´Ï´Ù...');
		return;
	}
	else if(confirm(issue_type == 'Y' ? 'ÁøÇàÁßÀÎ ÀÌ½´·Î Ãß°¡ÇÏ½Ã°Ú½À´Ï±î?' : 'ÁøÇàÁßÀÎ ÀÌ½´¿¡¼­ Á¦¿Ü ÇÏ½Ã°Ú½À´Ï±î?'))
	{
		var pars = $H({issuenum_grp:issuenum_grp,issue_type:issue_type,ran:Math.random()*1000}).toQueryString();
		updateIssueType = true;
		new Ajax.Request('/nnews/topissue/setIssueType.jsp', {method:'post', parameters:pars, onComplete:setIssueTypeResult});
	}
}

function setIssueTypeResult(obj)
{
	updateIssueType = false;
	var xml = obj.responseXML;
	var result = xml.getElementsByTagName("result")[0].firstChild.nodeValue;

	if(result == 'success')
	{
		document.location.reload();
	}
	else
	{
		alert('Ã³¸®Áß ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù.');
	}
}

var topIssueFlag = false;
var new_issuenum_grp;
function setTopIssue(issuenum, issuenum_grp)
{
	if(topIssueFlag)
	{
		alert('¿äÃ»Ã³¸® ÁøÇàÁßÀÔ´Ï´Ù...');
		return;
	}
	else if(confirm('Top ÀÌ½´·Î ÁöÁ¤ÇÏ½Ã°Ú½À´Ï±î?'))
	{
		new_issuenum_grp = issuenum;
		var pars = $H({issuenum:issuenum, issuenum_grp:issuenum_grp,ran:Math.random()*1000}).toQueryString();
		topIssueFlag = true;
		new Ajax.Request('/nnews/topissue/setTopIssue.jsp', {method:'post', parameters:pars, onComplete:setTopIssueResult});
	}
}

function setTopIssueResult(obj)
{
	topIssueFlag = false;
	var xml = obj.responseXML;
	var result = xml.getElementsByTagName("result")[0].firstChild.nodeValue;

	if(result == 'success')
	{
		document.location.href = "/nnews/?mcd=I1BA&issuenum_grp=" + new_issuenum_grp;
	}
	else
	{
		alert('Ã³¸®Áß ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù.');
	}
}


var exclusionFlag = false;
function exclusion(issuenum, issuenum_grp)
{
	if(exclusionFlag)
	{
		alert('¿äÃ»Ã³¸® ÁøÇàÁßÀÔ´Ï´Ù...');
		return;
	}
	else if(confirm('Á¦¿Ü ½ÃÅ°°Ú½À´Ï±î?'))
	{
		new_issuenum_grp = issuenum_grp;
		var pars = $H({issuenum:issuenum, issuenum_grp:issuenum_grp,ran:Math.random()*1000}).toQueryString();
		exclusionFlag = true;
		new Ajax.Request('/nnews/topissue/exclusion.jsp', {method:'post', parameters:pars, onComplete:exclusionResult});
	}
}

function exclusionResult(obj)
{
	exclusionFlag = false;
	var xml = obj.responseXML;
	var result = xml.getElementsByTagName("result")[0].firstChild.nodeValue;

	if(result == 'success')
	{
		document.location.href = "/nnews/?mcd=I1BA&issuenum_grp=" + new_issuenum_grp;
	}
	else
	{
		alert('Ã³¸®Áß ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù.');
	}
}


var deleteNewsFlag = false;
function deleteNews(sn)
{
	if(deleteNewsFlag)
	{
		alert('¿äÃ»Ã³¸® ÁøÇàÁßÀÔ´Ï´Ù...');
		return;
	}
	else if(confirm('»èÁ¦ÇÏ½Ã¸é ½ÇÁ¦ DB¿¡¼­ ÇØ´ç ±â»ç°¡ »èÁ¦ µË´Ï´Ù.\n\n»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?'))
	{
		var pars = $H({sn:sn,ran:Math.random()*1000}).toQueryString();
		deleteNewsFlag = true;
		new Ajax.Request('/nnews/deleteNews.jsp', {method:'post', parameters:pars, onComplete:deleteNewsResult});
	}
}

function deleteNewsResult(obj)
{
	deleteNewsFlag = false;
	var xml = obj.responseXML;
	var result = xml.getElementsByTagName("result")[0].firstChild.nodeValue;

	if(result == 'success')
	{
		alert('»èÁ¦µÇ¾ú½À´Ï´Ù.');
		document.location.reload();
	}
	else
	{
		alert('Ã³¸®Áß ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù.');
	}
}


var viewIndex = 1;
function photoView(flag)
{
	var oldViewIndex = viewIndex;
	if(flag == '+')
	{
		if(viewIndex < 4)
		{
			viewIndex ++;
		}
		else
		{
			viewIndex = 1;
		}
	}
	else if(flag == '-')
	{
		if(viewIndex > 1)
		{
			viewIndex --;
		}
		else
		{
			viewIndex = 4;
		}
	}
	
	Element.hide('photo1');
	Element.hide('photo2');
	Element.hide('photo3');
	Element.hide('photo4');
	//Element.hide('photo5');
	Element.show('photo'+viewIndex);
}

function interval()
{
	photoView('+');
	setTimeout("interval()", 7000);
}

var photoIndex = 0;//getCookie("photoIndex");

//if(photoIndex == '' || photoIndex == 'undefined') photoIndex = 1;

function viewPhoto(flag)
{
	if(flag == '+')
	{
		if(photoIndex < 4)
		{
			photoIndex ++;
		}
		else
		{
			photoIndex = 1;
		}
	}
	else
	{
		if(photoIndex > 1)
		{
			photoIndex --;
		}
		else
		{
			photoIndex = 4;
		}
	}

	//setCookie("photoIndex", photoIndex, 1);

	Element.hide('photo1');
	Element.hide('photo2');
	Element.hide('photo3');
	Element.hide('photo4');
	//Element.hide('photo5');
	//Element.hide('photo6');

	Element.show('photo'+photoIndex);
}

function photoInterval()
{
	viewPhoto('+');
	setTimeout("photoInterval()", 5000);
}



function getPhotoNews()
{
	var pars = $H({ran:Math.random()*1000}).toQueryString();
	new Ajax.Request('/nnews/photoNews.jsp', {method:'post', parameters:pars, onComplete:photoNewsResult});
}

function mainPhotoNews()
{
	var pars = $H({ran:Math.random()*1000}).toQueryString();
	new Ajax.Request('/nnews/photoNews.jsp', {method:'post', parameters:pars, onComplete:photoNewsMainResult});
}

var xlink_url = null;
var xsubject = null;
var xbig_img = null;
var xsmall_img = null;
var xmain_img = null;


function photoNewsResult(transfer)
{
	var xml = transfer.responseXML;

	var idx = parseInt(Math.random() * 3);

	xlink_url = xml.getElementsByTagName("link_url");
	xsubject = xml.getElementsByTagName("subject");
	xbig_img = xml.getElementsByTagName("big_img");
	xsmall_img = xml.getElementsByTagName("small_img");

	var htmlText = "";


		/*htmlText = "<table width='240' border='0' cellspacing='0' cellpadding='0'> " +
		"		<tr>  " +
		"			<td width='240' height='3'><img src='http://img.thinkpool.com/nnews/main_right_box04.gif' width='240' height='3'></td> " +
		"		</tr> " +
		"		<tr>  " +
		"			<td align='center' background='http://img.thinkpool.com/nnews/main_right_box02.gif'  style='padding:5 0 7 0'> " +
		"				<table width='224' height='185' border='0' cellpadding='0' cellspacing='0'> " +
		"				<tr> " +
		"					<td align='center' valign='middle'><a href='"+xlink_url[idx].firstChild.nodeValue+"' id='photo_link'><img src='"+xbig_img[idx].firstChild.nodeValue+"' id='photo_background' border='0' align='absmiddle'></a></td> " +
		"				</tr> " +
		"				<tr> " +
		"					<td height='25' align='center' bgcolor='#000000' style='padding-top:5'><span style='text-overflow:ellipsis;overflow:hidden;width=230px'><nobr><strong><font color='#CCCCCC'><span id='photo_title'>"+xsubject[idx].firstChild.nodeValue+"<span></font></strong></nobr></span></td> " +
		"				</tr> " +
		"				</table> " +
		"			</td> " +
		"		</tr> " +
		"		<tr> " +
		"			<td align='center' background='http://img.thinkpool.com/nnews/main_right_box02.gif' ><img src='http://img.thinkpool.com/nnews/main_right_box05.gif' width='240' height='3'></td> " +
		"		</tr> " +
		"		<tr> " +
		"			<td align='center' background='http://img.thinkpool.com/nnews/main_right_box02.gif' > " +
		"				<table border='0' cellpadding='1' cellspacing='6'> " +
		"				<tr> " +
		"					<td align='center' bgcolor='D8D8D8'><a href='"+xlink_url[0].firstChild.nodeValue+"'><img src='"+xsmall_img[0].firstChild.nodeValue+"' width='68' height='47' border='0' onMouseOver='changePhoto(0)'></a></td> " +
		"					<td align='center' bgcolor='D8D8D8'><a href='"+xlink_url[1].firstChild.nodeValue+"'><img src='"+xsmall_img[1].firstChild.nodeValue+"' width='68' height='47' border='0' onMouseOver='changePhoto(1)'></a></td> " +
		"					<td align='center' bgcolor='D8D8D8'><a href='"+xlink_url[2].firstChild.nodeValue+"'><img src='"+xsmall_img[2].firstChild.nodeValue+"' width='68' height='47' border='0' onMouseOver='changePhoto(2)'></a></td> " +
		"				</tr> " +
		"				</table> " +
		"			</td> " +
		"		</tr> " +
		"		<tr>  " +
		"			<td height='2'><img src='http://img.thinkpool.com/nnews/main_right_box03.gif' width='240' height='2'></td> " +
		"		</tr> " +
		"		</table> ";*/
	htmlText = "        <table width='240' border='0' cellspacing='0' cellpadding='0'> " +
	"        <tr>  " +
	"            <td width='240' height='3' colspan='3'><img src='http://img.thinkpool.com/nnews/main_right_box04.gif' width='240' height='3'></td> " +
	"        </tr> " +
	"        <tr>  " +
	"            <td colspan='3' align='center' background='http://img.thinkpool.com/nnews/main_right_box02.gif'  style='padding:5 0 4 0'>  " +
	"                <table width='224' height='156' border='0' cellpadding='0' cellspacing='0'> " +
	"                <tr>  " +
	"                    <td align='center'><a href='"+xlink_url[idx].firstChild.nodeValue+"' id='photo_link'><img src='"+xbig_img[idx].firstChild.nodeValue+"' id='photo_background' border='0' align='absmiddle'></a></td> " +
	"                </tr> " +
	"                <tr>  " +
	"                    <td align='center' valign='bottom' style='padding-top:7'><nobr style='text-overflow:ellipsis;overflow:hidden;width=230px'><strong><font color='#333333'><span id='photo_title'>"+xsubject[idx].firstChild.nodeValue+"<span></font></strong></nobr></td> " +
	"                </tr> " +
	"                </table> " +
	"            </td> " +
	"        </tr> " +
	"        <tr>  " +
	"            <td colspan='3' align='center' background='http://img.thinkpool.com/nnews/main_right_box02.gif' ><img src='http://img.thinkpool.com/nnews/main_right_box05.gif' width='240' height='3'></td> " +
	"        </tr> " +
	"        <tr>  " +
	"            <td align='center' background='http://img.thinkpool.com/nnews/main_right_box02.gif'>  " +
	"                <table width='100%' border='0' cellspacing='0' cellpadding='0'> " +
	"                <tr>  " +
	"                    <td style='padding-left:1'><img src='http://img.thinkpool.com/nnews/icon_arr04.gif' width='10' height='23'  onClick='newsmainPhoto.prev();' style='cursor:Pointer;'></td> " +
	"                    <td width='95%' align='center'>  " +
	"                        <table border='0' cellpadding='0' cellspacing='2' id='mainphoto1'> " +
	"                        <tr>  " +
	"                            <td align='center'><div style='padding:2px;border:#D8D8D8 1px solid' id='ph0'><a href='"+xlink_url[0].firstChild.nodeValue+"'><img src='"+xsmall_img[0].firstChild.nodeValue+"' width='60' border='0' onMouseOver='changePhoto(0)'></a></div></td> " +
	"                            <td align='center'><div style='padding:2px;border:#D8D8D8 1px solid' id='ph1'><a href='"+xlink_url[1].firstChild.nodeValue+"'><img src='"+xsmall_img[1].firstChild.nodeValue+"' width='60' border='0' onMouseOver='changePhoto(1)'></a></div></td> " +
	"                            <td align='center'><div style='padding:2px;border:#990000 2px solid' id='ph2'><a href='"+xlink_url[2].firstChild.nodeValue+"'><img src='"+xsmall_img[2].firstChild.nodeValue+"' width='60' border='0' onMouseOver='changePhoto(2)'></a></div></td> " +
	"                        </tr> " +
	"                        </table> " +
	"                        <table border='0' cellpadding='0' cellspacing='2' id='mainphoto2' style='display:none;'> " +
	"                        <tr>  " +
	"                            <td align='center'><div style='padding:2px;border:#D8D8D8 1px solid' id='ph3'><a href='"+xlink_url[3].firstChild.nodeValue+"'><img src='"+xsmall_img[3].firstChild.nodeValue+"' width='60' border='0' onMouseOver='changePhoto(3)'></a></div></td> " +
	"                            <td align='center'><div style='padding:2px;border:#D8D8D8 1px solid' id='ph4'><a href='"+xlink_url[4].firstChild.nodeValue+"'><img src='"+xsmall_img[4].firstChild.nodeValue+"' width='60' border='0' onMouseOver='changePhoto(4)'></a></div></td> " +
	"                            <td align='center'><div style='padding:2px;border:#990000 2px solid' id='ph5'><a href='"+xlink_url[5].firstChild.nodeValue+"'><img src='"+xsmall_img[5].firstChild.nodeValue+"' width='60' border='0' onMouseOver='changePhoto(5)'></a></div></td> " +
	"                        </tr> " +
	"                        </table> " +
	"                    </td> " +
	"                    <td align='right' style='padding-right:1'><img src='http://img.thinkpool.com/nnews/icon_arr05.gif' width='10' height='23' onClick='newsmainPhoto.next();' style='cursor:Pointer;'></td> " +
	"                </tr> " +
	"                </table> " +
	"            </td> " +
	"        </tr> " +
	"        <tr>  " +
	"            <td height='2' colspan='3'><img src='http://img.thinkpool.com/nnews/main_right_box03.gif' width='240' height='2'></td> " +
	"        </tr> " +
	"        </table>";

	$('photo_news').innerHTML = htmlText;
	newsmainPhoto = new photoViewer({id:'mainphoto',idx:1,size:2,time:5000});
	newsmainPhoto.start();
}

var newsmainPhoto = null;

function changePhoto(idx)
{
	$('photo_link').href = xlink_url[idx].firstChild.nodeValue;
	$('photo_title').innerText = xsubject[idx].firstChild.nodeValue;
	$('photo_background').src = xbig_img[idx].firstChild.nodeValue;
	
	$('ph0').style.cssText = 'padding:2px;border: #9B9B9B 1px solid;';
	$('ph1').style.cssText = 'padding:2px;border: #9B9B9B 1px solid;';
	$('ph2').style.cssText = 'padding:2px;border: #9B9B9B 1px solid;';
	$('ph3').style.cssText = 'padding:2px;border: #9B9B9B 1px solid;';
	$('ph4').style.cssText = 'padding:2px;border: #9B9B9B 1px solid;';
	$('ph5').style.cssText = 'padding:2px;border: #9B9B9B 1px solid;';
	$('ph'+idx).style.cssText = 'padding:2px;border: #990000 2px solid;';
}


function photoNewsMainResult(transfer)
{
	var xml = transfer.responseXML;

	xlink_url = xml.getElementsByTagName("link_url");
	xsubject = xml.getElementsByTagName("subject");
	xbig_img = xml.getElementsByTagName("big_img");
	xsmall_img = xml.getElementsByTagName("small_img");
	xmain_img = xml.getElementsByTagName("main_img");

	var htmlText = "";
	htmlText =
	"				<table width='170' border='0' cellspacing='0' cellpadding='3' bgcolor='#E6E6E6'> " +
	"				<tr>  " +
	"					<td ><a href='"+xlink_url[0].firstChild.nodeValue+"' id='photo_link'><img src='"+xmain_img[0].firstChild.nodeValue+"' width='170' height='118' border='0' id='photo_img'></a></td> " +
	"				</tr> " +
	"				<tr>  " +
	"					<td height='20' align='center' style='padding-top:3'><span style='text-overflow:ellipsis;overflow:hidden;width=150px'><nobr><b><span  id='photo_title'>"+xsubject[0].firstChild.nodeValue+"</span></b></nobr></span></td> " +
	"				</tr> " +
	"				<tr>  " +
	"					<td align='center'> " +
	"						<table border='0' cellpadding='0' cellspacing='0'> " +
	"						<tr>  " +
	"							<td align='center' style='border: #990000 2px solid;' id='over0'><a href='"+xlink_url[0].firstChild.nodeValue+"'><img src='"+xsmall_img[0].firstChild.nodeValue+"' width='52' border='0' onMouseOver='changePhotoMain(0)'></a></td> " +
	"							<td width='5' align='center' >&nbsp;</td> " +
	"							<td align='center' style='border: #9B9B9B 1px solid;' id='over1'><a href='"+xlink_url[1].firstChild.nodeValue+"'><img src='"+xsmall_img[1].firstChild.nodeValue+"' width='52' border='0' onMouseOver='changePhotoMain(1)'></a></td> " +
	"							<td width='5' align='center'>&nbsp;</td> " +
	"							<td align='center'style='border: #9B9B9B 1px solid;' id='over2'><a href='"+xlink_url[2].firstChild.nodeValue+"'><img src='"+xsmall_img[2].firstChild.nodeValue+"' width='52' border='0' onMouseOver='changePhotoMain(2)'></a></td> " +
	"						</tr> " +
	"						</table> " +
	"					</td> " +
	"				</tr> " +
	"				</table>";

	$('main_news_photo').innerHTML = htmlText;
}

function changePhotoMain(idx)
{
	$('photo_title').innerText = xsubject[idx].firstChild.nodeValue;
	$('photo_img').src = xmain_img[idx].firstChild.nodeValue;
	$('photo_link').href = xlink_url[idx].firstChild.nodeValue;
	
	$('over0').style.cssText = 'border: #9B9B9B 1px solid;';
	$('over1').style.cssText = 'border: #9B9B9B 1px solid;';
	$('over2').style.cssText = 'border: #9B9B9B 1px solid;';
	$('over'+idx).style.cssText = 'border: #990000 2px solid;';
}

var mainPhotoIndex = 0;
var mainListIndex = 1;
var changeFlag = true;
function mainInterval()
{
	if(xsubject != null && changeFlag)
	{
		SubView('+');
		changePhotoMain(mainPhotoIndex);
		if(2 > mainPhotoIndex)
		{
			mainPhotoIndex ++;
		}
		else
		{
			mainPhotoIndex = 0;
		}
	}
	setTimeout("mainInterval()", 5000);
}

function setChangeFlag(changeFlag)
{
	this.changeFlag = changeFlag;
}

function findCode()
{
	if($('ncode').getValue() == "" || $('ncode').getValue() == "Á¾¸ñ°Ë»ö")
	{
		alert("Á¾¸ñ¸í or Á¾¸ñÄÚµå¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
		$('ncode').clear();
		$('ncode').focus();
		return;
	}
	else if($('nhiddencode').getValue() == "")
	{
		alert("Á¾¸ñ¸í ¶Ç´Â Á¾¸ñÄÚµå¸¦ Á¤È®ÇÏ°Ô ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
		$('ncode').focus();
		return;
	}
	else
	{
		window.open('/itemanal/news/newsView.jsp?mcd=Q0&code='+$('nhiddencode').getValue());
	}
}

function findNews()
{
	if($('sMcd').getValue() == 'I1AAA')
	{
		var frm = document.tfrm;
		if(frm.keyword.value == '')
		{
			alert('°Ë»ö¾î¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.');
			return;
		}
		else
		{
			frm.method = 'get';
			frm.action = '/nnews/';
			frm.submit();
		}
	}
	else
	{
		findCode();
	}
}

function findNewsKeyListener(event)
{
	if(event.keyCode == 13)
	{
		findNews();
	}
}

var autoComple = null;
function changeSMode(mcd)
{
	if(mcd == 'I1AAA')
	{
		Element.show('I1AAA');
		Element.hide('I1ACA');
	}
	else
	{
		Element.hide('I1AAA');
		Element.show('I1ACA');
		if(autoComple == null ) autoComple = new autocomplete({_inputBox:'ncode', _hiddenBox:'nhiddencode',_viewSize:6, _function:findCode});//hidden box¿¡ Á¾¸ñÄÚµå¸¦ ³Ñ°Ü ¹ÞÀ»°æ¿ì
	}
}

function clearBox(n)
{
	if(n == 1 && $('ncode').getValue() == 'Á¾¸ñ°Ë»ö')
	{
		$('ncode').clear();
	}
	else if(n == 2)
	{
		if($('ncode').getValue() == '')
		{
			$('ncode').value = 'Á¾¸ñ°Ë»ö';
		}
	}
}

var __over = false;
function setOver(flag)
{
	__over = flag;
}
function indexInterval()
{
	if(!__over)
	{
		SubView('+');
	}
	
	setTimeout("indexInterval()", 5000);
}
var viewIndex = 1;
function SubView(flag)
{
	if(flag == '+')
	{
		if(viewIndex < 4)
		{
			viewIndex ++;
		}
		else
		{
			viewIndex = 1;
		}
	}
	else
	{
		if(viewIndex > 1)
		{
			viewIndex --;
		}
		else
		{
			viewIndex = 4;
		}
	}

	Element.hide('T_1');
	Element.hide('T_2');
	Element.hide('T_3');
	Element.hide('T_4');
	Element.show('T_'+viewIndex);
}



//ÅØ½ºÆ® ½ºÅ©·Ñ¸µ ÀÚ¹Ù½ºÅ©¸³Æ® ul(2008.07.21)
function textScroll(scroll_el_id) {
    this.objElement = document.getElementById(scroll_el_id);
    this.objElement.style.position = 'relative';
    this.objElement.style.overflow = 'hidden';

    this.objLi = this.objElement.getElementsByTagName('li');
    this.height = this.objElement.offsetHeight; // li ¿¤¸®¸ÕÆ®°¡ ¿òÁ÷ÀÌ´Â ³ôÀÌ(¿ÜºÎ¿¡¼­ º¯°æ°¡´É)
    this.num = this.objLi.length; // li ¿¤¸®¸ÕÆ®ÀÇ ÃÑ °¹¼ö
    this.totalHeight = this.height*this.num; // ÃÑ ³ôÀÌ
    this.scrollspeed = 2; // ½ºÅ©·ÑµÇ´Â px
    this.objTop = new Array(); // °¢ liÀÇ top À§Ä¡¸¦ ÀúÀå
    this.timer = null;
    
    for(var i=0; i<this.num; i++){
        this.objLi[i].style.position = 'absolute';
        this.objTop[i] = this.height*i;
        this.objLi[i].style.top = this.objTop[i]+"px";
    }
}

textScroll.prototype.move = function(){
    for(var i=0; i<this.num; i++) {
        this.objTop[i] = this.objTop[i] - this.scrollspeed;
        this.objLi[i].style.top = this.objTop[i]+"px";
    }
    if(this.objTop[0]%this.height == 0){
        this.jump();
    }else{
        clearTimeout(this.timer);
        this.timer = setTimeout(this.name+".move()",50);
    }
}

textScroll.prototype.jump = function(){
    for(var i=0; i<this.num; i++){
        if(this.objTop[i] == this.height*(-2)){
            this.objTop[i] = this.objTop[i] + this.totalHeight;
            this.objLi[i].style.top = this.objTop[i]+"px";
        }
    }
    clearTimeout(this.timer);
    this.timer = setTimeout(this.name+".move()",3000);
}

textScroll.prototype.start = function() {
    this.timer = setTimeout(this.name+".move()",3000);
}

var photoViewer = Class.create();

photoViewer.prototype = {
	initialize:function(options)
	{
		this.id = options.id;
		this.idx = options.idx;
		this.size = options.size;
		this.time = options.time;
		this.flag = '+';
	},
	
	prev:function()
	{
		this.flag = '-';
		this.hide();
		if(this.idx > 1)
		{
			this.idx --;
		}
		else
		{
			this.idx = this.size;
		}
		
		Element.show(this.id + this.idx);
	},
	
	next:function()
	{
		this.flag = '+';
		this.hide();
		if(this.idx < this.size)
		{
			this.idx ++;
		}
		else
		{
			this.idx = 1;
		}
		
		Element.show(this.id + this.idx);
	},
	
	hide:function()
	{
		for(var i = 1; i <= this.size; i ++)
		{
			Element.hide(this.id + i);
		}
	},
	
	start:function()
	{
		setTimeout(this.start.bind(this), this.time);
		if(this.flag == '+')
		{
			this.next();
		}
		else
		{
			this.prev();
		}
		
		if(this.id == 'mainphoto')
		{
			var cPosition  = (this.idx - 1) * 3;
			cPosition = parseInt(Math.random() * 3) + cPosition;
			changePhoto(cPosition);
		}
	}
}

//Æ÷Åä´º½º ¸ÞÀÎ _ ¿À´ÃÀÇ Æ÷Åä´º½º
var selectObj = null;
function setTodayPhoto(n)
{
	selectObj = $('photonews'+n);
	selectObj.style.cssText = 'border:2px solid #990000;';
}

function goTodayPhoto(n, sn)
{
	var obj = $('photonews'+n);
	if(selectObj == null)
	{
		obj.style.cssText = 'border:2px solid #990000;';
		selectObj = obj;
	}
	else
	{
		selectObj.style.cssText = 'border:2px solid #FFFFFF;';
		obj.style.cssText = 'border:2px solid #990000;';
		selectObj = obj;
	}
	
	var pars = $H({sn:sn, ran:Math.random()*1000}).toQueryString();
	new Ajax.Request('/nnews/common/getTodayPhotoNews.jsp', {method:'get', parameters:pars, onComplete:todayPhotoResult});
}

var imgPath = 'http://files.thinkpool.com/nnews/t_photo/thumb220x150_';
var tlink = '/nnews/?mcd=I1EE&sn=';

function todayPhotoResult(data)
{
	var xml = data.responseXML;
	var sn = xml.getElementsByTagName("sn")[0].firstChild.nodeValue;
	var title = xml.getElementsByTagName("title")[0].firstChild.nodeValue;
	var content = xml.getElementsByTagName("content")[0].firstChild.nodeValue;
	var name = xml.getElementsByTagName("name")[0].firstChild.nodeValue;
	var fname = xml.getElementsByTagName("fname")[0].firstChild.nodeValue;
	
	$('tlink1').href = tlink + sn;
	$('tlink2').href = tlink + sn;
	$('tlink3').href = tlink + sn;
	$('tlink4').href = tlink + sn;
	$('timg').src = (imgPath + fname);
	$('tcontent').innerHTML = content;
	$('ttitle').innerText = title;
	$('tname').innerText = name;
}

function deleteTodayPhoto(sn)
{
	if(confirm('»èÁ¦ ÇÏ½Ã°Ú½À´Ï±î?'))
	{
		OpenPublic('/nnews/common/inc_news_admin_t_photo_delete.jsp?reload=Y&sn=' + sn,'bbs', 50, 50,'no','no');
	}
}