var article_font=10;	// ±â»ç º¸±â default font size
var comment_flage="0";	// ÄÚ¸àÆ® ÀÔ·ÂÃ¢ »óÅÂ 0 : hidden 1: show »óÅÂ
var cmt_status=0;		// ÄÚ¸àÆ® »èÁ¦½Ã Æä½º¿öµå »óÅÂ 0 : hidden 1 : show »óÅÂ
var comment_id="";
var seq = 0;

seq=(Math.floor(Math.random()*100));

function rolling_banner(){
	var banner=seq%(middle_banner.length);
	if(middle_banner[banner].lastIndexOf("swf")>2){
		banner="<embed id=\"topBanner\" src=\"/banner/"+middle_banner[banner]+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"445\" height=\"60\" wmode=\"transparent\"></embed>";
	}else{
		banner="<a href=\""+middle_banner_herf[banner]+"\" id=\"rollingHref1\"><img id=\"rollingImg1\" src=\"/banner/"+middle_banner[banner]+"\" width=\"428\" height=\"56\" border=\"0\"></a>";
	}
	document.write(banner);
}

function topRandomBanner(){
	switch(seq%2) {
		case 0:	// ÇàÀÚºÎ
			document.write("<EMBED src=\"/banner/mogaha_445_60.swf\" quality=\"high\" bgcolor=\"#FFFFFF\"  WIDTH=\"445\" HEIGHT=\"60\" NAME=\"h_0710_445_60\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED>");
			break;
		default:	// ÃâÆÇ±¹
			document.write("<EMBED src=\"http://www.seoul.co.kr/banner/book_445_60.swf\" quality=\"high\" bgcolor=\"#FFFFFF\"  WIDTH=\"445\" HEIGHT=\"60\" NAME=\"h_0710_445_60\" ALIGN=\"\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=\"http://www.macromedia.com/go/getflashplayer\"></EMBED>");
			break;
	}
}

