// ÀÌ¹ÌÁö °íÁ¤ ½ºÅ©¸³Æ®
function ChgAniImgStatus(st,img)
{
	if(st=="stop"){
		document.execCommand('Stop');
		document.getElementById("aniImg").innerHTML = "<a href=\"javascript:ChgAniImgStatus();\"><img src=\"/images/button/btn_image_off.gif\"  alt='ÀÌ¹ÌÁö·Ñ¸µ' /></a>";
		return;
	}
	else{
		window.location.reload();
	}
}

// ÅÇ ¼±ÅÃ ½Ã ³ëÃâ ÀÌ¹ÌÁö º¯°æ
function view_tab( tab_no, status )
{
	if( status == "out" )
	{
		tab_no = pre_tab;
		pre_tab = tab_no;
	}
	for( i=1; i<6; i++ )
	{
		if( i == tab_no )
		{
			document.getElementById("tab_0"+i).src = "/images/common/best100_new_tab"+i+"_on.gif";
			document.getElementById("sub_tab_0"+i).style.display = "block";
		}
		else
		{
			document.getElementById("tab_0"+i).src = "/images/common/best100_new_tab"+i+"_off.gif";
			document.getElementById("sub_tab_0"+i).style.display = "none";
		}
	}	
}

// ¼±ÅÃÇÑ ÆäÀÌÁöÀÇ DIV³ëÃâ
var pre_num = 1;
function show_all( num, total, tab_no, logger )
{
	var start;
	var end;

	if( num == 11 )	// 10°³¾¿ º¸±â
	{
		if( tab_no == 1 || tab_no == 5 )
		{
			document.getElementById("page_area").style.display = "block";
			document.getElementById("best100_page").style.display = "block";
		}
		else
		{
			document.getElementById("best100_page").style.display = "block";
			document.getElementById("page_area").style.display = "block";
			document.getElementById("new_page_area").style.display = "none";
		}

		document.getElementById("img_all").src = "/images/button/btn_best100.gif";
		document.getElementById("btn_all").onclick = function()
		{
			show_all( 0, total, tab_no, logger );
		}
		document.getElementById("btn_all").onmousedown = function()
		{
			logger_mouse_down(logger+'_ÀüÃ¼»óÇ°º¸±â');
		}
		document.getElementById("btn_all").href = "#bookmark";
		page_num = num;
		order_mode = "part";
		show_all( pre_num, total, tab_no, logger );
	}
	else
	{
		if( num == 0 )	// 100°³ º¸±â
		{
			if( tab_no == 1 || tab_no == 5 )
			{
				document.getElementById("page_area").style.display = "none";
				document.getElementById("best100_page").style.display = "none";
			}
			else
			{
				document.getElementById("best100_page").style.display = "none";
				document.getElementById("page_area").style.display = "none";
				document.getElementById("new_page_area").style.display = "block";
			}
			document.getElementById("img_all").src = "/images/button/btn_best100_off.gif";
			document.getElementById("btn_all").onclick = function()
			{
				show_all( 11, total, tab_no, logger );
			}
			document.getElementById("btn_all").onmousedown = function()
			{
				logger_mouse_down(logger+'_10°³¾¿º¸±â');
			}
			document.getElementById("btn_all").href = "#";			
			order_mode = "all";
		}
		else
		{
			pre_num = num;
		}

		for( i=1; i<=total; i++ )
		{
			if( num == 0 || i == num )
			{
				if( i == num )
				{
					document.getElementById("p_img"+i).src = "/images/common/best100_p"+i+"_on.gif";
				}
				start = ( i * 10 ) - 9;
				end = i * 10;
				if( ( num == 0 && i == total ) || num == total )
				{
					end = total_cnt;
				}
				ins_image( start, end );
				document.getElementById("p_"+i).style.display = "block";
			}
			else
			{
				document.getElementById("p_img"+i).src = "/images/common/best100_p"+i+"_off.gif";
				document.getElementById("p_"+i).style.display = "none";
			}
		}
		page_num = num;
	}	
}