function rolling_banner2(){
	banerSeq=seq%2;
	document.getElementById("rollingImg2").src='/banner/'+middle_banner2[banerSeq];
	document.getElementById("rollingHref2").href=middle_banner_herf2[banerSeq];
}

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_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];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  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 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_showHideLayers() { //v6.0
  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 go_photo_news()
{
	counter=count-1;
	if(counter==-1)
		counter = cplogo_img.length-1;
	document.location = image_href[counter];
}

//count = Math.round(Math.random() * (cplogo_img.length-2));

//////////////////////////////////////////////////////////

function add_zero(number)
{
	if(number<10)
		number="0"+number;
	return number;
}

function now_date()
{
	var now = new Date();

	var day = now.getDay();
	var date = now.getDate();
		date = add_zero(date);
	var month = now.getMonth()+1;
	    month = add_zero(month);
	var year = now.getFullYear();
	var days = new Array();
		days[0] = "ìí";
		days[1] = "êÅ";
		days[2] = "ûý";
		days[3] = "â©";
		days[4] = "ÙÊ";
		days[5] = "ÐÝ";
		days[6] = "÷Ï";

	document.write(year+"."+month+"."+date+" "+days[day]);
}


function search()
{

	if(src_form.keyword.value==""){
		location.href='http://search.seoul.co.kr/';
		return;
	}

	//alert("°Ë»ö ¿£Áø Á¡°ËÁß ÀÔ´Ï´Ù.");
    document.src_form.submit();
	//return;
}

function entercheck_form()
{
	if(event.keyCode ==13) 
	   { 
		   search();
		   event.keyCode = '';
	   }
}

// ÀÌ¹ÌÁö ¹Ì¸® loding ½ÃÄÑÁÖ´Â ÇÔ¼ö
function preload()
{
	if (!document.images) return;
	var ar = new Array();
	var arguments = preload.arguments;
	for (var i = 0; i < arguments.length; i++)
	{
		ar[i] = new Image();
		ar[i].src = "/images/icon_s/",arguments[i];
	}
}


// ±â»ç ÆùÆ®»çÀÌÁî Á¶Àý +
function inc_font()
{
	article_font+=1;
	if(article_font>16) article_font=16;
	article_content.style.fontSize=article_font+"pt";
	return true;
}

// ±â»ç ÆùÆ®»çÀÌÁî Á¶Àý -
function dec_font()
{
	article_font-=1;
	if(article_font<8) article_font=8;
	article_content.style.fontSize=article_font+"pt";
	return true;
}

//ÇÁ¸°Æ® popup
function print_article(id)
{
	window.open("/news/seoul_print.php?id="+id,'q','menubar=0,resizable=0,scrollbars=yes,width=550,height=700,left='+(screen.width - 900)+', top=10');
}

//¸ÞÀÏ º¸³»±â popup
function send_mail(id)
{
	window.open("/news/send_mail.php?id="+id,'q','menubar=0,resizable=0,scrollbars=no,width=400,height=500,left='+(screen.width -800)+', top=10');
}

function login(){
	var top = screen.height/2 - 210/2;
	var left = screen.width/2 - 438/2;
	document.location='http://www.seoul.co.kr/member/login.php?loc='+document.location;
	//window.open("http://db.seoul.co.kr/member/popupLogin.html","login","menubar=0,resizable=0,scrollbars=no,width=438,height=210,left="+left+",top="+top);
}

/* Æ÷Åä/¸¸Æò ÅÇ */
function showTogglePM(tab){
	for(var i=1;i<=2;i++){
		if(i==tab)
			eval("document.getElementById('pmTab"+i+"').style.display='';");
		else 
			eval("document.getElementById('pmTab"+i+"').style.display='none';");
	}
}

/* °í½Ã ÅÇ */
function showToggleGosi(tab){
	for(var i=1;i<=3;i++){
		if(i==tab)
			eval("document.getElementById('gosiTab"+i+"').style.display='';");
		else 
			eval("document.getElementById('gosiTab"+i+"').style.display='none';");
	}
}

/* Æ¯ÆÄ¿ø,³×Æ¼Áð Ä®·³ */
function showToggleReporter(tab){
	for(var i=1;i<3;i++){
		if(i==tab)
			eval("document.getElementById('reporterTab"+i+"').style.display='';");
		else 
			eval("document.getElementById('reporterTab"+i+"').style.display='none';");
	}
}

/* ¸¹ÀÌº» ´º½º */
function showToggleHitTab(tab){
	for(var i=1;i<4;i++){
		if(i==tab) {
			document.getElementById('hitTab'+i).style.display='';
		}
		else {
			document.getElementById('hitTab'+i).style.display='none';
		}
	}
}

/* µ¿¹°/·Îº¿ */
function showToggleAnimalrobotTab(tab){
	for(var i=1;i<3;i++){
		if(i==tab)
			eval("document.getElementById('animalrobotTab"+i+"').style.display='';");
		else 
			eval("document.getElementById('animalrobotTab"+i+"').style.display='none';");
	}
}

/* ¿ìÁÖ/¿¬±¸ */
function spaceresearchTab(tab){
	for(var i=1;i<3;i++){
		if(i==tab)
			eval("document.getElementById('spaceresearchTab"+i+"').style.display='';");
		else 
			eval("document.getElementById('spaceresearchTab"+i+"').style.display='none';");
	}
}

/* Æ÷Åä´º½º */
function showTogglePhotonewsTab(tab){
	for(var i=1;i<6;i++){
		if(i==tab)
			eval("document.getElementById('photonewsTab"+i+"').style.display='';");
		else 
			eval("document.getElementById('photonewsTab"+i+"').style.display='none';");
	}
}


/* ¼±µ¥ÀÌ ¼­¿ï »çÁø, Ãß¾ïÀÇ »çÁø, Ç¥Áö ÅÇ */
function showToggleSunday(tab){
	for(var i=1;i<=3;i++){
		if(i==tab)
			eval("document.getElementById('sundayTab"+i+"').style.display='';");
		else 
			eval("document.getElementById('sundayTab"+i+"').style.display='none';");
	}
}



function showToggleSamtohLife(tab){
	for(var i=1;i<=2;i++){
		if(i==tab)
			eval("document.getElementById('SamtohLifeTab"+i+"').style.display='';");
		else 
			eval("document.getElementById('SamtohLifeTab"+i+"').style.display='none';");
	}
}

function showToggleReportBlog(tab){
	for(var i=1;i<=2;i++){
		if(i==tab)
			eval("document.getElementById('reportBlogTab"+i+"').style.display='';");
		else 
			eval("document.getElementById('reportBlogTab"+i+"').style.display='none';");
	}
}

// ÅõÇ¥ °á°úÃ¢ ÇÔ¼ö
function pollResult(pollid){
	var w = 475;
	var h = 280;
	// »õÃ¢À» È­¸é Áß¾Ó¿¡...
	var left = screen.width/2 - w/2 ;
	var top = screen.height/2 - h/2 ;

	window.open("/community/result_poll.php?pollid="+pollid,"pollresult","left="+left+",top="+top+",width="+w+",height="+h+",menubar=no,status=no,scrollbars=yes");
}

function openiBrowser(date,page){
	var top = screen.height/2 - 690/2;
	var left = screen.width/2 - 910/2;
	window.open("http://backup.seoul.co.kr/ipqserver/new_ebook2.php?date="+date+"&page="+page,"ibrowser","width=910,height=690,top="+top+",left="+left+",scrollbars=no,menubars=no,status=no");
}

function popPhoto(id){
	var top = 100;
	var left = screen.width/2 - 336/2;
	window.open('http://www.seoul.co.kr/photo/popPhoto.php?idx='+id,'photo',"width=336,height=450,top="+top+",left="+left+",scrollbars=yes,menubars=no,status=no");
}

// Advertisement Open Popup Windows
function getCookie(name){
	var nameOfCookie = name + "=";
	var x = 0;
	while(x <= document.cookie.length){
		var y = (x + nameOfCookie.length);
		if(document.cookie.substring(x,y) == nameOfCookie){
			if((endOfCookie=document.cookie.indexOf(";", y)) == -1)
				endOfCookie = document.cookie.length;
			return unescape(document.cookie.substring(y, endOfCookie));
		}
		x = document.cookie.indexOf(" ", x) + 1;
		if(x == 0)
			break;
	}
	return "";
} 

function open_pop1(){
	if(getCookie("kdaily_0503") != "done")
	{
		//window.open("/news/pop/notice.html",'q','menubar=0,resizable=1,scrollbars=no,width=340,height=271,left='+(screen.width -510)+', top=10');
		//window.open("/banner/popup/pop1.html",'q','menubar=0,resizable=1,scrollbars=no,width=310,height=255,left=365, top=10');
	}
}

function open_pop(){
    if(getCookie("kdaily_0604") != "done"){
        //window.open("/banner/popup/pop.html",'q','menubar=0,resizable=0,scrollbars=no,width=310,height=271,left=10, top=10');
	//	window.open("http://www.seoul.co.kr/banner/banner/popup/pop.html",'qyuioploi','menubar=0,resizable=0,scrollbars=no,width=310,height=271,left=10, top=10');
//window.open("/banner/popup/pop.html",'q','menubar=0,resizable=0,scrollbars=no,width=310,height=311,left=10, top=10');
//window.open("/news/pop/pop.html",'r','menubar=0,resizable=1,scrollbars=no,width=343,height=555,left='+(screen.width -900)+', top=10');
//window.open("/banner/popup/pop.html",'r','menubar=0,resizable=1,scrollbars=no,width=310,height=485,left=10, top=10');
//window.open("/banner/popup/pop.html",'r','menubar=0,resizable=0,scrollbars=no,width=310,height=270,left=10, top=10');
//window.open("/banner/popup/pop.html",'r','menubar=0,resizable=1,scrollbars=no,width=310,height=386,left=10, top=10');
//window.open("/banner/popup/pop.html",'r','menubar=0,resizable=1,scrollbars=no,width=310,height=478,left=10, top=10');
    }
}

function initTab(){
	if(document.getElementById("pmTab1")){
		ranNum=((Math.floor(Math.random()*100))%2)+1;
		showTogglePM(ranNum);
	}

	if(document.getElementById("gosiTab1")){
		ranNum=((Math.floor(Math.random()*100))%3)+1;
		showToggleGosi(ranNum);
	}

	if(document.getElementById("reporterTab1")){
		ranNum=(seq%2)+1;
		showToggleReporter(ranNum);
	}
}