// ÆäÀÌÁö ÀÌµ¿
var page_num = 1;
function page_move( mode, total, tab_no, logger )
{
	if( mode == "pre" )	page_num--;
	else			page_num++;

	if( page_num == 0 )	page_num = total;
	if( page_num == (total + 1))	page_num = 1;

	show_all( page_num, total, tab_no, logger );	
}

// »óÇ°¿¡ ¸¶¿ì½º ¿À¹ö/¾Æ¿ô ½Ã, 'ÁÖ¹®ÇÏ±â/ÂòÇÏ±â' ¹öÆ° ³ëÃâ
function show_btn( mode, num )
{
	if( mode == "show" )
	{
		document.getElementById("btn_area_"+num).style.display = "block";
		document.getElementById("best_dt_"+num).className = "on";
	}
	else
	{
		document.getElementById("btn_area_"+num).style.display = "none";
		document.getElementById("best_dt_"+num).className = "";
	}
}

// »óÇ° ÀÌ¹ÌÁö ³Ö±â
function ins_image( start, end )
{
	for( var k=start; k<=end; k++ )
	{
		if( document.getElementById("img_area"+k).src.indexOf( "/images/common/best100_loading.gif" ) > -1 )
		{
			document.getElementById("img_area"+k).src = pd_img[k];
		}
	}
}

function go_url( tab_no, sub_no, v_mode )
{
	var url = "";
	var add_url = "";
	var add_etc = "";

	if( sub_no )
	{
		add_url = "&sub_no="+sub_no;
	}
	if( order_mode == "part" )
	{
		add_etc = "#bookmark";
	}
	if( tab_no == 2 || tab_no == 3 || tab_no == 4 )
	{
		add_url += "&v_mode="+v_mode;
	}

	url = "best100.php?tab_no="+tab_no+add_url+"&order_mode="+order_mode+add_etc;
	location.replace( url );
}


/* ¸ÞÀÎ ÆäÀÌÁö ¼îÇÎ¸ô º£½ºÆ® °ü·Ã ½ºÅ©¸³Æ® ½ÃÀÛ <2009. 10. 27. jhyoon Ãß°¡> */

// ¸ÞÀÎ ÆäÀÌÁö ¼îÇÎ¸ô º£½ºÆ® rolling
function move_mall_best()	
{
	auto_m_num++;
	if(auto_m_num>m_total)
	{
		auto_m_num = 1;
	}

	show_mall_best(auto_m_num);
}


// ¸ÞÀÎ ÆäÀÌÁö ¼îÇÎ¸ô º£½ºÆ® setting
function set_mall_best( tmp_num )	
{
	if( !tmp_num )
	{
		var i;
		var now = new Date();
		var tmpi = now.getSeconds();
		tmpi = (tmpi % m_total) + 1;
	}
	else
	{
		tmpi = tmp_num;
	}

	auto_m_num = tmpi;
	show_mall_best(tmpi);
	m_tid=setInterval("move_mall_best()",10000);
}

// ¸ÞÀÎ ÆäÀÌÁö ¼îÇÎ¸ô º£½ºÆ® ³ëÃâ
function show_mall_best( num, click_flag )	
{
	var pre_num;
	var next_num;

	auto_m_num = num;
	pre_num = num-1;
	next_num = num+1;

	if(num==1)
	{
		pre_num = m_total;
	}
	if(num==m_total)
	{
		next_num = 1;
	}

	for(i=1; i<m_total+1; i++)
	{
		if(i==num)
		{
			document.getElementById("mall_list"+i).style.display = "block";
		}
		else
		{
			document.getElementById("mall_list"+i).style.display = "none";
		}
	}

	document.getElementById("m_pre_btn").onclick = function()
	{
		show_mall_best(pre_num,"c");
	}
	document.getElementById("m_next_btn").onclick = function()
	{
		show_mall_best(next_num,"c");
	}

	if( click_flag )
	{
		clearInterval( m_tid );
		set_mall_best( num );
	}
}

/* ¸ÞÀÎ ÆäÀÌÁö ¼îÇÎ¸ô º£½ºÆ® °ü·Ã ½ºÅ©¸³Æ® ³¡  <2009. 10. 27. jhyoon Ãß°¡> */